fixed bugs in function field name with special characters and no-parameter functions

This commit is contained in:
Loïc Chapeaux
2001-08-28 17:50:20 +00:00
parent ebf1d6e183
commit 6ec97b4ddf
2 changed files with 27 additions and 14 deletions

View File

@@ -140,7 +140,7 @@ for ($i = 0; $i < $fields_cnt; $i++) {
} else { } else {
?> ?>
<td> <td>
<select name="funcs[<?php echo $field; ?>]"> <select name="funcs[<?php echo urlencode($field); ?>]">
<option></option> <option></option>
<?php <?php
echo "\n"; echo "\n";

View File

@@ -57,7 +57,10 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
$valuelist = ''; $valuelist = '';
while (list($key, $val) = each($fields)) { while (list($key, $val) = each($fields)) {
if ($is_encoded) { if ($is_encoded) {
$key = urldecode($key); $encoded_key = $key;
$key = urldecode($key);
} else {
$encoded_key = urlencode($key);
} }
switch (strtolower($val)) { switch (strtolower($val)) {
@@ -114,16 +117,20 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
break; break;
} // end switch } // end switch
// No change for this column -> next column // No change for this column and no MySQL function is used -> next column
if (isset($fields_prev) && isset($fields_prev[urlencode($key)]) && empty($funcs[$key]) if (empty($funcs[$encoded_key])
&& ("'" . sql_addslashes(urldecode($fields_prev[urlencode($key)])) . "'" == $val)) { && isset($fields_prev) && isset($fields_prev[$encoded_key])
&& ("'" . sql_addslashes(urldecode($fields_prev[$encoded_key])) . "'" == $val)) {
continue; continue;
} }
else if (!empty($val)) { else if (!empty($val)) {
if (empty($funcs[$key])) { if (empty($funcs[$encoded_key])) {
$valuelist .= backquote($key) . ' = ' . $val . ', '; $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 { } else {
$valuelist .= backquote($key) . " = $funcs[$key]($val), "; $valuelist .= backquote($key) . ' = ' . $funcs[$encoded_key] . "($val), ";
} }
} }
} // end while } // end while
@@ -155,11 +162,14 @@ else {
$valuelist = ''; $valuelist = '';
while (list($key, $val) = each($fields)) { while (list($key, $val) = each($fields)) {
if ($is_encoded) { if ($is_encoded) {
$key = urldecode($key); $encoded_key = $key;
} $key = urldecode($key);
// the 'query' row is urlencoded in sql.php3 } else {
else if ($key == 'query') { $encoded_key = urlencode($key);
$val = urldecode($val); // the 'query' row is urlencoded in sql.php3
if ($key == 'query') {
$val = urldecode($val);
}
} }
$fieldlist .= backquote($key) . ', '; $fieldlist .= backquote($key) . ', ';
@@ -217,10 +227,13 @@ else {
break; break;
} // end switch } // end switch
if (empty($funcs[$key])) { if (empty($funcs[$encoded_key])) {
$valuelist .= $val . ', '; $valuelist .= $val . ', ';
} else if ($val == '\'\''
&& (ereg('^(NOW|CURDATE|CURTIME|UNIX_TIMESTAMP|RAND|USER|LAST_INSERT_ID)$', $funcs[$encoded_key]))) {
$valuelist .= $funcs[$encoded_key] . '(), ';
} else { } else {
$valuelist .= "$funcs[$key]($val), "; $valuelist .= $funcs[$encoded_key] . "($val), ";
} }
} // end while } // end while