Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezpbkerneladmin.php
Go to the documentation of this file.
1 <?php
16 class ezpbKernelAdmin 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 //
345 // $Id: index_admin.php 9465 2002-04-24 07:38:20Z jhe $
346 //
347 // Created on: <09-Nov-2000 14:52:40 ce>
348 //
349 // This source file is part of Exponential Basic, publishing software.
350 //
351 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
352 //
353 // This program is free software; you can redistribute it and/or
354 // modify it under the terms of the GNU General Public License
355 // as published by the Free Software Foundation; either version 2
356 // of the License, or (at your option) any later version.
357 //
358 // This program is distributed in the hope that it will be useful,
359 // but WITHOUT ANY WARRANTY; without even the implied warranty of
360 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
361 // GNU General Public License for more details.
362 //
363 // You should have received a copy of the GNU General Public License
364 // along with this program; if not, write to the Free Software
365 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
366 //
367
368 // header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
369 // header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
370 // header("Cache-Control: no-cache, must-revalidate");
371 // header("Pragma: no-cache");
372 // header( "X-Powered-By: Exponential Basic" );
373
374 // settings for sessions
375 // max timeout is set to 48 hours
376 ini_alter("session.gc_maxlifetime", "172800");
377 ini_alter("session.entropy_file","/dev/urandom");
378 ini_alter("session.entropy_length", "512");
379 ini_alter("session.cache_expire", "172800");
380
381 global $ini;
382 $ini =& eZINI::instance( 'site.ini' );
383
384 $siteDesign =& $ini->variable( "site", "SiteStyle" );
385 $SiteDesign =& $siteDesign;
386 $GlobalSiteDesign = $siteDesign;
387
388 $StoreStats = $ini->variable( "eZStatsMain", "StoreStats" );
389
390 $HelpMode = "disabled";
391
392 // 7x: Convert the following to ini settings
393 global $GLOBALS;
394
395 $GLOBALS["DEBUG"] = false;
396 $GLOBALS["DDD"] = '';
397 $UsePHPSessions = false;
398
399 // Convert into clean settings for portability
400 $GLOBALS["DEBUG"] = true;
401 $GLOBALS["DEBUG_EZTEMPLATE"] = false;
402
403 global $GlobalSiteIni;
404 $GlobalSiteIni =& $ini;
405
406 // Set the global nVH variables.
407 $GlobalSiteIni->Index = $index;
408 $GlobalSiteIni->WWWDir = $wwwDir;
409 $GlobalSiteIni->SiteDir = $siteDir;
410 unset( $index );
411 unset( $wwwDir );
412
413 // Find out, where our files are.
414 if ( preg_match( "/(.*\/)([^\/]+\.php)$/", $_SERVER['SCRIPT_FILENAME'], $regs ) )
415 {
416 $siteDir = $regs[1];
417 $index = "/" . $regs[2];
418 }
419 elseif ( preg_match( "/(.*\/)([^\/]+\.php)/?/", $_SERVER['PHP_SELF'], $regs ) )
420 {
421 // Some people using CGI have their $SCRIPT_FILENAME not right... so we are trying this.
422 $siteDir = $_SERVER['DOCUMENT_ROOT'] . $regs[1];
423 $index = "/" . $regs[2];
424 }
425 else
426 {
427 // Fallback... doesn't work with virtual-hosts, but better than nothing
428 $siteDir = "./";
429 $index = "/index_admin.php";
430 }
431
432 // What OS-type are we using?
433 if ( substr( php_uname(), 0, 7) == "Windows" )
434 $separator = ";";
435 else
436 $separator = ":";
437
438 // Setting the right include_path
439 $includePath = ini_get( "include_path" );
440 if ( trim( $includePath ) != "" )
441 $includePath .= $separator . $siteDir;
442 else
443 $includePath = $siteDir;
444 ini_set( "include_path", $includePath );
445
446 $wwwDir='';
447 // Get the webdir.
448 if ( preg_match( "/(.*)\/([^\/]+\.php)$/", $_SERVER['SCRIPT_NAME'], $regs ) )
449 $wwwDir = $regs[1];
450
451 // Fallback... Finding the paths above failed, so $PHP_SELF is not set right.
452 if ( $siteDir == "./" )
453 $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'];
454
455 // Trick: Rewrite setup doesn't have index.php in $PHP_SELF, so we don't want an $index
456 if ( ! preg_match( "/.*index\.php.*/", $_SERVER['PHP_SELF'] ) )
457 $index = "";
458 else
459 {
460 // Get the right $REQUEST_URI, when using nVH setup.
461 if ( preg_match( "/^$wwwDir$index(.+)/", $_SERVER['PHP_SELF'], $req ) )
462 $_SERVER['REQUEST_URI'] = $req[1];
463 }
464
465 // Remove url parameters
466 preg_match( "/([^?]+)/", $_SERVER['REQUEST_URI'], $regs );
467 $_SERVER['REQUEST_URI'] = $regs[1];
468
469 // Start the buffer cache
470 ob_start();
471 // Turn on output buffering with gz compression
472 //ob_start("ob_gzhandler");
473
474 if ( $UsePHPSessions == true )
475 {
476 // start session handling
477 session_start();
478 }
479
480 $url_array = explode( "/", $_SERVER['REQUEST_URI'] );
481 $url_array_count = count( $url_array );
482
483 for( $i = $url_array_count; $i <= 25; $i++ )
484 {
485 $url_array[$i] = false;
486 }
487
488 try
489 {
490 // $moduleResult = $this->dispatchLoop();
491
492 // set the module logo
493 $moduleName =& $url_array[1];
494
495 if ( $moduleName == "" )
496 $moduleName = "user";
497
498 $user =& eZUser::currentUser();
499 if ( $user )
500 {
501 if ( $url_array[1] == "help" )
502 {
503 $HelpMode = "enabled";
504
505 include( "design/admin/help_header.php" );
506 }
507 else
508 {
509 // html header
510 if ( !empty($_REQUEST['PrintableVersion']))
511 {
512 include( "design/admin/print_header.php" );
513 }
514 else
515 {
516 include( "design/admin/header.php" );
517 }
518 }
519
520 // require( "kernel/ezuser/admin/admincheck.php" );
521
522 if ( $HelpMode != "enabled" )
523 {
524 // // include_once( "kernel/ezsession/classes/ezpreferences.php" );
525 $preferences = new eZPreferences();
526
527 $site_modules = $ini->variable( "site", "EnabledModules" );
528 $admin_modules = explode( ";", $ini->variable( "site", "EnabledAdminModules" ) );
529 $modules =& eZModuleHandler::active();
530
531 $uri = $_SERVER["REQUEST_URI"];
532
533 if ( empty($_REQUEST['PrintableVersion']))
534 {
535 if ( !empty( $_REQUEST["ToggleMenu"] ) )
536 {
537 foreach( $modules as $module )
538 {
539 $module_dir = 'kernel/' . strtolower( $module );
540 if ( $_REQUEST["ToggleMenu"] == $module_dir )
541 {
542 eZModuleHandler::toggle( $module_dir );
543 $uri = eZHTTPTool::removeVariable( $uri, "ToggleMenu" );
544 eZHTTPTool::header( "Location: $uri" );
545 exit;
546 }
547 }
548 }
549
550 $moved_module = false;
551
552 if ( isset( $_REQUEST["MoveUp"] ) ) {
553 eZModuleHandler::moveUp( $modules, $_REQUEST["MoveUp"], $moved_module );
554
555 }
556 elseif( !$moved_module && isset($_REQUEST["MoveDown"]))
557 {
558 eZModuleHandler::moveDown( $modules, $_REQUEST["MoveDown"], $moved_module );
559 }
560
561 $uri = eZHTTPTool::removeVariable( $uri, "MoveUp" );
562 $uri = eZHTTPTool::removeVariable( $uri, "MoveDown" );
563
564 if ( $moved_module )
565 {
566 $preferences->setVariable( "EnabledModules", $modules );
567 eZHTTPTool::header( "Location: $uri" );
568 exit;
569 }
570
571 //if( $singleModule == 'enabled' )
572 // $modules = array( $modules[0] );
573
574 // set the module logo
575 $moduleName =& $url_array[1];
576
577 foreach ( $admin_modules as $moduleString )
578 {
579 $moduleArray = explode( "|", $moduleString );
580
581 if( $moduleArray[1] == "ez" . $moduleName )
582 {
583 $moduleNameMixedCase = $moduleArray[0];
584 $moduleSettingsGroupName = $moduleArray[0] . "Main";
585 break;
586 }
587 }
588 // draw modules
589 foreach ( $modules as $module )
590 {
591 if ( !empty( $module ) )
592 {
593 $module_dir = "kernel/" . strtolower( $module );
594
595 unset( $menuItems );
596 include( "$module_dir/admin/menubox.php" );
597 if ( isset( $menuItems ) )
598 eZMenuBox::createBox( $moduleName, $module_dir, "admin",
599 $siteDesign, $menuItems, true, false,
600 "$module_dir/admin/menubox.php", false, true, $moduleSettingsGroupName );
601 unset( $module_dir );
602 }
603 }
604 }
605
606 // 7x Register Globals Replacement
607 foreach($_COOKIE 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($_GET 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($_POST 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 foreach($_REQUEST as $key => $value) {
635 if(!is_array($value)){
636 ${$key} = trim(rawurldecode($value));
637 //echo "$key $value<br>";
638 }
639 else{
640 ${$key} = $value;
641 }
642 }
643 foreach($_SERVER as $key => $value) {
644 if(!is_array($value)){
645 ${$key} = trim(rawurldecode($value));
646 //echo "$key $value<br>";
647 }
648 else{
649 ${$key} = $value;
650 }
651 }
652
653 // parse the URI
654 $page = "";
655
656 // send the URI to the right decoder
657 $page = "kernel/ez" . $url_array[1] . "/admin/datasupplier.php";
658
659 // set the module logo
660 $moduleName =& $url_array[1];
661
662 foreach ( $admin_modules as $moduleString )
663 {
664 $moduleArray = explode( "|", $moduleString );
665
666 if( $moduleArray[1] == "ez" . $moduleName )
667 {
668 $moduleNameMixedCase = $moduleArray[0];
669 $moduleSettingsGroupName = $moduleArray[0] . "Main";
670 break;
671 }
672 }
673
674 if ( $moduleName == "" )
675 $moduleName = "user";
676
677
678 if ( empty($_REQUEST['PrintableVersion']))
679 {
680 // break the column an draw a horizontal line
681 // include( "design/admin/separator.php" );
682
683 $single_module = $preferences->variable( "SingleModule" ) == "enabled";
684
685 $ini =& eZINI::instance('site.ini');
686
687 $Language = $ini->variable( $moduleSettingsGroupName, "Language" );
688
689 $t = new eZTemplate( "design/admin/templates/" . $siteDesign,
690 "kernel/ez" . $moduleName . "/admin/intl/", $Language, "menubox.php" );
691 $t->set_file( array(
692 "separator_tpl" => "separator.tpl"
693 ) );
694
695 $t->set_block( "separator_tpl", "left_spacer_tpl", "left_spacer_item" );
696 $t->set_block( "separator_tpl", "top_field_tpl", "top_field_item" );
697 $t->set_block( "top_field_tpl", "help_tpl", "help" );
698
699 $t->set_var( "site_style", $siteDesign );
700
701 $t->set_var( "module_name", $moduleName );
702
703 $t->set_var( "current_url", $_SERVER['REQUEST_URI'] );
704
705 if( isset( $url_array[2] ) )
706 {
707 // check for help file
708 $helpFile = "kernel/ez" . $moduleName . "/admin/help/". $Language . "/" . $url_array[1] . "_" . $url_array[2] . ".hlp";
709 }
710 else {
711 // check for help file
712 $helpFile = "kernel/ez" . $moduleName . "/admin/help/". $Language . "/" . $url_array[1] . ".hlp";
713 }
714 $t->set_var( "help", "" );
715
716 if ( file_exists( $helpFile ) )
717 {
718 $t->set_var( "help_url", "/help/" . $moduleName . "/" . $url_array[1] . "/" . $url_array[2]. "/" );
719 $t->parse( "help", "help_tpl" );
720 }
721
722 $t->setAllStrings();
723
724 $t->set_var( "module_count", count ( $modules ) );
725 $t->set_var( "left_spacer_item", "" );
726
727 $moduletab = $ini->variable( "site", "ModuleTab" );
728
729 if ( ( $moduletab == "enabled" ) && ( count ( $modules ) != 0 ) )
730 {
731 $t->parse( "left_spacer_item", "left_spacer_tpl" );
732 }
733
734 $t->parse( "top_field_item", "top_field_tpl" );
735
736 $t->pparse( "output", "separator_tpl" );
737 }
738
739 if ( file_exists( $page ) )
740 {
741 include( $page );
742 }
743 else
744 {
745 include( "kernel/ezuser/admin/welcome.php" );
746 }
747 }
748 else
749 {
750 // show the help page
751
752 $helpFile = "kernel/ez" . $url_array[2] . "/admin/help/". $Language . "/" . $url_array[3] . "_" . $url_array[4] . ".hlp";
753
754 if ( file_exists( $helpFile ) )
755 {
756 include( $helpFile );
757 }
758 else
759 {
760 if ( $url_array[2] != "popup" )
761 print( "help file not found" );
762 else
763 {
764 $page = "ez" . $url_array[1] . "/admin/datasupplier.php";
765
766 if ( file_exists( $page ) )
767 {
768 include( $page );
769 }
770 else
771 {
772 print( "popup file not found" );
773 }
774 }
775
776 }
777 }
778 if ( $HelpMode == "enabled" )
779 {
780 include( "design/admin/help_footer.php" );
781 }
782 else
783 {
784 // html footer
785 if ( !empty($_REQUEST['PrintableVersion']))
786 {
787 include( "design/admin/print_footer.php" );
788 }
789 else
790 {
791 if ( $url_array[2] != "popup" )
792 include( "design/admin/footer.php" );
793 }
794 }
795 }
796 else
797 {
798 include( "design/admin/loginheader.php" );
799
800 if ( $moduleName == "" )
801 $moduleName = "user";
802
803 $LoginSeparator = true;
804
805 if ( $_SERVER['REQUEST_URI'] == "/" )
806 {
807 $_SERVER['REQUEST_URI'] = "/user/login";
808 $url_array =& explode( "/", $_SERVER['REQUEST_URI'] );
809 }
810
811 // parse the URI
812 $page = "";
813
814 // send the URI to the right decoder
815 $page = "kernel/ezuser/admin/datasupplier.php";
816
817 if ( file_exists( $page ) )
818 {
819 include( $page );
820 }
821
822 // html footer
823 include( "design/admin/loginfooter.php" );
824
825 $moduleResult =& ob_get_contents();
826
827 ob_end_clean();
828 ob_start();
829
830 }
831
832
833 // close the database connection.
834 $db =& eZDB::globalDatabase();
835 $db->close();
836
837 ob_end_flush();
838 }
839 catch ( Exception $e )
840 {
841 $this->shutdown();
842 throw $e;
843 }
844
845 $ini = eZINI::instance();
846
852 /*
853 if ( $ini->variable( "SiteAccessSettings", "CheckValidity" ) !== 'true' )
854 {
855 $wwwDir = eZSys::wwwDir();
856 // On host based site accesses this can be empty, causing the cookie to be set for the current dir,
857 // but we want it to be set for the whole Exponential Basic site
858 $cookiePath = $wwwDir != '' ? $wwwDir : '/';
859
860 if ( eZUser::isCurrentUserRegistered() )
861 {
862 // Only set the cookie if it doesnt exist. This way we are not constantly sending the set request in the headers.
863 if ( !isset( $_COOKIE['is_logged_in'] ) || $_COOKIE['is_logged_in'] !== 'true' )
864 {
865 setcookie( 'is_logged_in', 'true', 0, $cookiePath );
866 }
867 }
868 else if ( isset( $_COOKIE['is_logged_in'] ) )
869 {
870 setcookie( 'is_logged_in', false, 0, $cookiePath );
871 }
872 }
873
874 if ( $this->module->exitStatus() == eZModule::STATUS_REDIRECT )
875 {
876 $this->shutdown();
877 return $this->redirect();
878 }
879
880 $uiContextName = $this->module->uiContextName();
881
882 // Store the last URI for access history for login redirection
883 // Only if user has session and only if there was no error or no redirects happen
884 if ( eZSession::hasStarted() && $this->module->exitStatus() == eZModule::STATUS_OK )
885 {
886 $currentURI = $this->completeRequestedURI;
887 if ( strlen( $currentURI ) > 0 && $currentURI[0] !== '/' )
888 $currentURI = '/' . $currentURI;
889
890 $lastAccessedURI = "";
891 $lastAccessedViewURI = "";
892
893 $http = eZHTTPTool::instance();
894
895 // Fetched stored session variables
896 if ( $http->hasSessionVariable( "LastAccessesURI" ) )
897 {
898 $lastAccessedViewURI = $http->sessionVariable( "LastAccessesURI" );
899 }
900 if ( $http->hasSessionVariable( "LastAccessedModifyingURI" ) )
901 {
902 $lastAccessedURI = $http->sessionVariable( "LastAccessedModifyingURI" );
903 }
904
905 // Update last accessed view page
906 if ( $currentURI != $lastAccessedViewURI &&
907 !in_array( $uiContextName, array( 'edit', 'administration', 'ajax', 'browse', 'authentication' ) ) )
908 {
909 $http->setSessionVariable( "LastAccessesURI", $currentURI );
910 }
911
912 // Update last accessed non-view page
913 if ( $currentURI != $lastAccessedURI && $uiContextName != 'ajax' )
914 {
915 $http->setSessionVariable( "LastAccessedModifyingURI", $currentURI );
916 }
917 }
918
919 eZDebug::addTimingPoint( "Module end '" . $this->module->attribute( 'name' ) . "'" );
920 if ( !is_array( $moduleResult ) )
921 {
922 eZDebug::writeError( 'Module did not return proper result: ' . $this->module->attribute( 'name' ), 'index.php' );
923 $moduleResult = array();
924 $moduleResult['content'] = false;
925 }
926
927 if ( !isset( $moduleResult['ui_context'] ) )
928 {
929 $moduleResult['ui_context'] = $uiContextName;
930 }
931 $moduleResult['ui_component'] = $this->module->uiComponentName();
932 $moduleResult['is_mobile_device'] = $this->mobileDeviceDetect->isMobileDevice();
933 $moduleResult['mobile_device_alias'] = $this->mobileDeviceDetect->getUserAgentAlias();
934
935 $templateResult = null;
936
937 eZDebug::setUseExternalCSS( $this->siteBasics['external-css'] );
938 if ( $this->siteBasics['show-page-layout'] )
939 {
940 $tpl = eZTemplate::factory();
941 if ( $tpl->hasVariable( 'node' ) )
942 $tpl->unsetVariable( 'node' );
943
944 if ( !isset( $moduleResult['path'] ) )
945 $moduleResult['path'] = false;
946 $moduleResult['uri'] = eZSys::requestURI();
947
948 $tpl->setVariable( "module_result", $moduleResult );
949
950 $meta = $ini->variable( 'SiteSettings', 'MetaDataArray' );
951
952 if ( !isset( $meta['description'] ) )
953 {
954 $metaDescription = "";
955 if ( isset( $moduleResult['path'] ) && is_array( $moduleResult['path'] ) )
956 {
957 foreach ( $moduleResult['path'] as $pathPart )
958 {
959 if ( isset( $pathPart['text'] ) )
960 $metaDescription .= $pathPart['text'] . " ";
961 }
962 }
963 $meta['description'] = $metaDescription;
964 }
965
966 $this->site['uri'] = $this->oldURI;
967 $this->site['redirect'] = false;
968 $this->site['meta'] = $meta;
969 $this->site['version'] = eZPublishSDK::version();
970 $this->site['page_title'] = $this->module->title();
971
972 $tpl->setVariable( "site", $this->site );
973
974 if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) === 'enabled' )
975 {
976 // Make sure any errors or warnings are reported
977 if ( isset( $GLOBALS['eZDebugError'] ) && $GLOBALS['eZDebugError'] )
978 {
979 eZAppendWarningItem(
980 array(
981 'error' => array(
982 'type' => 'error',
983 'number' => 1 ,
984 'count' => $GLOBALS['eZDebugErrorCount']
985 ),
986 'identifier' => 'ezdebug-first-error',
987 'text' => ezpI18n::tr( 'index.php', 'Some errors occurred, see debug for more information.' )
988 )
989 );
990 }
991
992 if ( isset( $GLOBALS['eZDebugWarning'] ) && $GLOBALS['eZDebugWarning'] )
993 {
994 eZAppendWarningItem(
995 array(
996 'error' => array(
997 'type' => 'warning',
998 'number' => 1,
999 'count' => $GLOBALS['eZDebugWarningCount']
1000 ),
1001 'identifier' => 'ezdebug-first-warning',
1002 'text' => ezpI18n::tr( 'index.php', 'Some general warnings occured, see debug for more information.' )
1003 )
1004 );
1005 }
1006 }
1007
1008 if ( $this->siteBasics['user-object-required'] )
1009 {
1010 $currentUser = eZUser::currentUser();
1011
1012 $tpl->setVariable( "current_user", $currentUser );
1013 $tpl->setVariable( "anonymous_user_id", $ini->variable( 'UserSettings', 'AnonymousUserID' ) );
1014 }
1015 else
1016 {
1017 $tpl->setVariable( "current_user", false );
1018 $tpl->setVariable( "anonymous_user_id", false );
1019 }
1020
1021 $tpl->setVariable( "access_type", $this->access );
1022 $tpl->setVariable( 'warning_list', !empty( $this->warningList) ? $this->warningList : false );
1023
1024 $resource = "design:";
1025 if ( is_string( $this->siteBasics['show-page-layout'] ) )
1026 {
1027 if ( strpos( $this->siteBasics['show-page-layout'], ":" ) !== false )
1028 {
1029 $resource = "";
1030 }
1031 }
1032 else
1033 {
1034 $this->siteBasics['show-page-layout'] = "pagelayout.tpl";
1035 }
1036
1037 // Set the navigation part
1038 // Check for navigation part settings
1039 $navigationPartString = 'ezcontentnavigationpart';
1040 if ( isset( $moduleResult['navigation_part'] ) )
1041 {
1042 $navigationPartString = $moduleResult['navigation_part'];
1043
1044 // Fetch the navigation part
1045 }
1046 $navigationPart = eZNavigationPart::fetchPartByIdentifier( $navigationPartString );
1047
1048 $tpl->setVariable( 'navigation_part', $navigationPart );
1049 $tpl->setVariable( 'uri_string', $this->uri->uriString() );
1050 if ( isset( $moduleResult['requested_uri_string'] ) )
1051 {
1052 $tpl->setVariable( 'requested_uri_string', $moduleResult['requested_uri_string'] );
1053 }
1054 else
1055 {
1056 $tpl->setVariable( 'requested_uri_string', $this->actualRequestedURI );
1057 }
1058
1059 // Set UI context and component
1060 $tpl->setVariable( 'ui_context', $moduleResult['ui_context'] );
1061 $tpl->setVariable( 'ui_component', $moduleResult['ui_component'] );
1062
1063 $templateResult = $tpl->fetch( $resource . $this->siteBasics['show-page-layout'] );
1064 }
1065 else
1066 {
1067 $templateResult = $moduleResult['content'];
1068 }
1069 */
1070 $templateResult = $moduleResult;
1071
1072 eZDebug::addTimingPoint( "Script end" );
1073
1074 $content = trim( ob_get_clean() );
1075
1076 ob_start();
1077 // eZDB::checkTransactionCounter();
1078 eZDisplayResult( $templateResult );
1079 $content .= ob_get_clean();
1080
1081 $this->shutdown();
1082
1083 return new ezpbKernelResult( $content, array( 'module_result' => $moduleResult ) );
1084 }
1085
1089 protected function dispatchLoop()
1090 {
1091 $ini = eZINI::instance();
1092
1093 // Start the module loop
1094 while ( $this->siteBasics['module-run-required'] )
1095 {
1096 $objectHasMovedError = false;
1097 $objectHasMovedURI = false;
1098 $this->actualRequestedURI = $this->uri->uriString();
1099
1100 // Extract user specified parameters
1101 $userParameters = $this->uri->userParameters();
1102
1103 // Generate a URI which also includes the user parameters
1104 $this->completeRequestedURI = $this->uri->originalURIString();
1105
1106 // Check for URL translation
1107 if ( $this->siteBasics['url-translator-allowed'] && eZURLAliasML::urlTranslationEnabledByUri( $this->uri ) )
1108 {
1109 $translateResult = eZURLAliasML::translate( $this->uri );
1110
1111 if ( !is_string( $translateResult ) && $ini->variable( 'URLTranslator', 'WildcardTranslation' ) === 'enabled' )
1112 {
1113 $translateResult = eZURLWildcard::translate( $this->uri );
1114 }
1115
1116 // Check if the URL has moved
1117 if ( is_string( $translateResult ) )
1118 {
1119 $objectHasMovedURI = $translateResult;
1120 foreach ( $userParameters as $name => $value )
1121 {
1122 $objectHasMovedURI .= '/(' . $name . ')/' . $value;
1123 }
1124
1125 $objectHasMovedError = true;
1126 }
1127 }
1128
1129 if ( $this->uri->isEmpty() )
1130 {
1131 $tmp_uri = new eZURI( $ini->variable( "SiteSettings", "IndexPage" ) );
1132 $moduleCheck = eZModule::accessAllowed( $tmp_uri );
1133 }
1134 else
1135 {
1136 $moduleCheck = eZModule::accessAllowed( $this->uri );
1137 }
1138
1139 if ( !$moduleCheck['result'] )
1140 {
1141 if ( $ini->variable( "SiteSettings", "ErrorHandler" ) == "defaultpage" )
1142 {
1143 $defaultPage = $ini->variable( "SiteSettings", "DefaultPage" );
1144 $this->uri->setURIString( $defaultPage );
1145 $moduleCheck['result'] = true;
1146 }
1147 }
1148
1149 $displayMissingModule = false;
1150 $this->oldURI = $this->uri;
1151
1152 if ( $this->uri->isEmpty() )
1153 {
1154 if ( !fetchModule( $tmp_uri, $this->check, $this->module, $moduleName, $functionName, $params ) )
1155 $displayMissingModule = true;
1156 }
1157 else if ( !fetchModule( $this->uri, $this->check, $this->module, $moduleName, $functionName, $params ) )
1158 {
1159 if ( $ini->variable( "SiteSettings", "ErrorHandler" ) == "defaultpage" )
1160 {
1161 $tmp_uri = new eZURI( $ini->variable( "SiteSettings", "DefaultPage" ) );
1162 if ( !fetchModule( $tmp_uri, $this->check, $this->module, $moduleName, $functionName, $params ) )
1163 $displayMissingModule = true;
1164 }
1165 else
1166 $displayMissingModule = true;
1167 }
1168
1169 if ( !$displayMissingModule && $moduleCheck['result'] && $this->module instanceof eZModule )
1170 {
1171 // Run the module/function
1172 eZDebug::addTimingPoint( "Module start '" . $this->module->attribute( 'name' ) . "'" );
1173
1174 $moduleAccessAllowed = true;
1175 $omitPolicyCheck = true;
1176 $runModuleView = true;
1177
1178 $availableViewsInModule = $this->module->attribute( 'views' );
1179 if (
1180 !isset( $availableViewsInModule[$functionName] )
1181 && !$objectHasMovedError
1182 && !isset( $this->module->Module['function']['script'] )
1183 )
1184 {
1185 $moduleResult = $this->module->handleError( eZError::KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel', array( "check" => $moduleCheck ) );
1186 $runModuleView = false;
1187 $this->siteBasics['policy-check-required'] = false;
1188 $omitPolicyCheck = true;
1189 }
1190
1191 if ( $this->siteBasics['policy-check-required'] )
1192 {
1193 $omitPolicyCheck = false;
1194 $moduleName = $this->module->attribute( 'name' );
1195 if ( in_array( $moduleName, $this->siteBasics['policy-check-omit-list'] ) )
1196 $omitPolicyCheck = true;
1197 else
1198 {
1199 $policyCheckViewMap = $this->getPolicyCheckViewMap( $this->siteBasics['policy-check-omit-list'] );
1200 if ( isset( $policyCheckViewMap[$moduleName][$functionName] ) )
1201 $omitPolicyCheck = true;
1202 }
1203 }
1204 if ( !$omitPolicyCheck )
1205 {
1206 $currentUser = eZUser::currentUser();
1207 $siteAccessResult = $currentUser->hasAccessTo( 'user', 'login' );
1208
1209 $hasAccessToSite = false;
1210 if ( $siteAccessResult[ 'accessWord' ] === 'limited' )
1211 {
1212 $policyChecked = false;
1213 foreach ( array_keys( $siteAccessResult['policies'] ) as $key )
1214 {
1215 $policy = $siteAccessResult['policies'][$key];
1216 if ( isset( $policy['SiteAccess'] ) )
1217 {
1218 $policyChecked = true;
1219 $crc32AccessName = eZSys::ezcrc32( $this->access[ 'name' ] );
1220 eZDebugSetting::writeDebug( 'kernel-siteaccess', $policy['SiteAccess'], $crc32AccessName );
1221 if ( in_array( $crc32AccessName, $policy['SiteAccess'] ) )
1222 {
1223 $hasAccessToSite = true;
1224 break;
1225 }
1226 }
1227 if ( $hasAccessToSite )
1228 break;
1229 }
1230 if ( !$policyChecked )
1231 $hasAccessToSite = true;
1232 }
1233 else if ( $siteAccessResult[ 'accessWord' ] === 'yes' )
1234 {
1235 eZDebugSetting::writeDebug( 'kernel-siteaccess', "access is yes" );
1236 $hasAccessToSite = true;
1237 }
1238 else if ( $siteAccessResult['accessWord'] === 'no' )
1239 {
1240 $accessList = $siteAccessResult['accessList'];
1241 }
1242
1243 if ( $hasAccessToSite )
1244 {
1245 $accessParams = array();
1246 $moduleAccessAllowed = $currentUser->hasAccessToView( $this->module, $functionName, $accessParams );
1247 if ( isset( $accessParams['accessList'] ) )
1248 {
1249 $accessList = $accessParams['accessList'];
1250 }
1251 }
1252 else
1253 {
1254 eZDebugSetting::writeDebug( 'kernel-siteaccess', $this->access, 'not able to get access to siteaccess' );
1255 $moduleAccessAllowed = false;
1256 if ( $ini->variable( "SiteAccessSettings", "RequireUserLogin" ) == "true" )
1257 {
1258 $this->module = eZModule::exists( 'user' );
1259 if ( $this->module instanceof eZModule )
1260 {
1261 $moduleResult = $this->module->run(
1262 'login',
1263 array(),
1264 array(
1265 'SiteAccessAllowed' => false,
1266 'SiteAccessName' => $this->access['name']
1267 )
1268 );
1269 $runModuleView = false;
1270 }
1271 }
1272 }
1273 }
1274
1275 $GLOBALS['eZRequestedModule'] = $this->module;
1276
1277 if ( $runModuleView )
1278 {
1279 if ( $objectHasMovedError == true )
1280 {
1281 $moduleResult = $this->module->handleError( eZError::KERNEL_MOVED, 'kernel', array( 'new_location' => $objectHasMovedURI ) );
1282 }
1283 else if ( !$moduleAccessAllowed )
1284 {
1285 if ( isset( $availableViewsInModule[$functionName][ 'default_navigation_part' ] ) )
1286 {
1287 $defaultNavigationPart = $availableViewsInModule[$functionName][ 'default_navigation_part' ];
1288 }
1289
1290 if ( isset( $accessList ) )
1291 $moduleResult = $this->module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel', array( 'AccessList' => $accessList ) );
1292 else
1293 $moduleResult = $this->module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );
1294
1295 if ( isset( $defaultNavigationPart ) )
1296 {
1297 $moduleResult['navigation_part'] = $defaultNavigationPart;
1298 unset( $defaultNavigationPart );
1299 }
1300 }
1301 else
1302 {
1303 if ( !isset( $userParameters ) )
1304 {
1305 $userParameters = false;
1306 }
1307
1308 // Check if we should switch access mode (http/https) for this module view.
1309 eZSSLZone::checkModuleView( $this->module->attribute( 'name' ), $functionName );
1310
1311 $moduleResult = $this->module->run( $functionName, $params, false, $userParameters );
1312
1313 if ( $this->module->exitStatus() == eZModule::STATUS_FAILED && $moduleResult == null )
1314 $moduleResult = $this->module->handleError(
1315 eZError::KERNEL_MODULE_VIEW_NOT_FOUND,
1316 'kernel',
1317 array(
1318 'module' => $moduleName,
1319 'view' => $functionName
1320 )
1321 );
1322 }
1323 }
1324 }
1325 else if ( $moduleCheck['result'] )
1326 {
1327 eZDebug::writeError( "Undefined module: $moduleName", "index" );
1328 $this->module = new eZModule( "", "", $moduleName );
1329 $GLOBALS['eZRequestedModule'] = $this->module;
1330 $moduleResult = $this->module->handleError( eZError::KERNEL_MODULE_NOT_FOUND, 'kernel', array( 'module' => $moduleName ) );
1331 }
1332 else
1333 {
1334 if ( $moduleCheck['view_checked'] )
1335 eZDebug::writeError( "View '" . $moduleCheck['view'] . "' in module '" . $moduleCheck['module'] . "' is disabled", "index" );
1336 else
1337 eZDebug::writeError( "Module '" . $moduleCheck['module'] . "' is disabled", "index" );
1338 $GLOBALS['eZRequestedModule'] = $this->module = new eZModule( "", "", $moduleCheck['module'] );
1339 $moduleResult = $this->module->handleError( eZError::KERNEL_MODULE_DISABLED, 'kernel', array( 'check' => $moduleCheck ) );
1340 }
1341 $this->siteBasics['module-run-required'] = false;
1342 if ( isset( $moduleResult['rerun_uri'] ) )
1343 {
1344 $this->uri = eZURI::instance( $moduleResult['rerun_uri'] );
1345 $this->siteBasics['module-run-required'] = true;
1346 }
1347 else if ( $this->module->exitStatus() == eZModule::STATUS_RERUN )
1348 {
1349 eZDebug::writeError( 'No rerun URI specified on eZModule::STATUS_RERUN, cannot set URI', 'index.php' );
1350 }
1351
1352 if ( is_array( $moduleResult ) )
1353 {
1354 if ( isset( $moduleResult["pagelayout"] ) )
1355 {
1356 $this->siteBasics['show-page-layout'] = $moduleResult["pagelayout"];
1357 $GLOBALS['eZCustomPageLayout'] = $moduleResult["pagelayout"];
1358 }
1359 if ( isset( $moduleResult["external_css"] ) )
1360 $this->siteBasics['external-css'] = $moduleResult["external_css"];
1361 }
1362 }
1363
1364 return $moduleResult;
1365 }
1366
1374 protected function getPolicyCheckViewMap( array $policyCheckOmitList )
1375 {
1376 if ( $this->policyCheckViewMap !== null )
1377 return $this->policyCheckViewMap;
1378
1379 $this->policyCheckViewMap = array();
1380 foreach ( $policyCheckOmitList as $omitItem )
1381 {
1382 $items = explode( '/', $omitItem );
1383 if ( count( $items ) > 1 )
1384 {
1385 $module = $items[0];
1386 if ( !isset( $this->policyCheckViewMap[$module] ) )
1387 $this->policyCheckViewMap[$module] = array();
1388 $this->policyCheckViewMap[$module][$items[1]] = true;
1389 }
1390 }
1391
1392 return $this->policyCheckViewMap;
1393 }
1394
1398 protected function redirect()
1399 {
1400 $GLOBALS['eZRedirection'] = true;
1401 $ini = eZINI::instance();
1402 $automaticRedirect = true;
1403
1404 if ( $GLOBALS['eZDebugAllowed'] && ( $redirUri = $ini->variable( 'DebugSettings', 'DebugRedirection' ) ) !== 'disabled' )
1405 {
1406 if ( $redirUri == "enabled" )
1407 {
1408 $automaticRedirect = false;
1409 }
1410 else
1411 {
1412 $uri = eZURI::instance( eZSys::requestURI() );
1413 $uri->toBeginning();
1414 foreach ( $ini->variableArray( "DebugSettings", "DebugRedirection" ) as $redirUri )
1415 {
1416 $redirUri = new eZURI( $redirUri );
1417 if ( $redirUri->matchBase( $uri ) )
1418 {
1419 $automaticRedirect = false;
1420 break;
1421 }
1422 }
1423 }
1424 }
1425
1426 $redirectURI = eZSys::indexDir();
1427
1428 $moduleRedirectUri = $this->module->redirectURI();
1429 if ( $ini->variable( 'URLTranslator', 'Translation' ) === 'enabled' &&
1430 eZURLAliasML::urlTranslationEnabledByUri( new eZURI( $moduleRedirectUri ) ) )
1431 {
1432 $translatedModuleRedirectUri = $moduleRedirectUri;
1433 if ( eZURLAliasML::translate( $translatedModuleRedirectUri, true ) )
1434 {
1435 $moduleRedirectUri = $translatedModuleRedirectUri;
1436 if ( strlen( $moduleRedirectUri ) > 0 && $moduleRedirectUri[0] !== '/' )
1437 $moduleRedirectUri = '/' . $moduleRedirectUri;
1438 }
1439 }
1440
1441 if ( preg_match( '#^(\w+:)|^//#', $moduleRedirectUri ) )
1442 {
1443 $redirectURI = $moduleRedirectUri;
1444 }
1445 else
1446 {
1447 $leftSlash = strlen( $redirectURI ) > 0 && $redirectURI[strlen( $redirectURI ) - 1] === '/';
1448 $rightSlash = strlen( $moduleRedirectUri ) > 0 && $moduleRedirectUri[0] === '/';
1449
1450 if ( !$leftSlash && !$rightSlash ) // Both are without a slash, so add one
1451 $moduleRedirectUri = '/' . $moduleRedirectUri;
1452 else if ( $leftSlash && $rightSlash ) // Both are with a slash, so we remove one
1453 $moduleRedirectUri = substr( $moduleRedirectUri, 1 );
1454
1455 // In some cases $moduleRedirectUri can already contain $redirectURI (including the siteaccess).
1456 if ( !empty( $redirectURI ) && strpos( $moduleRedirectUri, $redirectURI ) === 0 )
1457 {
1458 $redirectURI = $moduleRedirectUri;
1459 }
1460 else
1461 {
1462 $redirectURI .= $moduleRedirectUri;
1463 }
1464 }
1465
1466 // After the module redirect url is completed, add the queryString params so they carry over the redirect operation
1467 $redirectURI .= eZSys::queryString();
1468
1469 if ( $ini->variable( 'ContentSettings', 'StaticCache' ) == 'enabled' )
1470 {
1471 $staticCacheHandlerClassName = $ini->variable( 'ContentSettings', 'StaticCacheHandler' );
1472 $staticCacheHandlerClassName::executeActions();
1473 }
1474
1475 eZDB::checkTransactionCounter();
1476
1477 if ( !$automaticRedirect )
1478 {
1479 // Make sure any errors or warnings are reported
1480 if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) === 'enabled' )
1481 {
1482 if ( isset( $GLOBALS['eZDebugError'] ) && $GLOBALS['eZDebugError'] )
1483 {
1484 eZAppendWarningItem(
1485 array(
1486 'error' => array(
1487 'type' => 'error',
1488 'number' => 1,
1489 'count' => $GLOBALS['eZDebugErrorCount']
1490 ),
1491 'identifier' => 'ezdebug-first-error',
1492 'text' => ezpI18n::tr( 'index.php', 'Some errors occurred, see debug for more information.' )
1493 )
1494 );
1495 }
1496
1497 if ( isset( $GLOBALS['eZDebugWarning'] ) && $GLOBALS['eZDebugWarning'] )
1498 {
1499 eZAppendWarningItem(
1500 array(
1501 'error' => array(
1502 'type' => 'warning',
1503 'number' => 1,
1504 'count' => $GLOBALS['eZDebugWarningCount']
1505 ),
1506 'identifier' => 'ezdebug-first-warning',
1507 'text' => ezpI18n::tr( 'index.php', 'Some general warnings occured, see debug for more information.' )
1508 )
1509 );
1510 }
1511 }
1512
1513 $tpl = eZTemplate::factory();
1514 $tpl->setVariable( 'site', $this->site );
1515 $tpl->setVariable( 'warning_list', !empty( $this->warningList ) ? $this->warningList : false );
1516 $tpl->setVariable( 'redirect_uri', eZURI::encodeURL( $redirectURI ) );
1517 $templateResult = $tpl->fetch( 'design:redirect.tpl' );
1518
1519 eZDebug::addTimingPoint( "Script end" );
1520
1521 eZDisplayResult( $templateResult );
1522 eZExecution::cleanExit();
1523 }
1524
1525 return eZHTTPTool::redirect( $redirectURI, array(), $this->module->redirectStatus(), true, true );
1526 }
1527
1532 protected function sessionInit()
1533 {
1534 if ( !isset( $this->settings['session'] ) || !$this->settings['session']['configured'] )
1535 {
1536 // running without Symfony2 or session is not configured
1537 // we keep the historic behaviour
1538 $ini = eZINI::instance();
1539 if ( $ini->variable( 'Session', 'ForceStart' ) === 'enabled' )
1540 eZSession::start();
1541 else
1542 eZSession::lazyStart();
1543 }
1544 else
1545 {
1546 $sfHandler = new ezpSessionHandlerSymfony(
1547 $this->settings['session']['has_previous']
1548 || $this->settings['session']['started']
1549 );
1550 $sfHandler->setStorage( $this->settings['session']['storage'] );
1551 eZSession::init(
1552 $this->settings['session']['name'],
1553 $this->settings['session']['started'],
1554 $this->settings['session']['namespace'],
1555 $sfHandler
1556 );
1557 }
1558
1559 // let session specify if db is required
1560 $this->siteBasics['db-required'] = eZSession::getHandlerInstance()->dbRequired();
1561 }
1562
1563 protected function requestInit()
1564 {
1565 if ( $this->isInitialized )
1566 return;
1567
1568 eZExecution::setCleanExit( false );
1569 $scriptStartTime = microtime( true );
1570
1571 $GLOBALS['eZRedirection'] = false;
1572 $this->access = eZSiteAccess::current();
1573
1574 eZDebug::setScriptStart( $scriptStartTime );
1575
1576 eZDebug::addTimingPoint( "Script start" );
1577
1578 $this->uri = eZURI::instance( eZSys::requestURI() );
1579 $GLOBALS['eZRequestedURI'] = $this->uri;
1580
1581 // Be able to do general events early in process
1582 ezpEvent::getInstance()->notify( 'request/preinput', array( $this->uri ) );
1583
1584 // Initialize module loading
1585 $this->siteBasics['module-repositories'] = eZModule::activeModuleRepositories();
1586 eZModule::setGlobalPathList( $this->siteBasics['module-repositories'] );
1587
1588 // make sure we get a new $ini instance now that it has been reset
1589 $ini = eZINI::instance();
1590
1591 // pre check, setup wizard related so needs to be before session/db init
1592 // TODO: Move validity check in the constructor? Setup is not meant to be launched at each (sub)request is it?
1593 if ( $ini->variable( 'SiteAccessSettings', 'CheckValidity' ) === 'true' )
1594 {
1595 $this->check = array( 'module' => 'setup', 'function' => 'init' );
1596 // Turn off some features that won't bee needed yet
1597 $this->siteBasics['policy-check-omit-list'][] = 'setup';
1598 $this->siteBasics['show-page-layout'] = $ini->variable( 'SetupSettings', 'PageLayout' );
1599 $this->siteBasics['validity-check-required'] = true;
1600 $this->siteBasics['session-required'] = $this->siteBasics['user-object-required'] = false;
1601 $this->siteBasics['db-required'] = $this->siteBasics['no-cache-adviced'] = $this->siteBasics['url-translator-allowed'] = false;
1602 $this->siteBasics['site-design-override'] = $ini->variable( 'SetupSettings', 'OverrideSiteDesign' );
1603 $this->access = eZSiteAccess::change( array( 'name' => 'setup', 'type' => eZSiteAccess::TYPE_URI ) );
1604 eZTranslatorManager::enableDynamicTranslations();
1605 }
1606
1607 if ( $this->siteBasics['session-required'] )
1608 {
1609 // Check if this should be run in a cronjob
1610 if ( $ini->variable( 'Session', 'BasketCleanup' ) !== 'cronjob' )
1611 {
1612 eZSession::addCallback(
1613 'destroy_pre',
1614 function ( eZDBInterface $db, $key, $escapedKey )
1615 {
1616 $basket = eZBasket::fetch( $key );
1617 if ( $basket instanceof eZBasket )
1618 $basket->remove();
1619 }
1620 );
1621 eZSession::addCallback(
1622 'gc_pre',
1623 function ( eZDBInterface $db, $time )
1624 {
1625 eZBasket::cleanupExpired( $time );
1626 }
1627 );
1628
1629 eZSession::addCallback(
1630 'cleanup_pre',
1631 function ( eZDBInterface $db )
1632 {
1633 eZBasket::cleanup();
1634 }
1635 );
1636 }
1637
1638 // addCallBack to update session id for shop basket on session regenerate
1639 eZSession::addCallback(
1640 'regenerate_post',
1641 function ( eZDBInterface $db, $escNewKey, $escOldKey )
1642 {
1643 $db->query( "UPDATE ezbasket SET session_id='{$escNewKey}' WHERE session_id='{$escOldKey}'" );
1644 }
1645 );
1646
1647 // TODO: Session starting should be made only once in the constructor
1648 $this->sessionInit();
1649 }
1650
1651 // if $this->siteBasics['db-required'], open a db connection and check that db is connected
1652 if ( $this->siteBasics['db-required'] && !eZDB::instance()->isConnected() )
1653 {
1654 $this->warningList[] = array(
1655 'error' => array(
1656 'type' => 'kernel',
1657 'number' => eZError::KERNEL_NO_DB_CONNECTION
1658 ),
1659 'text' => 'No database connection could be made, the system might not behave properly.'
1660 );
1661 }
1662
1663 // pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init
1664 if ( !isset( $this->check ) )
1665 {
1666 $this->check = eZUserLoginHandler::preCheck( $this->siteBasics, $this->uri );
1667 }
1668
1669 ezpEvent::getInstance()->notify( 'request/input', array( $this->uri ) );
1670
1671 // Initialize with locale settings
1672 // TODO: Move to constructor? Is it relevant to init the locale/charset for each (sub)requests?
1673 $this->languageCode = eZLocale::instance()->httpLocaleCode();
1674 $phpLocale = trim( $ini->variable( 'RegionalSettings', 'SystemLocale' ) );
1675 if ( $phpLocale != '' )
1676 {
1677 setlocale( LC_ALL, explode( ',', $phpLocale ) );
1678 }
1679
1680 $this->httpCharset = eZTextCodec::httpCharset();
1681
1682 // TODO: are these parameters supposed to vary across potential sub-requests?
1683 $this->site = array(
1684 'title' => $ini->variable( 'SiteSettings', 'SiteName' ),
1685 'design' => $ini->variable( 'DesignSettings', 'SiteDesign' ),
1686 'http_equiv' => array(
1687 'Content-Type' => 'text/html; charset=' . $this->httpCharset,
1688 'Content-language' => $this->languageCode
1689 )
1690 );
1691
1692 // Read role settings
1693 $this->siteBasics['policy-check-omit-list'] = array_merge(
1694 $this->siteBasics['policy-check-omit-list'],
1695 $ini->variable( 'RoleSettings', 'PolicyOmitList' )
1696 );
1697
1698 $this->isInitialized = true;
1699
1704 eZDebug::checkDebugByUser();
1705 }
1706
1710 public function runCallback( \Closure $callback, $postReinitialize = true )
1711 {
1712 $this->requestInit();
1713
1714 try
1715 {
1716 $return = $callback();
1717 }
1718 catch ( Exception $e )
1719 {
1720 $this->shutdown( $postReinitialize );
1721 throw $e;
1722 }
1723
1724 $this->shutdown( $postReinitialize );
1725
1726 return $return;
1727 }
1728
1732 protected function shutdown( $reInitialize = true )
1733 {
1734 eZExecution::cleanup();
1735 eZExecution::setCleanExit();
1736 eZExpiryHandler::shutdown();
1737 if ( $reInitialize )
1738 $this->isInitialized = false;
1739 }
1740
1746 public static function setUseExceptions( $useExceptions )
1747 {
1748 eZModule::$useExceptions = (bool)$useExceptions;
1749 }
1750
1754 public function reInitialize()
1755 {
1756 $this->isInitialized = false;
1757 }
1758
1765 public function hasServiceContainer()
1766 {
1767 return isset( $this->settings['service-container'] );
1768 }
1769
1776 public function getServiceContainer()
1777 {
1778 return $this->settings['service-container'];
1779 }
1780
1786 public function setUsePagelayout( $usePagelayout )
1787 {
1788 $this->siteBasics['show-page-layout'] = (bool)$usePagelayout;
1789 }
1790 }
$single_module
$single_module
Definition: activate.php:33
$i
$i
Definition: admin/adlist.php:91
$items
$items
Definition: admin/orderview.php:211
$modules
foreach( $categories as $category) $modules
Definition: bugedit.php:496
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
eZHTTPTool\removeVariable
static & removeVariable( $url, $variable, $value="")
Definition: ezhttptool.php:144
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZMenuBox\createBox
static createBox( $ModuleName, $module_dir, $place, $SiteDesign, &$menuItems, $print=true, $templatefile=false, $phpfile=false, $ignore_status=false, $allow_module_template=false, $settingsModuleName=false)
Definition: ezmenubox.php:61
eZModuleHandler\moveDown
static moveDown(&$modules, $module, &$moved_module)
Definition: ezmodulehandler.php:274
eZModuleHandler\toggle
static toggle( $module)
Definition: ezmodulehandler.php:193
eZModuleHandler\active
static active()
Definition: ezmodulehandler.php:139
eZModuleHandler\moveUp
static moveUp(&$modules, $module, &$moved_module)
Definition: ezmodulehandler.php:235
eZModule
Definition: ezmodule.php:54
eZModule\$useExceptions
static $useExceptions
Definition: ezmodule.php:258
eZModule\exists
exists( $name)
Definition: ezmodule.php:214
eZPreferences
Definition: ezpreferences.php:62
eZPublishSDK\EDITION
const EDITION
Definition: version.php:24
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\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
eZTemplate
Definition: eztemplate.php:107
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
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$t
foreach( $Modules as $module) if(isset( $ItemInsert)) $t
Definition: classes/admin/linklist.php:168
$preferences
$preferences
Definition: classes/admin/linklist.php:186
$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
ezpbKernelAdmin
Definition: ezpbkerneladmin.php:17
ezpbKernelAdmin\$site
$site
Definition: ezpbkerneladmin.php:78
ezpbKernelAdmin\run
run()
Definition: ezpbkerneladmin.php:312
ezpbKernelAdmin\requestInit
requestInit()
Definition: ezpbkerneladmin.php:1563
ezpbKernelAdmin\$access
$access
Definition: ezpbkerneladmin.php:63
ezpbKernelAdmin\$mobileDeviceDetect
$mobileDeviceDetect
Definition: ezpbkerneladmin.php:21
ezpbKernelAdmin\$module
$module
Definition: ezpbkerneladmin.php:31
ezpbKernelAdmin\reInitialize
reInitialize()
Definition: ezpbkerneladmin.php:1754
ezpbKernelAdmin\$settings
$settings
Definition: ezpbkerneladmin.php:107
ezpbKernelAdmin\$oldURI
$oldURI
Definition: ezpbkerneladmin.php:51
ezpbKernelAdmin\setUsePagelayout
setUsePagelayout( $usePagelayout)
Definition: ezpbkerneladmin.php:1786
ezpbKernelAdmin\hasServiceContainer
hasServiceContainer()
Definition: ezpbkerneladmin.php:1765
ezpbKernelAdmin\sessionInit
sessionInit()
Definition: ezpbkerneladmin.php:1532
ezpbKernelAdmin\setupFatalErrorHandler
setupFatalErrorHandler()
Definition: ezpbkerneladmin.php:277
ezpbKernelAdmin\$siteBasics
$siteBasics
Definition: ezpbkerneladmin.php:41
ezpbKernelAdmin\getPolicyCheckViewMap
getPolicyCheckViewMap(array $policyCheckOmitList)
Definition: ezpbkerneladmin.php:1374
ezpbKernelAdmin\shutdown
shutdown( $reInitialize=true)
Definition: ezpbkerneladmin.php:1732
ezpbKernelAdmin\$completeRequestedURI
$completeRequestedURI
Definition: ezpbkerneladmin.php:56
ezpbKernelAdmin\redirect
redirect()
Definition: ezpbkerneladmin.php:1398
ezpbKernelAdmin\$policyCheckViewMap
$policyCheckViewMap
Definition: ezpbkerneladmin.php:26
ezpbKernelAdmin\$httpCharset
$httpCharset
Definition: ezpbkerneladmin.php:90
ezpbKernelAdmin\$isInitialized
$isInitialized
Definition: ezpbkerneladmin.php:97
ezpbKernelAdmin\$check
$check
Definition: ezpbkerneladmin.php:73
ezpbKernelAdmin\setUseExceptions
static setUseExceptions( $useExceptions)
Definition: ezpbkerneladmin.php:1746
ezpbKernelAdmin\$warningList
$warningList
Definition: ezpbkerneladmin.php:36
ezpbKernelAdmin\$actualRequestedURI
$actualRequestedURI
Definition: ezpbkerneladmin.php:46
ezpbKernelAdmin\$uri
$uri
Definition: ezpbkerneladmin.php:68
ezpbKernelAdmin\runCallback
runCallback(\Closure $callback, $postReinitialize=true)
Definition: ezpbkerneladmin.php:1710
ezpbKernelAdmin\$languageCode
$languageCode
Definition: ezpbkerneladmin.php:84
ezpbKernelAdmin\getServiceContainer
getServiceContainer()
Definition: ezpbkerneladmin.php:1776
ezpbKernelAdmin\dispatchLoop
dispatchLoop()
Definition: ezpbkerneladmin.php:1089
ezpbKernelAdmin\__construct
__construct(array $settings=array())
Definition: ezpbkerneladmin.php:112
ezpbKernelResult
Definition: ezpbKernelResult.php:15
$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
$menuItems
$menuItems
Definition: ezabout/admin/menubox.php:31
$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
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$index
$index
Definition: ezforum/user/messageedit.php:36
$content
$content
Definition: ezimagecatalogue/admin/filedownload.php:53
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$moduleArray
$moduleArray
Definition: ezsearch/user/search.php:36
exit
exit
Definition: folder.php:81
$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
$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+.