TYPO3 CMS  TYPO3_6-2
SystemStatus.php
Go to the documentation of this file.
1 <?php
3 
22 
28  public function getStatus() {
29  $this->executeAdminCommand();
30  $statuses = array(
31  'PhpPeakMemory' => $this->getPhpPeakMemoryStatus(),
32  'PhpModules' => $this->getMissingPhpModulesOfExtensions()
33  );
34  return $statuses;
35  }
36 
42  protected function executeAdminCommand() {
43  $command = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('adminCmd');
44  switch ($command) {
45  case 'clear_peak_memory_usage_flag':
48  $registry->remove('core', 'reports-peakMemoryUsage');
49  break;
50  default:
51  // Do nothing
52  }
53  }
54 
60  protected function getPhpPeakMemoryStatus() {
63  $peakMemoryUsage = $registry->get('core', 'reports-peakMemoryUsage');
64  $memoryLimit = \TYPO3\CMS\Core\Utility\GeneralUtility::getBytesFromSizeMeasurement(ini_get('memory_limit'));
65  $value = $GLOBALS['LANG']->getLL('status_ok');
66  $message = '';
68  $bytesUsed = $peakMemoryUsage['used'];
69  $percentageUsed = $memoryLimit ? number_format($bytesUsed / $memoryLimit * 100, 1) . '%' : '?';
70  $dateOfPeak = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $peakMemoryUsage['tstamp']);
71  $urlOfPeak = '<a href="' . htmlspecialchars($peakMemoryUsage['url']) . '">' . htmlspecialchars($peakMemoryUsage['url']) . '</a>';
72  $clearFlagUrl = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&amp;adminCmd=clear_peak_memory_usage_flag';
73  if ($peakMemoryUsage['used']) {
74  $message = sprintf($GLOBALS['LANG']->getLL('status_phpPeakMemoryTooHigh'), \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($peakMemoryUsage['used']), $percentageUsed, \TYPO3\CMS\Core\Utility\GeneralUtility::formatSize($memoryLimit), $dateOfPeak, $urlOfPeak);
75  $message .= ' <a href="' . $clearFlagUrl . '">' . $GLOBALS['LANG']->getLL('status_phpPeakMemoryClearFlag') . '</a>.';
77  $value = $percentageUsed;
78  }
79  return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->getLL('status_phpPeakMemory'), $value, $message, $severity);
80  }
81 
87  protected function getMissingPhpModulesOfExtensions() {
88  $modules = array();
89  if (is_array(${$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['requiredPhpModules']})) {
90  foreach (${$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install/mod/class.tx_install.php']['requiredPhpModules']} as $classData) {
92  $modules = $hookObject->setRequiredPhpModules($modules, $this);
93  }
94  }
95  $missingPhpModules = array();
96  foreach ($modules as $module) {
97  if (is_array($module)) {
98  $detectedSubmodules = FALSE;
99  foreach ($module as $submodule) {
100  if (extension_loaded($submodule)) {
101  $detectedSubmodules = TRUE;
102  }
103  }
104  if ($detectedSubmodules === FALSE) {
105  $missingPhpModules[] = sprintf($GLOBALS['LANG']->getLL('status_phpModulesGroup'), '(' . implode(', ', $module) . ')');
106  }
107  } elseif (!extension_loaded($module)) {
108  $missingPhpModules[] = $module;
109  }
110  }
111  if (count($missingPhpModules) > 0) {
112  $value = $GLOBALS['LANG']->getLL('status_phpModulesMissing');
113  $message = sprintf($GLOBALS['LANG']->getLL('status_phpModulesList'), implode(', ', $missingPhpModules));
114  $message .= ' ' . $GLOBALS['LANG']->getLL('status_phpModulesInfo');
116  } else {
117  $value = $GLOBALS['LANG']->getLL('status_phpModulesPresent');
118  $message = '';
119  $severity = \TYPO3\CMS\Reports\Status::OK;
120  }
121  return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->getLL('status_phpModules'), $value, $message, $severity);
122  }
123 
124 }
static getUserObj($classRef, $checkPrefix='', $silent=FALSE)
$registry
Definition: ext_tables.php:46
static getBytesFromSizeMeasurement($measurement)
static formatSize($sizeInBytes, $labels='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]