示例#1
0
 public function getServerInfo(array $options = array())
 {
     $context = $this->container->getWordPressContext();
     return array('phpVersion' => PHP_VERSION, 'mysqlVersion' => $context->getDb()->db_version(), 'extensionPdoMysql' => extension_loaded('pdo_mysql'), 'extensionOpenSsl' => extension_loaded('openssl'), 'extensionFtp' => extension_loaded('ftp'), 'extensionZlib' => extension_loaded('zlib'), 'extensionBz2' => extension_loaded('bz2'), 'extensionZip' => extension_loaded('zip'), 'extensionCurl' => extension_loaded('curl'), 'extensionGd' => extension_loaded('gd'), 'extensionImagick' => extension_loaded('imagick'), 'extensionSockets' => extension_loaded('sockets'), 'extensionSsh2' => extension_loaded('ssh2'), 'shellAvailable' => mwp_is_shell_available(), 'safeMode' => mwp_is_safe_mode(), 'memoryLimit' => mwp_format_memory_limit(ini_get('memory_limit')), 'disabledFunctions' => mwp_get_disabled_functions(), 'processArchitecture' => strlen(decbin(~0)), 'internalIp' => $this->container->getRequestStack()->getMasterRequest()->server['SERVER_ADDR'], 'uname' => php_uname('a'), 'hostname' => php_uname('n'), 'os' => strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? 'windows' : 'unix');
 }
示例#2
0
 /**
  * Returns all important information of worker's system status to master.
  *
  * @return mixed associative array with information of server OS, php version, is backup folder writable, execute function, zip and unzip command, execution time, memory limit and path to error log if exists
  */
 public function check_backup_compat()
 {
     $reqs = array();
     if (strpos($_SERVER['DOCUMENT_ROOT'], '/') === 0) {
         $reqs['Server OS']['status'] = 'Linux (or compatible)';
         $reqs['Server OS']['pass'] = true;
     } else {
         $reqs['Server OS']['status'] = 'Windows';
         $reqs['Server OS']['pass'] = true;
         $pass = false;
     }
     $reqs['Process architecture']['status'] = '64bit';
     $reqs['Process architecture']['pass'] = true;
     if ($this->is32Bits()) {
         $reqs['Process architecture']['status'] = '';
         $reqs['Process architecture']['info'] = '32bit';
         $reqs['Process architecture']['pass'] = false;
     }
     $reqs['PHP Version']['status'] = PHP_VERSION;
     if (version_compare(PHP_VERSION, '5.3', '>=')) {
         $reqs['PHP Version']['pass'] = true;
     } else {
         $reqs['PHP Version']['status'] = '';
         $reqs['PHP Version']['info'] = PHP_VERSION;
         $reqs['PHP Version']['pass'] = false;
         $pass = false;
     }
     if (mwp_is_safe_mode()) {
         $reqs['Safe Mode']['status'] = 'on';
         $reqs['Safe Mode']['pass'] = false;
     } else {
         $reqs['Safe Mode']['status'] = 'off';
         $reqs['Safe Mode']['pass'] = true;
     }
     if (is_writable(WP_CONTENT_DIR)) {
         $reqs['Backup Folder']['status'] = "writable";
         $reqs['Backup Folder']['pass'] = true;
     } else {
         $reqs['Backup Folder']['status'] = "not writable";
         $reqs['Backup Folder']['pass'] = false;
     }
     if (is_writable(ABSPATH)) {
         $reqs['Root Folder']['status'] = "writable";
         $reqs['Root Folder']['pass'] = true;
     } else {
         $reqs['Root Folder']['status'] = "not writable";
         $reqs['Root Folder']['pass'] = false;
     }
     $file_path = MWP_BACKUP_DIR;
     $reqs['Backup Folder']['status'] .= ' (' . $file_path . ')';
     $reqs['Function `proc_open`']['status'] = 'exists';
     $reqs['Function `proc_open`']['pass'] = true;
     if (!$this->procOpenExists()) {
         $reqs['Function `proc_open`']['status'] = "not found";
         $reqs['Function `proc_open`']['pass'] = false;
     }
     $reqs['Zip']['status'] = 'exists';
     $reqs['Zip']['pass'] = true;
     if (!$this->zipExists()) {
         $reqs['Zip']['status'] = 'not found';
         //$reqs['Zip']['info']   = 'We\'ll use ZipArchive replacement';
         $reqs['Zip']['pass'] = false;
         $reqs['ZipArchive']['status'] = 'exists';
         $reqs['ZipArchive']['pass'] = true;
         if (!class_exists('ZipArchive')) {
             $reqs['ZipArchive']['status'] = 'not found';
             $reqs['ZipArchive']['info'] = 'We\'ll use PclZip replacement (PclZip takes up the memory that is equal to size of your site)';
             $reqs['ZipArchive']['pass'] = false;
         }
     }
     $reqs['Unzip']['status'] = 'exists';
     $reqs['Unzip']['pass'] = true;
     if (!$this->unzipExists()) {
         $reqs['Unzip']['status'] = 'not found';
         $reqs['Unzip']['info'] = 'We\'ll use PclZip replacement (PclZip takes up the memory that is equal to size of your site)';
         $reqs['Unzip']['pass'] = false;
     }
     $reqs['MySQL Dump']['status'] = 'exists';
     $reqs['MySQL Dump']['pass'] = true;
     if (!$this->mySqlDumpExists()) {
         $reqs['MySQL Dump']['status'] = "not found";
         $reqs['MySQL Dump']['info'] = "(we'll use PHP replacement)";
         $reqs['MySQL Dump']['pass'] = false;
     }
     $reqs['MySQL']['status'] = 'exists';
     $reqs['MySQL']['pass'] = true;
     if (!$this->mySqlExists()) {
         $reqs['MySQL']['status'] = "not found";
         $reqs['MySQL']['info'] = "(we'll use PHP replacement)";
         $reqs['MySQL']['pass'] = false;
     }
     $reqs['Curl']['status'] = 'not found';
     $reqs['Curl']['pass'] = false;
     if (function_exists('curl_init') && function_exists('curl_exec')) {
         $reqs['Curl']['status'] = 'exists';
         $reqs['Curl']['pass'] = true;
     }
     $exec_time = ini_get('max_execution_time');
     $exec_unlimited = $exec_time === '0';
     $reqs['PHP Execution time']['status'] = $exec_unlimited ? 'unlimited' : ($exec_time ? $exec_time . "s" : 'unknown');
     $reqs['PHP Execution time']['pass'] = true;
     $mem_limit = ini_get('memory_limit');
     $mem_limit = mwp_format_memory_limit($mem_limit);
     $reqs['PHP Memory limit']['status'] = $mem_limit ? $mem_limit : 'unknown';
     $reqs['PHP Memory limit']['pass'] = true;
     $changed = $this->set_memory();
     if ($changed['execution_time']) {
         $exec_time = ini_get('max_execution_time');
         $reqs['PHP Execution time']['status'] .= $exec_time ? ' (will try ' . $exec_time . 's)' : ' (unknown)';
     }
     if ($changed['memory_limit']) {
         $mem_limit = ini_get('memory_limit');
         $mem_limit = mwp_format_memory_limit($mem_limit);
         $reqs['PHP Memory limit']['status'] .= $mem_limit ? ' (will try ' . $mem_limit . ')' : ' (unknown)';
     }
     $reqs['Worker Version']['status'] = $GLOBALS['MMB_WORKER_VERSION'];
     $reqs['Worker Version']['pass'] = true;
     $reqs['Worker Revision']['status'] = $GLOBALS['MMB_WORKER_REVISION'];
     $reqs['Worker Revision']['pass'] = true;
     return $reqs;
 }