Exemplo n.º 1
0
 /**
  * @test
  */
 public function getExtensionVersion()
 {
     $msg = tx_additionalreports_util::getExtensionVersion('additional_reports');
     $emconf = tx_additionalreports_util::includeEMCONF(PATH_typo3conf . 'ext/additional_reports/ext_emconf.php', 'additional_reports');
     $this->assertTrue($msg == $emconf['version']);
 }
 /**
  * Generate the global status report
  *
  * @return string HTML code
  */
 public static function displayStatus()
 {
     $view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $view->setTemplatePathAndFilename(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('additional_reports') . 'Resources/Private/Templates/status-fluid.html');
     // infos about typo3 versions
     $jsonVersions = tx_additionalreports_util::getJsonVersionInfos();
     $currentVersionInfos = tx_additionalreports_util::getCurrentVersionInfos($jsonVersions, TYPO3_version);
     $currentBranch = tx_additionalreports_util::getCurrentBranchInfos($jsonVersions, TYPO3_version);
     $latestStable = tx_additionalreports_util::getLatestStableInfos($jsonVersions);
     $latestLts = tx_additionalreports_util::getLatestLtsInfos($jsonVersions);
     $headerVersions = self::getLl('status_version') . '<br/>';
     $headerVersions .= self::getLl('latestbranch') . '<br/>';
     $headerVersions .= self::getLl('lateststable') . '<br/>';
     $headerVersions .= self::getLl('latestlts');
     $htmlVersions = TYPO3_version . ' [' . $currentVersionInfos['date'] . ']';
     $htmlVersions .= '<br/>' . $currentBranch['version'] . ' [' . $currentBranch['date'] . ']';
     $htmlVersions .= '<br/>' . $latestStable['version'] . ' [' . $latestStable['date'] . ']';
     $htmlVersions .= '<br/>' . $latestLts['version'] . ' [' . $latestLts['date'] . ']';
     // TYPO3
     $content = tx_additionalreports_util::writeInformation(self::getLl('status_sitename'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
     $content .= tx_additionalreports_util::writeInformation($headerVersions, $htmlVersions);
     $content .= tx_additionalreports_util::writeInformation(self::getLl('status_path'), PATH_site);
     $content .= tx_additionalreports_util::writeInformation('TYPO3_db<br/>TYPO3_db_username<br/>TYPO3_db_host', TYPO3_db . '<br/>' . TYPO3_db_username . '<br/>' . TYPO3_db_host);
     if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'] != '') {
         $cmd = \TYPO3\CMS\Core\Utility\GeneralUtility::imageMagickCommand('convert', '-version');
         exec($cmd, $ret);
         $content .= tx_additionalreports_util::writeInformation(self::getLl('status_im'), $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'] . ' (' . $ret[0] . ')');
     }
     $content .= tx_additionalreports_util::writeInformation('forceCharset', $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
     $content .= tx_additionalreports_util::writeInformation('setDBinit', $GLOBALS['TYPO3_CONF_VARS']['SYS']['setDBinit']);
     $content .= tx_additionalreports_util::writeInformation('no_pconnect', $GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']);
     $content .= tx_additionalreports_util::writeInformation('displayErrors', $GLOBALS['TYPO3_CONF_VARS']['SYS']['displayErrors']);
     $content .= tx_additionalreports_util::writeInformation('maxFileSize', $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize']);
     $extensions = explode(',', $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']);
     if (is_file(PATH_site . 'typo3conf/PackageStates.php')) {
         $extensions = array();
         $packages = (include PATH_site . 'typo3conf/PackageStates.php');
         foreach ($packages['packages'] as $extensionKey => $package) {
             if ($package['state'] === 'active') {
                 $extensions[] = $extensionKey;
             }
         }
     }
     sort($extensions);
     foreach ($extensions as $aKey => $extension) {
         $extensions[$aKey] = $extension . ' (' . tx_additionalreports_util::getExtensionVersion($extension) . ')';
     }
     $content .= tx_additionalreports_util::writeInformationList(self::getLl('status_loadedextensions'), $extensions);
     $view->assign('typo3', $content);
     // Debug
     $content = '';
     $vars = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('_ARRAY');
     foreach ($vars as $varKey => $varValue) {
         $content .= tx_additionalreports_util::writeInformation($varKey, $varValue);
     }
     $gE_keys = explode(',', 'HTTP_ACCEPT,HTTP_ACCEPT_ENCODING,HTTP_CONNECTION,HTTP_COOKIE,REMOTE_PORT,SERVER_ADDR,SERVER_ADMIN,SERVER_NAME,SERVER_PORT,SERVER_SIGNATURE,SERVER_SOFTWARE,GATEWAY_INTERFACE,SERVER_PROTOCOL,REQUEST_METHOD,PATH_TRANSLATED');
     foreach ($gE_keys as $k) {
         $content .= tx_additionalreports_util::writeInformation($k, getenv($k));
     }
     $view->assign('getIndpEnv', $content);
     // PHP
     $content = tx_additionalreports_util::writeInformation(self::getLl('status_version'), phpversion());
     $content .= tx_additionalreports_util::writeInformation('memory_limit', ini_get('memory_limit'));
     $content .= tx_additionalreports_util::writeInformation('max_execution_time', ini_get('max_execution_time'));
     $content .= tx_additionalreports_util::writeInformation('post_max_size', ini_get('post_max_size'));
     $content .= tx_additionalreports_util::writeInformation('upload_max_filesize', ini_get('upload_max_filesize'));
     $content .= tx_additionalreports_util::writeInformation('display_errors', ini_get('display_errors'));
     $content .= tx_additionalreports_util::writeInformation('error_reporting', ini_get('error_reporting'));
     if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
         $apacheUser = posix_getpwuid(posix_getuid());
         $apacheGroup = posix_getgrgid(posix_getgid());
         $content .= tx_additionalreports_util::writeInformation('Apache user', $apacheUser['name'] . ' (' . $apacheUser['uid'] . ')');
         $content .= tx_additionalreports_util::writeInformation('Apache group', $apacheGroup['name'] . ' (' . $apacheGroup['gid'] . ')');
     }
     $extensions = array_map('strtolower', get_loaded_extensions());
     natcasesort($extensions);
     $content .= tx_additionalreports_util::writeInformationList(self::getLl('status_loadedextensions'), $extensions);
     $view->assign('php', $content);
     // Apache
     if (function_exists('apache_get_version') && function_exists('apache_get_modules')) {
         $extensions = apache_get_modules();
         natcasesort($extensions);
         $content = tx_additionalreports_util::writeInformation(self::getLl('status_version'), apache_get_version());
         $content .= tx_additionalreports_util::writeInformationList(self::getLl('status_loadedextensions'), $extensions);
         $view->assign('apache', $content);
     } else {
         $view->assign('apache', self::getLl('noresults'));
     }
     // MySQL
     if (function_exists('mysqli_get_server_info')) {
         $content = tx_additionalreports_util::writeInformation('Version', mysqli_get_server_info($GLOBALS['TYPO3_DB']->getDatabaseHandle()));
     }
     $items = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('default_character_set_name, default_collation_name', 'information_schema.schemata', 'schema_name = \'' . TYPO3_db . '\'');
     $content .= tx_additionalreports_util::writeInformation('default_character_set_name', $items[0]['default_character_set_name']);
     $content .= tx_additionalreports_util::writeInformation('default_collation_name', $items[0]['default_collation_name']);
     $content .= tx_additionalreports_util::writeInformation('query_cache', tx_additionalreports_util::getMySqlCacheInformations());
     $content .= tx_additionalreports_util::writeInformation('character_set', tx_additionalreports_util::getMySqlCharacterSet());
     // TYPO3 database
     $items = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('table_name, engine, table_collation, table_rows, ((data_length+index_length)/1024/1024) as "size"', 'information_schema.tables', 'table_schema = \'' . TYPO3_db . '\'', '', 'table_name');
     $tables = array();
     $size = 0;
     foreach ($items as $itemValue) {
         $tables[] = array('name' => $itemValue['table_name'], 'engine' => $itemValue['engine'], 'collation' => $itemValue['table_collation'], 'rows' => $itemValue['table_rows'], 'size' => round($itemValue['size'], 2));
         $size += round($itemValue['size'], 2);
     }
     $view->assign('mysql', $content);
     $view->assign('tables', $tables);
     $view->assign('tablessize', round($size, 2));
     $view->assign('typo3db', TYPO3_db);
     // Crontab
     exec('crontab -l', $crontab);
     $crontabString = self::getLl('status_nocrontab');
     if (count($crontab) > 0) {
         $crontabString = '';
         foreach ($crontab as $cron) {
             if (trim($cron) != '') {
                 $crontabString .= $cron . '<br />';
             }
         }
     }
     $content = tx_additionalreports_util::writeInformation('Crontab', $crontabString);
     $view->assign('crontab', $content);
     return $view->render();
 }