示例#1
0
 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');
 }
}

// 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;

// Check for new extension loaded by siteaccess
eZExtension::activateExtensions( 'access' );

$db = eZDB::instance();
if ( $db->isConnected() )
{
    eZSession::start();
}
else
{
    exitWithInternalError();
    public static function getServerURL()
    {
        if ( self::$serverURL === null  )
        {
            $oeini = eZINI::instance( 'ezoe.ini' );
            if ( $oeini->hasVariable( 'SystemSettings', 'RelativeURL' ) &&
                 $oeini->variable( 'SystemSettings', 'RelativeURL' ) === 'enabled' )
            {
                self::$serverURL = eZSys::wwwDir();
                if ( self::$serverURL === '/'  )
                    self::$serverURL = '';
            }
            else
            {
                $domain = eZSys::hostname();
                $protocol = 'http';

                // Default to https if SSL is enabled
                // Check if SSL port is defined in site.ini
                $sslPort = 443;
                $ini = eZINI::instance();
                if ( $ini->hasVariable( 'SiteSettings', 'SSLPort' ) )
                    $sslPort = $ini->variable( 'SiteSettings', 'SSLPort' );

                if ( eZSys::serverPort() == $sslPort )
                    $protocol = 'https';

                self::$serverURL = $protocol . '://' . $domain . eZSys::wwwDir();
            }
        }
        return self::$serverURL;
    }
 /**
  * @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();
     }
 }
    eZExecution::cleanExit();
} else {
    // Print the list of ID nodes..
    //Structure : name, type, ID
    $nodes = eZFunctionHandler::execute('content', 'list', array('parent_node_id' => $parentNodeID));
    $array = array();
    foreach ($nodes as $node) {
        $tpl->setVariable('node', $node);
        $nodeID = $node->attribute('node_id');
        $name = $node->attribute('name');
        $className = $node->attribute('class_name');
        $object =& $node->object();
        $contentClass = $object->contentClass();
        $isContainer = $contentClass->attribute('is_container');
        preg_match('/\\/+[a-z0-9\\-\\._]+\\/?[a-z0-9_\\.\\-\\?\\+\\/~=&#;,]*[a-z0-9\\/]{1}/si', $tpl->fetch('design:ezodf/icon.tpl'), $matches);
        $iconPath = 'http://' . eZSys::hostname() . ':' . eZSys::serverPort() . $matches[0];
        $array[] = array($nodeID, $name, $className, $isContainer, $iconPath);
    }
    //Test if not empty
    if (empty($array)) {
        print 'problem:No Items';
        eZExecution::cleanExit();
    }
    //Convert the array into a string and display it
    $display = '';
    foreach ($array as $line) {
        foreach ($line as $element) {
            $display .= $element . ';';
        }
        $display .= chr(13);
    }
示例#6
0
$_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;
// Check for new extension loaded by siteaccess
eZExtension::activateExtensions('access');
$db = eZDB::instance();
if ($db->isConnected()) {
    eZSession::start();
} else {
    exitWithInternalError();
    return;
}
$moduleINI = eZINI::instance('module.ini');
$globalModuleRepositories = $moduleINI->variable('ModuleSettings', 'ModuleRepositories');
eZModule::setGlobalPathList($globalModuleRepositories);
$module = eZModule::exists('content');
示例#7
0
 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;
 }
 /**
  * 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();
 }
示例#9
0
if (!$url) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$link = $url->attribute('url');
if (preg_match("/^(http:)/i", $link) or preg_match("/^(ftp:)/i", $link) or preg_match("/^(https:)/i", $link) or preg_match("/^(file:)/i", $link) or preg_match("/^(mailto:)/i", $link)) {
    // No changes
} else {
    $domain = getenv('HTTP_HOST');
    $protocol = 'http';
    // 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';
    }
    $preFix = $protocol . "://" . $domain;
    $preFix .= eZSys::wwwDir();
    $link = preg_replace("/^\\//e", "", $link);
    $link = $preFix . "/" . $link;
}
$viewParameters = array('offset' => $offset, 'limit' => $limit);
$http = eZHTTPTool::instance();
$objectList = eZURLObjectLink::fetchObjectVersionList($urlID, $viewParameters);
$urlViewCount = eZURLObjectLink::fetchObjectVersionCount($urlID);
if ($Module->isCurrentAction('EditObject')) {
    if ($http->hasPostVariable('ObjectList')) {
        $versionID = $http->postVariable('ObjectList');
        $version = eZContentObjectVersion::fetch($versionID);
示例#10
0
 static function isSSLNow()
 {
     $ini = eZINI::instance();
     $sslPort = $ini->variable('SiteSettings', 'SSLPort');
     if (!$sslPort) {
         $sslPort = eZSSLZone::DEFAULT_SSL_PORT;
     }
     // $nowSSl is true if current access mode is HTTPS.
     $nowSSL = eZSys::serverPort() == $sslPort;
     //Check if this request might be driven through a ssl proxy
     if (isset($_SERVER['HTTP_X_FORWARDED_SERVER']) and !$nowSSL) {
         $sslProxyServerName = $ini->variable('SiteSettings', 'SSLProxyServerName');
         $nowSSL = $sslProxyServerName == $_SERVER['HTTP_X_FORWARDED_SERVER'];
     }
     return $nowSSL;
 }
示例#11
0
    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
if (method_exists('eZSiteAccess', 'match') && method_exists('eZSiteAccess', 'change')) {
    $access = eZSiteAccess::match($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
    $access = eZSiteAccess::change($access);
} else {
    include_once 'access.php';
    $access = accessType($uri, eZSys::hostname(), eZSys::serverPort(), eZSys::indexFile());
    $access = changeAccess($access);
}
$GLOBALS['eZCurrentAccess'] = $access;
// Check for new extension loaded by siteaccess
eZExtension::activateExtensions('access');
$db = eZDB::instance();
if ($db->isConnected()) {
    eZSession::start();
} else {
    exitWithInternalError();
    return;
}
$moduleINI = eZINI::instance('module.ini');
$globalModuleRepositories = $moduleINI->variable('ModuleSettings', 'ModuleRepositories');
$globalModuleRepositories[] = 'extension/eztags/modules';
示例#12
0
 /**
  * Constructs an ezpKernel instance
  */
 public function __construct(array $settings = array())
 {
     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('siteaccess' => null, 'use-exceptions' => false, 'session' => null, 'service-container' => null);
     unset($settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting);
     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);
         }
     });
     // Sets up the FatalErrorHandler
     $this->setupFatalErrorHandler();
     // 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
     if ($this->hasServiceContainer() && $this->getServiceContainer()->has('request')) {
         eZSys::init(basename($this->getServiceContainer()->get('request')->server->get('SCRIPT_FILENAME')), $ini->variable('SiteAccessSettings', 'ForceVirtualHost') === 'true');
     } else {
         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());
     // eZSession::setSessionArray( $mainRequest->session );
 }