示例#1
0
 /**
  * Collects the needed data recursively cached. This function detects recursion loops.
  *
  * @param string $function The function to call and collect the result of.
  * @param string $childrenFunction The function to get the children from (must return an iterable object or an array).
  * @param callable $processData An optional closure to process the data from the function, must return an array.
  * @return array The resulting collection.
  */
 public function collectRecursiveDataCached($function, $childrenFunction, $processData = null, $keyFunction = null, &$recursionIndex = array())
 {
     if (isset($recursionIndex[$this->getUid()])) {
         return array();
     }
     $recursionIndex[$this->getUid()] = true;
     $identifier = 'tx_contentstage_' . get_class($this) . '_' . $function . '_' . $childrenFunction . '_' . $this->getUid();
     if (TX_CONTENTSTAGE_USECACHE) {
         if (self::$cache === null) {
             t3lib_cache::initializeCachingFramework();
             if (method_exists('t3lib_cache', 'initContentHashCache')) {
                 // not needed in 6.2 anymore
                 t3lib_cache::initContentHashCache();
             }
             self::$cache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
         }
         if (TX_CONTENTSTAGE_USECACHE && self::$cache->has($identifier)) {
             return self::$cache->get($identifier);
         }
     }
     $data = array();
     $tData = array();
     if (is_callable(array($this, $function))) {
         $tData = $this->{$function}();
         if ($processData !== null && is_callable($processData)) {
             $tData = $processData($tData);
         }
     }
     $tData = is_array($tData) ? $tData : array();
     $useKeyFunction = false;
     if ($keyFunction !== null && is_callable($keyFunction)) {
         $useKeyFunction = true;
         foreach ($tData as $item) {
             $key = $keyFunction($item);
             if ($key !== null) {
                 $data[$key] = $item;
             } else {
                 $data[] = $item;
             }
         }
     } else {
         $data = $tData;
     }
     if (is_callable(array($this, $childrenFunction))) {
         foreach ($this->{$childrenFunction}() as $child) {
             foreach ($child->collectRecursiveDataCached($function, $childrenFunction, $processData, $keyFunction, $recursionIndex) as $item) {
                 if ($useKeyFunction && ($key = $keyFunction($item)) !== null) {
                     $data[$key] = $item;
                 } else {
                     $data[] = $item;
                 }
             }
         }
     }
     if (TX_CONTENTSTAGE_USECACHE) {
         self::$cache->set($identifier, $data, array(), TX_CONTENTSTAGE_CACHETIME);
     }
     return $data;
 }
示例#2
0
$TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
$TYPO3_DB->debugOutput = $TYPO3_CONF_VARS['SYS']['sqlDebug'];
$CLIENT = t3lib_div::clientInfo();
// $CLIENT includes information about the browser/user-agent
$PARSETIME_START = t3lib_div::milliseconds();
// Is set to the system time in milliseconds. This could be used to output script parsetime in the end of the script
// ***********************************
// Initializing the Caching System
// ***********************************
if (TYPO3_UseCachingFramework) {
    $typo3CacheManager = t3lib_div::makeInstance('t3lib_cache_Manager');
    $typo3CacheFactory = t3lib_div::makeInstance('t3lib_cache_Factory');
    $typo3CacheFactory->setCacheManager($typo3CacheManager);
    t3lib_cache::initPageCache();
    t3lib_cache::initPageSectionCache();
    t3lib_cache::initContentHashCache();
}
// *************************
// CLI dispatch processing
// *************************
if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI && basename(PATH_thisScript) == 'cli_dispatch.phpsh') {
    // First, take out the first argument (cli-key)
    $temp_cliScriptPath = array_shift($_SERVER['argv']);
    $temp_cliKey = array_shift($_SERVER['argv']);
    array_unshift($_SERVER['argv'], $temp_cliScriptPath);
    // If cli_key was found in configuration, then set up the cliInclude path and module name:
    if ($temp_cliKey) {
        if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys'][$temp_cliKey])) {
            define('TYPO3_cliInclude', t3lib_div::getFileAbsFileName($TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys'][$temp_cliKey][0]));
            $MCONF['name'] = $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['cliKeys'][$temp_cliKey][1];
        } else {
示例#3
0
 /**
  * Init function, setting the input vars in the global space.
  *
  * @return	void
  */
 function init()
 {
     // Loading internal vars with the GET/POST parameters from outside:
     $this->file = t3lib_div::_GP('file');
     $this->width = t3lib_div::_GP('width');
     $this->height = t3lib_div::_GP('height');
     $this->sample = t3lib_div::_GP('sample');
     $this->alternativeTempPath = t3lib_div::_GP('alternativeTempPath');
     $this->effects = t3lib_div::_GP('effects');
     $this->frame = t3lib_div::_GP('frame');
     $this->bodyTag = t3lib_div::_GP('bodyTag');
     $this->title = t3lib_div::_GP('title');
     $this->wrap = t3lib_div::_GP('wrap');
     $this->md5 = t3lib_div::_GP('md5');
     $this->contentHash = t3lib_div::_GP('contentHash');
     // ***********************
     // Check parameters
     // ***********************
     // If no file-param is given, we must exit
     if (!$this->file) {
         die('Parameter Error: No file given.');
     }
     // Chech md5-checksum: If this md5-value does not match the one submitted, then we fail... (this is a kind of security that somebody don't just hit the script with a lot of different parameters
     $md5_value = md5($this->file . '|' . $this->width . '|' . $this->height . '|' . $this->effects . '|' . $this->bodyTag . '|' . $this->title . '|' . $this->wrap . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] . '|');
     if ($md5_value != $this->md5) {
         die('Parameter Error: Wrong parameters sent.');
     }
     // Need to connect to database, because this is used (typo3temp_db_tracking, cached image dimensions).
     $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password);
     $GLOBALS['TYPO3_DB']->sql_select_db(TYPO3_db);
     if (TYPO3_UseCachingFramework) {
         $GLOBALS['typo3CacheManager'] = t3lib_div::makeInstance('t3lib_cache_Manager');
         $GLOBALS['typo3CacheFactory'] = t3lib_div::makeInstance('t3lib_cache_Factory');
         $GLOBALS['typo3CacheFactory']->setCacheManager($GLOBALS['typo3CacheManager']);
         t3lib_cache::initPageCache();
         t3lib_cache::initPageSectionCache();
         t3lib_cache::initContentHashCache();
     }
     // Check for the new content cache hash
     if (strlen(t3lib_div::_GP('contentHash')) > 0) {
         $this->content = t3lib_pageSelect::getHash($this->contentHash);
         if (is_null($this->content)) {
             die('Parameter Error: Content not available.');
         }
     }
     // ***********************
     // Check the file. If must be in a directory beneath the dir of this script...
     // $this->file remains unchanged, because of the code in stdgraphic, but we do check if the file exists within the current path
     // ***********************
     $test_file = PATH_site . $this->file;
     if (!t3lib_div::validPathStr($test_file)) {
         die('Parameter Error: No valid filepath');
     }
     if (!@is_file($test_file)) {
         die('The given file was not found');
     }
 }
 /**
  * Initialize the controller.
  *
  * @return void
  */
 public function initializeAction()
 {
     $this->extensionName = 'Contentstage';
     $this->activeBackendUser = $this->backendUserRepository->findByUid($GLOBALS['BE_USER']->user['uid']);
     if ($this->activeBackendUser === null) {
         // should never happen
         die($this->translate('error.noBackendUser'));
     }
     t3lib_cache::initializeCachingFramework();
     if (method_exists('t3lib_cache', 'initContentHashCache')) {
         // not needed in 6.2 anymore
         t3lib_cache::initContentHashCache();
     }
     $this->cache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
     $this->extensionConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['contentstage']);
     define('TX_CONTENTSTAGE_USECACHE', !empty($this->extensionConfiguration['useCache']));
     define('TX_CONTENTSTAGE_CACHETIME', intval($this->extensionConfiguration['cacheTime']));
     $this->settings['publishRecords'] = $this->extensionConfiguration['global.']['disablePublishRecord'] ? '' : 'Extended';
     $this->localDB = $GLOBALS['TYPO3_DB'];
     $this->initializePage();
     $info = $this->extensionConfiguration['remote.']['db.'];
     $noPconnect = $GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'];
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'] = true;
     $this->remoteDB = t3lib_div::makeInstance('t3lib_db');
     $this->remoteDB->connectDB($info['host'], $info['user'], $info['password'], $info['database']);
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect'] = $noPconnect;
     $this->initializeLog();
     $this->localRepository = $this->objectManager->create('Tx_Contentstage_Domain_Repository_ContentRepository', $this->localDB, $this->log, $this->cache, 'localRepository');
     $this->localRepository->setFolder(PATH_site);
     $this->localRepository->setCurrentPage($this->page);
     $this->localRepository->setParent($this);
     $this->remoteRepository = $this->objectManager->create('Tx_Contentstage_Domain_Repository_ContentRepository', $this->remoteDB, $this->log, $this->cache, 'remoteRepository');
     $this->remoteRepository->setFolder($this->extensionConfiguration['remote.']['folder']);
     $this->remoteRepository->setCurrentPage($this->page);
     $this->remoteRepository->setParent($this);
     $pageTS = $this->getPageTS();
     $this->localRepository->setUseHttps($pageTS['useHttpsLocal']);
     $this->localRepository->setOverrideDomain($pageTS['overrideDomainLocal']);
     $this->remoteRepository->setUseHttps($pageTS['useHttpsRemote']);
     $this->remoteRepository->setOverrideDomain($pageTS['overrideDomainRemote']);
     $this->initializeDepth();
     $this->initializeIgnoreTables();
     $this->initializeReview();
     $hookFilename = 'contentstage/Classes/Controller/' . $this->request->getControllerName() . 'Controller.php';
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$hookFilename][$this->request->getControllerActionName()])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$hookFilename][$this->request->getControllerActionName()] as $classRef) {
             $this->hookObjectsArray[] =& t3lib_div::getUserObj($classRef);
         }
     }
 }
 /**
  * Initializes the caching system.
  *
  * @return	void
  */
 protected function initCaches()
 {
     if (TYPO3_UseCachingFramework) {
         $GLOBALS['TT']->push('Initializing the Caching System', '');
         $GLOBALS['typo3CacheManager'] = t3lib_div::makeInstance('t3lib_cache_Manager');
         $GLOBALS['typo3CacheFactory'] = t3lib_div::makeInstance('t3lib_cache_Factory');
         $GLOBALS['typo3CacheFactory']->setCacheManager($GLOBALS['typo3CacheManager']);
         try {
             $this->pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
         } catch (t3lib_cache_exception_NoSuchCache $e) {
             t3lib_cache::initPageCache();
             $this->pageCache = $GLOBALS['typo3CacheManager']->getCache('cache_pages');
         }
         t3lib_cache::initPageSectionCache();
         t3lib_cache::initContentHashCache();
         $GLOBALS['TT']->pull();
     }
 }
示例#6
0
 /**
  * Initialize the cache.
  *
  * @return void
  */
 protected function initializeCache()
 {
     t3lib_cache::initializeCachingFramework();
     if (method_exists('t3lib_cache', 'initContentHashCache')) {
         // not needed in 6.2 anymore
         t3lib_cache::initContentHashCache();
     }
     $this->cache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');
 }