00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 class eZHTTPHeader
00041 {
00042
00043
00044
00045
00046
00047 function enabled()
00048 {
00049 if ( isset( $GLOBALS['eZHTTPHeaderCustom'] ) )
00050 {
00051 return $GLOBALS['eZHTTPHeaderCustom'];
00052 }
00053
00054 $ini =& eZINI::instance();
00055 if ( !$ini->hasVariable( 'HTTPHeaderSettings', 'CustomHeader' ) )
00056 {
00057 $GLOBALS['eZHTTPHeaderCustom'] = false;
00058 }
00059 else
00060 {
00061 $GLOBALS['eZHTTPHeaderCustom'] = $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) == 'enabled';
00062 }
00063
00064 return $GLOBALS['eZHTTPHeaderCustom'];
00065 }
00066
00067
00068
00069
00070
00071 function headerOverrideArray( $uri )
00072 {
00073 $headerArray = array();
00074
00075 if ( !eZHTTPHeader::enabled() )
00076 {
00077 return $headerArray;
00078 }
00079
00080 $contentView = false;
00081
00082 include_once( 'kernel/classes/ezurlalias.php' );
00083 $uriString = eZURLAlias::cleanURL( $uri->uriString() );
00084
00085
00086 if ( strpos( $uriString, 'content/view/' ) === 0 )
00087 {
00088 $urlParts = explode( '/', $uriString );
00089 $nodeID = $urlParts[3];
00090 if ( !$nodeID )
00091 {
00092 return $headerArray;
00093 }
00094
00095 include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
00096 $resultSet = eZPersistentObject::fetchObject( eZContentObjectTreeNode::definition(),
00097 array( 'path_identification_string' ),
00098 array( 'node_id' => $nodeID ),
00099 false );
00100 if ( !$resultSet )
00101 {
00102 return $headerArray;
00103 }
00104
00105 $uriString = $resultSet['path_identification_string'];
00106 $contentView = true;
00107 }
00108 else
00109 {
00110 $uriCopy = $uri;
00111 eZURLAlias::translate( $uriCopy );
00112 if ( strpos( $uriCopy->uriString(), 'content/view' ) === 0 )
00113 {
00114 $contentView = true;
00115 }
00116 }
00117
00118 $uriString = '/' . eZURLAlias::cleanURL( $uriString );
00119 $ini = eZINI::instance();
00120
00121 foreach( $ini->variable( 'HTTPHeaderSettings', 'HeaderList' ) as $header )
00122 {
00123 foreach( $ini->variable( 'HTTPHeaderSettings', $header ) as $path => $value )
00124 {
00125 $path = '/' . eZURLAlias::cleanURL( $path );
00126 if ( strlen( $path ) == 1 &&
00127 !$contentView &&
00128 $uriString != '/' )
00129 {
00130 continue;
00131 }
00132
00133 if ( strpos( $uriString, $path ) === 0 )
00134 {
00135 @list( $headerValue, $depth, $level ) = explode( ';', $value );
00136
00137 if ( $header == 'Expires' )
00138 {
00139 $headerValue = gmdate( 'D, d M Y H:i:s', mktime() + $headerValue ) . ' GMT';
00140 }
00141
00142 if ( $depth === null )
00143 {
00144 $headerArray[$header] = $headerValue;
00145 }
00146 else
00147 {
00148 $pathLevel = count( explode( '/', $path ) );
00149 $uriLevel = count( explode( '/', $uriString ) );
00150 if ( $level === null )
00151 {
00152 if ( $uriLevel <= $pathLevel + $depth )
00153 {
00154 $headerArray[$header] = $headerValue;
00155 }
00156 }
00157 else
00158 {
00159 if ( $uriLevel <= $pathLevel + $depth &&
00160 $uriLevel >= $pathLevel + $level )
00161 {
00162 $headerArray[$header] = $headerValue;
00163 }
00164 }
00165 }
00166 }
00167 }
00168 }
00169
00170 return $headerArray;
00171 }
00172 }
00173
00174 ?>