| version 1.88, 2003/07/25 20:18:08 |
version 1.89, 2003/07/25 20:53:18 |
|
|
| * http://www.platon.sk/projects/phpMyEdit/ |
* http://www.platon.sk/projects/phpMyEdit/ |
| */ |
*/ |
| |
|
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.87 2003/07/24 12:45:28 nepto Exp $ */ |
/* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.88 2003/07/25 20:18:08 nepto Exp $ */ |
| |
|
| /* This is a generic table editing program. The table and fields to be |
/* This is a generic table editing program. The table and fields to be |
| edited are defined in the calling program. |
edited are defined in the calling program. |
| Line 2172 function phpMyEdit_form_control(theForm) |
|
| Line 2172 function phpMyEdit_form_control(theForm) |
|
| $key_col_val = ''; |
$key_col_val = ''; |
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| if ($this->processed($k)) { |
if ($this->processed($k)) { |
| $fd = $this->fds[$k]; |
|
| if ($fd == $this->key) { |
|
| $key_col_val = addslashes($fn); |
|
| } |
|
| if ($query == '') { |
|
| $query = 'INSERT INTO '.$this->tb.' ('.$fd; // ) |
|
| } else { |
|
| $query .= ','.$fd; |
|
| } |
|
| } |
} |
| } |
} |
| $vals_quoted = array(); |
$vals_quoted = array(); |
| $newvals = array(); |
$newvals = 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)) { |
| |
$fd = $this->fds[$k]; |
| if ($this->readonly($k)) { |
if ($this->readonly($k)) { |
| $fn = (string) @$this->fdd[$k]['default']; |
$fn = (string) @$this->fdd[$k]['default']; |
| } else { |
} else { |
| $fn = $this->get_cgi_var($this->fds[$k]); |
$fn = $this->get_cgi_var($this->fds[$k]); |
| } |
} |
| |
if ($fd == $this->key) { |
| |
$key_col_val = addslashes($fn); |
| |
} |
| |
if ($query == '') { |
| |
$query = 'INSERT INTO '.$this->tb.' ('.$fd; // ) |
| |
} else { |
| |
$query .= ','.$fd; |
| |
} |
| $newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn; |
$newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn; |
| $vals_quoted[$k] = addslashes($newvals[$this->fds[$k]]); |
$vals_quoted[$k] = addslashes($newvals[$this->fds[$k]]); |
| $vals_quoted[$k] = "'".$vals_quoted[$k]."'"; |
$vals_quoted[$k] = "'".$vals_quoted[$k]."'"; |
| Line 2248 function phpMyEdit_form_control(theForm) |
|
| Line 2248 function phpMyEdit_form_control(theForm) |
|
| for ($k = 0; $k < $this->num_fds; $k++) { |
for ($k = 0; $k < $this->num_fds; $k++) { |
| if ($this->processed($k) && !$this->readonly($k)) { |
if ($this->processed($k) && !$this->readonly($k)) { |
| $fd = $this->fds[$k]; |
$fd = $this->fds[$k]; |
| if ($fd == $this->key) { |
|
| $key_col_val = addslashes($this->get_cgi_var($fd)); |
|
| } |
|
| $fn = $this->get_cgi_var($fd); |
$fn = $this->get_cgi_var($fd); |
| $newValue = $newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn; |
$newValue = $newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn; |
| $newValue = addslashes($newValue); |
$newValue = addslashes($newValue); |
| Line 2305 function phpMyEdit_form_control(theForm) |
|
| Line 2302 function phpMyEdit_form_control(theForm) |
|
| .' VALUES (NOW(), "%s", "%s", "update", "%s", "%s", "%s", "%s", "%s")', |
.' VALUES (NOW(), "%s", "%s", "update", "%s", "%s", "%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($key), |
addslashes($this->rec), addslashes($key), |
| addslashes($oldvals[$key]), addslashes($newvals[$key])); |
addslashes($oldvals[$key]), addslashes($newvals[$key])); |
| $this->myquery($qry, __LINE__); |
$this->myquery($qry, __LINE__); |
| } |
} |
| Line 2322 function phpMyEdit_form_control(theForm) |
|
| Line 2319 function phpMyEdit_form_control(theForm) |
|
| |
|
| function do_delete_record() /* {{{ */ |
function do_delete_record() /* {{{ */ |
| { |
{ |
| // Preparing queries |
|
| for ($k = 0; $k < $this->num_fds; $k++) { |
|
| if ($this->processed($k)) { |
|
| if ($this->fds[$k] == $this->key) { |
|
| $key_col_val = addslashes($fn); |
|
| } |
|
| } |
|
| } |
|
| // Additional query |
// Additional query |
| $query = 'SELECT * FROM '.$this->tb.' WHERE ('.$this->key.' = ' |
$query = 'SELECT * FROM '.$this->tb.' WHERE ('.$this->key.' = ' |
| .$this->key_delim.$this->rec.$this->key_delim.')'; // ) |
.$this->key_delim.$this->rec.$this->key_delim.')'; // ) |
| Line 2364 function phpMyEdit_form_control(theForm) |
|
| Line 2353 function phpMyEdit_form_control(theForm) |
|
| .' VALUES (NOW(), "%s", "%s", "delete", "%s", "%s", "%s", "%s", "")', |
.' VALUES (NOW(), "%s", "%s", "delete", "%s", "%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($key), addslashes(serialize($oldvals))); |
addslashes($this->rec), addslashes($key), addslashes(serialize($oldvals))); |
| $this->myquery($query, __LINE__); |
$this->myquery($query, __LINE__); |
| } |
} |
| // After trigger |
// After trigger |