Outputs results to message list, must be called between PMA_messagesBegin() and PMA_messagesEnd()
示例#1
0
$all_languages = LanguageManager::getInstance()->sortedLanguages();
/** @var ConfigFile $cf */
$cf = $GLOBALS['ConfigFile'];
$separator = URL::getArgSeparator('html');
// message handling
PMA_messagesBegin();
//
// Check phpMyAdmin version
//
if (isset($_GET['version_check'])) {
    PMA_versionCheck();
}
//
// Perform various security, compatibility and consistency checks
//
$configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
$configChecker->performConfigChecks();
//
// Check whether we can read/write configuration
//
$config_readable = false;
$config_writable = false;
$config_exists = false;
PMA_checkConfigRw($config_readable, $config_writable, $config_exists);
if (!$config_writable || !$config_readable) {
    PMA_messagesSet('error', 'config_rw', __('Cannot load or save configuration'), Sanitize::sanitize(__('Please create web server writable folder [em]config[/em] in ' . 'phpMyAdmin top level directory as described in ' . '[doc@setup_script]documentation[/doc]. Otherwise you will be ' . 'only able to download or display it.')));
}
//
// Check https connection
//
$is_https = !empty($_SERVER['HTTPS']) && mb_strtolower($_SERVER['HTTPS']) == 'on';
 /**
  * Test for ServerConfigChecks::performConfigChecks
  *
  * @return void
  * @group medium
  */
 public function testServerConfigChecksPerformConfigChecks()
 {
     $GLOBALS['cfg']['AvailableCharsets'] = array();
     $GLOBALS['cfg']['ServerDefault'] = 0;
     $GLOBALS['server'] = 0;
     $cf = new ConfigFile();
     $GLOBALS['ConfigFile'] = $cf;
     $reflection = new \ReflectionProperty('PMA\\libraries\\config\\ConfigFile', '_id');
     $reflection->setAccessible(true);
     $sessionID = $reflection->getValue($cf);
     $_SESSION[$sessionID]['Servers'] = array('1' => array('host' => 'localhost', 'ssl' => false, 'extension' => 'mysql', 'auth_type' => 'config', 'user' => 'username', 'password' => 'password', 'AllowRoot' => true, 'AllowNoPassword' => true));
     $_SESSION[$sessionID]['ForceSSL'] = false;
     $_SESSION[$sessionID]['AllowArbitraryServer'] = true;
     $_SESSION[$sessionID]['LoginCookieValidity'] = 5000;
     $_SESSION[$sessionID]['LoginCookieStore'] = 4000;
     $_SESSION[$sessionID]['SaveDir'] = true;
     $_SESSION[$sessionID]['TempDir'] = true;
     $_SESSION[$sessionID]['GZipDump'] = true;
     $_SESSION[$sessionID]['BZipDump'] = true;
     $_SESSION[$sessionID]['ZipDump'] = true;
     $noticeArrayKeys = array('TempDir', 'SaveDir', 'LoginCookieValidity', 'AllowArbitraryServer', 'ForceSSL', 'Servers/1/AllowNoPassword', 'Servers/1/auth_type', 'Servers/1/ssl');
     $errorArrayKeys = array('LoginCookieValidity');
     if (@(!function_exists('gzopen')) || @(!function_exists('gzencode'))) {
         $errorArrayKeys[] = 'GZipDump';
     }
     if (@(!function_exists('bzopen')) || @(!function_exists('bzcompress'))) {
         $errorArrayKeys[] = 'BZipDump';
     }
     if (!@function_exists('zip_open')) {
         $errorArrayKeys[] = 'ZipDump_import';
     }
     if (!@function_exists('gzcompress')) {
         $errorArrayKeys[] = 'ZipDump_export';
     }
     $configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
     $configChecker->performConfigChecks();
     foreach ($noticeArrayKeys as $noticeKey) {
         $this->assertArrayHasKey($noticeKey, $_SESSION['messages']['notice']);
     }
     foreach ($errorArrayKeys as $errorKey) {
         $this->assertArrayHasKey($errorKey, $_SESSION['messages']['error']);
     }
     // Case 2
     unset($_SESSION['messages']);
     unset($_SESSION[$sessionID]);
     $_SESSION[$sessionID]['Servers'] = array('1' => array('host' => 'localhost', 'ssl' => true, 'extension' => 'mysqli', 'auth_type' => 'cookie', 'AllowRoot' => false));
     $_SESSION[$sessionID]['ForceSSL'] = true;
     $_SESSION[$sessionID]['AllowArbitraryServer'] = false;
     $_SESSION[$sessionID]['LoginCookieValidity'] = -1;
     $_SESSION[$sessionID]['LoginCookieStore'] = 0;
     $_SESSION[$sessionID]['SaveDir'] = '';
     $_SESSION[$sessionID]['TempDir'] = '';
     $_SESSION[$sessionID]['GZipDump'] = false;
     $_SESSION[$sessionID]['BZipDump'] = false;
     $_SESSION[$sessionID]['ZipDump'] = false;
     $configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
     $configChecker->performConfigChecks();
     $this->assertArrayHasKey('blowfish_secret_created', $_SESSION['messages']['notice']);
     foreach ($noticeArrayKeys as $noticeKey) {
         $this->assertArrayNotHasKey($noticeKey, $_SESSION['messages']['notice']);
     }
     $this->assertArrayNotHasKey('error', $_SESSION['messages']);
     // Case 3
     $_SESSION[$sessionID]['blowfish_secret'] = 'sec';
     $_SESSION[$sessionID]['Servers'] = array('1' => array('host' => 'localhost', 'auth_type' => 'cookie'));
     $configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
     $configChecker->performConfigChecks();
     $this->assertArrayHasKey('blowfish_warnings2', $_SESSION['messages']['error']);
 }