123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- <?php
- use PhpMyAdmin\Config;
- use PhpMyAdmin\Core;
- use PhpMyAdmin\DatabaseInterface;
- use PhpMyAdmin\ErrorHandler;
- use PhpMyAdmin\LanguageManager;
- use PhpMyAdmin\Logging;
- use PhpMyAdmin\Message;
- use PhpMyAdmin\Plugins\AuthenticationPlugin;
- use PhpMyAdmin\Response;
- use PhpMyAdmin\Session;
- use PhpMyAdmin\ThemeManager;
- use PhpMyAdmin\Tracker;
- use PhpMyAdmin\Util;
- if (getcwd() == dirname(__FILE__)) {
- die('Attack stopped');
- }
- if (version_compare(PHP_VERSION, '5.5.0', 'lt')) {
- die(
- 'PHP 5.5+ is required. <br /> Currently installed version is: '
- . phpversion()
- );
- }
- define('PHPMYADMIN', true);
- require_once './libraries/vendor_config.php';
- require_once './libraries/hash.lib.php';
- if (! @is_readable(AUTOLOAD_FILE)) {
- die(
- 'File <tt>' . AUTOLOAD_FILE . '</tt> missing or not readable. <br />'
- . 'Most likely you did not run Composer to '
- . '<a href="https://docs.phpmyadmin.net/en/latest/setup.html#installing-from-git">install library files</a>.'
- );
- }
- require_once AUTOLOAD_FILE;
- PhpMyAdmin\MoTranslator\Loader::loadFunctions();
- $GLOBALS['error_handler'] = new ErrorHandler();
- Core::checkExtensions();
- Core::configure();
- Core::cleanupPathInfo();
- $GLOBALS['PMA_Config'] = new Config(CONFIG_FILE);
- if (! defined('PMA_NO_SESSION')) {
- Session::setUp($GLOBALS['PMA_Config'], $GLOBALS['error_handler']);
- }
- Core::populateRequestWithEncryptedQueryParams();
- $GLOBALS['url_params'] = array();
- $GLOBALS['goto'] = '';
- if (Core::checkPageValidity($_REQUEST['goto'])) {
- $GLOBALS['goto'] = $_REQUEST['goto'];
- $GLOBALS['url_params']['goto'] = $_REQUEST['goto'];
- } else {
- $GLOBALS['PMA_Config']->removeCookie('goto');
- unset($_REQUEST['goto'], $_GET['goto'], $_POST['goto']);
- }
- if (Core::checkPageValidity($_REQUEST['back'])) {
- $GLOBALS['back'] = $_REQUEST['back'];
- } else {
- $GLOBALS['PMA_Config']->removeCookie('back');
- unset($_REQUEST['back'], $_GET['back'], $_POST['back']);
- }
- $token_mismatch = true;
- $token_provided = false;
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- if (Core::isValid($_POST['token'])) {
- $token_provided = true;
- $token_mismatch = ! @hash_equals($_SESSION[' PMA_token '], $_POST['token']);
- }
- if ($token_mismatch) {
-
- if (isset($_POST['set_session']) && $_POST['set_session'] != session_id()) {
- trigger_error(
- __(
- 'Failed to set session cookie. Maybe you are using '
- . 'HTTP instead of HTTPS to access phpMyAdmin.'
- ),
- E_USER_ERROR
- );
- }
-
- $whitelist = array('ajax_request');
- PhpMyAdmin\Sanitize::removeRequestVars($whitelist);
- }
- }
- Core::setGlobalDbOrTable('db');
- Core::setGlobalDbOrTable('table');
- if (Core::isValid($_REQUEST['selected_recent_table'])) {
- $recent_table = json_decode($_REQUEST['selected_recent_table'], true);
- $GLOBALS['db']
- = (array_key_exists('db', $recent_table) && is_string($recent_table['db'])) ?
- $recent_table['db'] : '';
- $GLOBALS['url_params']['db'] = $GLOBALS['db'];
- $GLOBALS['table']
- = (array_key_exists('table', $recent_table) && is_string($recent_table['table'])) ?
- $recent_table['table'] : '';
- $GLOBALS['url_params']['table'] = $GLOBALS['table'];
- }
- $GLOBALS['sql_query'] = '';
- if (Core::isValid($_POST['sql_query'])) {
- $GLOBALS['sql_query'] = $_POST['sql_query'];
- }
- $language = LanguageManager::getInstance()->selectLanguage();
- $language->activate();
- $GLOBALS['PMA_Config']->checkPermissions();
- $GLOBALS['PMA_Config']->checkErrors();
- Core::checkConfiguration();
- Core::checkRequest();
- $GLOBALS['PMA_Config']->checkServers();
- $GLOBALS['server'] = $GLOBALS['PMA_Config']->selectServer();
- $GLOBALS['url_params']['server'] = $GLOBALS['server'];
- $GLOBALS['PMA_Config']->enableBc();
- ThemeManager::initializeTheme();
- if (! defined('PMA_MINIMUM_COMMON')) {
-
- $GLOBALS['PMA_Config']->setCookie('pma_lang', $GLOBALS['lang']);
- ThemeManager::getInstance()->setThemeCookie();
- if (! empty($cfg['Server'])) {
-
- DatabaseInterface::load();
-
-
-
-
- $cache_key = 'server_' . $GLOBALS['server'];
- if (isset($_SESSION['cache'][$cache_key]['userprefs']['LoginCookieValidity'])
- ) {
- $value
- = $_SESSION['cache'][$cache_key]['userprefs']['LoginCookieValidity'];
- $GLOBALS['PMA_Config']->set('LoginCookieValidity', $value);
- $GLOBALS['cfg']['LoginCookieValidity'] = $value;
- unset($value);
- }
- unset($cache_key);
-
-
-
- $auth_class = 'PhpMyAdmin\\Plugins\\Auth\\Authentication' . ucfirst(strtolower($cfg['Server']['auth_type']));
- if (! @class_exists($auth_class)) {
- Core::fatalError(
- __('Invalid authentication method set in configuration:')
- . ' ' . $cfg['Server']['auth_type']
- );
- }
- if (isset($_POST['pma_password']) && strlen($_POST['pma_password']) > 256) {
- $_POST['pma_password'] = substr($_POST['pma_password'], 0, 256);
- }
- $auth_plugin = new $auth_class();
- $auth_plugin->authenticate();
-
-
-
-
- $controllink = false;
- if ($cfg['Server']['controluser'] != '') {
- $controllink = $GLOBALS['dbi']->connect(
- DatabaseInterface::CONNECT_CONTROL
- );
- }
-
-
- $userlink = $GLOBALS['dbi']->connect(DatabaseInterface::CONNECT_USER);
- if ($userlink === false) {
- $auth_plugin->showFailure('mysql-denied');
- }
- if (! $controllink) {
-
- $controllink = $GLOBALS['dbi']->connect(
- DatabaseInterface::CONNECT_USER,
- null,
- DatabaseInterface::CONNECT_CONTROL
- );
- }
- $auth_plugin->rememberCredentials();
- $auth_plugin->checkTwoFactor();
-
- Logging::logUser($cfg['Server']['user']);
- if ($GLOBALS['dbi']->getVersion() < $cfg['MysqlMinVersion']['internal']) {
- Core::fatalError(
- __('You should upgrade to %s %s or later.'),
- array('MySQL', $cfg['MysqlMinVersion']['human'])
- );
- }
-
- if (!empty($_REQUEST['sql_delimiter'])) {
- PhpMyAdmin\SqlParser\Lexer::$DEFAULT_DELIMITER = $_REQUEST['sql_delimiter'];
- }
-
- } else {
- $response = Response::getInstance();
- $response->getHeader()->disableMenuAndConsole();
- $response->getFooter()->setMinimal();
- }
-
- if (isset($_REQUEST['profiling'])
- && Util::profilingSupported()
- ) {
- $_SESSION['profiling'] = true;
- } elseif (isset($_REQUEST['profiling_form'])) {
-
- unset($_SESSION['profiling']);
- }
-
- $response = Response::getInstance();
- if (isset($_SESSION['profiling'])) {
- $scripts = $response->getHeader()->getScripts();
- $scripts->addFile('chart.js');
- $scripts->addFile('vendor/jqplot/jquery.jqplot.js');
- $scripts->addFile('vendor/jqplot/plugins/jqplot.pieRenderer.js');
- $scripts->addFile('vendor/jqplot/plugins/jqplot.highlighter.js');
- $scripts->addFile('vendor/jquery/jquery.tablesorter.js');
- }
-
- if ($response->isAjax() && $_SERVER['REQUEST_METHOD'] == 'POST' && $token_mismatch) {
- $response->setRequestStatus(false);
- $response->addJSON(
- 'message',
- Message::error(__('Error: Token mismatch'))
- );
- exit;
- }
- }
- $GLOBALS['PMA_Config']->loadUserPreferences();
- Tracker::enable();
- if (! defined('PMA_MINIMUM_COMMON')
- && ! empty($GLOBALS['server'])
- && isset($GLOBALS['cfg']['ZeroConf'])
- && $GLOBALS['cfg']['ZeroConf'] == true
- ) {
- $GLOBALS['dbi']->postConnectControl();
- }
|