2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Misc stuff and REQUIRED by ALL the scripts.
5 * MUST be included by every script
7 * Among other things, it contains the advanced authentication work.
9 * Order of sections for common.inc.php:
11 * the authentication libraries must be before the connection to db
13 * ... so the required order is:
15 * LABEL_variables_init
16 * - initialize some variables always needed
17 * LABEL_parsing_config_file
18 * - parsing of the configuration file
19 * LABEL_loading_language_file
20 * - loading language file
22 * - check and setup configured servers
26 * - load of MySQL extension (if necessary)
27 * - loading of an authentication library
29 * - authentication work
35 * Minimum PHP version; can't call PMA_fatalError() which uses a
36 * PHP 5 function, so cannot easily localize this message.
38 if (version_compare(PHP_VERSION
, '5.2.0', 'lt')) {
39 die('PHP 5.2+ is required');
43 * Backward compatibility for PHP 5.2
45 if (!defined('E_DEPRECATED')) {
46 define('E_DEPRECATED', 8192);
52 require './libraries/Error_Handler.class.php';
55 * initialize the error handler
57 $GLOBALS['error_handler'] = new PMA_Error_Handler();
58 $cfg['Error_Handler']['display'] = TRUE;
60 // at this point PMA_PHP_INT_VERSION is not yet defined
61 if (version_compare(phpversion(), '6', 'lt')) {
63 * Avoid object cloning errors
65 @ini_set
('zend.ze1_compatibility_mode', false);
68 * Avoid problems with magic_quotes_runtime
70 @ini_set
('magic_quotes_runtime', false);
74 * for verification in all procedural scripts under libraries
76 define('PHPMYADMIN', true);
81 require './libraries/core.lib.php';
86 require './libraries/sanitizing.lib.php';
91 require './libraries/Theme.class.php';
94 * the PMA_Theme_Manager class
96 require './libraries/Theme_Manager.class.php';
99 * the PMA_Config class
101 require './libraries/Config.class.php';
104 * the relation lib, tracker needs it
106 require './libraries/relation.lib.php';
109 * the PMA_Tracker class
111 require './libraries/Tracker.class.php';
114 * the PMA_Table class
116 require './libraries/Table.class.php';
118 if (!defined('PMA_MINIMUM_COMMON')) {
122 require_once './libraries/common.lib.php';
125 * Java script escaping.
127 require_once './libraries/js_escape.lib.php';
130 * Include URL/hidden inputs generating.
132 require_once './libraries/url_generating.lib.php';
135 /******************************************************************************/
136 /* start procedural code label_start_procedural */
139 * protect against possible exploits - there is no need to have so much variables
141 if (count($_REQUEST) > 1000) {
142 die('possible exploit');
146 * Check for numeric keys
147 * (if register_globals is on, numeric key can be found in $GLOBALS)
149 foreach ($GLOBALS as $key => $dummy) {
150 if (is_numeric($key)) {
151 die('numeric key detected');
157 * PATH_INFO could be compromised if set, so remove it from PHP_SELF
158 * and provide a clean PHP_SELF here
160 $PMA_PHP_SELF = PMA_getenv('PHP_SELF');
161 $_PATH_INFO = PMA_getenv('PATH_INFO');
162 if (! empty($_PATH_INFO) && ! empty($PMA_PHP_SELF)) {
163 $path_info_pos = strrpos($PMA_PHP_SELF, $_PATH_INFO);
164 if ($path_info_pos +
strlen($_PATH_INFO) === strlen($PMA_PHP_SELF)) {
165 $PMA_PHP_SELF = substr($PMA_PHP_SELF, 0, $path_info_pos);
168 $PMA_PHP_SELF = htmlspecialchars($PMA_PHP_SELF);
172 * just to be sure there was no import (registering) before here
173 * we empty the global space (but avoid unsetting $variables_list
174 * and $key in the foreach(), we still need them!)
176 $variables_whitelist = array (
188 'variables_whitelist',
192 foreach (get_defined_vars() as $key => $value) {
193 if (! in_array($key, $variables_whitelist)) {
197 unset($key, $value, $variables_whitelist);
201 * Subforms - some functions need to be called by form, cause of the limited URL
202 * length, but if this functions inside another form you cannot just open a new
203 * form - so phpMyAdmin uses 'arrays' inside this form
207 * ... main form elments ...
208 * <input type="hidden" name="subform[action1][id]" value="1" />
209 * ... other subform data ...
210 * <input type="submit" name="usesubform[action1]" value="do action1" />
211 * ... other subforms ...
212 * <input type="hidden" name="subform[actionX][id]" value="X" />
213 * ... other subform data ...
214 * <input type="submit" name="usesubform[actionX]" value="do actionX" />
215 * ... main form elments ...
216 * <input type="submit" name="main_action" value="submit form" />
220 * so we now check if a subform is submitted
223 if (isset($_POST['usesubform'])) {
224 // if a subform is present and should be used
225 // the rest of the form is deprecated
226 $subform_id = key($_POST['usesubform']);
227 $subform = $_POST['subform'][$subform_id];
229 $_REQUEST = $subform;
231 * some subforms need another page than the main form, so we will just
232 * include this page at the end of this script - we use $__redirect to
235 if (isset($_POST['redirect'])
236 && $_POST['redirect'] != basename($PMA_PHP_SELF)) {
237 $__redirect = $_POST['redirect'];
238 unset($_POST['redirect']);
240 unset($subform_id, $subform);
242 // Note: here we overwrite $_REQUEST so that it does not contain cookies,
243 // because another application for the same domain could have set
244 // a cookie (with a compatible path) that overrides a variable
245 // we expect from GET or POST.
246 // We'll refer to cookies explicitly with the $_COOKIE syntax.
247 $_REQUEST = array_merge($_GET, $_POST);
249 // end check if a subform is submitted
251 // remove quotes added by php
252 if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
253 PMA_arrayWalkRecursive($_GET, 'stripslashes', true);
254 PMA_arrayWalkRecursive($_POST, 'stripslashes', true);
255 PMA_arrayWalkRecursive($_COOKIE, 'stripslashes', true);
256 PMA_arrayWalkRecursive($_REQUEST, 'stripslashes', true);
260 * include deprecated grab_globals only if required
262 if (empty($__redirect) && !defined('PMA_NO_VARIABLES_IMPORT')) {
263 require './libraries/grab_globals.lib.php';
267 * check timezone setting
268 * this could produce an E_STRICT - but only once,
269 * if not done here it will produce E_STRICT on every date/time function
271 * @todo need to decide how we should handle this (without @)
273 date_default_timezone_set(@date_default_timezone_get
());
275 /******************************************************************************/
276 /* parsing configuration file LABEL_parsing_config_file */
279 * We really need this one!
281 if (! function_exists('preg_replace')) {
282 PMA_warnMissingExtension('pcre', true);
286 * @global PMA_Config $GLOBALS['PMA_Config']
287 * force reading of config file, because we removed sensitive values
288 * in the previous iteration
290 $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE
);
292 if (!defined('PMA_MINIMUM_COMMON')) {
293 $GLOBALS['PMA_Config']->checkPmaAbsoluteUri();
297 * BC - enable backward compatibility
298 * exports all configuration settings into $GLOBALS ($GLOBALS['cfg'])
300 $GLOBALS['PMA_Config']->enableBc();
303 * clean cookies on upgrade
304 * when changing something related to PMA cookies, increment the cookie version
306 $pma_cookie_version = 4;
308 && (isset($_COOKIE['pmaCookieVer'])
309 && $_COOKIE['pmaCookieVer'] < $pma_cookie_version)) {
310 // delete all cookies
311 foreach($_COOKIE as $cookie_name => $tmp) {
312 $GLOBALS['PMA_Config']->removeCookie($cookie_name);
315 $GLOBALS['PMA_Config']->setCookie('pmaCookieVer', $pma_cookie_version);
320 * check HTTPS connection
322 if ($GLOBALS['PMA_Config']->get('ForceSSL')
323 && !$GLOBALS['PMA_Config']->get('is_https')) {
324 PMA_sendHeaderLocation(
325 preg_replace('/^http/', 'https',
326 $GLOBALS['PMA_Config']->get('PmaAbsoluteUri'))
327 . PMA_generate_common_url($_GET, 'text'));
328 // delete the current session, otherwise we get problems (see bug #2397877)
329 $GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
335 * include session handling after the globals, to prevent overwriting
337 require './libraries/session.inc.php';
340 * init some variables LABEL_variables_init
344 * holds parameters to be passed to next page
345 * @global array $GLOBALS['url_params']
347 $GLOBALS['url_params'] = array();
350 * the whitelist for $GLOBALS['goto']
351 * @global array $goto_whitelist
353 $goto_whitelist = array(
354 //'browse_foreigners.php',
362 'db_importdocsql.php',
369 //'Documentation.html',
383 'server_collations.php',
384 'server_databases.php',
385 'server_engines.php',
388 'server_privileges.php',
389 'server_processlist.php',
392 'server_variables.php',
404 'tbl_operations.php',
408 'tbl_row_action.php',
411 'transformation_overview.php',
412 'transformation_wrapper.php',
418 * check $__redirect against whitelist
420 if (! PMA_checkPageValidity($__redirect, $goto_whitelist)) {
425 * holds page that should be displayed
426 * @global string $GLOBALS['goto']
428 $GLOBALS['goto'] = '';
429 // Security fix: disallow accessing serious server files via "?goto="
430 if (PMA_checkPageValidity($_REQUEST['goto'], $goto_whitelist)) {
431 $GLOBALS['goto'] = $_REQUEST['goto'];
432 $GLOBALS['url_params']['goto'] = $_REQUEST['goto'];
434 unset($_REQUEST['goto'], $_GET['goto'], $_POST['goto'], $_COOKIE['goto']);
439 * @global string $GLOBALS['back']
441 if (PMA_checkPageValidity($_REQUEST['back'], $goto_whitelist)) {
442 $GLOBALS['back'] = $_REQUEST['back'];
444 unset($_REQUEST['back'], $_GET['back'], $_POST['back'], $_COOKIE['back']);
448 * Check whether user supplied token is valid, if not remove any possibly
449 * dangerous stuff from request.
451 * remember that some objects in the session with session_start and __wakeup()
452 * could access this variables before we reach this point
453 * f.e. PMA_Config: fontsize
455 * @todo variables should be handled by their respective owners (objects)
456 * f.e. lang, server, collation_connection in PMA_Config
458 if (! PMA_isValid($_REQUEST['token']) ||
$_SESSION[' PMA_token '] != $_REQUEST['token']) {
460 * List of parameters which are allowed from unsafe source
463 /* needed for direct access, see FAQ 1.34
464 * also, server needed for cookie login screen (multi-server)
466 'server', 'db', 'table', 'target',
469 /* Cookie preferences */
470 'pma_lang', 'pma_collation_connection',
471 /* Possible login form */
472 'pma_servername', 'pma_username', 'pma_password',
473 /* for playing blobstreamable media */
474 'media_type', 'custom_type', 'bs_reference',
475 /* for changing BLOB repository file MIME type */
476 'bs_db', 'bs_table', 'bs_ref', 'bs_new_mime_type'
479 * Require cleanup functions
481 require './libraries/cleanup.lib.php';
485 PMA_remove_request_vars($allow_list);
491 * current selected database
492 * @global string $GLOBALS['db']
495 if (PMA_isValid($_REQUEST['db'])) {
496 // can we strip tags from this?
497 // only \ and / is not allowed in db names for MySQL
498 $GLOBALS['db'] = $_REQUEST['db'];
499 $GLOBALS['url_params']['db'] = $GLOBALS['db'];
503 * current selected table
504 * @global string $GLOBALS['table']
506 $GLOBALS['table'] = '';
507 if (PMA_isValid($_REQUEST['table'])) {
508 // can we strip tags from this?
509 // only \ and / is not allowed in table names for MySQL
510 $GLOBALS['table'] = $_REQUEST['table'];
511 $GLOBALS['url_params']['table'] = $GLOBALS['table'];
515 * SQL query to be executed
516 * @global string $GLOBALS['sql_query']
518 $GLOBALS['sql_query'] = '';
519 if (PMA_isValid($_REQUEST['sql_query'])) {
520 $GLOBALS['sql_query'] = $_REQUEST['sql_query'];
524 * avoid problems in phpmyadmin.css.php in some cases
525 * @global string $js_frame
527 $_REQUEST['js_frame'] = PMA_ifSetOr($_REQUEST['js_frame'], '');
529 //$_REQUEST['set_theme'] // checked later in this file LABEL_theme_setup
530 //$_REQUEST['server']; // checked later in this file
531 //$_REQUEST['lang']; // checked by LABEL_loading_language_file
535 * holds name of JavaScript files to be included in HTML header
536 * @global array $js_include
538 $GLOBALS['js_include'] = array();
539 $GLOBALS['js_include'][] = 'jquery/jquery-1.4.2.js';
540 $GLOBALS['js_include'][] = 'update-location.js';
543 * Add common jQuery functions script here if necessary.
547 * JavaScript events that will be registered
548 * @global array $js_events
550 $GLOBALS['js_events'] = array();
553 * footnotes to be displayed ot the page bottom
554 * @global array $footnotes
556 $GLOBALS['footnotes'] = array();
558 /******************************************************************************/
559 /* loading language file LABEL_loading_language_file */
562 * lang detection is done here
564 require './libraries/select_lang.lib.php';
567 * check for errors occurred while loading configuration
568 * this check is done here after loading language files to present errors in locale
570 if ($GLOBALS['PMA_Config']->error_config_file
) {
571 $error = __('phpMyAdmin was unable to read your configuration file!<br />This might happen if PHP finds a parse error in it or PHP cannot find the file.<br />Please call the configuration file directly using the link below and read the PHP error message(s) that you receive. In most cases a quote or a semicolon is missing somewhere.<br />If you receive a blank page, everything is fine.')
573 . ($GLOBALS['PMA_Config']->getSource() == CONFIG_FILE ?
574 '<a href="show_config_errors.php"'
575 .' target="_blank">' . $GLOBALS['PMA_Config']->getSource() . '</a>'
577 '<a href="' . $GLOBALS['PMA_Config']->getSource() . '"'
578 .' target="_blank">' . $GLOBALS['PMA_Config']->getSource() . '</a>');
579 trigger_error($error, E_USER_ERROR
);
581 if ($GLOBALS['PMA_Config']->error_config_default_file
) {
582 $error = sprintf(__('Could not load default configuration from: %1$s'),
583 $GLOBALS['PMA_Config']->default_source
);
584 trigger_error($error, E_USER_ERROR
);
586 if ($GLOBALS['PMA_Config']->error_pma_uri
) {
587 trigger_error(__('The <tt>$cfg[\'PmaAbsoluteUri\']</tt> directive MUST be set in your configuration file!'), E_USER_ERROR
);
591 /******************************************************************************/
592 /* setup servers LABEL_setup_servers */
596 * @global integer $GLOBALS['server']
598 $GLOBALS['server'] = 0;
601 * Servers array fixups.
602 * $default_server comes from PMA_Config::enableBc()
603 * @todo merge into PMA_Config
605 // Do we have some server?
606 if (!isset($cfg['Servers']) ||
count($cfg['Servers']) == 0) {
607 // No server => create one with defaults
608 $cfg['Servers'] = array(1 => $default_server);
610 // We have server(s) => apply default configuration
611 $new_servers = array();
613 foreach ($cfg['Servers'] as $server_index => $each_server) {
615 // Detect wrong configuration
616 if (!is_int($server_index) ||
$server_index < 1) {
617 trigger_error(sprintf(__('Invalid server index: %s'), $server_index), E_USER_ERROR
);
620 $each_server = array_merge($default_server, $each_server);
622 // Don't use servers with no hostname
623 if ($each_server['connect_type'] == 'tcp' && empty($each_server['host'])) {
624 trigger_error(sprintf(__('Invalid hostname for server %1$s. Please review your configuration.'), $server_index), E_USER_ERROR
);
627 // Final solution to bug #582890
628 // If we are using a socket connection
629 // and there is nothing in the verbose server name
630 // or the host field, then generate a name for the server
631 // in the form of "Server 2", localized of course!
632 if ($each_server['connect_type'] == 'socket' && empty($each_server['host']) && empty($each_server['verbose'])) {
633 $each_server['verbose'] = __('Server') . $server_index;
636 $new_servers[$server_index] = $each_server;
638 $cfg['Servers'] = $new_servers;
639 unset($new_servers, $server_index, $each_server);
643 unset($default_server);
646 /******************************************************************************/
647 /* setup themes LABEL_theme_setup */
649 if (isset($_REQUEST['custom_color_reset'])) {
650 unset($_SESSION['tmp_user_values']['custom_color']);
651 } elseif (isset($_REQUEST['custom_color'])) {
652 $_SESSION['tmp_user_values']['custom_color'] = $_REQUEST['custom_color'];
655 * @global PMA_Theme_Manager $_SESSION['PMA_Theme_Manager']
657 if (! isset($_SESSION['PMA_Theme_Manager'])) {
658 $_SESSION['PMA_Theme_Manager'] = new PMA_Theme_Manager
;
661 * @todo move all __wakeup() functionality into session.inc.php
663 $_SESSION['PMA_Theme_Manager']->checkConfig();
666 // for the theme per server feature
667 if (isset($_REQUEST['server']) && !isset($_REQUEST['set_theme'])) {
668 $GLOBALS['server'] = $_REQUEST['server'];
669 $tmp = $_SESSION['PMA_Theme_Manager']->getThemeCookie();
671 $tmp = $_SESSION['PMA_Theme_Manager']->theme_default
;
673 $_SESSION['PMA_Theme_Manager']->setActiveTheme($tmp);
677 * @todo move into PMA_Theme_Manager::__wakeup()
679 if (isset($_REQUEST['set_theme'])) {
680 // if user selected a theme
681 $_SESSION['PMA_Theme_Manager']->setActiveTheme($_REQUEST['set_theme']);
686 * @global PMA_Theme $_SESSION['PMA_Theme']
688 $_SESSION['PMA_Theme'] = $_SESSION['PMA_Theme_Manager']->theme
;
693 * @global string $GLOBALS['theme']
695 $GLOBALS['theme'] = $_SESSION['PMA_Theme']->getName();
698 * @global string $GLOBALS['pmaThemePath']
700 $GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath();
702 * the theme image path
703 * @global string $GLOBALS['pmaThemeImage']
705 $GLOBALS['pmaThemeImage'] = $_SESSION['PMA_Theme']->getImgPath();
708 * load layout file if exists
710 if (@file_exists
($_SESSION['PMA_Theme']->getLayoutFile())) {
711 include $_SESSION['PMA_Theme']->getLayoutFile();
713 * @todo remove if all themes are update use Navi instead of Left as frame name
715 if (! isset($GLOBALS['cfg']['NaviWidth'])
716 && isset($GLOBALS['cfg']['LeftWidth'])) {
717 $GLOBALS['cfg']['NaviWidth'] = $GLOBALS['cfg']['LeftWidth'];
721 if (! defined('PMA_MINIMUM_COMMON')) {
723 * Character set conversion.
725 require_once './libraries/charset_conversion.lib.php';
730 require_once './libraries/string.lib.php';
733 * Lookup server by name
734 * by Arnold - Helder Hosting
737 if (! empty($_REQUEST['server']) && is_string($_REQUEST['server'])
738 && ! is_numeric($_REQUEST['server'])) {
739 foreach ($cfg['Servers'] as $i => $server) {
740 if ($server['host'] == $_REQUEST['server']) {
741 $_REQUEST['server'] = $i;
745 if (is_string($_REQUEST['server'])) {
746 unset($_REQUEST['server']);
752 * If no server is selected, make sure that $cfg['Server'] is empty (so
753 * that nothing will work), and skip server authentication.
754 * We do NOT exit here, but continue on without logging into any server.
755 * This way, the welcome page will still come up (with no server info) and
756 * present a choice of servers in the case that there are multiple servers
757 * and '$cfg['ServerDefault'] = 0' is set.
760 if (isset($_REQUEST['server']) && (is_string($_REQUEST['server']) ||
is_numeric($_REQUEST['server'])) && ! empty($_REQUEST['server']) && ! empty($cfg['Servers'][$_REQUEST['server']])) {
761 $GLOBALS['server'] = $_REQUEST['server'];
762 $cfg['Server'] = $cfg['Servers'][$GLOBALS['server']];
764 if (!empty($cfg['Servers'][$cfg['ServerDefault']])) {
765 $GLOBALS['server'] = $cfg['ServerDefault'];
766 $cfg['Server'] = $cfg['Servers'][$GLOBALS['server']];
768 $GLOBALS['server'] = 0;
769 $cfg['Server'] = array();
772 $GLOBALS['url_params']['server'] = $GLOBALS['server'];
775 * Kanji encoding convert feature appended by Y.Kawada (2002/2/20)
777 if (function_exists('mb_convert_encoding')
779 require_once './libraries/kanji-encoding.lib.php';
781 * enable multibyte string support
783 define('PMA_MULTIBYTE_ENCODING', 1);
787 * save some settings in cookies
788 * @todo should be done in PMA_Config
790 $GLOBALS['PMA_Config']->setCookie('pma_lang', $GLOBALS['lang']);
791 $GLOBALS['PMA_Config']->setCookie('pma_collation_connection', $GLOBALS['collation_connection']);
793 $_SESSION['PMA_Theme_Manager']->setThemeCookie();
795 if (! empty($cfg['Server'])) {
798 * Loads the proper database interface for this server
800 require_once './libraries/database_interface.lib.php';
802 require_once './libraries/logging.lib.php';
804 // Gets the authentication library that fits the $cfg['Server'] settings
805 // and run authentication
807 // to allow HTTP or http
808 $cfg['Server']['auth_type'] = strtolower($cfg['Server']['auth_type']);
809 if (! file_exists('./libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php')) {
810 PMA_fatalError(__('Invalid authentication method set in configuration:') . ' ' . $cfg['Server']['auth_type']);
813 * the required auth type plugin
815 require_once './libraries/auth/' . $cfg['Server']['auth_type'] . '.auth.lib.php';
816 if (!PMA_auth_check()) {
822 // Check IP-based Allow/Deny rules as soon as possible to reject the
824 // Based on mod_access in Apache:
825 // http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/aaa/mod_access.c?rev=1.37&content-type=text/vnd.viewcvs-markup
826 // Look at: "static int check_dir_access(request_rec *r)"
827 // Robbat2 - May 10, 2002
828 if (isset($cfg['Server']['AllowDeny'])
829 && isset($cfg['Server']['AllowDeny']['order'])) {
832 * ip based access library
834 require_once './libraries/ip_allow_deny.lib.php';
836 $allowDeny_forbidden = false; // default
837 if ($cfg['Server']['AllowDeny']['order'] == 'allow,deny') {
838 $allowDeny_forbidden = true;
839 if (PMA_allowDeny('allow')) {
840 $allowDeny_forbidden = false;
842 if (PMA_allowDeny('deny')) {
843 $allowDeny_forbidden = true;
845 } elseif ($cfg['Server']['AllowDeny']['order'] == 'deny,allow') {
846 if (PMA_allowDeny('deny')) {
847 $allowDeny_forbidden = true;
849 if (PMA_allowDeny('allow')) {
850 $allowDeny_forbidden = false;
852 } elseif ($cfg['Server']['AllowDeny']['order'] == 'explicit') {
853 if (PMA_allowDeny('allow')
854 && !PMA_allowDeny('deny')) {
855 $allowDeny_forbidden = false;
857 $allowDeny_forbidden = true;
859 } // end if ... elseif ... elseif
861 // Ejects the user if banished
862 if ($allowDeny_forbidden) {
863 PMA_log_user($cfg['Server']['user'], 'allow-denied');
866 unset($allowDeny_forbidden); //Clean up after you!
870 if (!$cfg['Server']['AllowRoot'] && $cfg['Server']['user'] == 'root') {
871 $allowDeny_forbidden = true;
872 PMA_log_user($cfg['Server']['user'], 'root-denied');
874 unset($allowDeny_forbidden); //Clean up after you!
877 // is a login without password allowed?
878 if (!$cfg['Server']['AllowNoPassword'] && $cfg['Server']['password'] == '') {
879 $login_without_password_is_forbidden = true;
880 PMA_log_user($cfg['Server']['user'], 'empty-denied');
882 unset($login_without_password_is_forbidden); //Clean up after you!
885 // Try to connect MySQL with the control user profile (will be used to
886 // get the privileges list for the current user but the true user link
887 // must be open after this one so it would be default one for all the
889 $controllink = false;
890 if ($cfg['Server']['controluser'] != '') {
891 $controllink = PMA_DBI_connect($cfg['Server']['controluser'],
892 $cfg['Server']['controlpass'], true);
895 // Connects to the server (validates user's login)
896 $userlink = PMA_DBI_connect($cfg['Server']['user'],
897 $cfg['Server']['password'], false);
899 if (! $controllink) {
900 $controllink = $userlink;
904 PMA_log_user($cfg['Server']['user']);
907 * with phpMyAdmin 3 we support MySQL >=5
908 * but only production releases:
911 if (PMA_MYSQL_INT_VERSION
< 50015) {
912 PMA_fatalError(__('You should upgrade to %s %s or later.'), array('MySQL', '5.0.15'));
918 require_once './libraries/sqlparser.lib.php';
921 * SQL Validator interface code
923 require_once './libraries/sqlvalidator.lib.php';
926 * the PMA_List_Database class
928 require_once './libraries/PMA.php';
930 $pma->userlink
= $userlink;
931 $pma->controllink
= $controllink;
934 * some resetting has to be done when switching servers
936 if (isset($_SESSION['tmp_user_values']['previous_server']) && $_SESSION['tmp_user_values']['previous_server'] != $GLOBALS['server']) {
937 unset($_SESSION['tmp_user_values']['navi_limit_offset']);
939 $_SESSION['tmp_user_values']['previous_server'] = $GLOBALS['server'];
941 } // end server connecting
944 * check if profiling was requested and remember it
945 * (note: when $cfg['ServerDefault'] = 0, constant is not defined)
947 if (isset($_REQUEST['profiling']) && PMA_profilingSupported()) {
948 $_SESSION['profiling'] = true;
949 } elseif (isset($_REQUEST['profiling_form'])) {
950 // the checkbox was unchecked
951 unset($_SESSION['profiling']);
954 // library file for blobstreaming
955 require_once './libraries/blobstreaming.lib.php';
957 // checks for blobstreaming plugins and databases that support
958 // blobstreaming (by having the necessary tables for blobstreaming)
959 checkBLOBStreamingPlugins();
961 } // end if !defined('PMA_MINIMUM_COMMON')
963 // load user preferences
964 $GLOBALS['PMA_Config']->loadUserPreferences();
966 // remove sensitive values from session
967 $GLOBALS['PMA_Config']->set('blowfish_secret', '');
968 $GLOBALS['PMA_Config']->set('Servers', '');
969 $GLOBALS['PMA_Config']->set('default_server', '');
971 /* Tell tracker that it can actually work */
972 PMA_Tracker
::enable();
975 * @global boolean $GLOBALS['is_ajax_request']
976 * @todo should this be moved to the variables init section above?
978 * Check if the current request is an AJAX request, and set is_ajax_request
979 * accordingly. Suppress headers, footers and unnecessary output if set to
982 if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
983 $GLOBALS['is_ajax_request'] = true;
985 $GLOBALS['is_ajax_request'] = false;
989 * @global boolean $GLOBALS['inline_edit']
991 * Set to true if this is a request made during an inline edit process. This
992 * request is made to retrieve the non-truncated/transformed values.
994 if(isset($_REQUEST['inline_edit']) && $_REQUEST['inline_edit'] == true) {
995 $GLOBALS['inline_edit'] = true;
998 $GLOBALS['inline_edit'] = false;
1001 if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
1003 * include subform target page
1005 require $__redirect;