sbergmann               Tue Mar  6 07:27:30 2001 EDT

  Modified files:              
    /php4/pear  Cache.php 
    /php4/pear/Cache    Container.php Graphics.php Output.php 
    /php4/pear/Cache/Container  db.php file.php phplib.php 
  Log:
  Whitespace only.
  
Index: php4/pear/Cache.php
diff -u php4/pear/Cache.php:1.4 php4/pear/Cache.php:1.5
--- php4/pear/Cache.php:1.4     Sun Mar  4 06:26:58 2001
+++ php4/pear/Cache.php Tue Mar  6 07:27:30 2001
@@ -16,7 +16,7 @@
 // |          Sebastian Bergmann <[EMAIL PROTECTED]>               |
 // +----------------------------------------------------------------------+
 //
-// $Id: Cache.php,v 1.4 2001/03/04 14:26:58 mj Exp $
+// $Id: Cache.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
 
 /**
 * Cache is a base class for cache implementations.
@@ -24,7 +24,7 @@
 * TODO: Simple usage example goes here.
 *
 * @author   Ulf Wendel <[EMAIL PROTECTED]>
-* @version  $Id: Cache.php,v 1.4 2001/03/04 14:26:58 mj Exp $
+* @version  $Id: Cache.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
 * @package  Cache
 * @access   public 
 */
@@ -63,7 +63,7 @@
     * @access   public
     */
     var $gc_probability = 1;
-    
+
     /**
     * Storage container object.
     * 
@@ -91,7 +91,7 @@
         $this->garbageCollection();
         
     }
-    
+
     /**
     * Returns the requested dataset it if exists and is not expired
     *  
@@ -110,7 +110,6 @@
         return NULL;            
     } // end func get
 
-    
     /**
     * Stores the given data in the cache.
     * 
@@ -127,8 +126,7 @@
             
         return $this->container->save($id, $data, $expires, $group, "");
     } // end func save
-    
-    
+
     /**
     * Stores a dataset without additional userdefined data.
     * 
@@ -149,7 +147,6 @@
         return $this->container->save($id, $cachedata, $expires, $group, $userdata);
     } // end func extSave
 
-    
     /**
     * Loads the given ID from the cache.
     * 
@@ -164,8 +161,7 @@
             
         return $this->container->load($id, $group);
     } // end func load
-    
-    
+
     /**
     * Returns the userdata field of a cached data set.
     *
@@ -181,8 +177,7 @@
             
         return $this->container->getUserdata($id, $group);
     } // end func getUserdata
-    
-    
+
     /**
     * Removes the specified dataset from the cache.
     * 
@@ -197,8 +192,7 @@
             
         return $this->container->delete($id, $group);
     } // end func delete
-    
-    
+
     /**
     * Flushes the cache - removes all data from it
     * 
@@ -211,8 +205,7 @@
             
         return $this->container->flush($group);
     } // end func flush
-    
-    
+
     /**
     * Checks if a dataset exists.
     * 
@@ -229,8 +222,7 @@
             
         return $this->container->isCached($id, $group);
     } // end func isCached
-    
-    
+
     /**
     * Checks if a dataset is expired
     * 
@@ -251,7 +243,7 @@
             
         return $this->container->isExpired($id, $group, $max_age);
     } // end func isExpired
-    
+
     /**
     * Generates a "unique" ID for the given value
     * 
@@ -286,9 +278,6 @@
             $this->container->garbageCollection();
             $last_run = time();
         }
-        
     } // end func garbageCollection
-
-    
 } // end class cache 
 ?>
Index: php4/pear/Cache/Container.php
diff -u php4/pear/Cache/Container.php:1.5 php4/pear/Cache/Container.php:1.6
--- php4/pear/Cache/Container.php:1.5   Tue Mar  6 03:32:10 2001
+++ php4/pear/Cache/Container.php       Tue Mar  6 07:27:30 2001
@@ -1,5 +1,4 @@
 <?php
-
 // +----------------------------------------------------------------------+
 // | PHP version 4.0                                                      |
 // +----------------------------------------------------------------------+
@@ -17,7 +16,7 @@
 // |          Sebastian Bergmann <[EMAIL PROTECTED]>               |
 // +----------------------------------------------------------------------+
 //
-// $Id: Container.php,v 1.5 2001/03/06 11:32:10 chregu Exp $
+// $Id: Container.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
 
 /**
 * Common base class of all cache storage container.
@@ -37,7 +36,7 @@
 * not recommended!
 * 
 * @author   Ulf Wendel <[EMAIL PROTECTED]>
-* @version  $Id: Container.php,v 1.5 2001/03/06 11:32:10 chregu Exp $
+* @version  $Id: Container.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
 * @package  Cache
 * @access   public
 * @abstract
@@ -52,63 +51,56 @@
     * @var  boolean
     */
     var $preload = true;
-    
+
     /**
     * ID of a preloaded dataset
     *
     * @var  string
     */
     var $id = "";
-    
-    
+
     /**
     * Cache group of a preloaded dataset
     *
     * @var  string
     */
     var $group = "";
-    
-    
+
     /**
     * Expiration timestamp of a preloaded dataset.
     * 
     * @var  integer 0 means never, endless
     */
     var $expires = 0;
-    
-    
+
     /**
     * Value of a preloaded dataset.
     * 
     * @var  string
     */
     var $cachedata = "";
-    
-    
+
     /**
     * Preloaded userdata field.
     * 
     * @var  string
     */
     var $userdata = "";
-    
-    
+
     /**
     * Flag indicating that the dataset requested for preloading is unknown.
     *  
     * @var  boolean
     */
     var $unknown = true;
-    
-    
+
     /**
     * Encoding mode for cache data: base64 or addslashes() (slash).
     *
     * @var  string  base64 or slash
     */
     var $encoding_mode = "base64";
-    
-        
+
     /**
     * Loads a dataset from the cache.
     * 
@@ -118,24 +110,17 @@
     * @access   public
     */
     function load($id, $group) {
-
         if ($this->preload) {
-        
             if ($this->id != $id || $this->group != $group)
                 $this->preload($id, $group);
 
             return $this->cachedata;
-                            
         } else {
-        
             list( , $data, ) = $this->fetch($id, $group);
             return $data;
-            
         }
-
     } // end func load
-    
-    
+
     /**
     * Returns the userdata field of a cached data set.
     *
@@ -145,24 +130,17 @@
     * @access   public
     */
     function getUserdata($id, $group) {
-        
         if ($this->preload) {
-        
             if ($this->id != $id || $this->group != $group)
                 $this->preload($id, $group);
                 
             return $this->userdata;
-                        
         } else {
-        
             list( , , $userdata) = $this->fetch($id, $group);
             return $userdata;
-                    
         }
-            
     } // end func getUserdata
-    
-    
+
     /**
     * Checks if a dataset is expired.
     * 
@@ -173,17 +151,13 @@
     * @access   public
     */
     function isExpired($id, $group, $max_age) {
-
         if ($this->preload) {
-            
           if ($this->id != $id || $this->group != $group)
             $this->preload($id, $group);
           
           if ($this->unknown)
             return false;
-                        
         } else {
-        
             // check if at all it is cached
             if (!$this->isCached($id, $group))
                 return false;
@@ -191,23 +165,20 @@
             // I'm lazy...
             list($this->expires, , ) = $this->fetch($id, $group);
         }
-    
+
         // endless
         if (0 == $this->expires)
             return false;
-        
+
         // you feel fine, Ulf?
         if ($expired  = ($this->expires <= time() || ($max_age && ($this->expires <= 
$max_age))) ) {
-           
+
            $this->delete($id, $group);
            $this->flushPreload();
-           
         }
-        
         return $expired;
     } // end func isExpired
-    
-    
+
     /**
     * Checks if a dataset is cached.
     *
@@ -216,26 +187,20 @@
     * @return   boolean
     */
     function isCached($id, $group) {
-
         if ($this->preload) {
-            
             if ($this->id != $id || $this->group != $group)
                 $this->preload($id, $group);
 
             return !($this->unknown);
-            
         } else {
-            
             return $this->idExists($id, $group);
-            
         }
-        
     } // end func isCached
-    
+
     //
     // abstract methods
     //
-    
+
     /**
     * Fetches a dataset from the storage medium.
     *
@@ -248,7 +213,7 @@
     function fetch($id, $group) {
         return array(NULL, NULL, NULL);
     } // end func fetch
-    
+
     /**
     * Stores a dataset.
     * 
@@ -263,14 +228,13 @@
     * @abstract
     */
     function save($id, $data, $expire, $group, $userdata) {
-    
         // QUESTION: Should we update the preload buffer instead?
         // Don't think so as the sequence save()/load() is unlikely.
         $this->flushPreload($id, $group);
-        
+
         return NULL;
     } // end func save
-    
+
     /**
     * Deletes a dataset.
     * 
@@ -284,8 +248,7 @@
         $this->flushPreload($id, $group);
         return NULL;
     } // end func delete
-    
-    
+
     /**
     * Flushes the cache - removes all caches datasets from the cache.
     * 
@@ -298,8 +261,7 @@
         $this->flushPreload();
         return NULL;
     } // end func flush
-    
-    
+
     /**
     * Checks if a dataset exists.
     * 
@@ -312,8 +274,7 @@
     function idExists($id, $group) {
         return NULL;
     } // end func idExists
-    
-    
+
     /**
     * Starts the garbage collection.
     * 
@@ -324,7 +285,6 @@
         $this->flushPreload();
     } // end func garbageCollection
 
-    
     /**
     * Does a speculative preload of a dataset
     *
@@ -333,27 +293,24 @@
     * @return   boolean
     */ 
     function preload($id, $group) {
-        
         // whatever happens, remember the preloaded ID
         $this->id = $id;
         $this->group = $group;        
-        
+
         list($this->expires, $this->cachedata, $this->userdata) = $this->fetch($id, 
$group);
-        
-        if (NULL === $this->expires) {
 
+        if (NULL === $this->expires) {
             // Uuups, unknown ID
             $this->flushPreload();
 
             return false;
         }
-        
+
         $this->unknown = false;
-        
+
         return true;
     } // end func preload
-    
-    
+
     /**
     * Flushes the internal preload buffer.
     *
@@ -368,7 +325,6 @@
     * @see  preload()
     */
     function flushPreload($id = "", $group = "default") {
-
         if (!$id || ($this->id == $id && $this->group == $group)) {
             // clear the internal preload values
             $this->id = "";
@@ -378,10 +334,8 @@
             $this->expires = -1;
             $this->unknown = true;
         }
-        
     } // end func flushPreload
 
-    
     /**
     * Imports the requested datafields as object variables if allowed
     * 
@@ -389,42 +343,34 @@
     * @param    array   List of allowed datafields
     */
     function setOptions($requested, $allowed) {
-
         foreach ($allowed as $k => $field)
             if (isset($requested[$field]))
                 $this->$field = $requested[$field];
                 
     } // end func setOptions
-    
-    
+
     /**
     * Encodes the data for the storage container.
     * 
     * @var  mixed data to encode
     */
     function encode($data) {
-    
         if ("base64" == $this->encoding_mode) 
             return base64_encode(serialize($data));
         else 
             return serialize($data);
-    
     } // end func encode
-    
-    
+
     /**
     * Decodes the data from the storage container.
     * 
     * @var  mixed
     */
     function decode($data) {
-        
         if ("base64" == $this->encoding_mode)
             return unserialize(base64_decode($data));
         else
             return unserialize($data);
-                        
     } // end func decode
-    
 }
 ?>
Index: php4/pear/Cache/Graphics.php
diff -u php4/pear/Cache/Graphics.php:1.4 php4/pear/Cache/Graphics.php:1.5
--- php4/pear/Cache/Graphics.php:1.4    Sat Mar  3 11:18:31 2001
+++ php4/pear/Cache/Graphics.php        Tue Mar  6 07:27:30 2001
@@ -15,7 +15,7 @@
 // | Authors: Ulf Wendel <[EMAIL PROTECTED]>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: Graphics.php,v 1.4 2001/03/03 19:18:31 uw Exp $
+// $Id: Graphics.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
 
 require_once 'Cache.php';
 
@@ -66,7 +66,7 @@
 * the output buffer. Modify it if required!
 *
 * @author   Ulf Wendel <[EMAIL PROTECTED]>
-* @version  $Id: Graphics.php,v 1.4 2001/03/03 19:18:31 uw Exp $
+* @version  $Id: Graphics.php,v 1.5 2001/03/06 15:27:30 sbergmann Exp $
 * @package  Cache
 */
 class Cache_Graphics extends Cache {
@@ -82,7 +82,7 @@
     * @see  setCacheURL(), setCacheDir()
     */
     var $cache_url = "";
-    
+
     /**
     * Directory where cached files get stored.
     * s
@@ -94,7 +94,7 @@
     * @see  setCacheDir(), setCacheURL()
     */
     var $cache_dir = "";
-    
+
     /**
     * Nameprefix of cached files.
     * 
@@ -104,8 +104,7 @@
     * @var      string
     */
     var $cache_file_prefix = "graphics_";
-    
-    
+
     /**
     * Mapping from supported image type to a ImageType() constant.
     * 
@@ -128,7 +127,6 @@
         $this->cache("cache_container_file", array("cache_dir" => $this->cache_dir, 
"filename_prefix" => $this->cache_file_prefix));
     } // end constructor
 
-    
     /**
     * Returns the content of a cached image file.
     * 
@@ -144,13 +142,11 @@
     * @see      cacheImage()
     */                                    
     function getImage($id, $format = "png") {
-        
         $id = $this->generateID(array("id" => $id, "format" => strtolower($format)));
         
         return $this->get($id);
     } // end func getImage
-    
-    
+
     /**
     * Returns an array with a link to the cached image and the image file path.
     * 
@@ -164,17 +160,15 @@
     * @see      cacheImageLink()
     */
     function getImageLink($id, $format = "png") {
-
         $id = $this->generateID(array("id" => $id, "format" => strtolower($format)));
         if (!$this->container->idExists($id)) 
             return array();
-            
+
         $file = $this->cache_url . $this->cache_file_prefix . $id;
-        
+
         return array($this->container->getFilename($id), $file);
     } // end func getImageLink
-    
-    
+
     /**
     * Create an image from the given image handler, cache it and return the file 
content.
     *
@@ -198,7 +192,7 @@
     function cacheImage($id, &$img, $format = "png") {
         if (!$id)
             return new gerror("You must provide an ID for and image to be cached!");
-    
+
         $id = $this->generateID(array("id" => $id, "format" => strtolower($format)));
         
         // Check if the requested image type is supported by the GD lib.
@@ -210,31 +204,30 @@
                 else
                     return new gerror("Hmm, is you PHP build with GD support? Can't 
find any supported types.");
         }
-        
+
         if ($image = $this->get($id))
             return $image;
-        
+
         // save the image to the output buffer, write it to disk and 
         // return the image.
         ob_end_clean();
         ob_start(); 
-        
+
         // generate the image
         $func = "Image" . strtoupper($format);    
         $func($img);
         ImageDestroy($img);
-                
+
         ob_end();
         $image = ob_get_contents();
         ob_end_clean();
-    
+
         // save the generated image to disk
         $this->save($id, $image, 0);
-        
+
         return $image;
     } // end func cacheImage
 
-    
     /**
     * Create an image from the given image handler, cache it and return a url and the 
file path of the image.
     *
@@ -255,9 +248,9 @@
     function cacheImageLink($id, &$img, $format = "png") {
         if (!$id)
             return new gerror("You must provide an ID for and image to be cached!");
-            
+
         $id = $this->generateID(array("id" => $id, "format" => strtolower($format));
-        
+
         // Check if the requested image type is supported by the GD lib.
         // If not, try a callback to the first available image type.
         if (!isset($this->imagetypes[$format]) || !(ImageTypes() & 
$this->imagetypes[$format])) {
@@ -270,7 +263,7 @@
 
         $url = $this->cache_url . $this->cache_file_prefix . $id;
         $ffile = $this->container->getFilename($id);
-        
+
         if ($this->isCached($id) && !isExpired($id))
             return array($ffile, $url)
 
@@ -282,7 +275,6 @@
         return array($ffile, $url);
     } // end func cacheImageLink
 
-
     /**
     * Sets the URL prefix used when rendering HTML Tags. 
     * 
@@ -294,14 +286,13 @@
     * @see      setCacheDir()
     */
     function setCacheURL($cache_url) {
-    
         if ($cache_url && "/" != substr($cache_url, 1)) 
             $cache_url .= "/";
             
         $this->cache_url = $cache_url;
         
     } // end func setCacheURL
-    
+
     /**
     * Sets the directory where to cache generated Images
     * 
@@ -310,15 +301,11 @@
     * @see      setCacheURL()
     */
     function setCacheDir($cache_dir) {
-        
         if ($cache_dir && "/" != substr($cache_dir, 1))
             $cache_dir .= "/";
-            
+
         $this->cache_dir = $cache_dir;
         $this->container->cache_dir = $cache_dir;
-                        
     } // end func setCacheDir
-
-    
 } // end class Cache_Graphics
 ?>
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.8 php4/pear/Cache/Output.php:1.9
--- php4/pear/Cache/Output.php:1.8      Sat Mar  3 11:19:25 2001
+++ php4/pear/Cache/Output.php  Tue Mar  6 07:27:30 2001
@@ -17,7 +17,7 @@
 // |          Vinai Kopp <[EMAIL PROTECTED]>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: Output.php,v 1.8 2001/03/03 19:19:25 uw Exp $
+// $Id: Output.php,v 1.9 2001/03/06 15:27:30 sbergmann Exp $
 
 require_once 'Cache.php';
 
@@ -89,7 +89,7 @@
     * @see  start(), end()
     */
     var $output_id = "";
-    
+
     /**
     * Group passed to start()
     * 
@@ -97,8 +97,7 @@
     * @see  start(), end()
     */
     var $output_group = "";
-    
-    
+
     /**
     * starts the output buffering and returns an empty string or returns the cached 
output from the cache.
     * 
@@ -119,15 +118,14 @@
         // remember some data to be able to fill the cache on calling end()
         $this->output_id = $id;
         $this->output_group = $group;
-        
+
         // WARNING: we need the output buffer - possible clashes
         ob_start();
         ob_implicit_flush(false);
-        
+
         return "";
     } // end func start
 
-    
     /*
     * Stores the content of the output buffer into the cache and returns the content.
     *
@@ -138,30 +136,25 @@
     * @see      endPrint(), endGet()
     */
     function end($expire = 0, $userdata = "") {
-    
         $content = ob_get_contents();
         ob_end_clean();
-        
+
         // store in the cache
         if (!$this->no_cache)
             $this->container->save($this->output_id, $content, $expire, 
$this->output_group, $userdata);
 
         return $content;
     } // end func end()
-    
-    
+
     /**
     * Stores the content of the output buffer into the cache and prints the content.
     *
     * @brother  end()
     */
     function endPrint($expire = 0, $userdata = "") {
-    
         print $this->end($expire, $userdata);      
-        
     } // end func endPrint
-    
-    
+
     /**
     * Returns the content of the output buffer but does not store it into the cache.
     *
@@ -174,7 +167,6 @@
     * @see      endPrint(), end()
     */
     function endGet() {
-
         $content = ob_get_contents();
         ob_end_clean();
 
@@ -183,7 +175,5 @@
 
         return $content;
     } // end func endGet
-
-    
 } // end class output
 ?>
Index: php4/pear/Cache/Container/db.php
diff -u php4/pear/Cache/Container/db.php:1.6 php4/pear/Cache/Container/db.php:1.7
--- php4/pear/Cache/Container/db.php:1.6        Tue Mar  6 03:32:10 2001
+++ php4/pear/Cache/Container/db.php    Tue Mar  6 07:27:30 2001
@@ -17,7 +17,7 @@
 // |          Chuck Hagenbuch <[EMAIL PROTECTED]>                           |
 // +----------------------------------------------------------------------+
 //
-// $Id: db.php,v 1.6 2001/03/06 11:32:10 chregu Exp $
+// $Id: db.php,v 1.7 2001/03/06 15:27:30 sbergmann Exp $
 
 require_once 'DB.php';
 require_once 'Cache/Container.php';
@@ -50,11 +50,11 @@
 *   INDEX (expires),
 *   PRIMARY KEY (id, cachegroup)
 * )
-
- * @author   Sebastian Bergmann <[EMAIL PROTECTED]>
- * @version  $Id: db.php,v 1.6 2001/03/06 11:32:10 chregu Exp $
- * @package  Cache
- */
+*
+* @author   Sebastian Bergmann <[EMAIL PROTECTED]>
+* @version  $Id: db.php,v 1.7 2001/03/06 15:27:30 sbergmann Exp $
+* @package  Cache
+*/
 class Cache_Container_db extends Cache_Container {
   
     /**
@@ -63,7 +63,7 @@
     * @see  Cache_Container_file::$filename_prefix
     */  
     var $cache_table = '';
-    
+
     /**
     * PEAR DB dsn to use.
     * 
@@ -77,23 +77,18 @@
     * @var  object PEAR_DB
     */
     var $db;
-    
-    /**
-    *
-    * @param    mixed
-    */    
+
     function Cache_Container_db($options)
     {
-        
         if (!is_array($options) || !isset($options['dsn'])) {
             return new CacheError('No dsn specified!', __FILE__, __LINE__);
         }
-        
+
         $this->setOptions($options, array('dsn', 'cache_table'));
-        
+
         if (!$this->dsn)
             return new CacheError('No dsn specified!', __FILE__, __LINE__);
-        
+
         $this->db = DB::connect($this->dsn, true);
         if (DB::isError($this->db)) {
             return new CacheError('DB::connect failed: ' . 
DB::errorMessage($this->db), __FILE__, __LINE__);
@@ -101,8 +96,7 @@
             $this->db->setFetchMode(DB_FETCHMODE_ASSOC);
         }
     }
-    
-    
+
     function fetch($id, $group)
     {
         $query = sprintf("SELECT cachedata, userdata, expires FROM %s WHERE id = '%s' 
AND cachegroup = '%s'",
@@ -110,7 +104,7 @@
                          addslashes($id),
                          addslashes($group)
                          );
-        
+
         $res = $this->db->query($query);
 
         if (DB::isError($res))
@@ -121,7 +115,7 @@
         if (is_array($row))
             return array($row['expires'], $this->decode($row['cachedata']), 
$row['userdata']);
     }
-    
+
     /**
     * Stores a dataset.
     * 
@@ -131,9 +125,8 @@
     */
     function save($id, $data, $expires, $group, $userdata)
     {
-        
         $this->flushPreload($id, $group);
-        
+
         $query = sprintf("REPLACE INTO %s (userdata, cachedata, expires, id, 
cachegroup) VALUES ('%s', '%s', %d, '%s', '%s')",
                          $this->cache_table,
                          addslashes($userdata),
@@ -144,48 +137,44 @@
                         );
 
         $res = $this->db->query($query);
-        
+
         if (DB::isError($res)) {
             return new CacheError('DB::query failed: ' . DB::errorMessage($res) , 
__FILE__, __LINE__);
         }
     }
 
-
     function delete($id, $group)
     {
         $this->flushPreload($id, $group);
-        
+
         $query = sprintf("DELETE FROM %s WHERE id = '%s' and cachegroup = '%s'",
                          $this->cache_table,
                          addslashes($id),
                          addslashes($group)
                         );
-        
+
         $res = $this->db->query($query);
-        
+
         if (DB::isError($res))
             return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
     }
 
-
     function flush($group = "")
     {
-    
         $this->flushPreload();
-        
+
          if ($group) {
             $query = sprintf("DELETE FROM %s WHERE cachegroup = '%s'", 
$this->cache_table, addslashes($group));    
         } else {
             $query = sprintf("DELETE FROM %s", $this->cache_table);    
         }
-        
+
         $res = $this->db->query($query);
 
         if (DB::isError($res))
             return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
     }
 
-
     function idExists($id, $group)
     {
         $query = sprintf("SELECT id FROM %s WHERE ID = '%s' AND cachegroup = '%s'", 
@@ -193,14 +182,14 @@
                          addslashes($id),
                          addslashes($group)
                         );
-        
+
         $res = $this->db->query($query);
 
         if (DB::isError($res))
             return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
 
         $row = $res->fetchRow();
-        
+
         if (is_array($row)) {
             return true;
         } else {
@@ -213,13 +202,12 @@
         $query = sprintf('DELETE FROM %s WHERE expires <= %d AND expires > 0',
                          $this->cache_table,
                          time());
-        
+
         $res = $this->db->query($query);
-        
+
         if (DB::isError($res)) {
             return new CacheError('DB::query failed: ' . DB::errorMessage($res), 
__FILE__, __LINE__);
         }
     }
-
 }
 ?>
Index: php4/pear/Cache/Container/file.php
diff -u php4/pear/Cache/Container/file.php:1.5 php4/pear/Cache/Container/file.php:1.6
--- php4/pear/Cache/Container/file.php:1.5      Tue Mar  6 05:25:43 2001
+++ php4/pear/Cache/Container/file.php  Tue Mar  6 07:27:30 2001
@@ -16,7 +16,7 @@
 // |          Sebastian Bergmann <[EMAIL PROTECTED]>               |
 // +----------------------------------------------------------------------+
 //
-// $Id: file.php,v 1.5 2001/03/06 13:25:43 chregu Exp $
+// $Id: file.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
 
 require_once 'Cache/Container.php';
 
@@ -24,7 +24,7 @@
 * Stores cache contents in a file.
 *
 * @author   Ulf Wendel  <[EMAIL PROTECTED]>
-* @version  $Id: file.php,v 1.5 2001/03/06 13:25:43 chregu Exp $
+* @version  $Id: file.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
 */
 class Cache_Container_file extends Cache_Container {
 
@@ -34,7 +34,7 @@
     * @var  string  Make sure to add a trailing slash
     */
     var $cache_dir = "";
-    
+
     /**
     * Filename prefix for cache files.
     * 
@@ -53,35 +53,31 @@
     * @var  string
     */
     var $filename_prefix = "";
-    
+
     /**
     * Creates the cache directory if neccessary
     * 
     * @param    array   Config options: ["cache_dir" => ..., "filename_prefix" => ...]
     */
     function Cache_Container_file($options = "") {
-    
         if (is_array($options))
             $this->setOptions($options, array("cache_dir", "filename_prefix"));
-            
+
         clearstatcache();
-        
+
         if (!file_exists($this->cache_dir) || !is_dir($this->cache_dir))
             mkdir($this->cache_dir, 0755);
-            
     } // end func contructor
-    
-    
+
     function fetch($id, $group) {
-    
         $file = $this->getFilename($id, $group);
         if (!file_exists($file))
             return array(NULL, NULL, NULL);
-            
+
         // retrive the content
         if (!($fh = @fopen($file, "rb")))
             return new CacheError("Can't access cache file '$file'. Check access 
rights and path.", __FILE__, __LINE__);
-            
+
         // file format:
         // 1st line: expiration date
         // 2nd line: user data
@@ -90,11 +86,10 @@
         $userdata = trim(fgets($fh, 257));
         $cachedata = $this->decode(fread($fh, filesize($file)));
         fclose($fh);
-        
+
         return array($expire, $cachedata, $userdata);
     } // end func fetch
-    
-    
+
     /**
     * Stores a dataset.
     * 
@@ -102,13 +97,12 @@
     * otherwise it will break the filestructure.
     */
     function save($id, $cachedata, $expires, $group, $userdata) {
-    
         $this->flushPreload($id, $group);
-        
+
         $file = $this->getFilename($id, $group);
         if (!($fh = @fopen($file, "wb")))
             return new CacheError("Can't access '$file' to store cache data. Check 
access rights and path.", __FILE__, __LINE__);
-            
+
         // file format:
         // 1st line: expiration date
         // 2nd line: user data
@@ -117,51 +111,45 @@
         fwrite($fh, $expires . "\n");
         fwrite($fh, $userdata . "\n");
         fwrite($fh, $this->encode($cachedata));
-        
+
         fclose($fh);
-        
+
         // I'm not sure if we need this
         touch($file);
-        
+
         return true;
     } // end func save
     
     function delete($id, $group) {
-    
         $this->flushPreload($id, $group);
-        
+
         $file = $this->getFilename($id, $group);
         if (file_exists($file)) {
-        
+
             $ok = unlink($file);
             clearstatcache();
-            
+
             return $ok;
         }
-        
+
         return false;
     } // end func delete
-    
-    
+
     function flush($group) {
-    
         $this->flushPreload();
         $dir = ($group) ? $this->cache_dir . $group . "/" : $this->cache_dir;
-        
+
         $num_removed = $this->deleteDir($dir);
         clearstatcache();
-        
+
         return $num_removed;
     } // end func flush
-    
-    
+
     function idExists($id, $group) {
-    
         return file_exists($this->getFilename($id, $group));
         
     } // end func idExists
-    
-    
+
     /**
     * Deletes all expired files.
     * 
@@ -176,45 +164,42 @@
     *                   recursive function call!
     */
     function garbageCollection($dir = "") {
-    
         $this->flushPreload();
-        
+
         if (!$dir)
             $dir = $this->cache_dir;
-            
+
         if (!($dh = opendir($dir)))
             return new CacheError("Can't access cache directory '$dir'. Check 
permissions and path.", __FILE__, __LINE__);
-            
+
         while ($file = readdir($dh)) {
             if ("." == $file || ".." == $file)
                 continue;
-                
+
             $file = $dir . $file;
             if (is_dir($file))
                 $this->garbageCollection($file . "/");
-                
+
             // skip trouble makers but inform the user
             if (!($fh = @fopen($file, "rb"))) {
                 new CacheError("Can't access cache file '$file', skipping it. Check 
permissions and path.", __FILE__, __LINE__);
                 continue;
             }
-            
+
             $expire = time(fgets($fh, 11));
             fclose($fh);
-            
+
             // remove if expired
             if ($expire && $expire <= time() && !unlink($file))
                 new CacheError("Can't unlink cache file '$file', skipping. Check 
permissions and path.", __FILE__, __LINE__);
         }
-        
+
         closedir($dh);
-        
+
         // flush the disk state cache
         clearstatcache();
-        
     } // end func garbageCollection
-    
-    
+
     /**
     * Returns the filename for the specified id.
     *
@@ -225,23 +210,21 @@
     */
     function getFilename($id, $group) {
         static $group_dirs = array();
-        
+
         if (isset($group_dirs[$group]))
             return $group_dirs[$group] . $this->filename_prefix . $id;
-            
-            
+
         $dir = $this->cache_dir . $group . "/";
         if (!file_exists($dir)) {
             mkdir($dir, 0755);
             clearstatcache();
         }
-        
+
         $group_dirs[$group] = $dir;
-        
+
         return $dir . $this->filename_prefix . $id;
     } // end func getFilename
-    
-    
+
     /**
     * Deletes a directory and all files in it.
     * 
@@ -250,32 +233,25 @@
     * @throws   CacheError
     */
     function deleteDir($dir) {
-    
         if (!($dh = opendir($dir)))
             return new CacheError("Can't remove directory '$dir'. Check permissions 
and path.", __FILE__, __LINE__);
-            
+
         $num_removed = 0;
-        
+
         while ($file = readdir($dh)) {
             if ("." == $file || ".." == $file)
                 continue;
-                
+
             $file = $dir . $file;
             if (is_dir($file)) {
-            
                 $file .= "/";
                 $num = $this->deleteDir($file . "/");
                 if (is_int($num))
                     $num_removed += $num;
-                    
             } else {
-            
                 if (unlink($file))
                     $num_removed++;
-                    
             }
-            
-            
         }
         // according to php-manual the following is needed for windows installations.
         closedir($dh);
@@ -284,10 +260,8 @@
             rmDir($dir);
             $num_removed++;
         }
-        
+
         return $num_removed;
     } // end func deleteDir
-    
-    
 } // end class file
 ?>
Index: php4/pear/Cache/Container/phplib.php
diff -u php4/pear/Cache/Container/phplib.php:1.7 
php4/pear/Cache/Container/phplib.php:1.8
--- php4/pear/Cache/Container/phplib.php:1.7    Tue Mar  6 03:32:10 2001
+++ php4/pear/Cache/Container/phplib.php        Tue Mar  6 07:27:30 2001
@@ -16,7 +16,7 @@
 // |          Sebastian Bergmann <[EMAIL PROTECTED]>               |
 // +----------------------------------------------------------------------+
 //
-// $Id: phplib.php,v 1.7 2001/03/06 11:32:10 chregu Exp $
+// $Id: phplib.php,v 1.8 2001/03/06 15:27:30 sbergmann Exp $
 
 require_once 'Cache/Container.php';
 
@@ -51,7 +51,7 @@
 *
 * 
 * @author   Ulf Wendel  <[EMAIL PROTECTED]>, Sebastian Bergmann 
<[EMAIL PROTECTED]>
-* @version  $Id: phplib.php,v 1.7 2001/03/06 11:32:10 chregu Exp $
+* @version  $Id: phplib.php,v 1.8 2001/03/06 15:27:30 sbergmann Exp $
 * @package  Cache
 * @see      save()
 */
@@ -63,15 +63,14 @@
     * @see  Cache_Container_file::$filename_prefix
     */  
     var $cache_table = "cache";
-    
+
     /**
     * PHPLib object
     * 
     * @var  object PEAR_DB
     */
     var $db;
-    
-    
+
     /**
     * Name of the PHPLib DB class to use
     * 
@@ -79,8 +78,7 @@
     * @see  $db_path, $local_path
     */
     var $db_class = "";
-    
-    
+
     /**
     * Filename of your local.inc
     * 
@@ -89,7 +87,6 @@
     * @var       string
     */
     var $local_file = "";
-       
 
     /**
     * Include path for you local.inc
@@ -104,8 +101,7 @@
     * @see  $local_file
     */
     var $local_path = "";
-    
-    
+
     /**
     * Creates an instance of a phplib db class to use it for storage.
     *
@@ -122,7 +118,6 @@
     * @see  $local_path
     */
     function Cache_Container_phplib($options = "") {
-    
         if (is_array($options))
             $this->setOptions($options, array("db_class", "db_file", "db_path", 
"local_file", "local_path"));
 
@@ -132,18 +127,15 @@
         // include the required files
         if ($this->db_file)
             include_once($this->db_path . $this->db_file);
-            
+
         if ($this->local_file)
             include_once($this->local_path . $this->local_file);
-            
+
         // create a db object 
         $this->db = new $this->db_class;
-
     } // end constructor
-    
-    
+
     function fetch($id, $group) {
-    
         $query = sprintf("SELECT expires, cachedata, userdata FROM %s WHERE id = '%s' 
AND cachegroup = '%s'",
                             $this->cache_table, 
                             $id,
@@ -152,11 +144,10 @@
         $this->db->query($query);
         if (!$this->db->Next_Record())
             return array(NULL, NULL, NULL);
-            
+
         return array($this->db->f("expires"), 
$this->decode($this->db->f("cachedata")), $this->db->f("userdata"));
     } // end func fetch
-    
-    
+
     /**
     * Stores a dataset.
     * 
@@ -165,9 +156,8 @@
     * work fine for 95% of you.
     */
     function save($id, $data, $expires, $group) {
-        
         $this->flushPreload($id, $group);
-        
+
         $query = sprintf("REPLACE INTO %s (cachedata, expires, id, cachegroup) VALUES 
('%s', %d, '%s', '%s')",
                             $this->cache_table,
                             addslashes($this->encode($data)),
@@ -176,13 +166,11 @@
                             $group
                          );
         $this->db->query($query);
-        
+
         return (boolean)$this->db->affected_rows(); 
     } // end func save
-    
-    
+
     function delete($id, $group) {
-        
         $this->flushPreload($id, $group);
         $this->db->query(
                         sprintf("DELETE FROM %s WHERE id = '%s' AND cachegroup = 
'%s'",
@@ -191,28 +179,23 @@
                             $group
                           )
                     );
-        
+
         return (boolean)$this->db->affected_rows();
     } // end func delete
-    
-    
+
     function flush($group) {
-        
         $this->flushPreload();
-        
+
         if ($group) {
             $this->db->query(sprintf("DELETE FROM %s WHERE cachegroup = '%s'", 
$this->cache_table, $group));    
         } else {
             $this->db->query(sprintf("DELETE FROM %s", $this->cache_table));    
         }
-        
 
         return $this->db->affected_rows();
     } // end func flush
-    
-    
+
     function idExists($id, $group) {
-        
         $this->db->query(
                         sprintf("SELECT id FROM %s WHERE ID = '%s' AND cachegroup = 
'%s'", 
                             $this->cache_table,
@@ -220,13 +203,11 @@
                             $group
                         )   
                     );
-                            
+
         return (boolean)$this->db->nf();                         
     } // end func isExists
-    
-    
+
     function garbageCollection() {
-        
         $this->flushPreload();
 
         $this->db->query( 
@@ -235,8 +216,7 @@
                             time()
                         )
                     );
-                                 
-    } // end func garbageCollection
 
+    } // end func garbageCollection
 }
 ?>

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to