From 56dd0cb360a5ae4245103688b13232db8f5df4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Fri, 17 Aug 2001 14:21:37 +0000 Subject: [PATCH] Fixed some encoding/decoding bugs --- tbl_addfield.php3 | 46 +++++++++++++------------- tbl_alter.php3 | 23 +++++++++---- tbl_change.php3 | 71 ++++++++++++++++++++++++++--------------- tbl_properties.inc.php3 | 19 +++++------ tbl_properties.php3 | 22 +++++++------ tbl_replace.php3 | 4 +-- 6 files changed, 110 insertions(+), 75 deletions(-) diff --git a/tbl_addfield.php3 b/tbl_addfield.php3 index f47bc3f40..ba5c4fbba 100755 --- a/tbl_addfield.php3 +++ b/tbl_addfield.php3 @@ -20,21 +20,21 @@ if (isset($submit)) { $query .= backquote($field_name[$i]) . ' ' . $field_type[$i]; if ($field_length[$i] != '' && !eregi('^(DATE|DATETIME|TIME|TINYBLOB|TINYTEXT|BLOB|TEXT|MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT)$', $field_type[$i])) { - if (get_magic_quotes_gpc()) { + if (get_magic_quotes_gpc()) { $query .= '(' . stripslashes($field_length[$i]) . ')'; - } else { + } else { $query .= '(' . $field_length[$i] . ')'; - } - } + } + } if ($field_attribute[$i] != '') { $query .= ' ' . $field_attribute[$i]; } if ($field_default[$i] != '') { - if (get_magic_quotes_gpc()) { + if (get_magic_quotes_gpc()) { $query .= ' DEFAULT \'' . sql_addslashes(stripslashes($field_default[$i])) . '\''; - } else { + } else { $query .= ' DEFAULT \'' . sql_addslashes($field_default[$i]) . '\''; - } + } } if ($field_null[$i] != '') { $query .= ' ' . $field_null[$i]; @@ -45,24 +45,24 @@ if (isset($submit)) { if ($after_field != '--end--') { // Only the first field can be added somewhere else than at the end - if ($i == 0) { - if ($after_field == '--first--') { - $query .= ' FIRST'; - } else { - if (get_magic_quotes_gpc()) { - $query .= ' AFTER ' . backquote(stripslashes(urldecode($after_field))); + if ($i == 0) { + if ($after_field == '--first--') { + $query .= ' FIRST'; + } else { + if (get_magic_quotes_gpc()) { + $query .= ' AFTER ' . backquote(stripslashes(urldecode($after_field))); } else { $query .= ' AFTER ' . backquote(urldecode($after_field)); - } - } - } else { - if (get_magic_quotes_gpc()) { - $query .= ' AFTER ' . backquote(stripslashes($field_name[$i-1])); - } else { - $query .= ' AFTER ' . backquote($field_name[$i-1]); - } - } - } + } + } + } else { + if (get_magic_quotes_gpc()) { + $query .= ' AFTER ' . backquote(stripslashes($field_name[$i-1])); + } else { + $query .= ' AFTER ' . backquote($field_name[$i-1]); + } + } + } $query .= ', ADD '; } // end for $query = ereg_replace(', ADD $', '', $query); diff --git a/tbl_alter.php3 b/tbl_alter.php3 index 3f2fa067b..9cc2bb325 100755 --- a/tbl_alter.php3 +++ b/tbl_alter.php3 @@ -13,17 +13,26 @@ require('./header.inc.php3'); * Modifications have been submitted -> updates the table */ if (isset($submit)) { + if (get_magic_quotes_gpc()) { + $field_name[0] = stripslashes($field_name[0]); + $field_default[0] = stripslashes($field_default[0]); + $field_length[0] = stripslashes($field_length[0]); + } + // Some fields have been urlencoded or double quotes have been translated // to """ in tbl_properties.php3 - $field_orig[0] = urldecode($field_orig[0]); + $field_orig[0] = urldecode($field_orig[0]); if (str_replace('"', '"', $field_orig[0]) == $field_name[0]) { $field_name[0] = $field_orig[0]; } $field_default_orig[0] = urldecode($field_default_orig[0]); if (str_replace('"', '"', $field_default_orig[0]) == $field_default[0]) { - $field_default[0] = $field_default_orig[0]; + $field_default[0] = $field_default_orig[0]; + } + $field_length_orig[0] = urldecode($field_length_orig[0]); + if (str_replace('"', '"', $field_length_orig[0]) == $field_length[0]) { + $field_length[0] = $field_length_orig[0]; } - if (!isset($query)) { $query = ''; } @@ -39,9 +48,11 @@ if (isset($submit)) { if ($field_default[0] != '') { $query .= ' DEFAULT \'' . sql_addslashes($field_default[0]) . '\''; } - $query .= ' ' . $field_null[0] . ' ' . $field_extra[0]; - if (get_magic_quotes_gpc()) { - $query = stripslashes($query); + if ($field_null[0] != '') { + $query .= ' ' . $field_null[0]; + } + if ($field_extra[0] != '') { + $query .= ' ' . $field_extra[0]; } // Optimization fix - 2 May 2001 - Robbat2 diff --git a/tbl_change.php3 b/tbl_change.php3 index e795d4176..6494213f5 100755 --- a/tbl_change.php3 +++ b/tbl_change.php3 @@ -177,56 +177,74 @@ for ($i = 0; $i < mysql_num_rows($table_def); $i++) { } } else if (strstr($row_table_def['True_Type'], 'enum')) { - $set = str_replace('enum(', '', $row_table_def['Type']); - $set = ereg_replace('\\)$', '', $set); - $set = explode('\',\'', substr($set, 1, -1)); + $enum = str_replace('enum(', '', $row_table_def['Type']); + $enum = ereg_replace('\\)$', '', $enum); + $enum = explode('\',\'', substr($enum, 1, -1)); + $enum_cnt = count($enum); + $seenchecked = 0; ?> 20) { + echo "\n"; ?> + echo '>[' . $strNull . ']' . "\n"; + } // end if + ?> + ' . "\n"; - echo ' ' . htmlspecialchars($set[$j]) . "\n"; + echo ' ' . htmlspecialchars($enum_atom) . "\n"; } // end for if ($row_table_def['Null'] == 'YES') { @@ -239,6 +257,7 @@ for ($i = 0; $i < mysql_num_rows($table_def); $i++) { echo ' [' . $strNull . ']' . "\n"; } // end if } // end else + echo "\n"; ?> 40) ? 40 : $len); - $maxlength = (($len < 4) ? 4 : $len); + $maxlength = (($len < 4) ? 4 : $len); echo "\n"; ?> diff --git a/tbl_properties.inc.php3 b/tbl_properties.inc.php3 index e15b66c02..a3f7c4131 100755 --- a/tbl_properties.inc.php3 +++ b/tbl_properties.inc.php3 @@ -40,8 +40,8 @@ if ($action == 'tbl_create.php3' || $action == 'tbl_addfield.php3') { echo " $strUnique\n"; } else { for ($i = 0; $i < $num_indexes; $i++) { - echo " $strSequence\n"; - echo " $strLength\n"; + echo " $strSequence\n"; + echo " $strLength\n"; } // end for } // end if } @@ -78,14 +78,14 @@ for ($i = 0 ; $i < $num_fields; $i++) { $type = eregi_replace('ZEROFILL', '', $type); $type = eregi_replace('UNSIGNED', '', $type); $length = $type; - $type = eregi_replace('\\(.*\\)', '', $type); - $type = chop($type); + $type = chop(eregi_replace('\\(.*\\)', '', $type)); if (!empty($type)) { $length = eregi_replace("^$type\(", '', $length); $length = eregi_replace('\)$', '', trim($length)); } - $length = htmlspecialchars(chop($length)); - if($length == $type) { + // Removes automatic MySQL escape format + $length = str_replace('\'\'', '\\\'', $length); + if ($length == $type) { $length = ''; } for ($j = 0; $j < count($cfgColumnTypes); $j++) { @@ -99,7 +99,8 @@ for ($i = 0 ; $i < $num_fields; $i++) { - + + " />