TYPO3 CMS  TYPO3_6-2
ConfigurationStatus.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
32 
39 
45  protected $backPath = '../';
46 
52  public function getStatus() {
53  $this->executeAdminCommand();
54  $statuses = array(
55  'emptyReferenceIndex' => $this->getReferenceIndexStatus(),
56  'deprecationLog' => $this->getDeprecationLogStatus()
57  );
58  if ($this->isMemcachedUsed()) {
59  $statuses['memcachedConnection'] = $this->getMemcachedConnectionStatus();
60  }
61  if (TYPO3_OS !== 'WIN') {
62  $statuses['createdFilesWorldWritable'] = $this->getCreatedFilesWorldWritableStatus();
63  $statuses['createdDirectoriesWorldWritable'] = $this->getCreatedDirectoriesWorldWritableStatus();
64  }
65  return $statuses;
66  }
67 
73  protected function getReferenceIndexStatus() {
74  $value = $GLOBALS['LANG']->getLL('status_ok');
75  $message = '';
77  $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_refindex');
78  $registry = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Registry');
79  $lastRefIndexUpdate = $registry->get('core', 'sys_refindex_lastUpdate');
80  if (!$count && $lastRefIndexUpdate) {
81  $value = $GLOBALS['LANG']->getLL('status_empty');
83  $url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('system_dbint') . '&id=0&SET[function]=refindex';
84  $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.backend_reference_index'), '<a href="' . htmlspecialchars($url) . '">', '</a>', \TYPO3\CMS\Backend\Utility\BackendUtility::dateTime($lastRefIndexUpdate));
85  }
86  return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->getLL('status_referenceIndex'), $value, $message, $severity);
87  }
88 
94  protected function isMemcachedUsed() {
95  $memcachedUsed = FALSE;
96  $memcachedServers = $this->getConfiguredMemcachedServers();
97  if (count($memcachedServers)) {
98  $memcachedUsed = TRUE;
99  }
100  return $memcachedUsed;
101  }
102 
108  protected function getConfiguredMemcachedServers() {
109  $memcachedServers = array();
110  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'])) {
111  foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] as $table => $conf) {
112  if (is_array($conf)) {
113  foreach ($conf as $key => $value) {
114  if (!is_array($value) && $value === 'TYPO3\\CMS\\Core\\Cache\\Backend\\MemcachedBackend') {
115  $memcachedServers = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$table]['options']['servers'];
116  break;
117  }
118  }
119  }
120  }
121  }
122  return $memcachedServers;
123  }
124 
130  protected function getMemcachedConnectionStatus() {
131  $value = $GLOBALS['LANG']->getLL('status_ok');
132  $message = '';
133  $severity = \TYPO3\CMS\Reports\Status::OK;
134  $failedConnections = array();
135  $defaultMemcachedPort = ini_get('memcache.default_port');
136  $memcachedServers = $this->getConfiguredMemcachedServers();
137  if (function_exists('memcache_connect') && is_array($memcachedServers)) {
138  foreach ($memcachedServers as $testServer) {
139  $configuredServer = $testServer;
140  if (substr($testServer, 0, 7) == 'unix://') {
141  $host = $testServer;
142  $port = 0;
143  } else {
144  if (substr($testServer, 0, 6) === 'tcp://') {
145  $testServer = substr($testServer, 6);
146  }
147  if (strstr($testServer, ':') !== FALSE) {
148  list($host, $port) = explode(':', $testServer, 2);
149  } else {
150  $host = $testServer;
151  $port = $defaultMemcachedPort;
152  }
153  }
154  $memcachedConnection = @memcache_connect($host, $port);
155  if ($memcachedConnection != NULL) {
156  memcache_close($memcachedConnection);
157  } else {
158  $failedConnections[] = $configuredServer;
159  }
160  }
161  }
162  if (count($failedConnections)) {
163  $value = $GLOBALS['LANG']->getLL('status_connectionFailed');
165  $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.memcache_not_usable') . '<br /><br />' . '<ul><li>' . implode('</li><li>', $failedConnections) . '</li></ul>';
166  }
167  return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->getLL('status_memcachedConfiguration'), $value, $message, $severity);
168  }
169 
176  protected function getDeprecationLogStatus() {
177  $title = $GLOBALS['LANG']->getLL('status_configuration_DeprecationLog');
178  $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:disabled');
179  $message = '';
180  $severity = \TYPO3\CMS\Reports\Status::OK;
181  if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
182  $value = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:enabled');
183  $message = '<p>' . $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogEnabled') . '</p>';
186  $logFileSize = 0;
187  if (@file_exists($logFile)) {
188  $logFileSize = filesize($logFile);
189  $message .= '<p>' . sprintf($GLOBALS['LANG']->getLL('status_configuration_DeprecationLogFile'), $this->getDeprecationLogFileLink()) . '</p>';
190  $removeDeprecationLogFileUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL') . '&amp;adminCmd=removeDeprecationLogFile';
191  $message .= '<p>' . sprintf($GLOBALS['LANG']->getLL('status_configuration_DeprecationLogSize'), GeneralUtility::formatSize($logFileSize)) . ' <a href="' . $removeDeprecationLogFileUrl . '">' . $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogDeleteLink') . '</a></p>';
192  }
193  if ($logFileSize > $this->deprecationLogFileSizeWarningThreshold) {
195  }
196  if ($logFileSize > $this->deprecationLogFileSizeErrorThreshold) {
198  }
199  }
200  return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $title, $value, $message, $severity);
201  }
202 
208  protected function getCreatedFilesWorldWritableStatus() {
209  $value = $GLOBALS['LANG']->getLL('status_ok');
210  $message = '';
211  $severity = \TYPO3\CMS\Reports\Status::OK;
212  if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] % 10 & 2) {
213  $value = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'];
215  $message = $GLOBALS['LANG']->getLL('status_CreatedFilePermissions.writable');
216  }
217  return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->getLL('status_CreatedFilePermissions'), $value, $message, $severity);
218  }
219 
226  $value = $GLOBALS['LANG']->getLL('status_ok');
227  $message = '';
228  $severity = \TYPO3\CMS\Reports\Status::OK;
229  if ((int)$GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] % 10 & 2) {
230  $value = $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'];
232  $message = $GLOBALS['LANG']->getLL('status_CreatedDirectoryPermissions.writable');
233  }
234  return GeneralUtility::makeInstance('TYPO3\\CMS\\Reports\\Status', $GLOBALS['LANG']->getLL('status_CreatedDirectoryPermissions'), $value, $message, $severity);
235  }
236 
243  protected function getDeprecationLogFileLink() {
245  $relativePath = GeneralUtility::resolveBackPath($this->backPath . \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($logFile));
246  $link = '<a href="' . $relativePath . '">' . $logFile . '</a>';
247  return $link;
248  }
249 
258  protected function executeAdminCommand() {
259  $command = GeneralUtility::_GET('adminCmd');
260  switch ($command) {
261  case 'removeDeprecationLogFile':
262  self::removeDeprecationLogFile();
263  break;
264  default:
265  // intentionally left blank
266  }
267  }
268 
274  static protected function removeDeprecationLogFile() {
276  $message = $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogDeletedSuccessful');
278  } else {
279  $message = $GLOBALS['LANG']->getLL('status_configuration_DeprecationLogDeletionFailed');
281  }
282  $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $message, '', $severity, TRUE);
284  $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
286  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
287  $defaultFlashMessageQueue->enqueue($flashMessage);
288  }
289 
290 }
$registry
Definition: ext_tables.php:46
static getModuleUrl($moduleName, $urlParameters=array(), $backPathOverride=FALSE, $returnAbsoluteUrl=FALSE)
$host
Definition: server.php:35
static formatSize($sizeInBytes, $labels='')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]