📄 common.lib.php
字号:
if ($table_name == $table_key) continue 2; // check for correct row count if (null === $table['Rows']) { // Do not check exact row count here, // if row count is invalid possibly the table is defect // and this would break left frame; // but we can check row count if this is a view, // since PMA_Table::countRecords() returns a limited row count // in this case. // set this because PMA_Table::countRecords() can use it $tbl_is_view = PMA_Table::isView($db, $table['Name']); if ($tbl_is_view) { $table['Rows'] = PMA_Table::countRecords($db, $table['Name'], $return = true); } } // in $group we save the reference to the place in $table_groups // where to store the table info if ($GLOBALS['cfg']['LeftFrameDBTree'] && $sep && strstr($table_name, $sep)) { $parts = explode($sep, $table_name); $group =& $table_groups; $i = 0; $group_name_full = ''; while ($i < count($parts) - 1 && $i < $GLOBALS['cfg']['LeftFrameTableLevel']) { $group_name = $parts[$i] . $sep; $group_name_full .= $group_name; if (!isset($group[$group_name])) { $group[$group_name] = array(); $group[$group_name]['is' . $sep . 'group'] = true; $group[$group_name]['tab' . $sep . 'count'] = 1; $group[$group_name]['tab' . $sep . 'group'] = $group_name_full; } elseif (!isset($group[$group_name]['is' . $sep . 'group'])) { $table = $group[$group_name]; $group[$group_name] = array(); $group[$group_name][$group_name] = $table; unset($table); $group[$group_name]['is' . $sep . 'group'] = true; $group[$group_name]['tab' . $sep . 'count'] = 1; $group[$group_name]['tab' . $sep . 'group'] = $group_name_full; } else { $group[$group_name]['tab' . $sep . 'count']++; } $group =& $group[$group_name]; $i++; } } else { if (!isset($table_groups[$table_name])) { $table_groups[$table_name] = array(); } $group =& $table_groups; } if ($GLOBALS['cfg']['ShowTooltipAliasTB'] && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested') { // switch tooltip and name $table['Comment'] = $table['Name']; $table['disp_name'] = $table['Comment']; } else { $table['disp_name'] = $table['Name']; } $group[$table_name] = array_merge($default, $table); } return $table_groups;}/* ----------------------- Set of misc functions ----------------------- *//** * Adds backquotes on both sides of a database, table or field name. * and escapes backquotes inside the name with another backquote * * example: * <code> * echo PMA_backquote('owner`s db'); // `owner``s db` * * </code> * * @uses PMA_backquote() * @uses is_array() * @uses strlen() * @uses str_replace() * @param mixed $a_name the database, table or field name to "backquote" * or array of it * @param boolean $do_it a flag to bypass this function (used by dump * functions) * @return mixed the "backquoted" database, table or field name if the * current MySQL release is >= 3.23.6, the original one * else * @access public */function PMA_backquote($a_name, $do_it = true){ if (! $do_it) { return $a_name; } if (is_array($a_name)) { $result = array(); foreach ($a_name as $key => $val) { $result[$key] = PMA_backquote($val); } return $result; } // '0' is also empty for php :-( if (strlen($a_name) && $a_name !== '*') { return '`' . str_replace('`', '``', $a_name) . '`'; } else { return $a_name; }} // end of the 'PMA_backquote()' function/** * Defines the <CR><LF> value depending on the user OS. * * @uses PMA_USR_OS * @return string the <CR><LF> value to use * * @access public */function PMA_whichCrlf(){ $the_crlf = "\n"; // The 'PMA_USR_OS' constant is defined in "./libraries/Config.class.php" // Win case if (PMA_USR_OS == 'Win') { $the_crlf = "\r\n"; } // Others else { $the_crlf = "\n"; } return $the_crlf;} // end of the 'PMA_whichCrlf()' function/** * Reloads navigation if needed. * * @uses $GLOBALS['reload'] * @uses $GLOBALS['db'] * @uses PMA_generate_common_url() * @global array configuration * * @access public */function PMA_reloadNavigation(){ global $cfg; // Reloads the navigation frame via JavaScript if required if (isset($GLOBALS['reload']) && $GLOBALS['reload']) { // one of the reasons for a reload is when a table is dropped // in this case, get rid of the table limit offset, otherwise // we have a problem when dropping a table on the last page // and the offset becomes greater than the total number of tables unset($_SESSION['userconf']['table_limit_offset']); echo "\n"; $reload_url = './navigation.php?' . PMA_generate_common_url($GLOBALS['db'], '', '&'); ?><script type="text/javascript">//<![CDATA[if (typeof(window.parent) != 'undefined' && typeof(window.parent.frame_navigation) != 'undefined' && window.parent.goTo) { window.parent.goTo('<?php echo $reload_url; ?>');}//]]></script> <?php unset($GLOBALS['reload']); }}/** * displays the message and the query * usually the message is the result of the query executed * * @param string $message the message to display * @param string $sql_query the query to display * @param string $type the type (level) of the message * @global array the configuration array * @uses $cfg * @access public */function PMA_showMessage($message, $sql_query = null, $type = 'notice'){ global $cfg; if (null === $sql_query) { if (! empty($GLOBALS['display_query'])) { $sql_query = $GLOBALS['display_query']; } elseif ($cfg['SQP']['fmtType'] == 'none' && ! empty($GLOBALS['unparsed_sql'])) { $sql_query = $GLOBALS['unparsed_sql']; } elseif (! empty($GLOBALS['sql_query'])) { $sql_query = $GLOBALS['sql_query']; } else { $sql_query = ''; } } // Corrects the tooltip text via JS if required // @todo this is REALLY the wrong place to do this - very unexpected here if (strlen($GLOBALS['table']) && $cfg['ShowTooltip']) { $tooltip = PMA_Table::sGetToolTip($GLOBALS['db'], $GLOBALS['table']); $uni_tbl = PMA_jsFormat($GLOBALS['db'] . '.' . $GLOBALS['table'], false); echo "\n"; echo '<script type="text/javascript">' . "\n"; echo '//<![CDATA[' . "\n"; echo "if (window.parent.updateTableTitle) window.parent.updateTableTitle('" . $uni_tbl . "', '" . PMA_jsFormat($tooltip, false) . "');" . "\n"; echo '//]]>' . "\n"; echo '</script>' . "\n"; } // end if ... elseif // Checks if the table needs to be repaired after a TRUNCATE query. // @todo what about $GLOBALS['display_query']??? // @todo this is REALLY the wrong place to do this - very unexpected here if (strlen($GLOBALS['table']) && $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) { if (PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], 'Index_length') > 1024) { PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table'])); } } unset($tbl_status); echo '<div align="' . $GLOBALS['cell_align_left'] . '">' . "\n"; if ($message instanceof PMA_Message) { $message->display(); $type = $message->getLevel(); } else { echo '<div class="' . $type . '">'; echo PMA_sanitize($message); if (isset($GLOBALS['special_message'])) { echo PMA_sanitize($GLOBALS['special_message']); unset($GLOBALS['special_message']); } echo '</div>'; } if ($cfg['ShowSQL'] == true && ! empty($sql_query)) { // Html format the query to be displayed // If we want to show some sql code it is easiest to create it here /* SQL-Parser-Analyzer */ if (! empty($GLOBALS['show_as_php'])) { $new_line = '\\n"<br />' . "\n" . ' . "'; $query_base = htmlspecialchars(addslashes($sql_query)); $query_base = preg_replace('/((\015\012)|(\015)|(\012))/', $new_line, $query_base); } else { $query_base = $sql_query; } $query_too_big = false; if (strlen($query_base) > $cfg['MaxCharactersInDisplayedSQL']) { // when the query is large (for example an INSERT of binary // data), the parser chokes; so avoid parsing the query $query_too_big = true; $shortened_query_base = nl2br(htmlspecialchars(substr($sql_query, 0, $cfg['MaxCharactersInDisplayedSQL']) . '[...]')); } elseif (! empty($GLOBALS['parsed_sql']) && $query_base == $GLOBALS['parsed_sql']['raw']) { // (here, use "! empty" because when deleting a bookmark, // $GLOBALS['parsed_sql'] is set but empty $parsed_sql = $GLOBALS['parsed_sql']; } else { // Parse SQL if needed $parsed_sql = PMA_SQP_parse($query_base); } // Analyze it if (isset($parsed_sql)) { $analyzed_display_query = PMA_SQP_analyze($parsed_sql); // Here we append the LIMIT added for navigation, to // enable its display. Adding it higher in the code // to $sql_query would create a problem when // using the Refresh or Edit links. // Only append it on SELECTs. /** * @todo what would be the best to do when someone hits Refresh: * use the current LIMITs ? */ if (isset($analyzed_display_query[0]['queryflags']['select_from']) && isset($GLOBALS['sql_limit_to_append'])) { $query_base = $analyzed_display_query[0]['section_before_limit'] . "\n" . $GLOBALS['sql_limit_to_append'] . $analyzed_display_query[0]['section_after_limit']; // Need to reparse query $parsed_sql = PMA_SQP_parse($query_base); } } if (! empty($GLOBALS['show_as_php'])) { $query_base = '$sql = "' . $query_base; } elseif (! empty($GLOBALS['validatequery'])) { $query_base = PMA_validateSQL($query_base); } elseif (isset($parsed_sql)) { $query_base = PMA_formatSql($parsed_sql, $query_base); } // Prepares links that may be displayed to edit/explain the query // (don't go to default pages, we must go to the page // where the query box is available) // Basic url query part $url_params = array(); if (strlen($GLOBALS['db'])) { $url_params['db'] = $GLOBALS['db']; if (strlen($GLOBALS['table'])) { $url_params['table'] = $GLOBALS['table']; $edit_link = 'tbl_sql.php'; } else { $edit_link = 'db_sql.php'; } } else { $edit_link = 'server_sql.php'; } // Want to have the query explained (Mike Beck 2002-05-22) // but only explain a SELECT (that has not been explained) /* SQL-Parser-Analyzer */ $explain_link = ''; if (! empty($cfg['SQLQuery']['Explain']) && ! $query_too_big) { $explain_params = $url_params; // Detect if we are validating as well // To preserve the validate uRL data if (! empty($GLOBALS['validatequery'])) { $explain_params['validatequery'] = 1; } if (preg_match('@^SELECT[[:space:]]+@i', $sql_query)) { $explain_params['sql_query'] = 'EXPLAIN ' . $sql_query; $_message = $GLOBALS['strExplain']; } elseif (preg_match('@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query)) { $explain_params['sql_query'] = substr($sql_query, 8); $_message = $GLOBALS['strNoExplain']; } if (isset($explain_params['sql_query'])) { $explain_link = 'import.php' . PMA_generate_common_url($explain_params); $explain_link = ' [' . PMA_linkOrButton($explain_link, $_message) . ']'; } } //show explain $url_params['sql_query'] = $sql_query; $url_params['show_query'] = 1; if (! empty($cfg['SQLQuery']['Edit']) && ! $query_too_big) { if ($cfg['EditInWindow'] == true) { $onclick = 'window.parent.focus_querywindow(\'' . PMA_jsFormat($sql_query, false) . '\'); return false;'; } else { $onclick = ''; } $edit_link .= PMA_generate_common_url($url_params) . '#querybox'; $edit_link = ' [' . PMA_linkOrButton($edit_link, $GLOBALS['strEdit'], array('onclick' => $onclick)) . ']'; } else { $edit_link = ''; } $url_qpart = PMA_generate_common_url($url_params); // Also we would like to get the SQL formed in some nice // php-code (Mike Beck 2002-05-22) if (! empty($cfg['SQLQuery']['ShowAsPHP']) && ! $query_too_big) { $php_params = $url_params; if (! empty($GLOBALS['show_as_php'])) { $_message = $GLOBALS['strNoPhp']; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -