/** * Writes $auditName with $auditAttributes as content * to file name that will be fetched from ini settings by auditNameSettings() for logging. * * @param string $auditName * @param array $auditAttributes * @return bool */ static function writeAudit( $auditName, $auditAttributes = array() ) { $enabled = eZAudit::isAuditEnabled(); if ( !$enabled ) return false; $auditNameSettings = eZAudit::auditNameSettings(); if ( !isset( $auditNameSettings[$auditName] ) ) return false; $ip = eZSys::clientIP(); if ( !$ip ) $ip = eZSys::serverVariable( 'HOSTNAME', true ); $user = eZUser::currentUser(); $userID = $user->attribute( 'contentobject_id' ); $userLogin = $user->attribute( 'login' ); $message = "[$ip] [$userLogin:$userID]\n"; foreach ( array_keys( $auditAttributes ) as $attributeKey ) { $attributeValue = $auditAttributes[$attributeKey]; $message .= "$attributeKey: $attributeValue\n"; } $logName = $auditNameSettings[$auditName]['file_name']; $dir = $auditNameSettings[$auditName]['dir']; eZLog::write( $message, $logName, $dir ); return true; }
public function __construct(array $settings = array()) { $this->settings = $settings + array('use-cache-headers' => true, 'max-age' => 86400, 'siteaccess' => null, 'use-exceptions' => false); unset($settings); require_once __DIR__ . '/treemenu_functions.php'; $this->setUseExceptions($this->settings['use-exceptions']); header('X-Powered-By: ' . eZPublishSDK::EDITION . ' (index_treemenu)'); if ($this->settings['use-cache-headers'] === true) { define('MAX_AGE', $this->settings['max-age']); if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + MAX_AGE) . ' GMT'); header('Cache-Control: max-age=' . MAX_AGE); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) . ' GMT'); header('Pragma: '); exit; } } // Tweaks ini filetime checks if not defined! // This makes ini system not check modified time so // that index_treemenu.php can assume that index.php does // this regular enough, set in config.php to override. if (!defined('EZP_INI_FILEMTIME_CHECK')) { define('EZP_INI_FILEMTIME_CHECK', false); } eZExecution::addFatalErrorHandler(function () { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); }); eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP); // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs): $_SERVER['SCRIPT_FILENAME'] = str_replace('/index_treemenu.php', '/index.php', $_SERVER['SCRIPT_FILENAME']); $_SERVER['PHP_SELF'] = str_replace('/index_treemenu.php', '/index.php', $_SERVER['PHP_SELF']); $ini = eZINI::instance(); $timezone = $ini->variable('TimeZoneSettings', 'TimeZone'); if ($timezone) { putenv("TZ={$timezone}"); } // init uri code $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI'); eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true'); $this->uri = eZURI::instance(eZSys::requestURI()); $GLOBALS['eZRequestedURI'] = $this->uri; // Check for extension eZExtension::activateExtensions('default'); // load siteaccess // Use injected siteaccess if available or match it internally. $this->access = isset($this->settings['siteaccess']) ? $this->settings['siteaccess'] : eZSiteAccess::match($this->uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile()); eZSiteAccess::change($this->access); // Check for new extension loaded by siteaccess eZExtension::activateExtensions('access'); }
function createRedirectionUrl($process) { //__DEBUG__ $this->logger->writeTimedString("createRedirectionUrl"); //___end____ $paypalINI = eZINI::instance('paypal.ini'); $paypalServer = $paypalINI->variable('ServerSettings', 'ServerName'); $requestURI = $paypalINI->variable('ServerSettings', 'RequestURI'); $business = urlencode($paypalINI->variable('PaypalSettings', 'Business')); $processParams = $process->attribute('parameter_list'); $orderID = $processParams['order_id']; $indexDir = eZSys::indexDir(); $localHost = eZSys::serverURL(); $localURI = eZSys::serverVariable('REQUEST_URI'); $order = eZOrder::fetch($orderID); $amount = urlencode($order->attribute('total_inc_vat')); $currency = urlencode($order->currencyCode()); // include_once( 'lib/ezlocale/classes/ezlocale.php' ); $locale = eZLocale::instance(); $countryCode = urlencode($locale->countryCode()); $maxDescLen = $paypalINI->variable('PaypalSettings', 'MaxDescriptionLength'); $itemName = urlencode($this->createShortDescription($order, $maxDescLen)); $accountInfo = $order->attribute('account_information'); $first_name = urlencode($accountInfo['first_name']); $last_name = urlencode($accountInfo['last_name']); $street = urlencode($accountInfo['street2']); $zip = urlencode($accountInfo['zip']); $state = urlencode($accountInfo['state']); $place = urlencode($accountInfo['place']); $image_url = "{$localHost}" . urlencode($paypalINI->variable('PaypalSettings', 'LogoURI')); $background = urlencode($paypalINI->variable('PaypalSettings', 'BackgroundColor')); $pageStyle = urlencode($paypalINI->variable('PaypalSettings', 'PageStyle')); $noNote = urlencode($paypalINI->variable('PaypalSettings', 'NoNote')); $noteLabel = $noNote == 1 ? '' : urlencode($paypalINI->variable('PaypalSettings', 'NoteLabel')); $noShipping = 1; $url = $paypalServer . $requestURI . "?cmd=_ext-enter" . "&redirect_cmd=_xclick" . "&business={$business}" . "&item_name={$itemName}" . "&custom={$orderID}" . "&amount={$amount}" . "¤cy_code={$currency}" . "&first_name={$first_name}" . "&last_name={$last_name}" . "&address1={$street}" . "&zip={$zip}" . "&state={$state}" . "&city={$place}" . "&image_url={$image_url}" . "&cs={$background}" . "&page_style={$pageStyle}" . "&no_shipping={$noShipping}" . "&cn={$noteLabel}" . "&no_note={$noNote}" . "&lc={$countryCode}" . "¬ify_url={$localHost}" . $indexDir . "/paypal/notify_url/" . "&return={$localHost}" . $indexDir . "/shop/checkout/" . "&cancel_return={$localHost}" . $indexDir . "/shop/basket/"; //__DEBUG__ $this->logger->writeTimedString("business = {$business}"); $this->logger->writeTimedString("item_name = {$itemName}"); $this->logger->writeTimedString("custom = {$orderID}"); $this->logger->writeTimedString("no_shipping = {$noShipping}"); $this->logger->writeTimedString("localHost = {$localHost}"); $this->logger->writeTimedString("amount = {$amount}"); $this->logger->writeTimedString("currency_code = {$currency}"); $this->logger->writeTimedString("notify_url = {$localHost}" . $indexDir . "/paypal/notify_url/"); $this->logger->writeTimedString("return = {$localHost}" . $indexDir . "/shop/checkout/"); $this->logger->writeTimedString("cancel_return = {$localHost}" . $indexDir . "/shop/basket/"); //___end____ return $url; }
function createDataFromGET() { $this->logger->writeTimedString('createDataFromGET'); $this->callbackData = array(); $query_string = eZSys::serverVariable('QUERY_STRING'); if ($query_string) { $key_value_pairs = explode('&', $query_string); foreach ($key_value_pairs as $key_value) { $data = explode('=', $key_value); $this->callbackData[$data[0]] = $data[1]; $this->logger->writeTimedString("{$data['0']} = {$data['1']}"); } } return count($this->callbackData) > 0; }
/** * browserSupportsDHTMLType * Identify supported browser by layout engine using user agent string. * * @static * @return string|false Name of supported layout engine or false */ public static function browserSupportsDHTMLType() { if (self::$browserType === null) { self::$browserType = false; $userAgent = eZSys::serverVariable('HTTP_USER_AGENT'); // Opera 9.6+ if (strpos($userAgent, 'Presto') !== false && preg_match('/Presto\\/([0-9\\.]+)/i', $userAgent, $browserInfo)) { if ($browserInfo[1] >= 2.1) { self::$browserType = 'Presto'; } } else { if (strpos($userAgent, 'Trident') !== false && preg_match('/Trident\\/([0-9\\.]+)/i', $userAgent, $browserInfo)) { if ($browserInfo[1] >= 4.0) { self::$browserType = 'Trident'; } } else { if (strpos($userAgent, 'MSIE') !== false && preg_match('/MSIE[ \\/]([0-9\\.]+)/i', $userAgent, $browserInfo)) { if ($browserInfo[1] >= 6.0) { self::$browserType = 'Trident'; } } else { if (strpos($userAgent, 'Gecko') !== false && preg_match('/rv:([0-9\\.]+)/i', $userAgent, $browserInfo)) { if ($browserInfo[1] >= 1.9) { self::$browserType = 'Gecko'; } } else { if (strpos($userAgent, 'WebKit') !== false && strpos($userAgent, 'Mobile') === false && strpos($userAgent, 'Android') === false && strpos($userAgent, 'iPad') === false && strpos($userAgent, 'iPhone') === false && strpos($userAgent, 'iPod') === false && preg_match('/WebKit\\/([0-9\\.]+)/i', $userAgent, $browserInfo)) { if ($browserInfo[1] >= 528.16) { self::$browserType = 'WebKit'; } } else { if (strpos($userAgent, 'AppleWebKit') !== false && strpos($userAgent, 'Mobile') !== false && strpos($userAgent, 'Android') === false && preg_match('/AppleWebKit\\/([0-9\\.]+)/i', $userAgent, $browserInfo)) { if ($browserInfo[1] >= 534.46) { self::$browserType = 'MobileWebKit'; } } } } } } } if (self::$browserType === false) { eZDebug::writeNotice('Browser not supported: ' . $userAgent, __METHOD__); } } return self::$browserType; }
static function createRedirectUrl($path, $parameters = array()) { $parameters = array_merge(array('host' => false, 'protocol' => false, 'port' => false, 'username' => false, 'password' => false, 'override_host' => false, 'override_protocol' => false, 'override_port' => false, 'override_username' => false, 'override_password' => false, 'pre_url' => true), $parameters); $host = $parameters['host']; $protocol = $parameters['protocol']; $port = $parameters['port']; $username = $parameters['username']; $password = $parameters['password']; if (preg_match('#^([a-zA-Z0-9]+):(.+)$#', $path, $matches)) { if ($matches[1]) { $protocol = $matches[1]; } $path = $matches[2]; } if (preg_match('#^//((([a-zA-Z0-9_.]+)(:([a-zA-Z0-9_.]+))?)@)?([^./:]+(\\.[^./:]+)*)(:([0-9]+))?(.*)$#', $path, $matches)) { if ($matches[6]) { $host = $matches[6]; } if ($matches[3]) { $username = $matches[3]; } if ($matches[5]) { $password = $matches[5]; } if ($matches[9]) { $port = $matches[9]; } $path = $matches[10]; } if ($parameters['pre_url']) { if (strlen($path) > 0 and $path[0] != '/') { $preURL = eZSys::serverVariable('SCRIPT_URL'); if (strlen($preURL) > 0 and $preURL[strlen($preURL) - 1] != '/') { $preURL .= '/'; } $path = $preURL . $path; } } if ($parameters['override_host']) { $host = $parameters['override_host']; } if ($parameters['override_port']) { $port = $parameters['override_port']; } if (!is_string($host)) { $host = eZSys::hostname(); } if (!is_string($protocol)) { $protocol = 'http'; // Default to https if SSL is enabled // Check if SSL port is defined in site.ini $ini = eZINI::instance(); $sslPort = 443; if ($ini->hasVariable('SiteSettings', 'SSLPort')) { $sslPort = $ini->variable('SiteSettings', 'SSLPort'); } if (eZSys::serverPort() == $sslPort) { $protocol = 'https'; $port = false; } } if ($parameters['override_protocol']) { $protocol = $parameters['override_protocol']; } $uri = $protocol . '://'; if ($parameters['override_username']) { $username = $parameters['override_username']; } if ($parameters['override_password']) { $password = $parameters['override_password']; } if ($username) { $uri .= $username; if ($password) { $uri .= ':' . $password; } $uri .= '@'; } $uri .= $host; if ($port) { $uri .= ':' . $port; } $uri .= $path; return $uri; }
} else { $step = $stepData->nextStep($currentStep); } } } } else { $step = $stepData->step(0); //step contains file and class } } } $done = false; $result = null; while (!$done && $step != null) { // Some common variables for all steps $tpl->setVariable("script", eZSys::serverVariable('PHP_SELF')); $siteBasics = $GLOBALS['eZSiteBasics']; $useIndex = $siteBasics['validity-check-required']; if ($useIndex) { $script = eZSys::wwwDir() . eZSys::indexFileName(); } else { $script = eZSys::indexFile() . "/setup/{$partName}"; } $tpl->setVariable('script', $script); $tpl->setVariable("version", array("text" => eZPublishSDK::version(), "major" => eZPublishSDK::majorVersion(), "minor" => eZPublishSDK::minorVersion(), "release" => eZPublishSDK::release(), "alias" => eZPublishSDK::alias())); if ($persistenceList === null) { $persistenceList = eZSetupFetchPersistenceList(); } $tpl->setVariable('persistence_list', $persistenceList); // Try to include the relevant file $includeFile = $baseDir . 'steps/ezstep_' . $step['file'] . '.php';
function writeFile(&$logFileData, &$string, $verbosityLevel, $alwaysLog = false) { $enabled = eZDebug::isDebugEnabled(); if (!$alwaysLog and !$enabled) { return; } if (!$alwaysLog and !$this->isLogFileEnabled($verbosityLevel)) { return; } $oldHandleType = eZDebug::setHandleType(self::HANDLE_TO_PHP); $logDir = $logFileData[0]; $logName = $logFileData[1]; $fileName = $logDir . $logName; if (!file_exists($logDir)) { eZDir::mkdir($logDir, false, true); } $oldumask = @umask(0); clearstatcache(true, $fileName); $fileExisted = file_exists($fileName); if ($fileExisted and filesize($fileName) > eZDebug::maxLogSize()) { if (eZDebug::rotateLog($fileName)) { $fileExisted = false; } } $logFile = @fopen($fileName, "a"); if ($logFile) { $time = strftime("%b %d %Y %H:%M:%S", strtotime("now")); $ip = eZSys::clientIP(); if (!$ip) { $ip = eZSys::serverVariable('HOSTNAME', true); } $notice = "[ " . $time . " ] [" . $ip . "] " . $string . "\n"; @fwrite($logFile, $notice); @fclose($logFile); if (!$fileExisted) { $ini = eZINI::instance(); $permissions = octdec($ini->variable('FileSettings', 'LogFilePermissions')); @chmod($fileName, $permissions); } @umask($oldumask); } else { @umask($oldumask); $logEnabled = $this->isLogFileEnabled($verbosityLevel); $this->setLogFileEnabled(false, $verbosityLevel); if ($verbosityLevel != self::LEVEL_ERROR or $logEnabled) { eZDebug::setHandleType($oldHandleType); $this->writeError("Cannot open log file '{$fileName}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$fileName}' is disabled.", 'eZDebug::writeFile'); } } eZDebug::setHandleType($oldHandleType); }
} $callFnListCount = count($callFnList) - 1; // do calls if ($callType === 'stream') { if (isset($Params['interval']) && is_numeric($Params['interval']) && $Params['interval'] > 49) { // intervall in milliseconds, minimum is 0.05 seconds $callInterval = $Params['interval'] * 1000; } else { // default interval is every 0.5 seconds $callInterval = 500 * 1000; } $endTime = time() + 29; while (@ob_end_clean()) { } // flush 256 bytes first to force IE to not buffer the stream if (strpos(eZSys::serverVariable('HTTP_USER_AGENT'), 'MSIE') !== false) { echo ' '; echo ' '; echo ' '; echo ' '; echo " \n"; } // set_time_limit(65); while (time() < $endTime) { echo $streamSeperator . implode($callSeperator, multipleezjscServerCalls($callFnList, $contentType)); flush(); usleep($callInterval); } } else { echo implode($callSeperator, multipleezjscServerCalls($callFnList, $contentType)); }
/** * Test case setup * Prepare $_SERVER variable * */ public function setUp() { parent::setUp(); $this->httpHost = eZSys::serverVariable('HTTP_HOST'); eZSys::setServerVariable('HTTP_HOST', 'localhost'); }
/** * This method gets called by self::filter() */ public static function doLog($method, array $values, &$output) { switch ($method) { case 'apache': foreach ($values as $varName => $value) { /// @todo should remove any " or space chars in the value for proper parsing by updateperfstats.php apache_note($varName, $value); } break; case 'piwik': $text = ''; foreach (eZPerfLoggerINI::variable('GeneralSettings', 'TrackVariables') as $i => $var) { $text .= "\npiwikTracker.setCustomVariable( {$i}, \"{$var}\", \"{$values[$var]}\", \"page\" );"; } $text .= "\npiwikTracker.trackPageView();"; $output = preg_replace('/piwikTracker\\.trackPageView\\( *\\);?/', $text, $output); break; case 'googleanalytics': $text = ''; foreach (eZPerfLoggerINI::variable('GeneralSettings', 'TrackVariables') as $i => $var) { $text .= "\n_gaq.push([{$i}, '{$var}', '{$values[$var]}', 3]);"; } $text .= "\n_gaq.push(['_trackPageview']);"; $output = preg_replace("/_gaq.push\\( *[ *['\"]_trackPageview['\"] *] *\\);?/", $text, $output); break; case 'logfile': case 'syslog': /// same format as Apache "combined" by default $size = self::$outputSize; if ($size == 0) { $size = '-'; } $text = eZPerfLoggerApacheLogger::apacheLogLine('combined', $size, self::$returnCode) . ' '; foreach ($values as $value) { // do same as apache does: replace nulls with "-" if ((string) $value === '') { $text .= "- "; } else { /// @todo should remove any " or space chars in the value for proper parsing by updateperfstats.php $text .= $value . " "; } } if ($method == 'logfile') { $text .= "\n"; file_put_contents(eZPerfLoggerINI::variable('logfileSettings', 'FileName'), $text, FILE_APPEND); } else { // syslog: we use apache log format for lack of a better idea... openlog("eZPerfLog", LOG_PID, LOG_USER); syslog(LOG_INFO, $text); } break; case 'headers': $prefix = eZPerfLoggerINI::variable('HeadersSettings', 'HeaderPrefix'); foreach (eZPerfLoggerINI::variable('GeneralSettings', 'TrackVariables') as $i => $var) { header($prefix . str_replace(array('(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', "\t"), '-', $var) . ': ' . $values[$var]); } break; case 'database': case 'csv': case 'storage': if ($method == 'csv') { $storageClass = 'eZPerfLoggerCSVStorage'; } else { if ($method == 'database') { $storageClass = 'eZPerfLoggerDBStorage'; } else { $storageClass = eZPerfLoggerINI::variable('ParsingSettings', 'StorageClass'); } } /// @todo log error if storage class does not implement correct interface // when we deprecate php 5.2, we will be able to use $storageClass::insertStats... call_user_func(array($storageClass, 'insertStats'), array(array('url' => isset($_SERVER["REQUEST_URI"]) ? $_SERVER["REQUEST_URI"] : $_SERVER["PHP_SELF"], 'ip' => is_callable('eZSys::clientIP') ? eZSys::clientIP() : eZSys::serverVariable('REMOTE_ADDR'), 'time' => time(), 'response_status' => self::$returnCode, 'response_size' => self::$outputSize, 'counters' => $values))); break; /// @todo !important log a warning for default case (unhandled log format) } }
static function updateSettings($settings) { // Make sure errors are handled by PHP when we read, including our own debug output. $oldHandleType = eZDebug::setHandleType(self::HANDLE_TO_PHP); if (isset($settings['debug-log-files-enabled'])) { $GLOBALS['eZDebugLogFileEnabled'] = $settings['debug-log-files-enabled']; if (isset($GLOBALS["eZDebugGlobalInstance"])) { $GLOBALS["eZDebugGlobalInstance"]->GlobalLogFileEnabled = $settings['debug-log-files-enabled']; } } if (isset($settings['debug-styles'])) { $GLOBALS['eZDebugStyles'] = $settings['debug-styles']; } if (isset($settings['always-log']) and is_array($settings['always-log'])) { $GLOBALS['eZDebugAlwaysLog'] = $settings['always-log']; } if (isset($settings['log-only'])) { $GLOBALS['eZDebugLogOnly'] = $settings['log-only'] == 'enabled'; } $notDebugByIP = true; $debugEnabled = $settings['debug-enabled']; if ($settings['debug-enabled'] and $settings['debug-by-ip']) { $ipAddress = eZSys::serverVariable('REMOTE_ADDR', true); if ($ipAddress) { $debugEnabled = false; foreach ($settings['debug-ip-list'] as $itemToMatch) { if (preg_match("/^(([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+))(\\/([0-9]+)\$|\$)/", $itemToMatch, $matches)) { if ($matches[6]) { if (eZDebug::isIPInNet($ipAddress, $matches[1], $matches[7])) { $debugEnabled = true; $notDebugByIP = false; break; } } else { if ($matches[1] == $ipAddress) { $debugEnabled = true; $notDebugByIP = false; break; } } } } } else { $debugEnabled = in_array('commandline', $settings['debug-ip-list']) && php_sapi_name() == 'cli'; } } if ($settings['debug-enabled'] and isset($settings['debug-by-user']) and $settings['debug-by-user'] and $notDebugByIP) { $debugUserIDList = $settings['debug-user-list'] ? $settings['debug-user-list'] : array(); $GLOBALS['eZDebugUserIDList'] = $debugUserIDList; // We enable the debug temporarily. // In checkDebugByUser() will be last(final) check for debug by user id. $debugEnabled = true; } $GLOBALS['eZDebugEnabled'] = $debugEnabled; eZDebug::setHandleType($oldHandleType); }
static function protocolSchema() { $schema = ''; if (preg_match("#^([a-zA-Z]+)/.*\$#", eZSys::serverVariable('SERVER_PROTOCOL'), $schemaMatches)) { $schema = strtolower($schemaMatches[1]) . '://'; } return $schema; }
/** * Handles redirection to the mobile optimized interface * */ public function redirect() { $http = eZHTTPTool::instance(); $currentSiteAccess = eZSiteAccess::current(); if ($http->hasGetVariable('notmobile')) { setcookie('eZMobileDeviceDetect', 1, time() + (int) eZINI::instance()->variable('SiteAccessSettings', 'MobileDeviceDetectCookieTimeout'), '/'); $http->redirect(eZSys::indexDir()); eZExecution::cleanExit(); } if (!isset($_COOKIE['eZMobileDeviceDetect']) && !in_array($currentSiteAccess['name'], eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessList'))) { $http->redirect(eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessURL') . eZSys::serverVariable('REQUEST_URI')); eZExecution::cleanExit(); } }
/** * \static * \param $inSSL The desired access mode. * * Change access mode (HTTP/HTTPS): * - If previous mode was HHTP but $inSSL is true, we switch to SSL. * - If previous mode was SSL but $inSSL is false, we switch to HTTP. * - Otherwise no mode change is occured. * * Mode change is done by redirect to the same URL, but with changed * protocol (http/https) and TCP port. * * In case of mode change this method does not return (exit() is called). */ static function switchIfNeeded($inSSL) { // if it's undefined whether we should redirect we do nothing if (!isset($inSSL)) { return; } // $nowSSl is true if current access mode is HTTPS. $nowSSL = eZSys::isSSLNow(); $requestURI = eZSys::requestURI(); $indexDir = eZSys::indexDir(false); // If there are any $_GET parameters, those should be passed into the new URI $getString = eZSys::queryString(); $sslZoneRedirectionURL = false; if ($nowSSL && !$inSSL) { // switch to plain HTTP $ini = eZINI::instance(); $host = $ini->variable('SiteSettings', 'SiteURL'); $port = parse_url("http://{$host}", PHP_URL_PORT); $host = eZSys::serverVariable('HTTP_HOST'); $host = preg_replace('/:\\d+$/', '', $host); if ($port && $port != 80) { $host .= ":{$port}"; } $sslZoneRedirectionURL = "http://" . $host . $indexDir . $requestURI . $getString; } elseif (!$nowSSL && $inSSL) { // switch to HTTPS $host = eZSys::serverVariable('HTTP_HOST'); $host = preg_replace('/:\\d+$/', '', $host); $ini = eZINI::instance(); $sslPort = $ini->variable('SiteSettings', 'SSLPort'); $sslPortString = $sslPort == eZSSLZone::DEFAULT_SSL_PORT ? '' : ":{$sslPort}"; $sslZoneRedirectionURL = "https://" . $host . $sslPortString . $indexDir . $requestURI . $getString; } if ($sslZoneRedirectionURL) { eZDebugSetting::writeDebug('kernel-ssl-zone', "redirecting to [{$sslZoneRedirectionURL}]"); eZHTTPTool::redirect($sslZoneRedirectionURL, array(), false, false); eZExecution::cleanExit(); } }
function checkServerIP() { $remoteHostIP = eZSys::serverVariable('REMOTE_ADDR'); $serverIPList = $this->ini->variable('ServerSettings', 'ServerIP'); if ($serverIPList === false) { $this->logger->writeTimedString("Skipped the IP check because ServerIP is not set in the settings. Remote host is: {$remoteHostIP}.", 'checkServerIP'); return true; } if (is_array($serverIPList) && in_array($remoteHostIP, $serverIPList)) { return true; } $this->logger->writeTimedString("server with ip = {$remoteHostIP} does not exist.", 'checkServerIP failed'); $this->logger->writeTimedString($serverIPList, 'serverIPList from ini file is'); return false; }
public function process($tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace) { switch ($functionName) { case $this->FunctionName: $ini = eZINI::instance('ezsi.ini'); $SIMarkupIsEnabled = $ini->variable('DevelopmentSettings', 'ActivateSIMarkup') == 'enabled' ? true : false; $forceRegenerationString = $ini->variable('TemplateFunctionSettings', 'ForceRegenerationString'); $forceRegenerationValue = $ini->variable('TemplateFunctionSettings', 'ForceRegenerationValue'); $SIFileHandler = strtolower($ini->variable('SIFilesSettings', 'FileHandler')); $SIBlockHandler = strtolower($ini->variable('SIBlockSettings', 'BlockHandler')); $cronjobForUpdatesOnly = strtolower($ini->variable('CronjobSettings', 'CronjobForUpdatesOnly')) == 'yes' ? true : false; $configuredUserAgent = strtolower($ini->variable('CronjobSettings', 'UserAgentName')); // check for incompatible behavior, basically SSI + FTP if ($SIFileHandler == 'ftp' and $SIBlockHandler == 'ssi') { eZDebug::writeError('Incompatible configuration, SSI + FTP is not allowed', __METHOD__); break; } $regenerationIsForced = false; $http = eZHTTPTool::instance(); if (!$cronjobForUpdatesOnly and $http->hasGetVariable($forceRegenerationString) and $http->getVariable($forceRegenerationString) == $forceRegenerationValue) { $regenerationIsForced = true; } $userAgent = null; if (eZSys::serverVariable('HTTP_USER_AGENT') !== null) { $userAgent = strtolower(eZSys::serverVariable('HTTP_USER_AGENT')); } $blockFilePathPreprendString = $ini->variable('SIBlockSettings', 'BlockFilePathPrependString'); if ($this->keyIsValid($tpl, $rootNamespace, $currentNamespace, $functionParameters, $functionPlacement) and $this->ttlIsValid($tpl, $rootNamespace, $currentNamespace, $functionParameters, $functionPlacement)) { $blockKeyString = $this->generateBlockKeyString($tpl, $rootNamespace, $currentNamespace, $functionParameters, $functionPlacement); eZDebug::writeNotice($blockKeyString, __METHOD__); // generating filepath $cacheDir = $this->cacheBaseSubdir(); $fileName = $this->generateUniqueFilename($blockKeyString); if ($SIFileHandler == 'fs') { $blockFilePathPreprendString = 'var/'; } $filePath = $blockFilePathPreprendString . $cacheDir . '/' . $fileName; eZDebug::writeNotice($filePath, __METHOD__); if ($SIBlockHandler == 'ssi') { $this->SIBlockHandler->Src = './' . $filePath; } else { $this->SIBlockHandler->Src = $filePath; } // file exists ? if ($fileInfo = $this->fileExists($filePath)) { eZDebug::writeNotice('file exists : ' . $blockKeyString, __METHOD__); // does the ttl needs to be updated ? $blockTTL = $tpl->elementValue($functionParameters['ttl'], $rootNamespace, $currentNamespace, $functionPlacement); if (!$this->updateTTLIfNeeded($fileInfo[0]['ttl'], md5($filePath), $blockTTL)) { eZDebug::writeError('si-blocks : unable to update the TTL for file : ' . $filePath); } // expired ? if ($regenerationIsForced or $this->SIBlockHandler->fileIsExpired($fileInfo[0]['mtime']) and $cronjobForUpdatesOnly and $userAgent == $configuredUserAgent) { eZDebug::writeNotice('file expired : ' . $blockKeyString, __METHOD__); $htmlContents = $this->processChildren($tpl, $functionChildren, $rootNamespace, $currentNamespace); $db = eZDB::instance(); $db->begin(); // update file if ($this->SIFileHandler->storeFile($cacheDir, $fileName, $htmlContents)) { // update table if (!$this->updateRow($filePath, $this->SIBlockHandler->TTLInSeconds())) { $this->SIFileHandler->removeFile($cacheDir, $fileName); eZDebug::writeError($filePath . ' could not be updated', __METHOD__); $db->rollback(); } else { // yes I can commit the transaction here $db->commit(); if ($SIMarkupIsEnabled) { $textElements[] = $this->SIBlockHandler->generateMarkup(); } else { $textElements[] = $htmlContents; } } } else { eZDebug::writeError('Unable to store the file : ' . $filePath, __METHOD__); } } else { eZDebug::writeNotice('file valid : ' . $blockKeyString, __METHOD__); if ($SIMarkupIsEnabled) { $textElements[] = $this->SIBlockHandler->generateMarkup(); } else { $textElements[] = $this->processChildren($tpl, $functionChildren, $rootNamespace, $currentNamespace); } } } else { eZDebug::writeNotice('file does not exists : ' . $blockKeyString, __METHOD__); $htmlContents = $this->processChildren($tpl, $functionChildren, $rootNamespace, $currentNamespace); // A different process might have just generated // the file after processing a very heavy template // this avoid using a mutex if ($this->fileExists()) { if ($SIMarkupIsEnabled) { $textElements[] = $this->SIBlockHandler->generateMarkup(); } else { $textElements[] = $htmlContents; } break; } $db = eZDB::instance(); $db->begin(); // create file if ($this->SIFileHandler->storeFile($cacheDir, $fileName, $htmlContents)) { // insert into table if (!$this->writeRow($filePath, $this->SIBlockHandler->TTLInSeconds(), $blockKeyString)) { $this->SIFileHandler->removeFile($cacheDir, $fileName); eZDebug::writeError($filePath . ' could not be created', __METHOD__); $db->rollback(); } else { // yes I can commit the transaction here $db->commit(); if ($SIMarkupIsEnabled) { $textElements[] = $this->SIBlockHandler->generateMarkup(); } else { $textElements[] = $htmlContents; } } } else { eZDebug::writeError('Unable to store the file : ' . $filePath, __METHOD__); } } } break; } }
/** * This is called whenever an error occurs in one of the database handlers. * * If a transaction is active it will be invalidated as well. * * @access protected * @throws eZDBException */ function reportError() { // If we have a running transaction we must mark as invalid // in which case a call to commit() will perform a rollback if ($this->TransactionCounter > 0) { $this->invalidateTransaction(); // This is the unique ID for this incidence which will also be placed in the error logs. $transID = 'TRANSID-' . md5(time() . mt_rand()); eZDebug::writeError('Transaction in progress failed due to DB error, transaction was rollbacked. Transaction ID is ' . $transID . '.', 'eZDBInterface::commit ' . $transID); $this->rollback(); if ($this->errorHandling == eZDB::ERROR_HANDLING_EXCEPTIONS) { throw new eZDBException($this->ErrorMessage, $this->ErrorNumber); } else { // Stop execution immediately while allowing other systems (session etc.) to cleanup eZExecution::cleanup(); eZExecution::setCleanExit(); // Give some feedback, and also possibly show the debug output eZDebug::setHandleType(eZDebug::HANDLE_NONE); $ini = eZINI::instance(); $adminEmail = $ini->variable('MailSettings', 'AdminEmail'); if (!eZSys::isShellExecution()) { if (!headers_sent()) { header("HTTP/1.1 500 Internal Server Error"); } $site = eZSys::serverVariable('HTTP_HOST'); $uri = eZSys::serverVariable('REQUEST_URI'); print "<div class=\"fatal-error\" style=\""; print 'margin: 0.5em 0 1em 0; ' . 'padding: 0.25em 1em 0.75em 1em;' . 'border: 4px solid #000000;' . 'background-color: #f8f8f4;' . 'border-color: #f95038;" >'; print "<b>Fatal error</b>: A database transaction in eZ Publish failed.<br/>"; print "<p>"; print "The current execution was stopped to prevent further problems.<br/>\n" . "You should contact the <a href=\"mailto:{$adminEmail}?subject=Transaction failed on {$site} and URI {$uri} with ID {$transID}\">System Administrator</a> of this site with the information on this page.<br/>\n" . "The current transaction ID is <b>{$transID}</b> and has been logged.<br/>\n" . "Please include the transaction ID and the current URL when contacting the system administrator.<br/>\n"; print "</p>"; print "</div>"; $templateResult = null; if (function_exists('eZDisplayResult')) { eZDisplayResult($templateResult); } } else { fputs(STDERR, "Fatal error: A database transaction in eZ Publish failed.\n"); fputs(STDERR, "\n"); fputs(STDERR, "The current execution was stopped to prevent further problems.\n" . "You should contact the System Administrator ({$adminEmail}) of this site.\n" . "The current transaction ID is {$transID} and has been logged.\n" . "Please include the transaction ID and the name of the current script when contacting the system administrator.\n"); fputs(STDERR, "\n"); fputs(STDERR, eZDebug::printReport(false, false, true)); } // PHP execution stops here exit(1); } } }
/** * Returns the client IP whether he's behind a proxy or not * * Use [HTTPHeaderSettings].ClientIpByCustomHTTPHeader in site.ini if you want * to use a custom http header such as X-Forwarded-For * * Note: X-Forwarded-For is transformed by PHP * into $_SERVER['HTTP_X_FORWARDED_FOR] * * eZDebug calls in this method should be avoided as there is a risk of infinite recurstion * due to IP check (http://issues.ez.no/19045 * * @return string */ public static function clientIP() { $customHTTPHeader = eZINI::instance()->variable( 'HTTPHeaderSettings', 'ClientIpByCustomHTTPHeader' ); if( $customHTTPHeader && $customHTTPHeader != 'false' ) { // Transforms for instance, X-Forwarded-For into X_FORWARDED_FOR $phpHeader = 'HTTP_' . str_replace( '-', '_', strtoupper( $customHTTPHeader ) ); $forwardedClientsString = eZSys::serverVariable( $phpHeader, true ); if ( $forwardedClientsString ) { // $forwardedClientsString (usually) contains a comma+space separated list of IPs // where the left-most being the farthest downstream client. All the others are proxy servers. // As X-Forwarded-For is not a standard header yet, we prefer to use a simple comma as the explode delimiter $forwardedClients = explode( ',', $forwardedClientsString ); if( !empty( $forwardedClients ) ) { return trim( $forwardedClients[0] ); } } } return self::serverVariable( 'REMOTE_ADDR', true ); }
$server->showResponse('unknown_function_name', $namespaceURI, new ggWebservicesFault(ggWebservicesServer::INVALIDREQUESTERROR, ggWebservicesServer::INVALIDREQUESTSTRING)); eZExecution::cleanExit(); die; } if ($protocol == 'REST') { // hack! eZ is better at parsing the last path part than the REST request // on its own (in an eZP context...) $functionName = $Params['session']; } else { $functionName = $request->name(); } $params = $request->parameters(); $wsINI = eZINI::instance('wsproviders.ini'); // auth: validate incoming IP address first if ($wsINI->variable('GeneralSettings', 'ValidateClientIPs') == 'enabled') { $ip = is_callable('eZSys::clientIP') ? eZSys::clientIP() : eZSys::serverVariable('REMOTE_ADDR'); if (!in_array($ip, $wsINI->variable('GeneralSettings', 'ValidClientIPs'))) { // Error: access denied. We respond using an answer which is correct according // to the protocol used by the caller, instead of going through the standard // eZ access denied error handler, which displays in general an html page // with a 200 OK http return code $server->showResponse($functionName, $namespaceURI, new ggWebservicesFault(ggWebservicesServer::INVALIDAUTHERROR, ggWebservicesServer::INVALIDAUTHSTRING)); eZExecution::cleanExit(); die; // $module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' ); } } // if integration with jscore is enabled, look up function there // NB: ezjscServerRouter::getInstance does internally perms checking, but // it does not return to us different values for method not found / perms not accorded if ($wsINI->variable('GeneralSettings', 'JscoreIntegration') == 'enabled' && class_exists('ezjscServerRouter')) {
/** * @param array $settings * @param null $responseWriterClass Name of the ezpRestHttpResponseWriter implementation to use during request */ public function __construct(array $settings = array(), $responseWriterClass = null) { $this->responseWriterClass = $responseWriterClass; if (isset($settings['injected-settings'])) { $injectedSettings = array(); foreach ($settings['injected-settings'] as $keySetting => $injectedSetting) { list($file, $section, $setting) = explode('/', $keySetting); $injectedSettings[$file][$section][$setting] = $injectedSetting; } // Those settings override anything else in local .ini files and their overrides eZINI::injectSettings($injectedSettings); } if (isset($settings['injected-merge-settings'])) { $injectedSettings = array(); foreach ($settings['injected-merge-settings'] as $keySetting => $injectedSetting) { list($file, $section, $setting) = explode('/', $keySetting); $injectedSettings[$file][$section][$setting] = $injectedSetting; } // Those settings override anything else in local .ini files and their overrides eZINI::injectMergeSettings($injectedSettings); } $this->settings = $settings + array('use-cache-headers' => true, 'max-age' => 86400, 'siteaccess' => null, 'use-exceptions' => false); unset($settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting); // lazy loaded database driver include __DIR__ . '/lazy.php'; $this->setUseExceptions($this->settings['use-exceptions']); // Tweaks ini filetime checks if not defined! // This makes ini system not check modified time so // that index_treemenu.php can assume that index.php does // this regular enough, set in config.php to override. if (!defined('EZP_INI_FILEMTIME_CHECK')) { define('EZP_INI_FILEMTIME_CHECK', false); } eZExecution::addFatalErrorHandler(function () { if (!headers_sent()) { header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); } }); eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP); // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs): $_SERVER['SCRIPT_FILENAME'] = str_replace('/index_rest.php', '/index.php', $_SERVER['SCRIPT_FILENAME']); $_SERVER['PHP_SELF'] = str_replace('/index_rest.php', '/index.php', $_SERVER['PHP_SELF']); $ini = eZINI::instance(); $timezone = $ini->variable('TimeZoneSettings', 'TimeZone'); if ($timezone) { putenv("TZ={$timezone}"); } eZDebug::setHandleType(eZDebug::HANDLE_NONE); $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI'); $ini = eZINI::instance(); eZSys::init('index_rest.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') == 'true'); $uri = eZURI::instance(eZSys::requestURI()); $GLOBALS['eZRequestedURI'] = $uri; // load extensions eZExtension::activateExtensions('default'); require_once __DIR__ . '/restkernel_functions.php'; // set siteaccess from X-Siteaccess header if given and exists if (isset($_SERVER['HTTP_X_SITEACCESS']) && eZSiteAccess::exists($_SERVER['HTTP_X_SITEACCESS'])) { $access = array('name' => $_SERVER['HTTP_X_SITEACCESS'], 'type' => eZSiteAccess::TYPE_STATIC); } else { $access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile()); } eZSiteAccess::change($access); // load siteaccess extensions eZExtension::activateExtensions('access'); // Now that all extensions are activated and siteaccess has been changed, reset // all eZINI instances as they may not take into account siteaccess specific settings. eZINI::resetAllInstances(false); if (ezpRestDebug::isDebugEnabled()) { $debug = ezpRestDebug::getInstance(); $debug->updateDebugSettings(); } }
private static function isAllowedByCurrentIP($allowedIpList) { $ipAddress = eZSys::serverVariable('REMOTE_ADDR', true); if ($ipAddress) { foreach ($allowedIpList as $itemToMatch) { if (preg_match("/^(([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+))(\\/([0-9]+)\$|\$)/", $itemToMatch, $matches)) { if ($matches[6]) { if (self::isIPInNet($ipAddress, $matches[1], $matches[7])) { return true; } } else { if ($matches[1] == $ipAddress) { return true; } } } } return false; } else { return eZSys::isShellExecution() && in_array('commandline', $allowedIpList); } }
/** * browserSupportsDHTMLType * Identify supported browser by layout engine using user agent string. * * @static * @return string|false Name of supported layout engine or false */ public static function browserSupportsDHTMLType() { if ( self::$browserType === null ) { self::$browserType = false; $userAgent = eZSys::serverVariable( 'HTTP_USER_AGENT' ); // Opera 9.6+ if ( strpos( $userAgent, 'Presto' ) !== false && preg_match('/Presto\/([0-9\.]+)/i', $userAgent, $browserInfo ) ) { if ( $browserInfo[1] >= 2.1 ) self::$browserType = 'Presto'; } // IE 8.0+ else if ( strpos( $userAgent, 'Trident' ) !== false && preg_match('/Trident\/([0-9\.]+)/i', $userAgent, $browserInfo ) ) { if ( $browserInfo[1] >= 4.0 ) self::$browserType = 'Trident'; } // IE 6 & 7 else if ( strpos( $userAgent, 'MSIE' ) !== false && preg_match('/MSIE[ \/]([0-9\.]+)/i', $userAgent, $browserInfo ) ) { if ( $browserInfo[1] >= 6.0 ) self::$browserType = 'Trident'; } // Firefox 3+ else if ( strpos( $userAgent, 'Gecko' ) !== false && preg_match('/rv:([0-9\.]+)/i', $userAgent, $browserInfo ) ) { if ( $browserInfo[1] >= 1.9 ) self::$browserType = 'Gecko'; } // Safari 4+ (and Chrome) else if ( strpos( $userAgent, 'WebKit' ) !== false && strpos( $userAgent, 'Mobile' ) === false && strpos( $userAgent, 'Android' ) === false && strpos( $userAgent, 'iPad' ) === false && strpos( $userAgent, 'iPhone' ) === false && strpos( $userAgent, 'iPod' ) === false && preg_match('/WebKit\/([0-9\.]+)/i', $userAgent, $browserInfo ) ) { if ( $browserInfo[1] >= 528.16 ) self::$browserType = 'WebKit'; } // iOS 5+ else if ( strpos( $userAgent, 'AppleWebKit' ) !== false && strpos( $userAgent, 'Mobile' ) !== false && strpos( $userAgent, 'Android' ) === false &&//@todo: remove when Android is supported in TinyMCE preg_match('/AppleWebKit\/([0-9\.]+)/i', $userAgent, $browserInfo ) ) { if ( $browserInfo[1] >= 534.46 ) self::$browserType = 'MobileWebKit'; } if ( self::$browserType === false ) eZDebug::writeNotice( 'Browser not supported: ' . $userAgent, __METHOD__ ); } return self::$browserType; }
/** * Goes trough the access matching rules and returns the access match. * The returned match is an associative array with: * name => string Name of the siteaccess (same as folder name) * type => int The constant that represent the matching used * uri_part => array(string) List of path elements that was used in start of url for the match * * @since 4.4 * @param eZURI $uri * @param string $host * @param string(numeric) $port * @param string $file Example '/index.php' * @return array */ public static function match(eZURI $uri, $host, $port = 80, $file = '/index.php') { eZDebugSetting::writeDebug('kernel-siteaccess', array('uri' => $uri, 'host' => $host, 'port' => $port, 'file' => $file), __METHOD__); $ini = eZINI::instance(); if ($ini->hasVariable('SiteAccessSettings', 'StaticMatch')) { $match = $ini->variable('SiteAccessSettings', 'StaticMatch'); if ($match != '') { $access = array('name' => $match, 'type' => eZSiteAccess::TYPE_STATIC, 'uri_part' => array()); return $access; } } list($siteAccessList, $order) = $ini->variableMulti('SiteAccessSettings', array('AvailableSiteAccessList', 'MatchOrder')); $access = array('name' => $ini->variable('SiteSettings', 'DefaultAccess'), 'type' => eZSiteAccess::TYPE_DEFAULT, 'uri_part' => array()); if ($order == 'none') { return $access; } $order = $ini->variableArray('SiteAccessSettings', 'MatchOrder'); // Change the default type to eZSiteAccess::TYPE_URI if we're using URI MatchOrder. // This is to keep backward compatiblity with the ezurl operator. ezurl has since // rev 4949 added default siteaccess to generated URLs, even when there is // no siteaccess in the current URL. if (in_array('uri', $order)) { $access['type'] = eZSiteAccess::TYPE_URI; } foreach ($order as $matchprobe) { $name = ''; $type = ''; $match_type = ''; $uri_part = array(); switch ($matchprobe) { case 'servervar': if ($serversiteaccess = eZSys::serverVariable($ini->variable('SiteAccessSettings', 'ServerVariableName'), true)) { $access['name'] = $serversiteaccess; $access['type'] = eZSiteAccess::TYPE_SERVER_VAR; return $access; } else { continue; } break; case 'port': if ($ini->hasVariable('PortAccessSettings', $port)) { $access['name'] = $ini->variable('PortAccessSettings', $port); $access['type'] = eZSiteAccess::TYPE_PORT; return $access; } else { continue; } break; case 'uri': $type = eZSiteAccess::TYPE_URI; $match_type = $ini->variable('SiteAccessSettings', 'URIMatchType'); if ($match_type == 'map') { if ($ini->hasVariable('SiteAccessSettings', 'URIMatchMapItems')) { $match_item = $uri->element(0); $matchMapItems = $ini->variableArray('SiteAccessSettings', 'URIMatchMapItems'); foreach ($matchMapItems as $matchMapItem) { $matchMapURI = $matchMapItem[0]; $matchMapAccess = $matchMapItem[1]; if ($access['name'] == $matchMapAccess and in_array($matchMapAccess, $siteAccessList)) { $uri_part = array($matchMapURI); } if ($matchMapURI == $match_item and in_array($matchMapAccess, $siteAccessList)) { $uri->increase(1); $uri->dropBase(); $access['name'] = $matchMapAccess; $access['type'] = $type; $access['uri_part'] = array($matchMapURI); return $access; } } } } else { if ($match_type == 'element') { $match_index = $ini->variable('SiteAccessSettings', 'URIMatchElement'); $elements = $uri->elements(false); $elements = array_slice($elements, 0, $match_index); $name = implode('_', $elements); $uri_part = $elements; } else { if ($match_type == 'text') { $match_item = $uri->elements(); $matcher_pre = $ini->variable('SiteAccessSettings', 'URIMatchSubtextPre'); $matcher_post = $ini->variable('SiteAccessSettings', 'URIMatchSubtextPost'); } else { if ($match_type == 'regexp') { $match_item = $uri->elements(); $matcher = $ini->variable('SiteAccessSettings', 'URIMatchRegexp'); $match_num = $ini->variable('SiteAccessSettings', 'URIMatchRegexpItem'); } else { continue; } } } } break; case 'host': $type = eZSiteAccess::TYPE_HTTP_HOST; $match_type = $ini->variable('SiteAccessSettings', 'HostMatchType'); $match_item = $host; if ($match_type == 'map') { if ($ini->hasVariable('SiteAccessSettings', 'HostMatchMapItems')) { $matchMapItems = $ini->variableArray('SiteAccessSettings', 'HostMatchMapItems'); foreach ($matchMapItems as $matchMapItem) { $matchMapHost = $matchMapItem[0]; $matchMapAccess = $matchMapItem[1]; if ($matchMapHost == $host) { $access['name'] = $matchMapAccess; $access['type'] = $type; return $access; } } } } else { if ($match_type == 'element') { $match_index = $ini->variable('SiteAccessSettings', 'HostMatchElement'); $match_arr = explode('.', $match_item); $name = $match_arr[$match_index]; } else { if ($match_type == 'text') { $matcher_pre = $ini->variable('SiteAccessSettings', 'HostMatchSubtextPre'); $matcher_post = $ini->variable('SiteAccessSettings', 'HostMatchSubtextPost'); } else { if ($match_type == 'regexp') { $matcher = $ini->variable('SiteAccessSettings', 'HostMatchRegexp'); $match_num = $ini->variable('SiteAccessSettings', 'HostMatchRegexpItem'); } else { continue; } } } } break; case 'host_uri': $type = eZSiteAccess::TYPE_HTTP_HOST_URI; if ($ini->hasVariable('SiteAccessSettings', 'HostUriMatchMapItems')) { $uriString = $uri->elements(); $matchMapItems = $ini->variableArray('SiteAccessSettings', 'HostUriMatchMapItems'); $defaultHostMatchMethod = $ini->variable('SiteAccessSettings', 'HostUriMatchMethodDefault'); foreach ($matchMapItems as $matchMapItem) { $matchHost = $matchMapItem[0]; $matchURI = $matchMapItem[1]; $matchAccess = $matchMapItem[2]; $matchHostMethod = isset($matchMapItem[3]) ? $matchMapItem[3] : $defaultHostMatchMethod; if ($matchURI !== '' && !preg_match("@^{$matchURI}\\b@", $uriString)) { continue; } switch ($matchHostMethod) { case 'strict': $hasHostMatch = $matchHost === $host; break; case 'start': $hasHostMatch = strpos($host, $matchHost) === 0; break; case 'end': $hasHostMatch = strstr($host, $matchHost) === $matchHost; break; case 'part': $hasHostMatch = strpos($host, $matchHost) !== false; break; default: $hasHostMatch = false; eZDebug::writeError("Unknown host_uri host match: {$matchHostMethod}", "access"); break; } if ($hasHostMatch) { if ($matchURI !== '') { $matchURIFolders = explode('/', $matchURI); $uri->increase(count($matchURIFolders)); $uri->dropBase(); $access['uri_part'] = $matchURIFolders; } $access['name'] = $matchAccess; $access['type'] = $type; return $access; } } } break; case 'index': $type = eZSiteAccess::TYPE_INDEX_FILE; $match_type = $ini->variable('SiteAccessSettings', 'IndexMatchType'); $match_item = $file; if ($match_type == 'element') { $match_index = $ini->variable('SiteAccessSettings', 'IndexMatchElement'); $match_pos = strpos($match_item, '.php'); if ($match_pos !== false) { $match_item = substr($match_item, 0, $match_pos); $match_arr = explode('_', $match_item); $name = $match_arr[$match_index]; } } else { if ($match_type == 'text') { $matcher_pre = $ini->variable('SiteAccessSettings', 'IndexMatchSubtextPre'); $matcher_post = $ini->variable('SiteAccessSettings', 'IndexMatchSubtextPost'); } else { if ($match_type == 'regexp') { $matcher = $ini->variable('SiteAccessSettings', 'IndexMatchRegexp'); $match_num = $ini->variable('SiteAccessSettings', 'IndexMatchRegexpItem'); } else { continue; } } } break; default: eZDebug::writeError("Unknown access match: {$matchprobe}", "access"); break; } if ($match_type == 'regexp') { $name = self::matchRegexp($match_item, $matcher, $match_num); } else { if ($match_type == 'text') { $name = self::matchText($match_item, $matcher_pre, $matcher_post); } } if (isset($name) && $name != '') { $nameClean = self::washName($name); if (in_array($nameClean, $siteAccessList)) { if ($nameClean !== $name) { if (!$ini->hasVariable('SiteAccessSettings', 'NormalizeSANames') || $ini->variable('SiteAccessSettings', 'NormalizeSANames') == 'enabled') { $name = $nameClean; if ($ini->hasVariable('SiteAccessSettings', 'RedirectOnNormalize') && $ini->variable('SiteAccessSettings', 'RedirectOnNormalize') == 'enabled') { header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently"); header("Status: 301 Moved Permanently"); $uriSlice = $uri->URIArray; array_shift($uriSlice); $newUri = $name . '/' . implode('/', $uriSlice); $location = eZSys::indexDir() . "/" . eZURI::encodeIRI($newUri); header("Location: " . $location); eZExecution::cleanExit(); } } } if ($type == eZSiteAccess::TYPE_URI) { if ($match_type == 'element') { $uri->increase($match_index); $uri->dropBase(); } else { if ($match_type == 'regexp') { $uri->setURIString($match_item); } else { if ($match_type == 'text') { $uri->setURIString($match_item); } } } } $access['type'] = $type; $access['name'] = $name; $access['uri_part'] = $uri_part; return $access; } } } return $access; }
/** * Goes trough the access matching rules and returns the access match. * The returned match is an associative array with: * name => string Name of the siteaccess (same as folder name) * type => int The constant that represent the matching used * uri_part => array(string) List of path elements that was used in start of url for the match * * @since 4.4 * @param eZURI $uri * @param string $host * @param string(numeric) $port * @param string $file Example '/index.php' * @return array */ public static function match( eZURI $uri, $host, $port = 80, $file = '/index.php' ) { eZDebugSetting::writeDebug( 'kernel-siteaccess', array( 'uri' => $uri, 'host' => $host, 'port' => $port, 'file' => $file ), __METHOD__ ); $ini = eZINI::instance(); if ( $ini->hasVariable( 'SiteAccessSettings', 'StaticMatch' ) ) { $match = $ini->variable( 'SiteAccessSettings', 'StaticMatch' ); if ( $match != '' ) { $access = array( 'name' => $match, 'type' => eZSiteAccess::TYPE_STATIC, 'uri_part' => array() ); return $access; } } list( $siteAccessList, $order ) = $ini->variableMulti( 'SiteAccessSettings', array( 'AvailableSiteAccessList', 'MatchOrder' ) ); $access = array( 'name' => $ini->variable( 'SiteSettings', 'DefaultAccess' ), 'type' => eZSiteAccess::TYPE_DEFAULT, 'uri_part' => array() ); if ( $order == 'none' ) return $access; $order = $ini->variableArray( 'SiteAccessSettings', 'MatchOrder' ); // Change the default type to eZSiteAccess::TYPE_URI if we're using URI MatchOrder. // This is to keep backward compatiblity with the ezurl operator. ezurl has since // rev 4949 added default siteaccess to generated URLs, even when there is // no siteaccess in the current URL. if ( in_array( 'uri', $order ) ) { $access['type'] = eZSiteAccess::TYPE_URI; } foreach ( $order as $matchprobe ) { $name = ''; $type = ''; $match_type = ''; $uri_part = array(); switch( $matchprobe ) { case 'servervar': { if ( $serversiteaccess = eZSys::serverVariable( $ini->variable( 'SiteAccessSettings', 'ServerVariableName' ), true ) ) { $access['name'] = $serversiteaccess; $access['type'] = eZSiteAccess::TYPE_SERVER_VAR; return $access; } else continue; } break; case 'port': { if ( $ini->hasVariable( 'PortAccessSettings', $port ) ) { $access['name'] = $ini->variable( 'PortAccessSettings', $port ); $access['type'] = eZSiteAccess::TYPE_PORT; return $access; } else continue; } break; case 'uri': { $type = eZSiteAccess::TYPE_URI; $match_type = $ini->variable( 'SiteAccessSettings', 'URIMatchType' ); if ( $match_type == 'map' ) { if ( $ini->hasVariable( 'SiteAccessSettings', 'URIMatchMapItems' ) ) { $match_item = $uri->element( 0 ); $matchMapItems = $ini->variableArray( 'SiteAccessSettings', 'URIMatchMapItems' ); foreach ( $matchMapItems as $matchMapItem ) { $matchMapURI = $matchMapItem[0]; $matchMapAccess = $matchMapItem[1]; if ( $access['name'] == $matchMapAccess and in_array( $matchMapAccess, $siteAccessList ) ) { $uri_part = array( $matchMapURI ); } if ( $matchMapURI == $match_item and in_array( $matchMapAccess, $siteAccessList ) ) { $uri->increase( 1 ); $uri->dropBase(); $access['name'] = $matchMapAccess; $access['type'] = $type; $access['uri_part'] = array( $matchMapURI ); return $access; } } } } else if ( $match_type == 'element' ) { $match_index = $ini->variable( 'SiteAccessSettings', 'URIMatchElement' ); $elements = $uri->elements( false ); $elements = array_slice( $elements, 0, $match_index ); $name = implode( '_', $elements ); $uri_part = $elements; } else if ( $match_type == 'text' ) { $match_item = $uri->elements(); $matcher_pre = $ini->variable( 'SiteAccessSettings', 'URIMatchSubtextPre' ); $matcher_post = $ini->variable( 'SiteAccessSettings', 'URIMatchSubtextPost' ); } else if ( $match_type == 'regexp' ) { $match_item = $uri->elements(); $matcher = $ini->variable( 'SiteAccessSettings', 'URIMatchRegexp' ); $match_num = $ini->variable( 'SiteAccessSettings', 'URIMatchRegexpItem' ); } else continue; } break; case 'host': { $type = eZSiteAccess::TYPE_HTTP_HOST; $match_type = $ini->variable( 'SiteAccessSettings', 'HostMatchType' ); $match_item = $host; if ( $match_type == 'map' ) { if ( $ini->hasVariable( 'SiteAccessSettings', 'HostMatchMapItems' ) ) { $matchMapItems = $ini->variableArray( 'SiteAccessSettings', 'HostMatchMapItems' ); foreach ( $matchMapItems as $matchMapItem ) { $matchMapHost = $matchMapItem[0]; $matchMapAccess = $matchMapItem[1]; if ( $matchMapHost == $host ) { $access['name'] = $matchMapAccess; $access['type'] = $type; return $access; } } } } else if ( $match_type == 'element' ) { $match_index = $ini->variable( 'SiteAccessSettings', 'HostMatchElement' ); $match_arr = explode( '.', $match_item ); $name = $match_arr[$match_index]; } else if ( $match_type == 'text' ) { $matcher_pre = $ini->variable( 'SiteAccessSettings', 'HostMatchSubtextPre' ); $matcher_post = $ini->variable( 'SiteAccessSettings', 'HostMatchSubtextPost' ); } else if ( $match_type == 'regexp' ) { $matcher = $ini->variable( 'SiteAccessSettings', 'HostMatchRegexp' ); $match_num = $ini->variable( 'SiteAccessSettings', 'HostMatchRegexpItem' ); } else continue; } break; case 'host_uri': { $type = eZSiteAccess::TYPE_HTTP_HOST_URI; if ( $ini->hasVariable( 'SiteAccessSettings', 'HostUriMatchMapItems' ) ) { $uriString = $uri->elements(); $matchMapItems = $ini->variableArray( 'SiteAccessSettings', 'HostUriMatchMapItems' ); $defaultHostMatchMethod = $ini->variable( 'SiteAccessSettings', 'HostUriMatchMethodDefault' ); foreach ( $matchMapItems as $matchMapItem ) { $matchHost = $matchMapItem[0]; $matchURI = $matchMapItem[1]; $matchAccess = $matchMapItem[2]; $matchHostMethod = isset( $matchMapItem[3] ) ? $matchMapItem[3] : $defaultHostMatchMethod; if ( $matchURI !== '' && strpos($uriString, $matchURI) !== 0 ) continue; switch( $matchHostMethod ) { case 'strict': { $hasHostMatch = ( $matchHost === $host ); } break; case 'start': { $hasHostMatch = ( strpos($host, $matchHost) === 0 ); } break; case 'end': { $hasHostMatch = ( strstr($host, $matchHost) === $matchHost ); } break; case 'part': { $hasHostMatch = ( strpos($host, $matchHost) !== false ); } break; default: { $hasHostMatch = false; eZDebug::writeError( "Unknown host_uri host match: $matchHostMethod", "access" ); } break; } if ( $hasHostMatch ) { if ( $matchURI !== '' ) { $matchURIFolders = explode( '/', $matchURI ); $uri->increase( count( $matchURIFolders ) ); $uri->dropBase(); $access['uri_part'] = $matchURIFolders; } $access['name'] = $matchAccess; $access['type'] = $type; return $access; } } } } break; case 'index': { $type = eZSiteAccess::TYPE_INDEX_FILE; $match_type = $ini->variable( 'SiteAccessSettings', 'IndexMatchType' ); $match_item = $file; if ( $match_type == 'element' ) { $match_index = $ini->variable( 'SiteAccessSettings', 'IndexMatchElement' ); $match_pos = strpos( $match_item, '.php' ); if ( $match_pos !== false ) { $match_item = substr( $match_item, 0, $match_pos ); $match_arr = explode( '_', $match_item ); $name = $match_arr[$match_index]; } } else if ( $match_type == 'text' ) { $matcher_pre = $ini->variable( 'SiteAccessSettings', 'IndexMatchSubtextPre' ); $matcher_post = $ini->variable( 'SiteAccessSettings', 'IndexMatchSubtextPost' ); } else if ( $match_type == 'regexp' ) { $matcher = $ini->variable( 'SiteAccessSettings', 'IndexMatchRegexp' ); $match_num = $ini->variable( 'SiteAccessSettings', 'IndexMatchRegexpItem' ); } else continue; } break; default: { eZDebug::writeError( "Unknown access match: $matchprobe", "access" ); } break; } if ( $match_type == 'regexp' ) $name = self::matchRegexp( $match_item, $matcher, $match_num ); else if ( $match_type == 'text' ) $name = self::matchText( $match_item, $matcher_pre, $matcher_post ); if ( isset( $name ) && $name != '' ) { $name = preg_replace( array( '/[^a-zA-Z0-9]+/', '/_+/', '/^_/', '/_$/' ), array( '_', '_', '', '' ), $name ); if ( in_array( $name, $siteAccessList ) ) { if ( $type == eZSiteAccess::TYPE_URI ) { if ( $match_type == 'element' ) { $uri->increase( $match_index ); $uri->dropBase(); } else if ( $match_type == 'regexp' ) { $uri->setURIString( $match_item ); } else if ( $match_type == 'text' ) { $uri->setURIString( $match_item ); } } $access['type'] = $type; $access['name'] = $name; $access['uri_part'] = $uri_part; return $access; } } } return $access; }
if ($quantity <= 0) { $quantity = 1; } } else { $quantity = 1; } if ($http->hasPostVariable('eZOption')) { $optionList = $http->postVariable('eZOption'); } else { $optionList = array(); } $fromPage = ''; if ($http->hasSessionVariable('LastAccessesURI')) { $fromPage = $http->sessionVariable('LastAccessesURI'); } else { $fromPage = eZSys::serverVariable('HTTP_REFERER', true); } $http->setSessionVariable("FromPage", $fromPage); $http->setSessionVariable("AddToBasket_OptionList_" . $objectID, $optionList); $module->redirectTo("/shop/add/" . $objectID . "/" . $quantity); return; } if ($http->hasPostVariable("RemoveProductItemButton")) { $itemCountList = $http->postVariable("ProductItemCountList"); $itemIDList = $http->postVariable("ProductItemIDList"); if (is_array($itemCountList) && is_array($itemIDList) && count($itemCountList) == count($itemIDList) && is_object($basket)) { $productCollectionID = $basket->attribute('productcollection_id'); $removeItem = $http->postVariable("RemoveProductItemButton"); if ($http->hasPostVariable("RemoveProductItemDeleteList")) { $itemList = $http->postVariable("RemoveProductItemDeleteList"); } else {
if ( isset( $errorMap[$errorNumber] ) ) { $httpErrorCode = $errorMap[$errorNumber]; if ( $errorINI->hasVariable( 'HTTPError-' . $httpErrorCode, 'HTTPName' ) ) { $httpErrorName = $errorINI->variable( 'HTTPError-' . $httpErrorCode, 'HTTPName' ); $httpErrorString = "$httpErrorCode $httpErrorName"; if ( $errorNumber == eZError::KERNEL_MOVED ) { $module->redirectTo( $extraErrorParameters['new_location'] ); $module->setRedirectStatus( $httpErrorString ); return array(); // $Result of this view } else { header( eZSys::serverVariable( 'SERVER_PROTOCOL' ) . " $httpErrorString" ); header( "Status: $httpErrorString" ); } } } } } eZDebug::writeError( "Error ocurred using URI: " . $_SERVER['REQUEST_URI'] , "error/view.php" ); if ( $errorHandlerType == 'redirect' ) { $errorRedirectURL = $errorINI->variable( 'ErrorSettings', 'DefaultRedirectURL' ); if ( isset( $redirectURLList[$errorNumber] ) ) $errorRedirectURL = $redirectURLList[$errorNumber]; return $module->redirectTo( $errorRedirectURL );
/** * \static * \param $inSSL The desired access mode. * * Change access mode (HTTP/HTTPS): * - If previous mode was HHTP but $inSSL is true, we switch to SSL. * - If previous mode was SSL but $inSSL is false, we switch to HTTP. * - Otherwise no mode change is occured. * * Mode change is done by redirect to the same URL, but with changed * protocol (http/https) and TCP port. * * In case of mode change this method does not return (exit() is called). */ static function switchIfNeeded( $inSSL ) { // if it's undefined whether we should redirect we do nothing if ( !isset( $inSSL ) ) return; // $nowSSl is true if current access mode is HTTPS. $nowSSL = eZSys::isSSLNow(); $requestURI = eZSys::requestURI(); $indexDir = eZSys::indexDir( false ); $sslZoneRedirectionURL = false; if ( $nowSSL && !$inSSL ) { // switch to plain HTTP $ini = eZINI::instance(); $host = $ini->variable( 'SiteSettings', 'SiteURL' ); $sslZoneRedirectionURL = "http://" . $host . $indexDir . $requestURI; } elseif ( !$nowSSL && $inSSL ) { // switch to HTTPS $host = eZSys::serverVariable( 'HTTP_HOST' ); $host = preg_replace( '/:\d+$/', '', $host ); $ini = eZINI::instance(); $sslPort = $ini->variable( 'SiteSettings', 'SSLPort' ); $sslPortString = ( $sslPort == eZSSLZone::DEFAULT_SSL_PORT ) ? '' : ":$sslPort"; $sslZoneRedirectionURL = "https://" . $host . $sslPortString . $indexDir . $requestURI; } if ( $sslZoneRedirectionURL ) // if a redirection URL is found { eZDebugSetting::writeDebug( 'kernel-ssl-zone', "redirecting to [$sslZoneRedirectionURL]" ); eZHTTPTool::redirect( $sslZoneRedirectionURL, array(), false, false ); eZExecution::cleanExit(); } }
eZExecution::addFatalErrorHandler( 'eZFatalError' ); eZDebug::setHandleType( eZDebug::HANDLE_FROM_PHP ); // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs): $_SERVER['SCRIPT_FILENAME'] = str_replace( '/index_treemenu.php', '/index.php', $_SERVER['SCRIPT_FILENAME'] ); $_SERVER['PHP_SELF'] = str_replace( '/index_treemenu.php', '/index.php', $_SERVER['PHP_SELF'] ); $ini = eZINI::instance(); $timezone = $ini->variable( 'TimeZoneSettings', 'TimeZone' ); if ( $timezone ) { putenv( "TZ=$timezone" ); } // init uri code $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' ); eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' ); $uri = eZURI::instance( eZSys::requestURI() ); $GLOBALS['eZRequestedURI'] = $uri; // Check for extension eZExtension::activateExtensions( 'default' ); // load siteaccess $access = eZSiteAccess::match( $uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile() ); $access = eZSiteAccess::change( $access ); $GLOBALS['eZCurrentAccess'] = $access;
/** * Constructs an ezpKernel instance */ public function __construct(array $settings = array()) { $this->settings = $settings + array('siteaccess' => null, 'use-exceptions' => false, 'session' => null); unset($settings); require_once __DIR__ . '/global_functions.php'; $this->setUseExceptions($this->settings['use-exceptions']); $GLOBALS['eZSiteBasics'] = array('external-css' => true, 'show-page-layout' => true, 'module-run-required' => true, 'policy-check-required' => true, 'policy-check-omit-list' => array(), 'url-translator-allowed' => true, 'validity-check-required' => false, 'user-object-required' => true, 'session-required' => true, 'db-required' => false, 'no-cache-adviced' => false, 'site-design-override' => false, 'module-repositories' => array()); $this->siteBasics =& $GLOBALS['eZSiteBasics']; // Reads settings from i18n.ini and passes them to eZTextCodec. list($i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension']) = eZINI::instance('i18n.ini')->variableMulti('CharacterSettings', array('Charset', 'HTTPCharset', 'MBStringExtension'), array(false, false, 'enabled')); eZTextCodec::updateSettings($i18nSettings); // @todo Change so code only supports utf-8 in 5.0? // Initialize debug settings. eZUpdateDebugSettings(); // Set the different permissions/settings. $ini = eZINI::instance(); // Set correct site timezone $timezone = $ini->variable("TimeZoneSettings", "TimeZone"); if ($timezone) { date_default_timezone_set($timezone); } list($iniFilePermission, $iniDirPermission) = $ini->variableMulti('FileSettings', array('StorageFilePermissions', 'StorageDirPermissions')); // OPTIMIZATION: // Sets permission array as global variable, this avoids the eZCodePage include $GLOBALS['EZCODEPAGEPERMISSIONS'] = array('file_permission' => octdec($iniFilePermission), 'dir_permission' => octdec($iniDirPermission), 'var_directory' => eZSys::cacheDirectory()); unset($i18nSettings, $timezone, $iniFilePermission, $iniDirPermission); eZExecution::addCleanupHandler(function () { if (class_exists('eZDB', false) && eZDB::hasInstance()) { eZDB::instance()->setIsSQLOutputEnabled(false); } }); eZExecution::addFatalErrorHandler(function () { header("HTTP/1.1 500 Internal Server Error"); echo "<b>Fatal error</b>: The web server did not finish its request<br/>"; if (ini_get('display_errors') == 1) { if (eZDebug::isDebugEnabled()) { echo "<p>The execution of eZ Publish was abruptly ended, the debug output is present below.</p>"; } else { echo "<p>Debug information can be found in the log files normally placed in var/log/* or by enabling 'DebugOutput' in site.ini</p>"; } } else { echo "<p>Contact website owner with current url and info on what you did, and owner will be able to debug the issue further (by enabling 'display_errors' in php.ini).</p>"; } eZDisplayResult(null); }); eZExecution::setCleanExit(); // Enable this line to get eZINI debug output // eZINI::setIsDebugEnabled( true ); // Enable this line to turn off ini caching // eZINI::setIsCacheEnabled( false); if ($ini->variable('RegionalSettings', 'Debug') === 'enabled') { eZLocale::setIsDebugEnabled(true); } eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP); $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable('REQUEST_URI'); // Initialize basic settings, such as vhless dirs and separators eZSys::init('index.php', $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true'); // Check for extension eZExtension::activateExtensions('default'); // Extension check end // Use injected siteaccess if available or match it internally. $this->access = isset($this->settings['siteaccess']) ? $this->settings['siteaccess'] : eZSiteAccess::match(eZURI::instance(eZSys::requestURI()), eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile()); eZSiteAccess::change($this->access); eZDebugSetting::writeDebug('kernel-siteaccess', $this->access, 'current siteaccess'); // Check for siteaccess extension eZExtension::activateExtensions('access'); // Siteaccess extension check end // Now that all extensions are activated and siteaccess has been changed, reset // all eZINI instances as they may not take into account siteaccess specific settings. eZINI::resetAllInstances(false); ezpEvent::getInstance()->registerEventListeners(); $this->mobileDeviceDetect = new ezpMobileDeviceDetect(ezpMobileDeviceDetectFilter::getFilter()); if ($this->mobileDeviceDetect->isEnabled()) { $this->mobileDeviceDetect->process(); if ($this->mobileDeviceDetect->isMobileDevice()) { $this->mobileDeviceDetect->redirect(); } } // eZSession::setSessionArray( $mainRequest->session ); /** * Check for activating Debug by user ID (Final checking. The first was in eZDebug::updateSettings()) * @uses eZUser::instance() So needs to be executed after eZSession::start()|lazyStart() */ eZDebug::checkDebugByUser(); }