This file is indexed.

/usr/share/php/Cache/Container/msession.php is in php-cache 1.5.6-1.

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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?php
// +----------------------------------------------------------------------+
// | PEAR :: Cache                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available at through the world-wide-web at                           |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Ulf Wendel <ulf.wendel@phpdoc.de>                           |
// +----------------------------------------------------------------------+
//
// $Id: msession.php 178289 2005-01-26 09:47:28Z dufuz $

require_once 'Cache/Container.php';

/**
* Stores cache contents in msessions.
*
* WARNING: experimental, untested
*
* @author   Ulf Wendel  <ulf.wendel@phpdoc.de>
* @version  $Id: msession.php 178289 2005-01-26 09:47:28Z dufuz $
*/
class Cache_Container_msession extends Cache_Container
{
    /**
    * Length of the Cache-Identifier
    *
    * Note that the PEAR-Cache prefixes the ID with an md5() value
    * of the cache-group. A good value for the id_length
    * depends on the maximum number of entries per cache group.
    *
    * @var  int
    */
    var $id_length = 32;
    
    
    /**
    * Use msession_uniq to create a unique SID.
    * 
    * @var  boolean
    */
    var $uniq = true;
    
    
    /**
    * Establish a connection to a msession server?
    *
    * @var  boolean
    */
    var $connect = true;
   
   
    /**
    * msession host
    *
    * @var  string
    */  
    var $host = null;
    
   
    /**
    * msession port
    *
    * @var  string
    */
    var $port = null;
    
    
    /**
    * mesession server connection
    *
    * @var  resource msession
    */
    var $ms = null;

    
    function Cache_Container_msession($options = '')
    {
        if (is_array($options)) {
            $this->setOptions($options, array_merge($this->allowed_options, array('id_length', 'uniq', 'host', 'port', 'connect')));
        }
        if ($connect) {            
            if ($this->host == null) {
                new Cache_Error('No host specified.', __FILE__, __LINE__);
            }
            if ($this->port == null) {
                new Cache_Error('No port specified.', __FILE__, __LINE__);
            }
            if (!($this->ms = msession_connect($this->host, $this->port))) {
                new Cache_Error('Can not connect to the sever using host "' . $this->host . '" on port "' . $this->port . '"', __FILE__, __LINE__);
            }
        }
        
    } // end func contructor

    function fetch($id, $group)
    {
        $id = strtoupper(md5($group)) . $id;
        $group = msession_get($id, '_pear_cache_data', null);
        
        if ($data == null) {
            return array(null, null, null);
        }
        return array($data['expires'], $data['cachedata'], $data['userdata']);
    } // end func fetch

    /**
    * Stores a dataset.
    *
    * WARNING: If you supply userdata it must not contain any linebreaks,
    * otherwise it will break the filestructure.
    */
    function save($id, $cachedata, $expires, $group, $userdata)
    {
        $this->flushPreload($id, $group);
        
        $cachedata      = $this->encode($cachedata);
        $expires_abs    = $this->getExpiresAbsolute($expires);

        $size = 1 + strlen($cachedata) + strlen($expires_abs) + strlen($userdata) + strlen($group);
        $size += strlen($size);
        
        $data = array(
                    'cachedata' => $cachedata, 
                    'expires'   => $expires_abs,
                    'userdata'  => $userdata
                  );
        $id = strtoupper(md5($group)) . $id;
                            
        msession_lock($id);
        
        if (!msession_set($id, '_pear_cache', true)) {
            msession_unlock($id);
            return new Cache_Error("Can't write cache data.", __FILE__, __LINE__);
        }
        
        if (!msession_set($id, '_pear_cache_data', $data)) {
            msession_unlock($id);
            return new Cache_Error("Can't write cache data.", __FILE__, __LINE__);
        }
        
        if (!msession_set($id, '_pear_cache_group', $group)) {
            msession_unlock($id);
            return new Cache_Error("Can't write cache data.", __FILE__, __LINE__);
        }
        
        if (!msession_set($id, '_pear_cache_size', $size)) {
            msession_unlock($id);
            return new Cache_Error("Can't write cache data.", __FILE__, __LINE__);
        }
        
        // let msession do some GC as well
        // note that msession works different from the PEAR Cache.
        // msession deletes an entry if it has not been used for n-seconds.
        // PEAR Cache deletes after n-seconds.
        if ($expires != 0) {
            msession_timeout($id, $expires);
        }
        msession_unlock($id);

        return true;
    } // end func save

    function remove($id, $group)
    {
        $this->flushPreload($id, $group);
        return msession_destroy(strtoupper(md5($group)) . $id);
    } // end func remove

    function flush($group)
    {
        $this->flushPreload();
      
        $sessions = msession_find('_pear_cache_group', $group);
        if (empty($sessions)) {
            return 0;
        }

        foreach ($sessions as $k => $id)
            messsion_destroy($id);

        return count($sessions);
    } // end func flush

    function idExists($id, $group)
    {
        return (msession_get(strtoupper(md5($group)) . $id, '_pear_cache_group', null) == null) ? false : true;
    } // end func idExists

    /**
    * Deletes all expired files.
    *
    * Note: garbage collection should cause lot's of network traffic.
    *
    * @param    integer Maximum lifetime in seconds of an no longer used/touched entry
    * @throws   Cache_Error
    */
    function garbageCollection($maxlifetime)
    {
        $this->flushPreload();
        
        $sessions = msession_find('_pear_cache', true);
        if (empty($sessions))
            return true;
        
        $total = 0;
        $entries = array();
        
        foreach ($sessions as $k => $id) {
            $data = msession_get($id, '_pear_cache_data', null);
            if (null == $data) {
                continue;
            }

            if ($data['expires'] <= time()) {
                msession_destroy($id);
                continue;
            }
            
            $size = msession_get($id, '_pear_cache_size', null);
            $total += $size;
            $entries[$data['expires']] = array($id, $size);
        }
        
        if ($total > $this->highwater) {
            
            krsort($entries);
            reset($entries);
            
            while ($total > $this->lowwater && list($expires, $entry) = each($entries)) {
                msession_destroy($entry[0]);
                $total -= $entry[1];
            }
            
        }
        
        return true;
    } // end func garbageCollection
    
} // end class file
?>