Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezpbkernelweb.php
Go to the documentation of this file.
1 <?php
16 class ezpbKernelWeb implements ezpWebBasedKernelHandler
17 {
21 private $mobileDeviceDetect;
22
26 private $policyCheckViewMap;
27
31 private $module;
32
36 private $warningList = array();
37
41 private $siteBasics;
42
46 private $actualRequestedURI;
47
51 private $oldURI;
52
56 private $completeRequestedURI;
57
63 private $access;
64
68 private $uri;
69
73 private $check;
74
78 private $site;
79
84 private $languageCode;
85
90 private $httpCharset;
91
97 protected $isInitialized = false;
98
107 protected $settings = array();
108
112 public function __construct( array $settings = array() )
113 {
114 if ( isset( $settings['injected-settings'] ) )
115 {
116 $injectedSettings = array();
117 foreach ( $settings['injected-settings'] as $keySetting => $injectedSetting )
118 {
119 list( $file, $section, $setting ) = explode( '/', $keySetting );
120 $injectedSettings[$file][$section][$setting] = $injectedSetting;
121 }
122 // Those settings override anything else in local .ini files and their overrides
123 eZINI::injectSettings( $injectedSettings );
124 }
125
126 if ( isset( $settings['injected-merge-settings'] ) )
127 {
128 $injectedSettings = array();
129 foreach ( $settings['injected-merge-settings'] as $keySetting => $injectedSetting )
130 {
131 list( $file, $section, $setting ) = explode( '/', $keySetting );
132 $injectedSettings[$file][$section][$setting] = $injectedSetting;
133 }
134 // Those settings override anything else in local .ini files and their overrides
135 eZINI::injectMergeSettings( $injectedSettings );
136 }
137
138 $this->settings = $settings + array(
139 'siteaccess' => null,
140 'use-exceptions' => false,
141 'session' => null,
142 'service-container' => null,
143 );
144 unset( $settings, $injectedSettings, $file, $section, $setting, $keySetting, $injectedSetting );
145
146 require_once __DIR__ . '/../private/classes/global_functions.php';
147 $this->setUseExceptions( $this->settings['use-exceptions'] );
148
149 $GLOBALS['eZSiteBasics'] = array(
150 'external-css' => true,
151 'show-page-layout' => true,
152 'module-run-required' => true,
153 'policy-check-required' => true,
154 'policy-check-omit-list' => array(),// List of module names which will skip policy checking
155 'url-translator-allowed' => true,
156 'validity-check-required' => false,
157 'user-object-required' => true,
158 'session-required' => true,
159 'db-required' => false,
160 'no-cache-adviced' => false,
161 'site-design-override' => false,
162 'module-repositories' => array(),// List of directories to search for modules
163 );
164 $this->siteBasics =& $GLOBALS['eZSiteBasics'];
165
166 // Reads settings from i18n.ini and passes them to eZTextCodec.
167 list(
168 $i18nSettings['internal-charset'],
169 $i18nSettings['http-charset'],
170 $i18nSettings['mbstring-extension']
171 ) = eZINI::instance( 'i18n.ini' )->variableMulti(
172 'CharacterSettings',
173 array( 'Charset', 'HTTPCharset', 'MBStringExtension' ),
174 array( false, false, 'enabled' )
175 );
176
177 eZTextCodec::updateSettings( $i18nSettings );// @todo Change so code only supports utf-8 in 5.0?
178
179 // Initialize debug settings.
180 eZUpdateDebugSettings();
181
182 // Set the different permissions/settings.
183 $ini = eZINI::instance();
184
185 // Set correct site timezone
186 $timezone = $ini->variable( "TimeZoneSettings", "TimeZone");
187 if ( $timezone )
188 {
189 date_default_timezone_set( $timezone );
190 }
191
192 list( $iniFilePermission, $iniDirPermission ) =
193 $ini->variableMulti( 'FileSettings', array( 'StorageFilePermissions', 'StorageDirPermissions' ) );
194
195 // OPTIMIZATION:
196 // Sets permission array as global variable, this avoids the eZCodePage include
197 $GLOBALS['EZCODEPAGEPERMISSIONS'] = array(
198 'file_permission' => octdec( $iniFilePermission ),
199 'dir_permission' => octdec( $iniDirPermission ),
200 'var_directory' => eZSys::cacheDirectory()
201 );
202 unset( $i18nSettings, $timezone, $iniFilePermission, $iniDirPermission );
203
204 // eZExecution::addCleanupHandler(
205 // function()
206 // {
207 // if ( class_exists( 'eZDB', false ) && eZDB::hasInstance() )
208 // {
209 // eZDB::instance()->setIsSQLOutputEnabled( false );
210 // }
211 // }
212 // );
213
214 // Sets up the FatalErrorHandler
215 $this->setupFatalErrorHandler();
216
217 // Enable this line to get eZINI debug output
218 // eZINI::setIsDebugEnabled( true );
219 // Enable this line to turn off ini caching
220 // eZINI::setIsCacheEnabled( false);
221
222 if ( $ini->variable( 'RegionalSettings', 'Debug' ) === 'enabled' )
223 eZLocale::setIsDebugEnabled( true );
224
225 eZDebug::setHandleType( eZDebug::HANDLE_FROM_PHP );
226
227 $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' );
228
229 // Initialize basic settings, such as vhless dirs and separators
230 if ( $this->hasServiceContainer() && $this->getServiceContainer()->has( 'request' ) )
231 {
232 eZSys::init(
233 basename( $this->getServiceContainer()->get( 'request' )->server->get( 'SCRIPT_FILENAME' ) ),
234 $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true'
235 );
236 }
237 else
238 {
239 eZSys::init(
240 'index.php',
241 $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true'
242 );
243 }
244
245 // Check for extension
246 eZExtension::activateExtensions( 'default' );
247 // Extension check end
248
249 // Use injected siteaccess if available or match it internally.
250 $this->access = isset( $this->settings['siteaccess'] ) ?
251 $this->settings['siteaccess'] :
252 eZSiteAccess::match(
253 eZURI::instance( eZSys::requestURI() ),
254 eZSys::hostname(),
255 eZSys::serverPort(),
256 eZSys::indexFile()
257 )
258 ;
259
260 eZSiteAccess::change( $this->access );
261 eZDebugSetting::writeDebug( 'kernel-siteaccess', $this->access, 'current siteaccess' );
262
263 // Check for siteaccess extension
264 eZExtension::activateExtensions( 'access' );
265 // Siteaccess extension check end
266
267 // Now that all extensions are activated and siteaccess has been changed, reset
268 // all eZINI instances as they may not take into account siteaccess specific settings.
269 eZINI::resetAllInstances( false );
270
271 ezpEvent::getInstance()->registerEventListeners();
272
273 $this->mobileDeviceDetect = new ezpMobileDeviceDetect( ezpMobileDeviceDetectFilter::getFilter() );
274 // eZSession::setSessionArray( $mainRequest->session );
275 }
276
277 private function setupFatalErrorHandler()
278 {
279 $errorINI = eZINI::instance( 'error.ini' );
280 if ( $errorINI->hasVariable( 'ErrorSettings-kernel', 'FatalErrorHandler' ) && is_callable( $errorINI->variable( 'ErrorSettings-kernel', 'FatalErrorHandler' ) ) )
281 {
282 eZExecution::addFatalErrorHandler( $errorINI->variable( 'ErrorSettings-kernel', 'FatalErrorHandler' ) );
283 }
284 else
285 {
286 eZExecution::addFatalErrorHandler(
287 function()
288 {
289 header("HTTP/1.1 500 Internal Server Error");
290 echo "<b>Fatal error</b>: The web server did not finish its request<br/>";
291 if ( ini_get('display_errors') == 1 )
292 {
293 if ( eZDebug::isDebugEnabled() )
294 echo "<p>The execution of Exponential was abruptly ended, the debug output is present below.</p>";
295 else
296 echo "<p>Debug information can be found in the log files normally placed in var/log/* or by enabling 'DebugOutput' in site.ini</p>";
297 }
298 else
299 {
300 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>";
301 }
302 eZDisplayResult( null );
303 }
304 );
305 }
306 eZExecution::setCleanExit();
307 }
308
312 public function run()
313 {
314 if ( $this->mobileDeviceDetect->isEnabled() )
315 {
316 $this->mobileDeviceDetect->process();
317
318 if ( $this->mobileDeviceDetect->isMobileDevice() )
319 $this->mobileDeviceDetect->redirect();
320 }
321
322 ob_start();
323 // $this->requestInit();
324
325 // send header information
326 foreach (
327 eZHTTPHeader::headerOverrideArray( $this->uri ) +
328 array(
329 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
330 'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT',
331 'Cache-Control' => 'no-cache, must-revalidate',
332 'Pragma' => 'no-cache',
333 'X-Powered-By' => eZPublishSDK::EDITION,
334 'Content-Type' => 'text/html; charset=' . $this->httpCharset,
335 'Served-by' => isset( $_SERVER["SERVER_NAME"] ) ? $_SERVER['SERVER_NAME'] : null,
336 'Content-language' => $this->languageCode
337 ) as $key => $value
338 )
339 {
340 header( $key . ': ' . $value );
341 }
342
343 //
344 // $Id: index.php 9864 2003-07-11 07:27:00Z br $
345 //
346 // Created on: <09-Nov-2000 14:52:40 ce>
347 //
348 // This source file is part of Exponential Basic, publishing software.
349 //
350 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
351 //
352 // This program is free software; you can redistribute it and/or
353 // modify it under the terms of the GNU General Public License
354 // as published by the Free Software Foundation; either version 2
355 // of the License, or (at your option) any later version.
356 //
357 // This program is distributed in the hope that it will be useful,
358 // but WITHOUT ANY WARRANTY; without even the implied warranty of
359 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
360 // GNU General Public License for more details.
361 //
362 // You should have received a copy of the GNU General Public License
363 // along with this program; if not, write to the Free Software
364 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
365 //
366
367 // header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
368 // header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
369 // header( "Cache-Control: no-cache, must-revalidate" );
370 // header( "Pragma: no-cache" );
371 // header( "X-Powered-By: Exponential Basic" );
372
373 // Find out, where our files are.
374 if ( preg_match( "/(.*\/)([^\/]+\.php)$/", $_SERVER['SCRIPT_FILENAME'], $regs ) )
375 {
376 $siteDir = $regs[1];
377 $index = "/" . $regs[2];
378 }
379 elseif ( preg_match( "/(.*\/)([^\/]+\.php)/?/", $_SERVER['PHP_SELF'], $regs ) )
380 {
381 // Some people using CGI have their $SCRIPT_FILENAME not right... so we are trying this.
382 $siteDir = $_SERVER['DOCUMENT_ROOT'] . $regs[1];
383 $index = "/" . $regs[2];
384 }
385 else
386 {
387 // Fallback... doesn't work with virtual-hosts, but better than nothing
388 $siteDir = "./";
389 // kracker: changed from 2.2 to run on firebright vhost w/out index.php
390 // $index = "/index.php";
391 $index = "/";
392 }
393
394 // What OS-type are we using?
395 if ( substr( php_uname(), 0, 7) == "Windows" )
396 $separator = ";";
397 else
398 $separator = ":";
399
400 // Setting the right include_path
401 $includePath = ini_get( "include_path" );
402 if ( trim( $includePath ) != "" )
403 $includePath .= $separator . $siteDir;
404 else
405 $includePath = $siteDir;
406 ini_set( "include_path", $includePath );
407
408 $wwwDir='';
409 // Get the webdir.
410 if ( preg_match( "/(.*)\/([^\/]+\.php)$/", $_SERVER['SCRIPT_NAME'], $regs ) )
411 $wwwDir = $regs[1];
412
413 // Fallback... Finding the paths above failed, so $PHP_SELF is not set right.
414 if ( $siteDir == "./" )
415 $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'];
416
417 // Trick: Rewrite setup doesn't have index.php in $PHP_SELF, so we don't want an $index
418 if ( ! preg_match( "/.*index\.php.*/", $_SERVER['PHP_SELF'] ) )
419 $index = "";
420 else
421 {
422 // Get the right $REQUEST_URI, when using nVH setup.
423 if ( preg_match( '/^ ' . $wwwDir . str_replace('/', '\/', $index ) . '(.+)/', $_SERVER['PHP_SELF'], $req ) )
424 $_SERVER['REQUEST_URI'] = $req[1];
425 }
426
427 // kracker: changed from 2.2 to run on firebright vhost w/out index.php in auto generated urls
428 $index = "";
429
430 // Remove url parameters
431 preg_match( "/([^?]+)/", $_SERVER['REQUEST_URI'], $regs );
432 $_SERVER['REQUEST_URI'] = $regs[1];
433
434 // settings for sessions
435 // max timeout is set to 48 hours
436 ini_alter( "session.gc_maxlifetime", "172800" );
437 ini_alter( "session.entropy_file","/dev/urandom" );
438 ini_alter( "session.entropy_length", "512" );
439
440 global $ini;
441 $ini =& eZINI::instance( 'site.ini' );
442 $StoreStats = $ini->variable( "eZStatsMain", "StoreStats" );
443
444 $session =& eZSession::globalSession();
445
446 // 7x: Convert the following to ini settings
447 $GLOBALS["DEBUG"] = false;
448 $GLOBALS["DDD"] = '';
449 $UsePHPSessions = false;
450 global $GLOBALS;
451
452
453 global $GlobalSiteIni;
454 $GlobalSiteIni =& $ini;
455
456 // Set the global nVH variables.
457 $GlobalSiteIni->Index = $index;
458 $GlobalSiteIni->WWWDir = $wwwDir;
459 $GlobalSiteIni->SiteDir = $siteDir;
460 unset( $index );
461 unset( $wwwDir );
462
463 // Design
464 // Final variables before the kernel loads
465 unset( $siteStyle );
466 unset( $siteDesign );
467 unset( $GlobalSiteDesign );
468
469 global $SiteStyle;
470 $SiteStyle = $ini->variable( "site", "SiteDesign" );
471
472 global $siteDesign;
473 $siteDesign =& $ini->variable( "site", "SiteDesign" );
474
475 // Store the site design in a global variable
476 global $GlobalSiteDesign;
477 $GlobalSiteDesign = $siteDesign;
478
479 ob_start();
480 // Turn on output buffering with gz compression
481 //ob_start("ob_gzhandler");
482
483 if ( $UsePHPSessions == true )
484 {
485 // start session handling
486 session_start();
487 }
488
489 if ( $StoreStats == "enabled" and $GlobalSiteIni->Index != "" )
490 {
491 // do the statistics
492 // // include_once( "ezstats/classes/ezpageview.php" );
493
494 // if we are using nVH setup, we need to store our stats here
495 if ( isset( $GlobalSiteIni->SiteDir ) and $GlobalSiteIni->SiteDir != "" )
496 {
497 // create a global page view object for statistics
498 // and store the stats
499 $GlobalPageView = new eZPageView();
500 $GlobalPageView->store();
501 }
502 }
503
504 // parse the URI
505 $meta_page = "";
506 $content_page = "";
507
508 // Check if userlogin is required
509 $user =& eZUser::currentUser();
510
511 $requireUserLogin =& $ini->variable( "eZUserMain", "RequireUserLogin" );
512
513 // Cookie auto login.
514 if ( isset( $HTTP_COOKIE_VARS["eZUser_AutoCookieLogin"] ) and $HTTP_COOKIE_VARS["eZUser_AutoCookieLogin"] != false )
515 {
516 if ( ( !$user ) && ( $ini->variable( "eZUserMain", "AutoCookieLogin" ) == "enabled" ) )
517 {
518 eZUser::autoCookieLogin( $HTTP_COOKIE_VARS["eZUser_AutoCookieLogin"] );
519 }
520 }
521
522 $url_array = explode( "/", $_SERVER['REQUEST_URI'] );
523 $url_array_count = count( $url_array );
524
525 for( $i = $url_array_count; $i <= 25; $i++ )
526 {
527 $url_array[$i] = false;
528 }
529
530
531 try
532 {
533 // $moduleResult = $this->dispatchLoop();
534
535 if ( ( $requireUserLogin == "disabled" ) ||
536 ( ( $requireUserLogin == "enabled" ) && ( is_a( $user, "eZUser" ) ) && ( $user->id() != 0 ) ) )
537 {
538 // do url translation if needed
539 $URLTranslationKeyword = $ini->variable( "site", "URLTranslationKeyword" );
540 $urlTranslatorArray = explode( ";", $URLTranslationKeyword );
541
542 if( isset( $url_array[2] ) && $url_array[2] != "" )
543 $combinedURIs = '/'. $url_array[1] . '/'. $url_array[2];
544 else
545 $combinedURIs = '/' . $url_array[1];
546
547 if( isset( $url_array[3] ) && $url_array[3] != "" )
548 $combinedURIs = '/' . $url_array[1] . '/'. $url_array[2] . '/' . $url_array[3];
549
550 // var_dump($combinedURIs); echo "<hr>";
551 if ( in_array( $url_array[1], $urlTranslatorArray ) ||
552 in_array( $combinedURIs, $urlTranslatorArray ) ||
553 in_array( $_SERVER['REQUEST_URI'], $urlTranslatorArray ) )
554 {
555 $translatedURL = eZURLTranslator::translate( $combinedURIs );
556 // var_dump($translatedURL); echo "<hr>";
557
558 if ( $translatedURL )
559 {
560 $_SERVER['REQUEST_URI'] = $translatedURL;
561 $url_array = explode( "/", $_SERVER['REQUEST_URI'] );
562 }
563 }
564
565 // if uri == / show default page or article list
566 if ( $_SERVER['REQUEST_URI'] == "/" )
567 {
568 if ( $ini->variable( "site", "DefaultPage" ) == "disabled" )
569 {
570 $_SERVER['REQUEST_URI'] = "/article/archive/0/";
571 }
572 else
573 {
574 $_SERVER['REQUEST_URI'] = $ini->variable( "site", "DefaultPage" );
575 }
576
577 if ( $user )
578 {
579 $mainGroup = $user->groupDefinition( true );
580 if ( ( $mainGroup ) && $mainGroup->groupURL() )
581 {
582 $_SERVER['REQUEST_URI'] = $mainGroup->groupURL();
583 }
584 }
585 $url_array = explode( "/", $_SERVER['REQUEST_URI'] );
586 }
587
588 // 7x Register Globals Replacement
589 foreach($_COOKIE as $key => $value) {
590 if(!is_array($value)){
591 ${$key} = trim(rawurldecode($value));
592 //echo "$key $value<br>";
593 }
594 else{
595 ${$key} = $value;
596 }
597 }
598 foreach($_GET as $key => $value) {
599 if(!is_array($value)){
600 ${$key} = trim(rawurldecode($value));
601 //echo "$key $value<br>";
602 }
603 else{
604 ${$key} = $value;
605 }
606 }
607 foreach($_POST as $key => $value) {
608 if(!is_array($value)){
609 ${$key} = trim(rawurldecode($value));
610 //echo "$key $value<br>";
611 }
612 else{
613 ${$key} = $value;
614 }
615 }
616 foreach($_REQUEST as $key => $value) {
617 if(!is_array($value)){
618 ${$key} = trim(rawurldecode($value));
619 //echo "$key $value<br>";
620 }
621 else{
622 ${$key} = $value;
623 }
624 }
625 foreach($_SERVER as $key => $value) {
626 if(!is_array($value)){
627 ${$key} = trim(rawurldecode($value));
628 //echo "$key $value<br>";
629 }
630 else{
631 ${$key} = $value;
632 }
633 }
634
635 // Load the main contents and store in a variable
636 $content_page = "kernel/ez" . $url_array[1] . "/user/datasupplier.php";
637
638 // site cache check
639 $SiteCacheFile = "kernel/classes/cache/" . md5( $_SERVER['REQUEST_URI'] ) . ".php";
640 $SiteCache = $ini->variable( "site", "SiteCache" );
641
642 //This is horrible!!
643 if ( $_SERVER['REQUEST_METHOD'] == "POST" ||
644 $url_array[1] == "forum" ||
645 $url_array[1] == "user" ||
646 $url_array[1] == "trade" ||
647 $url_array[1] == "error" ||
648 $url_array[1] == "poll" )
649 {
650 $SiteCache = "disabled";
651 }
652
653 // check to use site cache
654 if ( ( $SiteCache == "enabled" ) and !file_exists( $SiteCacheFile ) )
655 {
656 $StoreSiteCache = true;
657 }
658 else
659 {
660 $StoreSiteCache = false;
661
662 if ( $SiteCache == "enabled" and file_exists( $SiteCacheFile ) )
663 {
664 $timeout = $ini->variable( "site", "SiteCacheTimeout" );
665 $SiteCacheTime = eZFile::filemtime( $SiteCacheFile );
666 if ( ( time() - $SiteCacheTime ) < ( $timeout * 60 ) )
667 {
668 // print( "valid cache" );
669 }
670 else
671 {
672 $StoreSiteCache = true;
673
674 // delete cache file
675 eZFile::unlink( $SiteCacheFile );
676 // print( "time out-clearing cache" );
677 }
678 }
679 }
680
681 if ( $StoreSiteCache || $SiteCache == "disabled" )
682 {
683 $buffer =& ob_get_contents();
684 ob_end_clean();
685 ob_start();
686
687 // fetch the module printout
688 if ( file_exists( $content_page ) )
689 {
690 // the page with the real contents
691 include( $content_page );
692 // The following variables can be set from the contents page:
693 // $PrintableVersion = "enabled | disabled";
694 // $GlobalSectionID = integer value, reference to the selected section.
695 // $SiteTitleAppend = string which will be appended to the site title
696 // $SiteDescriptionOverride = string which will override the meta content information
697 }
698 else
699 {
700 // the default page to load
701 if ( file_exists( $ini->variable( "site", "DefaultPage" ) ) )
702 {
703 include( $ini->variable( "site", "DefaultPage" ) );
704 }
705 else if ( $ini->variable( "site", "DefaultPage" ) != "disabled" )
706 {
707 $_SERVER['REQUEST_URI'] = $ini->variable( "site", "DefaultPage" );
708 $url_array = explode( "/", $_SERVER['REQUEST_URI'] );
709 $content_page = "kernel/ez" . $url_array[1] . "/user/datasupplier.php";
710 include( $content_page );
711 }
712 }
713
714 // set character set
715 // // include_once( "classes/ezlocale.php" );
716 if ( isset( $GLOBALS["eZLanguageOverride"] ) and $GLOBALS["eZLanguageOverride"] != "" )
717 {
718 $Language = $GLOBALS["eZLanguageOverride"];
719 }
720 else if ( $ini->hasVariable( "site", "Language" ) )
721 {
722 $Language = $ini->variable( "site", "Language" );
723 }
724 else
725 {
726 $Language = $ini->variable( "eZCalendarMain", "Language" );
727 }
728 $Locale = new eZLocale( $Language );
729 $iso =& $Locale->languageISO();
730 if ( $iso != false )
731 header( "Content-type: text/html;charset=$iso" );
732
733 $MainContents =& ob_get_contents();
734 ob_end_clean();
735
736 // fill the buffer with the old values
737 ob_start();
738 print( $buffer );
739
740 // set the sitedesign from the section
741 if ( $ini->variable( "site", "Sections" ) == "enabled" )
742 {
743 if ( !isset( $GlobalSectionID ) )
744 {
745 $GlobalSectionID = $ini->variable( "site", "DefaultSection" );
746 }
747
748 // // include_once( "ezsitemanager/classes/ezsection.php" );
749
750 if ( isset($_REQUEST['SectionIDOverride']) && is_numeric( $_REQUEST['SectionIDOverride'] ) )
751 {
752 $GlobalSectionID = $_REQUEST['SectionIDOverride'];
753 }
754
755 // init the section
756 $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
757 $sectionObject->setOverrideVariables();
758
759 if ( $ini->variable( "site", "DebugOutput") == "enabled" )
760 {
761 // print( "Section Debug $GlobalSectionID: <br>" );
762 // print( "sitedesign: " . $sectionObject->siteDesign() . " <br>" );
763 // print( "template: " . $sectionObject->templateStyle() . " <br>" );
764 // print( "language: " . $sectionObject->language() . " <br>" );
765 }
766
767 $theSection = new eZSection( $GlobalSectionID );
768 $sectionSiteDesign = $theSection->siteDesign( $GlobalSectionID );
769
770 if ( $sectionSiteDesign != "" )
771 {
772 $siteDesign = $sectionSiteDesign;
773 $GlobalSiteDesign = $sectionSiteDesign;
774 }
775 }
776
777 // include some html
778 $Title = $ini->variable( "site", "SiteTitle" );
779
780 // Main contents
781 // handled by the sitedesign/$design/frame.php file now..
782 // print( $MainContents );
783
784 // include framework
785 if ( isset( $PrintableVersion ) and $PrintableVersion == "enabled" )
786 {
787 include( "design/$siteDesign/simpleframe.php" );
788 }
789 else
790 {
791 include( "design/$siteDesign/frame.php" );
792 }
793
794 // store site cache
795 if ( $StoreSiteCache == true )
796 {
797 $fp = fopen( $SiteCacheFile, "w+");
798
799 $SiteContents =& ob_get_contents();
800 fwrite( $fp, $SiteContents );
801 fclose( $fp );
802 }
803 }
804 else
805 {
806 // load site cache
807 $fp = fopen( $SiteCacheFile, 'r' );
808 fpassthru( $fp );
809 }
810
811 }
812 else
813 {
814 // parse the URI
815 $page = "";
816
817 // send the URI to the right decoder
818 $page = "kernel/ezuser/user/datasupplier.php";
819 if ( file_exists( $page ) )
820 {
821 include( $page );
822 }
823
824 $MainContents =& ob_get_contents();
825 // 7x: Refactor
826 $moduleResult = $MainContents;
827 ob_end_clean();
828 ob_start();
829
830 include( "design/$siteDesign/loginframe.php" );
831 }
832
833
834 // close the database connection.
835 $db =& eZDB::globalDatabase();
836 $db->close();
837
838 ob_end_flush();
839 }
840 catch ( Exception $e )
841 {
842 $this->shutdown();
843 throw $e;
844 }
845
846 $ini = eZINI::instance();
847
853 /*
854 if ( $ini->variable( "SiteAccessSettings", "CheckValidity" ) !== 'true' )
855 {
856 $wwwDir = eZSys::wwwDir();
857 // On host based site accesses this can be empty, causing the cookie to be set for the current dir,
858 // but we want it to be set for the whole Exponential Basic site
859 $cookiePath = $wwwDir != '' ? $wwwDir : '/';
860
861 if ( eZUser::isCurrentUserRegistered() )
862 {
863 // Only set the cookie if it doesnt exist. This way we are not constantly sending the set request in the headers.
864 if ( !isset( $_COOKIE['is_logged_in'] ) || $_COOKIE['is_logged_in'] !== 'true' )
865 {
866 setcookie( 'is_logged_in', 'true', 0, $cookiePath );
867 }
868 }
869 else if ( isset( $_COOKIE['is_logged_in'] ) )
870 {
871 setcookie( 'is_logged_in', false, 0, $cookiePath );
872 }
873 }
874
875 if ( $this->module->exitStatus() == eZModule::STATUS_REDIRECT )
876 {
877 $this->shutdown();
878 return $this->redirect();
879 }
880
881 $uiContextName = $this->module->uiContextName();
882
883 // Store the last URI for access history for login redirection
884 // Only if user has session and only if there was no error or no redirects happen
885 if ( eZSession::hasStarted() && $this->module->exitStatus() == eZModule::STATUS_OK )
886 {
887 $currentURI = $this->completeRequestedURI;
888 if ( strlen( $currentURI ) > 0 && $currentURI[0] !== '/' )
889 $currentURI = '/' . $currentURI;
890
891 $lastAccessedURI = "";
892 $lastAccessedViewURI = "";
893
894 $http = eZHTTPTool::instance();
895
896 // Fetched stored session variables
897 if ( $http->hasSessionVariable( "LastAccessesURI" ) )
898 {
899 $lastAccessedViewURI = $http->sessionVariable( "LastAccessesURI" );
900 }
901 if ( $http->hasSessionVariable( "LastAccessedModifyingURI" ) )
902 {
903 $lastAccessedURI = $http->sessionVariable( "LastAccessedModifyingURI" );
904 }
905
906 // Update last accessed view page
907 if ( $currentURI != $lastAccessedViewURI &&
908 !in_array( $uiContextName, array( 'edit', 'administration', 'ajax', 'browse', 'authentication' ) ) )
909 {
910 $http->setSessionVariable( "LastAccessesURI", $currentURI );
911 }
912
913 // Update last accessed non-view page
914 if ( $currentURI != $lastAccessedURI && $uiContextName != 'ajax' )
915 {
916 $http->setSessionVariable( "LastAccessedModifyingURI", $currentURI );
917 }
918 }
919
920 eZDebug::addTimingPoint( "Module end '" . $this->module->attribute( 'name' ) . "'" );
921 if ( !is_array( $moduleResult ) )
922 {
923 eZDebug::writeError( 'Module did not return proper result: ' . $this->module->attribute( 'name' ), 'index.php' );
924 $moduleResult = array();
925 $moduleResult['content'] = false;
926 }
927
928 if ( !isset( $moduleResult['ui_context'] ) )
929 {
930 $moduleResult['ui_context'] = $uiContextName;
931 }
932 $moduleResult['ui_component'] = $this->module->uiComponentName();
933 $moduleResult['is_mobile_device'] = $this->mobileDeviceDetect->isMobileDevice();
934 $moduleResult['mobile_device_alias'] = $this->mobileDeviceDetect->getUserAgentAlias();
935
936 $templateResult = null;
937
938 eZDebug::setUseExternalCSS( $this->siteBasics['external-css'] );
939 if ( $this->siteBasics['show-page-layout'] )
940 {
941 $tpl = eZTemplate::factory();
942 if ( $tpl->hasVariable( 'node' ) )
943 $tpl->unsetVariable( 'node' );
944
945 if ( !isset( $moduleResult['path'] ) )
946 $moduleResult['path'] = false;
947 $moduleResult['uri'] = eZSys::requestURI();
948
949 $tpl->setVariable( "module_result", $moduleResult );
950
951 $meta = $ini->variable( 'SiteSettings', 'MetaDataArray' );
952
953 if ( !isset( $meta['description'] ) )
954 {
955 $metaDescription = "";
956 if ( isset( $moduleResult['path'] ) && is_array( $moduleResult['path'] ) )
957 {
958 foreach ( $moduleResult['path'] as $pathPart )
959 {
960 if ( isset( $pathPart['text'] ) )
961 $metaDescription .= $pathPart['text'] . " ";
962 }
963 }
964 $meta['description'] = $metaDescription;
965 }
966
967 $this->site['uri'] = $this->oldURI;
968 $this->site['redirect'] = false;
969 $this->site['meta'] = $meta;
970 $this->site['version'] = eZPublishSDK::version();
971 $this->site['page_title'] = $this->module->title();
972
973 $tpl->setVariable( "site", $this->site );
974
975 if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) === 'enabled' )
976 {
977 // Make sure any errors or warnings are reported
978 if ( isset( $GLOBALS['eZDebugError'] ) && $GLOBALS['eZDebugError'] )
979 {
980 eZAppendWarningItem(
981 array(
982 'error' => array(
983 'type' => 'error',
984 'number' => 1 ,
985 'count' => $GLOBALS['eZDebugErrorCount']
986 ),
987 'identifier' => 'ezdebug-first-error',
988 'text' => ezpI18n::tr( 'index.php', 'Some errors occurred, see debug for more information.' )
989 )
990 );
991 }
992
993 if ( isset( $GLOBALS['eZDebugWarning'] ) && $GLOBALS['eZDebugWarning'] )
994 {
995 eZAppendWarningItem(
996 array(
997 'error' => array(
998 'type' => 'warning',
999 'number' => 1,
1000 'count' => $GLOBALS['eZDebugWarningCount']
1001 ),
1002 'identifier' => 'ezdebug-first-warning',
1003 'text' => ezpI18n::tr( 'index.php', 'Some general warnings occured, see debug for more information.' )
1004 )
1005 );
1006 }
1007 }
1008
1009 if ( $this->siteBasics['user-object-required'] )
1010 {
1011 $currentUser = eZUser::currentUser();
1012
1013 $tpl->setVariable( "current_user", $currentUser );
1014 $tpl->setVariable( "anonymous_user_id", $ini->variable( 'UserSettings', 'AnonymousUserID' ) );
1015 }
1016 else
1017 {
1018 $tpl->setVariable( "current_user", false );
1019 $tpl->setVariable( "anonymous_user_id", false );
1020 }
1021
1022 $tpl->setVariable( "access_type", $this->access );
1023 $tpl->setVariable( 'warning_list', !empty( $this->warningList) ? $this->warningList : false );
1024
1025 $resource = "design:";
1026 if ( is_string( $this->siteBasics['show-page-layout'] ) )
1027 {
1028 if ( strpos( $this->siteBasics['show-page-layout'], ":" ) !== false )
1029 {
1030 $resource = "";
1031 }
1032 }
1033 else
1034 {
1035 $this->siteBasics['show-page-layout'] = "pagelayout.tpl";
1036 }
1037
1038 // Set the navigation part
1039 // Check for navigation part settings
1040 $navigationPartString = 'ezcontentnavigationpart';
1041 if ( isset( $moduleResult['navigation_part'] ) )
1042 {
1043 $navigationPartString = $moduleResult['navigation_part'];
1044
1045 // Fetch the navigation part
1046 }
1047 $navigationPart = eZNavigationPart::fetchPartByIdentifier( $navigationPartString );
1048
1049 $tpl->setVariable( 'navigation_part', $navigationPart );
1050 $tpl->setVariable( 'uri_string', $this->uri->uriString() );
1051 if ( isset( $moduleResult['requested_uri_string'] ) )
1052 {
1053 $tpl->setVariable( 'requested_uri_string', $moduleResult['requested_uri_string'] );
1054 }
1055 else
1056 {
1057 $tpl->setVariable( 'requested_uri_string', $this->actualRequestedURI );
1058 }
1059
1060 // Set UI context and component
1061 $tpl->setVariable( 'ui_context', $moduleResult['ui_context'] );
1062 $tpl->setVariable( 'ui_component', $moduleResult['ui_component'] );
1063
1064 $templateResult = $tpl->fetch( $resource . $this->siteBasics['show-page-layout'] );
1065 }
1066 else
1067 {
1068 $templateResult = $moduleResult['content'];
1069 }
1070 */
1071 $templateResult = $moduleResult;
1072
1073 eZDebug::addTimingPoint( "Script end" );
1074
1075 $content = trim( ob_get_clean() );
1076
1077 ob_start();
1078 // eZDB::checkTransactionCounter();
1079 eZDisplayResult( $templateResult );
1080 $content .= ob_get_clean();
1081
1082 $this->shutdown();
1083
1084 return new ezpbKernelResult( $content, array( 'module_result' => $moduleResult ) );
1085 }
1086
1090 protected function dispatchLoop()
1091 {
1092 $ini = eZINI::instance();
1093
1094 // Start the module loop
1095 while ( $this->siteBasics['module-run-required'] )
1096 {
1097 $objectHasMovedError = false;
1098 $objectHasMovedURI = false;
1099 $this->actualRequestedURI = $this->uri->uriString();
1100
1101 // Extract user specified parameters
1102 $userParameters = $this->uri->userParameters();
1103
1104 // Generate a URI which also includes the user parameters
1105 $this->completeRequestedURI = $this->uri->originalURIString();
1106
1107 // Check for URL translation
1108 if ( $this->siteBasics['url-translator-allowed'] && eZURLAliasML::urlTranslationEnabledByUri( $this->uri ) )
1109 {
1110 $translateResult = eZURLAliasML::translate( $this->uri );
1111
1112 if ( !is_string( $translateResult ) && $ini->variable( 'URLTranslator', 'WildcardTranslation' ) === 'enabled' )
1113 {
1114 $translateResult = eZURLWildcard::translate( $this->uri );
1115 }
1116
1117 // Check if the URL has moved
1118 if ( is_string( $translateResult ) )
1119 {
1120 $objectHasMovedURI = $translateResult;
1121 foreach ( $userParameters as $name => $value )
1122 {
1123 $objectHasMovedURI .= '/(' . $name . ')/' . $value;
1124 }
1125
1126 $objectHasMovedError = true;
1127 }
1128 }
1129
1130 if ( $this->uri->isEmpty() )
1131 {
1132 $tmp_uri = new eZURI( $ini->variable( "SiteSettings", "IndexPage" ) );
1133 $moduleCheck = eZModule::accessAllowed( $tmp_uri );
1134 }
1135 else
1136 {
1137 $moduleCheck = eZModule::accessAllowed( $this->uri );
1138 }
1139
1140 if ( !$moduleCheck['result'] )
1141 {
1142 if ( $ini->variable( "SiteSettings", "ErrorHandler" ) == "defaultpage" )
1143 {
1144 $defaultPage = $ini->variable( "SiteSettings", "DefaultPage" );
1145 $this->uri->setURIString( $defaultPage );
1146 $moduleCheck['result'] = true;
1147 }
1148 }
1149
1150 $displayMissingModule = false;
1151 $this->oldURI = $this->uri;
1152
1153 if ( $this->uri->isEmpty() )
1154 {
1155 if ( !fetchModule( $tmp_uri, $this->check, $this->module, $moduleName, $functionName, $params ) )
1156 $displayMissingModule = true;
1157 }
1158 else if ( !fetchModule( $this->uri, $this->check, $this->module, $moduleName, $functionName, $params ) )
1159 {
1160 if ( $ini->variable( "SiteSettings", "ErrorHandler" ) == "defaultpage" )
1161 {
1162 $tmp_uri = new eZURI( $ini->variable( "SiteSettings", "DefaultPage" ) );
1163 if ( !fetchModule( $tmp_uri, $this->check, $this->module, $moduleName, $functionName, $params ) )
1164 $displayMissingModule = true;
1165 }
1166 else
1167 $displayMissingModule = true;
1168 }
1169
1170 if ( !$displayMissingModule && $moduleCheck['result'] && $this->module instanceof eZModule )
1171 {
1172 // Run the module/function
1173 eZDebug::addTimingPoint( "Module start '" . $this->module->attribute( 'name' ) . "'" );
1174
1175 $moduleAccessAllowed = true;
1176 $omitPolicyCheck = true;
1177 $runModuleView = true;
1178
1179 $availableViewsInModule = $this->module->attribute( 'views' );
1180 if (
1181 !isset( $availableViewsInModule[$functionName] )
1182 && !$objectHasMovedError
1183 && !isset( $this->module->Module['function']['script'] )
1184 )
1185 {
1186 $moduleResult = $this->module->handleError( eZError::KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel', array( "check" => $moduleCheck ) );
1187 $runModuleView = false;
1188 $this->siteBasics['policy-check-required'] = false;
1189 $omitPolicyCheck = true;
1190 }
1191
1192 if ( $this->siteBasics['policy-check-required'] )
1193 {
1194 $omitPolicyCheck = false;
1195 $moduleName = $this->module->attribute( 'name' );
1196 if ( in_array( $moduleName, $this->siteBasics['policy-check-omit-list'] ) )
1197 $omitPolicyCheck = true;
1198 else
1199 {
1200 $policyCheckViewMap = $this->getPolicyCheckViewMap( $this->siteBasics['policy-check-omit-list'] );
1201 if ( isset( $policyCheckViewMap[$moduleName][$functionName] ) )
1202 $omitPolicyCheck = true;
1203 }
1204 }
1205 if ( !$omitPolicyCheck )
1206 {
1207 $currentUser = eZUser::currentUser();
1208 $siteAccessResult = $currentUser->hasAccessTo( 'user', 'login' );
1209
1210 $hasAccessToSite = false;
1211 if ( $siteAccessResult[ 'accessWord' ] === 'limited' )
1212 {
1213 $policyChecked = false;
1214 foreach ( array_keys( $siteAccessResult['policies'] ) as $key )
1215 {
1216 $policy = $siteAccessResult['policies'][$key];
1217 if ( isset( $policy['SiteAccess'] ) )
1218 {
1219 $policyChecked = true;
1220 $crc32AccessName = eZSys::ezcrc32( $this->access[ 'name' ] );
1221 eZDebugSetting::writeDebug( 'kernel-siteaccess', $policy['SiteAccess'], $crc32AccessName );
1222 if ( in_array( $crc32AccessName, $policy['SiteAccess'] ) )
1223 {
1224 $hasAccessToSite = true;
1225 break;
1226 }
1227 }
1228 if ( $hasAccessToSite )
1229 break;
1230 }
1231 if ( !$policyChecked )
1232 $hasAccessToSite = true;
1233 }
1234 else if ( $siteAccessResult[ 'accessWord' ] === 'yes' )
1235 {
1236 eZDebugSetting::writeDebug( 'kernel-siteaccess', "access is yes" );
1237 $hasAccessToSite = true;
1238 }
1239 else if ( $siteAccessResult['accessWord'] === 'no' )
1240 {
1241 $accessList = $siteAccessResult['accessList'];
1242 }
1243
1244 if ( $hasAccessToSite )
1245 {
1246 $accessParams = array();
1247 $moduleAccessAllowed = $currentUser->hasAccessToView( $this->module, $functionName, $accessParams );
1248 if ( isset( $accessParams['accessList'] ) )
1249 {
1250 $accessList = $accessParams['accessList'];
1251 }
1252 }
1253 else
1254 {
1255 eZDebugSetting::writeDebug( 'kernel-siteaccess', $this->access, 'not able to get access to siteaccess' );
1256 $moduleAccessAllowed = false;
1257 if ( $ini->variable( "SiteAccessSettings", "RequireUserLogin" ) == "true" )
1258 {
1259 $this->module = eZModule::exists( 'user' );
1260 if ( $this->module instanceof eZModule )
1261 {
1262 $moduleResult = $this->module->run(
1263 'login',
1264 array(),
1265 array(
1266 'SiteAccessAllowed' => false,
1267 'SiteAccessName' => $this->access['name']
1268 )
1269 );
1270 $runModuleView = false;
1271 }
1272 }
1273 }
1274 }
1275
1276 $GLOBALS['eZRequestedModule'] = $this->module;
1277
1278 if ( $runModuleView )
1279 {
1280 if ( $objectHasMovedError == true )
1281 {
1282 $moduleResult = $this->module->handleError( eZError::KERNEL_MOVED, 'kernel', array( 'new_location' => $objectHasMovedURI ) );
1283 }
1284 else if ( !$moduleAccessAllowed )
1285 {
1286 if ( isset( $availableViewsInModule[$functionName][ 'default_navigation_part' ] ) )
1287 {
1288 $defaultNavigationPart = $availableViewsInModule[$functionName][ 'default_navigation_part' ];
1289 }
1290
1291 if ( isset( $accessList ) )
1292 $moduleResult = $this->module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel', array( 'AccessList' => $accessList ) );
1293 else
1294 $moduleResult = $this->module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );
1295
1296 if ( isset( $defaultNavigationPart ) )
1297 {
1298 $moduleResult['navigation_part'] = $defaultNavigationPart;
1299 unset( $defaultNavigationPart );
1300 }
1301 }
1302 else
1303 {
1304 if ( !isset( $userParameters ) )
1305 {
1306 $userParameters = false;
1307 }
1308
1309 // Check if we should switch access mode (http/https) for this module view.
1310 eZSSLZone::checkModuleView( $this->module->attribute( 'name' ), $functionName );
1311
1312 $moduleResult = $this->module->run( $functionName, $params, false, $userParameters );
1313
1314 if ( $this->module->exitStatus() == eZModule::STATUS_FAILED && $moduleResult == null )
1315 $moduleResult = $this->module->handleError(
1316 eZError::KERNEL_MODULE_VIEW_NOT_FOUND,
1317 'kernel',
1318 array(
1319 'module' => $moduleName,
1320 'view' => $functionName
1321 )
1322 );
1323 }
1324 }
1325 }
1326 else if ( $moduleCheck['result'] )
1327 {
1328 eZDebug::writeError( "Undefined module: $moduleName", "index" );
1329 $this->module = new eZModule( "", "", $moduleName );
1330 $GLOBALS['eZRequestedModule'] = $this->module;
1331 $moduleResult = $this->module->handleError( eZError::KERNEL_MODULE_NOT_FOUND, 'kernel', array( 'module' => $moduleName ) );
1332 }
1333 else
1334 {
1335 if ( $moduleCheck['view_checked'] )
1336 eZDebug::writeError( "View '" . $moduleCheck['view'] . "' in module '" . $moduleCheck['module'] . "' is disabled", "index" );
1337 else
1338 eZDebug::writeError( "Module '" . $moduleCheck['module'] . "' is disabled", "index" );
1339 $GLOBALS['eZRequestedModule'] = $this->module = new eZModule( "", "", $moduleCheck['module'] );
1340 $moduleResult = $this->module->handleError( eZError::KERNEL_MODULE_DISABLED, 'kernel', array( 'check' => $moduleCheck ) );
1341 }
1342 $this->siteBasics['module-run-required'] = false;
1343 if ( isset( $moduleResult['rerun_uri'] ) )
1344 {
1345 $this->uri = eZURI::instance( $moduleResult['rerun_uri'] );
1346 $this->siteBasics['module-run-required'] = true;
1347 }
1348 else if ( $this->module->exitStatus() == eZModule::STATUS_RERUN )
1349 {
1350 eZDebug::writeError( 'No rerun URI specified on eZModule::STATUS_RERUN, cannot set URI', 'index.php' );
1351 }
1352
1353 if ( is_array( $moduleResult ) )
1354 {
1355 if ( isset( $moduleResult["pagelayout"] ) )
1356 {
1357 $this->siteBasics['show-page-layout'] = $moduleResult["pagelayout"];
1358 $GLOBALS['eZCustomPageLayout'] = $moduleResult["pagelayout"];
1359 }
1360 if ( isset( $moduleResult["external_css"] ) )
1361 $this->siteBasics['external-css'] = $moduleResult["external_css"];
1362 }
1363 }
1364
1365 return $moduleResult;
1366 }
1367
1375 protected function getPolicyCheckViewMap( array $policyCheckOmitList )
1376 {
1377 if ( $this->policyCheckViewMap !== null )
1378 return $this->policyCheckViewMap;
1379
1380 $this->policyCheckViewMap = array();
1381 foreach ( $policyCheckOmitList as $omitItem )
1382 {
1383 $items = explode( '/', $omitItem );
1384 if ( count( $items ) > 1 )
1385 {
1386 $module = $items[0];
1387 if ( !isset( $this->policyCheckViewMap[$module] ) )
1388 $this->policyCheckViewMap[$module] = array();
1389 $this->policyCheckViewMap[$module][$items[1]] = true;
1390 }
1391 }
1392
1393 return $this->policyCheckViewMap;
1394 }
1395
1399 protected function redirect()
1400 {
1401 $GLOBALS['eZRedirection'] = true;
1402 $ini = eZINI::instance();
1403 $automaticRedirect = true;
1404
1405 if ( $GLOBALS['eZDebugAllowed'] && ( $redirUri = $ini->variable( 'DebugSettings', 'DebugRedirection' ) ) !== 'disabled' )
1406 {
1407 if ( $redirUri == "enabled" )
1408 {
1409 $automaticRedirect = false;
1410 }
1411 else
1412 {
1413 $uri = eZURI::instance( eZSys::requestURI() );
1414 $uri->toBeginning();
1415 foreach ( $ini->variableArray( "DebugSettings", "DebugRedirection" ) as $redirUri )
1416 {
1417 $redirUri = new eZURI( $redirUri );
1418 if ( $redirUri->matchBase( $uri ) )
1419 {
1420 $automaticRedirect = false;
1421 break;
1422 }
1423 }
1424 }
1425 }
1426
1427 $redirectURI = eZSys::indexDir();
1428
1429 $moduleRedirectUri = $this->module->redirectURI();
1430 if ( $ini->variable( 'URLTranslator', 'Translation' ) === 'enabled' &&
1431 eZURLAliasML::urlTranslationEnabledByUri( new eZURI( $moduleRedirectUri ) ) )
1432 {
1433 $translatedModuleRedirectUri = $moduleRedirectUri;
1434 if ( eZURLAliasML::translate( $translatedModuleRedirectUri, true ) )
1435 {
1436 $moduleRedirectUri = $translatedModuleRedirectUri;
1437 if ( strlen( $moduleRedirectUri ) > 0 && $moduleRedirectUri[0] !== '/' )
1438 $moduleRedirectUri = '/' . $moduleRedirectUri;
1439 }
1440 }
1441
1442 if ( preg_match( '#^(\w+:)|^//#', $moduleRedirectUri ) )
1443 {
1444 $redirectURI = $moduleRedirectUri;
1445 }
1446 else
1447 {
1448 $leftSlash = strlen( $redirectURI ) > 0 && $redirectURI[strlen( $redirectURI ) - 1] === '/';
1449 $rightSlash = strlen( $moduleRedirectUri ) > 0 && $moduleRedirectUri[0] === '/';
1450
1451 if ( !$leftSlash && !$rightSlash ) // Both are without a slash, so add one
1452 $moduleRedirectUri = '/' . $moduleRedirectUri;
1453 else if ( $leftSlash && $rightSlash ) // Both are with a slash, so we remove one
1454 $moduleRedirectUri = substr( $moduleRedirectUri, 1 );
1455
1456 // In some cases $moduleRedirectUri can already contain $redirectURI (including the siteaccess).
1457 if ( !empty( $redirectURI ) && strpos( $moduleRedirectUri, $redirectURI ) === 0 )
1458 {
1459 $redirectURI = $moduleRedirectUri;
1460 }
1461 else
1462 {
1463 $redirectURI .= $moduleRedirectUri;
1464 }
1465 }
1466
1467 // After the module redirect url is completed, add the queryString params so they carry over the redirect operation
1468 $redirectURI .= eZSys::queryString();
1469
1470 if ( $ini->variable( 'ContentSettings', 'StaticCache' ) == 'enabled' )
1471 {
1472 $staticCacheHandlerClassName = $ini->variable( 'ContentSettings', 'StaticCacheHandler' );
1473 $staticCacheHandlerClassName::executeActions();
1474 }
1475
1476 eZDB::checkTransactionCounter();
1477
1478 if ( !$automaticRedirect )
1479 {
1480 // Make sure any errors or warnings are reported
1481 if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) === 'enabled' )
1482 {
1483 if ( isset( $GLOBALS['eZDebugError'] ) && $GLOBALS['eZDebugError'] )
1484 {
1485 eZAppendWarningItem(
1486 array(
1487 'error' => array(
1488 'type' => 'error',
1489 'number' => 1,
1490 'count' => $GLOBALS['eZDebugErrorCount']
1491 ),
1492 'identifier' => 'ezdebug-first-error',
1493 'text' => ezpI18n::tr( 'index.php', 'Some errors occurred, see debug for more information.' )
1494 )
1495 );
1496 }
1497
1498 if ( isset( $GLOBALS['eZDebugWarning'] ) && $GLOBALS['eZDebugWarning'] )
1499 {
1500 eZAppendWarningItem(
1501 array(
1502 'error' => array(
1503 'type' => 'warning',
1504 'number' => 1,
1505 'count' => $GLOBALS['eZDebugWarningCount']
1506 ),
1507 'identifier' => 'ezdebug-first-warning',
1508 'text' => ezpI18n::tr( 'index.php', 'Some general warnings occured, see debug for more information.' )
1509 )
1510 );
1511 }
1512 }
1513
1514 $tpl = eZTemplate::factory();
1515 $tpl->setVariable( 'site', $this->site );
1516 $tpl->setVariable( 'warning_list', !empty( $this->warningList ) ? $this->warningList : false );
1517 $tpl->setVariable( 'redirect_uri', eZURI::encodeURL( $redirectURI ) );
1518 $templateResult = $tpl->fetch( 'design:redirect.tpl' );
1519
1520 eZDebug::addTimingPoint( "Script end" );
1521
1522 eZDisplayResult( $templateResult );
1523 eZExecution::cleanExit();
1524 }
1525
1526 return eZHTTPTool::redirect( $redirectURI, array(), $this->module->redirectStatus(), true, true );
1527 }
1528
1533 protected function sessionInit()
1534 {
1535 if ( !isset( $this->settings['session'] ) || !$this->settings['session']['configured'] )
1536 {
1537 // running without Symfony2 or session is not configured
1538 // we keep the historic behaviour
1539 $ini = eZINI::instance();
1540 if ( $ini->variable( 'Session', 'ForceStart' ) === 'enabled' )
1541 eZSession::start();
1542 else
1543 eZSession::lazyStart();
1544 }
1545 else
1546 {
1547 $sfHandler = new ezpSessionHandlerSymfony(
1548 $this->settings['session']['has_previous']
1549 || $this->settings['session']['started']
1550 );
1551 $sfHandler->setStorage( $this->settings['session']['storage'] );
1552 eZSession::init(
1553 $this->settings['session']['name'],
1554 $this->settings['session']['started'],
1555 $this->settings['session']['namespace'],
1556 $sfHandler
1557 );
1558 }
1559
1560 // let session specify if db is required
1561 $this->siteBasics['db-required'] = eZSession::getHandlerInstance()->dbRequired();
1562 }
1563
1564 protected function requestInit()
1565 {
1566 if ( $this->isInitialized )
1567 return;
1568
1569 eZExecution::setCleanExit( false );
1570 $scriptStartTime = microtime( true );
1571
1572 $GLOBALS['eZRedirection'] = false;
1573 $this->access = eZSiteAccess::current();
1574
1575 eZDebug::setScriptStart( $scriptStartTime );
1576
1577 eZDebug::addTimingPoint( "Script start" );
1578
1579 $this->uri = eZURI::instance( eZSys::requestURI() );
1580 $GLOBALS['eZRequestedURI'] = $this->uri;
1581
1582 // Be able to do general events early in process
1583 ezpEvent::getInstance()->notify( 'request/preinput', array( $this->uri ) );
1584
1585 // Initialize module loading
1586 $this->siteBasics['module-repositories'] = eZModule::activeModuleRepositories();
1587 eZModule::setGlobalPathList( $this->siteBasics['module-repositories'] );
1588
1589 // make sure we get a new $ini instance now that it has been reset
1590 $ini = eZINI::instance();
1591
1592 // pre check, setup wizard related so needs to be before session/db init
1593 // TODO: Move validity check in the constructor? Setup is not meant to be launched at each (sub)request is it?
1594 if ( $ini->variable( 'SiteAccessSettings', 'CheckValidity' ) === 'true' )
1595 {
1596 $this->check = array( 'module' => 'setup', 'function' => 'init' );
1597 // Turn off some features that won't bee needed yet
1598 $this->siteBasics['policy-check-omit-list'][] = 'setup';
1599 $this->siteBasics['show-page-layout'] = $ini->variable( 'SetupSettings', 'PageLayout' );
1600 $this->siteBasics['validity-check-required'] = true;
1601 $this->siteBasics['session-required'] = $this->siteBasics['user-object-required'] = false;
1602 $this->siteBasics['db-required'] = $this->siteBasics['no-cache-adviced'] = $this->siteBasics['url-translator-allowed'] = false;
1603 $this->siteBasics['site-design-override'] = $ini->variable( 'SetupSettings', 'OverrideSiteDesign' );
1604 $this->access = eZSiteAccess::change( array( 'name' => 'setup', 'type' => eZSiteAccess::TYPE_URI ) );
1605 eZTranslatorManager::enableDynamicTranslations();
1606 }
1607
1608 if ( $this->siteBasics['session-required'] )
1609 {
1610 // Check if this should be run in a cronjob
1611 if ( $ini->variable( 'Session', 'BasketCleanup' ) !== 'cronjob' )
1612 {
1613 eZSession::addCallback(
1614 'destroy_pre',
1615 function ( eZDBInterface $db, $key, $escapedKey )
1616 {
1617 $basket = eZBasket::fetch( $key );
1618 if ( $basket instanceof eZBasket )
1619 $basket->remove();
1620 }
1621 );
1622 eZSession::addCallback(
1623 'gc_pre',
1624 function ( eZDBInterface $db, $time )
1625 {
1626 eZBasket::cleanupExpired( $time );
1627 }
1628 );
1629
1630 eZSession::addCallback(
1631 'cleanup_pre',
1632 function ( eZDBInterface $db )
1633 {
1634 eZBasket::cleanup();
1635 }
1636 );
1637 }
1638
1639 // addCallBack to update session id for shop basket on session regenerate
1640 eZSession::addCallback(
1641 'regenerate_post',
1642 function ( eZDBInterface $db, $escNewKey, $escOldKey )
1643 {
1644 $db->query( "UPDATE ezbasket SET session_id='{$escNewKey}' WHERE session_id='{$escOldKey}'" );
1645 }
1646 );
1647
1648 // TODO: Session starting should be made only once in the constructor
1649 $this->sessionInit();
1650 }
1651
1652 // if $this->siteBasics['db-required'], open a db connection and check that db is connected
1653 if ( $this->siteBasics['db-required'] && !eZDB::instance()->isConnected() )
1654 {
1655 $this->warningList[] = array(
1656 'error' => array(
1657 'type' => 'kernel',
1658 'number' => eZError::KERNEL_NO_DB_CONNECTION
1659 ),
1660 'text' => 'No database connection could be made, the system might not behave properly.'
1661 );
1662 }
1663
1664 // pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init
1665 if ( !isset( $this->check ) )
1666 {
1667 $this->check = eZUserLoginHandler::preCheck( $this->siteBasics, $this->uri );
1668 }
1669
1670 ezpEvent::getInstance()->notify( 'request/input', array( $this->uri ) );
1671
1672 // Initialize with locale settings
1673 // TODO: Move to constructor? Is it relevant to init the locale/charset for each (sub)requests?
1674 $this->languageCode = eZLocale::instance()->httpLocaleCode();
1675 $phpLocale = trim( $ini->variable( 'RegionalSettings', 'SystemLocale' ) );
1676 if ( $phpLocale != '' )
1677 {
1678 setlocale( LC_ALL, explode( ',', $phpLocale ) );
1679 }
1680
1681 $this->httpCharset = eZTextCodec::httpCharset();
1682
1683 // TODO: are these parameters supposed to vary across potential sub-requests?
1684 $this->site = array(
1685 'title' => $ini->variable( 'SiteSettings', 'SiteName' ),
1686 'design' => $ini->variable( 'DesignSettings', 'SiteDesign' ),
1687 'http_equiv' => array(
1688 'Content-Type' => 'text/html; charset=' . $this->httpCharset,
1689 'Content-language' => $this->languageCode
1690 )
1691 );
1692
1693 // Read role settings
1694 $this->siteBasics['policy-check-omit-list'] = array_merge(
1695 $this->siteBasics['policy-check-omit-list'],
1696 $ini->variable( 'RoleSettings', 'PolicyOmitList' )
1697 );
1698
1699 $this->isInitialized = true;
1700
1705 eZDebug::checkDebugByUser();
1706 }
1707
1711 public function runCallback( \Closure $callback, $postReinitialize = true )
1712 {
1713 $this->requestInit();
1714
1715 try
1716 {
1717 $return = $callback();
1718 }
1719 catch ( Exception $e )
1720 {
1721 $this->shutdown( $postReinitialize );
1722 throw $e;
1723 }
1724
1725 $this->shutdown( $postReinitialize );
1726
1727 return $return;
1728 }
1729
1733 protected function shutdown( $reInitialize = true )
1734 {
1735 eZExecution::cleanup();
1736 eZExecution::setCleanExit();
1737 eZExpiryHandler::shutdown();
1738 if ( $reInitialize )
1739 $this->isInitialized = false;
1740 }
1741
1747 public static function setUseExceptions( $useExceptions )
1748 {
1749 eZModule::$useExceptions = (bool)$useExceptions;
1750 }
1751
1755 public function reInitialize()
1756 {
1757 $this->isInitialized = false;
1758 }
1759
1766 public function hasServiceContainer()
1767 {
1768 return isset( $this->settings['service-container'] );
1769 }
1770
1777 public function getServiceContainer()
1778 {
1779 return $this->settings['service-container'];
1780 }
1781
1787 public function setUsePagelayout( $usePagelayout )
1788 {
1789 $this->siteBasics['show-page-layout'] = (bool)$usePagelayout;
1790 }
1791 }
$i
$i
Definition: admin/adlist.php:91
$Locale
$Locale
Definition: admin/articleedit.php:526
$session
$session
Definition: admin/articlelist.php:44
$items
$items
Definition: admin/orderview.php:211
$mainGroup
$mainGroup
Definition: admin/useredit.php:451
$sectionObject
$sectionObject
Definition: articleheaderlist.php:49
$Title
$Title
Definition: articlelistrss.php:36
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDebugSetting\writeDebug
static writeDebug( $conditionName, $string, $label="")
Definition: ezdebugsetting.php:128
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:546
eZDebug\isDebugEnabled
static isDebugEnabled()
Definition: ezdebug.php:1028
eZDebug\HANDLE_FROM_PHP
const HANDLE_FROM_PHP
Definition: ezdebug.php:76
eZDebug\setHandleType
static setHandleType( $type)
Definition: ezdebug.php:248
eZDebug\addTimingPoint
static addTimingPoint( $description="")
Definition: ezdebug.php:677
eZDebug\setScriptStart
static setScriptStart( $time=false)
Definition: ezdebug.php:1290
eZDebug\checkDebugByUser
static checkDebugByUser()
Definition: ezdebug.php:1185
eZExecution\setCleanExit
static setCleanExit( $hasCleanExit=true)
Definition: ezexecution.php:29
eZExecution\cleanup
static cleanup()
Definition: ezexecution.php:37
eZExecution\cleanExit
static cleanExit()
Definition: ezexecution.php:101
eZExecution\addFatalErrorHandler
static addFatalErrorHandler( $handler)
Definition: ezexecution.php:75
eZExtension\activateExtensions
static activateExtensions( $extensionType='default', eZINI $siteINI=null)
Definition: ezextension.php:188
eZHTTPHeader\headerOverrideArray
static headerOverrideArray( $uri)
Definition: ezhttpheader.php:58
eZLocale
Definition: ezlocale.php:119
eZModule
Definition: ezmodule.php:54
eZModule\$useExceptions
static $useExceptions
Definition: ezmodule.php:258
eZModule\exists
exists( $name)
Definition: ezmodule.php:214
eZPageView
Definition: ezpageview.php:47
eZPublishSDK\EDITION
const EDITION
Definition: version.php:24
eZSection
Definition: ezsection.php:45
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZSession\start
static start( $cookieTimeout=false)
Definition: lib/ezsession/classes/ezsession.php:384
eZSession\init
static init( $name, $started, $ns, ezpSessionHandler $handler)
Definition: lib/ezsession/classes/ezsession.php:428
eZSession\addCallback
static addCallback( $type, $callback)
Definition: lib/ezsession/classes/ezsession.php:622
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZSession\lazyStart
static lazyStart( $startIfUserHasCookie=true)
Definition: lib/ezsession/classes/ezsession.php:401
eZSession\getHandlerInstance
static getHandlerInstance(ezpSessionHandler|null $handler=null)
Definition: lib/ezsession/classes/ezsession.php:580
eZSiteAccess\TYPE_URI
const TYPE_URI
Definition: ezsiteaccess.php:25
eZSiteAccess\match
static match(eZURI $uri, $host, $port=80, $file='/index.php')
Definition: ezsiteaccess.php:104
eZSiteAccess\current
static current()
Definition: ezsiteaccess.php:676
eZSiteAccess\change
static change(array $access, eZINI $siteINI=null)
Definition: ezsiteaccess.php:504
eZSys\indexDir
static indexDir( $withAccessList=true)
Definition: ezsys.php:594
eZSys\serverVariable
static serverVariable( $variableName, $quiet=false)
Definition: ezsys.php:857
eZSys\serverPort
static serverPort()
Definition: ezsys.php:824
eZSys\requestURI
static requestURI()
Definition: ezsys.php:1263
eZSys\hostname
static hostname()
Definition: ezsys.php:677
eZSys\queryString
static queryString()
Definition: ezsys.php:608
eZSys\ezcrc32
static ezcrc32( $string)
Definition: ezsys.php:1298
eZSys\init
static init( $index='index.php', $forceVirtualHost=null)
Definition: ezsys.php:1104
eZSys\indexFile
static indexFile( $withAccessPath=true)
Definition: ezsys.php:619
eZSys\cacheDirectory
static cacheDirectory()
Definition: ezsys.php:528
eZTextCodec\updateSettings
static updateSettings( $settings)
Definition: ezi18n/classes/eztextcodec.php:527
eZTextCodec\httpCharset
static httpCharset()
Definition: ezi18n/classes/eztextcodec.php:569
eZTranslatorManager\enableDynamicTranslations
static enableDynamicTranslations( $enable=true)
Definition: eztranslatormanager.php:202
eZURI
Definition: ezuri.php:29
eZURI\instance
static instance( $uri=false)
Definition: ezuri.php:575
eZURI\encodeURL
static encodeURL( $url)
Definition: ezuri.php:195
eZURLTranslator\translate
static translate( $url)
Definition: ezurltranslator.php:54
eZUser\autoCookieLogin
static autoCookieLogin( $hash)
Definition: ezuser.php:837
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$Language
$Language
Definition: classes/admin/linklist.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
ezpEvent\getInstance
static getInstance()
Definition: ezpevent.php:176
ezpMobileDeviceDetectFilter\getFilter
static getFilter()
Definition: ezpmobiledevicedetectfilter.php:20
ezpMobileDeviceDetect
Definition: ezpmobiledevicedetect.php:16
ezpSessionHandlerSymfony
Definition: ezpsessionhandlersymfony.php:21
ezpbKernelResult
Definition: ezpbKernelResult.php:15
ezpbKernelWeb
Definition: ezpbkernelweb.php:17
ezpbKernelWeb\setupFatalErrorHandler
setupFatalErrorHandler()
Definition: ezpbkernelweb.php:277
ezpbKernelWeb\$policyCheckViewMap
$policyCheckViewMap
Definition: ezpbkernelweb.php:26
ezpbKernelWeb\$httpCharset
$httpCharset
Definition: ezpbkernelweb.php:90
ezpbKernelWeb\$module
$module
Definition: ezpbkernelweb.php:31
ezpbKernelWeb\reInitialize
reInitialize()
Definition: ezpbkernelweb.php:1755
ezpbKernelWeb\$languageCode
$languageCode
Definition: ezpbkernelweb.php:84
ezpbKernelWeb\hasServiceContainer
hasServiceContainer()
Definition: ezpbkernelweb.php:1766
ezpbKernelWeb\$siteBasics
$siteBasics
Definition: ezpbkernelweb.php:41
ezpbKernelWeb\$actualRequestedURI
$actualRequestedURI
Definition: ezpbkernelweb.php:46
ezpbKernelWeb\requestInit
requestInit()
Definition: ezpbkernelweb.php:1564
ezpbKernelWeb\run
run()
Definition: ezpbkernelweb.php:312
ezpbKernelWeb\$access
$access
Definition: ezpbkernelweb.php:63
ezpbKernelWeb\$site
$site
Definition: ezpbkernelweb.php:78
ezpbKernelWeb\$warningList
$warningList
Definition: ezpbkernelweb.php:36
ezpbKernelWeb\shutdown
shutdown( $reInitialize=true)
Definition: ezpbkernelweb.php:1733
ezpbKernelWeb\redirect
redirect()
Definition: ezpbkernelweb.php:1399
ezpbKernelWeb\sessionInit
sessionInit()
Definition: ezpbkernelweb.php:1533
ezpbKernelWeb\setUseExceptions
static setUseExceptions( $useExceptions)
Definition: ezpbkernelweb.php:1747
ezpbKernelWeb\$oldURI
$oldURI
Definition: ezpbkernelweb.php:51
ezpbKernelWeb\$check
$check
Definition: ezpbkernelweb.php:73
ezpbKernelWeb\$completeRequestedURI
$completeRequestedURI
Definition: ezpbkernelweb.php:56
ezpbKernelWeb\dispatchLoop
dispatchLoop()
Definition: ezpbkernelweb.php:1090
ezpbKernelWeb\$mobileDeviceDetect
$mobileDeviceDetect
Definition: ezpbkernelweb.php:21
ezpbKernelWeb\getServiceContainer
getServiceContainer()
Definition: ezpbkernelweb.php:1777
ezpbKernelWeb\getPolicyCheckViewMap
getPolicyCheckViewMap(array $policyCheckOmitList)
Definition: ezpbkernelweb.php:1375
ezpbKernelWeb\setUsePagelayout
setUsePagelayout( $usePagelayout)
Definition: ezpbkernelweb.php:1787
ezpbKernelWeb\$uri
$uri
Definition: ezpbkernelweb.php:68
ezpbKernelWeb\$settings
$settings
Definition: ezpbkernelweb.php:107
ezpbKernelWeb\$isInitialized
$isInitialized
Definition: ezpbkernelweb.php:97
ezpbKernelWeb\runCallback
runCallback(\Closure $callback, $postReinitialize=true)
Definition: ezpbkernelweb.php:1711
ezpbKernelWeb\__construct
__construct(array $settings=array())
Definition: ezpbkernelweb.php:112
$name
$name
Definition: companytypelist.php:194
$includePath
$includePath
Definition: cron_alerts.php:54
$separator
else $separator
Definition: cron_alerts.php:52
$siteDir
else $siteDir
Definition: cron_alerts.php:43
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$fp
$fp
Definition: export.php:97
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$url_array
$url_array
Definition: ezaddress/admin/datasupplier.php:34
$url_array_count
$url_array_count
Definition: ezaddress/admin/datasupplier.php:36
$page
$page
Definition: ezarticle/modules/content.php:28
$db
$db
Definition: ezarticle/user/authorlist.php:53
$GlobalSiteIni
$GlobalSiteIni
Definition: ezarticle/xmlrpc/xmlrpcserver.php:33
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$index
$index
Definition: ezforum/user/messageedit.php:36
$SiteStyle
$SiteStyle
Definition: ezgroupeventcalendar/user/filelist.php:35
$content
$content
Definition: ezimagecatalogue/admin/filedownload.php:53
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$StoreStats
$StoreStats
Definition: frame.php:482
eZDisplayResult
eZDisplayResult( $templateResult)
Definition: global_functions.php:56
eZUpdateDebugSettings
eZUpdateDebugSettings()
Definition: global_functions.php:88
fetchModule
fetchModule(eZURI $uri, $check, &$module, &$moduleName, &$functionName, &$params)
Definition: global_functions.php:144
eZAppendWarningItem
eZAppendWarningItem( $parameters=array())
Definition: global_functions.php:119
$time
$time
Definition: homepage.php:327
ezpWebBasedKernelHandler
Definition: ezpwebbasedkernelhandler.php:15
$GlobalSiteDesign
global $GlobalSiteDesign
Definition: latestmessages.php:52
$tpl
$tpl
Definition: mailtofriend.php:58
$wwwDir
$wwwDir
Definition: singlelist.php:33
$GlobalPageView
$GlobalPageView
Definition: storestats.php:43
$currentUser
$currentUser
Definition: surveyedit.php:54
$user
$user
Definition: user/adlist.php:39
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.