Example #1
0
    /**
     * Changes the site access to what's defined in $access. It will change the
     * access path in eZSys and prepend an override dir to eZINI
     * Note: does not load extensions, use {@link eZSiteAccess::load()} if you want that
     *
     * @since 4.4
     * @param array $access An associative array with 'name' (string), 'type' (int) and 'uri_part' (array).
     *                      See {@link eZSiteAccess::match()} for array structure definition
     * @param eZINI|null $siteINI Optional parameter to be able to only do change on specific instance of site.ini
     *                   hence skip changing eZSys access paths (but not siteaccess, see {@link eZSiteAccess::load()})
     * @return array The $access parameter
     */
    static function change( array $access, eZINI $siteINI = null )
    {
        $name = $access['name'];
        $GLOBALS['eZCurrentAccess'] =& $access;
        if ( $siteINI !== null )
        {
            $ini = $siteINI;
        }
        else
        {
            $ini = eZINI::instance();
        }

        $ini->prependOverrideDir( "siteaccess/$name", false, 'siteaccess', 'siteaccess' );

        /* Make sure extension siteaccesses are prepended */
        eZExtension::prependExtensionSiteAccesses( $name, $ini );

        $ini->loadCache();

        // change some global settings if $siteINI is null
        if ( $siteINI === null )
        {
            eZSys::clearAccessPath();
            if ( !isset( $access['uri_part'] ) || $access['uri_part'] === null )
            {
                if ( $ini->hasVariable('SiteSettings', 'SiteUriParts') )
                    $access['uri_part'] = $ini->variable('SiteSettings', 'SiteUriParts');
                else if ( isset( $access['type'] ) && $access['type'] === eZSiteAccess::TYPE_URI )
                    $access['uri_part'] = array( $access['name'] );
                else
                    $access['uri_part'] = array();
            }
            eZSys::setAccessPath( $access['uri_part'], $name );

            eZUpdateDebugSettings();
            eZDebugSetting::writeDebug( 'kernel-siteaccess', "Updated settings to use siteaccess '$name'", __METHOD__ );
        }

        return $access;
    }
Example #2
0
    }
    eZDebug::updateSettings($settings);
}
/*!
 Reads settings from i18n.ini and passes them to eZTextCodec.
*/
function eZUpdateTextCodecSettings()
{
    $ini = eZINI::instance('i18n.ini');
    list($i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension']) = $ini->variableMulti('CharacterSettings', array('Charset', 'HTTPCharset', 'MBStringExtension'), array(false, false, 'enabled'));
    eZTextCodec::updateSettings($i18nSettings);
}
// Initialize text codec settings
eZUpdateTextCodecSettings();
// 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'));
$iniVarDirectory = eZSys::cacheDirectory();
// 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' => $iniVarDirectory);
//
$warningList = array();
/*!
 /**
  * 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();
 }
 /**
  * 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 );
 }