From 6b00b75f7d1f8af1838a7c90d6b08c350f6b8691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Chapeaux?= Date: Wed, 1 May 2002 17:14:45 +0000 Subject: [PATCH] Splitted the large "database details" page in parts --- ChangeLog | 2 + db_details.php3 | 725 +------------------------------------- db_details_common.php3 | 68 ++++ db_details_db_info.php3 | 73 ++++ db_details_export.php3 | 164 +++++++++ db_details_links.php3 | 61 ++++ db_details_structure.php3 | 454 ++++++++++++++++++++++++ mult_submits.inc.php3 | 11 +- sql.php3 | 13 +- 9 files changed, 850 insertions(+), 721 deletions(-) create mode 100644 db_details_common.php3 create mode 100644 db_details_db_info.php3 create mode 100644 db_details_export.php3 create mode 100644 db_details_links.php3 create mode 100644 db_details_structure.php3 diff --git a/ChangeLog b/ChangeLog index d6b6629f6..ee330dc8b 100755 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,8 @@ $Source$ Kris Wood . * mosts scripts: optimization - do not call "mysql_numrows", "mysql_results" and "mysql_fetch_array" on invalid queries. + * db_details*.php3; mult_submits.inc.php3; sql.php3: splitted the large + "database details" page in parts. 2002-04-30 Loïc Chapeaux * lang/italian.inc.php3: updated thanks to Pietro Danesi. diff --git a/db_details.php3 b/db_details.php3 index 60ba8b971..2b6650e91 100755 --- a/db_details.php3 +++ b/db_details.php3 @@ -1,517 +1,10 @@ back to the welcome page - if (!empty($db)) { - $is_db = @mysql_select_db($db); - } - if (empty($db) || !$is_db) { - header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php3?lang=' . $lang . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); - exit(); - } -} // end if (ensures db exists) - -// Displays headers -if (!isset($message)) { - $js_to_run = 'functions.js'; - include('./header.inc.php3'); - // Reloads the navigation frame via JavaScript if required - if (isset($reload) && $reload) { - echo "\n"; - ?> - - = 32303) { - // Special speedup for newer MySQL Versions (in 4.0 format changed) - if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) { - $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db); - $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - // Blending out tables in use - if ($result != FALSE && mysql_num_rows($result) > 0) { - while ($tmp = mysql_fetch_row($result)) { - // if in use memorize tablename - if (eregi('in_use=[1-9]+', $tmp[1])) { - $sot_cache[$tmp[0]] = TRUE; - } - } - mysql_free_result($result); - - if (isset($sot_cache)) { - $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db); - $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - if ($result != FALSE && mysql_num_rows($result) > 0) { - while ($tmp = mysql_fetch_row($result)) { - if (!isset($sot_cache[$tmp[0]])) { - $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\''; - $sts_result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - $sts_tmp = mysql_fetch_array($sts_result); - $tables[] = $sts_tmp; - } else { // table in use - $tables[] = array('Name' => $tmp[0]); - } - } - mysql_free_result($result); - $sot_ready = TRUE; - } - } - } - } - if (!isset($sot_ready)) { - $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); - $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); - if ($result != FALSE && mysql_num_rows($result) > 0) { - while ($sts_tmp = mysql_fetch_array($result)) { - $tables[] = $sts_tmp; - } - mysql_free_result($result); - } - } - $num_tables = (isset($tables) ? count($tables) : 0); -} // end if (PMA_MYSQL_INT_VERSION >= 32303) -else { - $result = mysql_list_tables($db); - $num_tables = ($result) ? @mysql_numrows($result) : 0; - for ($i = 0; $i < $num_tables; $i++) { - $tables[] = mysql_tablename($result, $i); - } - mysql_free_result($result); -} - - -/** - * Displays an html table with all the tables contained into the current - * database - */ -?> - - - -= 3.23.03 - staybyte - 11 June 2001 -else if (PMA_MYSQL_INT_VERSION >= 32303) { - ?> -
- - - - - - - - - - - - ' . ucfirst($strSize) . ''; - } - echo "\n"; - ?> - - - - - - - - - - - - to get valid - // statistics whatever is the table type - if (isset($sts_data['Rows'])) { - // MyISAM, ISAM or Heap table: Row count, data size and index size - // is accurate. - if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) { - if ($cfg['ShowStats']) { - $tblsize = $sts_data['Data_length'] + $sts_data['Index_length']; - $sum_size += $tblsize; - list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); - } - $sum_entries += $sts_data['Rows']; - $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator); - } - - // InnoDB table: Row count is not accurate but data and index - // sizes are. - else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') { - if ($cfg['ShowStats']) { - $tblsize = $sts_data['Data_length'] + $sts_data['Index_length']; - $sum_size += $tblsize; - list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); - } - $display_rows = ' - '; - } - - // Merge or BerkleyDB table: Only row count is accurate. - else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) { - if ($cfg['ShowStats']) { - $formated_size = ' - '; - $unit = ''; - } - $sum_entries += $sts_data['Rows']; - $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator); - } - - // Unknown table type. - else { - if ($cfg['ShowStats']) { - $formated_size = 'unknown'; - $unit = ''; - } - $display_rows = 'unknown'; - } - ?> - - - - - - - - - - - - - - - - - - - - - - - - -
  
- /> - -     - - ' . $strBrowse . ''; - } else { - echo $strBrowse; - } - ?> - - ' - . $strSelect . ''; - } else { - echo $strSelect; - } - ?> - - - - - - - - - - - = 40000) { - echo urlencode('TRUNCATE ' . PMA_backquote($table)) - . '&zero_rows=' - . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table))) - . '" onclick="return confirmLink(this, \'TRUNCATE '; - } else { - echo urlencode('DELETE FROM ' . PMA_backquote($table)) - . '&zero_rows=' - . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table))) - . '" onclick="return confirmLink(this, \'DELETE FROM '; - } - echo PMA_jsFormat($table) . '\')">' . $strEmpty . ''; - } else { - echo $strEmpty; - } - ?> - - - -    - -    - - - -
-    - - - - - - -- - -   - -
- <?php echo $strWithChecked; ?> - - -  /  - - -     - - - - -
- -
- = 3.23.03 - -// 3. Shows tables list mysql < 3.23.03 -else { - $i = 0; - echo "\n"; - ?> -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  
- /> - -    - - - - - - - - - - - - - - -
- <?php echo $strWithChecked; ?> - - -  /  - - -
- -    - -    - -
- -
- -
- - - - -
    - 0) { - ?> - -
  • -
    -
  • - = 40000 && function_exists('ini_get')) ? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize'))) // loic1: php 3.0.15 and lower bug -> always enabled : (PMA_PHP_INT_VERSION < 30016 || intval(@get_cfg_var('upload_max_filesize'))); -?> +?> + +
    • @@ -628,192 +124,9 @@ if ($num_tables > 0) {
    • + -
    • - -
      -
      - - - 1) { - $colspan = ' colspan="2"'; - echo "\n"; - ?> - - - - - - > - - - - - - > - - - - - - > - - - - - = 32306) { - ?> - - > - - - - - - - > - - - = 40004) { - $is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress')); - $is_gzip = (isset($cfg['GZipDump']) && $cfg['GZipDump'] && @function_exists('gzencode')); - $is_bzip = (isset($cfg['BZipDump']) && $cfg['BZipDump'] && @function_exists('bzcompress')); - if ($is_zip || $is_gzip || $is_bzip) { - echo "\n" . ' (' . "\n"; - if ($is_zip) { - ?> - - ' . $strZip . '' . (($is_gzip || $is_bzip) ? ' ' : '') . "\n"; ?> - - - ' . $strGzip . '' . (($is_bzip) ? ' ' : '') . "\n"; ?> - - - ' . $strBzip . '' . "\n"; ?> - ' . "\n" - . PMA_set_enc_form(' '); - } - ?> - - - - > - - - -
      - - - -
      - -
      - -
      - - - 1) { - echo "\n"; - ?> -
      - -  /  - - -
      - - - -
      -
    • - - - -
    • -
      - - - -' . "\n"; -echo ' ' . $strName . ' : ' . "\n"; -echo ' ' . '' . "\n"; -echo ' ' . '
      ' . "\n"; -echo ' ' . $strFields . ' : ' . "\n"; -echo ' ' . '' . "\n"; -echo ' ' . ' ' . "\n"; -?> -
      -
    • - - - -
    • - - - -
    • - diff --git a/db_details_common.php3 b/db_details_common.php3 new file mode 100644 index 000000000..6b96900f1 --- /dev/null +++ b/db_details_common.php3 @@ -0,0 +1,68 @@ + back to the welcome page + if (!empty($db)) { + $is_db = @mysql_select_db($db); + } + if (empty($db) || !$is_db) { + header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php3?lang=' . $lang . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1'); + exit(); + } +} // end if (ensures db exists) + +// Displays headers +if (!isset($message)) { + $js_to_run = 'functions.js'; + include('./header.inc.php3'); + // Reloads the navigation frame via JavaScript if required + if (isset($reload) && $reload) { + echo "\n"; + ?> + + diff --git a/db_details_db_info.php3 b/db_details_db_info.php3 new file mode 100644 index 000000000..f9dab1bdc --- /dev/null +++ b/db_details_db_info.php3 @@ -0,0 +1,73 @@ += 32303) { + // Special speedup for newer MySQL Versions (in 4.0 format changed) + if ($cfg['SkipLockedTables'] == TRUE && PMA_MYSQL_INT_VERSION >= 32330) { + $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db); + $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + // Blending out tables in use + if ($result != FALSE && mysql_num_rows($result) > 0) { + while ($tmp = mysql_fetch_row($result)) { + // if in use memorize tablename + if (eregi('in_use=[1-9]+', $tmp[1])) { + $sot_cache[$tmp[0]] = TRUE; + } + } + mysql_free_result($result); + + if (isset($sot_cache)) { + $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db); + $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + if ($result != FALSE && mysql_num_rows($result) > 0) { + while ($tmp = mysql_fetch_row($result)) { + if (!isset($sot_cache[$tmp[0]])) { + $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\''; + $sts_result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + $sts_tmp = mysql_fetch_array($sts_result); + $tables[] = $sts_tmp; + } else { // table in use + $tables[] = array('Name' => $tmp[0]); + } + } + mysql_free_result($result); + $sot_ready = TRUE; + } + } + } + } + if (!isset($sot_ready)) { + $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); + $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0); + if ($result != FALSE && mysql_num_rows($result) > 0) { + while ($sts_tmp = mysql_fetch_array($result)) { + $tables[] = $sts_tmp; + } + mysql_free_result($result); + } + } + $num_tables = (isset($tables) ? count($tables) : 0); +} // end if (PMA_MYSQL_INT_VERSION >= 32303) +else { + $result = mysql_list_tables($db); + $num_tables = ($result) ? @mysql_numrows($result) : 0; + for ($i = 0; $i < $num_tables; $i++) { + $tables[] = mysql_tablename($result, $i); + } + mysql_free_result($result); +} + + +/** + * Displays top menu links + */ +echo '' . "\n"; +require('./db_details_links.php3'); + +?> \ No newline at end of file diff --git a/db_details_export.php3 b/db_details_export.php3 new file mode 100644 index 000000000..45ff2566b --- /dev/null +++ b/db_details_export.php3 @@ -0,0 +1,164 @@ + + +
      +
      + + + 1) { + $colspan = ' colspan="2"'; + ?> + + + + + + > + + + + + + > + + + + + + > + + + + += 32306) { + ?> + + > + + + + + + + > + + += 40004) { + $is_zip = (isset($cfg['ZipDump']) && $cfg['ZipDump'] && @function_exists('gzcompress')); + $is_gzip = (isset($cfg['GZipDump']) && $cfg['GZipDump'] && @function_exists('gzencode')); + $is_bzip = (isset($cfg['BZipDump']) && $cfg['BZipDump'] && @function_exists('bzcompress')); + if ($is_zip || $is_gzip || $is_bzip) { + echo "\n" . ' (' . "\n"; + if ($is_zip) { + ?> + + ' . $strZip . '' + . (($is_gzip || $is_bzip) ? ' ' : '') . "\n"; + } + if ($is_gzip) { + echo "\n" + ?> + + ' . $strGzip . '' + . (($is_bzip) ? ' ' : '') . "\n"; + } + if ($is_bzip) { + echo "\n" + ?> + + ' . $strBzip . '' . "\n"; + } + echo "\n" . ' )'; + } +} // end *zip feature +echo "\n"; + +// Encoding setting form appended by Y.Kawada +if (function_exists('PMA_set_enc_form')) { + echo '
      ' . "\n" + . PMA_set_enc_form(' '); +} +?> + +
      + + > + + + +
      + + + +
      + +
      + +
      + + + 1) { + ?> +
      + +  /  + + +
      + + + +
      + + + diff --git a/db_details_links.php3 b/db_details_links.php3 new file mode 100644 index 000000000..396ac8949 --- /dev/null +++ b/db_details_links.php3 @@ -0,0 +1,61 @@ + 0) { + $lnk3 = ''; +} +else { + $lnk3 = ''; +} +// Drop link if allowed +if (!$cfg['AllowUserDropDatabase']) { + // Check if the user is a Superuser + $result = @mysql_query('USE mysql'); + $cfg['AllowUserDropDatabase'] = (!mysql_error()); +} +if ($cfg['AllowUserDropDatabase']) { + $lnk4 = ''; +} +else { + $lnk4 = ''; +} + + +/** + * Displays links + */ +?> +

      + [  + +  | + +  | + + '; echo "\n"; ?> +  ]    + + + [  + + +  ] + +

      +
      diff --git a/db_details_structure.php3 b/db_details_structure.php3 new file mode 100644 index 000000000..ab2d11acd --- /dev/null +++ b/db_details_structure.php3 @@ -0,0 +1,454 @@ + + + + += 3.23.03 - staybyte - 11 June 2001 +else if (PMA_MYSQL_INT_VERSION >= 32303) { + ?> +
      + + + + + + + + + + + + ' . ucfirst($strSize) . ''; + } + echo "\n"; + ?> + + + + + + + + + + + + to get valid + // statistics whatever is the table type + if (isset($sts_data['Rows'])) { + // MyISAM, ISAM or Heap table: Row count, data size and index size + // is accurate. + if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) { + if ($cfg['ShowStats']) { + $tblsize = $sts_data['Data_length'] + $sts_data['Index_length']; + $sum_size += $tblsize; + list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); + } + $sum_entries += $sts_data['Rows']; + $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator); + } + + // InnoDB table: Row count is not accurate but data and index + // sizes are. + else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') { + if ($cfg['ShowStats']) { + $tblsize = $sts_data['Data_length'] + $sts_data['Index_length']; + $sum_size += $tblsize; + list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); + } + $display_rows = ' - '; + } + + // Merge or BerkleyDB table: Only row count is accurate. + else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) { + if ($cfg['ShowStats']) { + $formated_size = ' - '; + $unit = ''; + } + $sum_entries += $sts_data['Rows']; + $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator); + } + + // Unknown table type. + else { + if ($cfg['ShowStats']) { + $formated_size = 'unknown'; + $unit = ''; + } + $display_rows = 'unknown'; + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + +
        
      + /> + +     + + ' . $strBrowse . ''; + } else { + echo $strBrowse; + } + ?> + + ' + . $strSelect . ''; + } else { + echo $strSelect; + } + ?> + + + + + + + + + + + = 40000) { + echo urlencode('TRUNCATE ' . PMA_backquote($table)) + . '&zero_rows=' + . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table))) + . '" onclick="return confirmLink(this, \'TRUNCATE '; + } else { + echo urlencode('DELETE FROM ' . PMA_backquote($table)) + . '&zero_rows=' + . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table))) + . '" onclick="return confirmLink(this, \'DELETE FROM '; + } + echo PMA_jsFormat($table) . '\')">' . $strEmpty . ''; + } else { + echo $strEmpty; + } + ?> + + + +    + +    + + + +
      +    + + + + + + -- + +   + +
      + <?php echo $strWithChecked; ?> + + +  /  + + +     + + + + +
      + +
      + = 3.23.03 + +// 3. Shows tables list mysql < 3.23.03 +else { + $i = 0; + echo "\n"; + ?> +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
        
      + /> + +    + + + + + + + + + + + + + + +
      + <?php echo $strWithChecked; ?> + + +  /  + + +
      + +    + +    + +
      + +
      + +
      + + + + +
        + + 0) { + ?> + +
      • +
        +
      • + + + +
      • +
        + + + +' . "\n"; +echo ' ' . $strName . ' : ' . "\n"; +echo ' ' . '' . "\n"; +echo ' ' . '
        ' . "\n"; +echo ' ' . $strFields . ' : ' . "\n"; +echo ' ' . '' . "\n"; +echo ' ' . ' ' . "\n"; +?> +
        +
      • + +
      + + + + diff --git a/mult_submits.inc.php3 b/mult_submits.inc.php3 index 412751990..5acfac5ca 100644 --- a/mult_submits.inc.php3 +++ b/mult_submits.inc.php3 @@ -67,13 +67,6 @@ if (!empty($submit_mult) && !empty($what)) { . (($i == $selected_cnt - 1) ? ';
      ' : ''); break; -// loic1: removed confirmation stage for "OPTIMIZE" statements -// case 'optimize_tbl': -// $full_query .= (empty($full_query) ? 'OPTIMIZE TABLE ' : ', ') -// . PMA_backquote(htmlspecialchars(urldecode($selected[$i]))) -// . (($i == $selected_cnt - 1) ? ';
      ' : ''); -// break; - case 'empty_tbl': if (PMA_MYSQL_INT_VERSION >= 40000) { $full_query .= 'TRUNCATE '; @@ -112,9 +105,9 @@ if (!empty($submit_mult) && !empty($what)) { ' . "\n"; - } else if ($action == 'tbl_properties.php3') { + } else if (strpos(' ' . $action, 'tbl_properties') == 1) { echo ' ' . "\n"; echo ' ' . "\n"; } diff --git a/sql.php3 b/sql.php3 index 8ad19c3eb..ca1e5b563 100755 --- a/sql.php3 +++ b/sql.php3 @@ -27,11 +27,11 @@ if (empty($goto)) { $is_gotofile = TRUE; } if (!isset($err_url)) { - $err_url = $goto + $err_url = (!empty($back) ? $back : $goto) . '?lang=' . $lang . '&server=' . $server . (isset($db) ? '&db=' . urlencode($db) : '') - . (($goto != 'db_details.php3' && isset($table)) ? '&table=' . urlencode($table) : ''); + . ((strpos(' ' . $goto, 'db_details') != 1 && isset($table)) ? '&table=' . urlencode($table) : ''); } @@ -122,7 +122,7 @@ if (isset($btnDrop) && $btnDrop == $strNo) { $goto = $back; } if ($is_gotofile) { - if ($goto == 'db_details.php3' && !empty($table)) { + if (strpos(' ' . $goto, 'db_details') == 1 && !empty($table)) { unset($table); } include('./' . ereg_replace('\.\.*', '.', $goto)); @@ -340,7 +340,7 @@ else { unset($db); } $is_db = $is_table = FALSE; - if ($goto == 'tbl_properties.php3') { + if (strpos(' ' . $goto, 'tbl_properties') == 1) { if (!isset($table)) { $goto = 'db_details.php3'; } else { @@ -351,7 +351,7 @@ else { } } // end if... else... } - if ($goto == 'db_details.php3') { + if (strpos(' ' . $goto, 'db_details.php3') == 1) { if (isset($table)) { unset($table); } @@ -366,7 +366,8 @@ else { } // end if... else... } // Loads to target script - if ($goto == 'db_details.php3' || $goto == 'tbl_properties.php3') { + if (strpos(' ' . $goto, 'db_details') == 1 + || strpos(' ' . $goto, 'tbl_properties') == 1) { $js_to_run = 'functions.js'; } if ($goto != 'main.php3') {