📄 common.inc.php
字号:
*/$GLOBALS['js_include'] = array();/** * holds locale messages required by JavaScript function * @global array $js_messages */$GLOBALS['js_messages'] = array();/** * JavaScript events that will be registered * @global array $js_events */$GLOBALS['js_events'] = array();/** * footnotes to be displayed ot the page bottom * @global array $footnotes */$GLOBALS['footnotes'] = array();/******************************************************************************//* parsing configuration file LABEL_parsing_config_file *//** * We really need this one! */if (! function_exists('preg_replace')) { PMA_fatalError('strCantLoad', 'pcre');}/** * @global PMA_Config $_SESSION['PMA_Config'] * force reading of config file, because we removed sensitive values * in the previous iteration */$_SESSION['PMA_Config'] = new PMA_Config('./config.inc.php');if (!defined('PMA_MINIMUM_COMMON')) { $_SESSION['PMA_Config']->checkPmaAbsoluteUri();}/** * BC - enable backward compatibility * exports all configuration settings into $GLOBALS ($GLOBALS['cfg']) */$_SESSION['PMA_Config']->enableBc();/** * check HTTPS connection */if ($_SESSION['PMA_Config']->get('ForceSSL') && !$_SESSION['PMA_Config']->get('is_https')) { PMA_sendHeaderLocation( preg_replace('/^http/', 'https', $_SESSION['PMA_Config']->get('PmaAbsoluteUri')) . PMA_generate_common_url($_GET, 'text')); // delete the current session, otherwise we get problems (see bug #2397877) PMA_removeCookie($GLOBALS['session_name']); exit;}/******************************************************************************//* loading language file LABEL_loading_language_file *//** * Added messages while developing: */if (file_exists('./lang/added_messages.php')) { include './lang/added_messages.php';}/** * lang detection is done here */require_once './libraries/select_lang.lib.php';/** * check for errors occurred while loading configuration * this check is done here after loading language files to present errors in locale */if ($_SESSION['PMA_Config']->error_config_file) { $error = $strConfigFileError . '<br /><br />' . ($_SESSION['PMA_Config']->getSource() == './config.inc.php' ? '<a href="show_config_errors.php"' .' target="_blank">' . $_SESSION['PMA_Config']->getSource() . '</a>' : '<a href="' . $_SESSION['PMA_Config']->getSource() . '"' .' target="_blank">' . $_SESSION['PMA_Config']->getSource() . '</a>'); trigger_error($error, E_USER_ERROR);}if ($_SESSION['PMA_Config']->error_config_default_file) { $error = sprintf($strConfigDefaultFileError, $_SESSION['PMA_Config']->default_source); trigger_error($error, E_USER_ERROR);}if ($_SESSION['PMA_Config']->error_pma_uri) { trigger_error($strPmaUriError, E_USER_ERROR);}/******************************************************************************//* setup servers LABEL_setup_servers *//** * current server * @global integer $GLOBALS['server'] */$GLOBALS['server'] = 0;/** * Servers array fixups. * $default_server comes from PMA_Config::enableBc() * @todo merge into PMA_Config */// 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 configuration $new_servers = array(); foreach ($cfg['Servers'] as $server_index => $each_server) { // Detect wrong configuration if (!is_int($server_index) || $server_index < 1) { trigger_error(sprintf($strInvalidServerIndex, $server_index), E_USER_ERROR); } $each_server = array_merge($default_server, $each_server); // Don't use servers with no hostname if ($each_server['connect_type'] == 'tcp' && empty($each_server['host'])) { trigger_error(sprintf($strInvalidServerHostname, $server_index), E_USER_ERROR); } // Final solution to bug #582890 // If we are using a socket connection // and there is nothing in the verbose server name // or the host field, then generate a name for the server // in the form of "Server 2", localized of course! if ($each_server['connect_type'] == 'socket' && empty($each_server['host']) && empty($each_server['verbose'])) { $each_server['verbose'] = $GLOBALS['strServer'] . $server_index; } $new_servers[$server_index] = $each_server; } $cfg['Servers'] = $new_servers; unset($new_servers, $server_index, $each_server);}// Cleanupunset($default_server);/******************************************************************************//* setup themes LABEL_theme_setup */if (isset($_REQUEST['custom_color_reset'])) { unset($_SESSION['userconf']['custom_color']); unset($_SESSION['userconf']['custom_color_rgb']);} elseif (isset($_REQUEST['custom_color'])) { $_SESSION['userconf']['custom_color'] = $_REQUEST['custom_color']; $_SESSION['userconf']['custom_color_rgb'] = $_REQUEST['custom_color_rgb'];}/** * @global PMA_Theme_Manager $_SESSION['PMA_Theme_Manager'] */if (! isset($_SESSION['PMA_Theme_Manager'])) { $_SESSION['PMA_Theme_Manager'] = new PMA_Theme_Manager;} else { /** * @todo move all __wakeup() functionality into session.inc.php */ $_SESSION['PMA_Theme_Manager']->checkConfig();}// for the theme per server featureif (isset($_REQUEST['server']) && !isset($_REQUEST['set_theme'])) { $GLOBALS['server'] = $_REQUEST['server']; $tmp = $_SESSION['PMA_Theme_Manager']->getThemeCookie(); if (empty($tmp)) { $tmp = $_SESSION['PMA_Theme_Manager']->theme_default; } $_SESSION['PMA_Theme_Manager']->setActiveTheme($tmp); unset($tmp);}/** * @todo move into PMA_Theme_Manager::__wakeup() */if (isset($_REQUEST['set_theme'])) { // if user selected a theme $_SESSION['PMA_Theme_Manager']->setActiveTheme($_REQUEST['set_theme']);}/** * the theme object * @global PMA_Theme $_SESSION['PMA_Theme'] */$_SESSION['PMA_Theme'] = $_SESSION['PMA_Theme_Manager']->theme;// BC/** * the active theme * @global string $GLOBALS['theme'] */$GLOBALS['theme'] = $_SESSION['PMA_Theme']->getName();/** * the theme path * @global string $GLOBALS['pmaThemePath'] */$GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath();/** * the theme image path * @global string $GLOBALS['pmaThemeImage'] */$GLOBALS['pmaThemeImage'] = $_SESSION['PMA_Theme']->getImgPath();/** * load layout file if exists */if (@file_exists($_SESSION['PMA_Theme']->getLayoutFile())) { include $_SESSION['PMA_Theme']->getLayoutFile(); /** * @todo remove if all themes are update use Navi instead of Left as frame name */ if (! isset($GLOBALS['cfg']['NaviWidth']) && isset($GLOBALS['cfg']['LeftWidth'])) { $GLOBALS['cfg']['NaviWidth'] = $GLOBALS['cfg']['LeftWidth']; }}if (! defined('PMA_MINIMUM_COMMON')) { /** * Character set conversion. */ require_once './libraries/charset_conversion.lib.php'; /** * String handling */ require_once './libraries/string.lib.php'; /** * Lookup server by name * by Arnold - Helder Hosting * (see FAQ 4.8) */ if (! empty($_REQUEST['server']) && is_string($_REQUEST['server']) && ! is_numeric($_REQUEST['server'])) { foreach ($cfg['Servers'] as $i => $server) { if ($server['host'] == $_REQUEST['server']) { $_REQUEST['server'] = $i; break; } } if (is_string($_REQUEST['server'])) { unset($_REQUEST['server']); } unset($i); } /** * If no server is selected, make sure that $cfg['Server'] is empty (so * that nothing will work), and skip server authentication. * We do NOT exit here, but continue on without logging into any server. * This way, the welcome page will still come up (with no server info) and * present a choice of servers in the case that there are multiple servers * and '$cfg['ServerDefault'] = 0' is set. */ if (isset($_REQUEST['server']) && (is_string($_REQUEST['server']) || is_numeric($_REQUEST['server'])) && ! empty($_REQUEST['server']) && ! empty($cfg['Servers'][$_REQUEST['server']])) { $GLOBALS['server'] = $_REQUEST['server']; $cfg['Server'] = $cfg['Servers'][$GLOBALS['server']]; } else { if (!empty($cfg['Servers'][$cfg['ServerDefault']])) { $GLOBALS['server'] = $cfg['ServerDefault']; $cfg['Server'] = $cfg['Servers'][$GLOBALS['server']]; } else { $GLOBALS['server'] = 0; $cfg['Server'] = array(); } } $GLOBALS['url_params']['server'] = $GLOBALS['server']; /** * Kanji encoding convert feature appended by Y.Kawada (2002/2/20) */ if (function_exists('mb_convert_encoding') && strpos($lang, 'ja-') !== false) { require_once './libraries/kanji-encoding.lib.php'; /** * enable multibyte string support */ define('PMA_MULTIBYTE_ENCODING', 1); } // end if /** * save some settings in cookies * @todo should be done in PMA_Config */ PMA_setCookie('pma_lang', $GLOBALS['lang']); PMA_setCookie('pma_charset', $GLOBALS['convcharset']); PMA_setCookie('pma_collation_connection', $GLOBALS['collation_connection']); $_SESSION['PMA_Theme_Manager']->setThemeCookie(); if (! empty($cfg['Server'])) { /** * Loads the proper database interface for this server */ require_once './libraries/database_interface.lib.php'; // Gets the authentication library that fits the $cfg['Server'] settings // and run authentication // to allow HTTP or http $cfg['Server']['auth_type'] = strtolower($cfg['Server']['auth_type']); if (! file_exists('./libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php')) { PMA_fatalError($strInvalidAuthMethod . ' ' . $cfg['Server']['auth_type']); } /** * the required auth type plugin */ require_once './libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php'; if (!PMA_auth_check()) { PMA_auth(); } else { PMA_auth_set_user(); } // Check IP-based Allow/Deny rules as soon as possible to reject the // user // Based on mod_access in Apache: // http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/aaa/mod_access.c?rev=1.37&content-type=text/vnd.viewcvs-markup // Look at: "static int check_dir_access(request_rec *r)" // Robbat2 - May 10, 2002 if (isset($cfg['Server']['AllowDeny']) && isset($cfg['Server']['AllowDeny']['order'])) { /** * ip based access library */ 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; } } elseif ($cfg['Server']['AllowDeny']['order'] == 'deny,allow') { if (PMA_allowDeny('deny')) { $allowDeny_forbidden = true; } if (PMA_allowDeny('allow')) { $allowDeny_forbidden = false; } } elseif ($cfg['Server']['AllowDeny']['order'] == 'explicit') { if (PMA_allowDeny('allow') && !PMA_allowDeny('deny')) { $allowDeny_forbidden = false; } else { $allowDeny_forbidden = true; } } // end if ... elseif ... elseif // 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! } // is root without password allowed? if (!$cfg['Server']['AllowNoPasswordRoot'] && $cfg['Server']['user'] == 'root' && $cfg['Server']['password'] == '') { $allowDeny_forbidden = true; PMA_auth_fails(); unset($allowDeny_forbidden); //Clean up after you! } // 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) $controllink = false; if ($cfg['Server']['controluser'] != '') { $controllink = PMA_DBI_connect($cfg['Server']['controluser'], $cfg['Server']['controlpass'], true); } // Connects to the server (validates user's login) $userlink = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password'], false); if (! $controllink) { $controllink = $userlink; } /** * with phpMyAdmin 3 we support MySQL >=5 * but only production releases: * - > 5.0.15 */ if (PMA_MYSQL_INT_VERSION < 50015) { PMA_fatalError('strUpgrade', array('MySQL', '5.0.15')); } /** * SQL Parser code */ require_once './libraries/sqlparser.lib.php'; /** * SQL Validator interface code */ require_once './libraries/sqlvalidator.lib.php'; /** * the PMA_List_Database class */ require_once './libraries/PMA.php'; $pma = new PMA; $pma->userlink = $userlink; $pma->controllink = $controllink; /** * some resetting has to be done when switching servers */ if (isset($_SESSION['userconf']['previous_server']) && $_SESSION['userconf']['previous_server'] != $GLOBALS['server']) { unset($_SESSION['userconf']['navi_limit_offset']); } $_SESSION['userconf']['previous_server'] = $GLOBALS['server']; } // end server connecting /** * check if profiling was requested and remember it * (note: when $cfg['ServerDefault'] = 0, constant is not defined) */ if (isset($_REQUEST['profiling']) && PMA_profilingSupported()) { $_SESSION['profiling'] = true; } elseif (isset($_REQUEST['profiling_form'])) { // the checkbox was unchecked unset($_SESSION['profiling']); } // rajk - library file for blobstreaming require_once './libraries/blobstreaming.lib.php'; // rajk - checks for blobstreaming plugins and databases that support // blobstreaming (by having the necessary tables for blobstreaming) if (checkBLOBStreamingPlugins()) checkBLOBStreamableDatabases();} // end if !defined('PMA_MINIMUM_COMMON')// remove sensitive values from session$_SESSION['PMA_Config']->set('blowfish_secret', '');$_SESSION['PMA_Config']->set('Servers', '');$_SESSION['PMA_Config']->set('default_server', '');if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) { /** * include subform target page */ require $__redirect; exit();}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -