"TYPO3 4.0.1: typo3_src-4.0.1/typo3/sysext/adodb/adodb/session/adodb-compress-bzip2.php Source File", "datetime" => "Sat Dec 2 19:22:26 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>
00001 <?php 00002 00003 /* 00004 V4.90 8 June 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved. 00005 Contributed by Ross Smith (adodb@netebb.com). 00006 Released under both BSD license and Lesser GPL library license. 00007 Whenever there is any discrepancy between the two licenses, 00008 the BSD license will take precedence. 00009 Set tabs to 4 for best viewing. 00010 00011 */ 00012 00013 if (!function_exists('bzcompress')) { 00014 trigger_error('bzip2 functions are not available', E_USER_ERROR); 00015 return 0; 00016 } 00017 00018 /* 00019 */ 00020 class ADODB_Compress_Bzip2 { 00023 var $_block_size = null; 00024 00027 var $_work_level = null; 00028 00031 var $_min_length = 1; 00032 00035 function getBlockSize() { 00036 return $this->_block_size; 00037 } 00038 00041 function setBlockSize($block_size) { 00042 assert('$block_size >= 1'); 00043 assert('$block_size <= 9'); 00044 $this->_block_size = (int) $block_size; 00045 } 00046 00049 function getWorkLevel() { 00050 return $this->_work_level; 00051 } 00052 00055 function setWorkLevel($work_level) { 00056 assert('$work_level >= 0'); 00057 assert('$work_level <= 250'); 00058 $this->_work_level = (int) $work_level; 00059 } 00060 00063 function getMinLength() { 00064 return $this->_min_length; 00065 } 00066 00069 function setMinLength($min_length) { 00070 assert('$min_length >= 0'); 00071 $this->_min_length = (int) $min_length; 00072 } 00073 00076 function ADODB_Compress_Bzip2($block_size = null, $work_level = null, $min_length = null) { 00077 if (!is_null($block_size)) { 00078 $this->setBlockSize($block_size); 00079 } 00080 00081 if (!is_null($work_level)) { 00082 $this->setWorkLevel($work_level); 00083 } 00084 00085 if (!is_null($min_length)) { 00086 $this->setMinLength($min_length); 00087 } 00088 } 00089 00092 function write($data, $key) { 00093 if (strlen($data) < $this->_min_length) { 00094 return $data; 00095 } 00096 00097 if (!is_null($this->_block_size)) { 00098 if (!is_null($this->_work_level)) { 00099 return bzcompress($data, $this->_block_size, $this->_work_level); 00100 } else { 00101 return bzcompress($data, $this->_block_size); 00102 } 00103 } 00104 00105 return bzcompress($data); 00106 } 00107 00110 function read($data, $key) { 00111 return $data ? bzdecompress($data) : $data; 00112 } 00113 00114 } 00115 00116 return 1; 00117 00118 ?>