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