/** * Get system information */ public static function getSystemInformation() { global $piwik_minimumPHPVersion; $minimumMemoryLimit = Zend_Registry::get('config')->General->minimum_memory_limit; $infos = array(); $infos['general_infos'] = array(); $infos['directories'] = Piwik::checkDirectoriesWritable(); $infos['can_auto_update'] = Piwik::canAutoUpdate(); if(Piwik_Common::isIIS()) { Piwik::createWebConfigFiles(); } else { Piwik::createHtAccessFiles(); } Piwik::createWebRootFiles(); $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'] = Piwik_Db_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'] = Piwik_Http::getTransportMethod(); $infos['gd_ok'] = false; if (in_array('gd', $extensions)) { $gdInfo = gd_info(); $infos['gd_version'] = $gdInfo['GD Version']; preg_match('/([0-9]{1})/', $gdInfo['GD Version'], $gdVersion); if($gdVersion[0] >= 2) { $infos['gd_ok'] = true; } } $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 = Piwik::raiseMemoryLimitIfNecessary(); if(($memoryValue = Piwik::getMemoryLimitValue()) > 0) { $infos['memoryCurrent'] = $memoryValue.'M'; $infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit; } $infos['isWindows'] = Piwik_Common::isWindows(); $integrityInfo = Piwik::getFileIntegrityInformation(); $infos['integrity'] = $integrityInfo[0]; $infos['integrityErrorMessages'] = array(); if(isset($integrityInfo[1])) { if($infos['integrity'] == false) { $infos['integrityErrorMessages'][] = '<b>'.Piwik_Translate('General_FileIntegrityWarningExplanation').'</b>'; } $infos['integrityErrorMessages'] = array_merge($infos['integrityErrorMessages'], array_slice($integrityInfo, 1)); } $infos['timezone'] = Piwik::isTimezoneSupportEnabled(); $infos['tracker_status'] = Piwik_Common::getRequestVar('trackerStatus', 0, 'int'); $infos['protocol'] = Piwik_ProxyHeaders::getProtocolInformation(); if(Piwik_Url::getCurrentScheme() == 'http' && $infos['protocol'] !== null) { $infos['general_infos']['secure_protocol'] = '1'; } if(count($headers = Piwik_ProxyHeaders::getProxyClientHeaders()) > 0) { $infos['general_infos']['proxy_client_headers'] = $headers; } if(count($headers = Piwik_ProxyHeaders::getProxyHostHeaders()) > 0) { $infos['general_infos']['proxy_host_headers'] = $headers; } return $infos; }
/** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. */ function init() { static $initialized = false; if($initialized) { return; } $initialized = true; try { Zend_Registry::set('timer', new Piwik_Timer); $directoriesToCheck = array( '/tmp/', '/tmp/templates_c/', '/tmp/cache/', '/tmp/assets/' ); Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); Piwik_Common::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); $exceptionToThrow = false; try { Piwik::createConfigObject(); } catch(Exception $e) { Piwik_PostEvent('FrontController.NoConfigurationFile', $e, $info = array(), $pending = true); $exceptionToThrow = $e; } if(Zend_Registry::get('config')->General->maintenance_mode == 1 && !Piwik_Common::isPhpCliMode()) { throw new Exception("Piwik is in scheduled maintenance. Please come back later."); } $pluginsManager = Piwik_PluginsManager::getInstance(); $pluginsManager->loadPlugins( Zend_Registry::get('config')->Plugins->Plugins->toArray() ); if($exceptionToThrow) { throw $exceptionToThrow; } try { Piwik::createDatabaseObject(); } catch(Exception $e) { Piwik_PostEvent('FrontController.badConfigurationFile', $e, $info = array(), $pending = true); throw $e; } Piwik::createLogObject(); // creating the access object, so that core/Updates/* can enforce Super User and use some APIs Piwik::createAccessObject(); Piwik_PostEvent('FrontController.dispatchCoreAndPluginUpdatesScreen'); Piwik_PluginsManager::getInstance()->installLoadedPlugins(); Piwik::install(); // ensure the current Piwik URL is known for later use if(method_exists('Piwik', 'getPiwikUrl')) { $host = Piwik::getPiwikUrl(); } Piwik_PostEvent('FrontController.initAuthenticationObject'); try { $authAdapter = Zend_Registry::get('auth'); } catch(Exception $e){ throw new Exception("Authentication object cannot be found in the Registry. Maybe the Login plugin is not activated? <br />You can activate the plugin by adding:<br /> <code>Plugins[] = Login</code><br /> under the <code>[Plugins]</code> section in your config/config.inc.php"); } Zend_Registry::get('access')->reloadAccess($authAdapter); Piwik_Translate::getInstance()->reloadLanguage(); Piwik::raiseMemoryLimitIfNecessary(); $pluginsManager->postLoadPlugins(); Piwik_PostEvent('FrontController.checkForUpdates'); } catch(Exception $e) { Piwik_ExitWithMessage($e->getMessage(), false, true); } Piwik::log('End FrontController->init() - Request: '. var_export($_REQUEST, true)); }
public static function getSystemInformation() { $minimumPhpVersion = Zend_Registry::get('config')->General->minimum_php_version; $minimumMemoryLimit = Zend_Registry::get('config')->General->minimum_memory_limit; $infos = array(); $infos['directories'] = Piwik::checkDirectoriesWritable(); $infos['phpVersion_minimum'] = $minimumPhpVersion; $infos['phpVersion'] = phpversion(); $infos['phpVersion_ok'] = version_compare( $minimumPhpVersion, $infos['phpVersion']) === -1; // critical errors $extensions = @get_loaded_extensions(); $needed_extensions = array( 'zlib', 'SPL', 'iconv', ); $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'] = Piwik_Db::getAdapters(); $infos['json'] = false; if(in_array('json', $extensions)) { $infos['json'] = true; } $infos['xml'] = false; if(in_array('xml', $extensions)) { $infos['xml'] = true; } // warnings $needed_functions = array( 'set_time_limit', 'mail', ); $infos['needed_functions'] = $needed_functions; $infos['missing_functions'] = array(); foreach($needed_functions as $needed_function) { if(!function_exists($needed_function)) { $infos['missing_functions'][] = $needed_function; } } $infos['openurl'] = Piwik::getTransportMethod(); $infos['gd_ok'] = false; if (in_array('gd', $extensions)) { $gdInfo = gd_info(); $infos['gd_version'] = $gdInfo['GD Version']; preg_match('/([0-9]{1})/', $gdInfo['GD Version'], $gdVersion); if($gdVersion[0] >= 2) { $infos['gd_ok'] = true; } } $infos['serverVersion'] = addslashes($_SERVER['SERVER_SOFTWARE']); $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; // on windows the ini_get is not working? $infos['memoryCurrent'] = '?M'; $raised = Piwik::raiseMemoryLimitIfNecessary(); if( $memoryValue = Piwik::getMemoryLimitValue() ) { $infos['memoryCurrent'] = $memoryValue.'M'; $infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit; } $infos['isWindows'] = substr(PHP_OS, 0, 3) == 'WIN'; $infos['protocol_ok'] = true; $infos['protocol'] = self::getProtocolInformation(); if(Piwik_Url::getCurrentScheme() == 'http' && $infos['protocol'] !== null) { $infos['protocol_ok'] = false; } return $infos; }
/** * Get system information */ public static function getSystemInformation() { $minimumPhpVersion = Zend_Registry::get('config')->General->minimum_php_version; $minimumMemoryLimit = Zend_Registry::get('config')->General->minimum_memory_limit; $infos = array(); $infos['directories'] = Piwik::checkDirectoriesWritable(); $infos['phpVersion_minimum'] = $minimumPhpVersion; $infos['phpVersion'] = phpversion(); $infos['phpVersion_ok'] = version_compare($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'] = Piwik_Db::getAdapters(); $infos['json'] = false; if (in_array('json', $extensions)) { $infos['json'] = true; } $infos['xml'] = false; if (in_array('xml', $extensions)) { $infos['xml'] = true; } $needed_functions = array('debug_backtrace', 'create_function'); $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_functions = array('set_time_limit', 'mail', 'parse_ini_file'); $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'] = Piwik::getTransportMethod(); $infos['gd_ok'] = false; if (in_array('gd', $extensions)) { $gdInfo = gd_info(); $infos['gd_version'] = $gdInfo['GD Version']; preg_match('/([0-9]{1})/', $gdInfo['GD Version'], $gdVersion); if ($gdVersion[0] >= 2) { $infos['gd_ok'] = true; } } $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; } } /** * @see http://php.net/ip2long */ $infos['isIpv4'] = true; if (strpos($_SERVER['REMOTE_ADDR'], ':') !== false) { $infos['isIpv4'] = false; } $infos['serverVersion'] = addslashes($_SERVER['SERVER_SOFTWARE']); $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; // on windows the ini_get is not working? $infos['memoryCurrent'] = '?M'; $raised = Piwik::raiseMemoryLimitIfNecessary(); if ($memoryValue = Piwik::getMemoryLimitValue()) { $infos['memoryCurrent'] = $memoryValue . 'M'; $infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit; } $infos['isWindows'] = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN'; $infos['protocol_ok'] = true; $infos['protocol'] = self::getProtocolInformation(); if (Piwik_Url::getCurrentScheme() == 'http' && $infos['protocol'] !== null) { $infos['protocol_ok'] = false; } $integrityInfo = Piwik::getFileIntegrityInformation(); $infos['integrity'] = $integrityInfo[0]; $infos['integrityErrorMessages'] = array(); if (isset($integrityInfo[1])) { $infos['integrityErrorMessages'][] = '<b>' . Piwik_Translate('General_FileIntegrityWarningExplanation') . '</b>'; $infos['integrityErrorMessages'] += array_splice($integrityInfo, 1); } return $infos; }
/** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. */ function init() { try { Zend_Registry::set('timer', new Piwik_Timer()); $directoriesToCheck = array('/tmp', '/tmp/templates_c', '/tmp/cache'); Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); self::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); $exceptionToThrow = false; try { Piwik::createConfigObject(); } catch (Exception $e) { Piwik_PostEvent('FrontController.NoConfigurationFile', $e); $exceptionToThrow = $e; } $pluginsManager = Piwik_PluginsManager::getInstance(); $pluginsManager->setPluginsToLoad(Zend_Registry::get('config')->Plugins->Plugins->toArray()); if ($exceptionToThrow) { throw $exceptionToThrow; } Piwik_Translate::getInstance()->loadUserTranslation(); try { Piwik::createDatabaseObject(); } catch (Exception $e) { Piwik_PostEvent('FrontController.badConfigurationFile', $e); throw $e; } Piwik::createLogObject(); // creating the access object, so that core/Updates/* can enforce Super User and use some APIs Piwik::createAccessObject(); Piwik_PostEvent('FrontController.dispatchCoreAndPluginUpdatesScreen'); Piwik_PluginsManager::getInstance()->installLoadedPlugins(); Piwik::install(); Piwik_PostEvent('FrontController.initAuthenticationObject'); try { $authAdapter = Zend_Registry::get('auth'); } catch (Exception $e) { throw new Exception("Authentication object cannot be found in the Registry. Maybe the Login plugin is not activated?\n\t\t\t\t\t\t\t\t\t<br>You can activate the plugin by adding:<br>\n\t\t\t\t\t\t\t\t\t<code>Plugins[] = Login</code><br>\n\t\t\t\t\t\t\t\t\tunder the <code>[Plugins]</code> section in your config/config.inc.php"); } Zend_Registry::get('access')->reloadAccess($authAdapter); Piwik::raiseMemoryLimitIfNecessary(); $pluginsManager->setLanguageToLoad(Piwik_Translate::getInstance()->getLanguageToLoad()); $pluginsManager->postLoadPlugins(); Piwik_PostEvent('FrontController.checkForUpdates'); } catch (Exception $e) { Piwik_ExitWithMessage($e->getMessage(), $e->getTraceAsString(), true); } }
/** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. */ function init() { static $initialized = false; if ($initialized) { return; } $initialized = true; try { Zend_Registry::set('timer', new Piwik_Timer()); $directoriesToCheck = array('/tmp/', '/tmp/templates_c/', '/tmp/cache/', '/tmp/assets/', '/tmp/tcpdf/'); Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); Piwik_Common::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); $exceptionToThrow = false; try { Piwik::createConfigObject(); } catch (Exception $e) { Piwik_PostEvent('FrontController.NoConfigurationFile', $e, $info = array(), $pending = true); $exceptionToThrow = $e; } if (Piwik_Session::isFileBasedSessions()) { Piwik_Session::start(); } if (Piwik_Config::getInstance()->General['maintenance_mode'] == 1 && !Piwik_Common::isPhpCliMode()) { $format = Piwik_Common::getRequestVar('format', ''); $exception = new Exception("Piwik is in scheduled maintenance. Please come back later."); if (empty($format)) { throw $exception; } $response = new Piwik_API_ResponseBuilder($format); echo $response->getResponseException($exception); exit; } if (!Piwik_Common::isPhpCliMode() && Piwik_Config::getInstance()->General['force_ssl'] == 1 && !Piwik::isHttps()) { $url = Piwik_Url::getCurrentUrl(); $url = str_replace("http://", "https://", $url); Piwik_Url::redirectToUrl($url); } $pluginsManager = Piwik_PluginsManager::getInstance(); $pluginsToLoad = Piwik_Config::getInstance()->Plugins['Plugins']; $pluginsManager->loadPlugins($pluginsToLoad); if ($exceptionToThrow) { throw $exceptionToThrow; } try { Piwik::createDatabaseObject(); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; } Piwik_PostEvent('FrontController.badConfigurationFile', $e, $info = array(), $pending = true); throw $e; } Piwik::createLogObject(); // creating the access object, so that core/Updates/* can enforce Super User and use some APIs Piwik::createAccessObject(); Piwik_PostEvent('FrontController.dispatchCoreAndPluginUpdatesScreen'); Piwik_PluginsManager::getInstance()->installLoadedPlugins(); Piwik::install(); // ensure the current Piwik URL is known for later use if (method_exists('Piwik', 'getPiwikUrl')) { $host = Piwik::getPiwikUrl(); } Piwik_PostEvent('FrontController.initAuthenticationObject'); try { $authAdapter = Zend_Registry::get('auth'); } catch (Exception $e) { throw new Exception("Authentication object cannot be found in the Registry. Maybe the Login plugin is not activated?\n\t\t\t\t\t\t\t\t\t<br />You can activate the plugin by adding:<br />\n\t\t\t\t\t\t\t\t\t<code>Plugins[] = Login</code><br />\n\t\t\t\t\t\t\t\t\tunder the <code>[Plugins]</code> section in your config/config.ini.php"); } Zend_Registry::get('access')->reloadAccess($authAdapter); Piwik::raiseMemoryLimitIfNecessary(); Piwik_Translate::getInstance()->reloadLanguage(); $pluginsManager->postLoadPlugins(); Piwik_PostEvent('FrontController.checkForUpdates'); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; } Piwik_ExitWithMessage($e->getMessage(), false, true); } // Piwik::log('End FrontController->init() - Request: '. var_export($_REQUEST, true)); }
/** * If the token_auth is found in the $request parameter, * the current session will be authenticated using this token_auth. * It will overwrite the previous Auth object. * * @param array $request If null, uses the default request ($_GET) * @return void */ public static function reloadAuthUsingTokenAuth($request = null) { // if a token_auth is specified in the API request, we load the right permissions $token_auth = Piwik_Common::getRequestVar('token_auth', '', 'string', $request); if ($token_auth) { Piwik_PostEvent('API.Request.authenticate', $token_auth); Zend_Registry::get('access')->reloadAccess(); Piwik::raiseMemoryLimitIfNecessary(); } }
/** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. * * @return void */ function init() { Zend_Registry::set('timer', new Piwik_Timer()); $this->checkDirectoriesWritableOrDie(); $this->assignCliParametersToRequest(); $exceptionToThrow = false; //move into a init() method try { Piwik::createConfigObject(); } catch (Exception $e) { Piwik_PostEvent('FrontController.NoConfigurationFile', $e); $exceptionToThrow = $e; } Piwik::loadPlugins(); if ($exceptionToThrow) { throw $exceptionToThrow; } // database object Piwik::createDatabaseObject(); // Create the log objects Piwik::createLogObject(); Piwik::terminateLoadPlugins(); Piwik::install(); // Piwik::printMemoryUsage('Start program'); // can be used for debug purpose $doNotDrop = array(Piwik::prefixTable('access'), Piwik::prefixTable('user'), Piwik::prefixTable('site'), Piwik::prefixTable('archive'), Piwik::prefixTable('logger_api_call'), Piwik::prefixTable('logger_error'), Piwik::prefixTable('logger_exception'), Piwik::prefixTable('logger_message'), Piwik::prefixTable('log_visit'), Piwik::prefixTable('log_link_visit_action'), Piwik::prefixTable('log_action'), Piwik::prefixTable('log_profiling')); // Setup the auth object Piwik_PostEvent('FrontController.authSetCredentials'); try { $authAdapter = Zend_Registry::get('auth'); } catch (Exception $e) { throw new Exception("Object 'auth' cannot be found in the Registry. Maybe the Login plugin is not enabled?\r\n\t\t\t\t\t\t\t\t<br>You can enable the plugin by adding:<br>\r\n\t\t\t\t\t\t\t\t<code>Plugins[] = Login</code><br>\r\n\t\t\t\t\t\t\t\tunder the <code>[Plugins]</code> section in your config/config.inc.php"); } // Perform the authentication query, saving the result $access = new Piwik_Access($authAdapter); Zend_Registry::set('access', $access); Zend_Registry::get('access')->loadAccess(); Piwik::raiseMemoryLimitIfNecessary(); }
protected function getSystemInformation() { $minimumPhpVersion = Zend_Registry::get('config')->General->minimum_php_version; $minimumMemoryLimit = Zend_Registry::get('config')->General->minimum_memory_limit; $infos = array(); $infos['directories'] = Piwik::checkDirectoriesWritable(); $infos['phpVersion_minimum'] = $minimumPhpVersion; $infos['phpVersion'] = phpversion(); $infos['phpVersion_ok'] = version_compare($minimumPhpVersion, $infos['phpVersion']) === -1; // critical errors $extensions = @get_loaded_extensions(); $needed_extensions = array('PDO', 'pdo_mysql', 'zlib', 'SPL'); $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; } } // warnings $needed_functions = array('set_time_limit', 'mail'); $infos['needed_functions'] = $needed_functions; $infos['missing_functions'] = array(); foreach ($needed_functions as $needed_function) { if (!function_exists($needed_function)) { $infos['missing_functions'][] = $needed_function; } } $infos['gd_ok'] = false; if (in_array('gd', $extensions)) { $gdInfo = gd_info(); $infos['gd_version'] = $gdInfo['GD Version']; preg_match('/([0-9]{1})/', $gdInfo['GD Version'], $gdVersion); if ($gdVersion[0] >= 2) { $infos['gd_ok'] = true; } } $infos['serverVersion'] = addslashes($_SERVER['SERVER_SOFTWARE']); $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; // on windows the ini_get is not working? $infos['memoryCurrent'] = '?M'; $raised = Piwik::raiseMemoryLimitIfNecessary(); if ($memoryValue = Piwik::getMemoryLimitValue()) { $infos['memoryCurrent'] = $memoryValue . "M"; $infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit; } return $infos; }
/** * Must be called before dispatch() * - checks that directories are writable, * - loads the configuration file, * - loads the plugin, * - inits the DB connection, * - etc. * @throws Exception * @throws Exception * @throws bool|Exception * @return */ function init() { static $initialized = false; if ($initialized) { return; } $initialized = true; try { Zend_Registry::set('timer', new Piwik_Timer()); $directoriesToCheck = array('/tmp/', '/tmp/templates_c/', '/tmp/cache/', '/tmp/assets/', '/tmp/tcpdf/'); Piwik::checkDirectoriesWritableOrDie($directoriesToCheck); Piwik_Common::assignCliParametersToRequest(); Piwik_Translate::getInstance()->loadEnglishTranslation(); $exceptionToThrow = $this->createConfigObject(); if (Piwik_Session::isFileBasedSessions()) { Piwik_Session::start(); } $this->handleMaintenanceMode(); $this->handleSSLRedirection(); $pluginsManager = Piwik_PluginsManager::getInstance(); $pluginsToLoad = Piwik_Config::getInstance()->Plugins['Plugins']; $pluginsManager->loadPlugins($pluginsToLoad); if ($exceptionToThrow) { throw $exceptionToThrow; } try { Piwik::createDatabaseObject(); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; } Piwik_PostEvent('FrontController.badConfigurationFile', $e, $info = array(), $pending = true); throw $e; } Piwik::createLogObject(); // creating the access object, so that core/Updates/* can enforce Super User and use some APIs $this->createAccessObject(); Piwik_PostEvent('FrontController.dispatchCoreAndPluginUpdatesScreen'); Piwik_PluginsManager::getInstance()->installLoadedPlugins(); Piwik::install(); // ensure the current Piwik URL is known for later use if (method_exists('Piwik', 'getPiwikUrl')) { $host = Piwik::getPiwikUrl(); } Piwik_PostEvent('FrontController.initAuthenticationObject'); try { $authAdapter = Zend_Registry::get('auth'); } catch (Exception $e) { throw new Exception("Authentication object cannot be found in the Registry. Maybe the Login plugin is not activated?\n\t\t\t\t\t\t\t\t\t<br />You can activate the plugin by adding:<br />\n\t\t\t\t\t\t\t\t\t<code>Plugins[] = Login</code><br />\n\t\t\t\t\t\t\t\t\tunder the <code>[Plugins]</code> section in your config/config.ini.php"); } Zend_Registry::get('access')->reloadAccess($authAdapter); // Force the auth to use the token_auth if specified, so that embed dashboard // and all other non widgetized controller methods works fine if (($token_auth = Piwik_Common::getRequestVar('token_auth', false, 'string')) !== false) { Piwik_API_Request::reloadAuthUsingTokenAuth(); } Piwik::raiseMemoryLimitIfNecessary(); Piwik_Translate::getInstance()->reloadLanguage(); $pluginsManager->postLoadPlugins(); Piwik_PostEvent('FrontController.checkForUpdates'); } catch (Exception $e) { if (self::shouldRethrowException()) { throw $e; } Piwik_ExitWithMessage($e->getMessage(), false, true); } // Piwik::log('End FrontController->init() - Request: '. var_export($_REQUEST, true)); }