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

📄 common.lib.php

📁 WEBGAME源码,有架设说明,只是非常简单
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php/* $Id: common.lib.php,v 2.211 2005/11/20 11:52:17 cybot_tm Exp $ */// vim: expandtab sw=4 ts=4 sts=4:/** * Misc stuff and functions used by almost all the scripts. * Among other things, it contains the advanced authentification work. *//** * Order of sections for common.lib.php: * * some functions need the constants of libraries/defines.lib.php * and defines_mysql.lib.php * * the PMA_setFontSizes() function must be before the call to the * libraries/auth/cookie.auth.lib.php library * * the include of libraries/defines_mysql.lib.php must be after the connection * to db to get the MySql version * * the PMA_sqlAddslashes() function must be before the connection to db * * the authentication libraries must be before the connection to db but * after the PMA_isInto() function * * the PMA_mysqlDie() function must be before the connection to db but * after mysql extension has been loaded * * the PMA_mysqlDie() function needs the PMA_format_sql() Function * * ... so the required order is: * * - parsing of the configuration file * - load of the libraries/defines.lib.php library * - load of mysql extension (if necessary) * - definition of PMA_sqlAddslashes() * - definition of PMA_format_sql() * - definition of PMA_mysqlDie() * - definition of PMA_isInto() * - definition of PMA_setFontSizes() * - loading of an authentication library * - db connection * - authentication work * - load of the libraries/defines_mysql.lib.php library to get the MySQL *   release number * - other functions, respecting dependencies */// grab_globals.lib.php should really go before common.lib.phprequire_once('./libraries/grab_globals.lib.php');/** * @var array   $GLOBALS['PMA_errors']  holds errors */$GLOBALS['PMA_errors'] = array();/** * Avoids undefined variables */if (!isset($use_backquotes)) {    $use_backquotes   = 0;}if (!isset($pos)) {    $pos              = 0;}/** * 2004-06-30 rabus: Ensure, that $cfg variables are not set somwhere else * before including the config file. */unset($cfg);/** * Added messages while developing: */if (file_exists('./lang/added_messages.php')) {    include('./lang/added_messages.php');}/** * Set default configuration values. */include './config.default.php';// Remember default server config$default_server = $cfg['Servers'][1];// Drop all server, as they have to be configured by userunset($cfg['Servers']);/** * Parses the configuration file and gets some constants used to define * versions of phpMyAdmin/php/mysql... */$old_error_reporting = error_reporting(0);// We can not use include as it fails on parse errorif (file_exists('./config.inc.php')) {    $config_fd = fopen('./config.inc.php', 'r');    $result = eval('?>' . fread($config_fd, filesize('./config.inc.php')));    fclose( $config_fd );    unset( $config_fd );    // Eval failed    if ($result === FALSE || !isset($cfg['Servers'])) {        // Creates fake settings        $cfg = array('DefaultLang'           => 'en-iso-8859-1',                        'AllowAnywhereRecoding' => FALSE);        // Loads the language file        require_once('./libraries/select_lang.lib.php');        // Displays the error message        // (do not use &amp; for parameters sent by header)        header( 'Location: error.php'                . '?lang='  . urlencode( $available_languages[$lang][2] )                . '&char='  . urlencode( $charset )                . '&dir='   . urlencode( $text_dir )                . '&type='  . urlencode( $strError )                . '&error=' . urlencode(                    strtr( $strConfigFileError, array( '<br />' => '[br]' ) )                    . '[br][br]' . '[a@./config.inc.php@_blank]config.inc.php[/a]' )                . '&' . SID                 );        exit();    }    error_reporting($old_error_reporting);    unset( $old_error_reporting, $result );}/** * Includes the language file if it hasn't been included yet */require_once('./libraries/select_lang.lib.php');/** * Servers array fixups. */// Do we have some server?if (!isset($cfg['Servers']) || count($cfg['Servers']) == 0) {    // No server => create one with defaults    $cfg['Servers'] = array(1 => $default_server);} else {    // We have server(s) => apply default config    $new_servers = array();    foreach($cfg['Servers'] as $key => $val) {        if (!is_int($key) || $key < 1) {            // Show error            header( 'Location: error.php'                    . '?lang='  . urlencode( $available_languages[$lang][2] )                    . '&char='  . urlencode( $charset )                    . '&dir='   . urlencode( $text_dir )                    . '&type='  . urlencode( $strError )                    . '&error=' . urlencode(// FIXME: We could translate this message, however it's translations freeze right now:                        sprintf( 'Invalid server index: "%s"', $key))                    . '&' . SID                     );        }        $new_servers[$key] = array_merge($default_server, $val);    }    $cfg['Servers'] = $new_servers;    unset( $new_servers, $key, $val );}// Cleanupunset($default_server);/** * We really need this one! */if (!function_exists('preg_replace')) {    header( 'Location: error.php'        . '?lang='  . urlencode( $available_languages[$lang][2] )        . '&char='  . urlencode( $charset )        . '&dir='   . urlencode( $text_dir )        . '&type='  . urlencode( $strError )        . '&error=' . urlencode(            strtr( sprintf( $strCantLoad, 'pcre' ),                array('<br />' => '[br]') ) )        . '&' . SID         );    exit();}/** * Gets constants that defines the PHP version number. * This include must be located physically before any code that needs to * reference the constants, else PHP 3.0.16 won't be happy. */require_once('./libraries/defines.lib.php');/* Input sanitizing */require_once('./libraries/sanitizing.lib.php');// XSSif (isset($convcharset)) {    $convcharset = PMA_sanitize($convcharset);}if ( ! defined( 'PMA_MINIMUM_COMMON' ) ) {    /**     * Define $is_upload     */      $is_upload = TRUE;      if (strtolower(@ini_get('file_uploads')) == 'off'             || @ini_get('file_uploads') == 0) {          $is_upload = FALSE;      }    /**     * Maximum upload size as limited by PHP     * Used with permission from Moodle (http://moodle.org) by Martin Dougiamas     *     * this section generates $max_upload_size in bytes     */    function get_real_size($size=0) {    /// Converts numbers like 10M into bytes        if (!$size) {            return 0;        }        $scan['MB'] = 1048576;        $scan['Mb'] = 1048576;        $scan['M'] = 1048576;        $scan['m'] = 1048576;        $scan['KB'] = 1024;        $scan['Kb'] = 1024;        $scan['K'] = 1024;        $scan['k'] = 1024;        while (list($key) = each($scan)) {            if ((strlen($size)>strlen($key))&&(substr($size, strlen($size) - strlen($key))==$key)) {                $size = substr($size, 0, strlen($size) - strlen($key)) * $scan[$key];                break;            }        }        return $size;    } // end function    if (!$filesize = ini_get('upload_max_filesize')) {        $filesize = "5M";    }    $max_upload_size = get_real_size($filesize);    if ($postsize = ini_get('post_max_size')) {        $postsize = get_real_size($postsize);        if ($postsize < $max_upload_size) {            $max_upload_size = $postsize;        }    }    unset($filesize);    unset($postsize);    /**     * other functions for maximum upload work     */    /**     * Displays the maximum size for an upload     *     * @param   integer  the size     *     * @return  string   the message     *     * @access  public     */     function PMA_displayMaximumUploadSize($max_upload_size) {         list($max_size, $max_unit) = PMA_formatByteDown($max_upload_size);         return '(' . sprintf($GLOBALS['strMaximumSize'], $max_size, $max_unit) . ')';     }    /**     * Generates a hidden field which should indicate to the browser     * the maximum size for upload     *     * @param   integer  the size     *     * @return  string   the INPUT field     *     * @access  public     */     function PMA_generateHiddenMaxFileSize($max_size){         return '<input type="hidden" name="MAX_FILE_SIZE" value="' .$max_size . '" />';     }    /**     * Charset conversion.     */    require_once('./libraries/charset_conversion.lib.php');    /**     * String handling     */    require_once('./libraries/string.lib.php');}/** * Removes insecure parts in a path; used before include() or * require() when a part of the path comes from an insecure source * like a cookie or form. * * @param    string  The path to check * * @return   string  The secured path * * @access  public * @author  Marc Delisle (lem9@users.sourceforge.net) */function PMA_securePath($path) {    // change .. to .    $path = preg_replace('@\.\.*@','.',$path);    return $path;} // end function// If zlib output compression is set in the php configuration file, no// output buffering should be runif (@ini_get('zlib.output_compression')) {    $cfg['OBGzip'] = FALSE;}// disable output-buffering (if set to 'auto') for IE6, else enable it.if (strtolower($cfg['OBGzip']) == 'auto') {    if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 6 && PMA_USR_BROWSER_VER < 7) {        $cfg['OBGzip'] = FALSE;    } else {        $cfg['OBGzip'] = TRUE;    }}/* Theme Manager * 2004-05-20 Michael Keck (mail_at_michaelkeck_dot_de) *            This little script checks if there're themes available *            and if the directory $ThemePath/$theme/img/ exists *            If not, it will use default images*/// Allow different theme per server$theme_cookie_name = 'pma_theme';if ($GLOBALS['cfg']['ThemePerServer'] && isset($server)) {    $theme_cookie_name .= '-' . $server;}//echo $theme_cookie_name;// Theme Managerif (!$cfg['ThemeManager'] || !isset($_COOKIE[$theme_cookie_name]) || empty($_COOKIE[$theme_cookie_name])){    $GLOBALS['theme'] = $cfg['ThemeDefault'];    $ThemeDefaultOk = FALSE;

⌨️ 快捷键说明

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