Move magic words used for fields type into special variable.

This commit is contained in:
Michal Čihař
2003-02-24 11:15:07 +00:00
parent f1bdfe2334
commit c49e25f092
3 changed files with 78 additions and 55 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2003-02-24 Michal Cihar <nijel@users.sourceforge.net>
* tbl_change.php3, tbl_replace_fields.php3: Move magic words used for
fields type into special variable. Fixes #647689.
2003-02-23 Marc Delisle <lem9@users.sourceforge.net> 2003-02-23 Marc Delisle <lem9@users.sourceforge.net>
### 2.4.0 released ### 2.4.0 released

View File

@@ -268,7 +268,9 @@ for ($i = 0; $i < $fields_cnt; $i++) {
break; break;
} }
?> ?>
<td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>><?php echo $type; ?></td> <td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>>
<?php echo $type; ?>
</td>
<?php <?php
echo "\n"; echo "\n";
@@ -388,7 +390,8 @@ for ($i = 0; $i < $fields_cnt; $i++) {
?> ?>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?> <?php echo $backup_field . "\n"; ?>
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$foreign$" id="field_<?php echo $i; ?>_1" /> <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="foreign" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" />
<select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3"> <select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
<option value=""></option> <option value=""></option>
<?php <?php
@@ -426,7 +429,8 @@ for ($i = 0; $i < $fields_cnt; $i++) {
$enum_cnt = count($enum); $enum_cnt = count($enum);
?> ?>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$enum$" /> <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="enum" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
<?php <?php
echo "\n" . ' ' . $backup_field; echo "\n" . ' ' . $backup_field;
@@ -494,7 +498,8 @@ for ($i = 0; $i < $fields_cnt; $i++) {
?> ?>
<td bgcolor="<?php echo $bgcolor; ?>"> <td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?> <?php echo $backup_field . "\n"; ?>
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$set$" /> <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="set" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
<select name="field_<?php echo md5($field); ?>[]" size="<?php echo $size; ?>" multiple="multiple" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3"> <select name="field_<?php echo md5($field); ?>[]" size="<?php echo $size; ?>" multiple="multiple" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
<?php <?php
echo "\n"; echo "\n";
@@ -532,7 +537,8 @@ for ($i = 0; $i < $fields_cnt; $i++) {
} }
echo "\n"; echo "\n";
?> ?>
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$protected$" /> <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="protected" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
<?php <?php
} else if ($is_blob) { } else if ($is_blob) {
echo "\n"; echo "\n";

View File

@@ -56,61 +56,74 @@
if (!$check_stop) { if (!$check_stop) {
// f i e l d v a l u e i n t h e f o r m // f i e l d v a l u e i n t h e f o r m
if (isset($fields_type[$key])) $type = $fields_type[$key];
else $type = '';
switch (strtolower($val)) { switch (strtolower($val)) {
case 'null': case 'null':
break; break;
case '$enum$': case '':
// if we have an enum, then construct the value switch ($type) {
$f = 'field_' . md5($key); case 'enum':
if (!empty($$f)) { // if we have an enum, then construct the value
$val = implode(',', $$f); $f = 'field_' . md5($key);
if ($val == 'null') { if (!empty($$f)) {
// void $val = implode(',', $$f);
} else { if ($val == 'null') {
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'"; // void
} } else {
} else { $val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
$val = "''"; }
} } else {
break; $val = "''";
case '$set$': }
// if we have a set, then construct the value break;
$f = 'field_' . md5($key); case 'set':
if (!empty($$f)) { // if we have a set, then construct the value
$val = implode(',', $$f); $f = 'field_' . md5($key);
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'"; if (!empty($$f)) {
} else { $val = implode(',', $$f);
$val = "''"; $val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
} } else {
break; $val = "''";
case '$foreign$': }
// if we have a foreign key, then construct the value break;
$f = 'field_' . md5($key); case 'foreign':
if (!empty($$f)) { // if we have a foreign key, then construct the value
$val = implode(',', $$f); $f = 'field_' . md5($key);
if ($val == 'null') { if (!empty($$f)) {
// void $val = implode(',', $$f);
} else { if ($val == 'null') {
$val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'"; // void
} } else {
} else { $val = "'" . PMA_sqlAddslashes(urldecode($val)) . "'";
$val = "''"; }
} } else {
break; $val = "''";
case '$protected$': }
// here we are in protected mode (asked in the config) break;
// so tbl_change has put this special value in the case 'protected':
// fields array, so we do not change the field value // here we are in protected mode (asked in the config)
// but we can still handle field upload // so tbl_change has put this special value in the
// fields array, so we do not change the field value
// but we can still handle field upload
// garvin: when in UPDATE mode, do not alter field's contents. When in INSERT // garvin: when in UPDATE mode, do not alter field's contents. When in INSERT
// mode, insert empty field because no values were submitted. // mode, insert empty field because no values were submitted.
if (isset($fieldlist)) { if (isset($fieldlist)) {
$val = "''"; $val = "''";
} else { } else {
unset($val); unset($val);
} }
break;
default:
if (get_magic_quotes_gpc()) {
$val = "'" . str_replace('\\"', '"', $val) . "'";
} else {
$val = "'" . PMA_sqlAddslashes($val) . "'";
}
break;
}
break; break;
default: default:
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {