/** * Returns the cache breaking string * * @return mixed */ public function get() { if (!$this->storage->has(self::STORAGE_KEY)) { $this->update(); } return $this->storage->get(self::STORAGE_KEY); }
/** * Checks the cache for the given route values and returns the cached resolvedUriPath if a cache entry is found * * @param array $routeValues * @return string|boolean the cached request path or FALSE if no cache entry was found */ public function getCachedResolvedUriPath(array $routeValues) { $routeValues = $this->convertObjectsToHashes($routeValues); if ($routeValues === NULL) { return FALSE; } return $this->resolveCache->get($this->buildResolveCacheIdentifier($routeValues)); }
/** * @return string */ public function getRefreshToken() { $accessToken = $this->cache->get('RefreshToken'); if ($accessToken === FALSE) { return NULL; } return $accessToken; }
/** * @return string The current cache version identifier */ public function render() { $version = $this->configurationCache->get('ConfigurationVersion'); if ($version === false) { $version = time(); $this->configurationCache->set('ConfigurationVersion', (string) $version); } return $version; }
/** * Fetch the token or generate a new random token * * @return string */ public function getToken() { $token = $this->cache->get($this->tokenName); if ($token === FALSE) { $token = Algorithms::generateRandomToken(20); $this->storeToken($token); } return $token; }
/** * Tries to retrieve the specified content segment from the cache – further nested inline segments are retrieved * as well and segments which were not cacheable are rendered. * * @param \Closure $uncachedCommandCallback A callback to process commands in uncached segments * @param string $typoScriptPath TypoScript path identifying the TypoScript object to retrieve from the content cache * @param array $cacheIdentifierValues Further values which play into the cache identifier hash, must be the same as the ones specified while the cache entry was written * @param boolean $addCacheSegmentMarkersToPlaceholders If cache segment markers should be added – this makes sense if the cached segment is about to be included in a not-yet-cached segment * @return string|boolean The segment with replaced cache placeholders, or FALSE if a segment was missing in the cache * @throws \TYPO3\TypoScript\Exception */ public function getCachedSegment($uncachedCommandCallback, $typoScriptPath, $cacheIdentifierValues, $addCacheSegmentMarkersToPlaceholders = false) { $cacheIdentifier = $this->renderContentCacheEntryIdentifier($typoScriptPath, $cacheIdentifierValues); $content = $this->cache->get($cacheIdentifier); if ($content === false) { return false; } $i = 0; do { $replaced = $this->replaceCachePlaceholders($content, $addCacheSegmentMarkersToPlaceholders); if ($replaced === false) { return false; } if ($i > self::MAXIMUM_NESTING_LEVEL) { throw new Exception('Maximum cache segment level reached', 1391873620); } $i++; } while ($replaced > 0); $this->replaceUncachedPlaceholders($uncachedCommandCallback, $content); if ($addCacheSegmentMarkersToPlaceholders) { return self::CACHE_SEGMENT_START_TOKEN . $cacheIdentifier . self::CACHE_SEGMENT_SEPARATOR_TOKEN . '*' . self::CACHE_SEGMENT_SEPARATOR_TOKEN . $content . self::CACHE_SEGMENT_END_TOKEN; } else { return $content; } }
/** * {@inheritdoc} */ public function get($entryIdentifier) { $content = parent::get($entryIdentifier); if ($content !== FALSE) { $content = $this->extractMetadata($entryIdentifier, $content); } return $content; }
/** * Loads the last detected files for this monitor. * * @return void */ protected function loadDetectedDirectoriesAndFiles() { if ($this->directoriesAndFiles === null) { $this->directoriesAndFiles = json_decode($this->cache->get($this->identifier . '_directoriesAndFiles'), true); if (!is_array($this->directoriesAndFiles)) { $this->directoriesAndFiles = array(); } } }
/** * Logs a user in if a session identifier is available under the given token in the token cache. * * @param string $token * @return void */ public function tokenLoginAction($token) { $sessionId = $this->loginTokenCache->get($token); $this->loginTokenCache->remove($token); if ($sessionId === false) { $this->systemLogger->log(sprintf('Token-based login failed, non-existing or expired token %s', $token), LOG_WARNING); $this->redirect('index'); } else { $this->systemLogger->log(sprintf('Token-based login succeeded, token %s', $token), LOG_DEBUG); $this->replaceSessionCookie($sessionId); $this->redirect('index', 'Backend\\Backend'); } }
/** * Returns the encryption key from the persistent cache or Data/Persistent directory. If none exists, a new * encryption key will be generated and stored in the cache. * * @return string The configured encryption key stored in Data/Persistent/EncryptionKey */ protected function getEncryptionKey() { if ($this->encryptionKey === NULL) { $this->encryptionKey = $this->cache->get('encryptionKey'); } if ($this->encryptionKey === FALSE && file_exists(FLOW_PATH_DATA . 'Persistent/EncryptionKey')) { $this->encryptionKey = file_get_contents(FLOW_PATH_DATA . 'Persistent/EncryptionKey'); } if ($this->encryptionKey === FALSE) { $this->encryptionKey = bin2hex(\TYPO3\Flow\Utility\Algorithms::generateRandomBytes(96)); $this->cache->set('encryptionKey', $this->encryptionKey); } return $this->encryptionKey; }
/** * Returns the encryption key from the persistent cache or Data/Persistent directory. If none exists, a new * encryption key will be generated and stored in the cache. * * @return string The configured encryption key stored in Data/Persistent/EncryptionKey */ protected function getEncryptionKey() { if ($this->encryptionKey === null) { $this->encryptionKey = $this->cache->get('encryptionKey'); } if ($this->encryptionKey === false && file_exists(FLOW_PATH_DATA . 'Persistent/EncryptionKey')) { $this->encryptionKey = file_get_contents(FLOW_PATH_DATA . 'Persistent/EncryptionKey'); } if ($this->encryptionKey === false) { $this->encryptionKey = UtilityAlgorithms::generateRandomToken(48); $this->cache->set('encryptionKey', $this->encryptionKey); } return $this->encryptionKey; }
/** * Loads all node types into memory. * * @return void */ protected function loadNodeTypes() { $this->fullNodeTypeConfigurations = $this->fullConfigurationCache->get('fullNodeTypeConfigurations'); $fillFullConfigurationCache = !is_array($this->fullNodeTypeConfigurations); $completeNodeTypeConfiguration = $this->configurationManager->getConfiguration('NodeTypes'); foreach (array_keys($completeNodeTypeConfiguration) as $nodeTypeName) { $nodeType = $this->loadNodeType($nodeTypeName, $completeNodeTypeConfiguration, isset($this->fullNodeTypeConfigurations[$nodeTypeName]) ? $this->fullNodeTypeConfigurations[$nodeTypeName] : null); if ($fillFullConfigurationCache) { $this->fullNodeTypeConfigurations[$nodeTypeName] = $nodeType->getFullConfiguration(); } } if ($fillFullConfigurationCache) { $this->fullConfigurationCache->set('fullNodeTypeConfigurations', $this->fullNodeTypeConfigurations); } $this->fullNodeTypeConfigurations = null; }
/** * Logs a user in if a session identifier is available under the given token in the token cache. * * @param string $token * @return void */ public function tokenLoginAction($token) { $newSessionId = $this->loginTokenCache->get($token); $this->loginTokenCache->remove($token); if ($newSessionId === false) { $this->systemLogger->log(sprintf('Token-based login failed, non-existing or expired token %s', $token), LOG_WARNING); $this->redirect('index'); } $this->systemLogger->log(sprintf('Token-based login succeeded, token %s', $token), LOG_DEBUG); $newSession = $this->sessionManager->getSession($newSessionId); if ($newSession->canBeResumed()) { $newSession->resume(); } if ($newSession->isStarted()) { $newSession->putData('lastVisitedNode', null); } else { $this->systemLogger->log(sprintf('Failed resuming or starting session %s which was referred to in the login token %s.', $newSessionId, $token), LOG_ERR); } $this->replaceSessionCookie($newSessionId); $this->redirect('index', 'Backend\\Backend'); }
/** * Initializes this strategy * * @param FileMonitor $fileMonitor * @return void */ public function setFileMonitor(FileMonitor $fileMonitor) { $this->fileMonitor = $fileMonitor; $this->filesAndModificationTimes = json_decode($this->cache->get($this->fileMonitor->getIdentifier() . '_filesAndModificationTimes'), true); }
/** * @param string $key * @return boolean */ public function get($key) { return $this->cache->get($key); }
/** * @param string $pathAndFilename * @return void * @throws \Exception */ public function optimizeFile($pathAndFilename) { try { $imageType = exif_imagetype($pathAndFilename); $fileExtension = strtolower(pathinfo($pathAndFilename, PATHINFO_EXTENSION)); if ($imageType !== FALSE && !in_array($imageType, [\IMAGETYPE_JPEG, \IMAGETYPE_PNG, \IMAGETYPE_GIF], TRUE) || $imageType === FALSE && $fileExtension !== 'svg') { return; } $pathAndFilename = realpath($pathAndFilename); $cacheIdentifier = md5($pathAndFilename); $lastModificationTime = \DateTime::createFromFormat('U', filemtime($pathAndFilename)); $cachedLastModificationTime = $this->processingCache->get($cacheIdentifier); if ($cachedLastModificationTime instanceof \DateTime && $lastModificationTime->getTimestamp() === $lastModificationTime->getTimestamp()) { return; } $useGlobalBinary = $this->settings['useGlobalBinary']; $binaryRootPath = 'Private/Library/node_modules/'; $file = escapeshellarg($pathAndFilename); if ($imageType !== FALSE) { switch ($imageType) { case \IMAGETYPE_JPEG: if ($this->settings['formats']['jpg']['enabled'] === FALSE) { return; } $library = 'jpegtran'; $binaryPath = sprintf('%1$s-bin/vendor/%s', $library); $arguments = sprintf('-copy none -optimize %s -outfile %s %s', $this->settings['formats']['jpg']['progressive'] === TRUE ? '-progressive' : '', $file, $file); if ($this->settings['formats']['jpg']['useGlobalBinary'] === TRUE) { $useGlobalBinary = TRUE; } break; case \IMAGETYPE_PNG: if ($this->settings['formats']['png']['enabled'] === FALSE) { return; } $library = 'optipng'; $binaryPath = sprintf('%1$s-bin/vendor/%s', $library); $arguments = sprintf('-o%u -strip all -out %s %s', $this->settings['formats']['png']['optimizationLevel'], $file, $file); if ($this->settings['formats']['png']['useGlobalBinary'] === TRUE) { $useGlobalBinary = TRUE; } break; case \IMAGETYPE_GIF: if ($this->settings['formats']['gif']['enabled'] === FALSE) { return; } $library = 'gifsicle'; $binaryPath = sprintf('%1$s/vendor/%1$s', $library); $arguments = sprintf('--batch -O%u %s ', $this->settings['formats']['gif']['optimizationLevel'], $file); if ($this->settings['formats']['gif']['useGlobalBinary'] === TRUE) { $useGlobalBinary = TRUE; } break; } } else { if ($this->settings['formats']['svg']['enabled'] === FALSE) { return; } $library = 'svgo'; $binaryPath = sprintf('%1$s/bin/%1$s', $library); $arguments = sprintf('%s %s', $this->settings['formats']['svg']['pretty'] === TRUE ? '--pretty' : '', $file); if ($this->settings['formats']['svg']['useGlobalBinary'] === TRUE) { $useGlobalBinary = TRUE; } } $binaryPath = $useGlobalBinary === TRUE ? $this->settings['globalBinaryPath'] . $library : $this->packageManager->getPackageOfObject($this)->getResourcesPath() . $binaryRootPath . $binaryPath; $cmd = escapeshellcmd($binaryPath) . ' ' . $arguments; $output = []; exec($cmd, $output, $result); $this->systemLogger->log($cmd . ' (' . ((int) $result === 0 ? 'OK' : 'Error: ' . $result) . ')', LOG_INFO, $output); $lastModificationTime = \DateTime::createFromFormat('U', filemtime($pathAndFilename)); $this->processingCache->set($cacheIdentifier, $lastModificationTime); } catch (\Exception $exception) { $this->systemLogger->logException($exception); } }
/** * Initializes this monitor * * @return void */ public function initializeObject() { if ($this->cache->has($this->identifier . '_directoriesAndFiles')) { $this->directoriesAndFiles = json_decode($this->cache->get($this->identifier . '_directoriesAndFiles'), TRUE); } }