| version 1.56, 2003/03/18 00:52:59 |
version 1.57, 2003/03/19 01:03:49 |
|
|
| * http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.55 2003/03/17 19:30:44 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.56 2003/03/18 00:52:59 nepto Exp $ */ |
| |
|
| /* phpMyEdit intro {{{ */ |
/* phpMyEdit intro {{{ */ |
| /* |
/* |
|
|
| if ($this->add_operation() || $this->change_operation()) { |
if ($this->add_operation() || $this->change_operation()) { |
| $required_ar = array(); |
$required_ar = array(); |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| if ($this->displayed[$k] && $this->fdd[$k]['required']) { |
if ($this->displayed[$k] && $this->fdd[$k]['required'] |
| |
&& ! $this->readonly($k) && ! $this->hidden($k)) { |
| $required_ar[] = $k; |
$required_ar[] = $k; |
| if (isset($this->fdd[$k]['regex']['js'])) { |
if (isset($this->fdd[$k]['regex']['js'])) { |
| /* TODO: Use a javascript regex to validate it */ |
/* TODO: Use a javascript regex to validate it */ |
| Line 813 function phpMyEdit_form_control(theForm) |
|
| Line 814 function phpMyEdit_form_control(theForm) |
|
| if (! $this->displayed[$k]) { |
if (! $this->displayed[$k]) { |
| continue; |
continue; |
| } |
} |
| echo '<tr class="',$this->getCSSclass('row', '', true),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('row', '', 'next'),'">',"\n"; |
| echo '<td class="',$this->getCSSclass('key', '', true),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
echo '<td class="',$this->getCSSclass('key', '', true),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
| echo '<td class="',$this->getCSSclass('value', '', true),'">'."\n"; |
echo '<td class="',$this->getCSSclass('value', '', true),'">'."\n"; |
| $css_class_name = $this->getCSSclass('input', '', true); |
$css_class_name = $this->getCSSclass('input', '', true); |
| Line 910 function phpMyEdit_form_control(theForm) |
|
| Line 911 function phpMyEdit_form_control(theForm) |
|
| if (! $this->displayed[$k]) { |
if (! $this->displayed[$k]) { |
| continue; |
continue; |
| } |
} |
| echo '<tr class="',$this->getCSSclass('row', '', true),'">'."\n"; |
echo '<tr class="',$this->getCSSclass('row', '', 'next'),'">'."\n"; |
| echo '<td class="',$this->getCSSclass('key', '', true),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
echo '<td class="',$this->getCSSclass('key', '', true),'">',$this->fdd[$k]['name'],'</td>',"\n"; |
| /* There are two possibilities of readonly fields handling: |
/* There are two possibilities of readonly fields handling: |
| 1. Display plain text |
1. Display plain text |
| Line 933 function phpMyEdit_form_control(theForm) |
|
| Line 934 function phpMyEdit_form_control(theForm) |
|
| if (! $this->displayed[$k]) { |
if (! $this->displayed[$k]) { |
| continue; |
continue; |
| } |
} |
| echo '<tr class="',$this->getCSSclass('row', '', true),'">'."\n"; |
echo '<tr class="',$this->getCSSclass('row', '', 'next'),'">'."\n"; |
| echo '<td class="',$this->getCSSclass('key', '', true),'">',$this->fdd[$k]['name'].'</td>'."\n"; |
echo '<td class="',$this->getCSSclass('key', '', true),'">',$this->fdd[$k]['name'].'</td>'."\n"; |
| if ($this->password($k)) { |
if ($this->password($k)) { |
| echo '<td class="',$this->getCSSclass('value', '', true),'">'; |
echo '<td class="',$this->getCSSclass('value', '', true),'">'; |
| Line 1047 function phpMyEdit_form_control(theForm) |
|
| Line 1048 function phpMyEdit_form_control(theForm) |
|
| */ |
*/ |
| function getCSSclass($name, $position = '', $dividor = '', $postfix = '') /* {{{ */ |
function getCSSclass($name, $position = '', $dividor = '', $postfix = '') /* {{{ */ |
| { |
{ |
| static $div_idx = 0; |
static $div_idx = -1; |
| $elements = array($this->css['prefix'], $name); |
$elements = array($this->css['prefix'], $name); |
| if ($this->page_type && $this->css['page_type']) { |
if ($this->page_type && $this->css['page_type']) { |
| $elements[] = $this->page_type; |
$elements[] = $this->page_type; |
| Line 1056 function phpMyEdit_form_control(theForm) |
|
| Line 1057 function phpMyEdit_form_control(theForm) |
|
| $elements[] = $position; |
$elements[] = $position; |
| } |
} |
| if ($dividor && $this->css['dividor']) { |
if ($dividor && $this->css['dividor']) { |
| $elements[] = $div_idx; |
if ($dividor === 'next') { |
| $div_idx++; |
$div_idx++; |
| if ($this->css['dividor'] > 0 && $div_idx >= $this->css['dividor']) { |
if ($this->css['dividor'] > 0 && $div_idx >= $this->css['dividor']) { |
| $div_idx = 0; |
$div_idx = 0; |
| |
} |
| } |
} |
| |
$elements[] = $div_idx; |
| } |
} |
| if ($postfix) { |
if ($postfix) { |
| $elements[] = $postfix; |
$elements[] = $postfix; |
| Line 1838 function phpMyEdit_form_control(theForm) |
|
| Line 1841 function phpMyEdit_form_control(theForm) |
|
| .$this->qfn.$this->cgi['persist']); |
.$this->qfn.$this->cgi['persist']); |
| echo '">',$this->labels['Clear'],'</a></td>',"\n"; |
echo '">',$this->labels['Clear'],'</a></td>',"\n"; |
| echo '<td class="',$css_class_name,'" colspan="',$this->num_fields_displayed,'">'; |
echo '<td class="',$css_class_name,'" colspan="',$this->num_fields_displayed,'">'; |
| echo $this->labels['Sorted By'],':',join(', ', $sort_fields_w),'</td></tr>',"\n"; |
echo $this->labels['Sorted By'],': ',join(', ', $sort_fields_w),'</td></tr>',"\n"; |
| } |
} |
| |
|
| /* |
/* |
| Line 1883 function phpMyEdit_form_control(theForm) |
|
| Line 1886 function phpMyEdit_form_control(theForm) |
|
| while ((!$fetched && ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) != false) |
while ((!$fetched && ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) != false) |
| || ($fetched && $row != false)) { |
|| ($fetched && $row != false)) { |
| $fetched = false; |
$fetched = false; |
| echo '<tr class="',$this->getCSSclass('row', '', true),'">',"\n"; |
echo '<tr class="',$this->getCSSclass('row', '', 'next'),'">',"\n"; |
| if ($sys_cols) { |
if ($sys_cols) { |
| $key_rec = $row['qf'.$this->key_num]; |
$key_rec = $row['qf'.$this->key_num]; |
| $qviewStr = $qpviewStr . '&rec='.$key_rec; |
$qviewStr = $qpviewStr . '&rec='.$key_rec; |
| Line 2164 function phpMyEdit_form_control(theForm) |
|
| Line 2167 function phpMyEdit_form_control(theForm) |
|
| |
|
| function do_add_record() /* {{{ */ |
function do_add_record() /* {{{ */ |
| { |
{ |
| // Before trigger |
// Preparing query |
| if (isset($this->triggers['insert']['before'])) { |
|
| $ret = include($this->triggers['insert']['before']); |
|
| if ($ret == false) { |
|
| return false; |
|
| } |
|
| } |
|
| // Preparing queries |
|
| $query = ''; |
$query = ''; |
| $key_col_val = ''; |
$key_col_val = ''; |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| Line 2187 function phpMyEdit_form_control(theForm) |
|
| Line 2183 function phpMyEdit_form_control(theForm) |
|
| } |
} |
| } |
} |
| } |
} |
| $vals = array(); |
$vals_quoted = array(); |
| $vals_ori = array(); |
$values = array(); |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| if ($this->processed($k)) { |
if ($this->processed($k)) { |
| if ($this->readonly($k)) { |
if ($this->readonly($k)) { |
| Line 2196 function phpMyEdit_form_control(theForm) |
|
| Line 2192 function phpMyEdit_form_control(theForm) |
|
| } else { |
} else { |
| $fn = $this->get_cgi_var($this->fds[$k]); |
$fn = $this->get_cgi_var($this->fds[$k]); |
| } |
} |
| $vals_ori[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn; |
$values[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn; |
| $vals[$k] = addslashes($this->encode($this->fdd[$k],$vals_ori[$this->fds[$k]])); |
$vals_quoted[$k] = addslashes($this->encode($this->fdd[$k],$values[$this->fds[$k]])); |
| $vals[$k] = "'".$vals[$k]."'"; |
$vals_quoted[$k] = "'".$vals_quoted[$k]."'"; |
| |
} |
| |
} |
| |
// Before trigger |
| |
if (isset($this->triggers['insert']['before'])) { |
| |
$ret = include($this->triggers['insert']['before']); |
| |
if ($ret == false) { |
| |
return false; |
| } |
} |
| } |
} |
| // Real query (no additional query in this method) |
// Real query (no additional query in this method) |
| $query .= ') VALUES ('.join(',',$vals).')'; // ) |
$query .= ') VALUES ('.join(',',$vals_quoted).')'; // ) |
| $res = $this->myquery($query, __LINE__); |
$res = $this->myquery($query, __LINE__); |
| $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added']; |
$this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added']; |
| if (! $res) { |
if (! $res) { |
| Line 2210 function phpMyEdit_form_control(theForm) |
|
| Line 2213 function phpMyEdit_form_control(theForm) |
|
| } |
} |
| // Notify list |
// Notify list |
| if (@$this->notify['insert'] || @$this->notify['all']) { |
if (@$this->notify['insert'] || @$this->notify['all']) { |
| $this->email_notify(false, $vals_ori); |
$this->email_notify(false, $values); |
| } |
} |
| // Note change in log table |
// Note change in log table |
| if ($this->logtable) { |
if ($this->logtable) { |
| Line 2219 function phpMyEdit_form_control(theForm) |
|
| Line 2222 function phpMyEdit_form_control(theForm) |
|
| .' VALUES (NOW(), "%s", "%s", "insert", "%s", "%s", "", "", "%s")', |
.' VALUES (NOW(), "%s", "%s", "insert", "%s", "%s", "", "", "%s")', |
| $this->logtable, addslashes($this->get_server_var('REMOTE_USER')), |
$this->logtable, addslashes($this->get_server_var('REMOTE_USER')), |
| addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb), |
addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb), |
| addslashes($key_col_val), addslashes(serialize($vals_ori))); |
addslashes($key_col_val), addslashes(serialize($values))); |
| $this->myquery($query, __LINE__); |
$this->myquery($query, __LINE__); |
| } |
} |
| // After trigger |
// After trigger |
| Line 2229 function phpMyEdit_form_control(theForm) |
|
| Line 2232 function phpMyEdit_form_control(theForm) |
|
| return false; |
return false; |
| } |
} |
| } |
} |
| return false; |
return true; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function do_change_record() /* {{{ */ |
function do_change_record() /* {{{ */ |
| Line 2414 function phpMyEdit_form_control(theForm) |
|
| Line 2417 function phpMyEdit_form_control(theForm) |
|
| $i++; |
$i++; |
| } |
} |
| $body .= "\n--\r\n"; // \r is needed for signature separating |
$body .= "\n--\r\n"; // \r is needed for signature separating |
| $body .= "phpMyEdit - instant MySQL table editor and code generator\n"; |
$body .= "phpMyEdit\ninstant MySQL table editor and code generator\n"; |
| $body .= "http://www.platon.sk/projects/phpMyEdit/\n"; |
$body .= "http://www.platon.sk/projects/phpMyEdit/\n"; |
| $subject = @$this->notify['prefix'].$subject.' '.$this->db.'.'.$this->tb; |
$subject = @$this->notify['prefix'].$subject.' '.$this->db.'.'.$this->tb; |
| $subject = trim($subject); // just for sure |
$subject = trim($subject); // just for sure |
| Line 2729 function phpMyEdit_form_control(theForm) |
|
| Line 2732 function phpMyEdit_form_control(theForm) |
|
| !isset($this->css['prefix']) && $this->css['prefix'] = 'pme'; |
!isset($this->css['prefix']) && $this->css['prefix'] = 'pme'; |
| !isset($this->css['page_type']) && $this->css['page_type'] = false; |
!isset($this->css['page_type']) && $this->css['page_type'] = false; |
| !isset($this->css['position']) && $this->css['position'] = true; |
!isset($this->css['position']) && $this->css['position'] = true; |
| |
!isset($this->css['dividor']) && $this->css['dividor'] = 2; |
| $this->css['dividor'] = intval(@$this->css['dividor']); |
$this->css['dividor'] = intval(@$this->css['dividor']); |
| // Navigation |
// Navigation |
| $this->navigation = @$opts['navigation']; |
$this->navigation = @$opts['navigation']; |