/var
/www
/clients
/client50
/web246
/web
/typo3conf
/ext
/realurl
/Classes
/Configuration
/ConfigurationReader.php
$result = TRUE;
}
return $result;
}
/**
* Sets the root page id from pages with the root flag.
*
* @return bool
* @throws \Exception
*/
protected function setRootPageIdFromRootFlag() {
$result = FALSE;
/** @noinspection PhpUndefinedMethodInspection */
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages', 'is_siteroot=1 AND deleted=0 AND hidden=0');
if (count($rows) > 1) {
// Cannot be done: too many of them!
throw new \Exception('RealURL was not able to find the root page id for the domain "' . $this->utility->getCurrentHost() . '" as there was more than one root page with this domain.', 1420480928);
} elseif (count($rows) !== 0) {
$this->configuration['pagePath']['rootpage_id'] = (int)$rows[0]['uid'];
$result = TRUE;
}
return $result;
}
/**
* Sets the root page id from the top level pages.
*
* @return bool
* @throws \Exception
*/
protected function setRootPageIdFromTopLevelPages() {
/** @noinspection PhpUndefinedMethodInspection */
$rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'pages',
'pid=0 AND doktype IN (1,2,4) AND deleted=0 AND hidden=0');
if (count($rows) !== 1) {
// Cannot be done: too many of them!
/var
/www
/clients
/client50
/web246
/web
/typo3conf
/ext
/realurl
/Classes
/Configuration
/ConfigurationReader.php
}
}
if (empty($this->hostName) && !$MP) {
$this->hostName = $this->tsfe->getDomainNameForPid($id);
}
}
if (empty($this->hostName)) {
$this->alternativeHostName = $this->hostName = $this->utility->getCurrentHost();
}
}
/**
* Sets the root page id from the current host if that is not set already.
*
* @return void
* @throws \Exception
*/
protected function setRootPageId() {
if (!isset($this->configuration['pagePath']['rootpage_id'])) {
$this->setRootPageIdFromDomainRecord() || $this->setRootPageIdFromRootFlag() || $this->setRootPageIdFromTopLevelPages();
}
if ((int)$this->configuration['pagePath']['rootpage_id'] === 0) {
throw new \Exception('RealURL was not able to find the root page id for the domain "' . $this->utility->getCurrentHost() . '"', 1453732574);
}
}
/**
* Sets the root page id from domain records.
*
* @return bool
*/
protected function setRootPageIdFromDomainRecord() {
$result = FALSE;
$domainRecord = BackendUtility::getDomainStartPage($this->hostName);
if (is_array($domainRecord)) {
$this->configuration['pagePath']['rootpage_id'] = (int)$domainRecord['pid'];
$result = TRUE;
}
/var
/www
/clients
/client50
/web246
/web
/typo3conf
/ext
/realurl
/Classes
/Configuration
/ConfigurationReader.php
} while ($maxLoops-- && is_string($keyAlias));
return is_array($keyAlias) ? $lastKey : '_DEFAULT';
}
/**
* Sets the configuration from the current domain.
*
* @return void
*/
protected function setConfigurationForTheCurrentDomain() {
$globalConfig = &$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'];
if (is_array($globalConfig)) {
$configurationKey = $this->getConfigurationKey();
$configuration = $globalConfig[$configurationKey];
if (is_array($configuration)) {
$this->configuration = $configuration;
}
$this->setRootPageId();
if ($this->mode == self::MODE_ENCODE) {
// Decode is handled when detecting configuration key
$this->updateConfigurationForEncoding($configurationKey);
}
if (is_array($this->domainConfiguration)) {
$this->configuration['domains'] = $this->domainConfiguration;
}
unset($this->domainConfiguration);
}
}
/**
* Updates _DOMAINS configuration to include only relevant entries and remove
* rootpage_id option.
*
* @param string $configurationKey
* @return void
*/
/var
/www
/clients
/client50
/web246
/web
/typo3conf
/ext
/realurl
/Classes
/Configuration
/ConfigurationReader.php
'pagePath/spaceCharacter' => '-', // undocumented & deprecated!
);
/**
* Initializes the class.
*
* @param int $mode One of MODE_* constants
* @param array $urlParameters
*/
public function __construct($mode, array $urlParameters = array()) {
$this->mode = $mode;
$this->tsfe = $GLOBALS['TSFE'];
$this->urlParameters = $urlParameters;
$this->utility = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Utility', $this);
try {
$this->loadExtConfiguration();
$this->performAutomaticConfiguration();
$this->setHostnames();
$this->setConfigurationForTheCurrentDomain();
$this->postProcessConfiguration();
}
catch (\Exception $exception) {
$this->exception = $exception;
}
}
/**
* Obtains the configuration by its path. Paths are separated by '/'.
* Leading and trailing slashes are removed.
* Special use: 'extconf/xxx' gets the entry from the ext_conf_template.txt.
*
* @param string $path
* @return mixed
*/
public function get($path) {
if (substr($path, 0, 8) == 'extconf/') {
$value = $this->extConfiguration[substr($path, 8)];
} else {
$value = $this->getFromConfiguration($path);
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/core
/Classes
/Utility
/GeneralUtility.php
}
if (isset(static::$finalClassNameCache[$className])) {
$finalClassName = static::$finalClassNameCache[$className];
} else {
$finalClassName = self::getClassName($className);
static::$finalClassNameCache[$className] = $finalClassName;
}
// Return singleton instance if it is already registered
if (isset(self::$singletonInstances[$finalClassName])) {
return self::$singletonInstances[$finalClassName];
}
// Return instance if it has been injected by addInstance()
if (
isset(self::$nonSingletonInstances[$finalClassName])
&& !empty(self::$nonSingletonInstances[$finalClassName])
) {
return array_shift(self::$nonSingletonInstances[$finalClassName]);
}
// Create new instance and call constructor with parameters
$instance = new $finalClassName(...$constructorArguments);
// Register new singleton instance
if ($instance instanceof SingletonInterface) {
self::$singletonInstances[$finalClassName] = $instance;
}
return $instance;
}
/**
* Returns the class name for a new instance, taking into account
* registered implementations for this class
*
* @param string $className Base class name to evaluate
* @return string Final class name to instantiate with "new [classname]
*/
protected static function getClassName($className)
{
if (class_exists($className)) {
while (static::classHasImplementation($className)) {
$className = static::getImplementationForClass($className);
}
/var
/www
/clients
/client50
/web246
/web
/typo3conf
/ext
/realurl
/Classes
/Decoder
/UrlDecoder.php
$this->throw404('Segment "' . $postVarSetKey . '" was not a keyword for a postVarSet as expected on page with id=' . $pageId . '.');
}
}
/**
* Initializes the decoder.
*
* @throws \Exception
*/
protected function initialize() {
parent::initialize();
$this->disallowedDoktypes = PageRepository::DOKTYPE_RECYCLER;
}
/**
* Initializes configuration reader.
*/
protected function initializeConfiguration() {
$this->configuration = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Configuration\\ConfigurationReader', ConfigurationReader::MODE_DECODE);
}
/**
* Checks if the current root page is inside the rootline
* of the given page
*
* @param int $pageUid
* @return boolean
*/
protected function isPageInRootlineOfRootPage($pageUid) {
$result = false;
$rootLineUtility = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\RootlineUtility', $pageUid);
/** @var \TYPO3\CMS\Core\Utility\RootlineUtility $rootLineUtility */
$rootLine = $rootLineUtility->get();
foreach ((array)$rootLine as $page) {
if ($page['uid'] == $this->rootPageId) {
$result = true;
break;
/var
/www
/clients
/client50
/web246
/web
/typo3conf
/ext
/realurl
/Classes
/EncodeDecoderBase.php
* @return int ID integer. If none is found: false
*/
protected function getFromAliasCacheByAliasValue(array $configuration, $aliasValue) {
$row = $this->databaseConnection->exec_SELECTgetSingleRow('value_id', 'tx_realurl_uniqalias',
'value_alias=' . $this->databaseConnection->fullQuoteStr($aliasValue, 'tx_realurl_uniqalias') .
' AND field_alias=' . $this->databaseConnection->fullQuoteStr($configuration['alias_field'], 'tx_realurl_uniqalias') .
' AND field_id=' . $this->databaseConnection->fullQuoteStr($configuration['id_field'], 'tx_realurl_uniqalias') .
' AND tablename=' . $this->databaseConnection->fullQuoteStr($configuration['table'], 'tx_realurl_uniqalias') .
' AND (expire=0 OR expire>' . time() . ')');
return (is_array($row) ? (int)$row['value_id'] : false);
}
/**
* Initializes the instance.
*
* @throws \Exception
*/
protected function initialize() {
$this->initializeConfiguration();
$this->emptySegmentValue = $this->configuration->get('init/emptySegmentValue');
$this->rootPageId = (int)$this->configuration->get('pagePath/rootpage_id');
$this->utility = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Utility', $this->configuration);
$this->cache = $this->utility->getCache();
$this->separatorCharacter = $this->configuration->get('pagePath/spaceCharacter');
}
/**
* Checks if system runs in non-live workspace
*
* @return boolean
*/
protected function isInWorkspace() {
$result = false;
if ($this->tsfe->beUserLogin) {
$result = ($GLOBALS['BE_USER']->workspace !== 0);
}
return $result;
}
/var
/www
/clients
/client50
/web246
/web
/typo3conf
/ext
/realurl
/Classes
/Decoder
/UrlDecoder.php
header(self::REDIRECT_STATUS_HEADER);
header(self::REDIRECT_INFO_HEADER . ': postVarSet_failureMode redirect for ' . $postVarSetKey);
header('Content-length: 0');
header('Connection: close');
header('Location: ' . GeneralUtility::locationHeaderUrl($goodPath));
exit;
} elseif ($failureMode == 'ignore') {
$pathSegments = array();
} else {
$this->throw404('Segment "' . $postVarSetKey . '" was not a keyword for a postVarSet as expected on page with id=' . $pageId . '.');
}
}
/**
* Initializes the decoder.
*
* @throws \Exception
*/
protected function initialize() {
parent::initialize();
$this->disallowedDoktypes = PageRepository::DOKTYPE_RECYCLER;
}
/**
* Initializes configuration reader.
*/
protected function initializeConfiguration() {
$this->configuration = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Configuration\\ConfigurationReader', ConfigurationReader::MODE_DECODE);
}
/**
* Checks if the current root page is inside the rootline
* of the given page
*
* @param int $pageUid
* @return boolean
*/
protected function isPageInRootlineOfRootPage($pageUid) {
$result = false;
/var
/www
/clients
/client50
/web246
/web
/typo3conf
/ext
/realurl
/Classes
/Decoder
/UrlDecoder.php
/**
* Initializes the class.
*/
public function __construct() {
parent::__construct();
$this->siteScript = GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT');
}
/**
* Decodes the URL. This function is called from \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::checkAlternativeIdMethods()
*
* @param array $params
* @return void
*/
public function decodeUrl(array $params) {
if ($this->canDecoderExecute()) {
$this->caller = $params['pObj'];
$this->initialize();
$this->mergeGetVarsFromDomainsConfiguration();
if ($this->isSpeakingUrl()) {
$this->configuration->validate();
$this->setSpeakingUriFromSiteScript();
$this->callPreDecodeHooks($params);
$this->checkMissingSlash();
if ($this->speakingUri) {
$this->setLanguageFromQueryString();
$this->runDecoding();
}
}
}
}
/**
* Calls user-defined hooks.
*
* @param array $params
*/
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/core
/Classes
/Utility
/GeneralUtility.php
if ($storePersistentObject) {
// Get reference to current instance of class:
if (!is_object($GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]])) {
$GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]] = self::makeInstance($parts[0]);
}
$classObj = $GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]];
} else {
// Create new object:
$classObj = self::makeInstance($parts[0]);
}
if (method_exists($classObj, $parts[1])) {
// If persistent object should be created, set reference:
if ($storePersistentObject) {
$GLOBALS['T3_VAR']['callUserFunction'][$funcName] = [
'method' => $parts[1],
'obj' => &$classObj
];
}
// Call method:
$content = call_user_func_array([&$classObj, $parts[1]], [&$params, &$ref]);
} else {
$errorMsg = 'No method name \'' . $parts[1] . '\' in class ' . $parts[0];
if ($errorMode == 2) {
throw new \InvalidArgumentException($errorMsg, 1294585865);
}
if (!$errorMode) {
debug($errorMsg, \TYPO3\CMS\Core\Utility\GeneralUtility::class . '::callUserFunction');
}
}
} else {
$errorMsg = 'No class named ' . $parts[0];
if ($errorMode == 2) {
throw new \InvalidArgumentException($errorMsg, 1294585866);
}
if (!$errorMode) {
debug($errorMsg, \TYPO3\CMS\Core\Utility\GeneralUtility::class . '::callUserFunction');
}
}
} else {
// Function
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/core
/Classes
/Utility
/GeneralUtility.php
if ($storePersistentObject) {
// Get reference to current instance of class:
if (!is_object($GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]])) {
$GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]] = self::makeInstance($parts[0]);
}
$classObj = $GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]];
} else {
// Create new object:
$classObj = self::makeInstance($parts[0]);
}
if (method_exists($classObj, $parts[1])) {
// If persistent object should be created, set reference:
if ($storePersistentObject) {
$GLOBALS['T3_VAR']['callUserFunction'][$funcName] = [
'method' => $parts[1],
'obj' => &$classObj
];
}
// Call method:
$content = call_user_func_array([&$classObj, $parts[1]], [&$params, &$ref]);
} else {
$errorMsg = 'No method name \'' . $parts[1] . '\' in class ' . $parts[0];
if ($errorMode == 2) {
throw new \InvalidArgumentException($errorMsg, 1294585865);
}
if (!$errorMode) {
debug($errorMsg, \TYPO3\CMS\Core\Utility\GeneralUtility::class . '::callUserFunction');
}
}
} else {
$errorMsg = 'No class named ' . $parts[0];
if ($errorMode == 2) {
throw new \InvalidArgumentException($errorMsg, 1294585866);
}
if (!$errorMode) {
debug($errorMsg, \TYPO3\CMS\Core\Utility\GeneralUtility::class . '::callUserFunction');
}
}
} else {
// Function
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/frontend
/Classes
/Controller
/TypoScriptFrontendController.php
public function isUserOrGroupSet()
{
return is_array($this->fe_user->user) || $this->gr_list !== '0,-1';
}
/**
* Provides ways to bypass the '?id=[xxx]&type=[xx]' format, using either PATH_INFO or virtual HTML-documents (using Apache mod_rewrite)
*
* Two options:
* 1) Use PATH_INFO (also Apache) to extract id and type from that var. Does not require any special modules compiled with apache. (less typical)
* 2) Using hook which enables features like those provided from "realurl" extension (AKA "Speaking URLs")
*/
public function checkAlternativeIdMethods()
{
$this->siteScript = GeneralUtility::getIndpEnv('TYPO3_SITE_SCRIPT');
// Call post processing function for custom URL methods.
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'])) {
$_params = ['pObj' => &$this];
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'] as $_funcRef) {
GeneralUtility::callUserFunction($_funcRef, $_params, $this);
}
}
}
/**
* Clears the preview-flags, sets sim_exec_time to current time.
* Hidden pages must be hidden as default, $GLOBALS['SIM_EXEC_TIME'] is set to $GLOBALS['EXEC_TIME']
* in bootstrap initializeGlobalTimeVariables(). Alter it by adding or subtracting seconds.
*/
public function clear_preview()
{
$this->showHiddenPage = false;
$this->showHiddenRecords = false;
$GLOBALS['SIM_EXEC_TIME'] = $GLOBALS['EXEC_TIME'];
$GLOBALS['SIM_ACCESS_TIME'] = $GLOBALS['ACCESS_TIME'];
$this->fePreview = 0;
}
/**
* Checks if a backend user is logged in
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/frontend
/Classes
/Http
/RequestHandler.php
$this->timeTracker->push('Front End user initialized', '');
$this->controller->initFEuser();
$this->timeTracker->pull();
// Initializing a possible logged-in Backend User
/** @var $GLOBALS['BE_USER'] \TYPO3\CMS\Backend\FrontendBackendUserAuthentication */
$GLOBALS['BE_USER'] = $this->controller->initializeBackendUser();
// Process the ID, type and other parameters.
// After this point we have an array, $page in TSFE, which is the page-record
// of the current page, $id.
$this->timeTracker->push('Process ID', '');
// Initialize admin panel since simulation settings are required here:
if ($this->controller->isBackendUserLoggedIn()) {
$GLOBALS['BE_USER']->initializeAdminPanel();
$this->bootstrap
->initializeBackendRouter()
->loadExtTables();
}
$this->controller->checkAlternativeIdMethods();
$this->controller->clear_preview();
$this->controller->determineId();
// Now, if there is a backend user logged in and he has NO access to this page,
// then re-evaluate the id shown! _GP('ADMCMD_noBeUser') is placed here because
// \TYPO3\CMS\Version\Hook\PreviewHook might need to know if a backend user is logged in.
if (
$this->controller->isBackendUserLoggedIn()
&& (!$GLOBALS['BE_USER']->extPageReadAccess($this->controller->page) || GeneralUtility::_GP('ADMCMD_noBeUser'))
) {
// Remove user
unset($GLOBALS['BE_USER']);
$this->controller->beUserLogin = false;
// Re-evaluate the page-id.
$this->controller->checkAlternativeIdMethods();
$this->controller->clear_preview();
$this->controller->determineId();
}
$this->controller->makeCacheHash();
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/core
/Classes
/Core
/Bootstrap.php
ksort($suitableRequestHandlers);
return array_pop($suitableRequestHandlers);
}
/**
* Builds a Request instance from the current process, and then resolves the request
* through the request handlers depending on Frontend, Backend, CLI etc.
*
* @param \Psr\Http\Message\RequestInterface|\Symfony\Component\Console\Input\InputInterface $request
* @return Bootstrap
* @throws \TYPO3\CMS\Core\Exception
* @internal This is not a public API method, do not use in own extensions
*/
public function handleRequest($request)
{
// Resolve request handler that were registered based on the Application
$requestHandler = $this->resolveRequestHandler($request);
// Execute the command which returns a Response object or NULL
$this->response = $requestHandler->handleRequest($request);
return $this;
}
/**
* Outputs content if there is a proper Response object.
*
* @return Bootstrap
*/
protected function sendResponse()
{
if ($this->response instanceof \Psr\Http\Message\ResponseInterface) {
if (!headers_sent()) {
// If the response code was not changed by legacy code (still is 200)
// then allow the PSR-7 response object to explicitly set it.
// Otherwise let legacy code take precedence.
// This code path can be deprecated once we expose the response object to third party code
if (http_response_code() === 200) {
header('HTTP/' . $this->response->getProtocolVersion() . ' ' . $this->response->getStatusCode() . ' ' . $this->response->getReasonPhrase());
}
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/frontend
/Classes
/Http
/Application.php
// Redirect to install tool if base configuration is not found
if (!$this->bootstrap->checkIfEssentialConfigurationExists()) {
$this->bootstrap->redirectToInstallTool($this->entryPointLevel);
}
foreach ($this->availableRequestHandlers as $requestHandler) {
$this->bootstrap->registerRequestHandlerImplementation($requestHandler);
}
$this->bootstrap->configure();
}
/**
* Starting point
*
* @param callable $execute
*/
public function run(callable $execute = null)
{
$this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals());
if ($execute !== null) {
call_user_func($execute);
}
$this->bootstrap->shutdown();
}
/**
* Define constants and variables
*/
protected function defineLegacyConstants()
{
define('TYPO3_MODE', 'FE');
}
}
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/frontend
/Resources
/Private
/Php
/frontend.php
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
// Exit early if php requirement is not satisfied.
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
die('This version of TYPO3 CMS requires PHP 7.0 or above');
}
// Set up the application for the Frontend
call_user_func(function () {
$classLoader = require __DIR__ . '/../../../../../../vendor/autoload.php';
(new \TYPO3\CMS\Frontend\Http\Application($classLoader))->run();
});
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/typo3
/sysext
/frontend
/Resources
/Private
/Php
/frontend.php
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
// Exit early if php requirement is not satisfied.
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
die('This version of TYPO3 CMS requires PHP 7.0 or above');
}
// Set up the application for the Frontend
call_user_func(function () {
$classLoader = require __DIR__ . '/../../../../../../vendor/autoload.php';
(new \TYPO3\CMS\Frontend\Http\Application($classLoader))->run();
});
/var
/www
/clients
/client50
/web246
/web
/files
/TYPO3.CMS
/index.php
<?php
require __DIR__ . '/typo3/sysext/frontend/Resources/Private/Php/frontend.php';