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

📄 common.lib.php

📁 WEBGAME源码,有架设说明,只是非常简单
💻 PHP
📖 第 1 页 / 共 5 页
字号:
        // Look at: "static int check_dir_access(request_rec *r)"        // Robbat2 - May 10, 2002        if (isset($cfg['Server']['AllowDeny']) && isset($cfg['Server']['AllowDeny']['order'])) {            require_once('./libraries/ip_allow_deny.lib.php');            $allowDeny_forbidden         = FALSE; // default            if ($cfg['Server']['AllowDeny']['order'] == 'allow,deny') {                $allowDeny_forbidden     = TRUE;                if (PMA_allowDeny('allow')) {                    $allowDeny_forbidden = FALSE;                }                if (PMA_allowDeny('deny')) {                    $allowDeny_forbidden = TRUE;                }            } else if ($cfg['Server']['AllowDeny']['order'] == 'deny,allow') {                if (PMA_allowDeny('deny')) {                    $allowDeny_forbidden = TRUE;                }                if (PMA_allowDeny('allow')) {                    $allowDeny_forbidden = FALSE;                }            } else if ($cfg['Server']['AllowDeny']['order'] == 'explicit') {                if (PMA_allowDeny('allow')                    && !PMA_allowDeny('deny')) {                    $allowDeny_forbidden = FALSE;                } else {                    $allowDeny_forbidden = TRUE;                }            } // end if... else if... else if            // Ejects the user if banished            if ($allowDeny_forbidden) {               PMA_auth_fails();            }            unset($allowDeny_forbidden); //Clean up after you!        } // end if        // is root allowed?        if (!$cfg['Server']['AllowRoot'] && $cfg['Server']['user'] == 'root') {            $allowDeny_forbidden = TRUE;            PMA_auth_fails();            unset($allowDeny_forbidden); //Clean up after you!        }        // The user can work with only some databases        if (isset($cfg['Server']['only_db']) && $cfg['Server']['only_db'] != '') {            if (is_array($cfg['Server']['only_db'])) {                $dblist   = $cfg['Server']['only_db'];            } else {                $dblist[] = $cfg['Server']['only_db'];            }        } // end if        $bkp_track_err = @ini_set('track_errors', 1);        // Try to connect MySQL with the control user profile (will be used to        // get the privileges list for the current user but the true user link        // must be open after this one so it would be default one for all the        // scripts)        if ($cfg['Server']['controluser'] != '') {            $dbh = PMA_DBI_connect($cfg['Server']['controluser'], $cfg['Server']['controlpass'], TRUE);        } else {            $dbh = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password'], TRUE);        } // end if ... else        // Pass #1 of DB-Config to read in master level DB-Config will go here        // Robbat2 - May 11, 2002        // Connects to the server (validates user's login)        $userlink = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password'], FALSE);        // Pass #2 of DB-Config to read in user level DB-Config will go here        // Robbat2 - May 11, 2002        @ini_set('track_errors', $bkp_track_err);        unset($bkp_track_err);        /**         * SQL Parser code         */        require_once('./libraries/sqlparser.lib.php');        /**         * SQL Validator interface code         */        require_once('./libraries/sqlvalidator.lib.php');        // if 'only_db' is set for the current user, there is no need to check for        // available databases in the "mysql" db        $dblist_cnt = count($dblist);        if ($dblist_cnt) {            $true_dblist  = array();            $is_show_dbs  = TRUE;            $dblist_asterisk_bool = FALSE;            for ($i = 0; $i < $dblist_cnt; $i++) {                // The current position                if ($dblist[$i] == '*' && $dblist_asterisk_bool == FALSE) {                    $dblist_asterisk_bool = TRUE;                    $dblist_full = PMA_safe_db_list(FALSE, $dbh, FALSE, $rs, $userlink, $cfg, $dblist);                    foreach ($dblist_full as $dbl_val) {                        if (!in_array($dbl_val, $dblist)) {                            $true_dblist[] = $dbl_val;                        }                    }                    continue;                } elseif ($dblist[$i] == '*') {                    // We don't want more than one asterisk inside our 'only_db'.                    continue;                }                if ($is_show_dbs && ereg('(^|[^\])(_|%)', $dblist[$i])) {                    $local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\'';                    // here, a PMA_DBI_query() could fail silently                    // if SHOW DATABASES is disabled                    $rs          = PMA_DBI_try_query($local_query, $dbh);                    if ($i == 0                        && (substr(PMA_DBI_getError($dbh), 1, 4) == 1045)) {                        // "SHOW DATABASES" statement is disabled                        $true_dblist[] = str_replace('\\_', '_', str_replace('\\%', '%', $dblist[$i]));                        $is_show_dbs   = FALSE;                    }                    // Debug                    // else if (PMA_DBI_getError($dbh)) {                    //    PMA_mysqlDie(PMA_DBI_getError($dbh), $local_query, FALSE);                    // }                    while ($row = @PMA_DBI_fetch_row($rs)) {                        $true_dblist[] = $row[0];                    } // end while                    if ($rs) {                        PMA_DBI_free_result($rs);                    }                } else {                    $true_dblist[]     = str_replace('\\_', '_', str_replace('\\%', '%', $dblist[$i]));                } // end if... else...            } // end for            $dblist       = $true_dblist;            unset( $true_dblist, $i, $dbl_val );            $only_db_check = TRUE;        } // end if        // 'only_db' is empty for the current user...        else {            $only_db_check = FALSE;        } // end if (!$dblist_cnt)        if (isset($dblist_full) && !count($dblist_full)) {            $dblist = PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cfg, $dblist);        }    } // end server connecting    /**     * Missing server hostname     */    else {        echo $strHostEmpty;    }    /**     * Send HTTP header, taking IIS limits into account     *                   ( 600 seems ok)     *     * @param   string   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 language="JavaScript">' . "\n";             echo 'setTimeout ("window.location = unescape(\'"' . $uri . '"\')",2000); </script>' . "\n";             echo '</head>' . "\n";             echo '<body> <script language="JavaScript">' . "\n";             echo 'document.write (\'<p><a href="' . $uri . '">' . $GLOBALS['strGo'] . '</a></p>\');' . "\n";             echo '</script></body></html>' . "\n";         } else {             header( 'Location: ' . $uri . '&' . SID );         }     }    /**     * 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        //    authentification process -> gets the available databases list        if ( count( $dblist ) ) {            foreach ( $dblist as $key => $db ) {                if ( ! @PMA_DBI_select_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 ) {        $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];        $tables = PMA_DBI_get_tables_full($db);        if ( count( $tables ) < 1 ) {            return $tables;        }        if ( $GLOBALS['cfg']['NaturalOrder'] ) {            uksort( $tables, 'strcmp' );        }        $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'] ) {                $table['Rows'] = PMA_countRecords( $db, $table['Name'],                    $return = true, $force_exact = 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_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.     * Since MySQL 3.23.6 this allows to use non-alphanumeric characters in     * these names.     *     * @param   mixed    the database, table or field name to "backquote" or     *                   array of it     * @param   boolean  a flag to bypass this fu

⌨️ 快捷键说明

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