Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezhttpheader.php
Go to the documentation of this file.
1 <?php
18 class eZHTTPHeader
19 {
25 static function enabled()
26 {
27 if ( isset( $GLOBALS['eZHTTPHeaderCustom'] ) )
28 {
29 return $GLOBALS['eZHTTPHeaderCustom'];
30 }
31
32 $ini = eZINI::instance();
33 if ( !$ini->hasVariable( 'HTTPHeaderSettings', 'CustomHeader' ) )
34 {
35 $GLOBALS['eZHTTPHeaderCustom'] = false;
36 }
37 else
38 {
39 if ( $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) === 'enabled'
40 && $ini->hasVariable( 'HTTPHeaderSettings', 'OnlyForAnonymous' )
41 && $ini->variable( 'HTTPHeaderSettings', 'OnlyForAnonymous' ) === 'enabled' )
42 {
43 $GLOBALS['eZHTTPHeaderCustom'] = !eZUser::isCurrentUserRegistered();
44 }
45 else
46 {
47 $GLOBALS['eZHTTPHeaderCustom'] = $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) == 'enabled';
48 }
49 }
50
51 return $GLOBALS['eZHTTPHeaderCustom'];
52 }
53
58 static function headerOverrideArray( $uri )
59 {
60 $headerArray = array();
61
62 if ( !eZHTTPHeader::enabled() )
63 {
64 return $headerArray;
65 }
66
67 $contentView = false;
68
69 $uriString = eZURLAliasML::cleanURL( $uri->uriString() );
70
71 // If content/view used, get url alias for node
72 if ( strpos( $uriString, 'content/view/' ) === 0 )
73 {
74 $urlParts = explode( '/', $uriString );
75 $nodeID = $urlParts[3];
76 if ( !$nodeID )
77 {
78 return $headerArray;
79 }
80
81 $node = eZContentObjectTreeNode::fetch( $nodeID );
82 if ( !$node )
83 {
84 return $headerArray;
85 }
86
87 $uriString = $node->pathWithNames();
88 $contentView = true;
89 }
90 else
91 {
92 $uriCopy = clone $uri;
93 eZURLAliasML::translate( $uriCopy );
94 if ( strpos( $uriCopy->uriString(), 'content/view' ) === 0 )
95 {
96 $contentView = true;
97 }
98 }
99
100 $uriString = '/' . eZURLAliasML::cleanURL( $uriString );
101 $ini = eZINI::instance();
102
103 foreach( $ini->variable( 'HTTPHeaderSettings', 'HeaderList' ) as $header )
104 {
105 foreach( $ini->variable( 'HTTPHeaderSettings', $header ) as $path => $value )
106 {
107 $path = '/' . eZURLAliasML::cleanURL( $path );
108 if ( strlen( $path ) == 1 &&
109 ( !$contentView && ( $ini->variable( 'HTTPHeaderSettings', 'OnlyForContent' ) === 'enabled' ) ) &&
110 $uriString != '/' )
111 {
112 continue;
113 }
114
115 if ( strpos( $uriString, $path ) === 0 )
116 {
117 $config = eZStringUtils::explodeStr( $value, ';' );
118 $headerValue = $config[0];
119 $depth = isset( $config[1] ) ? $config[1] : null;
120 $level = isset( $config[2] ) ? $config[2] : null;
121
122 if ( $header == 'Expires' )
123 {
124 $headerValue = gmdate( 'D, d M Y H:i:s', time() + $headerValue ) . ' GMT';
125 }
126
127 if ( $depth === null )
128 {
129 $headerArray[$header] = $headerValue;
130 }
131 else
132 {
133 $pathLevel = count( explode( '/', $path ) );
134 $uriLevel = count( explode( '/', $uriString ) );
135 if ( $level === null )
136 {
137 if ( $uriLevel <= $pathLevel + $depth )
138 {
139 $headerArray[$header] = $headerValue;
140 }
141 }
142 else
143 {
144 if ( $uriLevel <= $pathLevel + $depth &&
145 $uriLevel >= $pathLevel + $level )
146 {
147 $headerArray[$header] = $headerValue;
148 }
149 }
150 }
151 }
152 }
153 }
154
155 return $headerArray;
156 }
157 }
158
159 ?>
$uri
$uri
Definition: activate.php:71
$level
$level
Definition: admin/message.php:106
eZHTTPHeader
The class eZHTTPHeader does.
Definition: ezhttpheader.php:19
eZHTTPHeader\headerOverrideArray
static headerOverrideArray( $uri)
Definition: ezhttpheader.php:58
eZHTTPHeader\enabled
static enabled()
Definition: ezhttpheader.php:25
$ini
$ini
Definition: classes/admin/linklist.php:64
$header
$header
Definition: paypalnotify.php:141
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.