/**
  * This method renders the report
  *
  * @return    string    The status report as HTML
  */
 public function getReport()
 {
     $actionURL = tx_additionalreports_util::getBaseUrl() . '&cmd=deleteAll';
     $content = '<a href="' . $actionURL . '"><img src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_DIR') . '../typo3conf/ext/additional_reports/Resources/Public/Icons/garbage.gif"/> ' . $GLOBALS['LANG']->getLL('flushalllog') . '</a>';
     $content .= tx_additionalreports_main::displayRealUrlErrors();
     return $content;
 }
 /**
  * Renders else-child or else-argument if variable $item is in $list
  *
  * @param string $list
  * @param string $item
  * @return string
  */
 public function render()
 {
     $item = $this->arguments['item'];
     $as = $this->arguments['as'];
     $plugin = $this->arguments['plugin'];
     $ctype = $this->arguments['ctype'];
     // plugin
     if ($plugin === TRUE) {
         foreach ($GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] as $itemKey => $itemValue) {
             if (trim($itemValue[1]) == $item['list_type']) {
                 preg_match('/EXT:(.*?)\\//', $itemValue[0], $ext);
                 preg_match('/^LLL:(EXT:.*?):(.*)/', $itemValue[0], $llfile);
                 $localLang = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile($llfile[1], $GLOBALS['LANG']->lang);
                 $item['iconext'] = tx_additionalreports_util::getExtIcon($ext[1]);
                 $item['extension'] = $ext[1];
                 $item['plugin'] = $GLOBALS['LANG']->getLLL($llfile[2], $localLang) . ' (' . $item['list_type'] . ')';
             } else {
                 $item['plugin'] = $item['list_type'];
             }
         }
     }
     // CType
     if ($ctype === TRUE) {
         foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $itemValue) {
             if ($itemValue[1] != '--div--') {
                 if (trim($itemValue[1]) == $item['CType']) {
                     preg_match('/^LLL:(EXT:.*?):(.*)/', $itemValue[0], $llfile);
                     $localLang = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile($llfile[1], $GLOBALS['LANG']->lang);
                     $item['iconext'] = tx_additionalreports_util::getContentTypeIcon($itemValue[2]);
                     $item['ctype'] = $GLOBALS['LANG']->getLLL($llfile[2], $localLang) . ' (' . $item['CType'] . ')';
                 } else {
                     $item['ctype'] = $item['CType'];
                 }
             }
         }
     }
     $item = array_merge($item, tx_additionalreports_main::getContentInfos($item));
     if ($this->templateVariableContainer->exists($as)) {
         $this->templateVariableContainer->remove($as);
     }
     $this->templateVariableContainer->add($as, $item);
 }
Пример #3
0
 /**
  * @test
  */
 public function initTSFE()
 {
     if (!defined('TYPO3_cliMode')) {
         tx_additionalreports_util::initTSFE(1);
         $this->assertTrue(!empty($GLOBALS['TSFE']));
     }
 }
Пример #4
0
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('additional_reports') . 'Classes/class.tx_additionalreports_main.php';
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('additional_reports') . 'Classes/class.tx_additionalreports_util.php';
if (TYPO3_MODE == 'BE') {
    $reports = tx_additionalreports_util::getReportsList();
    foreach ($reports as $report) {
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports'][$_EXTKEY][$report] = array('title' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:' . $report . '_title', 'description' => 'LLL:EXT:' . $_EXTKEY . '/locallang.xml:' . $report . '_description', 'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/tx_additionalreports_' . $report . '.png', 'report' => 'tx_additionalreports_' . $report);
    }
}
 /**
  * Main action which does all the fun
  *
  * @param integer $currentPage
  * @return void
  */
 public function indexAction($currentPage = 1)
 {
     // ugly patch to work without extbase (sry for that)
     $widgetIdentifier = '__widget_0';
     if (tx_additionalreports_util::intFromVer(TYPO3_version) >= 6002000) {
         $widgetIdentifier = '@widget_0';
     }
     if ($currentPage == 1 && !empty($_GET['tx__'][$widgetIdentifier]['currentPage'])) {
         $currentPage = (int) $_GET['tx__'][$widgetIdentifier]['currentPage'];
     }
     // set current page
     $this->currentPage = (int) $currentPage;
     if ($this->currentPage < 1) {
         $this->currentPage = 1;
     } elseif (!empty($this->numberOfPages) && $this->currentPage > $this->numberOfPages) {
         $this->currentPage = $this->numberOfPages;
     }
     // modify query
     $itemsPerPage = (int) $this->configuration['itemsPerPage'];
     $this->query['LIMIT'] = (int) ($itemsPerPage * ($this->currentPage - 1)) . ',' . $itemsPerPage;
     $res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($this->query);
     $modifiedObjects = array();
     while ($tempRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $modifiedObjects[] = $tempRow;
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     $this->view->assign('configuration', $this->configuration);
     $this->view->assign('pagination', $this->buildPagination());
 }
 /**
  * Main action which does all the fun
  *
  * @param integer $currentPage
  * @return void
  */
 public function indexAction($currentPage = 1)
 {
     // ugly patch to work without extbase (sry for that)
     $widgetIdentifier = '__widget_0';
     if (tx_additionalreports_util::intFromVer(TYPO3_version) >= 6002000) {
         $widgetIdentifier = '@widget_0';
     }
     if ($currentPage == 1 && !empty($_GET['tx__'][$widgetIdentifier]['currentPage'])) {
         $currentPage = (int) $_GET['tx__'][$widgetIdentifier]['currentPage'];
     }
     // set current page
     $this->currentPage = (int) $currentPage;
     if ($this->currentPage < 1) {
         $this->currentPage = 1;
     } elseif ($this->currentPage > $this->numberOfPages) {
         $this->currentPage = $this->numberOfPages;
     }
     // modify query
     $itemsPerPage = (int) $this->configuration['itemsPerPage'];
     if (is_a($this->objects, '\\TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface')) {
         $query = $this->objects->getQuery();
         // limit should only be used if needed and pagination only if results > itemsPerPage
         if ($itemsPerPage < $this->objects->count()) {
             $query->setLimit($itemsPerPage);
         }
         if ($this->currentPage > 1) {
             $query->setOffset((int) ($itemsPerPage * ($this->currentPage - 1)));
         }
         $modifiedObjects = $query->execute();
     } else {
         $offset = 0;
         if ($this->currentPage > 1) {
             $offset = (int) ($itemsPerPage * ($this->currentPage - 1));
         }
         $modifiedObjects = array_slice($this->objects, $offset, (int) $itemsPerPage);
     }
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     $this->view->assign('configuration', $this->configuration);
     $this->view->assign('pagination', $this->buildPagination());
 }
 /**
  * Build the TSFE (for the BE for example)
  *
  * @param int $pid
  * @return void
  */
 public static function initTSFE($id)
 {
     if (tx_additionalreports_util::intFromVer(TYPO3_version) < 6002000) {
         require_once PATH_t3lib . 'class.t3lib_befunc.php';
         require_once PATH_t3lib . 'stddb/tables.php';
         require_once PATH_tslib . 'class.tslib_pagegen.php';
         require_once PATH_tslib . 'class.tslib_fe.php';
         require_once PATH_t3lib . 'class.t3lib_page.php';
         require_once PATH_tslib . 'class.tslib_content.php';
         require_once PATH_t3lib . 'class.t3lib_userauth.php';
         require_once PATH_tslib . 'class.tslib_feuserauth.php';
         require_once PATH_t3lib . 'class.t3lib_tstemplate.php';
         require_once PATH_t3lib . 'class.t3lib_cs.php';
     }
     if (!is_object($GLOBALS['TT'])) {
         $GLOBALS['TT'] = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_TimeTrackNull');
     }
     if (version_compare(TYPO3_version, '4.3.0', '<')) {
         $tsfeClassName = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceClassName('tslib_fe');
         $GLOBALS['TSFE'] = new $tsfeClassName($GLOBALS['TYPO3_CONF_VARS'], $id, '');
     } else {
         $GLOBALS['TSFE'] = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], $id, '');
     }
     $GLOBALS['TSFE']->connectToDB();
     $GLOBALS['TSFE']->initFEuser();
     //$GLOBALS['TSFE']->checkAlternativeIdMethods();
     $GLOBALS['TSFE']->determineId();
     $GLOBALS['TSFE']->getCompressedTCarray();
     $GLOBALS['TSFE']->initTemplate();
     $GLOBALS['TSFE']->getConfigArray();
 }
 /**
  * Generate the dbcheck report
  *
  * @return string HTML code
  */
 public static function displayDbCheck()
 {
     $sqlStatements = tx_additionalreports_util::getSqlUpdateStatements();
     $dbchecks = array();
     if (!empty($sqlStatements['update']['add'])) {
         $dbchecks[1]['title'] = 'Add fields';
         $dbchecks[1]['items'] = $sqlStatements['update']['add'];
     }
     if (!empty($sqlStatements['update']['change'])) {
         $dbchecks[2]['title'] = 'Changing fields';
         foreach ($sqlStatements['update']['change'] as $itemKey => $itemValue) {
             if (isset($sqlStatements['update']['change_currentValue'][$itemKey])) {
                 $dbchecks[2]['items'][] = $itemValue . ' -- [current: ' . $sqlStatements['update']['change_currentValue'][$itemKey] . ']';
             } else {
                 $dbchecks[2]['items'][] = $itemValue;
             }
         }
     }
     if (!empty($sqlStatements['remove']['change'])) {
         $dbchecks[3]['title'] = 'Remove unused fields (rename with prefix)';
         $dbchecks[3]['items'] = $sqlStatements['remove']['change'];
     }
     if (!empty($sqlStatements['remove']['drop'])) {
         $dbchecks[4]['title'] = 'Drop fields (really!)';
         $dbchecks[4]['items'] = $sqlStatements['remove']['drop'];
     }
     if (!empty($sqlStatements['update']['create_table'])) {
         $dbchecks[5]['title'] = 'Add tables';
         $dbchecks[5]['items'] = $sqlStatements['update']['create_table'];
     }
     if (!empty($sqlStatements['remove']['change_table'])) {
         $dbchecks[6]['title'] = 'Removing tables (rename with prefix)';
         foreach ($sqlStatements['remove']['change_table'] as $itemKey => $itemValue) {
             if (!empty($sqlStatements['remove']['tables_count'][$itemKey])) {
                 $dbchecks[6]['items'][] = $itemValue . ' -- [' . $sqlStatements['remove']['tables_count'][$itemKey] . ']';
             } else {
                 $dbchecks[6]['items'][] = $itemValue . ' -- [empty]';
             }
         }
     }
     if (!empty($sqlStatements['remove']['drop_table'])) {
         $dbchecks[7]['title'] = 'Drop tables (really!)';
         foreach ($sqlStatements['remove']['drop_table'] as $itemKey => $itemValue) {
             if (!empty($sqlStatements['remove']['tables_count'][$itemKey])) {
                 $dbchecks[7]['items'][] = $itemValue . ' -- [' . $sqlStatements['remove']['tables_count'][$itemKey] . ']';
             } else {
                 $dbchecks[7]['items'][] = $itemValue . ' -- [empty]';
             }
         }
     }
     // dump sql structure
     $items = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('table_name', 'information_schema.tables', 'table_schema = \'' . TYPO3_db . '\'', '', 'table_name');
     $sqlStructure = '';
     foreach ($items as $table) {
         $resSqlDump = $GLOBALS['TYPO3_DB']->sql_query('SHOW CREATE TABLE ' . $table['table_name']);
         $sqlDump = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resSqlDump);
         $sqlStructure .= $sqlDump['Create Table'] . "\r\n\r\n";
         $GLOBALS['TYPO3_DB']->sql_free_result($resSqlDump);
     }
     $content = '<h3 class="uppercase">Dump SQL Structure (md5:' . md5($sqlStructure) . ')</h3>';
     $content .= '<textarea style="width:100%;height:200px;">' . $sqlStructure . '</textarea>';
     $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/dbcheck-fluid.html');
     $view->assign('dbchecks', $dbchecks);
     return $view->render() . $content;
 }
 /**
  * Get all the different ctypes (html select)
  *
  * @param boolean $displayHidden
  * @return array
  */
 public static function getAllDifferentCtypesSelect($displayHidden)
 {
     $where = $displayHidden === true ? '' : ' AND tt_content.hidden=0 AND pages.hidden=0 ';
     $getFiltersCat = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('filtersCat');
     $pluginsList = self::getAllDifferentCtypes($where);
     $filterCat = '';
     if ($getFiltersCat == 'all') {
         $filterCat .= '<option value="all" selected="selected">' . $GLOBALS['LANG']->getLL('all') . '</option>';
     } else {
         $filterCat .= '<option value="all">' . $GLOBALS['LANG']->getLL('all') . '</option>';
     }
     foreach ($pluginsList as $pluginsElement) {
         if ($getFiltersCat == $pluginsElement['CType'] && $getFiltersCat !== null) {
             $filterCat .= '<option value="' . $pluginsElement['CType'] . '" selected="selected">';
             $filterCat .= $pluginsElement['CType'] . '</option>';
         } else {
             $filterCat .= '<option value="' . $pluginsElement['CType'] . '">' . $pluginsElement['CType'] . '</option>';
         }
     }
     $listUrlOrig = tx_additionalreports_util::getBaseUrl() . '&display=' . tx_additionalreports_util::getPluginsDisplayMode();
     $content = '<select name="filtersCat" id="filtersCat">' . $filterCat . '</select>';
     $content .= '<a href="#"  onClick="jumpToUrl(\'' . $listUrlOrig;
     $content .= '&filtersCat=\'+document.getElementById(\'filtersCat\').value);">';
     $content .= '&nbsp;<img width="16" height="16" title="" alt="" src="' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_DIR');
     $content .= '../typo3conf/ext/additional_reports/Resources/Public/Icons/refresh_n.gif"></a>';
     return $content;
 }
$extVersion = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('extVersion');
$file1 = realpath(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey, $extFile));
$realPathExt = realpath(PATH_site . 'typo3conf/ext/' . $extKey);
if ($mode === null) {
    $mode = 'compareFile';
}
switch ($mode) {
    case 'compareFile':
        if (strstr($file1, $realPathExt) === false) {
            die('Access denied.');
        }
        $terFileContent = tx_additionalreports_util::downloadT3x($extKey, $extVersion, $extFile);
        t3Diff(\TYPO3\CMS\Core\Utility\GeneralUtility::getURL($file1), $terFileContent);
        break;
    case 'compareExtension':
        $t3xfiles = tx_additionalreports_util::downloadT3x($extKey, $extVersion);
        $diff = 0;
        foreach ($t3xfiles['FILES'] as $filePath => $file) {
            $currentFileContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($realPathExt . '/' . $filePath);
            if ($file['content_md5'] !== md5($currentFileContent)) {
                $diff++;
                echo '<h1>' . $filePath . '</h1>';
                t3Diff($currentFileContent, $file['content']);
            }
        }
        if (empty($diff)) {
            echo 'No diff to show';
        }
        break;
}
function t3Diff($file1, $file2)