⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.lib.php

📁 架設ROSE私服必備之物 ROSE數據庫
💻 PHP
📖 第 1 页 / 共 5 页
字号:
     *     * @access  public     */    function PMA_escape_mysql_wildcards($name)    {        $name = str_replace('_', '\\_', $name);        $name = str_replace('%', '\\%', $name);        return $name;    } // end of the 'PMA_escape_mysql_wildcards()' function    /**     * removes slashes before "_" and "%" characters     * Note: This function does not unescape backslashes!     *     * @param   string   $name  the string to escape     * @return  string   the escaped string     * @access  public     */    function PMA_unescape_mysql_wildcards($name)    {        $name = str_replace('\\_', '_', $name);        $name = str_replace('\\%', '%', $name);        return $name;    } // end of the 'PMA_unescape_mysql_wildcards()' function    /**     * removes quotes (',",`) from a quoted string     *     * checks if the sting is quoted and removes this quotes     *     * @param   string  $quoted_string  string to remove quotes from     * @param   string  $quote          type of quote to remove     * @return  string  unqoted string     */    function PMA_unQuote($quoted_string, $quote = null)    {        $quotes = array();        if (null === $quote) {            $quotes[] = '`';            $quotes[] = '"';            $quotes[] = "'";        } else {            $quotes[] = $quote;        }        foreach ($quotes as $quote) {            if (substr($quoted_string, 0, 1) === $quote             && substr($quoted_string, -1, 1) === $quote ) {                 $unquoted_string = substr($quoted_string, 1, -1);                 // replace escaped quotes                 $unquoted_string = str_replace($quote . $quote, $quote, $unquoted_string);                 return $unquoted_string;             }        }        return $quoted_string;    }    /**     * format sql strings     *     * @param   mixed    pre-parsed SQL structure     *     * @return  string   the formatted sql     *     * @global  array    the configuration array     * @global  boolean  whether the current statement is a multiple one or not     *     * @access  public     *     * @author  Robin Johnson <robbat2@users.sourceforge.net>     */    function PMA_formatSql($parsed_sql, $unparsed_sql = '')    {        global $cfg;        // Check that we actually have a valid set of parsed data        // well, not quite        // first check for the SQL parser having hit an error        if (PMA_SQP_isError()) {            return $parsed_sql;        }        // then check for an array        if (!is_array($parsed_sql)) {            // We don't so just return the input directly            // This is intended to be used for when the SQL Parser is turned off            $formatted_sql = '<pre>' . "\n"                            . (($cfg['SQP']['fmtType'] == 'none' && $unparsed_sql != '') ? $unparsed_sql : $parsed_sql) . "\n"                            . '</pre>';            return $formatted_sql;        }        $formatted_sql        = '';        switch ($cfg['SQP']['fmtType']) {            case 'none':                if ($unparsed_sql != '') {                    $formatted_sql = "<pre>\n" . PMA_SQP_formatNone(array('raw' => $unparsed_sql)) . "\n</pre>";                } else {                    $formatted_sql = PMA_SQP_formatNone($parsed_sql);                }                break;            case 'html':                $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'color');                break;            case 'text':                //$formatted_sql = PMA_SQP_formatText($parsed_sql);                $formatted_sql = PMA_SQP_formatHtml($parsed_sql, 'text');                break;            default:                break;        } // end switch        return $formatted_sql;    } // end of the "PMA_formatSql()" function    /**     * Displays a link to the official MySQL documentation     *     * @param string  chapter of "HTML, one page per chapter" documentation     * @param string  contains name of page/anchor that is being linked     * @param bool    whether to use big icon (like in left frame)     *     * @return  string  the html link     *     * @access  public     */    function PMA_showMySQLDocu($chapter, $link, $big_icon = false)    {        global $cfg;        if ($cfg['MySQLManualType'] == 'none' || empty($cfg['MySQLManualBase'])) {            return '';        }        // Fixup for newly used names:        $chapter = str_replace('_', '-', strtolower($chapter));        $link = str_replace('_', '-', strtolower($link));        switch ($cfg['MySQLManualType']) {            case 'chapters':                if (empty($chapter)) {                    $chapter = 'index';                }                $url = $cfg['MySQLManualBase'] . '/' . $chapter . '.html#' . $link;                break;            case 'big':                $url = $cfg['MySQLManualBase'] . '#' . $link;                break;            case 'searchable':                if (empty($link)) {                    $link = 'index';                }                $url = $cfg['MySQLManualBase'] . '/' . $link . '.html';                break;            case 'viewable':            default:                if (empty($link)) {                    $link = 'index';                }                $mysql = '5.0';                $lang = 'en';                if (defined('PMA_MYSQL_INT_VERSION')) {                    if (PMA_MYSQL_INT_VERSION < 50000) {                        $mysql = '4.1';                        if (!empty($GLOBALS['mysql_4_1_doc_lang'])) {                            $lang = $GLOBALS['mysql_4_1_doc_lang'];                        }                    } elseif (PMA_MYSQL_INT_VERSION >= 50100) {                        $mysql = '5.1';                        if (!empty($GLOBALS['mysql_5_1_doc_lang'])) {                            $lang = $GLOBALS['mysql_5_1_doc_lang'];                        }                    } elseif (PMA_MYSQL_INT_VERSION >= 50000) {                        $mysql = '5.0';                        if (!empty($GLOBALS['mysql_5_0_doc_lang'])) {                            $lang = $GLOBALS['mysql_5_0_doc_lang'];                        }                    }                }                $url = $cfg['MySQLManualBase'] . '/' . $mysql . '/' . $lang . '/' . $link . '.html';                break;        }        if ($big_icon) {            return '<a href="' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_sqlhelp.png" width="16" height="16" alt="' . $GLOBALS['strDocu'] . '" title="' . $GLOBALS['strDocu'] . '" /></a>';        } elseif ($GLOBALS['cfg']['ReplaceHelpImg']) {            return '<a href="' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png" width="11" height="11" alt="' . $GLOBALS['strDocu'] . '" title="' . $GLOBALS['strDocu'] . '" /></a>';        } else {            return '[<a href="' . $url . '" target="mysql_doc">' . $GLOBALS['strDocu'] . '</a>]';        }    } // end of the 'PMA_showMySQLDocu()' function    /**     * Displays a hint icon, on mouse over show the hint     *     * @param   string   the error message     *     * @access  public     */     function PMA_showHint($hint_message)     {         //return '<img class="lightbulb" src="' . $GLOBALS['pmaThemeImage'] . 'b_tipp.png" width="16" height="16" border="0" alt="' . $hint_message . '" title="' . $hint_message . '" align="middle" onclick="alert(\'' . PMA_jsFormat($hint_message, false) . '\');" />';         return '<img class="lightbulb" src="' . $GLOBALS['pmaThemeImage'] . 'b_tipp.png" width="16" height="16" alt="Tip" title="Tip" onmouseover="pmaTooltip(\'' .  PMA_jsFormat($hint_message, false) . '\'); return false;" onmouseout="swapTooltip(\'default\'); return false;" />';     }    /**     * Displays a MySQL error message in the right frame.     *     * @param   string   the error message     * @param   string   the sql query that failed     * @param   boolean  whether to show a "modify" link or not     * @param   string   the "back" link url (full path is not required)     * @param   boolean  EXIT the page?     *     * @global  array    the configuration array     *     * @access  public     */    function PMA_mysqlDie($error_message = '', $the_query = '',                            $is_modify_link = true, $back_url = '',                            $exit = true)    {        global $cfg, $table, $db, $sql_query;        require_once './libraries/header.inc.php';        if (!$error_message) {            $error_message = PMA_DBI_getError();        }        if (!$the_query && !empty($GLOBALS['sql_query'])) {            $the_query = $GLOBALS['sql_query'];        }        // --- Added to solve bug #641765        // Robbat2 - 12 January 2003, 9:46PM        // Revised, Robbat2 - 13 January 2003, 2:59PM        if (!function_exists('PMA_SQP_isError') || PMA_SQP_isError()) {            $formatted_sql = htmlspecialchars($the_query);        } elseif (empty($the_query) || trim($the_query) == '') {            $formatted_sql = '';        } else {            $formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);        }        // ---        echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";        echo '    <div class="error"><h1>' . $GLOBALS['strError'] . '</h1>' . "\n";        // if the config password is wrong, or the MySQL server does not        // respond, do not show the query that would reveal the        // username/password        if (!empty($the_query) && !strstr($the_query, 'connect')) {            // --- Added to solve bug #641765            // Robbat2 - 12 January 2003, 9:46PM            // Revised, Robbat2 - 13 January 2003, 2:59PM            if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {                echo PMA_SQP_getErrorString() . "\n";                echo '<br />' . "\n";            }            // ---            // modified to show me the help on sql errors (Michael Keck)            echo '    <p><strong>' . $GLOBALS['strSQLQuery'] . ':</strong>' . "\n";            if (strstr(strtolower($formatted_sql), 'select')) { // please show me help to the error on select                echo PMA_showMySQLDocu('SQL-Syntax', 'SELECT');            }            if ($is_modify_link && isset($db)) {                if (isset($table)) {                    $doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';                } else {                    $doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';                }                if ($GLOBALS['cfg']['PropertiesIconic']) {                    echo $doedit_goto                       . '<img class="icon" src=" '. $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" alt="' . $GLOBALS['strEdit'] .'" />'                       . '</a>';                } else {                    echo '    ['                       . $doedit_goto . $GLOBALS['strEdit'] . '</a>'                       . ']' . "\n";                }            } // end if            echo '    </p>' . "\n"                .'    <p>' . "\n"                .'        ' . $formatted_sql . "\n"                .'    </p>' . "\n";        } // end if        $tmp_mysql_error = ''; // for saving the original $error_message        if (!empty($error_message)) {            $tmp_mysql_error = strtolower($error_message); // save the original $error_message            $error_message = htmlspecialchars($error_message);            $error_message = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $error_message);        }        // modified to show me the help on error-returns (Michael Keck)        // (now error-messages-server)        echo '<p>' . "\n"                . '    <strong>' . $GLOBALS['strMySQLSaid'] . '</strong>'                . PMA_showMySQLDocu('Error-messages-server', 'Error-messages-server')                . "\n"                . '</p>' . "\n";        // The error message will be displayed within a CODE segment.        // To preserve original formatting, but allow wordwrapping, we do a couple of replacements        // Replace all non-single blanks with their HTML-counterpart        $error_message = str_replace('  ', '&nbsp;&nbsp;', $error_message);        // Replace TAB-characters with their HTML-counterpart        $error_message = str_replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;', $error_message);        // Replace linebreaks        $error_message = nl2br($error_message);        echo '<code>' . "\n"            . $error_message . "\n"            . '</code><br />' . "\n";        // feature request #1036254:        // Add a link by MySQL-Error #1062 - Duplicate entry        // 2004-10-20 by mkkeck        // 2005-01-17 modified by mkkeck bugfix        if (substr($error_message, 1, 4) == '1062') {            // get the duplicate entry            // get table name            // TODO: what would be the best delimiter, while avoiding            // special characters that can become high-ascii after editing,            // depending upon which editor is used by the developer?            $error_table = array();            if (preg_match('@ALTER\s*TABLE\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {                $error_table = $error_table[1];            } elseif (preg_match('@INSERT\s*INTO\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {                $error_table = $error_table[1];            } elseif (preg_match('@UPDATE\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {                $error_table = $error_table[1];            } elseif (preg_match('@INSERT\s*\`([^\`]+)\`@iu', $the_query, $error_table)) {                $error_table = $error_table[1];            }            // get fields            $error_fields = array();            if (preg_match('@\(([^\)]+)\)@i', $the_query, $error_fields)) {                $error_fields = explode(',', $error_fields[1]);            } elseif (preg_match('@(`[^`]+`)\s*=@i', $the_query, $error_fields)) {                $error_fields = explode(',', $error_fields[1]);            }            if (is_array($error_table) || is_array($error_fields)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -