示例#1
0
 /**
  * Get system information
  */
 public static function getSystemInformation()
 {
     global $piwik_minimumPHPVersion;
     $minimumMemoryLimit = Config::getInstance()->General['minimum_memory_limit'];
     $infos = array();
     $infos['general_infos'] = array();
     $directoriesToCheck = array();
     if (!DbHelper::isInstalled()) {
         // at install, need /config to be writable (so we can create config.ini.php)
         $directoriesToCheck[] = '/config/';
     }
     $directoriesToCheck = array_merge($directoriesToCheck, array('/tmp/', '/tmp/assets/', '/tmp/cache/', '/tmp/latest/', '/tmp/logs/', '/tmp/sessions/', '/tmp/tcpdf/', '/tmp/templates_c/'));
     $infos['directories'] = Filechecks::checkDirectoriesWritable($directoriesToCheck);
     $infos['can_auto_update'] = Filechecks::canAutoUpdate();
     self::initServerFilesForSecurity();
     $infos['phpVersion_minimum'] = $piwik_minimumPHPVersion;
     $infos['phpVersion'] = PHP_VERSION;
     $infos['phpVersion_ok'] = version_compare($piwik_minimumPHPVersion, $infos['phpVersion']) === -1;
     // critical errors
     $extensions = @get_loaded_extensions();
     $needed_extensions = array('zlib', 'SPL', 'iconv', 'Reflection');
     $infos['needed_extensions'] = $needed_extensions;
     $infos['missing_extensions'] = array();
     foreach ($needed_extensions as $needed_extension) {
         if (!in_array($needed_extension, $extensions)) {
             $infos['missing_extensions'][] = $needed_extension;
         }
     }
     $infos['pdo_ok'] = false;
     if (in_array('PDO', $extensions)) {
         $infos['pdo_ok'] = true;
     }
     $infos['adapters'] = Adapter::getAdapters();
     $needed_functions = array('debug_backtrace', 'create_function', 'eval', 'gzcompress', 'gzuncompress', 'pack');
     $infos['needed_functions'] = $needed_functions;
     $infos['missing_functions'] = array();
     foreach ($needed_functions as $needed_function) {
         if (!self::functionExists($needed_function)) {
             $infos['missing_functions'][] = $needed_function;
         }
     }
     // warnings
     $desired_extensions = array('json', 'libxml', 'dom', 'SimpleXML');
     $infos['desired_extensions'] = $desired_extensions;
     $infos['missing_desired_extensions'] = array();
     foreach ($desired_extensions as $desired_extension) {
         if (!in_array($desired_extension, $extensions)) {
             $infos['missing_desired_extensions'][] = $desired_extension;
         }
     }
     $desired_functions = array('set_time_limit', 'mail', 'parse_ini_file', 'glob');
     $infos['desired_functions'] = $desired_functions;
     $infos['missing_desired_functions'] = array();
     foreach ($desired_functions as $desired_function) {
         if (!self::functionExists($desired_function)) {
             $infos['missing_desired_functions'][] = $desired_function;
         }
     }
     $infos['openurl'] = Http::getTransportMethod();
     $infos['gd_ok'] = SettingsServer::isGdExtensionEnabled();
     $infos['hasMbstring'] = false;
     $infos['multibyte_ok'] = true;
     if (function_exists('mb_internal_encoding')) {
         $infos['hasMbstring'] = true;
         if ((int) ini_get('mbstring.func_overload') != 0) {
             $infos['multibyte_ok'] = false;
         }
     }
     $serverSoftware = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '';
     $infos['serverVersion'] = addslashes($serverSoftware);
     $infos['serverOs'] = @php_uname();
     $infos['serverTime'] = date('H:i:s');
     $infos['registerGlobals_ok'] = ini_get('register_globals') == 0;
     $infos['memoryMinimum'] = $minimumMemoryLimit;
     $infos['memory_ok'] = true;
     $infos['memoryCurrent'] = '';
     $raised = SettingsServer::raiseMemoryLimitIfNecessary();
     if (($memoryValue = SettingsServer::getMemoryLimitValue()) > 0) {
         $infos['memoryCurrent'] = $memoryValue . 'M';
         $infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit;
     }
     $infos['isWindows'] = SettingsServer::isWindows();
     $integrityInfo = Filechecks::getFileIntegrityInformation();
     $infos['integrity'] = $integrityInfo[0];
     $infos['integrityErrorMessages'] = array();
     if (isset($integrityInfo[1])) {
         if ($infos['integrity'] == false) {
             $infos['integrityErrorMessages'][] = Piwik::translate('General_FileIntegrityWarningExplanation');
         }
         $infos['integrityErrorMessages'] = array_merge($infos['integrityErrorMessages'], array_slice($integrityInfo, 1));
     }
     $infos['timezone'] = SettingsServer::isTimezoneSupportEnabled();
     $infos['tracker_status'] = Common::getRequestVar('trackerStatus', 0, 'int');
     $infos['protocol'] = ProxyHeaders::getProtocolInformation();
     if (!\Piwik\ProxyHttp::isHttps() && $infos['protocol'] !== null) {
         $infos['general_infos']['assume_secure_protocol'] = '1';
     }
     if (count($headers = ProxyHeaders::getProxyClientHeaders()) > 0) {
         $infos['general_infos']['proxy_client_headers'] = $headers;
     }
     if (count($headers = ProxyHeaders::getProxyHostHeaders()) > 0) {
         $infos['general_infos']['proxy_host_headers'] = $headers;
     }
     // check if filesystem is NFS, if it is file based sessions won't work properly
     $infos['is_nfs'] = Filesystem::checkIfFileSystemIsNFS();
     $infos = self::enrichSystemChecks($infos);
     return $infos;
 }
示例#2
0
 /**
  * Write configuration file from session-store
  */
 private function createConfigFile($dbInfos)
 {
     $config = Config::getInstance();
     // make sure DB sessions are used if the filesystem is NFS
     if (Filesystem::checkIfFileSystemIsNFS()) {
         $config->General['session_save_handler'] = 'dbtable';
     }
     if (count($headers = ProxyHeaders::getProxyClientHeaders()) > 0) {
         $config->General['proxy_client_headers'] = $headers;
     }
     if (count($headers = ProxyHeaders::getProxyHostHeaders()) > 0) {
         $config->General['proxy_host_headers'] = $headers;
     }
     if (Common::getRequestVar('clientProtocol', 'http', 'string') == 'https') {
         $protocol = 'https';
     } else {
         $protocol = ProxyHeaders::getProtocolInformation();
     }
     if (!empty($protocol) && !\Piwik\ProxyHttp::isHttps()) {
         $config->General['assume_secure_protocol'] = '1';
     }
     $config->General['salt'] = Common::generateUniqId();
     $config->General['installation_in_progress'] = 1;
     $config->database = $dbInfos;
     if (!DbHelper::isDatabaseConnectionUTF8()) {
         $config->database['charset'] = 'utf8';
     }
     $config->forceSave();
 }
示例#3
0
 /**
  * Write configuration file from session-store
  */
 private function createConfigFile($dbInfos)
 {
     $config = Config::getInstance();
     // make sure DB sessions are used if the filesystem is NFS
     if (Filesystem::checkIfFileSystemIsNFS()) {
         $config->General['session_save_handler'] = 'dbtable';
     }
     if (count($headers = ProxyHeaders::getProxyClientHeaders()) > 0) {
         $config->General['proxy_client_headers'] = $headers;
     }
     if (count($headers = ProxyHeaders::getProxyHostHeaders()) > 0) {
         $config->General['proxy_host_headers'] = $headers;
     }
     if (Common::getRequestVar('clientProtocol', 'http', 'string') == 'https') {
         $protocol = 'https';
     } else {
         $protocol = ProxyHeaders::getProtocolInformation();
     }
     if (!empty($protocol) && !\Piwik\ProxyHttp::isHttps()) {
         $config->General['assume_secure_protocol'] = '1';
     }
     $config->General['salt'] = Common::generateUniqId();
     $config->General['installation_in_progress'] = 1;
     $config->database = $dbInfos;
     if (!DbHelper::isDatabaseConnectionUTF8()) {
         $config->database['charset'] = 'utf8';
     }
     # Improved Security with IBM Bluemix
     # With SSL ALWAYS available for all Bluemix apps, let's require all requests
     # to be made over SSL (https) so that data is NOT sent in the clear.
     # Non-ssl requests will trigger a
     #    Error: Form security failed.
     #    Please reload the form and check that your cookies are enabled
     # Reference: http://piwik.org/faq/how-to/faq_91/
     # Reference: https://developer.ibm.com/answers/questions/8312/how-do-i-enable-tlsssl-for-my-bluemix-application/
     $config->General['assume_secure_protocol'] = 1;
     $config->General['force_ssl'] = 1;
     # Setup proxy_client_headers to accurately detect GeoIPs of visiting clients
     $config->General['proxy_client_headers'] = array("HTTP_X_CLIENT_IP", "HTTP_X_FORWARDED_FOR", "HTTP_X_CLUSTER_CLIENT_IP", "HTTP_CLIENT_IP");
     $config->General['proxy_host_headers'] = "HTTP_X_FORWARDED_HOST";
     # Implement some default settings that optimize performance
     $config->General['enabled_periods_UI'] = "day,week,month,year";
     $config->General['enabled_periods_API'] = "day,week,month,year";
     $config->General['action_category_level_limit'] = 3;
     $config->General['show_multisites_sparklines'] = 0;
     $config->General['anonymous_user_enable_use_segments_API'] = 0;
     $config->General['browser_archiving_disabled_enforce'] = 1;
     $config->General['enable_create_realtime_segments'] = 0;
     $config->General['enable_segment_suggested_values'] = 0;
     $config->General['adding_segment_requires_access'] = "superuser";
     $config->General['allow_adding_segments_for_all_websites'] = 0;
     $config->General['datatable_row_limits'] = "5,10,25,50";
     $config->General['enable_browser_archiving_triggering'] = 0;
     $config->General['multisites_refresh_after_seconds'] = 0;
     $config->General['enable_delete_old_data_settings_admin'] = 0;
     $config->General['enable_auto_update'] = 0;
     $config->Debug['enable_measure_piwik_usage_in_idsite'] = 0;
     $config->Debug['allow_upgrades_to_beta'] = 0;
     $config->Tracker['new_visit_api_requires_admin'] = 0;
     # Let us have this Piwik deploy track itself to get some early data and success :-)
     # $config->Debug['enable_measure_piwik_usage_in_idsite'] = 1;
     # Emailing the easy way with IBM Bluemix + the SendGrid Service
     if (isset($_ENV["REDISHOSTNAME"])) {
         $config->RedisCache['host'] = $_ENV["REDISHOSTNAME"];
         $config->RedisCache['port'] = $_ENV["REDISPORT"];
         $config->RedisCache['timeout'] = 0.0;
         $config->RedisCache['password'] = $_ENV["REDISPASSWORD"];
         $config->RedisCache['database'] = 14;
         $config->ChainedCache['backends'] = array("array", "redis");
     }
     # Let's setup the config files trusted hosts entries to handle
     # 1...N amount of user-defined IBM Bluemix app routes
     if (isset($_ENV["APPURIS"])) {
         foreach ($_ENV["APPURIS"] as $application_uri) {
             $this->addTrustedHosts("https://" . $application_uri);
         }
     }
     # Emailing the easy way with IBM Bluemix + the SendGrid Service
     if (isset($_ENV["MAILHOST"])) {
         $config->mail['transport'] = "smtp";
         $config->mail['port'] = 587;
         $config->mail['type'] = "Plain";
         $config->mail['host'] = $_ENV["MAILHOST"];
         $config->mail['username'] = $_ENV["MAILUSER"];
         $config->mail['password'] = $_ENV["MAILPASSWORD"];
     }
     $config->forceSave();
     // re-save the currently viewed language (since we saved the config file, there is now a salt which makes the
     // existing session cookie invalid)
     $this->resetLanguageCookie();
 }