Fixed some encoding/decoding bugs
This commit is contained in:
@@ -13,6 +13,12 @@ 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]);
|
||||
@@ -23,7 +29,10 @@ if (isset($submit)) {
|
||||
if (str_replace('"', '"', $field_default_orig[0]) == $field_default[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
|
||||
|
@@ -177,48 +177,66 @@ 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;
|
||||
?>
|
||||
<td>
|
||||
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="$enum$" />
|
||||
<?php
|
||||
echo "\n" . $backup_field . "\n";
|
||||
echo "\n" . ' ' . $backup_field;
|
||||
|
||||
// show dropdown or radio depend on length
|
||||
if (strlen($row_table_def['Type']) > 20) {
|
||||
echo "\n";
|
||||
?>
|
||||
<select name="field_<?php echo md5($field); ?>[]">
|
||||
<option value=""></option>
|
||||
<?php
|
||||
echo "\n";
|
||||
|
||||
for ($j = 0; $j < count($set);$j++) {
|
||||
for ($j = 0; $j < $enum_cnt; $j++) {
|
||||
// Removes automatic MySQL escape format
|
||||
$enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
|
||||
echo ' ';
|
||||
echo '<option value="' . urlencode($set[$j]) . '"';
|
||||
if ($data == $set[$j]
|
||||
|| ($data == ''
|
||||
&& isset($row_table_def['Default'])
|
||||
&& $set[$j] == $row_table_def['Default'])) {
|
||||
echo '<option value="' . urlencode($enum_atom) . '"';
|
||||
if ($data == $enum_atom
|
||||
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
|
||||
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
|
||||
// To be able to select the [Null] value when the field is
|
||||
// null, we lose the ability to select besides the default
|
||||
// value
|
||||
echo ' selected="selected"';
|
||||
$seenchecked = 1;
|
||||
}
|
||||
echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
|
||||
} // end for
|
||||
|
||||
if ($row_table_def['Null'] == 'YES') {
|
||||
echo ' ';
|
||||
echo '<option value="null"';
|
||||
if ($seenchecked == 0) {
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n";
|
||||
} // end for
|
||||
echo '>[' . $strNull . ']</option>' . "\n";
|
||||
} // end if
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
} // end if
|
||||
else {
|
||||
$seenchecked = 0;
|
||||
for ($j = 0; $j < count($set); $j++) {
|
||||
echo "\n";
|
||||
|
||||
for ($j = 0; $j < $enum_cnt; $j++) {
|
||||
// Removes automatic MySQL escape format
|
||||
$enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
|
||||
echo ' ';
|
||||
echo '<input type="radio" name="field_' . md5($field) . '[]" value="' . urlencode($set[$j]) . '"';
|
||||
if ($data == $set[$j]
|
||||
|| ($data == ''
|
||||
&& isset($row_table_def['Default'])
|
||||
&& $set[$j] == $row_table_def['Default']
|
||||
&& $row_table_def['Null'] != 'YES')) {
|
||||
echo '<input type="radio" name="field_' . md5($field) . '[]" value="' . urlencode($enum_atom) . '"';
|
||||
if ($data == $enum_atom
|
||||
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
|
||||
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
|
||||
// To be able to display a checkmark in the [Null] box when
|
||||
// the field is null, we lose the ability to display a
|
||||
// checkmark besides the default value
|
||||
@@ -226,7 +244,7 @@ for ($i = 0; $i < mysql_num_rows($table_def); $i++) {
|
||||
$seenchecked = 1;
|
||||
}
|
||||
echo ' />' . "\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";
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
@@ -266,6 +285,8 @@ for ($i = 0; $i < mysql_num_rows($table_def); $i++) {
|
||||
$countset = count($set);
|
||||
for ($j = 0; $j < $countset;$j++) {
|
||||
$subset = substr($set[$j], 1, -1);
|
||||
// Removes automatic MySQL escape format
|
||||
$subset = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $subset));
|
||||
echo ' ';
|
||||
echo '<option value="'. urlencode($subset) . '"';
|
||||
if (isset($vset[$subset]) && $vset[$subset]) {
|
||||
|
@@ -78,13 +78,13 @@ 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));
|
||||
// Removes automatic MySQL escape format
|
||||
$length = str_replace('\'\'', '\\\'', $length);
|
||||
if ($length == $type) {
|
||||
$length = '';
|
||||
}
|
||||
@@ -99,7 +99,8 @@ for ($i = 0 ; $i < $num_fields; $i++) {
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="field_length[]" size="8" value="<?php echo $length; ?>" />
|
||||
<input type="hidden" name="field_length_orig[]" value="<?php echo urlencode($length); ?>" />
|
||||
<input type="text" name="field_length[]" size="8" value="<?php echo str_replace('"', '"', $length); ?>" />
|
||||
</td>
|
||||
<td>
|
||||
<select name="field_attribute[]">
|
||||
@@ -134,14 +135,14 @@ for ($i = 0 ; $i < $num_fields; $i++) {
|
||||
if (!isset($row) || empty($row['Null'])) {
|
||||
echo "\n";
|
||||
?>
|
||||
<option value="not null">not null</option>
|
||||
<option value="NOT NULL">not null</option>
|
||||
<option value="">null</option>
|
||||
<?php
|
||||
} else {
|
||||
echo "\n";
|
||||
?>
|
||||
<option value="">null</option>
|
||||
<option value="not null">not null</option>
|
||||
<option value="NOT NULL">not null</option>
|
||||
<?php
|
||||
}
|
||||
echo "\n";
|
||||
|
@@ -31,7 +31,7 @@ $url_query = 'lang=' . $lang
|
||||
. '&goto=tbl_properties.php3';
|
||||
?>
|
||||
|
||||
<!-- first browse link -->
|
||||
<!-- first browse links -->
|
||||
<p>
|
||||
[ <a href="sql.php3?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . backquote($table)); ?>&pos=0">
|
||||
<b><?php echo $strBrowse; ?></b></a> ]
|
||||
@@ -140,6 +140,8 @@ while ($row = mysql_fetch_array($result)) {
|
||||
$shorttype = substr($type, 0, 3);
|
||||
if ($shorttype == 'set' || $shorttype == 'enu') {
|
||||
$type = eregi_replace(',', ', ', $type);
|
||||
// Removes automatic MySQL escape format
|
||||
$type = str_replace('\'\'', '\\\'', $type);
|
||||
$type_nowrap = '';
|
||||
} else {
|
||||
$type_nowrap = ' nowrap="nowrap"';
|
||||
|
@@ -95,7 +95,7 @@ if (isset($primary_key) && ($submit_type != $strInsertAsNewRow)) {
|
||||
if (!empty($$f)) {
|
||||
$val = implode(',', $$f);
|
||||
if ($is_encoded) {
|
||||
$val = "'" . sql_addslashes(urldecode(',', $val)) . "'";
|
||||
$val = "'" . sql_addslashes(urldecode(val)) . "'";
|
||||
} else if (get_magic_quotes_gpc()) {
|
||||
$val = "'" . str_replace('\\"', '"', $val) . "'";
|
||||
} else {
|
||||
@@ -198,7 +198,7 @@ else {
|
||||
if (!empty($$f)) {
|
||||
$val = implode(',', $$f);
|
||||
if ($is_encoded) {
|
||||
$val = "'" . sql_addslashes(urldecode(',', $val)) . "'";
|
||||
$val = "'" . sql_addslashes(urldecode($val)) . "'";
|
||||
} else if (get_magic_quotes_gpc()) {
|
||||
$val = "'" . str_replace('\\"', '"', $val) . "'";
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user