function PMA_buildHtmlForDb($current, $is_superuser, $checkall, $url_query, $column_order, $replication_types, $replication_info) { $out = ''; if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) { $out .= '<td class="tool">'; $out .= '<input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" '; if ($current['SCHEMA_NAME'] != 'mysql' && $current['SCHEMA_NAME'] != 'information_schema') { $out .= (empty($checkall) ? '' : 'checked="checked" ') . '/>'; } else { $out .= ' disabled="disabled" />'; } $out .= '</td>'; } $out .= '<td class="name">' . ' <a onclick="' . 'if (window.parent.openDb && window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;' . '" href="index.php?' . $url_query . '&db=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME'])) . '" target="_parent">' . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . '</a>' . '</td>'; foreach ($column_order as $stat_name => $stat) { if (array_key_exists($stat_name, $current)) { if (is_numeric($stat['footer'])) { $column_order[$stat_name]['footer'] += $current[$stat_name]; } if ($stat['format'] === 'byte') { list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1); } elseif ($stat['format'] === 'number') { $value = PMA_formatNumber($current[$stat_name], 0); } else { $value = htmlentities($current[$stat_name], 0); } $out .= '<td class="value">'; if (isset($stat['description_function'])) { $out .= '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">'; } $out .= $value; if (isset($stat['description_function'])) { $out .= '</dfn>'; } $out .= '</td>'; if ($stat['format'] === 'byte') { $out .= '<td class="unit">' . $unit . '</td>'; } } } foreach ($replication_types as $type) { if ($replication_info[$type]['status']) { $out .= '<td class="tool" style="text-align: center;">'; if (strlen(array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB'])) > 0) { $out .= PMA_getIcon('s_cancel.png', __('Not replicated')); } else { $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']); if (strlen($key) > 0 || $replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1) { // if ($key != null) did not work for index "0" $out .= PMA_getIcon('s_success.png', __('Replicated')); } } $out .= '</td>'; } } if ($is_superuser) { $out .= '<td class="tool">' . '<a onclick="' . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');' . '" href="./server_privileges.php?' . $url_query . '&checkprivs=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Check privileges for database "%s".'), htmlspecialchars($current['SCHEMA_NAME'])) . '">' . ' ' . PMA_getIcon('s_rights.png', __('Check Privileges')) . '</a></td>'; } return array($column_order, $out); }
/** * Function for displaying the table of an engine's parameters * * @param array List of MySQL variables and corresponding localized descriptions. * The array elements should have the following format: * $variable => array('title' => $title, 'desc' => $description); * @param string Prefix for the SHOW VARIABLES query. * @return string The table that was generated based on the given information. */ function PMA_generateEngineDetails($variables, $like = null) { /** * Get the variables! */ if (!empty($variables)) { $sql_query = 'SHOW ' . (PMA_MYSQL_INT_VERSION >= 40102 ? 'GLOBAL ' : '') . 'VARIABLES' . (empty($like) ? '' : ' LIKE \'' . $like . '\'') . ';'; $res = PMA_DBI_query($sql_query); $mysql_vars = array(); while ($row = PMA_DBI_fetch_row($res)) { if (isset($variables[$row[0]])) { $mysql_vars[$row[0]] = $row[1]; } } PMA_DBI_free_result($res); unset($res, $row, $sql_query); } if (empty($mysql_vars)) { return '<p>' . "\n" . ' ' . $GLOBALS['strNoDetailsForEngine'] . "\n" . '</p>' . "\n"; } $dt_table = '<table class="data" cellspacing="1">' . "\n"; $odd_row = false; $has_content = false; foreach ($variables as $var => $details) { if (!isset($mysql_vars[$var])) { continue; } if (!isset($details['type'])) { $details['type'] = PMA_ENGINE_DETAILS_TYPE_PLAINTEXT; } $is_num = $details['type'] == PMA_ENGINE_DETAILS_TYPE_SIZE || $details['type'] == PMA_ENGINE_DETAILS_TYPE_NUMERIC; $dt_table .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n" . ' <td>' . "\n"; if (!empty($variables[$var]['desc'])) { $dt_table .= ' ' . PMA_showHint($details['desc']) . "\n"; } $dt_table .= ' </td>' . "\n" . ' <th>' . htmlspecialchars(empty($details['title']) ? $var : $details['title']) . "\n" . ' </th>' . "\n" . ' <td class="value">'; switch ($details['type']) { case PMA_ENGINE_DETAILS_TYPE_SIZE: $parsed_size = PMA_formatByteDown($mysql_vars[$var]); $dt_table .= $parsed_size[0] . ' ' . $parsed_size[1]; unset($parsed_size); break; case PMA_ENGINE_DETAILS_TYPE_NUMERIC: $dt_table .= PMA_formatNumber($mysql_vars[$var]) . ' '; break; default: $dt_table .= htmlspecialchars($mysql_vars[$var]) . ' '; } $dt_table .= '</td>' . "\n" . '</tr>' . "\n"; $odd_row = !$odd_row; $has_content = true; } if (!$has_content) { return ''; } $dt_table .= '</table>' . "\n"; return $dt_table; }
/** * returns html tables with stats over inno db buffer pool * * @uses PMA_DBI_fetch_result() * @uses PMA_formatNumber() * @uses PMA_formatByteDown() * @uses join() * @uses htmlspecialchars() * @uses PMA_formatNumber() * @return string html table with stats */ function getPageBufferpool() { // The following query is only possible because we know // that we are on MySQL 5 here (checked above)! // side note: I love MySQL 5 for this. :-) $sql = ' SHOW STATUS WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\' OR Variable_name = \'Innodb_page_size\';'; $status = PMA_DBI_fetch_result($sql, 0, 1); $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n" . ' <caption class="tblHeaders">' . "\n" . ' ' . __('Buffer Pool Usage') . "\n" . ' </caption>' . "\n" . ' <tfoot>' . "\n" . ' <tr>' . "\n" . ' <th colspan="2">' . "\n" . ' ' . __('Total') . "\n" . ' : ' . PMA_formatNumber($status['Innodb_buffer_pool_pages_total'], 0) . ' ' . __('pages') . ' / ' . join(' ', PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n" . ' </th>' . "\n" . ' </tr>' . "\n" . ' </tfoot>' . "\n" . ' <tbody>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Free pages') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_free'], 0) . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Dirty pages') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0) . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Pages containing data') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Pages to be flushed') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Busy pages') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n" . '</td>' . "\n" . ' </tr>'; // not present at least since MySQL 5.1.40 if (isset($status['Innodb_buffer_pool_pages_latched'])) { $output .= ' <tr class="even">' . ' <th>' . __('Latched pages') . '</th>' . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_latched'], 0) . '</td>' . ' </tr>'; } $output .= ' </tbody>' . "\n" . '</table>' . "\n\n" . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n" . ' <caption class="tblHeaders">' . "\n" . ' ' . __('Buffer Pool Activity') . "\n" . ' </caption>' . "\n" . ' <tbody>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Read requests') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Write requests') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Read misses') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Write waits') . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . __('Read misses in %') . '</th>' . "\n" . ' <td class="value">' . ($status['Innodb_buffer_pool_read_requests'] == 0 ? '---' : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . __('Write waits in %') . '</th>' . "\n" . ' <td class="value">' . ($status['Innodb_buffer_pool_write_requests'] == 0 ? '---' : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' </tbody>' . "\n" . '</table>' . "\n"; return $output; }
/** * Counts and returns (or displays) the number of records in a table * * Revision 13 July 2001: Patch for limiting dump size from * vinay@sanisoft.com & girish@sanisoft.com * * @param string the current database name * @param string the current table name * @param boolean whether to retain or to displays the result * @param boolean whether to force an exact count * * @return mixed the number of records if retain is required, true else * * @access public */ function countRecords($db, $table, $ret = false, $force_exact = false) { $row_count = false; if (!$force_exact) { $row_count = PMA_DBI_fetch_value('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\';', 0, 'Rows'); } $tbl_is_view = PMA_Table::isView($db, $table); if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) { if (!$tbl_is_view) { $row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)); // since counting all rows of a view could be too long } else { // try_query because it can fail ( a VIEW was based on // a table that no longer exists) $result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCount'], null, PMA_DBI_QUERY_STORE); if (!PMA_DBI_getError()) { $row_count = PMA_DBI_num_rows($result); PMA_DBI_free_result($result); } } } if ($ret) { return $row_count; } /** * @deprecated at the moment nowhere is $return = false used */ // Note: as of PMA 2.8.0, we no longer seem to be using // PMA_Table::countRecords() in display mode. echo PMA_formatNumber($row_count, 0); if ($tbl_is_view) { echo ' ' . sprintf($GLOBALS['strViewMaxExactCount'], $GLOBALS['cfg']['MaxExactCount'], '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]'); } }
/** * returns html tables with stats over inno db buffer pool * * @uses PMA_MYSQL_INT_VERSION * @uses PMA_DBI_fetch_result() * @uses PMA_formatNumber() * @uses PMA_formatByteDown() * @uses $GLOBALS['strBufferPoolUsage'] * @uses $GLOBALS['strTotalUC'] * @uses $GLOBALS['strInnoDBPages'] * @uses $GLOBALS['strFreePages'] * @uses $GLOBALS['strDirtyPages'] * @uses $GLOBALS['strDataPages'] * @uses $GLOBALS['strPagesToBeFlushed'] * @uses $GLOBALS['strBusyPages'] * @uses $GLOBALS['strLatchedPages'] * @uses $GLOBALS['strBufferPoolActivity'] * @uses $GLOBALS['strReadRequests'] * @uses $GLOBALS['strWriteRequests'] * @uses $GLOBALS['strBufferReadMisses'] * @uses $GLOBALS['strBufferWriteWaits'] * @uses $GLOBALS['strBufferReadMissesInPercent'] * @uses $GLOBALS['strBufferWriteWaitsInPercent'] * @uses join() * @uses htmlspecialchars() * @uses PMA_formatNumber() * @return string html table with stats */ function getPageBufferpool() { if (PMA_MYSQL_INT_VERSION < 50002) { return false; } // rabus: The following query is only possible because we know // that we are on MySQL 5 here (checked above)! // side note: I love MySQL 5 for this. :-) $sql = ' SHOW STATUS WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\' OR Variable_name = \'Innodb_page_size\';'; $status = PMA_DBI_fetch_result($sql, 0, 1); $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n" . ' <caption class="tblHeaders">' . "\n" . ' ' . $GLOBALS['strBufferPoolUsage'] . "\n" . ' </caption>' . "\n" . ' <tfoot>' . "\n" . ' <tr>' . "\n" . ' <th colspan="2">' . "\n" . ' ' . $GLOBALS['strTotalUC'] . "\n" . ' : ' . PMA_formatNumber($status['Innodb_buffer_pool_pages_total'], 0) . ' ' . $GLOBALS['strInnoDBPages'] . ' / ' . join(' ', PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n" . ' </th>' . "\n" . ' </tr>' . "\n" . ' </tfoot>' . "\n" . ' <tbody>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . $GLOBALS['strFreePages'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_free'], 0) . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . $GLOBALS['strDirtyPages'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0) . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . $GLOBALS['strDataPages'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . $GLOBALS['strPagesToBeFlushed'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . $GLOBALS['strBusyPages'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . $GLOBALS['strLatchedPages'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_pages_latched'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' </tbody>' . "\n" . '</table>' . "\n\n" . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n" . ' <caption class="tblHeaders">' . "\n" . ' ' . $GLOBALS['strBufferPoolActivity'] . "\n" . ' </caption>' . "\n" . ' <tbody>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . $GLOBALS['strReadRequests'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . $GLOBALS['strWriteRequests'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . $GLOBALS['strBufferReadMisses'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . $GLOBALS['strBufferWriteWaits'] . '</th>' . "\n" . ' <td class="value">' . PMA_formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="odd">' . "\n" . ' <th>' . $GLOBALS['strBufferReadMissesInPercent'] . '</th>' . "\n" . ' <td class="value">' . ($status['Innodb_buffer_pool_read_requests'] == 0 ? '---' : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr class="even">' . "\n" . ' <th>' . $GLOBALS['strBufferWriteWaitsInPercent'] . '</th>' . "\n" . ' <td class="value">' . ($status['Innodb_buffer_pool_write_requests'] == 0 ? '---' : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . ' </tr>' . "\n" . ' </tbody>' . "\n" . '</table>' . "\n"; return $output; }
if (isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) { ?> <tr> <td><?php echo ucfirst($strRowSize); ?> ø</td> <td align="right"> <?php echo $avg_size . ' ' . $avg_unit . "\n"; ?> </td> </tr> <?php } if (isset($showtable['Auto_increment'])) { ?> <tr> <td><?php echo ucfirst($strNext); ?> Autoindex</td> <td align="right"> <?php echo PMA_formatNumber($showtable['Auto_increment'], 0) . "\n"; ?> </td> </tr> <?php } if (isset($showtable['Create_time'])) { ?> <tr> <td><?php echo $strStatCreateTime; ?></td> <td align="right"> <?php echo PMA_localisedDate(strtotime($showtable['Create_time'])) . "\n"; ?> </td> </tr> <?php } if (isset($showtable['Update_time'])) {
</tbody> <tbody> <tr><th></th> <th align="center" nowrap="nowrap"> <?php // for blobstreaming - if the number of tables is 0, set tableReductionCount to 0 // (we don't want negative numbers here) - rajk if ($num_tables == 0) $tableReductionCount = 0; echo sprintf($strTables, PMA_formatNumber($num_tables - $tableReductionCount, 0)); ?> </th> <th colspan="<?php echo ($db_is_information_schema ? 3 : 6) ?>" align="center"> <?php echo $strSum; ?></th> <th class="value"><?php echo $sum_row_count_pre . PMA_formatNumber($sum_entries, 0); ?></th> <?php if (!($cfg['PropertiesNumColumns'] > 1)) { $default_engine = PMA_DBI_get_default_engine(); echo ' <th align="center">' . "\n" . ' <dfn title="' . sprintf($strDefaultEngine, $default_engine) . '">' .$default_engine . '</dfn></th>' . "\n"; // we got a case where $db_collation was empty echo ' <th align="center">' . "\n"; if (! empty($db_collation)) { echo ' <dfn title="' . PMA_getCollationDescr($db_collation) . ' (' . $strDefault . ')">' . $db_collation . '</dfn>'; } echo '</th>'; }
</td> </tr> <?php } if (isset($showtable['Auto_increment'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> "> <th class="name"><?php echo $strNext; ?> Autoindex</th> <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?> </td> </tr> <?php } if (isset($showtable['Create_time'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> "> <th class="name"><?php echo $strStatCreateTime; ?> </th>
</th> <?php if ($server_slave_status) { echo ' <th>' . __('Replication') . '</th>' . "\n"; } ?> <th colspan="<?php echo $db_is_information_schema ? 3 : 6; ?> " align="center"> <?php echo __('Sum'); ?> </th> <th class="value tbl_rows"><?php echo $sum_row_count_pre . PMA_formatNumber($sum_entries, 0); ?> </th> <?php if (!($cfg['PropertiesNumColumns'] > 1)) { $default_engine = PMA_DBI_get_default_engine(); echo ' <th align="center">' . "\n" . ' <dfn title="' . sprintf(__('%s is the default storage engine on this MySQL server.'), $default_engine) . '">' . $default_engine . '</dfn></th>' . "\n"; // we got a case where $db_collation was empty echo ' <th align="center">' . "\n"; if (!empty($db_collation)) { echo ' <dfn title="' . PMA_getCollationDescr($db_collation) . ' (' . __('Default') . ')">' . $db_collation . '</dfn>'; } echo '</th>'; } if ($is_show_stats) { ?>
function printVariablesTable() { global $server_status, $server_variables, $allocationMap, $links; /** * Messages are built using the message name */ $strShowStatus = array('Aborted_clients' => __('The number of connections that were aborted because the client died without closing the connection properly.'), 'Aborted_connects' => __('The number of failed attempts to connect to the MySQL server.'), 'Binlog_cache_disk_use' => __('The number of transactions that used the temporary binary log cache but that exceeded the value of binlog_cache_size and used a temporary file to store statements from the transaction.'), 'Binlog_cache_use' => __('The number of transactions that used the temporary binary log cache.'), 'Connections' => __('The number of connection attempts (successful or not) to the MySQL server.'), 'Created_tmp_disk_tables' => __('The number of temporary tables on disk created automatically by the server while executing statements. If Created_tmp_disk_tables is big, you may want to increase the tmp_table_size value to cause temporary tables to be memory-based instead of disk-based.'), 'Created_tmp_files' => __('How many temporary files mysqld has created.'), 'Created_tmp_tables' => __('The number of in-memory temporary tables created automatically by the server while executing statements.'), 'Delayed_errors' => __('The number of rows written with INSERT DELAYED for which some error occurred (probably duplicate key).'), 'Delayed_insert_threads' => __('The number of INSERT DELAYED handler threads in use. Every different table on which one uses INSERT DELAYED gets its own thread.'), 'Delayed_writes' => __('The number of INSERT DELAYED rows written.'), 'Flush_commands' => __('The number of executed FLUSH statements.'), 'Handler_commit' => __('The number of internal COMMIT statements.'), 'Handler_delete' => __('The number of times a row was deleted from a table.'), 'Handler_discover' => __('The MySQL server can ask the NDB Cluster storage engine if it knows about a table with a given name. This is called discovery. Handler_discover indicates the number of time tables have been discovered.'), 'Handler_read_first' => __('The number of times the first entry was read from an index. If this is high, it suggests that the server is doing a lot of full index scans; for example, SELECT col1 FROM foo, assuming that col1 is indexed.'), 'Handler_read_key' => __('The number of requests to read a row based on a key. If this is high, it is a good indication that your queries and tables are properly indexed.'), 'Handler_read_next' => __('The number of requests to read the next row in key order. This is incremented if you are querying an index column with a range constraint or if you are doing an index scan.'), 'Handler_read_prev' => __('The number of requests to read the previous row in key order. This read method is mainly used to optimize ORDER BY ... DESC.'), 'Handler_read_rnd' => __('The number of requests to read a row based on a fixed position. This is high if you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan whole tables or you have joins that don\'t use keys properly.'), 'Handler_read_rnd_next' => __('The number of requests to read the next row in the data file. This is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries are not written to take advantage of the indexes you have.'), 'Handler_rollback' => __('The number of internal ROLLBACK statements.'), 'Handler_update' => __('The number of requests to update a row in a table.'), 'Handler_write' => __('The number of requests to insert a row in a table.'), 'Innodb_buffer_pool_pages_data' => __('The number of pages containing data (dirty or clean).'), 'Innodb_buffer_pool_pages_dirty' => __('The number of pages currently dirty.'), 'Innodb_buffer_pool_pages_flushed' => __('The number of buffer pool pages that have been requested to be flushed.'), 'Innodb_buffer_pool_pages_free' => __('The number of free pages.'), 'Innodb_buffer_pool_pages_latched' => __('The number of latched pages in InnoDB buffer pool. These are pages currently being read or written or that can\'t be flushed or removed for some other reason.'), 'Innodb_buffer_pool_pages_misc' => __('The number of pages busy because they have been allocated for administrative overhead such as row locks or the adaptive hash index. This value can also be calculated as Innodb_buffer_pool_pages_total - Innodb_buffer_pool_pages_free - Innodb_buffer_pool_pages_data.'), 'Innodb_buffer_pool_pages_total' => __('Total size of buffer pool, in pages.'), 'Innodb_buffer_pool_read_ahead_rnd' => __('The number of "random" read-aheads InnoDB initiated. This happens when a query is to scan a large portion of a table but in random order.'), 'Innodb_buffer_pool_read_ahead_seq' => __('The number of sequential read-aheads InnoDB initiated. This happens when InnoDB does a sequential full table scan.'), 'Innodb_buffer_pool_read_requests' => __('The number of logical read requests InnoDB has done.'), 'Innodb_buffer_pool_reads' => __('The number of logical reads that InnoDB could not satisfy from buffer pool and had to do a single-page read.'), 'Innodb_buffer_pool_wait_free' => __('Normally, writes to the InnoDB buffer pool happen in the background. However, if it\'s necessary to read or create a page and no clean pages are available, it\'s necessary to wait for pages to be flushed first. This counter counts instances of these waits. If the buffer pool size was set properly, this value should be small.'), 'Innodb_buffer_pool_write_requests' => __('The number writes done to the InnoDB buffer pool.'), 'Innodb_data_fsyncs' => __('The number of fsync() operations so far.'), 'Innodb_data_pending_fsyncs' => __('The current number of pending fsync() operations.'), 'Innodb_data_pending_reads' => __('The current number of pending reads.'), 'Innodb_data_pending_writes' => __('The current number of pending writes.'), 'Innodb_data_read' => __('The amount of data read so far, in bytes.'), 'Innodb_data_reads' => __('The total number of data reads.'), 'Innodb_data_writes' => __('The total number of data writes.'), 'Innodb_data_written' => __('The amount of data written so far, in bytes.'), 'Innodb_dblwr_pages_written' => __('The number of pages that have been written for doublewrite operations.'), 'Innodb_dblwr_writes' => __('The number of doublewrite operations that have been performed.'), 'Innodb_log_waits' => __('The number of waits we had because log buffer was too small and we had to wait for it to be flushed before continuing.'), 'Innodb_log_write_requests' => __('The number of log write requests.'), 'Innodb_log_writes' => __('The number of physical writes to the log file.'), 'Innodb_os_log_fsyncs' => __('The number of fsync() writes done to the log file.'), 'Innodb_os_log_pending_fsyncs' => __('The number of pending log file fsyncs.'), 'Innodb_os_log_pending_writes' => __('Pending log file writes.'), 'Innodb_os_log_written' => __('The number of bytes written to the log file.'), 'Innodb_pages_created' => __('The number of pages created.'), 'Innodb_page_size' => __('The compiled-in InnoDB page size (default 16KB). Many values are counted in pages; the page size allows them to be easily converted to bytes.'), 'Innodb_pages_read' => __('The number of pages read.'), 'Innodb_pages_written' => __('The number of pages written.'), 'Innodb_row_lock_current_waits' => __('The number of row locks currently being waited for.'), 'Innodb_row_lock_time_avg' => __('The average time to acquire a row lock, in milliseconds.'), 'Innodb_row_lock_time' => __('The total time spent in acquiring row locks, in milliseconds.'), 'Innodb_row_lock_time_max' => __('The maximum time to acquire a row lock, in milliseconds.'), 'Innodb_row_lock_waits' => __('The number of times a row lock had to be waited for.'), 'Innodb_rows_deleted' => __('The number of rows deleted from InnoDB tables.'), 'Innodb_rows_inserted' => __('The number of rows inserted in InnoDB tables.'), 'Innodb_rows_read' => __('The number of rows read from InnoDB tables.'), 'Innodb_rows_updated' => __('The number of rows updated in InnoDB tables.'), 'Key_blocks_not_flushed' => __('The number of key blocks in the key cache that have changed but haven\'t yet been flushed to disk. It used to be known as Not_flushed_key_blocks.'), 'Key_blocks_unused' => __('The number of unused blocks in the key cache. You can use this value to determine how much of the key cache is in use.'), 'Key_blocks_used' => __('The number of used blocks in the key cache. This value is a high-water mark that indicates the maximum number of blocks that have ever been in use at one time.'), 'Key_read_requests' => __('The number of requests to read a key block from the cache.'), 'Key_reads' => __('The number of physical reads of a key block from disk. If Key_reads is big, then your key_buffer_size value is probably too small. The cache miss rate can be calculated as Key_reads/Key_read_requests.'), 'Key_write_requests' => __('The number of requests to write a key block to the cache.'), 'Key_writes' => __('The number of physical writes of a key block to disk.'), 'Last_query_cost' => __('The total cost of the last compiled query as computed by the query optimizer. Useful for comparing the cost of different query plans for the same query. The default value of 0 means that no query has been compiled yet.'), 'Max_used_connections' => __('The maximum number of connections that have been in use simultaneously since the server started.'), 'Not_flushed_delayed_rows' => __('The number of rows waiting to be written in INSERT DELAYED queues.'), 'Opened_tables' => __('The number of tables that have been opened. If opened tables is big, your table cache value is probably too small.'), 'Open_files' => __('The number of files that are open.'), 'Open_streams' => __('The number of streams that are open (used mainly for logging).'), 'Open_tables' => __('The number of tables that are open.'), 'Qcache_free_blocks' => __('The number of free memory blocks in query cache. High numbers can indicate fragmentation issues, which may be solved by issuing a FLUSH QUERY CACHE statement.'), 'Qcache_free_memory' => __('The amount of free memory for query cache.'), 'Qcache_hits' => __('The number of cache hits.'), 'Qcache_inserts' => __('The number of queries added to the cache.'), 'Qcache_lowmem_prunes' => __('The number of queries that have been removed from the cache to free up memory for caching new queries. This information can help you tune the query cache size. The query cache uses a least recently used (LRU) strategy to decide which queries to remove from the cache.'), 'Qcache_not_cached' => __('The number of non-cached queries (not cachable, or not cached due to the query_cache_type setting).'), 'Qcache_queries_in_cache' => __('The number of queries registered in the cache.'), 'Qcache_total_blocks' => __('The total number of blocks in the query cache.'), 'Rpl_status' => __('The status of failsafe replication (not yet implemented).'), 'Select_full_join' => __('The number of joins that do not use indexes. If this value is not 0, you should carefully check the indexes of your tables.'), 'Select_full_range_join' => __('The number of joins that used a range search on a reference table.'), 'Select_range_check' => __('The number of joins without keys that check for key usage after each row. (If this is not 0, you should carefully check the indexes of your tables.)'), 'Select_range' => __('The number of joins that used ranges on the first table. (It\'s normally not critical even if this is big.)'), 'Select_scan' => __('The number of joins that did a full scan of the first table.'), 'Slave_open_temp_tables' => __('The number of temporary tables currently open by the slave SQL thread.'), 'Slave_retried_transactions' => __('Total (since startup) number of times the replication slave SQL thread has retried transactions.'), 'Slave_running' => __('This is ON if this server is a slave that is connected to a master.'), 'Slow_launch_threads' => __('The number of threads that have taken more than slow_launch_time seconds to create.'), 'Slow_queries' => __('The number of queries that have taken more than long_query_time seconds.'), 'Sort_merge_passes' => __('The number of merge passes the sort algorithm has had to do. If this value is large, you should consider increasing the value of the sort_buffer_size system variable.'), 'Sort_range' => __('The number of sorts that were done with ranges.'), 'Sort_rows' => __('The number of sorted rows.'), 'Sort_scan' => __('The number of sorts that were done by scanning the table.'), 'Table_locks_immediate' => __('The number of times that a table lock was acquired immediately.'), 'Table_locks_waited' => __('The number of times that a table lock could not be acquired immediately and a wait was needed. If this is high, and you have performance problems, you should first optimize your queries, and then either split your table or tables or use replication.'), 'Threads_cached' => __('The number of threads in the thread cache. The cache hit rate can be calculated as Threads_created/Connections. If this value is red you should raise your thread_cache_size.'), 'Threads_connected' => __('The number of currently open connections.'), 'Threads_created' => __('The number of threads created to handle connections. If Threads_created is big, you may want to increase the thread_cache_size value. (Normally this doesn\'t give a notable performance improvement if you have a good thread implementation.)'), 'Threads_running' => __('The number of threads that are not sleeping.')); /** * define some alerts */ // name => max value before alert $alerts = array('Aborted_clients' => 0, 'Aborted_connects' => 0, 'Binlog_cache_disk_use' => 0, 'Created_tmp_disk_tables' => 0, 'Handler_read_rnd' => 0, 'Handler_read_rnd_next' => 0, 'Innodb_buffer_pool_pages_dirty' => 0, 'Innodb_buffer_pool_reads' => 0, 'Innodb_buffer_pool_wait_free' => 0, 'Innodb_log_waits' => 0, 'Innodb_row_lock_time_avg' => 10, 'Innodb_row_lock_time_max' => 50, 'Innodb_row_lock_waits' => 0, 'Slow_queries' => 0, 'Delayed_errors' => 0, 'Select_full_join' => 0, 'Select_range_check' => 0, 'Sort_merge_passes' => 0, 'Opened_tables' => 0, 'Table_locks_waited' => 0, 'Qcache_lowmem_prunes' => 0, 'Qcache_free_blocks' => isset($server_status['Qcache_total_blocks']) ? $server_status['Qcache_total_blocks'] / 5 : 0, 'Slow_launch_threads' => 0, 'Key_reads' => isset($server_status['Key_read_requests']) ? 0.01 * $server_status['Key_read_requests'] : 0, 'Key_writes' => isset($server_status['Key_write_requests']) ? 0.9 * $server_status['Key_write_requests'] : 0, 'Key_buffer_fraction' => 0.5, 'Threads_cached' => isset($server_variables['thread_cache_size']) ? 0.95 * $server_variables['thread_cache_size'] : 0); ?> <table class="data sortable noclick" id="serverstatusvariables"> <col class="namecol" /> <col class="valuecol" /> <col class="descrcol" /> <thead> <tr> <th><?php echo __('Variable'); ?> </th> <th><?php echo __('Value'); ?> </th> <th><?php echo __('Description'); ?> </th> </tr> </thead> <tbody> <?php $odd_row = false; foreach ($server_status as $name => $value) { $odd_row = !$odd_row; ?> <tr class="<?php echo $odd_row ? 'odd' : 'even'; echo isset($allocationMap[$name]) ? ' s_' . $allocationMap[$name] : ''; ?> "> <th class="name"><?php echo htmlspecialchars(str_replace('_', ' ', $name)); /* Fields containing % are calculated, they can not be described in MySQL documentation */ if (strpos($name, '%') === FALSE) { echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name); } ?> </th> <td class="value"><span class="formatted"><?php if (isset($alerts[$name])) { if ($value > $alerts[$name]) { echo '<span class="attention">'; } else { echo '<span class="allfine">'; } } if ('%' === substr($name, -1, 1)) { echo htmlspecialchars(PMA_formatNumber($value, 0, 2)) . ' %'; } elseif (strpos($name, 'Uptime') !== false) { echo htmlspecialchars(PMA_timespanFormat($value)); } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) { echo htmlspecialchars(PMA_formatNumber($value, 3, 1)); } elseif (is_numeric($value) && $value == (int) $value) { echo htmlspecialchars(PMA_formatNumber($value, 3, 0)); } elseif (is_numeric($value)) { echo htmlspecialchars(PMA_formatNumber($value, 3, 1)); } else { echo htmlspecialchars($value); } if (isset($alerts[$name])) { echo '</span>'; } ?> </span><span style="display:none;" class="original"><?php echo $value; ?> </span> </td> <td class="descr"> <?php if (isset($strShowStatus[$name])) { echo $strShowStatus[$name]; } if (isset($links[$name])) { foreach ($links[$name] as $link_name => $link_url) { if ('doc' == $link_name) { echo PMA_showMySQLDocu($link_url, $link_url); } else { echo ' <a href="' . $link_url . '">' . $link_name . '</a>' . "\n"; } } unset($link_url, $link_name); } ?> </td> </tr> <?php } ?> </tbody> </table> <?php }
$(document).ready(makeProfilingChart); </script> <?php echo '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n"; echo '<div style="float: left;">'; echo '<table>' . "\n"; echo ' <tr>' . "\n"; echo ' <th>' . __('Status') . PMA_showMySQLDocu('general-thread-states', 'general-thread-states') . '</th>' . "\n"; echo ' <th>' . __('Time') . '</th>' . "\n"; echo ' </tr>' . "\n"; $chart_json = Array(); foreach ($profiling_results as $one_result) { echo ' <tr>' . "\n"; echo '<td>' . ucwords($one_result['Status']) . '</td>' . "\n"; echo '<td class="right">' . (PMA_formatNumber($one_result['Duration'], 3, 1)) . 's</td>' . "\n"; $chart_json[ucwords($one_result['Status'])] = $one_result['Duration']; } echo '</table>' . "\n"; echo '</div>'; //require_once 'libraries/chart.lib.php'; echo '<div id="profilingchart" style="display:none;">'; //PMA_chart_profiling($profiling_results); echo json_encode($chart_json); echo '</div>'; echo '</fieldset>' . "\n"; } // Displays the results in a table if (empty($disp_mode)) {
/** * display unordered list of tables * calls itself recursively if table in given list * is a list itself * * @uses is_array() * @uses count() * @uses urlencode() * @uses strpos() * @uses printf() * @uses htmlspecialchars() * @uses strlen() * @uses is_array() * @uses PMA_displayTableList() * @uses $_REQUEST['tbl_group'] * @uses $GLOBALS['common_url_query'] * @uses $GLOBALS['table'] * @uses $GLOBALS['pmaThemeImage'] * @uses $GLOBALS['cfg']['LeftFrameTableSeparator'] * @uses $GLOBALS['cfg']['DefaultTabDatabase'] * @uses $GLOBALS['cfg']['DefaultTabTable'] * @uses $GLOBALS['strRows'] * @uses $GLOBALS['strBrowse'] * @global integer the element counter * @global string html code for '-' image * @global string html code for '+' image * @global string html code for self link * @param array $tables array of tables/tablegroups * @param boolean $visible whether the list is visible or not * @param string $tab_group_full full tab group name * @param string $table_db db of this table */ function PMA_displayTableList($tables, $visible = false, $tab_group_full = '', $table_db = '') { if (!is_array($tables) || count($tables) === 0) { return; } global $element_counter, $img_minus, $img_plus, $href_left; $sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; if ($visible) { echo '<ul id="subel' . $element_counter . '">'; } else { echo '<ul id="subel' . $element_counter . '" style="display: none">'; } foreach ($tables as $group => $table) { // only allow grouping if the group has more than 1 table if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) { $common_url_query = $GLOBALS['common_url_query'] . '&tbl_group=' . urlencode($tab_group_full . $group); $element_counter++; echo '<li>' . "\n"; if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || strpos($GLOBALS['table'], $group) === 0)) { printf($href_left, $element_counter, $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full); printf($img_minus, $element_counter); } else { printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } echo '</a>'; ?> <a href="index.php?<?php echo $common_url_query; ?> " target="_parent" onclick=" if (! toggle('<?php echo $element_counter; ?> ', true)) window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?> '); window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?> ', 'main'); return false;"> <?php if ($GLOBALS['text_dir'] === 'rtl') { echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep))); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } ?> </a> <?php unset($table['is' . $sep . 'group']); unset($table['tab' . $sep . 'group']); unset($table['tab' . $sep . 'count']); if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || strpos($GLOBALS['table'], $group) === 0)) { PMA_displayTableList($table, true, $tab_group_full . $group, $table_db); } else { PMA_displayTableList($table, false, '', $table_db); } echo '</li>' . "\n"; } elseif (is_array($table)) { // the table was not grouped because it is the only one with its prefix if (isset($table['is' . $sep . 'group'])) { // get the array with the actual table information foreach ($table as $value) { if (is_array($value)) { $table = $value; } } } $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']); // quick access icon next to each table name echo '<li>' . "\n"; echo '<a title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"' . ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $GLOBALS['common_url_query'] . '&table=' . urlencode($table['Name']) . '&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >' . '<img class="icon"'; if ('VIEW' === strtoupper($table['Comment'])) { echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"'; } else { echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"'; } echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' width="10" height="10" alt="' . htmlspecialchars($link_title) . '" /></a>' . "\n"; // link for the table name itself $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['common_url_query'] . '&table=' . urlencode($table['Name']) . '&pos=0'; echo '<a href="' . $href . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"' . ' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>'; echo '</li>' . "\n"; } } echo '</ul>'; }
/** * Displays a message at the top of the "main" (right) frame * * @param string the message to display * * @global array the configuration array * * @access public */ function PMA_showMessage($message) { global $cfg; // Sanitizes $message $message = PMA_sanitize($message); // Corrects the tooltip text via JS if required if (isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) { $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\''); if ($result) { $tbl_status = PMA_DBI_fetch_assoc($result); $tooltip = empty($tbl_status['Comment']) ? '' : $tbl_status['Comment'] . ' '; $tooltip .= '(' . PMA_formatNumber($tbl_status['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')'; PMA_DBI_free_result($result); $uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false); echo "\n"; ?> <script type="text/javascript" language="javascript"> //<![CDATA[ window.parent.updateTableTitle('<?php echo $uni_tbl; ?> ', '<?php echo PMA_jsFormat($tooltip, false); ?> '); //]]> </script> <?php } // end if } // end if ... elseif // Checks if the table needs to be repaired after a TRUNCATE query. if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) { if (!isset($tbl_status)) { $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\''); if ($result) { $tbl_status = PMA_DBI_fetch_assoc($result); PMA_DBI_free_result($result); } } if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) { PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])); } } unset($tbl_status); ?> <br /> <div align="<?php echo $GLOBALS['cell_align_left']; ?> "> <?php if (!empty($GLOBALS['show_error_header'])) { ?> <div class="error"> <h1><?php echo $GLOBALS['strError']; ?> </h1> <?php } echo $message; if (isset($GLOBALS['special_message'])) { echo PMA_sanitize($GLOBALS['special_message']); unset($GLOBALS['special_message']); } if (!empty($GLOBALS['show_error_header'])) { echo '</div>'; } if ($cfg['ShowSQL'] == true && (!empty($GLOBALS['sql_query']) || !empty($GLOBALS['display_query']))) { $local_query = !empty($GLOBALS['display_query']) ? $GLOBALS['display_query'] : ($cfg['SQP']['fmtType'] == 'none' && isset($GLOBALS['unparsed_sql']) && $GLOBALS['unparsed_sql'] != '' ? $GLOBALS['unparsed_sql'] : $GLOBALS['sql_query']); // Basic url query part $url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : ''); // Html format the query to be displayed // The nl2br function isn't used because its result isn't a valid // xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />") // If we want to show some sql code it is easiest to create it here /* SQL-Parser-Analyzer */ if (!empty($GLOBALS['show_as_php'])) { $new_line = '\'<br />' . "\n" . ' . \' '; } if (isset($new_line)) { /* SQL-Parser-Analyzer */ $query_base = PMA_sqlAddslashes(htmlspecialchars($local_query), false, false, true); /* SQL-Parser-Analyzer */ $query_base = preg_replace("@((\r\n)|(\r)|(\n))+@", $new_line, $query_base); } else { $query_base = $local_query; } // Parse SQL if needed if (isset($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) { $parsed_sql = $GLOBALS['parsed_sql']; } else { // when the query is large (for example an INSERT of binary // data), the parser chokes; so avoid parsing the query if (strlen($query_base) < 1000) { $parsed_sql = PMA_SQP_parse($query_base); } } // Analyze it if (isset($parsed_sql)) { $analyzed_display_query = PMA_SQP_analyze($parsed_sql); } // Here we append the LIMIT added for navigation, to // enable its display. Adding it higher in the code // to $local_query would create a problem when // using the Refresh or Edit links. // Only append it on SELECTs. // FIXME: what would be the best to do when someone // hits Refresh: use the current LIMITs ? if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) { $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit']; // Need to reparse query $parsed_sql = PMA_SQP_parse($query_base); } if (!empty($GLOBALS['show_as_php'])) { $query_base = '$sql = \'' . $query_base; } elseif (!empty($GLOBALS['validatequery'])) { $query_base = PMA_validateSQL($query_base); } else { if (isset($parsed_sql)) { $query_base = PMA_formatSql($parsed_sql, $query_base); } } // Prepares links that may be displayed to edit/explain the query // (don't go to default pages, we must go to the page // where the query box is available) // (also, I don't see why we should check the goto variable) //if (!isset($GLOBALS['goto'])) { //$edit_target = (isset($GLOBALS['table'])) ? $cfg['DefaultTabTable'] : $cfg['DefaultTabDatabase']; $edit_target = isset($GLOBALS['db']) ? isset($GLOBALS['table']) ? 'tbl_properties.php' : 'db_details.php' : 'server_sql.php'; //} elseif ($GLOBALS['goto'] != 'main.php') { // $edit_target = $GLOBALS['goto']; //} else { // $edit_target = ''; //} if (isset($cfg['SQLQuery']['Edit']) && $cfg['SQLQuery']['Edit'] == true && !empty($edit_target)) { if ($cfg['EditInWindow'] == true) { $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($local_query, false) . '\'); return false;'; } else { $onclick = ''; } $edit_link = $edit_target . $url_qpart . '&sql_query=' . urlencode($local_query) . '&show_query=1#querybox'; $edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']'; } else { $edit_link = ''; } // Want to have the query explained (Mike Beck 2002-05-22) // but only explain a SELECT (that has not been explained) /* SQL-Parser-Analyzer */ if (isset($cfg['SQLQuery']['Explain']) && $cfg['SQLQuery']['Explain'] == true) { // Detect if we are validating as well // To preserve the validate uRL data if (!empty($GLOBALS['validatequery'])) { $explain_link_validate = '&validatequery=1'; } else { $explain_link_validate = ''; } $explain_link = 'import.php' . $url_qpart . $explain_link_validate . '&sql_query='; if (preg_match('@^SELECT[[:space:]]+@i', $local_query)) { $explain_link .= urlencode('EXPLAIN ' . $local_query); $message = $GLOBALS['strExplain']; } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $local_query)) { $explain_link .= urlencode(substr($local_query, 8)); $message = $GLOBALS['strNoExplain']; } else { $explain_link = ''; } if (!empty($explain_link)) { $explain_link = ' [' . PMA_linkOrButton($explain_link, $message) . ']'; } } else { $explain_link = ''; } //show explain // Also we would like to get the SQL formed in some nice // php-code (Mike Beck 2002-05-22) if (isset($cfg['SQLQuery']['ShowAsPHP']) && $cfg['SQLQuery']['ShowAsPHP'] == true) { $php_link = 'import.php' . $url_qpart . '&show_query=1' . '&sql_query=' . urlencode($local_query) . '&show_as_php='; if (!empty($GLOBALS['show_as_php'])) { $php_link .= '0'; $message = $GLOBALS['strNoPhp']; } else { $php_link .= '1'; $message = $GLOBALS['strPhp']; } $php_link = ' [' . PMA_linkOrButton($php_link, $message) . ']'; if (isset($GLOBALS['show_as_php']) && $GLOBALS['show_as_php'] == '1') { $runquery_link = 'import.php' . $url_qpart . '&show_query=1' . '&sql_query=' . urlencode($local_query); $php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']'; } } else { $php_link = ''; } //show as php // Refresh query if (isset($cfg['SQLQuery']['Refresh']) && $cfg['SQLQuery']['Refresh'] && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $local_query)) { $refresh_link = 'import.php' . $url_qpart . '&show_query=1' . (isset($_GET['pos']) ? '&pos=' . $_GET['pos'] : '') . '&sql_query=' . urlencode($local_query); $refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']'; } else { $refresh_link = ''; } //show as php if (isset($cfg['SQLValidator']['use']) && $cfg['SQLValidator']['use'] == true && isset($cfg['SQLQuery']['Validate']) && $cfg['SQLQuery']['Validate'] == true) { $validate_link = 'import.php' . $url_qpart . '&show_query=1' . '&sql_query=' . urlencode($local_query) . '&validatequery='; if (!empty($GLOBALS['validatequery'])) { $validate_link .= '0'; $validate_message = $GLOBALS['strNoValidateSQL']; } else { $validate_link .= '1'; $validate_message = $GLOBALS['strValidateSQL']; } $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']'; } else { $validate_link = ''; } //validator unset($local_query); // Displays the message echo '<fieldset class="">' . "\n"; echo ' <legend>' . $GLOBALS['strSQLQuery'] . ':</legend>'; echo ' ' . $query_base; //Clean up the end of the PHP if (!empty($GLOBALS['show_as_php'])) { echo '\';'; } echo '</fieldset>' . "\n"; if (!empty($edit_target)) { echo '<fieldset class="tblFooters">'; echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link; echo '</fieldset>'; } } ?> </div><br /> <?php }
<noscript> <input type="submit" value="<?php echo $strGo; ?> " /> </noscript> <?php echo implode("\n", $hidden_fields) . "\n"; ?> </div> </form> <?php // Notice about row count for views if ($at_least_one_view_exceeds_max_count && !$db_is_information_schema) { echo '<div class="notice">' . "\n"; echo '<sup>1</sup>' . PMA_sanitize(sprintf($strViewMaxExactCount, PMA_formatNumber($cfg['MaxExactCountViews'], 0), '[a@./Documentation.html#cfg_MaxExactCountViews@_blank]', '[/a]')) . "\n"; echo '</div>' . "\n"; } // display again the table list navigator PMA_listNavigator($total_num_tables, $pos, $_url_params, 'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']); ?> <hr /> <?php // Routines require './libraries/db_routines.inc.php'; /** * Work on the database * redesigned 2004-05-08 by mkkeck */ /* DATABASE WORK */
/** * displays the message and the query * usually the message is the result of the query executed * * @param string $message the message to display * @param string $sql_query the query to display * @global array the configuration array * @uses $GLOBALS['cfg'] * @access public */ function PMA_showMessage($message, $sql_query = null) { global $cfg; if (null === $sql_query) { if (!empty($GLOBALS['display_query'])) { $sql_query = $GLOBALS['display_query']; } elseif ($cfg['SQP']['fmtType'] == 'none' && !empty($GLOBALS['unparsed_sql'])) { $sql_query = $GLOBALS['unparsed_sql']; // could be empty, for example export + save on server } elseif (!empty($GLOBALS['sql_query'])) { $sql_query = $GLOBALS['sql_query']; } else { $sql_query = ''; } } // Corrects the tooltip text via JS if required // @todo this is REALLY the wrong place to do this - very unexpected here if (isset($GLOBALS['table']) && strlen($GLOBALS['table']) && $cfg['ShowTooltip']) { $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\''); if ($result) { $tbl_status = PMA_DBI_fetch_assoc($result); $tooltip = empty($tbl_status['Comment']) ? '' : $tbl_status['Comment'] . ' '; $tooltip .= '(' . PMA_formatNumber($tbl_status['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')'; PMA_DBI_free_result($result); $uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false); echo "\n"; echo '<script type="text/javascript" language="javascript">' . "\n"; echo '//<![CDATA[' . "\n"; echo "window.parent.updateTableTitle('" . $uni_tbl . "', '" . PMA_jsFormat($tooltip, false) . "');" . "\n"; echo '//]]>' . "\n"; echo '</script>' . "\n"; } // end if } // end if ... elseif // Checks if the table needs to be repaired after a TRUNCATE query. // @todo this should only be done if isset($GLOBALS['sql_query']), what about $GLOBALS['display_query']??? // @todo this is REALLY the wrong place to do this - very unexpected here if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) { if (!isset($tbl_status)) { $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], true) . '\''); if ($result) { $tbl_status = PMA_DBI_fetch_assoc($result); PMA_DBI_free_result($result); } } if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) { PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])); } } unset($tbl_status); echo '<br />' . "\n"; echo '<div align="' . $GLOBALS['cell_align_left'] . '">' . "\n"; if (!empty($GLOBALS['show_error_header'])) { echo '<div class="error">' . "\n"; echo '<h1>' . $GLOBALS['strError'] . '</h1>' . "\n"; } echo '<div class="notice">'; echo PMA_sanitize($message); if (isset($GLOBALS['special_message'])) { echo PMA_sanitize($GLOBALS['special_message']); unset($GLOBALS['special_message']); } echo '</div>'; if (!empty($GLOBALS['show_error_header'])) { echo '</div>'; } if ($cfg['ShowSQL'] == true && !empty($sql_query)) { // Basic url query part $url_qpart = '?' . PMA_generate_common_url(isset($GLOBALS['db']) ? $GLOBALS['db'] : '', isset($GLOBALS['table']) ? $GLOBALS['table'] : ''); // Html format the query to be displayed // The nl2br function isn't used because its result isn't a valid // xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />") // If we want to show some sql code it is easiest to create it here /* SQL-Parser-Analyzer */ if (!empty($GLOBALS['show_as_php'])) { $new_line = '\'<br />' . "\n" . ' . \' '; } if (isset($new_line)) { /* SQL-Parser-Analyzer */ $query_base = PMA_sqlAddslashes(htmlspecialchars($sql_query), false, false, true); /* SQL-Parser-Analyzer */ $query_base = preg_replace("@((\r\n)|(\r)|(\n))+@", $new_line, $query_base); } else { $query_base = $sql_query; } $max_characters = 1000; if (!defined('PMA_QUERY_TOO_BIG') && strlen($query_base) > $max_characters) { define('PMA_QUERY_TOO_BIG', 1); $query_base = nl2br(htmlspecialchars($sql_query)); } // Parse SQL if needed // (here, use "! empty" because when deleting a bookmark, // $GLOBALS['parsed_sql'] is set but empty if (!empty($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) { $parsed_sql = $GLOBALS['parsed_sql']; } else { // when the query is large (for example an INSERT of binary // data), the parser chokes; so avoid parsing the query if (!defined('PMA_QUERY_TOO_BIG')) { $parsed_sql = PMA_SQP_parse($query_base); } } // Analyze it if (isset($parsed_sql)) { $analyzed_display_query = PMA_SQP_analyze($parsed_sql); } // Here we append the LIMIT added for navigation, to // enable its display. Adding it higher in the code // to $sql_query would create a problem when // using the Refresh or Edit links. // Only append it on SELECTs. /** * @todo what would be the best to do when someone hits Refresh: * use the current LIMITs ? */ if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) { $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit']; // Need to reparse query $parsed_sql = PMA_SQP_parse($query_base); } if (!empty($GLOBALS['show_as_php'])) { $query_base = '$sql = \'' . $query_base; } elseif (!empty($GLOBALS['validatequery'])) { $query_base = PMA_validateSQL($query_base); } else { if (isset($parsed_sql)) { $query_base = PMA_formatSql($parsed_sql, $query_base); } } // Prepares links that may be displayed to edit/explain the query // (don't go to default pages, we must go to the page // where the query box is available) $edit_target = isset($GLOBALS['db']) ? isset($GLOBALS['table']) ? 'tbl_sql.php' : 'db_sql.php' : 'server_sql.php'; if (isset($cfg['SQLQuery']['Edit']) && $cfg['SQLQuery']['Edit'] == true && !empty($edit_target) && !defined('PMA_QUERY_TOO_BIG')) { if ($cfg['EditInWindow'] == true) { $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;'; } else { $onclick = ''; } $edit_link = $edit_target . $url_qpart . '&sql_query=' . urlencode($sql_query) . '&show_query=1#querybox'; $edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']'; } else { $edit_link = ''; } // Want to have the query explained (Mike Beck 2002-05-22) // but only explain a SELECT (that has not been explained) /* SQL-Parser-Analyzer */ if (isset($cfg['SQLQuery']['Explain']) && $cfg['SQLQuery']['Explain'] == true && !defined('PMA_QUERY_TOO_BIG')) { // Detect if we are validating as well // To preserve the validate uRL data if (!empty($GLOBALS['validatequery'])) { $explain_link_validate = '&validatequery=1'; } else { $explain_link_validate = ''; } $explain_link = 'import.php' . $url_qpart . $explain_link_validate . '&sql_query='; if (preg_match('@^SELECT[[:space:]]+@i', $sql_query)) { $explain_link .= urlencode('EXPLAIN ' . $sql_query); $message = $GLOBALS['strExplain']; } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) { $explain_link .= urlencode(substr($sql_query, 8)); $message = $GLOBALS['strNoExplain']; } else { $explain_link = ''; } if (!empty($explain_link)) { $explain_link = ' [' . PMA_linkOrButton($explain_link, $message) . ']'; } } else { $explain_link = ''; } //show explain // Also we would like to get the SQL formed in some nice // php-code (Mike Beck 2002-05-22) if (isset($cfg['SQLQuery']['ShowAsPHP']) && $cfg['SQLQuery']['ShowAsPHP'] == true && !defined('PMA_QUERY_TOO_BIG')) { $php_link = 'import.php' . $url_qpart . '&show_query=1' . '&sql_query=' . urlencode($sql_query) . '&show_as_php='; if (!empty($GLOBALS['show_as_php'])) { $php_link .= '0'; $message = $GLOBALS['strNoPhp']; } else { $php_link .= '1'; $message = $GLOBALS['strPhp']; } $php_link = ' [' . PMA_linkOrButton($php_link, $message) . ']'; if (isset($GLOBALS['show_as_php'])) { $runquery_link = 'import.php' . $url_qpart . '&show_query=1' . '&sql_query=' . urlencode($sql_query); $php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']'; } } else { $php_link = ''; } //show as php // Refresh query if (isset($cfg['SQLQuery']['Refresh']) && $cfg['SQLQuery']['Refresh'] && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) { $refresh_link = 'import.php' . $url_qpart . '&show_query=1' . (isset($_GET['pos']) ? '&pos=' . $_GET['pos'] : '') . '&sql_query=' . urlencode($sql_query); $refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']'; } else { $refresh_link = ''; } //show as php if (isset($cfg['SQLValidator']['use']) && $cfg['SQLValidator']['use'] == true && isset($cfg['SQLQuery']['Validate']) && $cfg['SQLQuery']['Validate'] == true) { $validate_link = 'import.php' . $url_qpart . '&show_query=1' . '&sql_query=' . urlencode($sql_query) . '&validatequery='; if (!empty($GLOBALS['validatequery'])) { $validate_link .= '0'; $validate_message = $GLOBALS['strNoValidateSQL']; } else { $validate_link .= '1'; $validate_message = $GLOBALS['strValidateSQL']; } $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']'; } else { $validate_link = ''; } //validator unset($sql_query); // Displays the message echo '<fieldset class="">' . "\n"; echo ' <legend>' . $GLOBALS['strSQLQuery'] . ':</legend>'; echo ' <div>'; // when uploading a 700 Kio binary file into a LONGBLOB, // I get a white page, strlen($query_base) is 2 x 700 Kio // so put a hard limit here (let's say 1000) if (defined('PMA_QUERY_TOO_BIG')) { echo ' ' . substr($query_base, 0, $max_characters) . '[...]'; } else { echo ' ' . $query_base; } //Clean up the end of the PHP if (!empty($GLOBALS['show_as_php'])) { echo '\';'; } echo ' </div>'; echo '</fieldset>' . "\n"; if (!empty($edit_target)) { echo '<fieldset class="tblFooters">'; echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link; echo '</fieldset>'; } } echo '</div><br />' . "\n"; }
/** * returns as HTML table of the engine's server variables * * @return string The table that was generated based on the retrieved information */ function getHtmlVariables() { $odd_row = false; $ret = ''; foreach ($this->getVariablesStatus() as $details) { $ret .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n" . ' <td>' . "\n"; if (!empty($details['desc'])) { $ret .= ' ' . PMA_showHint($details['desc']) . "\n"; } $ret .= ' </td>' . "\n" . ' <th>' . htmlspecialchars($details['title']) . '</th>' . "\n" . ' <td class="value">'; switch ($details['type']) { case PMA_ENGINE_DETAILS_TYPE_SIZE: $parsed_size = $this->resolveTypeSize($details['value']); $ret .= $parsed_size[0] . ' ' . $parsed_size[1]; unset($parsed_size); break; case PMA_ENGINE_DETAILS_TYPE_NUMERIC: $ret .= PMA_formatNumber($details['value']) . ' '; break; default: $ret .= htmlspecialchars($details['value']) . ' '; } $ret .= '</td>' . "\n" . '</tr>' . "\n"; $odd_row = !$odd_row; } if (!$ret) { $ret = '<p>' . "\n" . ' ' . __('There is no detailed status information available for this storage engine.') . "\n" . '</p>' . "\n"; } else { $ret = '<table class="data">' . "\n" . $ret . '</table>' . "\n"; } return $ret; }
} ?> </td> </tr> <?php } ?> <tr> <th align="center"> <?php echo sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_formatNumber($num_tables, 0)); ?> </th> <th align="right" nowrap="nowrap"> <?php echo PMA_formatNumber($sum_entries, 0); ?> </th> <th align="center"> -- </th> <?php if ($cfg['ShowStats']) { list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1); ?> <th align="right" nowrap="nowrap"> <?php echo $sum_formated . ' ' . $unit; ?> </th> <?php
function formatVariable($name, $value) { global $VARIABLE_DOC_LINKS; if (is_numeric($value)) { if (isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte') { return '<abbr title="'.PMA_formatNumber($value, 0).'">'.implode(' ', PMA_formatByteDown($value, 3, 3)).'</abbr>'; } else { return PMA_formatNumber($value, 0); } } return htmlspecialchars($value); }
'; $(document).ready(makeProfilingChart); </script> <?php echo '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n"; echo '<div style="float: left;">'; echo '<table>' . "\n"; echo ' <tr>' . "\n"; echo ' <th>' . __('Status') . PMA_showMySQLDocu('general-thread-states', 'general-thread-states') . '</th>' . "\n"; echo ' <th>' . __('Time') . '</th>' . "\n"; echo ' </tr>' . "\n"; $chart_json = array(); foreach ($profiling_results as $one_result) { echo ' <tr>' . "\n"; echo '<td>' . ucwords($one_result['Status']) . '</td>' . "\n"; echo '<td align="right">' . PMA_formatNumber($one_result['Duration'], 3, 1) . 's</td>' . "\n"; if (isset($chart_json[ucwords($one_result['Status'])])) { $chart_json[ucwords($one_result['Status'])] += $one_result['Duration']; } else { $chart_json[ucwords($one_result['Status'])] = $one_result['Duration']; } } echo '</table>' . "\n"; echo '</div>'; //require_once './libraries/chart.lib.php'; echo '<div id="profilingchart" style="display:none;">'; //PMA_chart_profiling($profiling_results); echo json_encode($chart_json); echo '</div>'; echo '</fieldset>' . "\n"; }
?> </th> <td class="value"><?php if (isset($alerts[$name])) { if ($value > $alerts[$name]) { echo '<span class="attention">'; } else { echo '<span class="allfine">'; } } if ('%' === substr($name, -1, 1)) { echo PMA_formatNumber($value, 0, 2) . ' %'; } elseif (is_numeric($value) && $value == (int) $value) { echo PMA_formatNumber($value, 4, 0); } elseif (is_numeric($value)) { echo PMA_formatNumber($value, 4, 2); } else { echo htmlspecialchars($value); } if (isset($alerts[$name])) { echo '</span>'; } ?> </td> <td class="descr"> <?php if (isset($GLOBALS['strShowStatus' . $name . 'Descr'])) { echo $GLOBALS['strShowStatus' . $name . 'Descr']; } if (isset($links[$name])) { foreach ($links[$name] as $link_name => $link_url) {
/** * display unordered list of tables * calls itself recursively if table in given list * is a list itself * * @uses is_array() * @uses count() * @uses urlencode() * @uses strpos() * @uses printf() * @uses htmlspecialchars() * @uses strlen() * @uses is_array() * @uses PMA_displayTableList() * @uses $_REQUEST['tbl_group'] * @uses $GLOBALS['common_url_query'] * @uses $GLOBALS['table'] * @uses $GLOBALS['pmaThemeImage'] * @uses $GLOBALS['cfg']['LeftFrameTableSeparator'] * @uses $GLOBALS['cfg']['DefaultTabDatabase'] * @uses $GLOBALS['cfg']['DefaultTabTable'] * @uses $GLOBALS['strRows'] * @uses $GLOBALS['strBrowse'] * @global integer the element counter * @global string html code for '-' image * @global string html code for '+' image * @global string html code for self link * @param array $tables array of tables/tablegroups * @param boolean $visible wether the list is visible or not * @param string $tab_group_full full tab group name * @param string $table_db db of this table */ function PMA_displayTableList($tables, $visible = false, $tab_group_full = '', $table_db = '') { if (!is_array($tables) || count($tables) === 0) { return; } global $element_counter, $img_minus, $img_plus, $href_left; $sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; if ($visible) { echo '<ul id="subel' . $element_counter . '">'; } else { echo '<ul id="subel' . $element_counter . '" style="display: none">'; } foreach ($tables as $group => $table) { if (isset($table['is' . $sep . 'group'])) { $common_url_query = $GLOBALS['common_url_query'] . '&tbl_group=' . urlencode($tab_group_full . $group); $element_counter++; echo '<li>' . "\n"; if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || isset($GLOBALS['table']) && strpos($GLOBALS['table'], $group) === 0)) { printf($href_left, $element_counter, $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full); printf($img_minus, $element_counter); } else { printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } echo '</a>'; ?> <a href="index.php?<?php echo $common_url_query; ?> " target="_parent" onclick=" if (! toggle('<?php echo $element_counter; ?> ', true)) window.parent.goTo('./navigation.php?<?php echo $common_url_query; ?> '); window.parent.goTo('./<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?> ', 'main'); return false;"> <?php if ($GLOBALS['text_dir'] === 'rtl') { echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep))); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } ?> </a> <?php unset($table['is' . $sep . 'group']); unset($table['tab' . $sep . 'group']); unset($table['tab' . $sep . 'count']); if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || isset($GLOBALS['table']) && strpos($GLOBALS['table'], $group) === 0)) { PMA_displayTableList($table, true, $tab_group_full . $group, $table_db); } else { PMA_displayTableList($table, false, '', $table_db); } echo '</li>' . "\n"; } elseif (is_array($table)) { $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['common_url_query'] . '&table=' . urlencode($table['Name']); echo '<li>' . "\n"; echo '<a title="' . $GLOBALS['strBrowse'] . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"' . ' id="browse_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="sql.php?' . $GLOBALS['common_url_query'] . '&table=' . urlencode($table['Name']) . '&goto=' . $GLOBALS['cfg']['DefaultTabTable'] . '" >' . '<img class="icon"'; if ('VIEW' === strtoupper($table['Comment'])) { echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"'; } else { echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"'; } echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' width="10" height="10" alt="' . $GLOBALS['strBrowse'] . '" /></a>' . "\n" . '<a href="' . $href . '" title="' . htmlspecialchars($table['Comment'] . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"' . ' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . htmlspecialchars($table['disp_name']) . '</a>'; echo '</li>' . "\n"; } } echo '</ul>'; }
/** * Formats $value to byte view * * @param double $value the value to format * @param int $limes the sensitiveness * @param int $comma the number of decimals to retain * * @return array the formatted value and its unit * * @access public */ function PMA_formatByteDown($value, $limes = 6, $comma = 0) { if ($value === null) { return null; } $byteUnits = array(__('B'), __('KiB'), __('MiB'), __('GiB'), __('TiB'), __('PiB'), __('EiB')); $dh = PMA_pow(10, $comma); $li = PMA_pow(10, $limes); $unit = $byteUnits[0]; for ($d = 6, $ex = 15; $d >= 1; $d--, $ex -= 3) { if (isset($byteUnits[$d]) && $value >= $li * PMA_pow(10, $ex)) { // use 1024.0 to avoid integer overflow on 64-bit machines $value = round($value / (PMA_pow(1024, $d) / $dh)) / $dh; $unit = $byteUnits[$d]; break 1; } // end if } // end for if ($unit != $byteUnits[0]) { // if the unit is not bytes (as represented in current language) // reformat with max length of 5 // 4th parameter=true means do not reformat if value < 1 $return_value = PMA_formatNumber($value, 5, $comma, true); } else { // do not reformat, just handle the locale $return_value = PMA_formatNumber($value, 0); } return array(trim($return_value), $unit); }
} echo '</tr>' . "\n"; } // end foreach ( $databases as $key => $current ) unset($current, $odd_row); echo '<tr>' . "\n"; if ($is_superuser || $cfg['AllowUserDropDatabase']) { echo ' <th> </th>' . "\n"; } echo ' <th>' . $strTotalUC . ': ' . $databases_count . '</th>' . "\n"; foreach ($column_order as $stat_name => $stat) { if (array_key_exists($stat_name, $first_database)) { if ($stat['format'] === 'byte') { list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1); } elseif ($stat['format'] === 'number') { $value = PMA_formatNumber($stat['footer'], 0); } else { $value = htmlentities($stat['footer'], 0); } echo ' <th class="value">'; if (isset($stat['description_function'])) { echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">'; } echo $value; if (isset($stat['description_function'])) { echo '</dfn>'; } echo '</th>' . "\n"; if ($stat['format'] === 'byte') { echo ' <th class="unit">' . $unit . '</th>' . "\n"; }
/** * Counts and returns (or displays) the number of records in a table * * Revision 13 July 2001: Patch for limiting dump size from * vinay@sanisoft.com & girish@sanisoft.com * * @param string the current database name * @param string the current table name * @param boolean whether to retain or to displays the result * @param boolean whether to force an exact count * * @return mixed the number of records if retain is required, true else * * @access public */ function countRecords($db, $table, $ret = false, $force_exact = false) { $row_count = false; if (!$force_exact) { $row_count = PMA_DBI_fetch_value('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\';', 0, 'Rows'); } $tbl_is_view = PMA_Table::isView($db, $table); // for a VIEW, $row_count is always false at this point if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) { if (!$tbl_is_view) { $row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)); } else { // For complex views, even trying to get a partial record // count could bring down a server, so we offer an // alternative: setting MaxExactCountViews to 0 will bypass // completely the record counting for views if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) { $row_count = 0; } else { // Counting all rows of a VIEW could be too long, so use // a LIMIT clause. // Use try_query because it can fail (a VIEW is based on // a table that no longer exists) $result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, PMA_DBI_QUERY_STORE); if (!PMA_DBI_getError()) { $row_count = PMA_DBI_num_rows($result); PMA_DBI_free_result($result); } } } } if ($ret) { return $row_count; } /** * @deprecated at the moment nowhere is $return = false used */ // Note: as of PMA 2.8.0, we no longer seem to be using // PMA_Table::countRecords() in display mode. echo PMA_formatNumber($row_count, 0); if ($tbl_is_view) { echo ' ' . sprintf($GLOBALS['strViewMaxExactCount'], $GLOBALS['cfg']['MaxExactCount'], '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]'); } }
/** * Displays a table of results returned by a SQL query. * This function is called by the "sql.php" script. * * @param integer the link id associated to the query which results have * to be displayed * @param array the display mode * @param array the analyzed query * * @uses $_SESSION['tmp_user_values']['pos'] * @global string $db the database name * @global string $table the table name * @global string $goto the URL to go back in case of errors * @global string $sql_query the current SQL query * @global integer $num_rows the total number of rows returned by the * SQL query * @global integer $unlim_num_rows the total number of rows returned by the * SQL query without any programmatically * appended "LIMIT" clause * @global array $fields_meta the list of fields properties * @global integer $fields_cnt the total number of fields returned by * the SQL query * @global array $vertical_display informations used with vertical display * mode * @global array $highlight_columns column names to highlight * @global array $cfgRelation the relation settings * * @access private * * @see PMA_showMessage(), PMA_setDisplayMode(), * PMA_displayTableNavigation(), PMA_displayTableHeaders(), * PMA_displayTableBody(), PMA_displayResultsOperations() */ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) { global $db, $table, $goto; global $sql_query, $num_rows, $unlim_num_rows, $fields_meta, $fields_cnt; global $vertical_display, $highlight_columns; global $cfgRelation; global $showtable; // why was this called here? (already called from sql.php) //PMA_displayTable_checkConfigParams(); /** * @todo move this to a central place * @todo for other future table types */ $is_innodb = isset($showtable['Type']) && $showtable['Type'] == 'InnoDB'; if ($is_innodb && !isset($analyzed_sql[0]['queryflags']['union']) && !isset($analyzed_sql[0]['table_ref'][1]['table_name']) && (empty($analyzed_sql[0]['where_clause']) || $analyzed_sql[0]['where_clause'] == '1 ')) { // "j u s t b r o w s i n g" $pre_count = '~'; $after_count = PMA_showHint(PMA_sanitize($GLOBALS['strApproximateCount']), true); } else { $pre_count = ''; $after_count = ''; } // 1. ----- Prepares the work ----- // 1.1 Gets the informations about which functionalities should be // displayed $total = ''; $is_display = PMA_setDisplayMode($the_disp_mode, $total); // 1.2 Defines offsets for the next and previous pages if ($is_display['nav_bar'] == '1') { if ($_SESSION['tmp_user_values']['max_rows'] == 'all') { $pos_next = 0; $pos_prev = 0; } else { $pos_next = $_SESSION['tmp_user_values']['pos'] + $_SESSION['tmp_user_values']['max_rows']; $pos_prev = $_SESSION['tmp_user_values']['pos'] - $_SESSION['tmp_user_values']['max_rows']; if ($pos_prev < 0) { $pos_prev = 0; } } } // end if // 1.3 Find the sort expression // we need $sort_expression and $sort_expression_nodirection // even if there are many table references if (!empty($analyzed_sql[0]['order_by_clause'])) { $sort_expression = trim(str_replace(' ', ' ', $analyzed_sql[0]['order_by_clause'])); /** * Get rid of ASC|DESC */ preg_match('@(.*)([[:space:]]*(ASC|DESC))@si', $sort_expression, $matches); $sort_expression_nodirection = isset($matches[1]) ? trim($matches[1]) : $sort_expression; $sort_direction = isset($matches[2]) ? trim($matches[2]) : ''; unset($matches); } else { $sort_expression = $sort_expression_nodirection = $sort_direction = ''; } // 1.4 Prepares display of first and last value of the sorted column if (!empty($sort_expression_nodirection)) { list($sort_table, $sort_column) = explode('.', $sort_expression_nodirection); $sort_table = PMA_unQuote($sort_table); $sort_column = PMA_unQuote($sort_column); // find the sorted column index in row result // (this might be a multi-table query) $sorted_column_index = false; foreach ($fields_meta as $key => $meta) { if ($meta->table == $sort_table && $meta->name == $sort_column) { $sorted_column_index = $key; break; } } if ($sorted_column_index !== false) { // fetch first row of the result set $row = PMA_DBI_fetch_row($dt_result); $column_for_first_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']); // fetch last row of the result set PMA_DBI_data_seek($dt_result, $num_rows - 1); $row = PMA_DBI_fetch_row($dt_result); $column_for_last_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']); // reset to first row for the loop in PMA_displayTableBody() PMA_DBI_data_seek($dt_result, 0); // we could also use here $sort_expression_nodirection $sorted_column_message = ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]'; unset($row, $column_for_first_row, $column_for_last_row); } unset($sorted_column_index, $sort_table, $sort_column); } // 2. ----- Displays the top of the page ----- // 2.1 Displays a messages with position informations if ($is_display['nav_bar'] == '1' && isset($pos_next)) { if (isset($unlim_num_rows) && $unlim_num_rows != $total) { $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows']; } else { $selectstring = ''; } $last_shown_rec = $_SESSION['tmp_user_values']['max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1; if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCountViews']) { $message = PMA_Message::notice('strViewHasAtLeast'); $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]'); $message->addParam('[/a]'); $message_view_warning = PMA_showHint($message); } else { $message_view_warning = false; } $message = PMA_Message::success('strShowingRecords'); $message->addMessage($_SESSION['tmp_user_values']['pos']); if ($message_view_warning) { $message->addMessage('...', ' - '); $message->addMessage($message_view_warning); $message->addMessage('('); } else { $message->addMessage($last_shown_rec, ' - '); $message->addMessage($pre_count . PMA_formatNumber($total, 0) . $after_count, ' ('); $message->addString('strTotal'); $message->addMessage($selectstring, ''); $message->addMessage(', ', ''); } $messagge_qt = PMA_Message::notice('strQueryTime'); $messagge_qt->addParam($GLOBALS['querytime']); $message->addMessage($messagge_qt, ''); $message->addMessage(')', ''); $message->addMessage(isset($sorted_column_message) ? $sorted_column_message : '', ''); PMA_showMessage($message, $sql_query, 'success'); } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { PMA_showMessage($GLOBALS['strSuccess'], $sql_query, 'success'); } // 2.3 Displays the navigation bars if (!strlen($table)) { if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') { // table does not always contain a real table name, // for example in MySQL 5.0.x, the query SHOW STATUS // returns STATUS as a table name $table = $fields_meta[0]->table; } else { $table = ''; } } if ($is_display['nav_bar'] == '1') { PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'top_direction_dropdown'); echo "\n"; } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { echo "\n" . '<br /><br />' . "\n"; } // 2b ----- Get field references from Database ----- // (see the 'relation' configuration variable) // loic1, 2002-03-02: extended to php3 // initialize map $map = array(); // find tables $target = array(); if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) { foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) { $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name']; } } $tabs = '(\'' . join('\',\'', $target) . '\')'; if ($cfgRelation['displaywork']) { if (!strlen($table)) { $exist_rel = false; } else { $exist_rel = PMA_getForeigners($db, $table, '', 'both'); if ($exist_rel) { foreach ($exist_rel as $master_field => $rel) { $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']); $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']); } // end while } // end if } // end if } // end if // end 2b // 3. ----- Displays the results table ----- PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql, $sort_expression, $sort_expression_nodirection, $sort_direction); $url_query = ''; echo '<tbody>' . "\n"; $clause_is_unique = PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql); // vertical output case if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') { PMA_displayVerticalTable(); } // end if unset($vertical_display); echo '</tbody>' . "\n"; ?> </table> <?php // 4. ----- Displays the link for multi-fields edit and delete if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') { $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill']; $_url_params = array('db' => $db, 'table' => $table, 'sql_query' => $sql_query, 'goto' => $goto); $uncheckall_url = 'sql.php' . PMA_generate_common_url($_url_params); $_url_params['checkall'] = '1'; $checkall_url = 'sql.php' . PMA_generate_common_url($_url_params); if ($_SESSION['tmp_user_values']['disp_direction'] == 'vertical') { $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;'; $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;'; } else { $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;'; $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;'; } $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false); $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false); if ($_SESSION['tmp_user_values']['disp_direction'] != 'vertical') { echo '<img class="selectallarrow" width="38" height="22"' . ' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"' . ' alt="' . $GLOBALS['strWithChecked'] . '" />'; } echo $checkall_link . "\n" . ' / ' . "\n" . $uncheckall_link . "\n" . '<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n"; PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png'); PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png'); if ($analyzed_sql[0]['querytype'] == 'SELECT') { PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', $GLOBALS['strExport'], 'b_tblexport.png'); } echo "\n"; echo '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($sql_query) . '" />' . "\n"; echo '<input type="hidden" name="url_query"' . ' value="' . $GLOBALS['url_query'] . '" />' . "\n"; echo '<input type="hidden" name="clause_is_unique"' . ' value="' . $clause_is_unique . '" />' . "\n"; echo '</form>' . "\n"; } // 5. ----- Displays the navigation bar at the bottom if required ----- if ($is_display['nav_bar'] == '1') { echo '<br />' . "\n"; PMA_displayTableNavigation($pos_next, $pos_prev, $sql_query, 'bottom_direction_dropdown'); } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { echo "\n" . '<br /><br />' . "\n"; } // 6. ----- Displays "Query results operations" if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { PMA_displayResultsOperations($the_disp_mode, $analyzed_sql); } }
/** * returns as HTML table of the engine's server variables * * @uses PMA_ENGINE_DETAILS_TYPE_SIZE * @uses PMA_ENGINE_DETAILS_TYPE_NUMERIC * @uses PMA_StorageEngine::getVariablesStatus() * @uses $GLOBALS['strNoDetailsForEngine'] * @uses PMA_showHint() * @uses PMA_formatByteDown() * @uses PMA_formatNumber() * @uses htmlspecialchars() * @return string The table that was generated based on the retrieved information */ function getHtmlVariables() { $odd_row = false; $ret = ''; foreach ($this->getVariablesStatus() as $details) { $ret .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n" . ' <td>' . "\n"; if (!empty($details['desc'])) { $ret .= ' ' . PMA_showHint($details['desc']) . "\n"; } $ret .= ' </td>' . "\n" . ' <th>' . htmlspecialchars($details['title']) . '</th>' . "\n" . ' <td class="value">'; switch ($details['type']) { case PMA_ENGINE_DETAILS_TYPE_SIZE: $parsed_size = PMA_formatByteDown($details['value']); $ret .= $parsed_size[0] . ' ' . $parsed_size[1]; unset($parsed_size); break; case PMA_ENGINE_DETAILS_TYPE_NUMERIC: $ret .= PMA_formatNumber($details['value']) . ' '; break; default: $ret .= htmlspecialchars($details['value']) . ' '; } $ret .= '</td>' . "\n" . '</tr>' . "\n"; $odd_row = !$odd_row; } if (!$ret) { $ret = '<p>' . "\n" . ' ' . $GLOBALS['strNoDetailsForEngine'] . "\n" . '</p>' . "\n"; } else { $ret = '<table class="data">' . "\n" . $ret . '</table>' . "\n"; } return $ret; }
/** * Displays a table of results returned by a sql query. * This function is called by the "sql.php" script. * * @param integer the link id associated to the query which results have * to be displayed * @param array the display mode * @param array the analyzed query * * @global string $db the database name * @global string $table the table name * @global string $goto the url to go back in case of errors * @global boolean $dontlimitchars whether to limit the number of displayed * characters of text type fields or not * @global string $sql_query the current sql query * @global integer $num_rows the total number of rows returned by the * sql query * @global integer $unlim_num_rows the total number of rows returned by the * sql query without any programmatically * appended "LIMIT" clause * @global integer $pos the current postion of the first record * to be displayed * @global array $fields_meta the list of fields properties * @global integer $fields_cnt the total number of fields returned by * the sql query * @global array $vertical_display informations used with vertical display * mode * @global string $disp_direction the display mode * (horizontal/vertical/horizontalflipped) * @global integer $repeat_cells the number of row to display between two * table headers * @global array $highlight_columns collumn names to highlight * @global array $cfgRelation the relation settings * * @access private * * @see PMA_showMessage(), PMA_setDisplayMode(), * PMA_displayTableNavigation(), PMA_displayTableHeaders(), * PMA_displayTableBody(), PMA_displayResultsOperations() */ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) { global $db, $table, $goto, $dontlimitchars; global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt; global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns; global $cfgRelation; // 1. ----- Prepares the work ----- // 1.1 Gets the informations about which functionnalities should be // displayed $total = ''; $is_display = PMA_setDisplayMode($the_disp_mode, $total); if ($total == '') { unset($total); } // 1.2 Defines offsets for the next and previous pages if ($is_display['nav_bar'] == '1') { if (!isset($pos)) { $pos = 0; } if ($GLOBALS['session_max_rows'] == 'all') { $pos_next = 0; $pos_prev = 0; } else { $pos_next = $pos + $GLOBALS['cfg']['MaxRows']; $pos_prev = $pos - $GLOBALS['cfg']['MaxRows']; if ($pos_prev < 0) { $pos_prev = 0; } } } // end if // 1.3 Urlencodes the query to use in input form fields $encoded_sql_query = urlencode($sql_query); // 2. ----- Displays the top of the page ----- // 2.1 Displays a messages with position informations if ($is_display['nav_bar'] == '1' && isset($pos_next)) { if (isset($unlim_num_rows) && $unlim_num_rows != $total) { $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows']; } else { $selectstring = ''; } $last_shown_rec = $GLOBALS['session_max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1; PMA_showMessage($GLOBALS['strShowingRecords'] . " {$pos} - {$last_shown_rec} (" . PMA_formatNumber($total, 0) . ' ' . $GLOBALS['strTotal'] . $selectstring . ', ' . sprintf($GLOBALS['strQueryTime'], $GLOBALS['querytime']) . ')'); if (isset($table) && PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCount']) { echo '<div class="notice">' . "\n"; echo PMA_sanitize(sprintf($GLOBALS['strViewMaxExactCount'], PMA_formatNumber($GLOBALS['cfg']['MaxExactCount'], 0), '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]')) . "\n"; echo '</div>' . "\n"; } } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { PMA_showMessage($GLOBALS['strSQLQuery']); } // 2.3 Displays the navigation bars if (!isset($table) || strlen(trim($table)) == 0) { if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') { // table does not always contain a real table name, // for example in MySQL 5.0.x, the query SHOW STATUS // returns STATUS as a table name $table = $fields_meta[0]->table; } else { $table = ''; } } if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { PMA_displayResultsOperations($the_disp_mode, $analyzed_sql); } if ($is_display['nav_bar'] == '1') { PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query); echo "\n"; } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { echo "\n" . '<br /><br />' . "\n"; } // 2b ----- Get field references from Database ----- // (see the 'relation' config variable) // loic1, 2002-03-02: extended to php3 // init map $map = array(); // find tables $target = array(); if (isset($analyzed_sql[0]['table_ref']) && is_array($analyzed_sql[0]['table_ref'])) { foreach ($analyzed_sql[0]['table_ref'] as $table_ref_position => $table_ref) { $target[] = $analyzed_sql[0]['table_ref'][$table_ref_position]['table_true_name']; } } $tabs = '(\'' . join('\',\'', $target) . '\')'; if ($cfgRelation['displaywork']) { if (!isset($table) || !strlen($table)) { $exist_rel = false; } else { $exist_rel = PMA_getForeigners($db, $table, '', 'both'); if ($exist_rel) { foreach ($exist_rel as $master_field => $rel) { $display_field = PMA_getDisplayField($rel['foreign_db'], $rel['foreign_table']); $map[$master_field] = array($rel['foreign_table'], $rel['foreign_field'], $display_field, $rel['foreign_db']); } // end while } // end if } // end if } // end if // end 2b // 3. ----- Displays the results table ----- PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt, $analyzed_sql); $url_query = ''; echo '<tbody>' . "\n"; PMA_displayTableBody($dt_result, $is_display, $map, $analyzed_sql); echo '</tbody>' . "\n"; // vertical output case if ($disp_direction == 'vertical') { PMA_displayVerticalTable(); } // end if unset($vertical_display); ?> </table> <?php // 4. ----- Displays the link for multi-fields delete if ($is_display['del_lnk'] == 'dr' && $is_display['del_lnk'] != 'kp') { $delete_text = $is_display['del_lnk'] == 'dr' ? $GLOBALS['strDelete'] : $GLOBALS['strKill']; $uncheckall_url = 'sql.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($sql_query) . '&pos=' . $pos . '&session_max_rows=' . $GLOBALS['session_max_rows'] . '&pos=' . $pos . '&disp_direction=' . $disp_direction . '&repeat_cells=' . $repeat_cells . '&goto=' . $goto . '&dontlimitchars=' . $dontlimitchars; $checkall_url = $uncheckall_url . '&checkall=1'; if ($disp_direction == 'vertical') { $checkall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', true)) return false;'; $uncheckall_params['onclick'] = 'if (setCheckboxes(\'rowsDeleteForm\', false)) return false;'; } else { $checkall_params['onclick'] = 'if (markAllRows(\'rowsDeleteForm\')) return false;'; $uncheckall_params['onclick'] = 'if (unMarkAllRows(\'rowsDeleteForm\')) return false;'; } $checkall_link = PMA_linkOrButton($checkall_url, $GLOBALS['strCheckAll'], $checkall_params, false); $uncheckall_link = PMA_linkOrButton($uncheckall_url, $GLOBALS['strUncheckAll'], $uncheckall_params, false); if ($disp_direction != 'vertical') { echo '<img class="selectallarrow" width="38" height="22"' . ' src="' . $GLOBALS['pmaThemeImage'] . 'arrow_' . $GLOBALS['text_dir'] . '.png' . '"' . ' alt="' . $GLOBALS['strWithChecked'] . '" />'; } echo $checkall_link . "\n" . ' / ' . "\n" . $uncheckall_link . "\n" . '<i>' . $GLOBALS['strWithChecked'] . '</i>' . "\n"; if ($GLOBALS['cfg']['PropertiesIconic']) { PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $GLOBALS['strChange'], 'b_edit.png'); PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete', $delete_text, 'b_drop.png'); if ($analyzed_sql[0]['querytype'] == 'SELECT') { PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', $GLOBALS['strExport'], 'b_tblexport.png'); } echo "\n"; } else { echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($GLOBALS['strEdit']) . '"' . ' title="' . $GLOBALS['strEdit'] . '" />' . "\n"; echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($delete_text) . '"' . ' title="' . $delete_text . '" />' . "\n"; if ($analyzed_sql[0]['querytype'] == 'SELECT') { echo ' <input type="submit" name="submit_mult"' . ' value="' . htmlspecialchars($GLOBALS['strExport']) . '"' . ' title="' . $GLOBALS['strExport'] . '" />' . "\n"; } } echo '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($sql_query) . '" />' . "\n"; echo '<input type="hidden" name="pos" value="' . $pos . '" />' . "\n"; echo '<input type="hidden" name="url_query"' . ' value="' . $GLOBALS['url_query'] . '" />' . "\n"; echo '</form>' . "\n"; } // 5. ----- Displays the navigation bar at the bottom if required ----- if ($is_display['nav_bar'] == '1') { echo '<br />' . "\n"; PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query); } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { echo "\n" . '<br /><br />' . "\n"; } }
</tr> <?php } if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> <th class="name"><?php echo $strRowSize; ?> ø</th> <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td> </tr> <?php } if (isset($showtable['Auto_increment'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> <th class="name"><?php echo $strNext; ?> Autoindex</th> <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td> </tr> <?php } if (isset($showtable['Create_time'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> <th class="name"><?php echo $strStatCreateTime; ?></th> <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td> </tr> <?php } if (isset($showtable['Update_time'])) { ?> <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>"> <th class="name"><?php echo $strStatUpdateTime; ?></th>
} else { echo htmlspecialchars($value); $is_numeric = false; } ?></td> <?php if ($serverVarsGlobal[$name] !== $value) { ?> </tr> <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?> marked"> <td>(<?php echo $strGlobalValue; ?>)</td> <td class="value"><?php if ($is_numeric) { echo PMA_formatNumber($serverVarsGlobal[$name], 0); } else { echo htmlspecialchars($serverVarsGlobal[$name]); } ?></td> <?php } ?> </tr> <?php $odd_row = !$odd_row; } ?> </tbody> </table> <?php
/** * DB search optimisation * * @package PhpMyAdmin */ require_once 'libraries/common.inc.php'; require_once 'libraries/common.lib.php'; $db = $_GET['db']; $table_term = $_GET['table']; $common_url_query = PMA_generate_common_url($GLOBALS['db']); $tables_full = PMA_getTableList($db); $tables_response = array(); foreach ($tables_full as $key => $table) { if (strpos($key, $table_term) !== false) { $link = '<li class="ajax_table"><a class="tableicon" title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"' . ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table['Name']) . '&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >'; $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name'])); if (PMA_Table::isView($table_db, $table['Name'])) { $link .= PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr); } else { $link .= PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr); } $link .= '</a>'; // link for the table name itself $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table['Name']) . '&pos=0'; $link .= '<a href="' . $href . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')') . '" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>'; $link .= '</li>' . "\n"; $table['line'] = $link; $tables_response[] = $table; } } PMA_ajaxResponse('', true, array('tables' => $tables_response));