new approach to logging database access and upgraded adodb
[openemr.git] / library / adodb / session / adodb-compress-gzip.php
blobc72a78e5117ef4c89e8d56d6603accf4eb577e72
1 <?php
4 /*
5 V5.14 8 Sept 2011 (c) 2000-2011 John Lim (jlim#natsoft.com). All rights reserved.
6 Contributed by Ross Smith (adodb@netebb.com).
7 Released under both BSD license and Lesser GPL library license.
8 Whenever there is any discrepancy between the two licenses,
9 the BSD license will take precedence.
10 Set tabs to 4 for best viewing.
14 if (!function_exists('gzcompress')) {
15 trigger_error('gzip functions are not available', E_USER_ERROR);
16 return 0;
21 class ADODB_Compress_Gzip {
22 /**
24 var $_level = null;
26 /**
28 var $_min_length = 1;
30 /**
32 function getLevel() {
33 return $this->_level;
36 /**
38 function setLevel($level) {
39 assert('$level >= 0');
40 assert('$level <= 9');
41 $this->_level = (int) $level;
44 /**
46 function getMinLength() {
47 return $this->_min_length;
50 /**
52 function setMinLength($min_length) {
53 assert('$min_length >= 0');
54 $this->_min_length = (int) $min_length;
57 /**
59 function ADODB_Compress_Gzip($level = null, $min_length = null) {
60 if (!is_null($level)) {
61 $this->setLevel($level);
64 if (!is_null($min_length)) {
65 $this->setMinLength($min_length);
69 /**
71 function write($data, $key) {
72 if (strlen($data) < $this->_min_length) {
73 return $data;
76 if (!is_null($this->_level)) {
77 return gzcompress($data, $this->_level);
78 } else {
79 return gzcompress($data);
83 /**
85 function read($data, $key) {
86 return $data ? gzuncompress($data) : $data;
91 return 1;