TYPO3 CMS  TYPO3_7-6
adodb-compress-gzip.php
Go to the documentation of this file.
1 <?php
2 
3 
4 /*
5 @version v5.20.3 01-Jan-2016
6 @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
7 @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community
8  Contributed by Ross Smith (adodb@netebb.com).
9  Released under both BSD license and Lesser GPL library license.
10  Whenever there is any discrepancy between the two licenses,
11  the BSD license will take precedence.
12  Set tabs to 4 for best viewing.
13 
14 */
15 
16 if (!function_exists('gzcompress')) {
17  trigger_error('gzip functions are not available', E_USER_ERROR);
18  return 0;
19 }
20 
21 /*
22 */
26  var $_level = null;
27 
30  var $_min_length = 1;
31 
34  function getLevel() {
35  return $this->_level;
36  }
37 
40  function setLevel($level) {
41  assert('$level >= 0');
42  assert('$level <= 9');
43  $this->_level = (int) $level;
44  }
45 
48  function getMinLength() {
49  return $this->_min_length;
50  }
51 
54  function setMinLength($min_length) {
55  assert('$min_length >= 0');
56  $this->_min_length = (int) $min_length;
57  }
58 
61  function __construct($level = null, $min_length = null) {
62  if (!is_null($level)) {
63  $this->setLevel($level);
64  }
65 
66  if (!is_null($min_length)) {
67  $this->setMinLength($min_length);
68  }
69  }
70 
73  function write($data, $key) {
74  if (strlen($data) < $this->_min_length) {
75  return $data;
76  }
77 
78  if (!is_null($this->_level)) {
79  return gzcompress($data, $this->_level);
80  } else {
81  return gzcompress($data);
82  }
83  }
84 
87  function read($data, $key) {
88  return $data ? gzuncompress($data) : $data;
89  }
90 
91 }
92 
93 return 1;
__construct($level=null, $min_length=null)
if(!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE' E_USER_ERROR