コード例 #1
0
ファイル: ezpkerneltreemenu.php プロジェクト: nfrp/ezpublish
 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');
 }
コード例 #2
0
$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 );
コード例 #3
0
    /**
     * Reloads extensions and changes siteaccess globally
     * If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()}
     *
     * - clears all in-memory caches used by the INI system
     * - re-builds the list of paths where INI files are searched for
     * - runs {@link eZSiteAccess::change()}
     * - re-searches module paths {@link eZModule::setGlobalPathList()}
     *
     * @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
     *                            If set, then global siteacceess will not be changed as well.
     * @return array The $access parameter
     */
    static function load( array $access, eZINI $siteINI = null )
    {
        $currentSiteAccess = $GLOBALS['eZCurrentAccess'];
        unset( $GLOBALS['eZCurrentAccess'] );

        // Clear all ini override dirs
        if ( $siteINI instanceof eZINI )
        {
            $siteINI->resetOverrideDirs();
        }
        else
        {
            eZINI::resetAllInstances();
            eZExtension::clearActiveExtensionsMemoryCache();
            eZTemplateDesignResource::clearInMemoryCache();
        }

        // Reload extensions, siteaccess and access extensions
        eZExtension::activateExtensions( 'default', $siteINI );
        $access = self::change( $access, $siteINI );
        eZExtension::activateExtensions( 'access', $siteINI );

        // Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini
        if ( $siteINI instanceof eZINI )
        {
            $GLOBALS['eZCurrentAccess'] = $currentSiteAccess;
        }
        else
        {
            $moduleRepositories = eZModule::activeModuleRepositories();
            eZModule::setGlobalPathList( $moduleRepositories );
        }

        return $access;
    }
コード例 #4
0
 /**
  * @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();
     }
 }
コード例 #5
0
<?php

/**
 * File containing the unpublish.php cronjob
 *
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2012.8
 * @package kernel
 */
// Check for extension
require_once 'kernel/common/ezincludefunctions.php';
eZExtension::activateExtensions();
// Extension check end
$ini = eZINI::instance('content.ini');
$unpublishClasses = $ini->variable('UnpublishSettings', 'ClassList');
$rootNodeIDList = $ini->variable('UnpublishSettings', 'RootNodeList');
$currentDate = time();
foreach ($rootNodeIDList as $nodeID) {
    $rootNode = eZContentObjectTreeNode::fetch($nodeID);
    $articleNodeArray = $rootNode->subTree(array('ClassFilterType' => 'include', 'ClassFilterArray' => $unpublishClasses));
    foreach ($articleNodeArray as $articleNode) {
        $article = $articleNode->attribute('object');
        $dataMap = $article->attribute('data_map');
        $dateAttribute = $dataMap['unpublish_date'];
        if ($dateAttribute === null) {
            continue;
        }
        $date = $dateAttribute->content();
        $articleRetractDate = $date->attribute('timestamp');
        if ($articleRetractDate > 0 && $articleRetractDate < $currentDate) {
コード例 #6
0
    eZDebug::updateSettings($debugSettings);
}
/*!
 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();
// Check for extension
require_once 'kernel/common/ezincludefunctions.php';
eZExtension::activateExtensions('default');
// 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);
// Grab the main WebDAV setting (enable/disable) from the WebDAV ini file.
$webDavIni = eZINI::instance('webdav.ini');
$enable = $webDavIni->variable('GeneralSettings', 'EnableWebDAV');
function eZDBCleanup()
{
    if (class_exists('ezdb') and eZDB::hasInstance()) {
        $db = eZDB::instance();
        $db->setIsSQLOutputEnabled(false);
    }
}
function eZFatalError()
コード例 #7
0
ファイル: ezscript.php プロジェクト: nlescure/ezpublish
 function initialize()
 {
     if (ob_get_length() != 0) {
         ob_end_clean();
     }
     $debugINI = eZINI::instance('debug.ini');
     eZDebugSetting::setDebugINI($debugINI);
     // Initialize text codec settings
     $this->updateTextCodecSettings();
     // Initialize debug settings
     $this->updateDebugSettings($this->UseDebugOutput);
     // Set the different permissions/settings.
     $ini = eZINI::instance();
     $iniFilePermission = $ini->variable('FileSettings', 'StorageFilePermissions');
     $iniDirPermission = $ini->variable('FileSettings', 'StorageDirPermissions');
     $iniVarDirectory = eZSys::cacheDirectory();
     eZCodePage::setPermissionSetting(array('file_permission' => octdec($iniFilePermission), 'dir_permission' => octdec($iniDirPermission), 'var_directory' => $iniVarDirectory));
     eZExecution::addCleanupHandler('eZDBCleanup');
     eZExecution::addFatalErrorHandler('eZFatalError');
     eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
     if ($this->UseExtensions) {
         // Check for extension
         eZExtension::activateExtensions('default');
         // Extension check end
     } else {
         if (!$this->isQuiet()) {
             $cli = eZCLI::instance();
             $cli->output("Notice: This script uses 'use-extensions' => false, meaning extension settings are not loaded!");
         }
     }
     $siteaccess = $this->SiteAccess;
     if ($siteaccess) {
         $access = array('name' => $siteaccess, 'type' => eZSiteAccess::TYPE_STATIC);
     } else {
         $ini = eZINI::instance();
         $siteaccess = $ini->variable('SiteSettings', 'DefaultAccess');
         $access = array('name' => $siteaccess, 'type' => eZSiteAccess::TYPE_DEFAULT);
     }
     $access = eZSiteAccess::change($access);
     if ($this->UseExtensions) {
         // Check for siteaccess extension
         eZExtension::activateExtensions('access');
         // 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);
     // Set the global setting which is read by the session lib
     $GLOBALS['eZSiteBasics']['session-required'] = $this->UseSession;
     if ($this->UseSession) {
         $db = eZDB::instance();
         if ($db->isConnected()) {
             eZSession::start();
         } else {
             $this->setIsInitialized(false);
             $this->InitializationErrorMessage = 'database error: ' . $db->errorMessage();
             return;
         }
     }
     if ($this->User) {
         $userLogin = $this->User['login'];
         $userPassword = $this->User['password'];
         if ($userLogin and $userPassword) {
             $userID = eZUser::loginUser($userLogin, $userPassword);
             if (!$userID) {
                 $cli = eZCLI::instance();
                 if ($this->isLoud()) {
                     $cli->warning('Failed to login with user ' . $userLogin);
                 }
                 eZExecution::cleanup();
                 eZExecution::setCleanExit();
             }
         }
     }
     // Initialize module handling
     if ($this->UseModules) {
         $moduleRepositories = eZModule::activeModuleRepositories($this->UseExtensions);
         eZModule::setGlobalPathList($moduleRepositories);
     }
     $this->setIsInitialized(true);
 }
コード例 #8
0
 /**
  * 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
    /**
     * Reloads extensions and changes siteaccess globally
     * If you only want changes on a instance of ini, use {@link eZSiteAccess::getIni()}
     *
     * - clears all in-memory caches used by the INI system
     * - re-builds the list of paths where INI files are searched for
     * - runs {@link eZSiteAccess::change()}
     * - re-searches module paths {@link eZModule::setGlobalPathList()}
     *
     * @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
     *                            If set, then global siteacceess will not be changed as well.
     * @return array The $access parameter
     */
    static function load( array $access, eZINI $siteINI = null )
    {
        $currentSiteAccess = $GLOBALS['eZCurrentAccess'];
        unset( $GLOBALS['eZCurrentAccess'] );

        // Clear all ini override dirs
        if ( $siteINI instanceof eZINI )
        {
            $siteINI->resetOverrideDirs();
        }
        else
        {
            eZINI::resetAllInstances();
            eZExtension::clearActiveExtensionsMemoryCache();
            eZTemplateDesignResource::clearInMemoryCache();
        }

        // Reload extensions, siteaccess and access extensions
        eZExtension::activateExtensions( 'default', $siteINI );
        $access = self::change( $access, $siteINI );
        eZExtension::activateExtensions( 'access', $siteINI );

        // Reload Extenion ordering to reorder eZINI Global Override Dirs.
        // @TODO : Améliorer la gestion globale (éviter des appels multiples !!!)
        if (  $siteINI instanceof eZINI  && $siteINI->variable( 'ExtensionSettings', 'ExtensionOrdering' ) === 'enabled' )
        {
            eZINI::removeGlobalOverrideDirsByScope( 'sa-extension' );
            eZINI::removeGlobalOverrideDirsByScope( 'extension' );
            eZExtension::activateExtensions( false );
        }

        // Restore current (old) siteacces if changes where only to be applied to locale instance of site.ini
        if ( $siteINI instanceof eZINI )
        {
            $GLOBALS['eZCurrentAccess'] = $currentSiteAccess;
        }
        else
        {
            $moduleRepositories = eZModule::activeModuleRepositories();
            eZModule::setGlobalPathList( $moduleRepositories );
        }

        return $access;
    }
コード例 #10
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 );
 }
コード例 #11
0
 /**
  * Runs the $file (.request file from $this->files) as a PHPUnit test.
  *
  * Steps performed:
  *  - setUp() is called automatically before this function
  *  - skip the test $file if declared. See {@link skip()}
  *  - identify test files attached to the .request file $file (.expected, .body)
  *  - initialize various global variables (together with $GLOBALS from setUp())
  *  - create an eZ Publish folder with the name $file
  *  - include $file (the .request file) as PHP code. $GLOBALS and $_SERVER values set in there
  *    will be used further on
  *  - initialize the WebDAV system like in webdav.php (it does NOT go through webdav.php)
  *  - create an eZWebDAVContentBackend object and use ezcWebdavServer to handle the
  *    WebDAV request specified in the .request file $file (through $_SERVER variables
  *    'REQUEST_METHOD' and 'REQUEST_URI' and others.
  *  - the output from the WebDAV system is collected in $GLOBALS['ezc_response_body']
  *    (through hacks in wrappers.php).
  *  - append the .body file contents to the $GLOBALS['ezc_response_body'] if it exists
  *  - clean the response and the .expected file with cleanForCompare() (eg. creation date, etags etc)
  *  - compare the response and the .expected file with assertEquals(). Same contents means the test passed.
  *  - tearDown() is called automatically after this function
  *
  * See doc/specifications/trunk/webdav/testing.txt for detailed information
  * about each $GLOBALS and $_SERVER variables.
  *
  * @param string $file
  */
 public function testRunRegression($file)
 {
     // 'ezc' = use eZWebDAVContentBackend (new eZ Publish WebDAV based on ezcWebdav)
     // 'ezp' = use eZWebDAVContentServer  (old eZ Publish WebDAV)
     // Only 'ezc' is supported for now
     $system = 'ezc';
     // uncomment the tests that you want to skip in the skip() function
     $this->skip($file);
     $error = '';
     $response = null;
     $outFile = $this->outFileName($file, '.request', '.expected');
     $bodyFile = $this->outFileName($file, '.request', '.body');
     $parts = pathinfo($file);
     $GLOBALS['ezc_webdav_testfolder'] = $parts['filename'];
     // Create an eZ Publish folder for each test with the name of the test
     // $GLOBALS['ezc_webdav_testfolderid'] can be used in the .request file
     // to create file, image, folder etc under the test folder.
     $folder = new ezpObject("folder", 2);
     $folder->name = $GLOBALS['ezc_webdav_testfolder'];
     $folder->publish();
     $GLOBALS['ezc_webdav_testfolderobject'] = $folder;
     $GLOBALS['ezc_webdav_testfolderid'] = $folder->mainNode->node_id;
     // var_dump( $GLOBALS['ezc_webdav_testfolder'] . ' (' . $GLOBALS['ezc_webdav_testfolderid'] . ')' );
     eZExtension::activateExtensions('default');
     eZModule::setGlobalPathList(array("kernel"));
     eZUser::logoutCurrent();
     eZSys::init('webdav.php');
     // include the .request file. $GLOBALS and $_SERVER defined in the file
     // will be used in the test
     include $file;
     // var_dump( '--- After include' );
     // These values can be overwritten in the included $file which contains the WebDAV request
     $username = $GLOBALS['ezc_webdav_username'];
     $password = $GLOBALS['ezc_webdav_password'];
     // Set the HTTP_AUTHORIZATION header
     $_SERVER['HTTP_AUTHORIZATION'] = 'Basic ' . base64_encode("{$username}:{$password}");
     // var_dump( 'Default REQUEST_URI: ' . $_SERVER['REQUEST_URI'] );
     // var_dump( 'Cleaned REQUEST_URI: ' . $_SERVER['REQUEST_URI'] );
     if ($system === 'ezc') {
         // Use eZ Components
         // clean the REQUEST_URI and HTTP_DESTINATION
         $_SERVER['REQUEST_URI'] = urldecode($_SERVER['REQUEST_URI']);
         if (isset($_SERVER['HTTP_DESTINATION'])) {
             $_SERVER['HTTP_DESTINATION'] = urldecode($_SERVER['HTTP_DESTINATION']);
         }
         $server = ezcWebdavServer::getInstance();
         $backend = new eZWebDAVContentBackend();
         $server->configurations = new ezcWebdavServerConfigurationManagerWrapper();
         $server->init(new ezcWebdavBasicPathFactory($GLOBALS['ezc_webdav_url']), new ezcWebdavXmlTool(), new ezcWebdavPropertyHandler(), new ezcWebdavHeaderHandler(), new ezcWebdavTransportWrapper());
         $server->auth = new eZWebDAVContentBackendAuth();
     } else {
         // Use the previous WebDAV system in eZ Publish
         $backend = new eZWebDAVContentServerWrapper();
     }
     $currentSite = $backend->currentSiteFromPath($_SERVER['REQUEST_URI']);
     if ($currentSite) {
         $backend->setCurrentSite($currentSite);
     }
     if ($system === 'ezc') {
         $server->handle($backend);
     } else {
         $backend->processClientRequest();
     }
     // This value comes from the included $file which contains the WebDAV request
     $response = trim($GLOBALS['ezc_response_body']);
     $expected = trim(file_get_contents($outFile));
     $body = null;
     if (file_exists($bodyFile)) {
         $body = trim(file_get_contents($bodyFile));
     }
     // replace dynamic text (eg. ETag) with static text
     // $body = optional body content (eg. for binary files) to be appended to $expected
     $expected = $this->cleanForCompare($expected, $body);
     $response = $this->cleanForCompare($response);
     $this->assertEquals($expected, $response, "The expected response " . basename($outFile) . " (" . strlen($expected) . ") is not the same as the response got from request " . basename($file) . " (" . strlen($response) . "). {$error}");
 }