| 1 | <?php |
| 2 | /** |
| 3 | * @copyright Copyright (C) 1999-2011 eZ Systems AS. All rights reserved. |
| 4 | * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 |
| 5 | * @version 2011.7 |
| 6 | * @package kernel |
| 7 | */ |
| 8 | |
| 9 | // Set a default time zone if none is given. The time zone can be overriden |
| 10 | // in config.php or php.ini. |
| 11 | if ( !ini_get( 'date.timezone' ) ) |
| 12 | { |
| 13 | date_default_timezone_set( 'UTC' ); |
| 14 | } |
| 15 | |
| 16 | define( 'MAX_AGE', 86400 ); |
| 17 | header( 'X-Powered-By: eZ Publish (index_treemenu)' ); |
| 18 | |
| 19 | if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) |
| 20 | { |
| 21 | header( $_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified' ); |
| 22 | header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + MAX_AGE ) . ' GMT' ); |
| 23 | header( 'Cache-Control: max-age=' . MAX_AGE ); |
| 24 | header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', strtotime( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) . ' GMT' ); |
| 25 | header( 'Pragma: ' ); |
| 26 | exit(); |
| 27 | } |
| 28 | |
| 29 | require 'autoload.php'; |
| 30 | |
| 31 | // Tweaks ini filetime checks if not defined! |
| 32 | // This makes ini system not check modified time so |
| 33 | // that index_treemenu.php can assume that index.php does |
| 34 | // this regular enough, set in config.php to override. |
| 35 | if ( !defined('EZP_INI_FILEMTIME_CHECK') ) |
| 36 | { |
| 37 | define( 'EZP_INI_FILEMTIME_CHECK', false ); |
| 38 | } |
| 39 | |
| 40 | function ezupdatedebugsettings() |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | function eZFatalError() |
| 45 | { |
| 46 | header( $_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error' ); |
| 47 | } |
| 48 | |
| 49 | function exitWithInternalError() |
| 50 | { |
| 51 | header( $_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error' ); |
| 52 | eZExecution::cleanup(); |
| 53 | eZExecution::setCleanExit(); |
| 54 | } |
| 55 | |
| 56 | ignore_user_abort( true ); |
| 57 | ob_start(); |
| 58 | error_reporting ( E_ALL ); |
| 59 | |
| 60 | eZExecution::addFatalErrorHandler( 'eZFatalError' ); |
| 61 | eZDebug::setHandleType( eZDebug::HANDLE_FROM_PHP ); |
| 62 | |
| 63 | // Trick to get eZSys working with a script other than index.php (while index.php still used in generated URLs): |
| 64 | $_SERVER['SCRIPT_FILENAME'] = str_replace( '/index_treemenu.php', '/index.php', $_SERVER['SCRIPT_FILENAME'] ); |
| 65 | $_SERVER['PHP_SELF'] = str_replace( '/index_treemenu.php', '/index.php', $_SERVER['PHP_SELF'] ); |
| 66 | |
| 67 | $ini = eZINI::instance(); |
| 68 | $timezone = $ini->variable( 'TimeZoneSettings', 'TimeZone' ); |
| 69 | if ( $timezone ) |
| 70 | { |
| 71 | putenv( "TZ=$timezone" ); |
| 72 | } |
| 73 | |
| 74 | // init uri code |
| 75 | $GLOBALS['eZGlobalRequestURI'] = eZSys::serverVariable( 'REQUEST_URI' ); |
| 76 | eZSys::init( 'index.php', $ini->variable( 'SiteAccessSettings', 'ForceVirtualHost' ) === 'true' ); |
| 77 | $uri = eZURI::instance( eZSys::requestURI() ); |
| 78 | |
| 79 | $GLOBALS['eZRequestedURI'] = $uri; |
| 80 | |
| 81 | // Check for extension |
| 82 | eZExtension::activateExtensions( 'default' ); |
| 83 | |
| 84 | // load siteaccess |
| 85 | $access = eZSiteAccess::match( $uri, |
| 86 | eZSys::hostname(), |
| 87 | eZSys::serverPort(), |
| 88 | eZSys::indexFile() ); |
| 89 | $access = eZSiteAccess::change( $access ); |
| 90 | $GLOBALS['eZCurrentAccess'] = $access; |
| 91 | |
| 92 | // Check for new extension loaded by siteaccess |
| 93 | eZExtension::activateExtensions( 'access' ); |
| 94 | |
| 95 | $db = eZDB::instance(); |
| 96 | if ( $db->isConnected() ) |
| 97 | { |
| 98 | eZSession::start(); |
| 99 | } |
| 100 | else |
| 101 | { |
| 102 | exitWithInternalError(); |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | $moduleINI = eZINI::instance( 'module.ini' ); |
| 107 | $globalModuleRepositories = $moduleINI->variable( 'ModuleSettings', 'ModuleRepositories' ); |
| 108 | eZModule::setGlobalPathList( $globalModuleRepositories ); |
| 109 | |
| 110 | $module = eZModule::exists( 'content' ); |
| 111 | if ( !$module ) |
| 112 | { |
| 113 | exitWithInternalError(); |
| 114 | return; |
| 115 | } |
| 116 | |
| 117 | $function_name = 'treemenu'; |
| 118 | $uri->increase(); |
| 119 | $uri->increase(); |
| 120 | |
| 121 | $currentUser = eZUser::currentUser(); |
| 122 | $siteAccessResult = $currentUser->hasAccessTo( 'user', 'login' ); |
| 123 | $hasAccessToSite = false; |
| 124 | if ( $siteAccessResult[ 'accessWord' ] == 'limited' ) |
| 125 | { |
| 126 | $policyChecked = false; |
| 127 | foreach ( $siteAccessResult['policies'] as $policy ) |
| 128 | { |
| 129 | if ( isset( $policy['SiteAccess'] ) ) |
| 130 | { |
| 131 | $policyChecked = true; |
| 132 | $crc32AccessName = eZSys::ezcrc32( $access[ 'name' ] ); |
| 133 | if ( in_array( $crc32AccessName, $policy['SiteAccess'] ) ) |
| 134 | { |
| 135 | $hasAccessToSite = true; |
| 136 | break; |
| 137 | } |
| 138 | } |
| 139 | if ( $hasAccessToSite ) |
| 140 | { |
| 141 | break; |
| 142 | } |
| 143 | } |
| 144 | if ( !$policyChecked ) |
| 145 | { |
| 146 | $hasAccessToSite = true; |
| 147 | } |
| 148 | } |
| 149 | else if ( $siteAccessResult[ 'accessWord' ] == 'yes' ) |
| 150 | { |
| 151 | $hasAccessToSite = true; |
| 152 | } |
| 153 | |
| 154 | if ( !$hasAccessToSite ) |
| 155 | { |
| 156 | exitWithInternalError(); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | $GLOBALS['eZRequestedModule'] = $module; |
| 161 | $moduleResult = $module->run( $function_name, $uri->elements( false ) ); |
| 162 | |
| 163 | eZExecution::cleanup(); |
| 164 | eZExecution::setCleanExit(); |
| 165 | |
| 166 | ?> |
| 167 | |