📄 common.lib.php
字号:
$php_params['show_as_php'] = 1; $_message = $GLOBALS['strPhp']; } $php_link = 'import.php' . PMA_generate_common_url($php_params); $php_link = ' [' . PMA_linkOrButton($php_link, $_message) . ']'; if (isset($GLOBALS['show_as_php'])) { $runquery_link = 'import.php' . PMA_generate_common_url($url_params); $php_link .= ' [' . PMA_linkOrButton($runquery_link, $GLOBALS['strRunQuery']) . ']'; } } else { $php_link = ''; } //show as php // Refresh query if (! empty($cfg['SQLQuery']['Refresh']) && preg_match('@^(SELECT|SHOW)[[:space:]]+@i', $sql_query)) { $refresh_link = 'import.php' . PMA_generate_common_url($url_params); $refresh_link = ' [' . PMA_linkOrButton($refresh_link, $GLOBALS['strRefresh']) . ']'; } else { $refresh_link = ''; } //show as php if (! empty($cfg['SQLValidator']['use']) && ! empty($cfg['SQLQuery']['Validate'])) { $validate_params = $url_params; if (!empty($GLOBALS['validatequery'])) { $validate_message = $GLOBALS['strNoValidateSQL'] ; } else { $validate_params['validatequery'] = 1; $validate_message = $GLOBALS['strValidateSQL'] ; } $validate_link = 'import.php' . PMA_generate_common_url($validate_params); $validate_link = ' [' . PMA_linkOrButton($validate_link, $validate_message) . ']'; } else { $validate_link = ''; } //validator echo '<code class="sql">'; if ($query_too_big) { echo $shortened_query_base; } else { echo $query_base; } //Clean up the end of the PHP if (! empty($GLOBALS['show_as_php'])) { echo '";'; } echo '</code>'; echo '<div class="tools">'; // avoid displaying a Profiling checkbox that could // be checked, which would reexecute an INSERT, for example if (! empty($refresh_link)) { PMA_profilingCheckbox($sql_query); } echo $edit_link . $explain_link . $php_link . $refresh_link . $validate_link; echo '</div>'; } echo '</div><br />' . "\n";} // end of the 'PMA_showMessage()' function/** * Verifies if current MySQL server supports profiling * * @uses $_SESSION['profiling_supported'] for caching * @uses $GLOBALS['server'] * @uses PMA_DBI_fetch_value() * @uses PMA_MYSQL_INT_VERSION * @uses defined() * @access public * @return boolean whether profiling is supported * * @author Marc Delisle */function PMA_profilingSupported(){ if (! PMA_cacheExists('profiling_supported', true)) { // 5.0.37 has profiling but for example, 5.1.20 does not // (avoid a trip to the server for MySQL before 5.0.37) // and do not set a constant as we might be switching servers if (defined('PMA_MYSQL_INT_VERSION') && PMA_MYSQL_INT_VERSION >= 50037 && PMA_DBI_fetch_value("SHOW VARIABLES LIKE 'profiling'")) { PMA_cacheSet('profiling_supported', true, true); } else { PMA_cacheSet('profiling_supported', false, true); } } return PMA_cacheGet('profiling_supported', true);}/** * Displays a form with the Profiling checkbox * * @param string $sql_query * @access public * * @author Marc Delisle */function PMA_profilingCheckbox($sql_query){ if (PMA_profilingSupported()) { echo '<form action="sql.php" method="post">' . "\n"; echo PMA_generate_common_hidden_inputs($GLOBALS['db'], $GLOBALS['table']); echo '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n"; echo '<input type="hidden" name="profiling_form" value="1" />' . "\n"; PMA_generate_html_checkbox('profiling', $GLOBALS['strProfiling'], isset($_SESSION['profiling']), true); echo '<noscript><input type="submit" value="' . $GLOBALS['strGo'] . '" /></noscript>' . "\n"; echo '</form>' . "\n"; }}/** * Displays the results of SHOW PROFILE * * @param array the results * @access public * * @author Marc Delisle */function PMA_profilingResults($profiling_results){ echo '<fieldset><legend>' . $GLOBALS['strProfiling'] . '</legend>' . "\n"; echo '<table>' . "\n"; echo ' <tr>' . "\n"; echo ' <th>' . $GLOBALS['strStatus'] . '</th>' . "\n"; echo ' <th>' . $GLOBALS['strTime'] . '</th>' . "\n"; echo ' </tr>' . "\n"; foreach($profiling_results as $one_result) { echo ' <tr>' . "\n"; echo '<td>' . $one_result['Status'] . '</td>' . "\n"; echo '<td>' . $one_result['Duration'] . '</td>' . "\n"; } echo '</table>' . "\n"; echo '</fieldset>' . "\n";}/** * Formats $value to byte view * * @param double the value to format * @param integer the sensitiveness * @param integer the number of decimals to retain * * @return array the formatted value and its unit * * @access public * * @author staybyte * @version 1.2 - 18 July 2002 */function PMA_formatByteDown($value, $limes = 6, $comma = 0){ $dh = PMA_pow(10, $comma); $li = PMA_pow(10, $limes); $return_value = $value; $unit = $GLOBALS['byteUnits'][0]; for ($d = 6, $ex = 15; $d >= 1; $d--, $ex-=3) { if (isset($GLOBALS['byteUnits'][$d]) && $value >= $li * PMA_pow(10, $ex)) { // use 1024.0 to avoid integer overflow on 64-bit machines $value = round($value / (PMA_pow(1024, $d) / $dh)) /$dh; $unit = $GLOBALS['byteUnits'][$d]; break 1; } // end if } // end for if ($unit != $GLOBALS['byteUnits'][0]) { // if the unit is not bytes (as represented in current language) // reformat with max length of 5 // 4th parameter=true means do not reformat if value < 1 $return_value = PMA_formatNumber($value, 5, $comma, true); } else { // do not reformat, just handle the locale $return_value = PMA_formatNumber($value, 0); } return array($return_value, $unit);} // end of the 'PMA_formatByteDown' function/** * Formats $value to the given length and appends SI prefixes * $comma is not substracted from the length * with a $length of 0 no truncation occurs, number is only formated * to the current locale * * examples: * <code> * echo PMA_formatNumber(123456789, 6); // 123,457 k * echo PMA_formatNumber(-123456789, 4, 2); // -123.46 M * echo PMA_formatNumber(-0.003, 6); // -3 m * echo PMA_formatNumber(0.003, 3, 3); // 0.003 * echo PMA_formatNumber(0.00003, 3, 2); // 0.03 m * echo PMA_formatNumber(0, 6); // 0 * * </code> * @param double $value the value to format * @param integer $length the max length * @param integer $comma the number of decimals to retain * @param boolean $only_down do not reformat numbers below 1 * * @return string the formatted value and its unit * * @access public * * @author staybyte, sebastian mendel * @version 1.1.0 - 2005-10-27 */function PMA_formatNumber($value, $length = 3, $comma = 0, $only_down = false){ //number_format is not multibyte safe, str_replace is safe if ($length === 0) { return str_replace(array(',', '.'), array($GLOBALS['number_thousands_separator'], $GLOBALS['number_decimal_separator']), number_format($value, $comma)); } // this units needs no translation, ISO $units = array( -8 => 'y', -7 => 'z', -6 => 'a', -5 => 'f', -4 => 'p', -3 => 'n', -2 => 'µ', -1 => 'm', 0 => ' ', 1 => 'k', 2 => 'M', 3 => 'G', 4 => 'T', 5 => 'P', 6 => 'E', 7 => 'Z', 8 => 'Y' ); // we need at least 3 digits to be displayed if (3 > $length + $comma) { $length = 3 - $comma; } // check for negative value to retain sign if ($value < 0) { $sign = '-'; $value = abs($value); } else { $sign = ''; } $dh = PMA_pow(10, $comma); $li = PMA_pow(10, $length); $unit = $units[0]; if ($value >= 1) { for ($d = 8; $d >= 0; $d--) { if (isset($units[$d]) && $value >= $li * PMA_pow(1000, $d-1)) { $value = round($value / (PMA_pow(1000, $d) / $dh)) /$dh; $unit = $units[$d]; break 1; } // end if } // end for } elseif (!$only_down && (float) $value !== 0.0) { for ($d = -8; $d <= 8; $d++) { if (isset($units[$d]) && $value <= $li * PMA_pow(1000, $d-1)) { $value = round($value / (PMA_pow(1000, $d) / $dh)) /$dh; $unit = $units[$d]; break 1; } // end if } // end for } // end if ($value >= 1) elseif (!$only_down && (float) $value !== 0.0) //number_format is not multibyte safe, str_replace is safe $value = str_replace(array(',', '.'), array($GLOBALS['number_thousands_separator'], $GLOBALS['number_decimal_separator']), number_format($value, $comma)); return $sign . $value . ' ' . $unit;} // end of the 'PMA_formatNumber' function/** * Writes localised date * * @param string the current timestamp * * @return string the formatted date * * @access public */function PMA_localisedDate($timestamp = -1, $format = ''){ global $datefmt, $month, $day_of_week; if ($format == '') { $format = $datefmt; } if ($timestamp == -1) { $timestamp = time(); } $date = preg_replace('@%[aA]@', $day_of_week[(int)strftime('%w', $timestamp)], $format); $date = preg_replace('@%[bB]@', $month[(int)strftime('%m', $timestamp)-1], $date); return strftime($date, $timestamp);} // end of the 'PMA_localisedDate()' function/** * returns a tab for tabbed navigation. * If the variables $link and $args ar left empty, an inactive tab is created * * @uses $GLOBALS['PMA_PHP_SELF'] * @uses $GLOBALS['strEmpty'] * @uses $GLOBALS['strDrop'] * @uses $GLOBALS['active_page'] * @uses $GLOBALS['url_query'] * @uses $cfg['MainPageIconic'] * @uses $GLOBALS['pmaThemeImage'] * @uses PMA_generate_common_url() * @uses E_USER_NOTICE * @uses htmlentities() * @uses urlencode() * @uses sprintf() * @uses trigger_error() * @uses array_merge() * @uses basename() * @param array $tab array with all options * @param array $url_params * @return string html code for one tab, a link if valid otherwise a span * @access public */function PMA_getTab($tab, $url_params = array()){ // default values $defaults = array( 'text' => '', 'class' => '', 'active' => false, 'link' => '', 'sep' => '?', 'attr' => '', 'args' => '', 'warning' => '', 'fragment' => '', ); $tab = array_merge($defaults, $tab); // determine additionnal style-class if (empty($tab['class'])) { if ($tab['text'] == $GLOBALS['strEmpty'] || $tab['text'] == $GLOBALS['strDrop']) { $tab['class'] = 'caution'; } elseif (! empty($tab['active']) || PMA_isValid($GLOBALS['active_page'], 'identical', $tab['link'])) { $tab['class'] = 'active'; } elseif (empty($GLOBALS['active_page']) && basename($GLOBALS['PMA_PHP_SELF']) == $tab['link'] && empty($tab['warning'])) { $tab['class'] = 'active'; } } if (!empty($tab['warning'])) { $tab['class'] .= ' warning'; $tab['attr'] .= ' title="' . htmlspecialchars($tab['warning']) . '"'; } // build the link if (!empty($tab['link'])) { $tab['link'] = htmlentities($tab['link']); $tab['link'] = $tab['link'] . PMA_generate_common_url($url_params); if (! empty($tab['args'])) { foreach ($tab['args'] as $param => $value) { $tab['link'] .= PMA_get_arg_separator('html') . urlencode($param) . '=' . urlencode($value); } } } if (! empty($tab['fragment'])) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -