|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 Ingo Renner <ingo@typo3.org> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 00026 /** 00027 * Performs several checks about the system's health 00028 * 00029 * @author Ingo Renner <ingo@typo3.org> 00030 * @package TYPO3 00031 * @subpackage reports 00032 */ 00033 class tx_reports_reports_status_SystemStatus implements tx_reports_StatusProvider { 00034 00035 /** 00036 * Determines the Install Tool's status, mainly concerning its protection. 00037 * 00038 * @return array List of statuses 00039 * @see typo3/sysext/reports/interfaces/tx_reports_StatusProvider::getStatus() 00040 */ 00041 public function getStatus() { 00042 $statuses = array( 00043 'Php' => $this->getPhpStatus(), 00044 'PhpMemoryLimit' => $this->getPhpMemoryLimitStatus(), 00045 'PhpRegisterGlobals' => $this->getPhpRegisterGlobalsStatus(), 00046 'Webserver' => $this->getWebserverStatus(), 00047 ); 00048 00049 return $statuses; 00050 } 00051 00052 00053 /** 00054 * Checks the current PHP version against a minimum required version. 00055 * 00056 * @return tx_reports_reports_status_Status A status of whether a minimum PHP version requirment is met 00057 */ 00058 protected function getPhpStatus() { 00059 $message = ''; 00060 $severity = tx_reports_reports_status_Status::OK; 00061 00062 if (version_compare(phpversion(), TYPO3_REQUIREMENTS_MINIMUM_PHP) < 0) { 00063 $message = $GLOBALS['LANG']->getLL('status_phpTooOld'); 00064 $severity = tx_reports_reports_status_Status::ERROR; 00065 } 00066 00067 return t3lib_div::makeInstance('tx_reports_reports_status_Status', 00068 $GLOBALS['LANG']->getLL('status_phpVersion'), 00069 phpversion(), 00070 $message, 00071 $severity 00072 ); 00073 } 00074 00075 /** 00076 * Checks the current memory limit against a minimum required version. 00077 * 00078 * @return tx_reports_reports_status_Status A status of whether a minimum memory limit requirment is met 00079 */ 00080 protected function getPhpMemoryLimitStatus() { 00081 $memoryLimit = ini_get('memory_limit'); 00082 $message = ''; 00083 $severity = tx_reports_reports_status_Status::OK; 00084 00085 if ($memoryLimit && t3lib_div::getBytesFromSizeMeasurement($memoryLimit) < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_RECOMMENDED_PHP_MEMORY_LIMIT)) { 00086 $message = sprintf($GLOBALS['LANG']->getLL('status_phpMemoryRecommendation'), $memoryLimit, TYPO3_REQUIREMENTS_RECOMMENDED_PHP_MEMORY_LIMIT); 00087 $severity = tx_reports_reports_status_Status::WARNING; 00088 } 00089 00090 if ($memoryLimit && t3lib_div::getBytesFromSizeMeasurement($memoryLimit) < t3lib_div::getBytesFromSizeMeasurement(TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT)) { 00091 $message = sprintf($GLOBALS['LANG']->getLL('status_phpMemoryRequirement'), $memoryLimit, TYPO3_REQUIREMENTS_MINIMUM_PHP_MEMORY_LIMIT); 00092 $severity = tx_reports_reports_status_Status::ERROR; 00093 } 00094 00095 if ($severity > tx_reports_reports_status_Status::OK) { 00096 if ($php_ini_path = get_cfg_var('cfg_file_path')) { 00097 $message .= ' ' . sprintf($GLOBALS['LANG']->getLL('status_phpMemoryEditLimit'), $php_ini_path); 00098 } else { 00099 $message .= ' ' . $GLOBALS['LANG']->getLL('status_phpMemoryContactAdmin'); 00100 } 00101 } 00102 00103 return t3lib_div::makeInstance('tx_reports_reports_status_Status', 00104 $GLOBALS['LANG']->getLL('status_phpMemory'), $memoryLimit, $message, $severity 00105 ); 00106 } 00107 00108 /** 00109 * checks whether register globals is on or off. 00110 * 00111 * @return tx_reports_reports_status_Status A status of whether register globals is on or off 00112 */ 00113 protected function getPhpRegisterGlobalsStatus() { 00114 $value = $GLOBALS['LANG']->getLL('status_disabled'); 00115 $message = ''; 00116 $severity = tx_reports_reports_status_Status::OK; 00117 00118 $registerGlobals = trim(ini_get('register_globals')); 00119 00120 // can't reliably check for 'on', therefore checking for the oposite 'off', '', or 0 00121 if (!empty($registerGlobals) && strtolower($registerGlobals) != 'off') { 00122 $registerGlobalsHighlight = '<em>register_globals</em>'; 00123 $phpManualLink .= '<a href="http://php.net/configuration.changes">' . $GLOBALS['LANG']->getLL('status_phpRegisterGlobalsHowToChange') . '</a>'; 00124 $message = sprintf($GLOBALS['LANG']->getLL('status_phpRegisterGlobalsEnabled'), $registerGlobalsHighlight); 00125 $message .= ' ' . sprintf($GLOBALS['LANG']->getLL('status_phpRegisterGlobalsSecurity'), $registerGlobalsHighlight); 00126 $message .= ' ' . sprintf($GLOBALS['LANG']->getLL('status_phpRegisterGlobalsPHPManual'), $phpManualLink); 00127 $severity = tx_reports_reports_status_Status::ERROR; 00128 $value = $GLOBALS['LANG']->getLL('status_enabled') 00129 . ' (\'' . $registerGlobals . '\')'; 00130 } 00131 00132 return t3lib_div::makeInstance('tx_reports_reports_status_Status', 00133 $GLOBALS['LANG']->getLL('status_phpRegisterGlobals'), $value, $message, $severity 00134 ); 00135 } 00136 00137 /** 00138 * Reports the webserver TYPO3 is running on. 00139 * 00140 * @return tx_reports_reports_status_Status The server software as a status 00141 */ 00142 protected function getWebserverStatus() { 00143 return t3lib_div::makeInstance('tx_reports_reports_status_Status', 00144 $GLOBALS['LANG']->getLL('status_webServer'), 00145 $_SERVER['SERVER_SOFTWARE'] 00146 ); 00147 } 00148 } 00149 00150 00151 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/reports/reports/status/class.tx_reports_reports_status_systemstatus.php'])) { 00152 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/reports/reports/status/class.tx_reports_reports_status_systemstatus.php']); 00153 } 00154 00155 ?>
1.8.0