diff --git a/tbl_change.php b/tbl_change.php index 9d24d8c83..05085439d 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -286,6 +286,7 @@ foreach ($rows as $row_id => $vrow) { } ?> + @@ -299,6 +300,15 @@ foreach ($rows as $row_id => $vrow) { + + + + + + + $vrow) { $odd_row = true; for ($i = 0; $i < $fields_cnt; $i++) { - $table_field = $table_fields[$i]; - $table_field['True_Type'] = preg_replace('@\(.*@s', '', $table_field['Type']); + if (! isset($table_fields[$i]['processed'])) { + $table_fields[$i]['Field_html'] = htmlspecialchars($table_fields[$i]['Field']); + $table_fields[$i]['Field_md5'] = md5($table_fields[$i]['Field']); + $table_fields[$i]['True_Type'] = preg_replace('@\(.*@s', '', $table_fields[$i]['Type']); + } + $field = $table_fields[$i]; - $field = $table_field['Field']; - $field_html = htmlspecialchars($field); - $field_md5 = md5($field); - - $unnullify_trigger = $chg_evt_handler . "=\"return unNullify('" . PMA_escapeJsString($field_html) . "', '" . PMA_escapeJsString($jsvkey) . "')\""; - $field_name_appendix = $vkey . '[' . $field_html . ']'; - $field_name_appendix_md5 = $field_md5 . $vkey . '[]'; + $unnullify_trigger = $chg_evt_handler . "=\"return unNullify('" + . PMA_escapeJsString($field['Field_html']) . "', '" + . PMA_escapeJsString($jsvkey) . "')\""; + $field_name_appendix = $vkey . '[' . $field['Field_html'] . ']'; + $field_name_appendix_md5 = $field['Field_md5'] . $vkey . '[]'; // removed previous PHP3-workaround that caused a problem with @@ -335,53 +347,53 @@ foreach ($rows as $row_id => $vrow) { // Default value logic below) // Note: (tested in MySQL 4.0.16): when lang is some UTF-8, - // $table_field['Default'] is not set if it contains NULL: + // $field['Default'] is not set if it contains NULL: // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime) // but, look what we get if we switch to iso: (Default is NULL) // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime) // so I force a NULL into it (I don't think it's possible // to have an empty default value for DATETIME) // then, the "if" after this one will work - if ($table_field['Type'] == 'datetime' - && ! isset($table_field['Default']) - && isset($table_field['Null']) - && $table_field['Null'] == 'YES') { - $table_field['Default'] = null; + if ($field['Type'] == 'datetime' + && ! isset($field['Default']) + && isset($field['Null']) + && $field['Null'] == 'YES') { + $field['Default'] = null; } - if ($table_field['Type'] == 'datetime' - && ! isset($table_field['Default']) - && ! is_null($table_field['Default'])) { + if ($field['Type'] == 'datetime' + && ! isset($field['Default']) + && ! is_null($field['Default'])) { // INSERT case if ($insert_mode) { - $vrow[$field] = date('Y-m-d H:i:s', time()); + $vrow[$field['Field']] = date('Y-m-d H:i:s', time()); } // UPDATE case with an empty and not NULL value under PHP4 - elseif (empty($vrow[$field]) && is_null($vrow[$field])) { - $vrow[$field] = date('Y-m-d H:i:s', time()); + elseif (empty($vrow[$field['Field']]) && is_null($vrow[$field['Field']])) { + $vrow[$field['Field']] = date('Y-m-d H:i:s', time()); } // end if... elseif... } - $len = (preg_match('@float|double@', $table_field['Type'])) + $len = (preg_match('@float|double@', $field['Type'])) ? 100 : PMA_DBI_field_len($vresult, $i); $first_timestamp = 0; - $field_name = $field_html; - if (isset($comments_map[$field])) { + $field_name = $field['Field_html']; + if (isset($comments_map[$field['Field']])) { $field_name = '' . $field_name . ''; } ?> - + $vrow) { $timestamp_seen = 1; $first_timestamp = 1; } - $type = $table_field['Type']; + $type = $field['Type']; $type_nowrap = ' nowrap="nowrap"'; break; default: - $type = $table_field['Type']; + $type = $field['Type']; $type_nowrap = ' nowrap="nowrap"'; break; } @@ -414,29 +426,29 @@ foreach ($rows as $row_id => $vrow) { // Prepares the field value $real_null_value = FALSE; if (isset($vrow)) { - if (! isset($vrow[$field]) - || is_null($vrow[$field])) { + if (! isset($vrow[$field['Field']]) + || is_null($vrow[$field['Field']])) { $real_null_value = TRUE; - $vrow[$field] = ''; + $vrow[$field['Field']] = ''; $special_chars = ''; - $data = $vrow[$field]; - } elseif ($table_field['True_Type'] == 'bit') { + $data = $vrow[$field['Field']]; + } elseif ($field['True_Type'] == 'bit') { $special_chars = ''; for ($j = 0; $j < ceil($len / 8); $j++) { - $special_chars .= sprintf('%08d', decbin(ord(substr($vrow[$field], $j, 1)))); + $special_chars .= sprintf('%08d', decbin(ord(substr($vrow[$field['Field']], $j, 1)))); } $special_chars = substr($special_chars, -$len); } else { // loic1: special binary "characters" if ($is_binary || $is_blob) { - $vrow[$field] = str_replace("\x00", '\0', $vrow[$field]); - $vrow[$field] = str_replace("\x08", '\b', $vrow[$field]); - $vrow[$field] = str_replace("\x0a", '\n', $vrow[$field]); - $vrow[$field] = str_replace("\x0d", '\r', $vrow[$field]); - $vrow[$field] = str_replace("\x1a", '\Z', $vrow[$field]); + $vrow[$field['Field']] = str_replace("\x00", '\0', $vrow[$field['Field']]); + $vrow[$field['Field']] = str_replace("\x08", '\b', $vrow[$field['Field']]); + $vrow[$field['Field']] = str_replace("\x0a", '\n', $vrow[$field['Field']]); + $vrow[$field['Field']] = str_replace("\x0d", '\r', $vrow[$field['Field']]); + $vrow[$field['Field']] = str_replace("\x1a", '\Z', $vrow[$field['Field']]); } // end if - $special_chars = htmlspecialchars($vrow[$field]); - $data = $vrow[$field]; + $special_chars = htmlspecialchars($vrow[$field['Field']]); + $data = $vrow[$field['Field']]; } // end if... else... // loic1: if a timestamp field value is not included in an update // statement MySQL auto-update it to the current timestamp @@ -444,17 +456,17 @@ foreach ($rows as $row_id => $vrow) { // it's better to set a fields_prev in this situation $backup_field = ''; + . htmlspecialchars($vrow[$field['Field']]) . '" />'; } else { // loic1: display default values - if (!isset($table_field['Default'])) { - $table_field['Default'] = ''; + if (!isset($field['Default'])) { + $field['Default'] = ''; $real_null_value = TRUE; $data = ''; } else { - $data = $table_field['Default']; + $data = $field['Default']; } - $special_chars = htmlspecialchars($table_field['Default']); + $special_chars = htmlspecialchars($field['Default']); $backup_field = ''; } @@ -472,7 +484,7 @@ foreach ($rows as $row_id => $vrow) { if (($cfg['ProtectBinary'] && $is_blob && !$is_upload) || ($cfg['ProtectBinary'] == 'all' && $is_binary)) { echo ' ' . "\n"; - } elseif (strstr($table_field['True_Type'], 'enum') || strstr($table_field['True_Type'], 'set')) { + } elseif (strstr($field['True_Type'], 'enum') || strstr($field['True_Type'], 'set')) { echo ' ' . "\n"; } else { ?> @@ -487,9 +499,9 @@ foreach ($rows as $row_id => $vrow) { // which will then reveal the available dropdown options if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) - && isset($cfg['RestrictColumnTypes'][strtoupper($table_field['True_Type'])]) - && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($table_field['True_Type'])]])) { - $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($table_field['True_Type'])]; + && isset($cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]) + && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]])) { + $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($field['True_Type'])]; $dropdown = $cfg['RestrictFunctions'][$current_func_type]; $default_function = $cfg['DefaultFunctions'][$current_func_type]; } else { @@ -512,9 +524,9 @@ foreach ($rows as $row_id => $vrow) { // and the column does not have the // ON UPDATE DEFAULT TIMESTAMP attribute. - if (!($table_field['True_Type'] == 'timestamp' - && !empty($table_field['Default']) - && !isset($analyzed_sql[0]['create_table_fields'][$field]['on_update_current_timestamp']))) { + if (!($field['True_Type'] == 'timestamp' + && !empty($field['Default']) + && !isset($analyzed_sql[0]['create_table_fields'][$field['Field']]['on_update_current_timestamp']))) { $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp']) || (!$first_timestamp && $dropdown[$j] == $default_function) ? ' selected="selected"' @@ -559,7 +571,7 @@ foreach ($rows as $row_id => $vrow) { // The null column // --------------- echo ' - - +   - 32000) { - echo ' ' . "\n"; + echo " \n"; + echo ' - $val, + 'html' => htmlspecialchars($val), + ); + } + $table_fields[$i]['select_size'] = min(4, count($table_fields[$i]['values'])); + } + $field_set_values = $table_fields[$i]['values']; + $select_size = $table_fields[$i]['select_size']; - if (isset($vset)) { - unset($vset); - } - for ($vals = explode(',', $data); list($t, $k) = each($vals);) { - $vset[$k] = 1; - } - $countset = count($set); - $size = min(4, $countset); + $vset = array_flip(explode(',', $data)); + echo $backup_field . "\n"; ?> - @@ -793,9 +802,6 @@ foreach ($rows as $row_id => $vrow) { if (($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary)) { echo "\n"; - ?> -
+ +
align="center"> align="center"> ' . $strBinary . '--' . "\n"; - if ($table_field['Null'] == 'YES') { + if ($field['Null'] == 'YES') { echo ' $vrow) { } echo ' id="field_' . ($idindex) . '_2"'; $onclick = ' onclick="if (this.checked) {nullify('; - if (strstr($table_field['True_Type'], 'enum')) { - if (strlen($table_field['Type']) > 20) { + if (strstr($field['True_Type'], 'enum')) { + if (strlen($field['Type']) > 20) { $onclick .= '1, '; } else { $onclick .= '2, '; } - } elseif (strstr($table_field['True_Type'], 'set')) { + } elseif (strstr($field['True_Type'], 'set')) { $onclick .= '3, '; - } elseif ($foreigners && isset($foreigners[$field])) { + } elseif ($foreigners && isset($foreigners[$field['Field']])) { $onclick .= '4, '; } else { $onclick .= '5, '; } - $onclick .= '\'' . PMA_escapeJsString($field_html) . '\', \'' . $field_md5 . '\', \'' . PMA_escapeJsString($vkey) . '\'); this.checked = true}; return true" />' . "\n"; + $onclick .= '\'' . PMA_escapeJsString($field['Field_html']) . '\', \'' . $field['Field_md5'] . '\', \'' . PMA_escapeJsString($vkey) . '\'); this.checked = true}; return true" />' . "\n"; echo $onclick; } else { echo ' $vrow) { require './libraries/get_foreign.lib.php'; + echo ' ' . "\n"; if (isset($foreign_link) && $foreign_link == true) { + echo $backup_field . "\n"; ?> - - $vrow) { document.writeln(''); + document.writeln('&field=">'); document.writeln(''); //]]> - - $vrow) { id="field__3"> -  
@@ -661,12 +670,10 @@ foreach ($rows as $row_id => $vrow) { tabindex="" > - - - ' . $strTextAreaLength . '' . $strTextAreaLength; } } elseif ($type == 'enum') { - $enum = PMA_getEnumSetOptions($table_field['Type']); - $enum_cnt = count($enum); + if (! isset($table_fields[$i]['values'])) { + $table_fields[$i]['values'] = array(); + foreach (PMA_getEnumSetOptions($field['Type']) as $val) { + // Removes automatic MySQL escape format + $val = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $val)); + $table_fields[$i]['values'][] = array( + 'plain' => $val, + 'html' => htmlspecialchars($val), + ); + } + } + $field_enum_values = $table_fields[$i]['values']; ?> - 20) { - echo "\n"; + if (strlen($field['Type']) > 20) { ?> '; echo '' . "\n"; + . $enum_value['html'] . '' . "\n"; + $j++; } // end for - } // end else - echo "\n"; - ?> - - - - $vrow) { - -