function PMA_generateEngineDetails($variables, $like = NULL, $indent = 0) { global $cfg; $spaces = ''; for ($i = 0; $i < $indent; $i++) { $spaces .= ' '; } /** * 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 $spaces . '<p>' . "\n" . $spaces . ' ' . $GLOBALS['strNoDetailsForEngine'] . "\n" . $spaces . '</p>' . "\n"; } $dt_table = $spaces . '<table>' . "\n"; $useBgcolorOne = TRUE; $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; $bgcolor = $useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']; $dt_table .= $spaces . ' <tr>' . "\n" . $spaces . ' <td bgcolor="' . $bgcolor . '">' . "\n"; if (!empty($variables[$var]['desc'])) { $dt_table .= $spaces . ' ' . PMA_showHint($details['desc']) . "\n"; } $dt_table .= $spaces . ' </td>' . "\n" . $spaces . ' <td bgcolor="' . $bgcolor . '">' . "\n" . $spaces . ' ' . $details['title'] . ' ' . "\n" . $spaces . ' </td>' . "\n" . $spaces . ' <td bgcolor="' . $bgcolor . '"' . ($is_num ? ' align="right"' : '') . '>' . "\n" . $spaces . ' '; 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; default: $dt_table .= htmlspecialchars($mysql_vars[$var]); } $dt_table .= ' ' . "\n" . $spaces . ' </td>' . "\n" . $spaces . ' </tr>' . "\n"; $useBgcolorOne = !$useBgcolorOne; $has_content = TRUE; } if (!$has_content) { return ''; } return $dt_table; }
function getPage($id) { global $cfg; switch ($id) { case 'bufferpool': 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. :-) $res = PMA_DBI_query('SHOW STATUS WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\' OR Variable_name = \'Innodb_page_size\';'); $status = array(); while ($row = PMA_DBI_fetch_row($res)) { $status[$row[0]] = $row[1]; } PMA_DBI_free_result($res); unset($res, $row); $output = '<table>' . "\n" . ' <thead>' . "\n" . ' <tr>' . "\n" . ' <th colspan="4">' . "\n" . ' ' . $GLOBALS['strBufferPoolUsage'] . "\n" . ' </th>' . "\n" . ' </tr>' . "\n" . ' </thead>' . "\n" . ' <tfoot>' . "\n" . ' <tr>' . "\n" . ' <th>' . "\n" . ' ' . $GLOBALS['strTotalUC'] . "\n" . ' </th>' . "\n" . ' <th colspan="3">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_total']) . ' ' . $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>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . $GLOBALS['strFreePages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_free']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strDirtyPages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_dirty']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strDataPages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_data']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strPagesToBeFlushed'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_flushed']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . $GLOBALS['strBusyPages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_misc']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strLatchedPages'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_pages_latched']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' </tbody>' . "\n" . '</table>' . "\n\n" . '<br />' . "\n\n" . '<table>' . "\n" . ' <thead>' . "\n" . ' <tr>' . "\n" . ' <th colspan="4">' . "\n" . ' ' . $GLOBALS['strBufferPoolActivity'] . "\n" . ' </th>' . "\n" . ' </tr>' . "\n" . ' </thead>' . "\n" . ' <tbody>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strReadRequests'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_read_requests']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strWriteRequests'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_write_requests']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . $GLOBALS['strBufferReadMisses'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_reads']) . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . $GLOBALS['strBufferWriteWaits'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . htmlspecialchars($status['Innodb_buffer_pool_wait_free']) . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strBufferReadMissesInPercent'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . ($status['Innodb_buffer_pool_read_requests'] == 0 ? '---' : htmlspecialchars(number_format($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 2, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator'])) . ' %') . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . $cfg['BgcolorOne'] . '">' . "\n" . ' ' . $GLOBALS['strBufferWriteWaitsInPercent'] . ' ' . "\n" . ' </td>' . "\n" . ' <td align="right" bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n" . ' ' . ($status['Innodb_buffer_pool_write_requests'] == 0 ? '---' : htmlspecialchars(number_format($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 2, $GLOBALS['number_decimal_separator'], $GLOBALS['number_thousands_separator'])) . ' %') . "\n" . ' </td>' . "\n" . ' </tr>' . "\n" . ' </tbody>' . "\n" . '</table>' . "\n"; return $output; case 'status': $res = PMA_DBI_query('SHOW INNODB STATUS;'); $row = PMA_DBI_fetch_row($res); PMA_DBI_free_result($res); return '<pre>' . "\n" . htmlspecialchars($row[0]) . "\n" . '</pre>' . "\n"; default: return FALSE; } }
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 the pbxt engine specific handling for * PMA_ENGINE_DETAILS_TYPE_SIZE variables. * * @param string $formatted_size the size expression (for example 8MB) * * @return string the formatted value and its unit */ function resolveTypeSize($formatted_size) { if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)) { $value = PMA_extractValueFromFormattedSize($formatted_size); } else { $value = $formatted_size; } return PMA_formatByteDown($value); }
/** * 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; }
foreach ($binary_logs as $each_log) { echo '<option value="' . $each_log['Log_name'] . '"'; if ($each_log['Log_name'] == $_REQUEST['log']) { echo ' selected="selected"'; } echo '>' . $each_log['Log_name']; if (isset($each_log['File_size'])) { $full_size += $each_log['File_size']; echo ' (' . implode(' ', PMA_formatByteDown($each_log['File_size'], 3, 2)) . ')'; } echo '</option>'; } echo '</select> '; echo count($binary_logs) . ' ' . __('Files') . ', '; if ($full_size > 0) { echo implode(' ', PMA_formatByteDown($full_size)); } echo '</fieldset>'; echo '<fieldset class="tblFooters">'; echo '<input type="submit" value="' . __('Go') . '" />'; echo '</fieldset>'; echo '</form>'; } PMA_showMessage(PMA_Message::success()); /** * Displays the page */ ?> <table border="0" cellpadding="2" cellspacing="1"> <thead> <tr>
/** * Verifies what to do with non-printable contents (binary or BLOB) * in Browse mode. * * @uses is_null() * @uses isset() * @uses strlen() * @uses PMA_formatByteDown() * @uses strpos() * @uses str_replace() * @param string $category BLOB|BINARY|GEOMETRY * @param string $content the binary content * @param string $transform_function * @param string $transform_options * @param string $default_function * @param object $meta the meta-information about this field * @return mixed string or float */ function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta, $url_params = array()) { $result = '[' . $category; if (is_null($content)) { $result .= ' - NULL'; $size = 0; } elseif (isset($content)) { $size = strlen($content); $display_size = PMA_formatByteDown($size, 3, 1); $result .= ' - ' . $display_size[0] . $display_size[1]; } $result .= ']'; if (strpos($transform_function, 'octetstream')) { $result = $content; } if ($size > 0) { if ($default_function != $transform_function) { $result = $transform_function($result, $transform_options, $meta); } else { $result = $default_function($result, array(), $meta); if (stristr($meta->type, 'BLOB') && $_SESSION['tmp_user_values']['display_blob']) { // in this case, restart from the original $content $result = htmlspecialchars(PMA_replace_binary_contents($content)); } /* Create link to download */ if (count($url_params) > 0) { $result = '<a href="tbl_get_field.php' . PMA_generate_common_url($url_params) . '">' . $result . '</a>'; } } } return $result; }
$max_digits = 5; $decimals = 1; list($data_size, $data_unit) = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals); if ($mergetable == false) { list($index_size, $index_unit) = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals); } // InnoDB returns a huge value in Data_free, do not use it if (!$is_innodb && isset($showtable['Data_free']) && $showtable['Data_free'] > 0) { list($free_size, $free_unit) = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals); list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals); } else { list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals); } list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals); if ($table_info_num_rows > 0) { list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1); } // Displays them $odd_row = false; ?> <a name="showusage"></a> <?php if (!$tbl_is_view && !$db_is_information_schema) { ?> <table id="tablespaceusage" class="data"> <caption class="tblHeaders"><?php echo $strSpaceUsage; ?> </caption> <thead>
/** * 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; }
/** * format byte test, globals are defined * @dataProvider formatByteDownDataProvider */ public function testFormatByteDown($a, $b, $c, $e) { $result = PMA_formatByteDown($a, $b, $c); $result[0] = trim($result[0]); $this->assertEquals($e, $result); }
<?php echo __('in use'); ?> </td> <?php } // end if (isset($each_table['TABLE_ROWS'])) else ?> </tr> <?php } // end foreach // Show Summary if ($is_show_stats) { list($sum_formatted, $unit) = PMA_formatByteDown($sum_size, 3, 1); list($overhead_formatted, $overhead_unit) = PMA_formatByteDown($overhead_size, 3, 1); } ?> </tbody> <tbody id="tbl_summary_row"> <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) if ($num_tables == 0) { $tableReductionCount = 0; } echo sprintf(_ngettext('%s table', '%s tables', $num_tables - $tableReductionCount), PMA_formatNumber($num_tables - $tableReductionCount, 0)); ?> </th>
/** * Displays the maximum size for an upload * * @param integer $max_upload_size the size * * @return string the message * * @access public */ function PMA_displayMaximumUploadSize($max_upload_size) { // I have to reduce the second parameter (sensitiveness) from 6 to 4 // to avoid weird results like 512 kKib list($max_size, $max_unit) = PMA_formatByteDown($max_upload_size, 4); return '(' . sprintf(__('Max: %s%s'), $max_size, $max_unit) . ')'; }
<td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_sent'] * $hour_factor, 4)); ?> </td> </tr> <tr class="odd"> <th class="name"><?php echo $strTotalUC; ?> </th> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 4)); ?> </td> <td class="value"><?php echo implode(' ', PMA_formatByteDown(($server_status['Bytes_received'] + $server_status['Bytes_sent']) * $hour_factor, 4)); ?> </td> </tr> </tbody> </table> <table id="serverstatusconnections" class="data"> <thead> <tr> <th colspan="2"><?php echo $strConnections; ?> </th> <th>ø <?php echo $strPerHour;
/** * Displays the maximum size for an upload * * @param integer the size * * @return string the message * * @access public */ function PMA_displayMaximumUploadSize($max_upload_size) { list($max_size, $max_unit) = PMA_formatByteDown($max_upload_size); return '(' . sprintf($GLOBALS['strMaximumSize'], $max_size, $max_unit) . ')'; }
function printServerTraffic() { global $server_status, $PMA_PHP_SELF; global $server_master_status, $server_slave_status, $replication_types; $hour_factor = 3600 / $server_status['Uptime']; /** * starttime calculation */ $start_time = PMA_DBI_fetch_value('SELECT UNIX_TIMESTAMP() - ' . $server_status['Uptime']); ?> <h3><?php echo sprintf(__('Network traffic since startup: %s'), implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))); ?> </h3> <p> <?php echo sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'), PMA_timespanFormat($server_status['Uptime']), PMA_localisedDate($start_time)) . "\n"; ?> </p> <?php if ($server_master_status || $server_slave_status) { echo '<p class="notice">'; if ($server_master_status && $server_slave_status) { echo __('This MySQL server works as <b>master</b> and <b>slave</b> in <b>replication</b> process.'); } elseif ($server_master_status) { echo __('This MySQL server works as <b>master</b> in <b>replication</b> process.'); } elseif ($server_slave_status) { echo __('This MySQL server works as <b>slave</b> in <b>replication</b> process.'); } echo ' '; echo __('For further information about replication status on the server, please visit the <a href="#replication">replication section</a>.'); echo '</p>'; } /* if the server works as master or slave in replication process, display useful information */ if ($server_master_status || $server_slave_status) { ?> <hr class="clearfloat" /> <h3><a name="replication"></a><?php echo __('Replication status'); ?> </h3> <?php foreach ($replication_types as $type) { if (${"server_{$type}_status"}) { PMA_replication_print_status_table($type); } } unset($types); } ?> <table id="serverstatustraffic" class="data noclick"> <thead> <tr> <th colspan="2"><?php echo __('Traffic') . ' ' . PMA_showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?> </th> <th>ø <?php echo __('per hour'); ?> </th> </tr> </thead> <tbody> <tr class="odd"> <th class="name"><?php echo __('Received'); ?> </th> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_received'], 3, 1)); ?> </td> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_received'] * $hour_factor, 3, 1)); ?> </td> </tr> <tr class="even"> <th class="name"><?php echo __('Sent'); ?> </th> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)); ?> </td> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_sent'] * $hour_factor, 3, 1)); ?> </td> </tr> <tr class="odd"> <th class="name"><?php echo __('Total'); ?> </th> <td class="value"><?php echo implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1)); ?> </td> <td class="value"><?php echo implode(' ', PMA_formatByteDown(($server_status['Bytes_received'] + $server_status['Bytes_sent']) * $hour_factor, 3, 1)); ?> </td> </tr> </tbody> </table> <table id="serverstatusconnections" class="data noclick"> <thead> <tr> <th colspan="2"><?php echo __('Connections'); ?> </th> <th>ø <?php echo __('per hour'); ?> </th> <th>%</th> </tr> </thead> <tbody> <tr class="odd"> <th class="name"><?php echo __('max. concurrent connections'); ?> </th> <td class="value"><?php echo PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td> <td class="value">--- </td> <td class="value">--- </td> </tr> <tr class="even"> <th class="name"><?php echo __('Failed attempts'); ?> </th> <td class="value"><?php echo PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?> </td> <td class="value"><?php echo PMA_formatNumber($server_status['Aborted_connects'] * $hour_factor, 4, 2, true); ?> </td> <td class="value"><?php echo $server_status['Connections'] > 0 ? PMA_formatNumber($server_status['Aborted_connects'] * 100 / $server_status['Connections'], 0, 2, true) . '%' : '--- '; ?> </td> </tr> <tr class="odd"> <th class="name"><?php echo __('Aborted'); ?> </th> <td class="value"><?php echo PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?> </td> <td class="value"><?php echo PMA_formatNumber($server_status['Aborted_clients'] * $hour_factor, 4, 2, true); ?> </td> <td class="value"><?php echo $server_status['Connections'] > 0 ? PMA_formatNumber($server_status['Aborted_clients'] * 100 / $server_status['Connections'], 0, 2, true) . '%' : '--- '; ?> </td> </tr> <tr class="even"> <th class="name"><?php echo __('Total'); ?> </th> <td class="value"><?php echo PMA_formatNumber($server_status['Connections'], 4, 0); ?> </td> <td class="value"><?php echo PMA_formatNumber($server_status['Connections'] * $hour_factor, 4, 2); ?> </td> <td class="value"><?php echo PMA_formatNumber(100, 0, 2); ?> %</td> </tr> </tbody> </table> <?php $url_params = array(); $show_full_sql = !empty($_REQUEST['full']); if ($show_full_sql) { $url_params['full'] = 1; $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?'); } else { $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1)); } if (PMA_DRIZZLE) { $sql_query = "SELECT\n p.id AS Id,\n p.username AS User,\n p.host AS Host,\n p.db AS db,\n p.command AS Command,\n p.time AS Time,\n p.state AS State,\n " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int) $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info\n FROM data_dictionary.PROCESSLIST p\n " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : ''); } else { $sql_query = $show_full_sql ? 'SHOW FULL PROCESSLIST' : 'SHOW PROCESSLIST'; } $result = PMA_DBI_query($sql_query); /** * Displays the page */ ?> <table id="tableprocesslist" class="data clearfloat noclick"> <thead> <tr> <th><?php echo __('Processes'); ?> </th> <th><?php echo __('ID'); ?> </th> <th><?php echo __('User'); ?> </th> <th><?php echo __('Host'); ?> </th> <th><?php echo __('Database'); ?> </th> <th><?php echo __('Command'); ?> </th> <th><?php echo __('Time'); ?> </th> <th><?php echo __('Status'); ?> </th> <th><?php echo __('SQL query'); if (!PMA_DRIZZLE) { ?> <a href="<?php echo $full_text_link; ?> " title="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?> "> <img src="<?php echo $GLOBALS['pmaThemeImage'] . 's_' . ($show_full_sql ? 'partial' : 'full'); ?> text.png" alt="<?php echo $show_full_sql ? __('Truncate Shown Queries') : __('Show Full Queries'); ?> " /> </a> <?php } ?> </th> </tr> </thead> <tbody> <?php $odd_row = true; while ($process = PMA_DBI_fetch_assoc($result)) { $url_params['kill'] = $process['Id']; $kill_process = 'server_status.php' . PMA_generate_common_url($url_params); ?> <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?> "> <td><a href="<?php echo $kill_process; ?> "><?php echo __('Kill'); ?> </a></td> <td class="value"><?php echo $process['Id']; ?> </td> <td><?php echo $process['User']; ?> </td> <td><?php echo $process['Host']; ?> </td> <td><?php echo !isset($process['db']) || !strlen($process['db']) ? '<i>' . __('None') . '</i>' : $process['db']; ?> </td> <td><?php echo $process['Command']; ?> </td> <td class="value"><?php echo $process['Time']; ?> </td> <td><?php echo empty($process['State']) ? '---' : $process['State']; ?> </td> <td> <?php if (empty($process['Info'])) { echo '---'; } else { if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { echo htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]'; } else { echo PMA_SQP_formatHtml(PMA_SQP_parse($process['Info'])); } } ?> </td> </tr> <?php $odd_row = !$odd_row; } ?> </tbody> </table> <?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); }
$current_collation = PMA_getDbCollation($current['db_name']); echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' <dfn title="' . htmlspecialchars(PMA_getCollationDescr($current_collation)) . '">' . "\n" . ' ' . htmlspecialchars($current_collation) . "\n" . ' </dfn>' . "\n" . ' </td>' . "\n"; } echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n" . ' ' . $current['tbl_cnt'] . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n" . ' ' . $data_size . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' ' . $data_unit . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n" . ' ' . $idx_size . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' ' . $idx_unit . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="right">' . "\n" . ' <b>' . "\n" . ' ' . $tot_size . "\n" . ' </b>' . "\n" . ' </td>' . "\n" . ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '">' . "\n" . ' <b>' . "\n" . ' ' . $tot_unit . "\n" . ' </b>' . "\n" . ' </td>' . "\n"; } if ($is_superuser) { echo ' <td bgcolor="' . ($useBgcolorOne ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo']) . '" align="center">' . "\n" . ' <a onclick="reload_window(\'' . urlencode($current['db_name']) . '\'); return true;" href="./server_privileges.php?' . $url_query . '&checkprivs=' . urlencode($current['db_name']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['db_name'])) . '">' . "\n" . ' ' . ($cfg['PropertiesIconic'] ? '<img src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" hspace="2" border="0" alt=" ' . $strCheckPrivs . '" /> ' : $strCheckPrivs) . "\n" . ' </a>' . "\n" . ' </td>' . "\n"; } echo ' </tr>' . "\n"; $useBgcolorOne = !$useBgcolorOne; } // end while if (!empty($dbstats)) { list($data_size, $data_unit) = PMA_formatByteDown($total_calc['data_sz'], 3, 1); list($idx_size, $idx_unit) = PMA_formatByteDown($total_calc['idx_sz'], 3, 1); list($tot_size, $tot_unit) = PMA_formatByteDown($total_calc['tot_sz'], 3, 1); echo ' <tr>' . "\n" . ' <th> </th>' . "\n" . ' <th>' . "\n" . ' ' . $strTotalUC . ': ' . $total_calc['db_cnt'] . ' ' . "\n" . ' </th>' . "\n"; if (PMA_MYSQL_INT_VERSION >= 40101) { echo ' <th> </th>' . "\n"; } echo ' <th align="right">' . "\n" . ' ' . $total_calc['tbl_cnt'] . ' ' . "\n" . ' </th>' . "\n" . ' <th align="right">' . "\n" . ' ' . $data_size . "\n" . ' </th>' . "\n" . ' <th align="left">' . "\n" . ' ' . $data_unit . ' ' . "\n" . ' </th>' . "\n" . ' <th align="right">' . "\n" . ' ' . $idx_size . "\n" . ' </th>' . "\n" . ' <th align="left">' . "\n" . ' ' . $idx_unit . ' ' . "\n" . ' </th>' . "\n" . ' <th align="right">' . "\n" . ' ' . $tot_size . "\n" . ' </th>' . "\n" . ' <th align="left">' . "\n" . ' ' . $tot_unit . ' ' . "\n" . ' </th>' . "\n" . ' <th> </th>' . "\n" . ' </tr>' . "\n"; } if ($is_superuser || $cfg['AllowUserDropDatabase']) { $common_url_query = PMA_generate_common_url() . '&sort_by=' . $sort_by . '&sort_order=' . $sort_order . '&dbstats=' . (empty($dbstats) ? '10' : '3'); echo ' <tr>' . "\n" . ' <td colspan="' . (empty($dbstats) ? '10' : '3') . '">' . "\n" . ' <img src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" border="0" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n" . ' <a href="./server_databases.php?' . $common_url_query . '&checkall=1" onclick="setCheckboxes(\'dbStatsForm\', true); return false;">' . "\n" . ' ' . $strCheckAll . ' </a>' . "\n" . ' / ' . "\n" . ' <a href="./server_databases.php?' . $common_url_query . '" onclick="setCheckboxes(\'dbStatsForm\', false); return false;">' . "\n" . ' ' . $strUncheckAll . ' </a>' . "\n" . ' </td>' . "\n" . ' </tr>' . "\n"; } echo ' </table>' . "\n"; unset($data_size); unset($data_unit); unset($idx_size); unset($idx_unit);
"> <?php echo $strTotalUC; ?> </td> <td bgcolor="<?php echo $cfg['BgcolorOne']; ?> " align="right"> <?php echo join(' ', PMA_formatByteDown($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent'])); ?> </td> <td bgcolor="<?php echo $cfg['BgcolorOne']; ?> " align="right"> <?php echo join(' ', PMA_formatByteDown(($serverStatus['Bytes_received'] + $serverStatus['Bytes_sent']) * 3600 / $serverStatus['Uptime'])); ?> </td> </tr> </table> </td> <td valign="top"> <table border="0"> <tr> <th colspan="2"> <?php echo $strConnections; ?> </th> <th> ø <?php echo $strPerHour; ?>
/** * Displays the body of the results table * * @param integer the link id associated to the query which results have * to be displayed * @param array which elements to display * @param array the list of relations * @param array the analyzed query * * @return boolean always true * * @global string the current language * @global string the current charset for MySQL * @global integer the server to use (refers to the number in the * configuration file) * @global string the database name * @global string the table name * @global string the sql query * @global string the url to go back in case of errors * @global integer the current position in results * @global integer the maximum number of rows per page * @global array the list of fields properties * @global integer the total number of fields returned by the sql query * @global array informations used with vertical display mode * @global string the display mode (horizontal/vertical/horizontalflipped) * @global integer the number of row to display between two table headers * @global boolean whether to limit the number of displayed characters of * text type fields or not * * @access private * * @see PMA_displayTable() */ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { global $lang, $convcharset, $server, $db, $table; global $goto; global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt; global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns; global $dontlimitchars; global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin if (!is_array($map)) { $map = array(); } ?> <!-- Results table body --> <?php echo "\n"; $row_no = 0; $vertical_display['edit'] = array(); $vertical_display['delete'] = array(); $vertical_display['data'] = array(); $vertical_display['row_delete'] = array(); // Correction uva 19991216 in the while below // Previous code assumed that all tables have keys, specifically that // the phpMyAdmin GUI should support row delete/edit only for such // tables. // Although always using keys is arguably the prescribed way of // defining a relational table, it is not required. This will in // particular be violated by the novice. // We want to encourage phpMyAdmin usage by such novices. So the code // below has been changed to conditionally work as before when the // table being displayed has one or more keys; but to display // delete/edit options correctly for tables without keys. // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row' // to get the NULL values while ($row = PMA_mysql_fetch_array($dt_result)) { // lem9: "vertical display" mode stuff if ($row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { echo '<tr>' . "\n"; for ($foo_i = 0; $foo_i < $vertical_display['emptypre']; $foo_i++) { echo ' <td> </td>' . "\n"; } foreach ($vertical_display['desc'] as $key => $val) { echo $val; } for ($foo_i = 0; $foo_i < $vertical_display['emptyafter']; $foo_i++) { echo ' <td> </td>' . "\n"; } echo '</tr>' . "\n"; } // end if if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { $bgcolor = '#ffffff'; } else { $bgcolor = $row_no % 2 ? $GLOBALS['cfg']['BgcolorOne'] : $GLOBALS['cfg']['BgcolorTwo']; } if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { // loic1: pointer code part $on_mouse = ''; if (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') { if ($GLOBALS['cfg']['BrowsePointerColor'] != '') { $on_mouse = ' onmouseover="setPointer(this, ' . $row_no . ', \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"' . ' onmouseout="setPointer(this, ' . $row_no . ', \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'; } if ($GLOBALS['cfg']['BrowseMarkerColor'] != '') { $on_mouse .= ' onmousedown="setPointer(this, ' . $row_no . ', \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'; } } // end if ?> <tr<?php echo $on_mouse; ?> > <?php echo "\n"; } // 1. Prepares the row (gets primary keys to use) if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') { $primary_key = ''; $unique_key = ''; $uva_nonprimary_condition = ''; // 1.1 Results from a "SELECT" statement -> builds the // "primary" key to use in links if ($is_display['edit_lnk'] == 'ur') { for ($i = 0; $i < $fields_cnt; ++$i) { $field_flags = PMA_mysql_field_flags($dt_result, $i); $meta = $fields_meta[$i]; // do not use an alias in a condition $column_for_condition = $meta->name; if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; if (!empty($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $column_for_condition = $true_column; } // end if } // end if } // end while } // to fix the bug where float fields (primary or not) // can't be matched because of the imprecision of // floating comparison, use CONCAT // (also, the syntax "CONCAT(field) IS NULL" // that we need on the next "if" will work) if ($meta->type == 'real') { $condition = ' CONCAT(' . PMA_backquote($column_for_condition) . ') '; } else { $condition = ' ' . PMA_backquote($column_for_condition) . ' '; } // end if... else... // loic1: To fix bug #474943 under php4, the row // pointer will depend on whether the "is_null" // php4 function is available or not $pointer = function_exists('is_null') ? $i : $meta->name; if (!isset($row[$meta->name]) || function_exists('is_null') && is_null($row[$pointer])) { $condition .= 'IS NULL AND'; } else { if ($meta->type == 'blob' && stristr($field_flags, 'BINARY') && !empty($row[$pointer])) { $condition .= 'LIKE 0x' . bin2hex($row[$pointer]) . ' AND'; } else { $condition .= '= \'' . PMA_sqlAddslashes($row[$pointer], FALSE, TRUE) . '\' AND'; } } if ($meta->primary_key > 0) { $primary_key .= $condition; } else { if ($meta->unique_key > 0) { $unique_key .= $condition; } } $uva_nonprimary_condition .= $condition; } // end for // Correction uva 19991216: prefer primary or unique keys // for condition, but use conjunction of all values if no // primary key if ($primary_key) { $uva_condition = $primary_key; } else { if ($unique_key) { $uva_condition = $unique_key; } else { $uva_condition = $uva_nonprimary_condition; } } $uva_condition = urlencode(preg_replace('|\\s?AND$|', '', $uva_condition)); } // end if (1.1) // 1.2 Defines the urls for the modify/delete link(s) $url_query = PMA_generate_common_url($db, $table) . '&pos=' . $pos . '&session_max_rows=' . $session_max_rows . '&disp_direction=' . $disp_direction . '&repeat_cells=' . $repeat_cells . '&dontlimitchars=' . $dontlimitchars; // We need to copy the value or else the == 'both' check will always return true $propicon = (string) $GLOBALS['cfg']['PropertiesIconic']; if ($propicon == 'both') { $iconic_spacer = '<nobr>'; } else { $iconic_spacer = ''; } // 1.2.1 Modify link(s) if ($is_display['edit_lnk'] == 'ur') { // update row case // $lnk_goto = 'sql.php' // . '?' . str_replace('&', '&', $url_query) // . '&sql_query=' . urlencode($sql_query) // . '&goto=' . (empty($goto) ? 'tbl_properties.php' : $goto); // to reduce the length of the URL, because of some browsers limitations: $lnk_goto = 'sql.php'; $edit_url = 'tbl_change.php' . '?' . $url_query . '&primary_key=' . $uva_condition . '&sql_query=' . urlencode($sql_query) . '&goto=' . urlencode($lnk_goto); if ($GLOBALS['cfg']['PropertiesIconic'] == FALSE) { $edit_str = $GLOBALS['strEdit']; } else { $edit_str = $iconic_spacer . '<img width="12" height="13" src="images/button_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" border="0" />'; if ($propicon == 'both') { $edit_str .= ' ' . $GLOBALS['strEdit'] . '</nobr>'; } } } // end if (1.2.1) if ($table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db']) { $bookmark_go = '<a href="read_dump.php?' . PMA_generate_common_url($row['dbase'], '') . '&id_bookmark=' . $row['id'] . '&action_bookmark=0' . '&action_bookmark_all=1' . '&SQL=' . $GLOBALS['strExecuteBookmarked'] . ' " title="' . $GLOBALS['strExecuteBookmarked'] . '">'; if ($GLOBALS['cfg']['PropertiesIconic'] == FALSE) { $bookmark_go .= $GLOBALS['strExecuteBookmarked']; } else { $bookmark_go .= $iconic_spacer . '<img width="12" height="13" src="images/button_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" border="0" />'; if ($propicon == 'both') { $bookmark_go .= ' ' . $GLOBALS['strExecuteBookmarked'] . '</nobr>'; } } $bookmark_go .= '</a>'; } else { $bookmark_go = ''; } // 1.2.2 Delete/Kill link(s) if ($is_display['del_lnk'] == 'dr') { // delete row case $lnk_goto = 'sql.php' . '?' . str_replace('&', '&', $url_query) . '&sql_query=' . urlencode($sql_query) . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . (empty($goto) ? 'tbl_properties.php' : $goto); $del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . '+LIMIT+1'; $del_url = 'sql.php' . '?' . $url_query . '&sql_query=' . $del_query . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . urlencode($lnk_goto); $js_conf = 'DELETE FROM ' . PMA_jsFormat($table) . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), FALSE)) . ' LIMIT 1'; if ($GLOBALS['cfg']['PropertiesIconic'] == FALSE) { $del_str = $GLOBALS['strDelete']; } else { $del_str = $iconic_spacer . '<img width="12" height="13" src="images/button_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" border="0" />'; if ($propicon == 'both') { $del_str .= ' ' . $GLOBALS['strDelete'] . '</nobr>'; } } } else { if ($is_display['del_lnk'] == 'kp') { // kill process case $lnk_goto = 'sql.php' . '?' . str_replace('&', '&', $url_query) . '&sql_query=' . urlencode($sql_query) . '&goto=main.php'; $del_url = 'sql.php?' . PMA_generate_common_url('mysql') . '&sql_query=' . urlencode('KILL ' . $row['Id']) . '&goto=' . urlencode($lnk_goto); $del_query = urlencode('KILL ' . $row['Id']); $js_conf = 'KILL ' . $row['Id']; if ($GLOBALS['cfg']['PropertiesIconic'] == FALSE) { $del_str = $GLOBALS['strKill']; } else { $del_str = $iconic_spacer . '<img width="12" height="13" src="images/button_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" border="0" />'; if ($propicon == 'both') { $del_str .= ' ' . $GLOBALS['strKill'] . '</nobr>'; } } } } // end if (1.2.2) // 1.3 Displays the links at left if required if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { require './libraries/display_tbl_links.lib.php'; } // end if (1.3) echo $disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped' ? "\n" : ''; } // end if (1) // 2. Displays the rows' values for ($i = 0; $i < $fields_cnt; ++$i) { $meta = $fields_meta[$i]; // loic1: To fix bug #474943 under php4, the row pointer will // depend on whether the "is_null" php4 function is // available or not $pointer = function_exists('is_null') ? $i : $meta->name; // garvin: See if this column should get highlight because it's used in the // where-query. if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) { $column_style = 'style="border: 1px solid ' . $GLOBALS['cfg']['BrowseMarkerColor'] . '"'; } else { $column_style = ''; } // garvin: Wrap MIME-transformations. [MIME] $default_function = 'default_function'; // default_function $transform_function = $default_function; $transform_options = array(); if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) { $include_file = PMA_sanitizeTransformationFile($GLOBALS['mime_map'][$meta->name]['transformation']); if (file_exists('./libraries/transformations/' . $include_file)) { $transformfunction_name = preg_replace('@(\\.inc\\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']); require_once './libraries/transformations/' . $include_file; if (function_exists('PMA_transformation_' . $transformfunction_name)) { $transform_function = 'PMA_transformation_' . $transformfunction_name; $transform_options = PMA_transformation_getOptions(isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''); $meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']); } } // end if file_exists } // end if transformation is set } // end if mime/transformation works. $transform_options['wrapper_link'] = '?' . (isset($url_query) ? $url_query : '') . '&primary_key=' . (isset($uva_condition) ? $uva_condition : '') . '&sql_query=' . (isset($sql_query) ? urlencode($sql_query) : '') . '&goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '') . '&transform_key=' . urlencode($meta->name); // n u m e r i c if ($meta->numeric == 1) { // lem9: if two fields have the same name (this is possible // with self-join queries, for example), using $meta->name // will show both fields NULL even if only one is NULL, // so use the $pointer // (works only if function_exists('is_null') // PS: why not always work with the number ($i), since // the default second parameter of // mysql_fetch_array() is MYSQL_BOTH, so we always get // associative and numeric indices? //if (!isset($row[$meta->name]) if (!isset($row[$pointer]) || function_exists('is_null') && is_null($row[$pointer])) { $vertical_display['data'][$row_no][$i] = ' <td align="right" valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n"; } else { if ($row[$pointer] != '') { $vertical_display['data'][$row_no][$i] = ' <td align="right" valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '" nowrap="nowrap">'; if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; if (!empty($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; } // end if } // end if } // end while } if (isset($map[$meta->name])) { // Field to display from the foreign table? if (!empty($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$pointer]; $dispresult = PMA_mysql_query($dispsql); if ($dispresult && mysql_num_rows($dispresult) > 0) { $dispval = PMA_mysql_result($dispresult, 0); } else { $dispval = $GLOBALS['strLinkNotFound']; } } else { $dispval = ''; } // end if... else... if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$pointer], $transform_options, $meta) : $transform_function($row[$pointer], array(), $meta)) . ' <code>[->' . $dispval . ']</code>'; } else { $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : ''; $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$pointer]) . '"' . $title . '>' . ($transform_function != $default_function ? $transform_function($row[$pointer], $transform_options, $meta) : $transform_function($row[$pointer], array(), $meta)) . '</a>'; } } else { $vertical_display['data'][$row_no][$i] .= $transform_function != $default_function ? $transform_function($row[$pointer], $transform_options, $meta) : $transform_function($row[$pointer], array(), $meta); } $vertical_display['data'][$row_no][$i] .= '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td align="right" ' . $column_style . ' valign="top" bgcolor="' . $bgcolor . '" nowrap="nowrap"> </td>' . "\n"; } } // b l o b } else { if ($GLOBALS['cfg']['ShowBlob'] == FALSE && stristr($meta->type, 'BLOB')) { // loic1 : PMA_mysql_fetch_fields returns BLOB in place of // TEXT fields type, however TEXT fields must be displayed // even if $cfg['ShowBlob'] is false -> get the true type // of the fields. $field_flags = PMA_mysql_field_flags($dt_result, $i); if (stristr($field_flags, 'BINARY')) { $blobtext = '[BLOB'; if (isset($row[$pointer])) { $blob_size = PMA_formatByteDown(strlen($row[$pointer]), 3, 1); $blobtext .= ' - ' . $blob_size[0] . ' ' . $blob_size[1]; unset($blob_size); } $blobtext .= ']'; $blobtext = $default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta); $vertical_display['data'][$row_no][$i] = ' <td align="center" ' . $column_style . ' valign="top" bgcolor="' . $bgcolor . '">' . $blobtext . '</td>'; } else { //if (!isset($row[$meta->name]) if (!isset($row[$pointer]) || function_exists('is_null') && is_null($row[$pointer])) { $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n"; } else { if ($row[$pointer] != '') { // garvin: if a transform function for blob is set, none of these replacements will be made if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1) { $row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } // loic1: displays all space characters, 4 space // characters for tabulations and <cr>/<lf> $row[$pointer] = $default_function != $transform_function ? $transform_function($row[$pointer], $transform_options, $meta) : $default_function($row[$pointer], array(), $meta); $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '">' . $row[$pointer] . '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"> </td>' . "\n"; } } } } else { //if (!isset($row[$meta->name]) if (!isset($row[$pointer]) || function_exists('is_null') && is_null($row[$pointer])) { $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n"; } else { if ($row[$pointer] != '') { // loic1: support blanks in the key $relation_id = $row[$pointer]; // nijel: Cut all fields to $cfg['LimitChars'] if (strlen($row[$pointer]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1) { $row[$pointer] = substr($row[$pointer], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } // loic1: displays special characters from binaries $field_flags = PMA_mysql_field_flags($dt_result, $i); if (stristr($field_flags, 'BINARY')) { $row[$pointer] = str_replace("", '\\0', $row[$pointer]); $row[$pointer] = str_replace("", '\\b', $row[$pointer]); $row[$pointer] = str_replace("\n", '\\n', $row[$pointer]); $row[$pointer] = str_replace("\r", '\\r', $row[$pointer]); $row[$pointer] = str_replace("", '\\Z', $row[$pointer]); $row[$pointer] = $default_function != $transform_function ? $transform_function($row[$pointer], $transform_options, $meta) : $default_function($row[$pointer], array(), $meta); } else { $row[$pointer] = $default_function != $transform_function ? $transform_function($row[$pointer], $transform_options, $meta) : $default_function($row[$pointer], array(), $meta); } // garvin: transform functions may enable nowrapping: $function_nowrap = $transform_function . '_nowrap'; $bool_nowrap = $default_function != $transform_function && function_exists($function_nowrap) ? $function_nowrap($transform_options) : false; // loic1: do not wrap if date field type $nowrap = preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap ? ' nowrap="nowrap"' : ''; $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"' . $nowrap . '>'; if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; if (!empty($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; } // end if } // end if } // end while } if (isset($map[$meta->name])) { // Field to display from the foreign table? if (!empty($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($row[$pointer]) . '\''; $dispresult = @PMA_mysql_query($dispsql); if ($dispresult && mysql_num_rows($dispresult) > 0) { $dispval = PMA_mysql_result($dispresult, 0); } else { $dispval = $GLOBALS['strLinkNotFound']; } } else { $dispval = ''; } $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : ''; $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>' . $row[$pointer] . '</a>'; } else { $vertical_display['data'][$row_no][$i] .= $row[$pointer]; } $vertical_display['data'][$row_no][$i] .= '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td valign="top" ' . $column_style . ' bgcolor="' . $bgcolor . '"> </td>' . "\n"; } } } } // lem9: output stored cell if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { echo $vertical_display['data'][$row_no][$i]; } if (isset($vertical_display['rowdata'][$i][$row_no])) { $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i]; } else { $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i]; } } // end for (2) // 3. Displays the modify/delete links on the right if required if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { require './libraries/display_tbl_links.lib.php'; } // end if (3) if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { echo "\n"; ?> </tr> <?php } // end if // 4. Gather links of del_urls and edit_urls in an array for later // output if (!isset($vertical_display['edit'][$row_no])) { $vertical_display['edit'][$row_no] = ''; $vertical_display['delete'][$row_no] = ''; $vertical_display['row_delete'][$row_no] = ''; } if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { $vertical_display['row_delete'][$row_no] .= ' <td width="10" align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n" . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '" name="rows_to_delete[' . $uva_condition . ']" value="' . $del_query . '" />' . "\n" . ' </td>' . "\n"; } else { unset($vertical_display['row_delete'][$row_no]); } if (isset($edit_url)) { $vertical_display['edit'][$row_no] .= ' <td width="10" align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n" . PMA_linkOrButton($edit_url, $edit_str, '') . $bookmark_go . ' </td>' . "\n"; } else { unset($vertical_display['edit'][$row_no]); } if (isset($del_url)) { $vertical_display['delete'][$row_no] .= ' <td width="10" align="center" valign="' . ($bookmark_go != '' ? 'top' : 'middle') . '" bgcolor="' . $bgcolor . '">' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '') . ' </td>' . "\n"; } else { unset($vertical_display['delete'][$row_no]); } echo $disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped' ? "\n" : ''; $row_no++; } // end while if (isset($url_query)) { $GLOBALS['url_query'] = $url_query; } return TRUE; }
<th align="center"> <?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?> </th> <th align="right" nowrap="nowrap"> <?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?> </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 } ?> <th> </th> </tr> </tbody> </table> <?php }
<td class="value">-</td> <?php } ?> <?php } else { ?> <td colspan="<?php echo ($structure_tbl_col_cnt - ($db_is_information_schema ? 5 : 8)) ?>" align="center"> <?php echo $strInUse; ?></td> <?php } // end if (isset($each_table['TABLE_ROWS'])) else ?> </tr> <?php } // end foreach // Show Summary if ($is_show_stats) { list($sum_formatted, $unit) = PMA_formatByteDown($sum_size, 3, 1); list($overhead_formatted, $overhead_unit) = PMA_formatByteDown($overhead_size, 3, 1); } ?> </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>
if ($is_superuser) { echo ' <td class="tool">' . "\n" . ' <a onclick="window.parent.setDb(\'' . urlencode($current['SCHEMA_NAME']) . '\');" href="./server_privileges.php?' . $url_query . '&checkprivs=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['SCHEMA_NAME'])) . '">' . "\n" . ' ' . ($cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . $strCheckPrivs . '" /> ' : $strCheckPrivs) . "\n" . ' </a></td>' . "\n"; } 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') {
$tbl_url_params['db'] = $db; $tbl_url_params['table'] = $table; $is_show_stats = $cfg['ShowStats']; $tbl_stats_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($table) . '\';'); $tbl_stats = PMA_DBI_fetch_assoc($tbl_stats_result); PMA_DBI_free_result($tbl_stats_result); unset($tbl_stats_result); if ($is_show_stats) { $sum_size = (double) 0; $overhead_size = (double) 0; $overhead_check = ''; $tblsize = doubleval($tbl_stats['Data_length']) + doubleval($tbl_stats['Index_length']); $sum_size += $tblsize; list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, $tblsize > 0 ? 1 : 0); if (isset($tbl_stats['Data_free']) && $tbl_stats['Data_free'] > 0) { list($formatted_overhead, $overhead_unit) = PMA_formatByteDown($tbl_stats['Data_free'], 3, $tbl_stats['Data_free'] > 0 ? 1 : 0); $overhead_size += $tbl_stats['Data_free']; } if (isset($formatted_overhead)) { $overhead = $formatted_overhead . ' ' . $overhead_unit; unset($formatted_overhead); } else { $overhead = '-'; } } $new_table_string = '<tr>' . "\n"; $new_table_string .= '<td align="center"> <input type="checkbox" id="checkbox_tbl_" name="selected_tbl[]" value="' . htmlspecialchars($table) . '" /> </td>' . "\n"; $new_table_string .= '<th>'; $new_table_string .= '<a href="sql.php' . PMA_generate_common_url($tbl_url_params) . '">' . htmlspecialchars($table) . '</a>'; if (PMA_Tracker::isActive()) { $truename = str_replace(' ', ' ', htmlspecialchars($table));
/** * Verifies what to do with non-printable contents (binary or BLOB) * in Browse mode. * * @uses is_null() * @uses isset() * @uses strlen() * @uses PMA_formatByteDown() * @uses strpos() * @uses str_replace() * @param string $category BLOB|BINARY * @param string $content the binary content * @param string $transform_function * @param string $transform_options * @param string $default_function * @param object $meta the meta-information about this field * @return mixed string or float */ function PMA_handle_non_printable_contents($category, $content, $transform_function, $transform_options, $default_function, $meta) { $result = '[' . $category; if (is_null($content)) { $result .= ' - NULL'; $size = 0; } elseif (isset($content)) { $size = strlen($content); $display_size = PMA_formatByteDown($size, 3, 1); $result .= ' - ' . $display_size[0] . $display_size[1]; } $result .= ']'; if (strpos($transform_function, 'octetstream')) { $result = $content; } if ($size > 0) { if ($default_function != $transform_function) { $result = $transform_function($result, $transform_options, $meta); } else { $result = $default_function($result, array(), $meta); if (stristr($meta->type, 'BLOB') && $_SESSION['tmp_user_values']['display_blob']) { // in this case, restart from the original $content $result = htmlspecialchars(PMA_replace_binary_contents($content)); } } } return $result; }
/** * 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; }
/** * Displays the body of the results table * * @param integer the link id associated to the query which results have * to be displayed * @param array which elements to display * @param array the list of relations * @param array the analyzed query * * @return boolean always true * * @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 sql query * @global integer $pos the current position in results * @global integer $session_max_rows the maximum number of rows per page * @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 * @gloabl array $row current row data * * @access private * * @see PMA_displayTable() */ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) { global $db, $table, $goto, $dontlimitchars; global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt; global $vertical_display, $disp_direction, $repeat_cells, $highlight_columns; global $row; // mostly because of browser transformations, to make the row-data accessible in a plugin $url_sql_query = $sql_query; // query without conditions to shorten urls when needed, 200 is just // guess, it should depend on remaining url length if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['querytype']) && $analyzed_sql[0]['querytype'] == 'SELECT' && strlen($sql_query) > 200) { $url_sql_query = 'SELECT '; if (isset($analyzed_sql[0]['queryflags']['distinct'])) { $url_sql_query .= ' DISTINCT '; } $url_sql_query .= $analyzed_sql[0]['select_expr_clause']; if (!empty($analyzed_sql[0]['from_clause'])) { $url_sql_query .= ' FROM ' . $analyzed_sql[0]['from_clause']; } } if (!is_array($map)) { $map = array(); } $row_no = 0; $vertical_display['edit'] = array(); $vertical_display['delete'] = array(); $vertical_display['data'] = array(); $vertical_display['row_delete'] = array(); // Correction uva 19991216 in the while below // Previous code assumed that all tables have keys, specifically that // the phpMyAdmin GUI should support row delete/edit only for such // tables. // Although always using keys is arguably the prescribed way of // defining a relational table, it is not required. This will in // particular be violated by the novice. // We want to encourage phpMyAdmin usage by such novices. So the code // below has been changed to conditionally work as before when the // table being displayed has one or more keys; but to display // delete/edit options correctly for tables without keys. // loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row' // to get the NULL values // rabus: This function needs a little rework. // Using MYSQL_BOTH just pollutes the memory! // ne0x: Use function PMA_DBI_fetch_array() due to mysqli // compatibility. Now this function is wrapped. $odd_row = true; while ($row = PMA_DBI_fetch_row($dt_result)) { // lem9: "vertical display" mode stuff if ($row_no != 0 && $repeat_cells != 0 && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { echo '<tr>' . "\n"; if ($vertical_display['emptypre'] > 0) { echo ' <th colspan="' . $vertical_display['emptypre'] . '">' . "\n" . ' </th>' . "\n"; } foreach ($vertical_display['desc'] as $val) { echo $val; } if ($vertical_display['emptyafter'] > 0) { echo ' <th colspan="' . $vertical_display['emptyafter'] . '">' . "\n" . ' </th>' . "\n"; } echo '</tr>' . "\n"; } // end if $class = $odd_row ? 'odd' : 'even'; $odd_row = !$odd_row; if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { // loic1: pointer code part echo ' <tr class="' . $class . '">' . "\n"; $class = ''; } // 1. Prepares the row (gets primary keys to use) // 1.1 Results from a "SELECT" statement -> builds the // "primary" key to use in links $uva_condition = urlencode(PMA_getUvaCondition($dt_result, $fields_cnt, $fields_meta, $row)); // 1.2 Defines the urls for the modify/delete link(s) $url_query = PMA_generate_common_url($db, $table) . '&pos=' . $pos . '&session_max_rows=' . $session_max_rows . '&disp_direction=' . $disp_direction . '&repeat_cells=' . $repeat_cells . '&dontlimitchars=' . $dontlimitchars; if ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn') { // We need to copy the value or else the == 'both' check will always return true if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $iconic_spacer = '<div class="nowrap">'; } else { $iconic_spacer = ''; } // 1.2.1 Modify link(s) if ($is_display['edit_lnk'] == 'ur') { // update row case $lnk_goto = 'sql.php'; $edit_url = 'tbl_change.php' . '?' . $url_query . '&primary_key=' . $uva_condition . '&sql_query=' . urlencode($url_sql_query) . '&goto=' . urlencode($lnk_goto); if ($GLOBALS['cfg']['PropertiesIconic'] === false) { $edit_str = $GLOBALS['strEdit']; } else { $edit_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" alt="' . $GLOBALS['strEdit'] . '" title="' . $GLOBALS['strEdit'] . '" />'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $edit_str .= ' ' . $GLOBALS['strEdit'] . '</div>'; } } } // end if (1.2.1) if ($table == $GLOBALS['cfg']['Bookmark']['table'] && $db == $GLOBALS['cfg']['Bookmark']['db'] && isset($row[1]) && isset($row[0])) { $bookmark_go = '<a href="import.php?' . PMA_generate_common_url($row[1], '') . '&id_bookmark=' . $row[0] . '&action_bookmark=0' . '&action_bookmark_all=1' . '&SQL=' . $GLOBALS['strExecuteBookmarked'] . ' " title="' . $GLOBALS['strExecuteBookmarked'] . '">'; if ($GLOBALS['cfg']['PropertiesIconic'] === false) { $bookmark_go .= $GLOBALS['strExecuteBookmarked']; } else { $bookmark_go .= $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_bookmark.png" alt="' . $GLOBALS['strExecuteBookmarked'] . '" title="' . $GLOBALS['strExecuteBookmarked'] . '" />'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $bookmark_go .= ' ' . $GLOBALS['strExecuteBookmarked'] . '</div>'; } } $bookmark_go .= '</a>'; } else { $bookmark_go = ''; } // 1.2.2 Delete/Kill link(s) if ($is_display['del_lnk'] == 'dr') { // delete row case $lnk_goto = 'sql.php' . '?' . str_replace('&', '&', $url_query) . '&sql_query=' . urlencode($url_sql_query) . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . (empty($goto) ? 'tbl_properties.php' : $goto); $del_query = urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . '+LIMIT+1'; $del_url = 'sql.php' . '?' . $url_query . '&sql_query=' . $del_query . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted'])) . '&goto=' . urlencode($lnk_goto); $js_conf = 'DELETE FROM ' . PMA_jsFormat($table) . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), false)) . ' LIMIT 1'; if ($GLOBALS['cfg']['PropertiesIconic'] === false) { $del_str = $GLOBALS['strDelete']; } else { $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strDelete'] . '" title="' . $GLOBALS['strDelete'] . '" />'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $del_str .= ' ' . $GLOBALS['strDelete'] . '</div>'; } } } elseif ($is_display['del_lnk'] == 'kp') { // kill process case $lnk_goto = 'sql.php' . '?' . str_replace('&', '&', $url_query) . '&sql_query=' . urlencode($url_sql_query) . '&goto=main.php'; $del_url = 'sql.php?' . PMA_generate_common_url('mysql') . '&sql_query=' . urlencode('KILL ' . $row[0]) . '&goto=' . urlencode($lnk_goto); $del_query = urlencode('KILL ' . $row[0]); $js_conf = 'KILL ' . $row[0]; if ($GLOBALS['cfg']['PropertiesIconic'] === false) { $del_str = $GLOBALS['strKill']; } else { $del_str = $iconic_spacer . '<img class="icon" width="16" height="16" src="' . $GLOBALS['pmaThemeImage'] . 'b_drop.png" alt="' . $GLOBALS['strKill'] . '" title="' . $GLOBALS['strKill'] . '" />'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $del_str .= ' ' . $GLOBALS['strKill'] . '</div>'; } } } // end if (1.2.2) // 1.3 Displays the links at left if required if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { $doWriteModifyAt = 'left'; require './libraries/display_tbl_links.lib.php'; } // end if (1.3) } // end if (1) // 2. Displays the rows' values for ($i = 0; $i < $fields_cnt; ++$i) { $meta = $fields_meta[$i]; // loic1: To fix bug #474943 under php4, the row pointer will // depend on whether the "is_null" php4 function is // available or not $pointer = function_exists('is_null') ? $i : $meta->name; // garvin: See if this column should get highlight because it's used in the // where-query. if (isset($highlight_columns) && (isset($highlight_columns[$meta->name]) || isset($highlight_columns[PMA_backquote($meta->name)]))) { $condition_field = true; } else { $condition_field = false; } $mouse_events = ''; if ($disp_direction == 'vertical' && (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1')) { if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) { $mouse_events .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"' . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');" '; } if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) { $mouse_events .= ' onmousedown="setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\'); setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" '; } else { $mouse_events .= ' onmousedown="setCheckboxColumn(\'id_rows_to_delete' . $row_no . '\');" '; } } // end if // garvin: Wrap MIME-transformations. [MIME] $default_function = 'default_function'; // default_function $transform_function = $default_function; $transform_options = array(); if ($GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { if (isset($GLOBALS['mime_map'][$meta->name]['mimetype']) && isset($GLOBALS['mime_map'][$meta->name]['transformation']) && !empty($GLOBALS['mime_map'][$meta->name]['transformation'])) { $include_file = PMA_sanitizeTransformationFile($GLOBALS['mime_map'][$meta->name]['transformation']); if (file_exists('./libraries/transformations/' . $include_file)) { $transformfunction_name = preg_replace('@(\\.inc\\.php3?)$@i', '', $GLOBALS['mime_map'][$meta->name]['transformation']); require_once './libraries/transformations/' . $include_file; if (function_exists('PMA_transformation_' . $transformfunction_name)) { $transform_function = 'PMA_transformation_' . $transformfunction_name; $transform_options = PMA_transformation_getOptions(isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : ''); $meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']); } } // end if file_exists } // end if transformation is set } // end if mime/transformation works. $transform_options['wrapper_link'] = '?' . (isset($url_query) ? $url_query : '') . '&primary_key=' . (isset($uva_condition) ? $uva_condition : '') . '&sql_query=' . (isset($sql_query) ? urlencode($url_sql_query) : '') . '&goto=' . (isset($sql_goto) ? urlencode($lnk_goto) : '') . '&transform_key=' . urlencode($meta->name); // n u m e r i c if ($meta->numeric == 1) { // lem9: if two fields have the same name (this is possible // with self-join queries, for example), using $meta->name // will show both fields NULL even if only one is NULL, // so use the $pointer // (works only if function_exists('is_null') // PS: why not always work with the number ($i), since // the default second parameter of // mysql_fetch_array() is MYSQL_BOTH, so we always get // associative and numeric indices? //if (!isset($row[$meta->name]) if (!isset($row[$i]) || is_null($row[$i])) { $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n"; } elseif ($row[$i] != '') { $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . ' nowrap">'; if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; } // end if } // end if } // end while } if (isset($map[$meta->name])) { // Field to display from the foreign table? if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]; $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE); if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { list($dispval) = PMA_DBI_fetch_row($dispresult, 0); } else { $dispval = $GLOBALS['strLinkNotFound']; } @PMA_DBI_free_result($dispresult); } else { $dispval = ''; } // end if... else... if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') { $vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . ' <code>[->' . $dispval . ']</code>'; } else { $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : ''; $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>' . ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>'; } } else { $vertical_display['data'][$row_no][$i] .= $transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta); } $vertical_display['data'][$row_no][$i] .= '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ' nowrap' . ($condition_field ? ' condition' : '') . '"> </td>' . "\n"; } // b l o b } elseif ($GLOBALS['cfg']['ShowBlob'] == false && stristr($meta->type, 'BLOB')) { // loic1 : PMA_mysql_fetch_fields returns BLOB in place of // TEXT fields type, however TEXT fields must be displayed // even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type // of the fields. $field_flags = PMA_DBI_field_flags($dt_result, $i); if (stristr($field_flags, 'BINARY')) { $blobtext = '[BLOB'; if (!isset($row[$i]) || is_null($row[$i])) { $blobtext .= ' - NULL'; $blob_size = 0; } elseif (isset($row[$i])) { $blob_size = strlen($row[$i]); $display_blob_size = PMA_formatByteDown($blob_size, 3, 1); $blobtext .= ' - ' . $display_blob_size[0] . ' ' . $display_blob_size[1]; unset($display_blob_size); } $blobtext .= ']'; if (strpos($transform_function, 'octetstream')) { $blobtext = $row[$i]; } if ($blob_size > 0) { $blobtext = $default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta); } unset($blob_size); $vertical_display['data'][$row_no][$i] = ' <td align="left"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $blobtext . '</td>'; } else { if (!isset($row[$i]) || is_null($row[$i])) { $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n"; } elseif ($row[$i] != '') { // garvin: if a transform function for blob is set, none of these replacements will be made if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1) { $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } // loic1: displays all space characters, 4 space // characters for tabulations and <cr>/<lf> $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta); $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $row[$i] . '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"> </td>' . "\n"; } } } else { if (!isset($row[$i]) || is_null($row[$i])) { $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n"; } elseif ($row[$i] != '') { // loic1: support blanks in the key $relation_id = $row[$i]; // nijel: Cut all fields to $GLOBALS['cfg']['LimitChars'] // lem9: (unless it's a link-type transformation) if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1 && !strpos($transform_function, 'link') === true) { $row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...'; } // loic1: displays special characters from binaries $field_flags = PMA_DBI_field_flags($dt_result, $i); if (stristr($field_flags, 'BINARY')) { $row[$i] = str_replace("", '\\0', $row[$i]); $row[$i] = str_replace("", '\\b', $row[$i]); $row[$i] = str_replace("\n", '\\n', $row[$i]); $row[$i] = str_replace("\r", '\\r', $row[$i]); $row[$i] = str_replace("", '\\Z', $row[$i]); $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta); } else { $row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta); } // garvin: transform functions may enable nowrapping: $function_nowrap = $transform_function . '_nowrap'; $bool_nowrap = $default_function != $transform_function && function_exists($function_nowrap) ? $function_nowrap($transform_options) : false; // loic1: do not wrap if date field type $nowrap = preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap ? ' nowrap' : ''; $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . $nowrap . ($condition_field ? ' condition' : '') . '">'; if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) { foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) { $alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias']; if (isset($alias) && strlen($alias)) { $true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column']; if ($alias == $meta->name) { $meta->name = $true_column; } // end if } // end if } // end while } if (isset($map[$meta->name])) { // Field to display from the foreign table? if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) { $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($row[$i]) . '\''; $dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE); if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) { list($dispval) = PMA_DBI_fetch_row($dispresult); @PMA_DBI_free_result($dispresult); } else { $dispval = $GLOBALS['strLinkNotFound']; } } else { $dispval = ''; } $title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : ''; $vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = \'' . PMA_sqlAddslashes($relation_id) . '\'') . '"' . $title . '>' . $row[$i] . '</a>'; } else { $vertical_display['data'][$row_no][$i] .= $row[$i]; } $vertical_display['data'][$row_no][$i] .= '</td>' . "\n"; } else { $vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"> </td>' . "\n"; } } // lem9: output stored cell if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { echo $vertical_display['data'][$row_no][$i]; } if (isset($vertical_display['rowdata'][$i][$row_no])) { $vertical_display['rowdata'][$i][$row_no] .= $vertical_display['data'][$row_no][$i]; } else { $vertical_display['rowdata'][$i][$row_no] = $vertical_display['data'][$row_no][$i]; } } // end for (2) // 3. Displays the modify/delete links on the right if required if ($GLOBALS['cfg']['ModifyDeleteAtRight'] && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) { $doWriteModifyAt = 'right'; require './libraries/display_tbl_links.lib.php'; } // end if (3) if ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped') { ?> </tr> <?php } // end if // 4. Gather links of del_urls and edit_urls in an array for later // output if (!isset($vertical_display['edit'][$row_no])) { $vertical_display['edit'][$row_no] = ''; $vertical_display['delete'][$row_no] = ''; $vertical_display['row_delete'][$row_no] = ''; } $column_style_vertical = ''; if ($GLOBALS['cfg']['BrowsePointerEnable'] == true) { $column_style_vertical .= ' onmouseover="setVerticalPointer(this, ' . $row_no . ', \'over\', \'odd\', \'even\', \'hover\', \'marked\');"' . ' onmouseout="setVerticalPointer(this, ' . $row_no . ', \'out\', \'odd\', \'even\', \'hover\', \'marked\');"'; } $column_marker_vertical = ''; if ($GLOBALS['cfg']['BrowseMarkerEnable'] == true) { $column_marker_vertical .= 'setVerticalPointer(this, ' . $row_no . ', \'click\', \'odd\', \'even\', \'hover\', \'marked\');'; } if (!empty($del_url) && $is_display['del_lnk'] != 'kp') { $vertical_display['row_delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n" . ' <input type="checkbox" id="id_rows_to_delete' . $row_no . '[%_PMA_CHECKBOX_DIR_%]" name="rows_to_delete[' . $uva_condition . ']"' . ' onclick="' . $column_marker_vertical . 'copyCheckboxesRange(\'rowsDeleteForm\', \'id_rows_to_delete' . $row_no . '\',\'[%_PMA_CHECKBOX_DIR_%]\');"' . ' value="' . $del_query . '" ' . (isset($GLOBALS['checkall']) ? 'checked="checked"' : '') . ' />' . "\n" . ' </td>' . "\n"; } else { unset($vertical_display['row_delete'][$row_no]); } if (isset($edit_url)) { $vertical_display['edit'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n" . PMA_linkOrButton($edit_url, $edit_str, array(), false) . $bookmark_go . ' </td>' . "\n"; } else { unset($vertical_display['edit'][$row_no]); } if (isset($del_url)) { $vertical_display['delete'][$row_no] .= ' <td align="center" class="' . $class . '" ' . $column_style_vertical . '>' . "\n" . PMA_linkOrButton($del_url, $del_str, isset($js_conf) ? $js_conf : '', false) . ' </td>' . "\n"; } else { unset($vertical_display['delete'][$row_no]); } echo $disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped' ? "\n" : ''; $row_no++; } // end while if (isset($url_query)) { $GLOBALS['url_query'] = $url_query; } return true; }
/** * returns the engine specific handling for * PMA_ENGINE_DETAILS_TYPE_SIZE type variables. * * This function should be overridden when * PMA_ENGINE_DETAILS_TYPE_SIZE type needs to be * handled differently for a particular engine. * * @return string the formatted value and its unit */ function resolveTypeSize($value) { return PMA_formatByteDown($value); }
// end if ($pluginsExist) } // end if ($requiredTblType == strtolower ($tbl_type)) } // end if (!empty($PMA_Config)) } // end if (isset ($tbl_type) && strlen ($tbl_type) > 0) if ($bs_reference_exists) { echo '<input type="hidden" name="remove_blob_ref_' . $field['Field_md5'] . $vkey . '" value="' . $data . '" />'; echo '<input type="checkbox" name="remove_blob_repo_' . $field['Field_md5'] . $vkey . '" /> ' . $strBLOBRepositoryRemove . "<br />"; echo PMA_BS_CreateReferenceLink($data, $db); echo "<br />"; } else { echo $strBinaryDoNotEdit; if (isset($data)) { $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1); echo ' (' . $data_size[0] . ' ' . $data_size[1] . ')'; unset($data_size); } echo "\n"; } // end if ($bs_reference_exists) ?> <input type="hidden" name="fields_type<?php echo $field_name_appendix; ?> " value="protected" /> <input type="hidden" name="fields<?php echo $field_name_appendix; ?> " value="" />
+ $showtable['Index_length'] - $showtable['Data_free']); } else { unset($free_size); unset($free_unit); list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']); } list($tot_size, $tot_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']); if ($num_rows > 0) { list($avg_size, $avg_unit) = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1); } // Displays them ?> <br /><br /> <table cellspacing="0" cellpadding="0"> <tr> <!-- Space usage --> <td class="vtop"> <big><?php echo __('Space usage') . ':'; ?></big> <table width="100%"> <tr>