Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

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