diff --git a/ChangeLog b/ChangeLog index 02ac2d6f6..db1ba7637 100755 --- a/ChangeLog +++ b/ChangeLog @@ -14,9 +14,9 @@ $Source$ * sql.php3: Fixed another occurence of addslashes() where it no longer belongs. * tbl_addfield.php3, tbl_alter.php3, tbl_create.php3, - tbl_properties.inc.php3: Goodie for you all - when creating/altering/ - adding table fields you can now change the wrong form input, instead - of losing all your data. Have fun. :-) + tbl_properties.inc.php3, libraries/common.lib.php3: Goodie for you all + - when creating/altering/adding table fields you can now change the + wrong form input, instead of losing all your data. Have fun. :-) * tbl_dump.php3, tbl_properties_export.php3, css/phpmyadmin.css.php3, lang/*: Added new table export format by Michal Cihar. db_details_export.php3 diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index db163e08d..71a6fd327 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -399,13 +399,15 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} * @param string the sql query that failed * @param boolean whether to show a "modify" link or not * @param string the "back" link url (full path is not required) + * @param boolean EXIT the page? * * @global array the configuration array * * @access public */ function PMA_mysqlDie($error_message = '', $the_query = '', - $is_modify_link = TRUE, $back_url = '') + $is_modify_link = TRUE, $back_url = '', + $exit = TRUE) { global $cfg; @@ -466,13 +468,15 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} . '' . "\n"; - if (!empty($back_url)) { + if (!empty($back_url) && $exit) { echo '' . $GLOBALS['strBack'] . ''; } echo "\n"; - include('./footer.inc.php3'); - exit(); + if ($exit) { + include('./footer.inc.php3'); + exit(); + } } // end of the 'PMA_mysqlDie()' function diff --git a/tbl_addfield.php3 b/tbl_addfield.php3 index c1980f6e9..2e512d3e1 100755 --- a/tbl_addfield.php3 +++ b/tbl_addfield.php3 @@ -20,6 +20,7 @@ $err_url = 'tbl_properties.php3?' . PMA_generate_common_url($db, $table); /** * The form used to define the field to add has been submitted */ +$abort = false; if (isset($submit)) { $query = ''; @@ -101,114 +102,129 @@ if (isset($submit)) { $sql_query = 'USE ' . PMA_backquote($db); $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD ' . $query; - $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); - $sql_query_cpy = $sql_query . ';'; + $error_create = false; + $result = PMA_mysql_query($sql_query) or $error_create = true; - // Builds the primary keys statements and updates the table - $primary = ''; - if (isset($field_primary)) { - $primary_cnt = count($field_primary); - for ($i = 0; $i < $primary_cnt; $i++) { - $j = $field_primary[$i]; - if (!empty($field_name[$j])) { - $primary .= PMA_backquote($field_name[$j]) . ', '; + if ($error_create == false) { + + $sql_query_cpy = $sql_query . ';'; + + // Builds the primary keys statements and updates the table + $primary = ''; + if (isset($field_primary)) { + $primary_cnt = count($field_primary); + for ($i = 0; $i < $primary_cnt; $i++) { + $j = $field_primary[$i]; + if (!empty($field_name[$j])) { + $primary .= PMA_backquote($field_name[$j]) . ', '; + } + } // end for + $primary = ereg_replace(', $', '', $primary); + if (!empty($primary)) { + $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ')'; + $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); + $sql_query_cpy .= "\n" . $sql_query . ';'; } - } // end for - $primary = ereg_replace(', $', '', $primary); - if (!empty($primary)) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD PRIMARY KEY (' . $primary . ')'; - $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); - $sql_query_cpy .= "\n" . $sql_query . ';'; - } - } // end if - - // Builds the indexes statements and updates the table - $index = ''; - if (isset($field_index)) { - $index_cnt = count($field_index); - for ($i = 0; $i < $index_cnt; $i++) { - $j = $field_index[$i]; - if (!empty($field_name[$j])) { - $index .= PMA_backquote($field_name[$j]) . ', '; + } // end if + + // Builds the indexes statements and updates the table + $index = ''; + if (isset($field_index)) { + $index_cnt = count($field_index); + for ($i = 0; $i < $index_cnt; $i++) { + $j = $field_index[$i]; + if (!empty($field_name[$j])) { + $index .= PMA_backquote($field_name[$j]) . ', '; + } + } // end for + $index = ereg_replace(', $', '', $index); + if (!empty($index)) { + $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')'; + $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); + $sql_query_cpy .= "\n" . $sql_query . ';'; } - } // end for - $index = ereg_replace(', $', '', $index); - if (!empty($index)) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX (' . $index . ')'; - $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); - $sql_query_cpy .= "\n" . $sql_query . ';'; - } - } // end if - - // Builds the uniques statements and updates the table - $unique = ''; - if (isset($field_unique)) { - $unique_cnt = count($field_unique); - for ($i = 0; $i < $unique_cnt; $i++) { - $j = $field_unique[$i]; - if (!empty($field_name[$j])) { - $unique .= PMA_backquote($field_name[$j]) . ', '; + } // end if + + // Builds the uniques statements and updates the table + $unique = ''; + if (isset($field_unique)) { + $unique_cnt = count($field_unique); + for ($i = 0; $i < $unique_cnt; $i++) { + $j = $field_unique[$i]; + if (!empty($field_name[$j])) { + $unique .= PMA_backquote($field_name[$j]) . ', '; + } + } // end for + $unique = ereg_replace(', $', '', $unique); + if (!empty($unique)) { + $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')'; + $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); + $sql_query_cpy .= "\n" . $sql_query . ';'; + } + } // end if + + + // Builds the fulltext statements and updates the table + $fulltext = ''; + if (PMA_MYSQL_INT_VERSION >= 32323 && isset($field_fulltext)) { + $fulltext_cnt = count($field_fulltext); + for ($i = 0; $i < $fulltext_cnt; $i++) { + $j = $field_fulltext[$i]; + $fulltext .= PMA_backquote($field_name[$j]) . ', '; + } // end for + $fulltext = ereg_replace(', $', '', $fulltext); + if (!empty($fulltext)) { + $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')'; + $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); + $sql_query_cpy .= "\n" . $sql_query . ';'; + } + } // end if + + // garvin: If comments were sent, enable relation stuff + require('./libraries/relation.lib.php3'); + require('./libraries/transformations.lib.php3'); + + $cfgRelation = PMA_getRelationsParam(); + + // garvin: Update comment table, if a comment was set. + if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { + @reset($field_comments); + while(list($fieldindex, $fieldcomment) = each($field_comments)) { + PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment); } - } // end for - $unique = ereg_replace(', $', '', $unique); - if (!empty($unique)) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE (' . $unique . ')'; - $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); - $sql_query_cpy .= "\n" . $sql_query . ';'; } - } // end if - - - // Builds the fulltext statements and updates the table - $fulltext = ''; - if (PMA_MYSQL_INT_VERSION >= 32323 && isset($field_fulltext)) { - $fulltext_cnt = count($field_fulltext); - for ($i = 0; $i < $fulltext_cnt; $i++) { - $j = $field_fulltext[$i]; - $fulltext .= PMA_backquote($field_name[$j]) . ', '; - } // end for - $fulltext = ereg_replace(', $', '', $fulltext); - if (!empty($fulltext)) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT (' . $fulltext . ')'; - $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); - $sql_query_cpy .= "\n" . $sql_query . ';'; + + // garvin: Update comment table for mime types [MIME] + if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { + @reset($field_mimetype); + while(list($fieldindex, $mimetype) = each($field_mimetype)) { + PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + } } - } // end if - - // garvin: If comments were sent, enable relation stuff - require('./libraries/relation.lib.php3'); - require('./libraries/transformations.lib.php3'); - - $cfgRelation = PMA_getRelationsParam(); - - // garvin: Update comment table, if a comment was set. - if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { - @reset($field_comments); - while(list($fieldindex, $fieldcomment) = each($field_comments)) { - PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment); + + // Go back to the structure sub-page + $sql_query = $sql_query_cpy; + unset($sql_query_cpy); + $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered; + include('./tbl_properties_structure.php3'); + exit(); + } else { + PMA_mysqlDie('', '', '', $err_url, FALSE); + // garvin: An error happened while inserting/updating a table definition. + // to prevent total loss of that data, we embed the form once again. + // The variable $regenerate will be used to restore data in tbl_properties.inc.php3 + $num_fields = $orig_num_fields; + if (isset($orig_after_field)) { + $after_field = $orig_after_field; } + $regenerate = true; } - - // garvin: Update comment table for mime types [MIME] - if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { - @reset($field_mimetype); - while(list($fieldindex, $mimetype) = each($field_mimetype)) { - PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); - } - } - - // Go back to the structure sub-page - $sql_query = $sql_query_cpy; - unset($sql_query_cpy); - $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered; - include('./tbl_properties_structure.php3'); - exit(); } // end do alter table /** * Displays the form used to define the new field */ -else{ +if ($abort == FALSE) { $action = 'tbl_addfield.php3'; include('./tbl_properties.inc.php3'); diff --git a/tbl_alter.php3 b/tbl_alter.php3 index 1b1f9ef42..0ccc9530c 100755 --- a/tbl_alter.php3 +++ b/tbl_alter.php3 @@ -22,6 +22,7 @@ $err_url = 'tbl_properties_structure.php3?' . PMA_generate_common_url($db, $tabl /** * Modifications have been submitted -> updates the table */ +$abort = false; if (isset($submit)) { $field_cnt = count($field_orig); for ($i = 0; $i < $field_cnt; $i++) { @@ -78,41 +79,54 @@ if (isset($submit)) { $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); // Optimization fix - 2 May 2001 - Robbat2 $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' . $query; - $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); - $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered; - $btnDrop = 'Fake'; + $error_create = false; + $result = PMA_mysql_query($sql_query) or $error_create = true; - // garvin: If comments were sent, enable relation stuff - require('./libraries/relation.lib.php3'); - require('./libraries/transformations.lib.php3'); - - $cfgRelation = PMA_getRelationsParam(); + if ($error_create == false) { + $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered; + $btnDrop = 'Fake'; - // garvin: Update comment table, if a comment was set. - if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { - @reset($field_comments); - while(list($fieldindex, $fieldcomment) = each($field_comments)) { - PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, $field_orig[$fieldindex]); + // garvin: If comments were sent, enable relation stuff + require('./libraries/relation.lib.php3'); + require('./libraries/transformations.lib.php3'); + + $cfgRelation = PMA_getRelationsParam(); + + // garvin: Update comment table, if a comment was set. + if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { + @reset($field_comments); + while(list($fieldindex, $fieldcomment) = each($field_comments)) { + PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, $field_orig[$fieldindex]); + } } - } - - // garvin: Update comment table for mime types [MIME] - if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { - @reset($field_mimetype); - while(list($fieldindex, $mimetype) = each($field_mimetype)) { - PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + + // garvin: Update comment table for mime types [MIME] + if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { + @reset($field_mimetype); + while(list($fieldindex, $mimetype) = each($field_mimetype)) { + PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + } + } + + include('./tbl_properties_structure.php3'); + exit(); + } else { + PMA_mysqlDie('', '', '', $err_url, FALSE); + // garvin: An error happened while inserting/updating a table definition. + // to prevent total loss of that data, we embed the form once again. + // The variable $regenerate will be used to restore data in tbl_properties.inc.php3 + if (isset($orig_field)) { + $field = $orig_field; } - } - include('./tbl_properties_structure.php3'); - exit(); + $regenerate = true; + } } - /** * No modifications yet required -> displays the table fields */ -else { +if ($abort == FALSE) { if (!isset($selected)) { $selected[] = $field; $selected_cnt = 1; diff --git a/tbl_create.php3 b/tbl_create.php3 index 359a55fb3..957209231 100755 --- a/tbl_create.php3 +++ b/tbl_create.php3 @@ -26,6 +26,7 @@ PMA_mysql_select_db($db); /** * The form used to define the structure of the table has been submitted */ +$abort = false; if (isset($submit)) { $sql_query = $query_cpy = ''; @@ -141,7 +142,7 @@ if (isset($submit)) { $fulltext .= PMA_backquote($field_name[$j]) . ', '; } } // end for - unset($field_fulltext); + $fulltext = ereg_replace(', $', '', $fulltext); if (!empty($fulltext)) { $sql_query .= ', FULLTEXT (' . $fulltext . ')'; @@ -164,42 +165,53 @@ if (isset($submit)) { } // Executes the query - $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', '', '', $err_url); - $sql_query = $query_cpy . ';'; - unset($query_cpy); - $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated; + $error_create = false; + $result = PMA_mysql_query($sql_query) or $error_create = true; - // garvin: If comments were sent, enable relation stuff - require('./libraries/relation.lib.php3'); - require('./libraries/transformations.lib.php3'); - - $cfgRelation = PMA_getRelationsParam(); - - // garvin: Update comment table, if a comment was set. - if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { - @reset($field_comments); - while(list($fieldindex, $fieldcomment) = each($field_comments)) { - PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment); + if ($error_create == false) { + $sql_query = $query_cpy . ';'; + unset($query_cpy); + $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated; + + // garvin: If comments were sent, enable relation stuff + require('./libraries/relation.lib.php3'); + require('./libraries/transformations.lib.php3'); + + $cfgRelation = PMA_getRelationsParam(); + + // garvin: Update comment table, if a comment was set. + if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) { + @reset($field_comments); + while(list($fieldindex, $fieldcomment) = each($field_comments)) { + PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment); + } } - } - - // garvin: Update comment table for mime types [MIME] - if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { - @reset($field_mimetype); - while(list($fieldindex, $mimetype) = each($field_mimetype)) { - PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + + // garvin: Update comment table for mime types [MIME] + if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) { + @reset($field_mimetype); + while(list($fieldindex, $mimetype) = each($field_mimetype)) { + PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]); + } } + + include('./' . $cfg['DefaultTabTable']); + $abort = TRUE; + exit(); + } else { + PMA_mysqlDie('', '', '', $err_url, FALSE); + // garvin: An error happened while inserting/updating a table definition. + // to prevent total loss of that data, we embed the form once again. + // The variable $regenerate will be used to restore data in tbl_properties.inc.php3 + $num_fields = $orig_num_fields; + $regenerate = true; } - - include('./' . $cfg['DefaultTabTable']); - exit(); } // end do create table - /** * Displays the form used to define the structure of the table */ -else { +if ($abort == FALSE) { if (isset($num_fields)) { $num_fields = intval($num_fields); } diff --git a/tbl_properties.inc.php3 b/tbl_properties.inc.php3 index a8e49877d..e87a88812 100755 --- a/tbl_properties.inc.php3 +++ b/tbl_properties.inc.php3 @@ -26,6 +26,49 @@ else if ($action == 'tbl_addfield.php3') { + + + + + + + + + + + + " /> + ' . "\n"; + $backup_field = (isset($true_selected) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : '')); + $content_cells[$i][$ci] = "\n" . '' . "\n"; } else { $content_cells[$i][$ci] = ''; } @@ -119,6 +219,10 @@ for ($i = 0 ; $i < $num_fields; $i++) { $length = ''; } } // end if else + + if (isset($submit_length) && $submit_length != FALSE) { + $length = $submit_length; + } for ($j = 0; $j < count($cfg['ColumnTypes']); $j++) { $content_cells[$i][$ci] .= ' ' . "\n"; $content_cells[$i][$ci] .= ' ' . "\n"; @@ -277,7 +386,10 @@ for ($i = 0 ; $i < $num_fields; $i++) { && empty($checked_index) && empty($checked_unique)) { $checked_none = ' checked="checked"'; + } else { + $checked_none = ''; } + if (PMA_MYSQL_INT_VERSION >= 32323 &&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) { $checked_fulltext = ' checked="checked"'; @@ -384,7 +496,7 @@ if ($action == 'tbl_create.php3' && PMA_MYSQL_INT_VERSION >= 32300) { - + = 32300) {