| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // SOFTWARE NAME: eZ publish 4 // SOFTWARE RELEASE: 3.9.0 5 // BUILD VERSION: 17785 6 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 7 // SOFTWARE LICENSE: GNU General Public License v2.0 8 // NOTICE: > 9 // This program is free software; you can redistribute it and/or 10 // modify it under the terms of version 2.0 of the GNU General 11 // Public License as published by the Free Software Foundation. 12 // 13 // This program is distributed in the hope that it will be useful, 14 // but WITHOUT ANY WARRANTY; without even the implied warranty of 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 // GNU General Public License for more details. 17 // 18 // You should have received a copy of version 2.0 of the GNU General 19 // Public License along with this program; if not, write to the Free 20 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 21 // MA 02110-1301, USA. 22 // 23 // 24 25 // if ( file_exists( 'ezp.xt' ) ) 26 // { 27 // $fd = fopen( 'ezp.xt', 'w' ); fclose( $fd ); 28 // } 29 // xdebug_start_trace( 'ezp' ); 30 31 if ( version_compare( phpversion(), '5.0' ) >= 0 ) 32 { 33 print( "<h1>Unsupported PHP version " . phpversion() . "</h1>" ); 34 print( "<p>eZ publish 3.x does not run with PHP 5.</p>". 35 "<p>For more information about supported software please visit ". 36 "<a href=\"http://ez.no/download/ez_publish\" >eZ publish download page</a></p>" ); 37 exit; 38 } 39 40 ignore_user_abort( true ); 41 require 'lib/compat.php'; 42 43 $memLimit = ini_get( 'memory_limit' ); 44 if ($memLimit != '') 45 { 46 switch ( $memLimit{strlen( $memLimit ) - 1} ) 47 { 48 case 'G': 49 $memLimit *= 1024; 50 case 'M': 51 $memLimit *= 1024; 52 case 'K': 53 $memLimit *= 1024; 54 } 55 if ( $memLimit != -1 && $memLimit < 44040192) /* 42*1024*1024 */ 56 { 57 @ini_set( 'memory_limit', '42M' ); 58 } 59 } 60 61 $scriptStartTime = microtime(); 62 ob_start(); 63 64 $use_external_css = true; 65 $show_page_layout = true; 66 $moduleRunRequired = true; 67 $policyCheckRequired = true; 68 $urlTranslatorAllowed = true; 69 $validityCheckRequired = false; 70 $userObjectRequired = true; 71 $sessionRequired = true; 72 $dbRequired = true; 73 $noCacheAdviced = false; 74 75 $siteDesignOverride = false; 76 77 // List of module names which will skip policy checking 78 $policyCheckOmitList = array(); 79 80 // List of directories to search for modules 81 $moduleRepositories = array(); 82 83 $siteBasics = array(); 84 $siteBasics['external-css'] =& $use_external_css; 85 $siteBasics['show-page-layout'] =& $show_page_layout; 86 $siteBasics['module-run-required'] =& $moduleRunRequired; 87 $siteBasics['policy-check-required'] =& $policyCheckRequired; 88 $siteBasics['policy-check-omit-list'] =& $policyCheckOmitList; 89 $siteBasics['url-translator-allowed'] =& $urlTranslatorAllowed; 90 $siteBasics['validity-check-required'] =& $validityCheckRequired; 91 $siteBasics['user-object-required'] =& $userObjectRequired; 92 $siteBasics['session-required'] =& $sessionRequired; 93 $siteBasics['db-required'] =& $dbRequired; 94 $siteBasics['no-cache-adviced'] =& $noCacheAdviced; 95 $siteBasics['site-design-override'] =& $siteDesignOverride; 96 97 $siteBasics['module-repositories'] =& $moduleRepositories; 98 99 $GLOBALS['eZSiteBasics'] =& $siteBasics; 100 101 $GLOBALS['eZRedirection'] = false; 102 103 error_reporting ( E_ALL ); 104 105 // include standard libs 106 include_once ( "lib/ezutils/classes/ezdebug.php" ); 107 include_once ( "lib/ezutils/classes/ezini.php" ); 108 include_once ( "lib/ezutils/classes/ezdebugsetting.php" ); 109 110 $debugINI =& eZINI::instance( 'debug.ini' ); 111 eZDebugSetting::setDebugINI( $debugINI ); 112 113 114 /*! 115 Reads settings from site.ini and passes them to eZDebug. 116 */ 117 function eZUpdateDebugSettings() 118 { 119 $ini =& eZINI::instance(); 120 121 $settings = array(); 122 list( $settings['debug-enabled'], $settings['debug-by-ip'], $settings['log-only'], $settings['debug-by-user'], $settings['debug-ip-list'], $logList, $settings['debug-user-list'] ) = 123 $ini->variableMulti( 'DebugSettings', 124 array( 'DebugOutput', 'DebugByIP', 'DebugLogOnly', 'DebugByUser', 'DebugIPList', 'AlwaysLog', 'DebugUserIDList' ), 125 array( 'enabled', 'enabled', 'disabled', 'enabled' ) ); 126 $logMap = array( 'notice' => EZ_LEVEL_NOTICE, 127 'warning' => EZ_LEVEL_WARNING, 128 'error' => EZ_LEVEL_ERROR, 129 'debug' => EZ_LEVEL_DEBUG ); 130 $settings['always-log'] = array(); 131 foreach ( $logMap as $name => $level ) 132 { 133 $settings['always-log'][$level] = in_array( $name, $logList ); 134 } 135 eZDebug::updateSettings( $settings ); 136 } 137 138 /*! 139 Reads settings from i18n.ini and passes them to eZTextCodec. 140 */ 141 function eZUpdateTextCodecSettings() 142 { 143 $ini =& eZINI::instance( 'i18n.ini' ); 144 145 list( $i18nSettings['internal-charset'], $i18nSettings['http-charset'], $i18nSettings['mbstring-extension'] ) = 146 $ini->variableMulti( 'CharacterSettings', array( 'Charset', 'HTTPCharset', 'MBStringExtension' ), array( false, false, 'enabled' ) ); 147 148 include_once ( 'lib/ezi18n/classes/eztextcodec.php' ); 149 eZTextCodec::updateSettings( $i18nSettings ); 150 } 151 152 // Initialize text codec settings 153 eZUpdateTextCodecSettings(); 154 155 // Initialize debug settings. 156 eZUpdateDebugSettings(); 157 158 159 // Set the different permissions/settings. 160 $ini =& eZINI::instance(); 161 162 // Set correct site timezone 163 $timezone = $ini->variable( "TimeZoneSettings", "TimeZone"); 164 if ( $timezone ) 165 { 166 putenv( "TZ=$timezone" ); 167 } 168 169 170 list( $iniFilePermission, $iniDirPermission ) = 171 $ini->variableMulti( 'FileSettings', array( 'StorageFilePermissions', 'StorageDirPermissions' ) ); 172 173 $iniVarDirectory = eZSys::cacheDirectory() ; 174 175 // OPTIMIZATION: 176 // Sets permission array as global variable, this avoids the eZCodePage include 177 $GLOBALS['EZCODEPAGEPERMISSIONS'] = array( 'file_permission' => octdec( $iniFilePermission ), 178 'dir_permission' => octdec( $iniDirPermission ), 179 'var_directory' => $iniVarDirectory ); 180 181 // 182 $warningList = array(); 183 184 /*! 185 Appends a new warning item to the warning list. 186 \a $parameters must contain a \c error and \c text key. 187 */ 188 function eZAppendWarningItem( $parameters = array() ) 189 { 190 global $warningList; 191 $parameters = array_merge( array( 'error' => false, 192 'text' => false, 193 'identifier' => false ), 194 $parameters ); 195 $error = $parameters['error']; 196 $text = $parameters['text']; 197 $identifier = $parameters['identifier']; 198 $warningList[] = array( 'error' => $error, 199 'text' => $text, 200 'identifier' => $identifier ); 201 } 202 203 include_once ( 'lib/ezutils/classes/ezexecution.php' ); 204 205 function eZDBCleanup() 206 { 207 if ( class_exists( 'ezdb' ) 208 and eZDB::hasInstance() ) 209 { 210 $db =& eZDB::instance(); 211 $db->setIsSQLOutputEnabled( false ); 212 } 213 // session_write_close(); 214 } 215 216 function eZFatalError() 217 { 218 eZDebug::setHandleType( EZ_HANDLE_NONE ); 219 print( "<b>Fatal error</b>: eZ publish did not finish its request<br/>" ); 220 print( "<p>The execution of eZ publish was abruptly ended, the debug output is present below.</p>" ); 221 $templateResult = null; 222 eZDisplayResult( $templateResult ); 223 } 224 225 eZExecution::addCleanupHandler( 'eZDBCleanup' ); 226 eZExecution::addFatalErrorHandler( 'eZFatalError' ); 227 228 eZDebug::setScriptStart( $scriptStartTime ); 229 230 // Enable this line to get eZINI debug output 231 // eZINI::setIsDebugEnabled( true ); 232 // Enable this line to turn off ini caching 233 // eZINI::setIsCacheEnabled( false); 234 235 function eZDisplayDebug() 236 { 237 $ini =& eZINI::instance(); 238 239 if ( $ini->variable( 'DebugSettings', 'DebugOutput' ) != 'enabled' ) 240 return null; 241 242 $type = $ini->variable( "DebugSettings", "Debug" ); 243 eZDebug::setHandleType( EZ_HANDLE_NONE ); 244 if ( $type == "inline" or $type == "popup" ) 245 { 246 $as_html = true; 247 248 if ( $ini->variable( "DebugSettings", "DebugToolbar" ) == 'enabled' && $as_html == true && !$GLOBALS['eZRedirection'] ) 249 { 250 include_once ( 'kernel/common/template.php' ); 251 $tpl =& templateInit(); 252 $result = "<tr><td>" . $tpl->fetch( 'design:setup/debug_toolbar.tpl' ) . "</td></tr>"; 253 eZDebug::appendTopReport( "Debug toolbar", $result ); 254 } 255 256 include_once ( 'kernel/common/eztemplatesstatisticsreporter.php' ); 257 eZDebug::appendBottomReport( 'Template Usage Statistics', eZTemplatesStatisticsReporter::generateStatistics( $as_html ) ); 258 259 return eZDebug::printReport( $type == "popup", $as_html, true ); 260 } 261 return null; 262 } 263 264 /*! 265 \private 266 */ 267 function eZDisplayResult( $templateResult ) 268 { 269 if ( $templateResult !== null ) 270 { 271 $debugMarker = '<!--DEBUG_REPORT-->'; 272 $pos = strpos( $templateResult, $debugMarker ); 273 if ( $pos !== false ) 274 { 275 $debugMarkerLength = strlen( $debugMarker ); 276 echo substr( $templateResult, 0, $pos ); 277 eZDisplayDebug(); 278 echo substr( $templateResult, $pos + $debugMarkerLength ); 279 } 280 else 281 { 282 echo $templateResult, eZDisplayDebug(); 283 } 284 } 285 else 286 { 287 eZDisplayDebug(); 288 } 289 } 290 291 function fetchModule( &$uri, &$check, &$module, &$module_name, &$function_name, &$params ) 292 { 293 $module_name = $uri->element(); 294 if ( $check !== null and isset( $check["module"] ) ) 295 $module_name = $check["module"]; 296 297 // Try to fetch the module object 298 $module = eZModule::exists( $module_name ); 299 if ( get_class( $module ) != "ezmodule" ) 300 return false; 301 302 $uri->increase(); 303 $function_name = ""; 304 if ( !$module->singleFunction() ) 305 { 306 $function_name = $uri->element(); 307 $uri->increase(); 308 } 309 // Override it if required 310 if ( $check !== null and isset( $check["function"] ) ) 311 $function_name = $check["function"]; 312 313 $params = $uri->elements( false ); 314 return true; 315 } 316 317 include_once ( 'lib/ezi18n/classes/eztextcodec.php' ); 318 $httpCharset = eZTextCodec::httpCharset(); 319 include_once ( 'lib/ezlocale/classes/ezlocale.php' ); 320 $ini =& eZINI::instance(); 321 if ( $ini->variable( 'RegionalSettings', 'Debug' ) == 'enabled' ) 322 eZLocale::setIsDebugEnabled( true ); 323 324 include_once ( "lib/ezutils/classes/ezsys.php" ); 325 326 327 eZDebug::setHandleType( EZ_HANDLE_FROM_PHP ); 328 329 $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' ); 330 331 // Initialize basic settings, such as vhless dirs and separators 332 333 eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) == 'true' ); 334 335 eZSys::initIni( $ini ); 336 337 eZDebug::addTimingPoint( "Script start" ); 338 339 include_once ( "lib/ezutils/classes/ezuri.php" ); 340 341 $uri =& eZURI::instance( eZSys::requestURI() ); 342 $GLOBALS['eZRequestedURI'] =& $uri; 343 include_once ( "pre_check.php" ); 344 345 // Shall we start the eZ setup module? 346 //if ( $ini->variable( "SiteAccessSettings", "CheckValidity" ) == "true" ) 347 // include_once( "lib/ezsetup/classes/ezsetup.php" ); 348 349 include_once ( 'kernel/error/errors.php' ); 350 351 /* 352 print( "<pre>" ); 353 var_dump( $_SERVER ); 354 print( "</pre>" ); 355 print( "HTTP_HOST=" . eZSys::serverVariable( 'HTTP_HOST' ) . "<br/" ); 356 */ 357 358 // include ezsession override implementation 359 include_once ( "lib/ezutils/classes/ezsession.php" ); 360 361 362 // Check for extension 363 include_once ( 'lib/ezutils/classes/ezextension.php' ); 364 include_once ( 'kernel/common/ezincludefunctions.php' ); 365 eZExtension::activateExtensions( 'default' ); 366 // Extension check end 367 368 include_once ( "access.php" ); 369 370 $access = accessType( $uri, 371 eZSys::hostname(), 372 eZSys::serverPort(), 373 eZSys::indexFile() ); 374 $access = changeAccess( $access ); 375 eZDebugSetting::writeDebug( 'kernel-siteaccess', $access, 'current siteaccess' ); 376 $GLOBALS['eZCurrentAccess'] =& $access; 377 378 // Check for activating Debug by user ID (Final checking. The first was in eZDebug::updateSettings()) 379 eZDebug::checkDebugByUser(); 380 381 // Check for siteaccess extension 382 eZExtension::activateExtensions( 'access' ); 383 // Siteaccess extension check end 384 385 // Make sure template.ini reloads its cache incase 386 // siteaccess or extensions override it 387 $tplINI =& eZINI::instance( 'template.ini' ); 388 $tplINI->loadCache(); 389 390 $check = eZHandlePreChecks( $siteBasics, $uri ); 391 392 include_once ( 'kernel/common/i18n.php' ); 393 394 if ( $sessionRequired ) 395 { 396 $dbRequired = true; 397 } 398 399 $db = false; 400 if ( $dbRequired ) 401 { 402 include_once ( 'lib/ezdb/classes/ezdb.php' ); 403 $db =& eZDB::instance(); 404 if ( $sessionRequired and 405 $db->isConnected() ) 406 { 407 eZSessionStart(); 408 } 409 410 if ( !$db->isConnected() ) 411 $warningList[] = array( 'error' => array( 'type' => 'kernel', 412 'number' => EZ_ERROR_KERNEL_NO_DB_CONNECTION ), 413 'text' => 'No database connection could be made, the system might not behave properly.' ); 414 } 415 416 // Initialize with locale settings 417 include_once ( "lib/ezlocale/classes/ezlocale.php" ); 418 $locale =& eZLocale::instance(); 419 $languageCode = $locale->httpLocaleCode(); 420 $phpLocale = trim( $ini->variable( 'RegionalSettings', 'SystemLocale' ) ); 421 if ( $phpLocale != '' ) 422 { 423 setlocale( LC_ALL, explode( ',', $phpLocale ) ); 424 } 425 426 // send header information 427 $headerList = array( 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 428 'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT', 429 'Cache-Control' => 'no-cache, must-revalidate', 430 'Pragma' => 'no-cache', 431 'X-Powered-By' => 'eZ publish', 432 'Content-Type' => 'text/html; charset=' . $httpCharset, 433 'Served-by' => $_SERVER["SERVER_NAME"], 434 'Content-language' => $languageCode ); 435 436 $site = array( 'title' => $ini->variable( 'SiteSettings', 'SiteName' ), 437 'design' => $ini->variable( 'DesignSettings', 'SiteDesign' ), 438 'http_equiv' => array( 'Content-Type' => 'text/html; charset=' . $httpCharset, 439 'Content-language' => $languageCode ) ); 440 441 442 include_once ( 'kernel/classes/ezhttpheader.php' ); 443 $headerOverrideArray = eZHTTPHeader::headerOverrideArray( $uri ); 444 445 $headerList = array_merge( $headerList, $headerOverrideArray ); 446 447 foreach( $headerList as $key => $value ) 448 { 449 header( $key . ': ' . $value ); 450 } 451 452 include_once ( 'kernel/classes/ezsection.php' ); 453 eZSection::initGlobalID(); 454 455 // Read role settings 456 $globalPolicyCheckOmitList = $ini->variable( 'RoleSettings', 'PolicyOmitList' ); 457 $policyCheckOmitList = array_merge( $policyCheckOmitList, $globalPolicyCheckOmitList ); 458 $policyCheckViewMap = array(); 459 foreach ( $policyCheckOmitList as $omitItem ) 460 { 461 $items = explode( '/', $omitItem ); 462 if ( count( $items ) > 1 ) 463 { 464 $module = $items[0]; 465 $view = $items[1]; 466 if ( !isset( $policyCheckViewMap[$module] ) ) 467 $policyCheckViewMap[$module] = array(); 468 $policyCheckViewMap[$module][] = $view; 469 } 470 } 471 472 // Initialize module loading 473 include_once ( "lib/ezutils/classes/ezmodule.php" ); 474 475 $moduleINI =& eZINI::instance( 'module.ini' ); 476 $globalModuleRepositories = $moduleINI->variable( 'ModuleSettings', 'ModuleRepositories' ); 477 $extensionRepositories = $moduleINI->variable( 'ModuleSettings', 'ExtensionRepositories' ); 478 $extensionDirectory = eZExtension::baseDirectory(); 479 $activeExtensions = eZExtension::activeExtensions(); 480 $globalExtensionRepositories = array(); 481 foreach ( $extensionRepositories as $extensionRepository ) 482 { 483 $extPath = $extensionDirectory . '/' . $extensionRepository; 484 $modulePath = $extPath . '/modules'; 485 if ( file_exists( $modulePath ) ) 486 { 487 $globalExtensionRepositories[] = $modulePath; 488 } 489 else if ( !file_exists( $extPath ) ) 490 { 491 eZDebug::writeWarning( "Extension '$extensionRepository' was reported to have modules but the extension itself does not exist.\n" . 492 "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions.\n" . 493 "You should probably remove this extension from the list." ); 494 } 495 else if ( !in_array( $extensionRepository, $activeExtensions ) ) 496 { 497 eZDebug::writeWarning( "Extension '$extensionRepository' was reported to have modules but has not yet been activated.\n" . 498 "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions\n" . 499 "or make sure it is activated in the setting ExtensionSettings/ActiveExtensions in site.ini." ); 500 } 501 else 502 { 503 eZDebug::writeWarning( "Extension '$extensionRepository' does not have the subdirectory 'modules' allthough it reported it had modules.\n" . 504 "Looked for directory '" . $modulePath . "'\n" . 505 "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extension." ); 506 } 507 } 508 $moduleRepositories = array_merge( $moduleRepositories, $globalModuleRepositories, $globalExtensionRepositories ); 509 eZModule::setGlobalPathList( $moduleRepositories ); 510 511 include_once ( 'kernel/classes/eznavigationpart.php' ); 512 513 // Check if this should be run in a cronjob 514 $useCronjob = $ini->variable( 'Session', 'BasketCleanup' ) == 'cronjob'; 515 if ( !$useCronjob ) 516 { 517 // Functions for session to make sure baskets are cleaned up 518 function eZSessionBasketDestroy( &$db, $key, $escapedKey ) 519 { 520 include_once ( 'kernel/classes/ezbasket.php' ); 521 $basket =& eZBasket::fetch( $key ); 522 if ( is_object( $basket ) ) 523 $basket->remove(); 524 } 525 526 function eZSessionBasketGarbageCollector( &$db, $time ) 527 { 528 include_once ( 'kernel/classes/ezbasket.php' ); 529 eZBasket::cleanupExpired( $time ); 530 } 531 532 function eZSessionBasketEmpty( &$db ) 533 { 534 include_once ( 'kernel/classes/ezbasket.php' ); 535 eZBasket::cleanup(); 536 } 537 538 // Fill in hooks 539 $GLOBALS['eZSessionFunctions']['destroy_pre'] = array( 'eZSessionBasketDestroy' ); 540 $GLOBALS['eZSessionFunctions']['gc_pre'] = array( 'eZSessionBasketGarbageCollector' ); 541 $GLOBALS['eZSessionFunctions']['empty_pre'] = array( 'eZSessionBasketEmpty' ); 542 } 543 544 // Start the module loop 545 while ( $moduleRunRequired ) 546 { 547 $objectHasMovedError = false; 548 $objectHasMovedURI = false; 549 $actualRequestedURI = $uri->uriString(); 550 551 // Extract user specified parameters 552 $userParameters = $uri->userParameters(); 553 554 // Generate a URI which also includes the user parameters 555 $completeRequestedURI = $uri->originalURIString(); 556 557 // Check for URL translation 558 if ( $urlTranslatorAllowed and 559 $ini->variable( 'URLTranslator', 'Translation' ) == 'enabled' and 560 !$uri->isEmpty() ) 561 { 562 include_once ( 'kernel/classes/ezurlalias.php' ); 563 $translateResult = eZURLAlias::translate( $uri ); 564 565 566 if ( !$translateResult ) 567 { 568 $useWildcardTranslation = $ini->variable( 'URLTranslator', 'WildcardTranslation' ) == 'enabled'; 569 if ( $useWildcardTranslation ) 570 { 571 $translateResult =& eZURLAlias::translateByWildcard( $uri ); 572 } 573 } 574 575 // Check if the URL has moved 576 if ( get_class( $translateResult ) == 'ezurlalias' ) 577 { 578 $objectHasMovedURI =& $translateResult->attribute( 'source_url' ); 579 $objectHasMovedError = true; 580 } 581 else if ( is_string( $translateResult ) ) 582 { 583 $objectHasMovedURI = $translateResult; 584 $objectHasMovedError = true; 585 } 586 } 587 588 $moduleCheck = accessAllowed( $uri ); 589 if ( !$moduleCheck['result'] ) 590 { 591 if ( $ini->variable( "SiteSettings", "ErrorHandler" ) == "defaultpage" ) 592 { 593 $defaultPage = $ini->variable( "SiteSettings", "DefaultPage" ); 594 $uri->setURIString( $defaultPage ); 595 $moduleCheck['result'] = true; 596 } 597 } 598 599 include_once ( "lib/ezutils/classes/ezhttptool.php" ); 600 $http =& eZHTTPTool::instance(); 601 602 $displayMissingModule = false; 603 $oldURI = $uri; 604 605 if ( $uri->isEmpty() ) 606 { 607 $tmp_uri = new eZURI( $ini->variable( "SiteSettings", "IndexPage" ) ); 608 if ( !fetchModule( $tmp_uri, $check, $module, $module_name, $function_name, $params ) ) 609 $displayMissingModule = true; 610 } 611 else if ( !fetchModule( $uri, $check, $module, $module_name, $function_name, $params ) ) 612 { 613 if ( $ini->variable( "SiteSettings", "ErrorHandler" ) == "defaultpage" ) 614 { 615 $tmp_uri = new eZURI( $ini->variable( "SiteSettings", "DefaultPage" ) ); 616 if ( !fetchModule( $tmp_uri, $check, $module, $module_name, $function_name, $params ) ) 617 $displayMissingModule = true; 618 } 619 else 620 $displayMissingModule = true; 621 } 622 623 if ( !$displayMissingModule and 624 $moduleCheck['result'] and 625 get_class( $module ) == "ezmodule" ) 626 { 627 // Run the module/function 628 eZDebug::addTimingPoint( "Module start '" . $module->attribute( 'name' ) . "'" ); 629 630 $moduleAccessAllowed = true; 631 $omitPolicyCheck = true; 632 $runModuleView = true; 633 if ( $policyCheckRequired ) 634 { 635 $omitPolicyCheck = false; 636 $moduleName = $module->attribute( 'name' ); 637 $viewName = $function_name; 638 if ( in_array( $moduleName, $policyCheckOmitList ) ) 639 $omitPolicyCheck = true; 640 else if ( isset( $policyCheckViewMap[$moduleName] ) and 641 in_array( $viewName, $policyCheckViewMap[$moduleName] ) ) 642 $omitPolicyCheck = true; 643 } 644 if ( !$omitPolicyCheck ) 645 { 646 if( include_once ( "kernel/classes/datatypes/ezuser/ezuser.php" ) ) 647 { 648 $currentUser =& eZUser::currentUser(); 649 650 $availableViewsInModule = $module->attribute( 'views' ); 651 $runningFunctions = false; 652 if ( isset( $availableViewsInModule[$function_name][ 'functions' ] ) ) 653 $runningFunctions = $availableViewsInModule[$function_name][ 'functions' ]; 654 $siteAccessResult = $currentUser->hasAccessTo( 'user', 'login' ); 655 656 $hasAccessToSite = false; 657 if ( $siteAccessResult[ 'accessWord' ] == 'limited' ) 658 { 659 $policyChecked = false; 660 foreach ( array_keys( $siteAccessResult['policies'] ) as $key ) 661 { 662 $policy =& $siteAccessResult['policies'][$key]; 663 if ( isset( $policy['SiteAccess'] ) ) 664 { 665 $policyChecked = true; 666 $crc32AccessName = eZSys::ezcrc32( $access[ 'name' ] ); 667 eZDebugSetting::writeDebug( 'kernel-siteaccess', $policy['SiteAccess'], $crc32AccessName ); 668 if ( in_array( $crc32AccessName, $policy['SiteAccess'] ) ) 669 { 670 $hasAccessToSite = true; 671 break; 672 } 673 } 674 if ( $hasAccessToSite ) 675 break; 676 } 677 if ( !$policyChecked ) 678 $hasAccessToSite = true; 679 } 680 else if ( $siteAccessResult[ 'accessWord' ] == 'yes' ) 681 { 682 eZDebugSetting::writeDebug( 'kernel-siteaccess', "access is yes" ); 683 $hasAccessToSite = true; 684 } 685 else if ( $siteAccessResult['accessWord'] == 'no' ) 686 { 687 $accessList = $siteAccessResult['accessList']; 688 } 689 } 690 691 if ( $hasAccessToSite ) 692 { 693 $functionName = $runningFunctions[0]; 694 if ( $functionName ) 695 $accessResult = $currentUser->hasAccessTo( $module->attribute( 'name' ), $functionName ); 696 else 697 $accessResult = $currentUser->hasAccessTo( $module->attribute( 'name' ), false ); 698 699 if ( $accessResult['accessWord'] == 'limited' ) 700 { 701 $moduleName = $module->attribute( 'name' ); 702 $params['Limitation'] =& $accessResult['policies']; 703 $GLOBALS['ezpolicylimitation_list'][$moduleName][$functionName] =& $params['Limitation']; 704 } 705 if ( $accessResult['accessWord'] == 'no' ) 706 { 707 $accessList = $accessResult['accessList']; 708 $moduleAccessAllowed = false; 709 } 710 } 711 else 712 { 713 eZDebugSetting::writeDebug( 'kernel-siteaccess', $access, 'not able to get access to siteaccess' ); 714 $moduleAccessAllowed = false; 715 $requireUserLogin = ( $ini->variable( "SiteAccessSettings", "RequireUserLogin" ) == "true" ); 716 if ( $requireUserLogin ) 717 { 718 $module = eZModule::exists( 'user' ); 719 if ( get_class( $module ) == "ezmodule" ) 720 { 721 $moduleResult =& $module->run( 'login', array(), 722 array( 'SiteAccessAllowed' => false, 723 'SiteAccessName' => $access['name'] ) ); 724 $runModuleView = false; 725 } 726 } 727 } 728 } 729 730 $GLOBALS['eZRequestedModule'] =& $module; 731 732 if ( $runModuleView ) 733 { 734 if ( $objectHasMovedError == true ) 735 { 736 $moduleResult =& $module->handleError( EZ_ERROR_KERNEL_MOVED, 'kernel', array( 'new_location' => $objectHasMovedURI ) ); 737 } 738 else if ( !$moduleAccessAllowed ) 739 { 740 $availableViewsInModule = $module->attribute( 'views' ); 741 if ( isset( $availableViewsInModule[$function_name][ 'default_navigation_part' ] ) ) 742 { 743 $defaultNavigationPart = $availableViewsInModule[$function_name][ 'default_navigation_part' ]; 744 } 745 746 if ( isset( $accessList ) ) 747 $moduleResult =& $module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel', array( 'AccessList' => $accessList ) ); 748 else 749 $moduleResult =& $module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' ); 750 751 if ( isset( $defaultNavigationPart ) ) 752 { 753 $moduleResult['navigation_part'] = $defaultNavigationPart; 754 unset( $defaultNavigationPart ); 755 } 756 } 757 else 758 { 759 if ( !isset( $userParameters ) ) 760 { 761 $userParameters = false; 762 } 763 764 // Check if we should switch access mode (http/https) for this module view. 765 include_once ( 'kernel/classes/ezsslzone.php' ); 766 eZSSLZone::checkModuleView( $module->attribute( 'name' ), $function_name ); 767 768 $moduleResult =& $module->run( $function_name, $params, false, $userParameters ); 769 770 if ( $module->exitStatus() == EZ_MODULE_STATUS_FAILED and 771 $moduleResult == null ) 772 $moduleResult =& $module->handleError( EZ_ERROR_KERNEL_MODULE_VIEW_NOT_FOUND, 'kernel', array( 'module' => $module_name, 773 'view' => $function_name ) ); 774 } 775 } 776 } 777 else if ( $moduleCheck['result'] ) 778 { 779 eZDebug::writeError( "Undefined module: $module_name", "index" ); 780 $module = new eZModule( "", "", $module_name ); 781 $GLOBALS['eZRequestedModule'] =& $module; 782 $moduleResult =& $module->handleError( EZ_ERROR_KERNEL_MODULE_NOT_FOUND, 'kernel', array( 'module' => $module_name ) ); 783 } 784 else 785 { 786 if ( $moduleCheck['view_checked'] ) 787 eZDebug::writeError( "View '" . $moduleCheck['view'] . "' in module '" . $moduleCheck['module'] . "' is disabled", "index" ); 788 else 789 eZDebug::writeError( "Module '" . $moduleCheck['module'] . "' is disabled", "index" ); 790 $module = new eZModule( "", "", $moduleCheck['module'] ); 791 $GLOBALS['eZRequestedModule'] =& $module; 792 $moduleResult =& $module->handleError( EZ_ERROR_KERNEL_MODULE_DISABLED, 'kernel', array( 'check' => $moduleCheck ) ); 793 } 794 $moduleRunRequired = false; 795 if ( $module->exitStatus() == EZ_MODULE_STATUS_RERUN ) 796 { 797 if ( isset( $moduleResult['rerun_uri'] ) ) 798 { 799 $uri = & eZURI::instance( $moduleResult['rerun_uri'] ); 800 $moduleRunRequired = true; 801 } 802 else 803 eZDebug::writeError( 'No rerun URI specified, cannot continue', 'index.php' ); 804 } 805 806 if ( is_array( $moduleResult ) ) 807 { 808 if ( isset( $moduleResult["pagelayout"] ) ) 809 { 810 $show_page_layout =& $moduleResult["pagelayout"]; 811 $GLOBALS['eZCustomPageLayout'] = $moduleResult["pagelayout"]; 812 } 813 if ( isset( $moduleResult["external_css"] ) ) 814 $use_external_css =& $moduleResult["external_css"]; 815 } 816 } 817 818 if ( $module->exitStatus() == EZ_MODULE_STATUS_REDIRECT ) 819 { 820 $GLOBALS['eZRedirection'] = true; 821 $ini =& eZINI::instance(); 822 $uri =& eZURI::instance( eZSys::requestURI() ); 823 824 list( $redirUri, $debugByIP, $debugIPList ) = 825 $ini->variableMulti( "DebugSettings", array( 'DebugRedirection', 'DebugByIP', 'DebugIPList' ) ); 826 $automatic_redir = true; 827 828 if ( $redirUri == "enabled" ) 829 { 830 $automatic_redir = false; 831 } 832 else if ( $redirUri != "disabled" ) 833 { 834 $redirUris = $ini->variableArray( "DebugSettings", "DebugRedirection" ); 835 $uri->toBeginning(); 836 foreach ( $redirUris as $redirUri ) 837 { 838 $redirUri = new eZURI( $redirUri ); 839 if ( $redirUri->matchBase( $uri ) ) 840 { 841 $automatic_redir = false; 842 break; 843 } 844 } 845 } 846 847 $debugEnabled = false; 848 if ( $debugByIP == 'enabled' ) 849 { 850 $ipAddress = eZSys::serverVariable( 'REMOTE_ADDR', true ); 851 if ( $ipAddress ) 852 { 853 foreach( $debugIPList as $itemToMatch ) 854 { 855 if ( preg_match("/^(([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+))(\/([0-9]+)$|$)/", $itemToMatch, $matches ) ) 856 { 857 if ( $matches[6] ) 858 { 859 if ( eZDebug::isIPInNet( $ipAddress, $matches[1], $matches[7] ) ) 860 { 861 $debugEnabled=true; 862 break; 863 } 864 } 865 else 866 { 867 if ( $matches[1] == $ipAddress ) 868 { 869 $debugEnabled=true; 870 break; 871 } 872 } 873 } 874 } 875 } 876 else 877 { 878 $debugEnabled = ( 879 in_array( 'commandline', $debugIPList ) && 880 ( php_sapi_name() == 'cli' ) 881 ); 882 } 883 } 884 if ( !$debugEnabled && $redirUri == 'disabled' ) 885 { 886 $automatic_redir = true; 887 } 888 889 $redirectURI =& eZSys::indexDir(); 890 // eZDebug::writeDebug( eZSys::indexDir(), 'eZSys::indexDir()' ); 891 // eZDebug::writeDebug( $module->redirectURI(), '$module->redirectURI()' ); 892 893 $moduleRedirectUri = $module->redirectURI(); 894 $redirectStatus = $module->redirectStatus(); 895 $translatedModuleRedirectUri = $moduleRedirectUri; 896 if ( $ini->variable( 'URLTranslator', 'Translation' ) == 'enabled' ) 897 { 898 include_once ( 'kernel/classes/ezurlalias.php' ); 899 if ( eZURLAlias::translate( $translatedModuleRedirectUri, true ) ) 900 { 901 $moduleRedirectUri = $translatedModuleRedirectUri; 902 if ( strlen( $moduleRedirectUri ) > 0 and 903 $moduleRedirectUri[0] != '/' ) 904 $moduleRedirectUri = '/' . $moduleRedirectUri; 905 } 906 } 907 908 if ( preg_match( '#^(\w+:)|^//#', $moduleRedirectUri ) ) 909 { 910 $redirectURI = $moduleRedirectUri; 911 } 912 else 913 { 914 $leftSlash = false; 915 $rightSlash = false; 916 if ( strlen( $redirectURI ) > 0 and 917 $redirectURI[strlen( $redirectURI ) - 1] == '/' ) 918 $leftSlash = true; 919 if ( strlen( $moduleRedirectUri ) > 0 and 920 $moduleRedirectUri[0] == '/' ) 921 $rightSlash = true; 922 923 if ( !$leftSlash and !$rightSlash ) // Both are without a slash, so add one 924 $moduleRedirectUri = '/' . $moduleRedirectUri; 925 else if ( $leftSlash and $rightSlash ) // Both are with a slash, so we remove one 926 $moduleRedirectUri = substr( $moduleRedirectUri, 1 ); 927 $redirectURI .= $moduleRedirectUri; 928 } 929 930 include_once ( 'kernel/classes/ezstaticcache.php' ); 931 eZStaticCache::executeActions(); 932 933 eZDB::checkTransactionCounter(); 934 935 if ( $automatic_redir ) 936 { 937 eZHTTPTool::redirect( $redirectURI, array(), $redirectStatus ); 938 } 939 else 940 { 941 // Make sure any errors or warnings are reported 942 if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) == 'enabled' ) 943 { 944 if ( isset( $GLOBALS['eZDebugError'] ) and 945 $GLOBALS['eZDebugError'] ) 946 { 947 eZAppendWarningItem( array( 'error' => array( 'type' => 'error', 948 'number' => 1, 949 'count' => $GLOBALS['eZDebugErrorCount'] ), 950 'identifier' => 'ezdebug-first-error', 951 'text' => ezi18n( 'index.php', 'Some errors occured, see debug for more information.' ) ) ); 952 } 953 954 if ( isset( $GLOBALS['eZDebugWarning'] ) and 955 $GLOBALS['eZDebugWarning'] ) 956 { 957 eZAppendWarningItem( array( 'error' => array( 'type' => 'warning', 958 'number' => 1, 959 'count' => $GLOBALS['eZDebugWarningCount'] ), 960 'identifier' => 'ezdebug-first-warning', 961 'text' => ezi18n( 'index.php', 'Some general warnings occured, see debug for more information.' ) ) ); 962 } 963 } 964 include_once ( "kernel/common/template.php" ); 965 $tpl =& templateInit(); 966 if ( count( $warningList ) == 0 ) 967 $warningList = false; 968 $tpl->setVariable( 'site', $site ); 969 $tpl->setVariable( 'warning_list', $warningList ); 970 $tpl->setVariable( 'redirect_uri', $redirectURI ); 971 $templateResult =& $tpl->fetch( 'design:redirect.tpl' ); 972 973 eZDebug::addTimingPoint( "End" ); 974 975 eZDisplayResult( $templateResult ); 976 } 977 978 eZExecution::cleanExit(); 979 } 980 981 // Store the last URI for access history for login redirection 982 // Only if database is connected and only if there was no error or no redirects happen 983 if ( is_object( $db ) and $db->isConnected() and 984 $module->exitStatus() == EZ_MODULE_STATUS_OK ) 985 { 986 $currentURI = $completeRequestedURI; 987 if ( strlen( $currentURI ) > 0 and $currentURI[0] != '/' ) 988 $currentURI = '/' . $currentURI; 989 990 $lastAccessedURI = ""; 991 $lastAccessedViewURI = ""; 992 993 $http =& eZHTTPTool::instance(); 994 995 // Fetched stored session variables 996 if ( $http->hasSessionVariable( "LastAccessesURI" ) ) 997 { 998 $lastAccessedViewURI = $http->sessionVariable( "LastAccessesURI" ); 999 } 1000 if ( $http->hasSessionVariable( "LastAccessedModifyingURI" ) ) 1001 { 1002 $lastAccessedURI = $http->sessionVariable( "LastAccessedModifyingURI" ); 1003 } 1004 1005 // Update last accessed view page 1006 if ( $currentURI != $lastAccessedViewURI and 1007 !in_array( $module->uiContextName(), array( 'edit', 'administration', 'browse', 'authentication' ) ) ) 1008 { 1009 $http->setSessionVariable( "LastAccessesURI", $currentURI ); 1010 } 1011 1012 // Update last accessed non-view page 1013 if ( $currentURI != $lastAccessedURI ) 1014 { 1015 $http->setSessionVariable( "LastAccessedModifyingURI", $currentURI ); 1016 } 1017 } 1018 1019 1020 eZDebug::addTimingPoint( "Module end '" . $module->attribute( 'name' ) . "'" ); 1021 if ( !is_array( $moduleResult ) ) 1022 { 1023 eZDebug::writeError( 'Module did not return proper result: ' . $module->attribute( 'name' ), 'index.php' ); 1024 $moduleResult = array(); 1025 $moduleResult['content'] = false; 1026 } 1027 1028 if ( !isset( $moduleResult['ui_context'] ) ) 1029 { 1030 $moduleResult['ui_context'] = $module->uiContextName(); 1031 } 1032 $moduleResult['ui_component'] = $module->uiComponentName(); 1033 1034 $templateResult = null; 1035 1036 eZDebug::setUseExternalCSS( $use_external_css ); 1037 if ( $show_page_layout ) 1038 { 1039 include_once ( "kernel/common/template.php" ); 1040 $tpl =& templateInit(); 1041 if ( $tpl->hasVariable( 'node' ) ) 1042 $tpl->unsetVariable( 'node' ); 1043 1044 if ( !isset( $moduleResult['path'] ) ) 1045 $moduleResult['path'] = false; 1046 $moduleResult['uri'] = eZSys::requestURI(); 1047 1048 $tpl->setVariable( "module_result", $moduleResult ); 1049 1050 $meta = $ini->variable( 'SiteSettings', 'MetaDataArray' ); 1051 1052 if ( !isset( $meta['description'] ) ) 1053 { 1054 $metaDescription = ""; 1055 if ( isset( $moduleResult['path'] ) and 1056 is_array( $moduleResult['path'] ) ) 1057 { 1058 foreach ( $moduleResult['path'] as $pathPart ) 1059 { 1060 if ( isset( $pathPart['text'] ) ) 1061 $metaDescription .= $pathPart['text'] . " "; 1062 } 1063 } 1064 $meta['description'] = $metaDescription; 1065 } 1066 1067 include_once ( 'lib/version.php' ); 1068 $site['uri'] = $oldURI; 1069 $site['redirect'] = false; 1070 $site['meta'] = $meta; 1071 $site['version'] = eZPublishSDK::version(); 1072 $site['page_title'] = $module->title(); 1073 1074 $tpl->setVariable( "site", $site ); 1075 1076 include_once ( 'lib/version.php' ); 1077 $ezinfo = array( 'version' => eZPublishSDK::version( true ), 1078 'version_alias' => eZPublishSDK::version( true, true ), 1079 'revision' => eZPublishSDK::revision() ); 1080 1081 $tpl->setVariable( "ezinfo", $ezinfo ); 1082 if ( isset( $tpl_vars ) and is_array( $tpl_vars ) ) 1083 { 1084 foreach( $tpl_vars as $tpl_var_name => $tpl_var_value ) 1085 { 1086 $tpl->setVariable( $tpl_var_name, $tpl_var_value ); 1087 } 1088 } 1089 1090 if ( $show_page_layout ) 1091 { 1092 if ( $ini->variable( 'DebugSettings', 'DisplayDebugWarnings' ) == 'enabled' ) 1093 { 1094 // Make sure any errors or warnings are reported 1095 if ( isset( $GLOBALS['eZDebugError'] ) and 1096 $GLOBALS['eZDebugError'] ) 1097 { 1098 eZAppendWarningItem( array( 'error' => array( 'type' => 'error', 1099 'number' => 1 , 1100 'count' => $GLOBALS['eZDebugErrorCount'] ), 1101 'identifier' => 'ezdebug-first-error', 1102 'text' => ezi18n( 'index.php', 'Some errors occured, see debug for more information.' ) ) ); 1103 } 1104 1105 if ( isset( $GLOBALS['eZDebugWarning'] ) and 1106 $GLOBALS['eZDebugWarning'] ) 1107 { 1108 eZAppendWarningItem( array( 'error' => array( 'type' => 'warning', 1109 'number' => 1, 1110 'count' => $GLOBALS['eZDebugWarningCount'] ), 1111 'identifier' => 'ezdebug-first-warning', 1112 'text' => ezi18n( 'index.php', 'Some general warnings occured, see debug for more information.' ) ) ); 1113 } 1114 } 1115 1116 if ( $userObjectRequired ) 1117 { 1118 // include user class 1119 if( include_once ( "kernel/classes/datatypes/ezuser/ezuser.php" ) ) 1120 $currentUser =& eZUser::currentUser(); 1121 1122 $tpl->setVariable( "current_user", $currentUser ); 1123 $tpl->setVariable( "anonymous_user_id", $ini->variable( 'UserSettings', 'AnonymousUserID' ) ); 1124 } 1125 else 1126 { 1127 $tpl->setVariable( "current_user", false ); 1128 $tpl->setVariable( "anonymous_user_id", false ); 1129 } 1130 1131 // include_once( "lib/ezutils/classes/ezexecutionstack.php" ); 1132 // $execStack =& eZExecutionStack::instance(); 1133 // $tpl->setVariable( "execution_entries", $execStack->entries() ); 1134 1135 $tpl->setVariable( "access_type", $access ); 1136 1137 if ( count( $warningList ) == 0 ) 1138 $warningList = false; 1139 $tpl->setVariable( 'warning_list', $warningList ); 1140 1141 $resource = "design:"; 1142 if ( is_string( $show_page_layout ) ) 1143 { 1144 if ( strpos( $show_page_layout, ":" ) !== false ) 1145 { 1146 $resource = ""; 1147 } 1148 } 1149 else 1150 { 1151 $show_page_layout = "pagelayout.tpl"; 1152 } 1153 1154 // Set the navigation part 1155 // Check for navigation part settings 1156 $navigationPartString = 'ezcontentnavigationpart'; 1157 if ( isset( $moduleResult['navigation_part'] ) ) 1158 { 1159 $navigationPartString = $moduleResult['navigation_part']; 1160 1161 // Fetch the navigation part 1162 } 1163 $navigationPart = eZNavigationPart::fetchPartByIdentifier( $navigationPartString ); 1164 1165 $tpl->setVariable( 'navigation_part', $navigationPart ); 1166 $tpl->setVariable( 'uri_string', $uri->uriString() ); 1167 if ( isset( $moduleResult['requested_uri_string'] ) ) 1168 { 1169 $tpl->setVariable( 'requested_uri_string', $moduleResult['requested_uri_string'] ); 1170 } 1171 else 1172 { 1173 $tpl->setVariable( 'requested_uri_string', $actualRequestedURI ); 1174 } 1175 1176 // Set UI context and component 1177 $tpl->setVariable( 'ui_context', $moduleResult['ui_context'] ); 1178 $tpl->setVariable( 'ui_component', $moduleResult['ui_component'] ); 1179 1180 $templateResult =& $tpl->fetch( $resource . $show_page_layout ); 1181 } 1182 } 1183 else 1184 { 1185 $templateResult =& $moduleResult['content']; 1186 } 1187 1188 1189 eZDebug::addTimingPoint( "End" ); 1190 1191 ob_end_flush(); 1192 1193 eZDB::checkTransactionCounter(); 1194 1195 eZDisplayResult( $templateResult ); 1196 1197 eZExecution::cleanup(); 1198 eZExecution::setCleanExit(); 1199 1200 //xdebug_dump_function_profile( 4 ); 1201 1202 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |