From 6ec97b4ddfaaf0345cad11e8455f017766c5712f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Tue, 28 Aug 2001 17:50:20 +0000 Subject: [PATCH] fixed bugs in function field name with special characters and no-parameter functions --- tbl_change.php3 | 2 +- tbl_replace.php3 | 39 ++++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/tbl_change.php3 b/tbl_change.php3 index cd5a72b47..c862eb469 100755 --- a/tbl_change.php3 +++ b/tbl_change.php3 @@ -140,7 +140,7 @@ for ($i = 0; $i < $fields_cnt; $i++) { } else { ?> - next column - if (isset($fields_prev) && isset($fields_prev[urlencode($key)]) && empty($funcs[$key]) - && ("'" . sql_addslashes(urldecode($fields_prev[urlencode($key)])) . "'" == $val)) { + // No change for this column and no MySQL function is used -> next column + if (empty($funcs[$encoded_key]) + && isset($fields_prev) && isset($fields_prev[$encoded_key]) + && ("'" . sql_addslashes(urldecode($fields_prev[$encoded_key])) . "'" == $val)) { continue; } else if (!empty($val)) { - if (empty($funcs[$key])) { + if (empty($funcs[$encoded_key])) { $valuelist .= backquote($key) . ' = ' . $val . ', '; + } else if ($val == '\'\'' + && (ereg('^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$', $funcs[$encoded_key]))) { + $valuelist .= backquote($key) . ' = ' . $funcs[$encoded_key] . '(), '; } else { - $valuelist .= backquote($key) . " = $funcs[$key]($val), "; + $valuelist .= backquote($key) . ' = ' . $funcs[$encoded_key] . "($val), "; } } } // end while @@ -155,11 +162,14 @@ else { $valuelist = ''; while (list($key, $val) = each($fields)) { if ($is_encoded) { - $key = urldecode($key); - } - // the 'query' row is urlencoded in sql.php3 - else if ($key == 'query') { - $val = urldecode($val); + $encoded_key = $key; + $key = urldecode($key); + } else { + $encoded_key = urlencode($key); + // the 'query' row is urlencoded in sql.php3 + if ($key == 'query') { + $val = urldecode($val); + } } $fieldlist .= backquote($key) . ', '; @@ -217,10 +227,13 @@ else { break; } // end switch - if (empty($funcs[$key])) { + if (empty($funcs[$encoded_key])) { $valuelist .= $val . ', '; + } else if ($val == '\'\'' + && (ereg('^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$', $funcs[$encoded_key]))) { + $valuelist .= $funcs[$encoded_key] . '(), '; } else { - $valuelist .= "$funcs[$key]($val), "; + $valuelist .= $funcs[$encoded_key] . "($val), "; } } // end while