This file is indexed.

/usr/share/php/Horde/Cache.php is in php-horde-cache 2.5.2-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
/**
 * Copyright 1999-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 *
 * @author   Anil Madhavapeddy <anil@recoil.org>
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @author   Michael Slusarz <slusarz@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package  Cache
 */

/**
 * This class provides the API interface to the cache storage drivers.
 *
 * @author   Anil Madhavapeddy <anil@recoil.org>
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @author   Michael Slusarz <slusarz@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package  Cache
 */
class Horde_Cache
{
    /**
     * Cache parameters.
     *
     * @var array
     */
    protected $_params = array(
        'compress' => false,
        'lifetime' => 86400
    );

    /**
     * Logger.
     *
     * @var Horde_Log_Logger
     */
    protected $_logger;

    /**
     * Storage object.
     *
     * @var Horde_Cache_Storage
     */
    protected $_storage;

    /**
     * Constructor.
     *
     * @param Horde_Cache_Storage $storage  The storage object.
     * @param array $params                 Parameter array:
     * <pre>
     *   - compress: (boolean) Compress data (if possible)?
     *               DEFAULT: false
     *   - lifetime: (integer) Lifetime of data, in seconds.
     *               DEFAULT: 86400 seconds
     *   - logger: (Horde_Log_Logger) Log object to use for log/debug messages.
     * </pre>
     */
    public function __construct(Horde_Cache_Storage_Base $storage,
                                array $params = array())
    {
        if (isset($params['logger'])) {
            $this->_logger = $params['logger'];
            unset($params['logger']);

            $storage->setLogger($this->_logger);
        }

        $this->_params = array_merge($this->_params, $params);
        $this->_storage = $storage;
    }

    /**
     * Attempts to directly output a cached object.
     *
     * @todo Change default lifetime to 0
     *
     * @param string $key        Object ID to query.
     * @param integer $lifetime  Lifetime of the object in seconds.
     *
     * @return boolean  True if output or false if no object was found.
     */
    public function output($key, $lifetime = 1)
    {
        $data = $this->get($key, $lifetime);
        if ($data === false) {
            return false;
        }

        echo $data;
        return true;
    }

    /**
     * Retrieve cached data.
     *
     * @todo Change default lifetime to 0
     *
     * @param string $key        Object ID to query.
     * @param integer $lifetime  Lifetime of the object in seconds.
     *
     * @return mixed  Cached data, or false if none was found.
     */
    public function get($key, $lifetime = 1)
    {
        $res = $this->_storage->get($key, $lifetime);

        if (empty($this->_params['compress']) || !is_string($res)) {
            return $res;
        }

        $compress = new Horde_Compress_Fast();
        return $compress->decompress($res);
    }

    /**
     * Store an object in the cache.
     *
     * @param string $key        Object ID used as the caching key.
     * @param string $data       Data to store in the cache.
     * @param integer $lifetime  Object lifetime - i.e. the time before the
     *                           data becomes available for garbage
     *                           collection, in seconds.  If null use the
     *                           default Horde GC time.  If 0 will not be GC'd.
     */
    public function set($key, $data, $lifetime = null)
    {
        if (!empty($this->_params['compress'])) {
            $compress = new Horde_Compress_Fast();
            $data = $compress->compress($data);
        }

        $lifetime = is_null($lifetime)
            ? $this->_params['lifetime']
            : $lifetime;

        $this->_storage->set($key, $data, $lifetime);
    }

    /**
     * Checks if a given key exists in the cache, valid for the given
     * lifetime.
     *
     * @todo Change default lifetime to 0
     *
     * @param string $key        Cache key to check.
     * @param integer $lifetime  Lifetime of the key in seconds.
     *
     * @return boolean  Existence.
     */
    public function exists($key, $lifetime = 1)
    {
        return $this->_storage->exists($key, $lifetime);
    }

    /**
     * Expire any existing data for the given key.
     *
     * @param string $key  Cache key to expire.
     *
     * @return boolean  Success or failure.
     */
    public function expire($key)
    {
        return $this->_storage->expire($key);
    }

    /**
     * Clears all data from the cache.
     *
     * @throws Horde_Cache_Exception
     */
    public function clear()
    {
        return $this->_storage->clear();
    }

    /**
     * Tests the driver for read/write access.
     *
     * @return boolean  True if read/write is available.
     */
    public function testReadWrite()
    {
        $key = '__horde_cache_testkey';

        try {
            $this->_storage->set($key, 1);
            if ($this->_storage->exists($key)) {
                $this->_storage->expire($key);
                return true;
            }
        } catch (Exception $e) {}

        return false;
    }

}