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

📄 common.lib.php

📁 架設ROSE私服必備之物 ROSE數據庫
💻 PHP
📖 第 1 页 / 共 5 页
字号:
                // 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) {            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();                // 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);                }            }        }    }    /**     * Get the list and number of available databases.     *     * @param   string   the url to go back to in case of error     *     * @return  boolean  always true     *     * @global  array    the list of available databases     * @global  integer  the number of available databases     * @global  array    current configuration     */    function PMA_availableDatabases($error_url = '')    {        global $dblist;        global $num_dbs;        global $cfg;        // 1. A list of allowed databases has already been defined by the        //    authentication process -> gets the available databases list        if (count($dblist)) {            foreach ($dblist as $key => $db) {                if (!@PMA_DBI_select_db($db) || (!empty($GLOBALS['cfg']['Server']['hide_db']) && preg_match('/' . $GLOBALS['cfg']['Server']['hide_db'] . '/', $db))) {                    unset($dblist[$key]);                } // end if            } // end for        } // end if        // 2. Allowed database list is empty -> gets the list of all databases        //    on the server        elseif (empty($cfg['Server']['only_db'])) {            $dblist = PMA_DBI_get_dblist(); // needed? or PMA_mysqlDie('', 'SHOW DATABASES;', false, $error_url);        } // end else        $num_dbs = count($dblist);        // natural order for db list; but do not sort if user asked        // for a specific order with the 'only_db' mechanism        if (!is_array($GLOBALS['cfg']['Server']['only_db'])            && $GLOBALS['cfg']['NaturalOrder']) {            natsort($dblist);        }        return true;    } // end of the 'PMA_availableDatabases()' function    /**     * 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_DBI_fetch_result()     * @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 ----------------------- */    /**     * Adds backquotes on both sides of a database, table or field name.     * and escapes backquotes inside the name with another backquote     *     * <code>     * echo PMA_backquote('owner`s db'); // `owner``s db`     * </code>     *     * @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    /**     * Format a string so it can be a string inside JavaScript code inside an     * eventhandler (onclick, onchange, on..., ).     * This function is used to displays a javascript confirmation box for     * "DROP/DELETE/ALTER" queries.     *     * @uses    PMA_escapeJsString()     * @uses    PMA_backquote()     * @uses    is_string()     * @uses    htmlspecialchars()     * @uses    str_replace()     * @param   string   $a_string          the string to format     * @param   boolean  $add_backquotes    whether to add backquotes to the string or not     *     * @return  string   the formated string     *     * @access  public     */    function PMA_jsFormat($a_string = '', $add_backquotes = true)    {        if (is_string($a_string)) {            $a_string = htmlspecialchars($a_string);            $a_string = PMA_escapeJsString($a_string);            // TODO: what is this good for?            $a_string = str_replace('#', '\\#', $a_string);        }        return (($add_backquotes) ? PMA_backquote($a_string) : $a_string);    } // end of the 'PMA_jsFormat()' function    /**     * escapes a string to be inserted as string a JavaScript block

⌨️ 快捷键说明

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