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

📄 common.lib.php

📁 一个用PHP编写的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
            $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_sql.php?' . PMA_generate_common_url($db, $table) . '&amp;sql_query=' . urlencode($the_query) . '&amp;show_query=1">';                } else {                    $doedit_goto = '<a href="db_sql.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)) {                // duplicate value                $duplicate_value = array();                preg_match('@\'([^\']+)\'@i', $tmp_mysql_error, $duplicate_value);                $duplicate_value = $duplicate_value[1];                $sql = '                     SELECT *                       FROM ' . PMA_backquote($error_table) . '                      WHERE CONCAT_WS("-", ' . implode(', ', $error_fields) . ')                            = "' . PMA_sqlAddslashes($duplicate_value) . '"                   ORDER BY ' . implode(', ', $error_fields);                unset($error_table, $error_fields, $duplicate_value);                echo '        <form method="post" action="import.php" style="padding: 0; margin: 0">' ."\n"                    .'            <input type="hidden" name="sql_query" value="' . htmlentities($sql) . '" />' . "\n"                    .'            ' . PMA_generate_common_hidden_inputs($db, $table) . "\n"                    .'            <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n"                    .'        </form>' . "\n";                unset($sql);            }        } // end of show duplicate entry        echo '</div>';        echo '<fieldset class="tblFooters">';        if (!empty($back_url) && $exit) {            $goto_back_url='<a href="' . (strstr($back_url, '?') ? $back_url . '&amp;no_history=true' : $back_url . '?no_history=true') . '">';            echo '[ ' . $goto_back_url . $GLOBALS['strBack'] . '</a> ]';        }        echo '    </fieldset>' . "\n\n";        if ($exit) {            /**             * display footer and exit             */            require_once './libraries/footer.inc.php';        }    } // end of the 'PMA_mysqlDie()' function    /**     * Returns a string formatted with CONVERT ... USING     * if MySQL supports it     *     * @param   string  the string itself     * @param   string  the mode: quoted or unquoted (this one by default)     *     * @return  the formatted string     *     * @access  private     */    function PMA_convert_using($string, $mode='unquoted')    {        if ($mode == 'quoted') {            $possible_quote = "'";        } else {            $possible_quote = "";        }        if (PMA_MYSQL_INT_VERSION >= 40100) {            list($conn_charset) = explode('_', $GLOBALS['collation_connection']);            $converted_string = "CONVERT(" . $possible_quote . $string . $possible_quote . " USING " . $conn_charset . ")";        } else {            $converted_string = $possible_quote . $string . $possible_quote;        }        return $converted_string;    } // end function    /**     * Send HTTP header, taking IIS limits into account (600 seems ok)     *     * @param   string   $uri the header to send     * @return  boolean  always true     */    function PMA_sendHeaderLocation($uri)    {        if (PMA_IS_IIS && strlen($uri) > 600) {            echo '<html><head><title>- - -</title>' . "\n";            echo '<meta http-equiv="expires" content="0">' . "\n";            echo '<meta http-equiv="Pragma" content="no-cache">' . "\n";            echo '<meta http-equiv="Cache-Control" content="no-cache">' . "\n";            echo '<meta http-equiv="Refresh" content="0;url=' .$uri . '">' . "\n";            echo '<script type="text/javascript" language="javascript">' . "\n";            echo '//<![CDATA[' . "\n";            echo 'setTimeout ("window.location = unescape(\'"' . $uri . '"\')",2000); </script>' . "\n";            echo '//]]>' . "\n";            echo '</head>' . "\n";            echo '<body>' . "\n";            echo '<script type="text/javascript" language="javascript">' . "\n";            echo '//<![CDATA[' . "\n";            echo 'document.write (\'<p><a href="' . $uri . '">' . $GLOBALS['strGo'] . '</a></p>\');' . "\n";            echo '//]]>' . "\n";            echo '</script></body></html>' . "\n";        } else {            if (SID) {                if (strpos($uri, '?') === false) {                    header('Location: ' . $uri . '?' . SID);                } else {                    $separator = PMA_get_arg_separator();                    header('Location: ' . $uri . $separator . SID);                }            } else {                session_write_close();                if (headers_sent()) {                    if (function_exists('debug_print_backtrace')) {                        echo '<pre>';                        debug_print_backtrace();                        echo '</pre>';                    }                    trigger_error('PMA_sendHeaderLocation called when headers are already sent!', E_USER_ERROR);                }                // bug #1523784: IE6 does not like 'Refresh: 0', it                // results in a blank page                // but we need it when coming from the cookie login panel)                if (PMA_IS_IIS && defined('PMA_COMING_FROM_COOKIE_LOGIN')) {                    header('Refresh: 0; ' . $uri);                } else {                    header('Location: ' . $uri);                }            }        }    }    /**     * returns array with tables of given db with extended infomation and grouped     *     * @uses    $GLOBALS['cfg']['LeftFrameTableSeparator']     * @uses    $GLOBALS['cfg']['LeftFrameTableLevel']     * @uses    $GLOBALS['cfg']['ShowTooltipAliasTB']     * @uses    $GLOBALS['cfg']['NaturalOrder']     * @uses    PMA_backquote()     * @uses    count()     * @uses    array_merge     * @uses    uksort()     * @uses    strstr()     * @uses    explode()     * @param   string  $db     name of db     * return   array   (rekursive) grouped table list     */    function PMA_getTableList($db, $tables = null)    {        $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];        if ( null === $tables ) {            $tables = PMA_DBI_get_tables_full($db);            if ($GLOBALS['cfg']['NaturalOrder']) {                uksort($tables, 'strnatcasecmp');            }        }        if (count($tables) < 1) {            return $tables;        }        $default = array(            'Name'      => '',            'Rows'      => 0,            'Comment'   => '',            'disp_name' => '',        );        $table_groups = array();        foreach ($tables as $table_name => $table) {            // 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 ----------------------- */

⌨️ 快捷键说明

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