public function setUp()
 {
     parent::setUp();
     // Backup previous instance of eZSys (if any) and reset it
     $this->oldSysInstance = eZSys::instance();
     eZSys::setInstance();
     // Set the RequestURI to a known value so that eZSys::requestURI()
     // returns something known and useful.
     $this->queryString = "?foo=bar&this=that";
     eZSys::setServerVariable("REQUEST_URI", "/all/work/and/no/sleep/makes/(ole)/a/(dull)/boy{$this->queryString}");
     eZSys::init();
 }
예제 #2
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');
 }
예제 #3
0
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;
예제 #4
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()}
     *  - load data from file, create eZSys instance and run init
     *  - check that misc os / vh variables where as expected
     *  - tearDown() is called automatically after this function
     *
     * @param string $file
     */
    protected function testRunRegression( $file )
    {
        if ( $this->skip( $file ) )
            return;

        $testData = include $file;
        $instance = new eZSys( $testData );
        eZSys::setInstance( $instance );
        eZSys::init();// 'index.php', strpos( $file, 'server/vh/' ) !== false );

        // OS tests
        if ( $testData['PHP_OS'] === 'WINNT' )
        {
            $os = 'Windows';
            $this->assertEquals( "win32", $instance->OSType, "Did not get correct $os 'OSType' value" );
            $this->assertEquals( "windows", $instance->OS, "Did not get correct $os 'OS' value" );
            $this->assertEquals( "win32", $instance->FileSystemType, "Did not get correct $os 'FileSystemType' value" );
            $this->assertEquals( "\\", $instance->FileSeparator, "Did not get correct $os 'FileSeparator' value" );
            $this->assertEquals( "\r\n", $instance->LineSeparator, "Did not get correct $os 'LineSeparator' value" );
            $this->assertEquals( ";", $instance->EnvSeparator, "Did not get correct $os 'EnvSeparator' value" );
            $this->assertEquals( '"', $instance->ShellEscapeCharacter, "Did not get correct $os 'ShellEscapeCharacter' value" );
            $this->assertEquals( '.bak', $instance->BackupFilename, "Did not get correct $os 'BackupFilename' value" );
        }
        else // unix (incl Darwin)
        {
            $os = 'Unix';
            $this->assertEquals( "unix", $instance->OSType, "Did not get correct $os 'OSType' value" );

            if ( $testData['PHP_OS'] === 'Linux' )
                $this->assertEquals( "linux", $instance->OS, "Did not get correct $os 'OS' value" );
            else if (  $testData['PHP_OS'] === 'FreeBSD' )
                $this->assertEquals( "freebsd", $instance->OS, "Did not get correct $os 'OS' value" );
            else if (  $testData['PHP_OS'] === 'Darwin' )
                $this->assertEquals( "darwin", $instance->OS, "Did not get correct $os 'OS' value" );
            else
                $this->assertEquals( false, $instance->OS, "Did not get correct $os 'OS' value" );

            $this->assertEquals( "unix", $instance->FileSystemType, "Did not get correct $os 'FileSystemType' value" );
            $this->assertEquals( "/",    $instance->FileSeparator, "Did not get correct $os 'FileSeparator' value" );
            $this->assertEquals( "\n",   $instance->LineSeparator, "Did not get correct $os 'LineSeparator' value" );
            $this->assertEquals( ":",    $instance->EnvSeparator, "Did not get correct $os 'EnvSeparator' value" );
            $this->assertEquals( "'",    $instance->ShellEscapeCharacter, "Did not get correct $os 'ShellEscapeCharacter' value" );
            $this->assertEquals( '~',    $instance->BackupFilename, "Did not get correct $os 'BackupFilename' value" );
        }

        // Uri test: vh / nvh part
        if ( strpos( $file, 'server/nvh/' ) )
            $expected = '/index.php';
        else
            $expected = '';

        $this->assertEquals( $expected, $instance->IndexFile, "The IndexFile was not expected value" );


        // Uri test: sub path part
        if ( isset( $testData['__out']['WWWDir'] ) )
            $wwwDir = $testData['__out']['WWWDir'];
        elseif ( strpos( $testData['_SERVER']['SCRIPT_NAME'], 'index.php' ) !== false )// .htaccess or nvh
            $wwwDir = rtrim( str_replace( 'index.php', '', $testData['_SERVER']['SCRIPT_NAME'] ), '\/' );
        else
            $wwwDir = '';

        $this->assertEquals( $wwwDir, $instance->WWWDir, "The WWWDir was not expected value" );
        $this->assertEquals( rtrim( str_replace( 'index.php', '', $testData['_SERVER']['SCRIPT_FILENAME'] ), '\/' ) . '/', $instance->SiteDir, "The SiteDir was not expected value" );


        // Uri test: uri part
        if ( isset( $testData['__out']['RequestURI'] ) )
            $expected = $testData['__out']['RequestURI'];
        else if ( strpos( $file, 'vh/utf8' ) )
            $expected = '/News/Blåbær-Øl-med-d\'or-新闻军事社会体育中超';
        elseif ( strpos( $file, 'vh/view' ) )
            $expected = '/content/view/full/44';
        else
            $expected = '';

        $this->assertEquals( $expected, $instance->RequestURI, "The RequestURI was not expected value" );
    }
예제 #5
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();
     }
 }
예제 #6
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();
 }
예제 #7
0
$soapINI->loadCache();
/*!
 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 module loading
$moduleRepositories = eZModule::activeModuleRepositories();
eZModule::setGlobalPathList($moduleRepositories);
// Load soap extensions
$enableSOAP = $soapINI->variable('GeneralSettings', 'EnableSOAP');
if ($enableSOAP == 'true') {
    eZSys::init('soap.php');
    // Login if we have username and password.
    if (eZHTTPTool::username() and eZHTTPTool::password()) {
        eZUser::loginUser(eZHTTPTool::username(), eZHTTPTool::password());
    }
    $server = new eZSOAPServer();
    foreach ($soapINI->variable('ExtensionSettings', 'SOAPExtensions') as $extension) {
        include_once eZExtension::baseDirectory() . '/' . $extension . '/soap/initialize.php';
    }
    $server->processRequest();
}
ob_end_flush();
eZExecution::cleanExit();
    /**
     * 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'] );

        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}" );
    }
예제 #9
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 );
 }
예제 #10
0
// Check and proceed only if WebDAV functionality is enabled:
if ($enable === 'true') {
    eZExecution::addCleanupHandler('eZDBCleanup');
    eZExecution::addFatalErrorHandler('eZFatalError');
    eZDebug::setHandleType(eZDebug::HANDLE_FROM_PHP);
    if (!isset($_SERVER['REQUEST_URI']) or !isset($_SERVER['REQUEST_METHOD'])) {
        // We stop the script if these are missing
        // e.g. if run from the shell
        eZExecution::cleanExit();
    }
    include_once "access.php";
    eZModule::setGlobalPathList(array("kernel"));
    eZWebDAVContentBackend::appendLogEntry("========================================");
    eZWebDAVContentBackend::appendLogEntry("Requested URI is: " . $_SERVER['REQUEST_URI'], 'webdav.php');
    // Initialize/set the index file.
    eZSys::init('webdav.php');
    // @as 2009-03-04 - added cleaning up of 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']);
    }
    eZWebDAVContentBackend::appendLogEntry("Used (cleaned) URI is: " . $_SERVER['REQUEST_URI'], 'webdav.php');
    // The top/root folder is publicly available (without auth):
    if ($_SERVER['REQUEST_URI'] == '' or $_SERVER['REQUEST_URI'] == '/' or $_SERVER['REQUEST_URI'] == '/webdav.php/' or $_SERVER['REQUEST_URI'] == '/webdav.php') {
        // $requestUri = $_SERVER['REQUEST_URI'];
        // if ( $requestUri == '' )
        // {
        //     $requestUri = '/';
        // }
        // if ( $requestUri == '/webdav.php' )
        // {
예제 #11
0
    list($i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension']) = $ini->variableMulti('CharacterSettings', array('Charset', 'HTTPCharset', 'MBStringExtension'), array(false, false, 'enabled'));
    //include_once( 'lib/ezi18n/classes/eztextcodec.php' );
    eZTextCodec::updateSettings($i18nSettings);
}
// Initialize text codec settings
eZUpdateTextCodecSettings();
//include_once( 'lib/ezdb/classes/ezdb.php' );
//$db = eZDB::instance();
// Initialize module loading
//include_once( "lib/ezutils/classes/ezmodule.php" );
$moduleRepositories = eZModule::activeModuleRepositories();
eZModule::setGlobalPathList($moduleRepositories);
// Load extensions
$enable = $wsINI->variable('GeneralSettings', 'Enable' . strtoupper(WS_PROTOCOL));
if ($enable == 'true') {
    eZSys::init(WS_PROTOCOL . '.php');
    //include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
    // Login if we have username and password.
    if (eZHTTPTool::username() and eZHTTPTool::password()) {
        eZUser::loginUser(eZHTTPTool::username(), eZHTTPTool::password());
    }
    //include_once( 'lib/ezsoap/classes/ezsoapserver.php' );
    $server_class = 'gg' . strtoupper(WS_PROTOCOL) . 'Server';
    $server = new $server_class();
    // nb: this will register methods declared only for $protocol or for all
    //     protocols, depending on ini settings
    ggeZWebservices::registerAvailableMethods($server, WS_PROTOCOL);
    $server->processRequest();
}
ob_end_flush();
eZExecution::cleanExit();