/** * Configures global environment. * * @return void */ function setup() { if (!defined('PMA_IS_WINDOWS')) { define('PMA_IS_WINDOWS', false); } $GLOBALS['cfg']['Server']['DisableIS'] = false; $GLOBALS['server'] = 0; $GLOBALS['cfg']['ServerDefault'] = 1; $GLOBALS['cfg']['Server']['verbose'] = 'verbose host'; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'both'; $_SESSION['PMA_Theme'] = new PMA_Theme(); $GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath(); $GLOBALS['pmaThemeImage'] = 'theme/'; $GLOBALS['cfg']['DefaultTabServer'] = 'main.php'; $GLOBALS['cfg']['DefaultTabDatabase'] = 'db_structure.php'; $GLOBALS['cfg']['DefaultTabTable'] = 'sql.php'; $GLOBALS['cfg']['OBGzip'] = false; $GLOBALS['cfg']['NaturalOrder'] = true; $GLOBALS['cfg']['TabsMode'] = 'both'; $GLOBALS['cfg']['DBG']['sql'] = false; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['server'] = 'server'; $GLOBALS['db'] = 'pma_test'; $GLOBALS['table'] = 'table1'; }
/** * Test for setUp * * @return void */ public function setUp() { //$GLOBALS $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; $GLOBALS['cfg']['SQP'] = array(); $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $GLOBALS['cfg']['LimitChars'] = 100; $GLOBALS['cfg']['DBG']['sql'] = false; $GLOBALS['cfg']['Server']['host'] = "localhost"; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['server_master_status'] = false; $GLOBALS['server_slave_status'] = false; $GLOBALS['table'] = "table"; $GLOBALS['pmaThemeImage'] = 'image'; //$_SESSION $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new PMA_Theme(); //Mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock(); //this data is needed when PMA_ServerStatusData constructs $server_status = array("Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", "Com_create_function" => "0", "Com_empty_query" => "0"); $server_variables = array("auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF"); $fetchResult = array(array("SHOW GLOBAL STATUS", 0, 1, null, 0, $server_status), array("SHOW GLOBAL VARIABLES", 0, 1, null, 0, $server_variables)); $dbi->expects($this->any())->method('fetchResult')->will($this->returnValueMap($fetchResult)); $GLOBALS['dbi'] = $dbi; $this->ServerStatusData = new PMA_ServerStatusData(); $upTime = "10h"; $this->ServerStatusData->status['Uptime'] = $upTime; $this->ServerStatusData->used_queries = array("Com_change_db" => "15", "Com_select" => "12", "Com_set_option" => "54", "Com_show_databases" => "16", "Com_show_status" => "14", "Com_show_tables" => "13"); }
/** * Test for setUp * * @return void */ public function setUp() { //$_REQUEST $_REQUEST['log'] = "index1"; $_REQUEST['pos'] = 3; //$GLOBALS $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['server'] = 1; $GLOBALS['table'] = "table"; $GLOBALS['pmaThemeImage'] = 'image'; //$_SESSION $_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new Theme(); //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); //this data is needed when ServerStatusData constructs $server_session_variable = array("auto_increment_increment" => "1", "auto_increment_offset" => "13", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF"); $server_global_variables = array("auto_increment_increment" => "0", "auto_increment_offset" => "12"); $fetchResult = array(array("SHOW SESSION VARIABLES;", 0, 1, null, 0, $server_session_variable), array("SHOW GLOBAL VARIABLES;", 0, 1, null, 0, $server_global_variables)); $dbi->expects($this->any())->method('fetchResult')->will($this->returnValueMap($fetchResult)); $GLOBALS['dbi'] = $dbi; $container = Container::getDefaultContainer(); $container->set('dbi', $GLOBALS['dbi']); $this->_response = new \PMA\Test\Stubs\Response(); $container->set('PMA\\libraries\\Response', $this->_response); $container->alias('response', 'PMA\\libraries\\Response'); }
/** * Test for setUp * * @return void */ public function setUp() { //$_REQUEST $_REQUEST['log'] = "index1"; $_REQUEST['pos'] = 3; //$GLOBALS $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; $GLOBALS['cfg']['SQP'] = array(); $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $GLOBALS['cfg']['LimitChars'] = 100; $GLOBALS['cfg']['DBG']['sql'] = false; $GLOBALS['cfg']['Server']['host'] = "localhost"; $GLOBALS['cfg']['ActionLinksMode'] = 'icons'; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['table'] = "table"; $GLOBALS['pmaThemeImage'] = 'image'; //$_SESSION $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new PMA_Theme(); //Mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock(); //this data is needed when PMA_ServerStatusData constructs $server_session_variable = array("auto_increment_increment" => "1", "auto_increment_offset" => "13", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF"); $server_global_variables = array("auto_increment_increment" => "0", "auto_increment_offset" => "12"); $fetchResult = array(array("SHOW SESSION VARIABLES;", 0, 1, null, 0, $server_session_variable), array("SHOW GLOBAL VARIABLES;", 0, 1, null, 0, $server_global_variables)); $dbi->expects($this->any())->method('fetchResult')->will($this->returnValueMap($fetchResult)); $GLOBALS['dbi'] = $dbi; }
/** * Test for setUp * * @return void */ public function setUp() { //$GLOBALS $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ExecTimeLimit'] = 300; $GLOBALS['cfg']['ServerDefault'] = "PMA_server"; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $GLOBALS['cfg']['LimitChars'] = 100; $GLOBALS['cfg']['ActionLinksMode'] = 'icons'; $GLOBALS['cfg']['Server']['host'] = "localhost"; $GLOBALS['cfg']['Server']['user'] = "******"; $GLOBALS['cfg']['ShowHint'] = true; $GLOBALS['cfg']['ActionLinksMode'] = 'icons'; $GLOBALS['cfg']['ZipDump'] = true; $GLOBALS['cfg']['GZipDump'] = false; $GLOBALS['cfg']['BZipDump'] = false; $GLOBALS['cfg']['Export']['asfile'] = true; $GLOBALS['cfg']['Export']['file_template_server'] = "file_template_server"; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['PMA_recoding_engine'] = "InnerDB"; $GLOBALS['server'] = 0; $GLOBALS['table'] = "table"; $GLOBALS['pmaThemeImage'] = 'image'; $GLOBALS['db'] = "PMA"; //$_SESSION $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new PMA_Theme(); $_SESSION['relation'][$GLOBALS['server']] = ""; $pmaconfig = $this->getMockBuilder('PMA_Config')->disableOriginalConstructor()->getMock(); $pmaconfig->expects($this->any())->method('getUserValue')->will($this->returnValue('user value for test')); $GLOBALS['PMA_Config'] = $pmaconfig; }
/** * Test for setUp * * @return void */ public function setUp() { $GLOBALS['cfg']['Server']['host'] = "localhost"; $GLOBALS['cfg']['ShowHint'] = true; $GLOBALS['cfg']['ActionLinksMode'] = 'icons'; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['replication_info']['master']['status'] = true; $GLOBALS['replication_info']['slave']['status'] = false; $GLOBALS['replication_types'] = array(); $GLOBALS['table'] = "table"; $GLOBALS['pmaThemeImage'] = 'image'; //$_SESSION $_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new Theme(); //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); //this data is needed when ServerStatusData constructs $server_status = array("Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", "Com_create_function" => "0", "Com_empty_query" => "0", "Com_execute_sql" => 2, "Com_stmt_execute" => 2); $server_variables = array("auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF"); $fetchResult = array(array("SHOW GLOBAL STATUS", 0, 1, null, 0, $server_status), array("SHOW GLOBAL VARIABLES", 0, 1, null, 0, $server_variables), array("SELECT concat('Com_', variable_name), variable_value " . "FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1, null, 0, $server_status)); $dbi->expects($this->at(0))->method('tryQuery')->with('SHOW GLOBAL STATUS')->will($this->returnValue(true)); $dbi->expects($this->at(1))->method('fetchRow')->will($this->returnValue(array("Aborted_clients", "0"))); $dbi->expects($this->at(2))->method('fetchRow')->will($this->returnValue(array("Aborted_connects", "0"))); $dbi->expects($this->at(3))->method('fetchRow')->will($this->returnValue(array("Com_delete_multi", "0"))); $dbi->expects($this->at(4))->method('fetchRow')->will($this->returnValue(array("Com_create_function", "0"))); $dbi->expects($this->at(5))->method('fetchRow')->will($this->returnValue(array("Com_empty_query", "0"))); $dbi->expects($this->at(6))->method('fetchRow')->will($this->returnValue(false)); $dbi->expects($this->at(7))->method('freeResult'); $dbi->expects($this->any())->method('fetchResult')->will($this->returnValueMap($fetchResult)); $GLOBALS['dbi'] = $dbi; $this->ServerStatusData = new ServerStatusData(); }
/** * Test for setUp * * @return void */ public function setUp() { //$_REQUEST $_REQUEST['log'] = "index1"; $_REQUEST['pos'] = 3; //$GLOBALS $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; $GLOBALS['cfg']['SQP'] = array(); $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['Server']['host'] = "localhost"; $GLOBALS['cfg']['ShowHint'] = true; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['replication_info']['master']['status'] = false; $GLOBALS['replication_info']['slave']['status'] = false; $GLOBALS['table'] = "table"; $GLOBALS['pmaThemeImage'] = 'image'; //$_SESSION $_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new Theme(); //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); //this data is needed when ServerStatusData constructs $server_status = array("Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", "Com_create_function" => "0", "Com_empty_query" => "0"); $server_variables = array("auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF"); $fetchResult = array(array("SHOW GLOBAL STATUS", 0, 1, null, 0, $server_status), array("SHOW GLOBAL VARIABLES", 0, 1, null, 0, $server_variables), array("SELECT concat('Com_', variable_name), variable_value " . "FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1, null, 0, $server_status)); $dbi->expects($this->any())->method('fetchResult')->will($this->returnValueMap($fetchResult)); $GLOBALS['dbi'] = $dbi; $this->ServerStatusData = new ServerStatusData(); }
/** * Prepares environment for the test. * * @return void */ public function setUp() { //Constants if (!defined("PMA_USR_BROWSER_AGENT")) { define("PMA_USR_BROWSER_AGENT", "other"); } //$_REQUEST $_REQUEST['log'] = "index1"; $_REQUEST['pos'] = 3; //$GLOBALS $GLOBALS['cfg']['MaxRows'] = 10; $GLOBALS['cfg']['SendErrorReports'] = "never"; $GLOBALS['cfg']['ServerDefault'] = "server"; $GLOBALS['cfg']['RememberSorting'] = true; $GLOBALS['cfg']['SQP'] = array(); $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000; $GLOBALS['cfg']['ShowSQL'] = true; $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons'; $GLOBALS['cfg']['LimitChars'] = 100; $GLOBALS['cfg']['AllowThirdPartyFraming'] = false; $GLOBALS['cfg']['Server']['pmadb'] = 'pmadb'; $GLOBALS['cfg']['Server']['usergroups'] = 'usergroups'; $GLOBALS['cfg']['Server']['users'] = 'users'; $GLOBALS['cfg']['ActionLinksMode'] = "both"; $GLOBALS['cfg']['DefaultTabDatabase'] = 'db_structure.php'; $GLOBALS['cfg']['QueryWindowHeight'] = 100; $GLOBALS['cfg']['QueryWindowWidth'] = 100; $GLOBALS['cfg']['PmaAbsoluteUri'] = "PmaAbsoluteUri"; $GLOBALS['cfg']['DefaultTabTable'] = "db_structure.php"; $GLOBALS['cfg']['NavigationTreeDefaultTabTable'] = "db_structure.php"; $GLOBALS['cfg']['Confirm'] = "Confirm"; $GLOBALS['cfg']['ShowHint'] = true; $GLOBALS['cfgRelation'] = array(); $GLOBALS['cfgRelation']['menuswork'] = false; $GLOBALS['table'] = "table"; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['pmaThemeImage'] = 'image'; $GLOBALS['server'] = 1; $GLOBALS['hostname'] = "hostname"; $GLOBALS['username'] = "******"; $GLOBALS['collation_connection'] = "collation_connection"; $GLOBALS['text_dir'] = "text_dir"; //$_POST $_POST['pred_password'] = '******'; //$_SESSION $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new PMA_Theme(); $pmaconfig = $this->getMockBuilder('PMA_Config')->disableOriginalConstructor()->getMock(); $GLOBALS['PMA_Config'] = $pmaconfig; //Mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock(); $dbi->expects($this->any())->method('fetchResult')->will($this->returnValue(array('grant user1 select', 'grant user2 delete'))); $fetchSingleRow = array('password' => 'pma_password', 'Table_priv' => 'pri1, pri2', 'Type' => 'Type'); $dbi->expects($this->any())->method('fetchSingleRow')->will($this->returnValue($fetchSingleRow)); $fetchValue = array('key1' => 'value1'); $dbi->expects($this->any())->method('fetchValue')->will($this->returnValue($fetchValue)); $dbi->expects($this->any())->method('tryQuery')->will($this->returnValue(true)); $GLOBALS['dbi'] = $dbi; }
/** * Test for checkParameters * * @return void */ function testCheckParameter() { $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath(); $GLOBALS['db'] = "dbDatabase"; $GLOBALS['table'] = "tblTable"; $GLOBALS['field'] = "test_field"; $GLOBALS['sql_query'] = "SELECT * FROM tblTable;"; $this->expectOutputString(""); PMA\libraries\Util::checkParameters(array('db', 'table', 'field', 'sql_query')); }
/** * trys to find the language to use * * @uses $GLOBALS['cfg']['lang'] * @uses $GLOBALS['cfg']['DefaultLang'] * @uses $GLOBALS['lang_failed_cfg'] * @uses $GLOBALS['lang_failed_cookie'] * @uses $GLOBALS['lang_failed_request'] * @uses $_REQUEST['lang'] * @uses $_COOKIE['pma_lang'] * @uses $_SERVER['HTTP_ACCEPT_LANGUAGE'] * @uses $_SERVER['HTTP_USER_AGENT'] * @uses PMA_langSet() * @uses PMA_langDetect() * @uses explode() * @return bool success if valid lang is found, otherwise false */ function PMA_langCheck() { // check forced language if (!empty($GLOBALS['cfg']['Lang'])) { if (PMA_langSet($GLOBALS['cfg']['Lang'])) { return true; } else { $GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang']; } } // Don't use REQUEST in following code as it might be confused by cookies with same name // check user requested language (POST) if (!empty($_POST['lang'])) { if (PMA_langSet($_POST['lang'])) { return true; } else { $GLOBALS['lang_failed_request'] = $_POST['lang']; } } // check user requested language (GET) if (!empty($_GET['lang'])) { if (PMA_langSet($_GET['lang'])) { return true; } else { $GLOBALS['lang_failed_request'] = $_GET['lang']; } } // check previous set language if (!empty($_COOKIE['pma_lang'])) { if (PMA_langSet($_COOKIE['pma_lang'])) { return true; } else { $GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang']; } } // try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable if (PMA_getenv('HTTP_ACCEPT_LANGUAGE')) { foreach (explode(',', PMA_getenv('HTTP_ACCEPT_LANGUAGE')) as $lang) { if (PMA_langDetect($lang, 1)) { return true; } } } // try to findout user's language by checking its HTTP_USER_AGENT variable if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) { return true; } // Didn't catch any valid lang : we use the default settings if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) { return true; } return false; }
/** * Test for setUp * * @return void */ public function setUp() { $GLOBALS['cfg']['Server']['host'] = "localhost"; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['replication_info']['master']['status'] = true; $GLOBALS['replication_info']['slave']['status'] = false; $GLOBALS['replication_types'] = array(); $GLOBALS['pmaThemeImage'] = 'image'; //$_SESSION //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); $GLOBALS['dbi'] = $dbi; }
/** * Configures global environment. * * @return void */ function setup() { if (!defined('PMA_IS_WINDOWS')) { define('PMA_IS_WINDOWS', false); } $GLOBALS['cfg']['Server']['DisableIS'] = false; $GLOBALS['server'] = 0; $GLOBALS['cfg']['Server']['verbose'] = 'verbose host'; $GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath(); $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['server'] = 'server'; $GLOBALS['db'] = 'pma_test'; $GLOBALS['table'] = 'table1'; }
/** * Test for setUp * * @return void */ public function setUp() { $GLOBALS['cfg']['Server']['host'] = "localhost"; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['server_master_status'] = true; $GLOBALS['server_slave_status'] = false; $GLOBALS['replication_types'] = array(); $GLOBALS['pmaThemeImage'] = 'image'; //$_SESSION $_SESSION['PMA_Theme'] = PMA_Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new PMA_Theme(); //Mock DBI $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock(); $GLOBALS['dbi'] = $dbi; }
/** * Configures global environment. * * @return void */ function setup() { $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['cfg']['Server']['host'] = "::1"; $GLOBALS['replication_info']['master']['status'] = true; $GLOBALS['replication_info']['slave']['status'] = true; $GLOBALS['replication_types'] = array(); //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); //this data is needed when ServerStatusData constructs $server_status = array("Aborted_clients" => "0", "Aborted_connects" => "0", "Com_delete_multi" => "0", "Com_create_function" => "0", "Com_empty_query" => 3, "Key_blocks_used" => 2, "Key_writes" => true, "Key_reads" => true, "Key_write_requests" => 5, "Key_read_requests" => 1, "Threads_created" => true, "Connections" => 2); $server_variables = array("auto_increment_increment" => "1", "auto_increment_offset" => "1", "automatic_sp_privileges" => "ON", "back_log" => "50", "big_tables" => "OFF", "key_buffer_size" => 10); $fetchResult = array(array("SHOW GLOBAL STATUS", 0, 1, null, 0, $server_status), array("SHOW GLOBAL VARIABLES", 0, 1, null, 0, $server_variables), array("SELECT concat('Com_', variable_name), variable_value " . "FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1, null, 0, $server_status)); $dbi->expects($this->any())->method('fetchResult')->will($this->returnValueMap($fetchResult)); $GLOBALS['dbi'] = $dbi; $this->object = new ServerStatusData(); }
/** * Configures global environment. * * @return void */ function setup() { if (!defined('PMA_IS_WINDOWS')) { define('PMA_IS_WINDOWS', false); } $GLOBALS['server'] = 0; $GLOBALS['message'] = 'phpmyadminmessage'; $GLOBALS['pmaThemePath'] = $_SESSION['PMA_Theme']->getPath(); $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['server'] = 'server'; $GLOBALS['db'] = 'pma_test'; $GLOBALS['table'] = 'table1'; $GLOBALS['PMA_Config'] = new PMA\libraries\Config(); $GLOBALS['PMA_Config']->enableBc(); $GLOBALS['cfg']['Server']['DisableIS'] = false; $GLOBALS['cfg']['Server']['verbose'] = 'verbose host'; $GLOBALS['cfg']['Server']['pmadb'] = ''; $GLOBALS['cfg']['Server']['user'] = ''; }
/** * Test for setUp * * @return void */ public function setUp() { //$GLOBALS $GLOBALS['max_upload_size'] = 100; $GLOBALS['PMA_PHP_SELF'] = PMA_getenv('PHP_SELF'); $GLOBALS['db'] = "PMA_db"; $GLOBALS['table'] = "PMA_table"; $GLOBALS['pmaThemeImage'] = 'image'; $GLOBALS['text_dir'] = "text_dir"; $GLOBALS['cfg']['GZipDump'] = false; $GLOBALS['cfg']['BZipDump'] = false; $GLOBALS['cfg']['ZipDump'] = false; $GLOBALS['cfg']['ServerDefault'] = "default"; $GLOBALS['cfg']['TextareaAutoSelect'] = true; $GLOBALS['cfg']['TextareaRows'] = 100; $GLOBALS['cfg']['TextareaCols'] = 11; $GLOBALS['cfg']['DefaultTabDatabase'] = "structure"; $GLOBALS['cfg']['RetainQueryBox'] = true; $GLOBALS['cfg']['ActionLinksMode'] = 'both'; $GLOBALS['cfg']['DefaultTabTable'] = 'browse'; $GLOBALS['cfg']['CodemirrorEnable'] = true; $GLOBALS['cfg']['DefaultForeignKeyChecks'] = 'default'; //_SESSION $_SESSION['relation'][0] = array('PMA_VERSION' => PMA_VERSION, 'table_coords' => "table_name", 'displaywork' => 'displaywork', 'db' => "information_schema", 'table_info' => 'table_info', 'relwork' => 'relwork', 'relation' => 'relation', 'bookmarkwork' => 'bookmarkwork'); //$GLOBALS $GLOBALS['cfg']['Server']['user'] = "******"; $GLOBALS['cfg']['Server']['pmadb'] = "pmadb"; $GLOBALS['cfg']['Server']['bookmarktable'] = "bookmarktable"; //$_SESSION $_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme'); $_SESSION['PMA_Theme'] = new Theme(); //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); $fetchResult = array("index1" => "table1", "index2" => "table2"); $dbi->expects($this->any())->method('fetchResult')->will($this->returnValue($fetchResult)); $getColumns = array(array("Field" => "field1", "Comment" => "Comment1")); $dbi->expects($this->any())->method('getColumns')->will($this->returnValue($getColumns)); $GLOBALS['dbi'] = $dbi; }
use PMA\libraries\Util; /** * Gets some core libraries and displays a top message if required */ require_once 'libraries/common.inc.php'; require_once 'libraries/user_preferences.lib.php'; require_once 'libraries/config/config_functions.lib.php'; require_once 'libraries/config/messages.inc.php'; require 'libraries/config/user_preferences.forms.php'; $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings); PMA_userprefsPageInit($cf); $error = ''; if (isset($_POST['submit_export']) && isset($_POST['export_type']) && $_POST['export_type'] == 'text_file') { // export to JSON file PMA\libraries\Response::getInstance()->disable(); $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.json'; PMA_downloadHeader($filename, 'application/json'); $settings = PMA_loadUserprefs(); echo json_encode($settings['config_data'], JSON_PRETTY_PRINT); exit; } else { if (isset($_POST['submit_get_json'])) { $settings = PMA_loadUserprefs(); $response = PMA\libraries\Response::getInstance(); $response->addJSON('prefs', json_encode($settings['config_data'])); $response->addJSON('mtime', $settings['mtime']); exit; } else { if (isset($_POST['submit_import'])) { // load from JSON file $json = '';
/** * Tries to find the language to use * * @return bool success if valid lang is found, otherwise false */ function PMA_langCheck() { // check forced language if (!empty($GLOBALS['cfg']['Lang'])) { if (PMA_langSet($GLOBALS['cfg']['Lang'])) { return true; } else { $GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang']; } } // Don't use REQUEST in following code as it might be confused by cookies // with same name. Check user requested language (POST) if (!empty($_POST['lang'])) { if (PMA_langSet($_POST['lang'])) { return true; } elseif (!is_string($_POST['lang'])) { /* Faked request, don't care on localisation */ $GLOBALS['lang_failed_request'] = 'Yes'; } else { $GLOBALS['lang_failed_request'] = $_POST['lang']; } } // check user requested language (GET) if (!empty($_GET['lang'])) { if (PMA_langSet($_GET['lang'])) { return true; } elseif (!is_string($_GET['lang'])) { /* Faked request, don't care on localisation */ $GLOBALS['lang_failed_request'] = 'Yes'; } else { $GLOBALS['lang_failed_request'] = $_GET['lang']; } } // check previous set language if (!empty($_COOKIE['pma_lang'])) { if (PMA_langSet($_COOKIE['pma_lang'])) { return true; } elseif (!is_string($_COOKIE['pma_lang'])) { /* Faked request, don't care on localisation */ $GLOBALS['lang_failed_cookie'] = 'Yes'; } else { $GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang']; } } // try to find out user's language by checking its HTTP_ACCEPT_LANGUAGE variable; // prevent XSS $accepted_languages = PMA_getenv('HTTP_ACCEPT_LANGUAGE'); if ($accepted_languages && false === strpos($accepted_languages, '<')) { foreach (explode(',', $accepted_languages) as $lang) { if (PMA_langDetect($lang, 1)) { return true; } } } unset($accepted_languages); // try to find out user's language by checking its HTTP_USER_AGENT variable if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) { return true; } // Didn't catch any valid lang : we use the default settings if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) { return true; } return false; }
} if (!empty($_POST)) { PMA_recursive_extract($_POST, $GLOBALS); } if (!empty($_FILES)) { $_valid_variables = preg_replace($GLOBALS['_import_blacklist'], '', array_keys($_FILES)); foreach ($_valid_variables as $name) { if (strlen($name) != 0) { ${$name} = $_FILES[$name]['tmp_name']; ${$name . '_name'} = $_FILES[$name]['name']; } } unset($name, $value); } /** * globalize some environment variables */ $server_vars = array('HTTP_ACCEPT_LANGUAGE', 'HTTP_AUTHORIZATION'); foreach ($server_vars as $current) { // it's not important HOW we detect html tags // it's more important to prevent XSS // so it's not important if we result in an invalid string, // it's even better than a XSS capable string if (PMA_getenv($current) && false === strpos(PMA_getenv($current), '<')) { ${$current} = PMA_getenv($current); // already imported by register_globals? } elseif (!isset(${$current}) || false !== strpos(${$current}, '<')) { ${$current} = ''; } } unset($server_vars, $current, $_import_blacklist);
/** * Renders the footer * * @return string */ public function getDisplay() { $retval = ''; $this->_setHistory(); if ($this->_isEnabled) { if (!$this->_isAjax) { $retval .= "</div>"; } if (!$this->_isAjax && !$this->_isMinimal) { if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && empty($GLOBALS['checked_special']) && !$this->_isAjax) { $url = $this->getSelfUrl('unencoded'); $header = PMA_Response::getInstance()->getHeader(); $scripts = $header->getScripts()->getFiles(); $menuHash = $header->getMenu()->getHash(); // prime the client-side cache $this->_scripts->addCode(sprintf('AJAX.cache.primer = {' . ' url: "%s",' . ' scripts: %s,' . ' menuHash: "%s"' . '};', PMA_escapeJsString($url), json_encode($scripts), PMA_escapeJsString($menuHash))); $url = $this->getSelfUrl(); $retval .= $this->_getSelfLink($url); } $retval .= $this->_getDebugMessage(); $retval .= $this->getErrorMessages(); $retval .= $this->_scripts->getDisplay(); if ($GLOBALS['cfg']['DBG']['demo']) { $retval .= '<div id="pma_demo">'; $retval .= $this->_getDemoMessage(); $retval .= '</div>'; } // Include possible custom footers if (file_exists(CUSTOM_FOOTER_FILE)) { $retval .= '<div id="pma_footer">'; ob_start(); include CUSTOM_FOOTER_FILE; $retval .= ob_get_contents(); ob_end_clean(); $retval .= '</div>'; } } if (!$this->_isAjax) { $retval .= "</body></html>"; } } return $retval; }
/** * Gets advanced authentication settings * * @global string $PHP_AUTH_USER the username if register_globals is * on * @global string $PHP_AUTH_PW the password if register_globals is * on * * @return boolean whether we get authentication settings or not */ public function authCheck() { global $PHP_AUTH_USER, $PHP_AUTH_PW; if ($GLOBALS['token_provided'] && $GLOBALS['token_mismatch']) { return false; } // Grabs the $PHP_AUTH_USER variable whatever are the values of the // 'register_globals' and the 'variables_order' directives if (empty($PHP_AUTH_USER)) { if (PMA_getenv('PHP_AUTH_USER')) { $PHP_AUTH_USER = PMA_getenv('PHP_AUTH_USER'); } elseif (PMA_getenv('REMOTE_USER')) { // CGI, might be encoded, see below $PHP_AUTH_USER = PMA_getenv('REMOTE_USER'); } elseif (PMA_getenv('REDIRECT_REMOTE_USER')) { // CGI, might be encoded, see below $PHP_AUTH_USER = PMA_getenv('REDIRECT_REMOTE_USER'); } elseif (PMA_getenv('AUTH_USER')) { // WebSite Professional $PHP_AUTH_USER = PMA_getenv('AUTH_USER'); } elseif (PMA_getenv('HTTP_AUTHORIZATION') && false === strpos(PMA_getenv('HTTP_AUTHORIZATION'), '<')) { // IIS, might be encoded, see below; also prevent XSS $PHP_AUTH_USER = PMA_getenv('HTTP_AUTHORIZATION'); } elseif (PMA_getenv('Authorization')) { // FastCGI, might be encoded, see below $PHP_AUTH_USER = PMA_getenv('Authorization'); } } // Grabs the $PHP_AUTH_PW variable whatever are the values of the // 'register_globals' and the 'variables_order' directives if (empty($PHP_AUTH_PW)) { if (PMA_getenv('PHP_AUTH_PW')) { $PHP_AUTH_PW = PMA_getenv('PHP_AUTH_PW'); } elseif (PMA_getenv('REMOTE_PASSWORD')) { // Apache/CGI $PHP_AUTH_PW = PMA_getenv('REMOTE_PASSWORD'); } elseif (PMA_getenv('AUTH_PASSWORD')) { // WebSite Professional $PHP_AUTH_PW = PMA_getenv('AUTH_PASSWORD'); } } // Decode possibly encoded information (used by IIS/CGI/FastCGI) // (do not use explode() because a user might have a colon in his password if (strcmp(substr($PHP_AUTH_USER, 0, 6), 'Basic ') == 0) { $usr_pass = base64_decode(substr($PHP_AUTH_USER, 6)); if (!empty($usr_pass)) { $colon = strpos($usr_pass, ':'); if ($colon) { $PHP_AUTH_USER = substr($usr_pass, 0, $colon); $PHP_AUTH_PW = substr($usr_pass, $colon + 1); } unset($colon); } unset($usr_pass); } // User logged out -> ensure the new username is not the same $old_usr = isset($_REQUEST['old_usr']) ? $_REQUEST['old_usr'] : ''; if (!empty($old_usr) && (isset($PHP_AUTH_USER) && $old_usr == $PHP_AUTH_USER)) { $PHP_AUTH_USER = ''; // -> delete user's choices that were stored in session if (!defined('TESTSUITE')) { session_destroy(); } } // Returns whether we get authentication settings or not if (empty($PHP_AUTH_USER)) { return false; } else { return true; } }
/** * Detects whether https appears to be used. * * This function checks if the https protocol is used in the current connection * with the webserver, based on environment variables. * Please note that this just detects what we see, so * it completely ignores things like reverse proxies. * * @return bool */ function detectHttps() { $is_https = false; $url = array(); // At first we try to parse REQUEST_URI, it might contain full URL, if (PMA_getenv('REQUEST_URI')) { // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/' $url = @parse_url(PMA_getenv('REQUEST_URI')); if ($url === false) { $url = array(); } } // If we don't have scheme, we didn't have full URL so we need to // dig deeper if (empty($url['scheme'])) { // Scheme if (PMA_getenv('HTTP_SCHEME')) { $url['scheme'] = PMA_getenv('HTTP_SCHEME'); } elseif (PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) == 'on') { $url['scheme'] = 'https'; // A10 Networks load balancer: } elseif (PMA_getenv('HTTP_HTTPS_FROM_LB') && strtolower(PMA_getenv('HTTP_HTTPS_FROM_LB')) == 'on') { $url['scheme'] = 'https'; } elseif (PMA_getenv('HTTP_X_FORWARDED_PROTO')) { $url['scheme'] = strtolower(PMA_getenv('HTTP_X_FORWARDED_PROTO')); } elseif (PMA_getenv('HTTP_FRONT_END_HTTPS') && strtolower(PMA_getenv('HTTP_FRONT_END_HTTPS')) == 'on') { $url['scheme'] = 'https'; } else { $url['scheme'] = 'http'; } } if (isset($url['scheme']) && $url['scheme'] == 'https') { $is_https = true; } else { $is_https = false; } return $is_https; }
/** * Formats user string, expanding @VARIABLES@, accepting strftime format string. * * @param string $string Text where to do expansion. * @param function $escape Function to call for escaping variable values. * @param array $updates Array with overrides for default parameters * (obtained from GLOBALS). * * @return string */ function PMA_expandUserString($string, $escape = null, $updates = array()) { /* Content */ $vars['http_host'] = PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : ''; $vars['server_name'] = $GLOBALS['cfg']['Server']['host']; $vars['server_verbose'] = $GLOBALS['cfg']['Server']['verbose']; $vars['server_verbose_or_name'] = !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host']; $vars['database'] = $GLOBALS['db']; $vars['table'] = $GLOBALS['table']; $vars['phpmyadmin_version'] = 'phpMyAdmin ' . PMA_VERSION; /* Update forced variables */ foreach ($updates as $key => $val) { $vars[$key] = $val; } /* Replacement mapping */ /* * The __VAR__ ones are for backward compatibility, because user * might still have it in cookies. */ $replace = array('@HTTP_HOST@' => $vars['http_host'], '@SERVER@' => $vars['server_name'], '__SERVER__' => $vars['server_name'], '@VERBOSE@' => $vars['server_verbose'], '@VSERVER@' => $vars['server_verbose_or_name'], '@DATABASE@' => $vars['database'], '__DB__' => $vars['database'], '@TABLE@' => $vars['table'], '__TABLE__' => $vars['table'], '@PHPMYADMIN@' => $vars['phpmyadmin_version']); /* Optional escaping */ if (!is_null($escape)) { foreach ($replace as $key => $val) { $replace[$key] = $escape($val); } } /* Backward compatibility in 3.5.x */ if (strpos($string, '@FIELDS@') !== false) { $string = strtr($string, array('@FIELDS@' => '@COLUMNS@')); } /* Fetch columns list if required */ if (strpos($string, '@COLUMNS@') !== false) { $columns_list = PMA_DBI_get_columns($GLOBALS['db'], $GLOBALS['table']); $column_names = array(); foreach ($columns_list as $column) { if (!is_null($escape)) { $column_names[] = $escape($column['Field']); } else { $column_names[] = $field['Field']; } } $replace['@COLUMNS@'] = implode(',', $column_names); } /* Do the replacement */ return strtr(strftime($string), $replace); }
function Output($name = '', $dest = '') { //Output PDF to some destination // lem9 //global $HTTP_SERVER_VARS; //Finish document if necessary if ($this->state < 3) { $this->Close(); } //Normalize parameters if (is_bool($dest)) { $dest = $dest ? 'D' : 'F'; } $dest = strtoupper($dest); if ($dest == '') { if ($name == '') { $name = 'doc.pdf'; $dest = 'I'; } else { $dest = 'F'; } } switch ($dest) { case 'I': //Send to standard output // lem9 //if(isset($HTTP_SERVER_VARS['SERVER_NAME'])) if (PMA_getenv('SERVER_NAME')) { //We send to a browser Header('Content-Type: application/pdf'); if (headers_sent()) { $this->Error('Some data has already been output to browser, can\'t send PDF file'); } Header('Content-Length: ' . strlen($this->buffer)); Header('Content-disposition: inline; filename="' . $name . '"'); } echo $this->buffer; break; case 'D': //Download file // lem9 //if(isset($HTTP_SERVER_VARS['HTTP_USER_AGENT']) and strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'],'MSIE')) if (PMA_getenv('HTTP_USER_AGENT') and strpos(PMA_getenv('HTTP_USER_AGENT'), 'MSIE')) { Header('Content-Type: application/force-download'); } else { Header('Content-Type: application/octet-stream'); } if (headers_sent()) { $this->Error('Some data has already been output to browser, can\'t send PDF file'); } Header('Content-Length: ' . strlen($this->buffer)); Header('Content-disposition: attachment; filename="' . $name . '"'); echo $this->buffer; break; case 'F': //Save to local file $f = fopen($name, 'wb'); if (!$f) { $this->Error('Unable to create output file: ' . $name); } fwrite($f, $this->buffer, strlen($this->buffer)); fclose($f); break; case 'S': //Return as a string return $this->buffer; default: $this->Error('Incorrect output destination: ' . $dest); } return ''; }
/** * Gets the "true" IP address of the current user * * @return string the ip of the user * * @access private */ function PMA_getIp() { /* Get the address of user */ if (empty($_SERVER['REMOTE_ADDR'])) { /* We do not know remote IP */ return false; } $direct_ip = $_SERVER['REMOTE_ADDR']; /* Do we trust this IP as a proxy? If yes we will use it's header. */ if (!isset($GLOBALS['cfg']['TrustedProxies'][$direct_ip])) { /* Return true IP */ return $direct_ip; } /** * Parse header in form: * X-Forwarded-For: client, proxy1, proxy2 */ // Get header content $value = PMA_getenv($GLOBALS['cfg']['TrustedProxies'][$direct_ip]); // Grab first element what is client adddress $value = explode(',', $value)[0]; // checks that the header contains only one IP address, $is_ip = filter_var($value, FILTER_VALIDATE_IP); if ($is_ip !== false) { // True IP behind a proxy return $value; } // We could not parse header return false; }
var topdomain = top.document.domain; // double-check just for sure if (topdomain != self.document.domain) { alert("Redirecting..."); top.location.replace(self.document.URL.substring(0, self.document.URL.lastIndexOf("/")+1)); } } catch(e) { alert("Redirecting... (error: " + e); top.location.replace(self.document.URL.substring(0, self.document.URL.lastIndexOf("/")+1)); } </script> <?php } // generate title $title = str_replace(array('@HTTP_HOST@', '@SERVER@', '@VERBOSE@', '@VSERVER@', '@DATABASE@', '@TABLE@', '@PHPMYADMIN@'), array(PMA_getenv('HTTP_HOST') ? PMA_getenv('HTTP_HOST') : '', isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : '', isset($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : '', !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : (isset($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['Server']['host'] : ''), $GLOBALS['db'], $GLOBALS['table'], 'phpMyAdmin ' . PMA_VERSION), !empty($GLOBALS['table']) ? $GLOBALS['cfg']['TitleTable'] : (!empty($GLOBALS['db']) ? $GLOBALS['cfg']['TitleDatabase'] : (!empty($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['TitleServer'] : $GLOBALS['cfg']['TitleDefault']))); // here, the function does not exist with this configuration: $cfg['ServerDefault'] = 0; $is_superuser = function_exists('PMA_isSuperuser') && PMA_isSuperuser(); if (in_array('functions.js', $GLOBALS['js_include'])) { $GLOBALS['js_messages']['strFormEmpty'] = $GLOBALS['strFormEmpty']; $GLOBALS['js_messages']['strNotNumber'] = $GLOBALS['strNotNumber']; if (!$is_superuser && !$GLOBALS['cfg']['AllowUserDropDatabase']) { $GLOBALS['js_messages']['strNoDropDatabases'] = $GLOBALS['strNoDropDatabases']; } else { $GLOBALS['js_messages']['strNoDropDatabases'] = ''; } if ($GLOBALS['cfg']['Confirm']) { $GLOBALS['js_messages']['strDoYouReally'] = $GLOBALS['strDoYouReally']; $GLOBALS['js_messages']['strDropDatabaseStrongWarning'] = $GLOBALS['strDropDatabaseStrongWarning']; // rajk - for blobstreaming $GLOBALS['js_messages']['strBLOBRepositoryDisableStrongWarning'] = $GLOBALS['strBLOBRepositoryDisableStrongWarning'];
/** * Detects whether https appears to be used. * * Please note that this just detects what we see, so * it completely ignores things like reverse proxies. */ function detectHttps() { $is_https = false; $url = array(); // At first we try to parse REQUEST_URI, it might contain full URL, if (PMA_getenv('REQUEST_URI')) { $url = @parse_url(PMA_getenv('REQUEST_URI')); // produces E_WARNING if it cannot get parsed, e.g. '/foobar:/' if ($url === false) { $url = array(); } } // If we don't have scheme, we didn't have full URL so we need to // dig deeper if (empty($url['scheme'])) { // Scheme if (PMA_getenv('HTTP_SCHEME')) { $url['scheme'] = PMA_getenv('HTTP_SCHEME'); } else { $url['scheme'] = PMA_getenv('HTTPS') && strtolower(PMA_getenv('HTTPS')) != 'off' ? 'https' : 'http'; } } if (isset($url['scheme']) && $url['scheme'] == 'https') { $is_https = true; } else { $is_https = false; } return $is_https; }
/** * Runs through IP Allow/Deny rules the use of it below for more information * * @param string $type 'allow' | 'deny' type of rule to match * * @return bool Matched a rule ? * * @access public * * @see PMA_getIp() */ function PMA_allowDeny($type) { global $cfg; // Grabs true IP of the user and returns if it can't be found $remote_ip = PMA_getIp(); if (empty($remote_ip)) { return false; } // copy username $username = $cfg['Server']['user']; // copy rule database $rules = $cfg['Server']['AllowDeny']['rules']; // lookup table for some name shortcuts $shortcuts = array('all' => '0.0.0.0/0', 'localhost' => '127.0.0.1/8'); // Provide some useful shortcuts if server gives us address: if (PMA_getenv('SERVER_ADDR')) { $shortcuts['localnetA'] = PMA_getenv('SERVER_ADDR') . '/8'; $shortcuts['localnetB'] = PMA_getenv('SERVER_ADDR') . '/16'; $shortcuts['localnetC'] = PMA_getenv('SERVER_ADDR') . '/24'; } foreach ($rules as $rule) { // extract rule data $rule_data = explode(' ', $rule); // check for rule type if ($rule_data[0] != $type) { continue; } // check for username if ($rule_data[1] != '%' && $rule_data[1] != $username) { continue; } // check if the config file has the full string with an extra // 'from' in it and if it does, just discard it if ($rule_data[2] == 'from') { $rule_data[2] = $rule_data[3]; } // Handle shortcuts with above array if (isset($shortcuts[$rule_data[2]])) { $rule_data[2] = $shortcuts[$rule_data[2]]; } // Add code for host lookups here // Excluded for the moment // Do the actual matching now if (PMA_ipMaskTest($rule_data[2], $remote_ip)) { return true; } } // end while return false; }
* Include URL/hidden inputs generating. */ include_once './libraries/url_generating.lib.php'; /** * Used to generate the page */ include_once 'libraries/Response.class.php'; } /******************************************************************************/ /* start procedural code label_start_procedural */ /** * PATH_INFO could be compromised if set, so remove it from PHP_SELF * and provide a clean PHP_SELF here */ $PMA_PHP_SELF = PMA_getenv('PHP_SELF'); $_PATH_INFO = PMA_getenv('PATH_INFO'); if (!empty($_PATH_INFO) && !empty($PMA_PHP_SELF)) { $path_info_pos = mb_strrpos($PMA_PHP_SELF, $_PATH_INFO); $pathLength = $path_info_pos + mb_strlen($_PATH_INFO); if ($pathLength === mb_strlen($PMA_PHP_SELF)) { $PMA_PHP_SELF = mb_substr($PMA_PHP_SELF, 0, $path_info_pos); } } $PMA_PHP_SELF = htmlspecialchars($PMA_PHP_SELF); /** * just to be sure there was no import (registering) before here * we empty the global space (but avoid unsetting $variables_list * and $key in the foreach (), we still need them!) */ $variables_whitelist = array('GLOBALS', '_SERVER', '_GET', '_POST', '_REQUEST', '_FILES', '_ENV', '_COOKIE', '_SESSION', 'error_handler', 'PMA_PHP_SELF', 'variables_whitelist', 'key', 'PMA_String'); foreach (get_defined_vars() as $key => $value) {
*/ if (!defined('PHPMYADMIN')) { exit; } use phpseclib\Crypt; /* Get the authentication interface */ require_once 'libraries/plugins/AuthenticationPlugin.class.php'; /** * Remember where to redirect the user * in case of an expired session. */ if (!empty($_REQUEST['target'])) { $GLOBALS['target'] = $_REQUEST['target']; } else { if (PMA_getenv('SCRIPT_NAME')) { $GLOBALS['target'] = basename(PMA_getenv('SCRIPT_NAME')); } } /** * Swekey authentication functions. */ require './libraries/plugins/auth/swekey/swekey.auth.lib.php'; /** * phpseclib */ if (!function_exists('openssl_encrypt') || !function_exists('openssl_decrypt') || !function_exists('openssl_random_pseudo_bytes') || PHP_VERSION_ID < 50304) { include PHPSECLIB_INC_DIR . '/Crypt/Base.php'; include PHPSECLIB_INC_DIR . '/Crypt/Rijndael.php'; include PHPSECLIB_INC_DIR . '/Crypt/AES.php'; include PHPSECLIB_INC_DIR . '/Crypt/Random.php'; }