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
00041
00042 include_once( 'lib/ezfile/classes/ezcompressionhandler.php' );
00043
00044 class eZGZIPZLIBCompressionHandler extends eZCompressionHandler
00045 {
00046
00047
00048 function eZGZIPZLIBCompressionHandler()
00049 {
00050 $this->File = false;
00051 $this->Level = false;
00052 $this->eZCompressionHandler( 'GZIP (zlib)', 'gzipzlib' );
00053 }
00054
00055
00056
00057
00058 function setCompressionLevel( $level )
00059 {
00060 if ( $level < 0 or $level > 9 )
00061 $level = false;
00062 $this->Level = $level;
00063 }
00064
00065
00066
00067
00068
00069 function compressionLevel()
00070 {
00071 return $this->Level;
00072 }
00073
00074
00075
00076
00077
00078 function isAvailable()
00079 {
00080 $extensionName = 'zlib';
00081 if ( !extension_loaded( $extensionName ) )
00082 {
00083 $dlExtension = ( eZSys::osType() == 'win32' ) ? '.dll' : '.so';
00084 @dl( $extensionName . $dlExtension );
00085 }
00086 return extension_loaded( $extensionName );
00087 }
00088
00089
00090
00091
00092 function doOpen( $filename, $mode )
00093 {
00094 $this->File = @gzopen( $filename, $mode );
00095 return $this->File;
00096 }
00097
00098
00099
00100
00101 function doClose()
00102 {
00103 $result = @gzclose( $this->File );
00104 $this->File = false;
00105 return $result;
00106 }
00107
00108
00109
00110
00111 function doRead( $uncompressedLength = false )
00112 {
00113 return @gzread( $this->File, $uncompressedLength );
00114 }
00115
00116
00117
00118
00119 function doWrite( $data, $uncompressedLength = false )
00120 {
00121 if ( $uncompressedLength )
00122 return @gzwrite( $this->File, $data, $uncompressedLength );
00123 else
00124 return @gzwrite( $this->File, $data );
00125 }
00126
00127
00128
00129
00130 function doFlush()
00131 {
00132 return @fflush( $this->File );
00133 }
00134
00135
00136
00137
00138 function doSeek( $offset, $whence )
00139 {
00140 if ( $whence == SEEK_CUR )
00141 {
00142 $offset = gztell( $this->File ) + $offset;
00143 }
00144 else if ( $whence == SEEK_END )
00145 {
00146 eZDebug::writeError( "Seeking from end is not supported for gzipped files",
00147 'eZGZIPZLIBCompressionHandler::doSeek' );
00148 return false;
00149 }
00150 return @gzseek( $this->File, $offset );
00151 }
00152
00153
00154
00155
00156 function doRewind()
00157 {
00158 return @gzrewind( $this->File );
00159 }
00160
00161
00162
00163
00164 function doTell()
00165 {
00166 return @gztell( $this->File );
00167 }
00168
00169
00170
00171
00172 function doEOF()
00173 {
00174 return @gzeof( $this->File );
00175 }
00176
00177
00178
00179
00180 function doPasstrough( $closeFile)
00181 {
00182 $result = @gzpasstru( $this->File );
00183 if ( !$closeFile )
00184 {
00185
00186 $this->File = @gzopen( $this->filename(), $this->mode(), $this->isBinaryMode() );
00187 }
00188 else
00189 $this->File = false;
00190 return $result;
00191 }
00192
00193
00194
00195
00196 function compress( $source )
00197 {
00198 return @gzcompress( $source, $this->Level );
00199 }
00200
00201
00202
00203
00204 function decompress( $source )
00205 {
00206 return @gzuncompress( $source );
00207 }
00208
00209
00210
00211
00212 function errorString()
00213 {
00214 return false;
00215 }
00216
00217
00218
00219
00220 function errorNumber()
00221 {
00222 return false;
00223 }
00224
00225
00226
00227 var $File;
00228
00229 var $Level;
00230 }
00231
00232 ?>