[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-16 Thread Ulf Wendel

uw  Fri Mar 16 00:40:40 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Usage example changes should answer peoples FAQs.
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.12 php4/pear/Cache/Output.php:1.13
--- php4/pear/Cache/Output.php:1.12 Thu Mar 15 23:58:35 2001
+++ php4/pear/Cache/Output.php  Fri Mar 16 00:40:39 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.12 2001/03/16 07:58:35 sbergmann Exp $
+// $Id: Output.php,v 1.13 2001/03/16 08:40:39 uw Exp $
 
 require_once 'Cache.php';
 
@@ -36,10 +36,10 @@
 *
 *  // place this somewhere in a central config file
 *  define(CACHE_STORAGE_CLASS, "file");
-* // file storage needs a dir to put the cache files
-* define(CACHE_DIR, "/var/tmp/");
+*  // file storage needs a dir to put the cache files
+*  define(CACHE_DIR, "/var/tmp/");
 *
-* // get a cache object
+*  // get a cache object
 *  $cache = new Cache_Output(CACHE_STORAGE_CLASS, array("cache_dir" = CACHE_DIR));
 *
 *  // compute the unique handle.
@@ -50,12 +50,20 @@
 *  //   "post" = $HTTP_POST_VAS"
 *  //   "cookie"  = $HTTP_COOKIE_VARS
 *  //);
+ Output.php
+*  // But be warned, using all GET or POST Variables as a seed
+*  // can be used for a DOS attack. Calling 
+http://www.example.com/example.php?whatever
+*  // where whatever is a random text might be used to flood your cache.
 *  $cache_handle = $cache-generateID($REQUEST_URI);
+===
+*  $cache_handle = $cache-generateID($REQUEST_URI);
+ 1.12
 * 
 *  // now the magic happens: if cached call die() 
 *  // to end the time consumptiong script script execution and use the cached value!
 *  if ($content = $cache-start($cache_handle)) {
 * print $content;
+* print "pCache hit/p";
 * die();
 *  }
 *  
@@ -63,17 +71,27 @@
 * 
 *  // store the output of the cache into the cache and print the output.
 *  print $cache-end();
+*  print "pCache miss, stored using the ID '$id'./p";
+* 
+*  If you do not want to cache a whole page - no problem:
 * 
-* If you do not want to cache a whole page - no problem:
+*  if (!($content = $cache-start($cache_handle))) {
+* // do the computation here
+* print $cache-end()
+*  } else {
+ print $content;
+*  }
 * 
-* if (!($content = $cache-start($cache_handle))) {
-*// do the computation here
-*print $cache-end()
-* } else {
-print $content;
-* }
+*  If you need an example script check the (auto_)prepend and (auto_)append 
+*  files of my homepage:
+* 
+*http://www.ulf-wendel.de/php/show_source.php?file=prepend
+*http://www.ulf-wendel.de/php/show_source.php?file=append
+*
+*  Don't know how to use it or you need profiling informations?`
+*  Ask Christian he was patient with me and he'll be so with your questions ;).
 *
-* Have fun!
+*  Have fun!
 * 
 * @authors  Ulf Wendel [EMAIL PROTECTED]
 * @version  $ID: $



-- 
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]




[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-16 Thread Egon Schmid

eschmid Fri Mar 16 00:50:39 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Ulf, you have a conflict.
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.13 php4/pear/Cache/Output.php:1.14
--- php4/pear/Cache/Output.php:1.13 Fri Mar 16 00:40:39 2001
+++ php4/pear/Cache/Output.php  Fri Mar 16 00:50:39 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.13 2001/03/16 08:40:39 uw Exp $
+// $Id: Output.php,v 1.14 2001/03/16 08:50:39 eschmid Exp $
 
 require_once 'Cache.php';
 
@@ -50,14 +50,10 @@
 *  //   "post" = $HTTP_POST_VAS"
 *  //   "cookie"  = $HTTP_COOKIE_VARS
 *  //);
- Output.php
 *  // But be warned, using all GET or POST Variables as a seed
 *  // can be used for a DOS attack. Calling 
http://www.example.com/example.php?whatever
 *  // where whatever is a random text might be used to flood your cache.
 *  $cache_handle = $cache-generateID($REQUEST_URI);
-===
-*  $cache_handle = $cache-generateID($REQUEST_URI);
- 1.12
 * 
 *  // now the magic happens: if cached call die() 
 *  // to end the time consumptiong script script execution and use the cached value!



-- 
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]




[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-15 Thread Sebastian Bergmann

sbergmann   Thu Mar 15 23:58:35 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Fix the example.
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.11 php4/pear/Cache/Output.php:1.12
--- php4/pear/Cache/Output.php:1.11 Sat Mar 10 23:46:58 2001
+++ php4/pear/Cache/Output.php  Thu Mar 15 23:58:35 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.11 2001/03/11 07:46:58 sbergmann Exp $
+// $Id: Output.php,v 1.12 2001/03/16 07:58:35 sbergmann Exp $
 
 require_once 'Cache.php';
 
@@ -50,7 +50,7 @@
 *  //   "post" = $HTTP_POST_VAS"
 *  //   "cookie"  = $HTTP_COOKIE_VARS
 *  //);
-*  $cache_handle = $REQUEST_URI;
+*  $cache_handle = $cache-generateID($REQUEST_URI);
 * 
 *  // now the magic happens: if cached call die() 
 *  // to end the time consumptiong script script execution and use the cached value!



-- 
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]




[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-10 Thread Sebastian Bergmann

sbergmann   Sat Mar 10 23:46:58 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Updated example.
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.10 php4/pear/Cache/Output.php:1.11
--- php4/pear/Cache/Output.php:1.10 Thu Mar  8 03:57:15 2001
+++ php4/pear/Cache/Output.php  Sat Mar 10 23:46:58 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.10 2001/03/08 11:57:15 chregu Exp $
+// $Id: Output.php,v 1.11 2001/03/11 07:46:58 sbergmann Exp $
 
 require_once 'Cache.php';
 
@@ -35,7 +35,7 @@
 * Usage example:
 *
 *  // place this somewhere in a central config file
-*  define(CACHE_STORAGE_CLASS, "cache_container_file");
+*  define(CACHE_STORAGE_CLASS, "file");
 * // file storage needs a dir to put the cache files
 * define(CACHE_DIR, "/var/tmp/");
 *



-- 
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]




[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-03 Thread Ulf Wendel

uw  Sat Mar  3 11:19:25 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Made Output use the new features.
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.7 php4/pear/Cache/Output.php:1.8
--- php4/pear/Cache/Output.php:1.7  Fri Mar  2 08:16:00 2001
+++ php4/pear/Cache/Output.php  Sat Mar  3 11:19:25 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.7 2001/03/02 16:16:00 sbergmann Exp $
+// $Id: Output.php,v 1.8 2001/03/03 19:19:25 uw Exp $
 
 require_once 'Cache.php';
 
@@ -90,25 +90,35 @@
 */
 var $output_id = "";
 
+/**
+* Group passed to start()
+* 
+* @var  string  
+* @see  start(), end()
+*/
+var $output_group = "";
 
+
 /**
 * starts the output buffering and returns an empty string or returns the cached 
output from the cache.
 * 
 * @paramstring  dataset ID
+* @paramstring  cache group
 * @return   string  
 * @access   public
 */
-function start($id) {
+function start($id, $group = "default") {
 if ($this-no_cache)
 return "";
 
 // this is already cached return it from the cache so that the user 
 // can use the cache content and stop script execution
-if ($content = $this-get($id))
+if ($content = $this-get($id, $group))
 return $content;
 
 // 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();
@@ -122,18 +132,19 @@
 * Stores the content of the output buffer into the cache and returns the content.
 *
 * @paraminteger lifetime of the cached data in seconds - 0 for endless
+* @paramstring  additional userdefined data
 * @return   string  cached output
 * @access   public
 * @see  endPrint(), endGet()
 */
-function end($expire = 0) {
+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-container-save($this-output_id, $content, $expire, 
+$this-output_group, $userdata);
 
 return $content;
 } // end func end()
@@ -142,11 +153,11 @@
 /**
 * Stores the content of the output buffer into the cache and prints the content.
 *
-* @brother  end(), endGet()
+* @brother  end()
 */
-function endPrint($expire = 0) {
+function endPrint($expire = 0, $userdata = "") {
 
-print $this-end($expire);  
+print $this-end($expire, $userdata);  
 
 } // end func endPrint
 
@@ -168,10 +179,11 @@
 ob_end_clean();
 
 $this-output_id = "";
+$this-output_group = "";
 
 return $content;
 } // end func endGet
-
 
+
 } // end class output
 ?



-- 
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]




[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-02 Thread Sebastian Bergmann

sbergmann   Fri Mar  2 02:39:37 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Fixed typo.
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.2 php4/pear/Cache/Output.php:1.3
--- php4/pear/Cache/Output.php:1.2  Thu Mar  1 11:38:04 2001
+++ php4/pear/Cache/Output.php  Fri Mar  2 02:39:36 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.2 2001/03/01 19:38:04 sbergmann Exp $
+// $Id: Output.php,v 1.3 2001/03/02 10:39:36 sbergmann Exp $
 
 require_once'Cache.php';
 
@@ -124,7 +124,7 @@
 */
 function end($expire = 0) {
 
-$content = ob_get_content();
+$content = ob_get_contents();
 ob_end_clean();
 
 // store in the cache



-- 
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]




[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-02 Thread Christian Stocker

chregu  Fri Mar  2 06:46:01 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Wrong order of Parameters in $this-container-save();
  and $this-cache_id instead of $this-id on the same line
  
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.3 php4/pear/Cache/Output.php:1.4
--- php4/pear/Cache/Output.php:1.3  Fri Mar  2 02:39:36 2001
+++ php4/pear/Cache/Output.php  Fri Mar  2 06:46:01 2001
@@ -17,7 +17,7 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.3 2001/03/02 10:39:36 sbergmann Exp $
+// $Id: Output.php,v 1.4 2001/03/02 14:46:01 chregu Exp $
 
 require_once'Cache.php';
 
@@ -98,12 +98,12 @@
 function start($id) {
 if ($this-no_cache)
 return "";
-
-// this is already cached return it from the cache so that the user 
+
+// this is already cached return it from the cache so that the user
 // can use the cache content and stop script execution
 if ($content = $this-get($id))
 return $content;
-
+
 // remember some data to be able to fill the cache on calling end()
 $this-cache_id = $id;
 
@@ -113,7 +113,7 @@
 
 return "";
 } // end func start
-
+
 /*
 * Stores the content of the output buffer into the cache and returns the content.
 *
@@ -129,8 +129,8 @@
 
 // store in the cache
 if (!$this-no_cache)
-$this-container-save($content, $this-id, $expire);
-
+$this-container-save($this-cache_id,$content,  $expire);
+
 return $content;
 } // end func end()
 
@@ -141,10 +141,10 @@
 */
 function endPrint($expire = 0) {
 
-print $this-end($expire);  
+print $this-end($expire);
 
 } // end func endPrint
-
+
 
 } // end class output
 ?



-- 
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]




[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-02 Thread Ulf Wendel

uw  Fri Mar  2 07:17:23 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  ... must forgot this commit - endGet(), $cache_id = $output_id
  
   - added endGet() which returns the output buffering content 
   - changed $cache_id to $output_id seems to be a better name as the class 
 is named Cache_Output
  
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.4 php4/pear/Cache/Output.php:1.5
--- php4/pear/Cache/Output.php:1.4  Fri Mar  2 06:46:01 2001
+++ php4/pear/Cache/Output.php  Fri Mar  2 07:17:22 2001
@@ -17,9 +17,9 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.4 2001/03/02 14:46:01 chregu Exp $
+// $Id: Output.php,v 1.5 2001/03/02 15:17:22 uw Exp $
 
-require_once'Cache.php';
+require_once SHOP_INCLUDE_DIR . 'Cache/Cache.php';
 
 /**
 * Class to cache the output of a script using the output buffering functions
@@ -36,9 +36,11 @@
 *
 *  // place this somewhere in a central config file
 *  define(CACHE_STORAGE_CLASS, "cache_container_file");
+* // file storage needs a dir to put the cache files
+* define(CACHE_DIR, "/var/tmp/");
 *
 * // get a cache object
-*  $cache = new Cache_Output(CACHE_STORAGE_CLASS)
+*  $cache = new Cache_Output(CACHE_STORAGE_CLASS, array("cache_dir" = CACHE_DIR));
 *
 *  // compute the unique handle.
 *  // if your script depends on Cookie and HTTP Post data as well 
@@ -86,8 +88,9 @@
 * @var  string
 * @see  start(), end()
 */
-var $cache_id = "";
+var $output_id = "";
 
+
 /**
 * starts the output buffering and returns an empty string or returns the cached 
output from the cache.
 * 
@@ -98,14 +101,14 @@
 function start($id) {
 if ($this-no_cache)
 return "";
-
-// this is already cached return it from the cache so that the user
+
+// this is already cached return it from the cache so that the user 
 // can use the cache content and stop script execution
 if ($content = $this-get($id))
 return $content;
-
+
 // remember some data to be able to fill the cache on calling end()
-$this-cache_id = $id;
+$this-output_id = $id;
 
 // WARNING: we need the output buffer - possible clashes
 ob_start();
@@ -113,6 +116,7 @@
 
 return "";
 } // end func start
+
 
 /*
 * Stores the content of the output buffer into the cache and returns the content.
@@ -120,7 +124,7 @@
 * @paraminteger lifetime of the cached data in seconds - 0 for endless
 * @return   string  cached output
 * @access   public
-* @see  endPrint()
+* @see  endPrint(), endGet()
 */
 function end($expire = 0) {
 
@@ -129,22 +133,45 @@
 
 // store in the cache
 if (!$this-no_cache)
-$this-container-save($this-cache_id,$content,  $expire);
-
+$this-container-save($this-output_id, $content, $expire);
+
 return $content;
 } // end func end()
 
+
 /**
 * Stores the content of the output buffer into the cache and prints the content.
 *
-* @brother  end()
+* @brother  end(), endGet()
 */
 function endPrint($expire = 0) {
 
-print $this-end($expire);
+print $this-end($expire);  
 
 } // end func endPrint
 
 
+/**
+* Returns the content of the output buffer but does not store it into the cache.
+*
+* Use this method if the content of your script is markup (XML) 
+* that has to be parsed/converted (XSLT) before you can output 
+* and store it into the cache using save().
+*
+* @return   string
+* @access   public
+* @see  endPrint(), end()
+*/
+function endGet() {
+
+$content = ob_get_contents();
+ob_end_clean();
+
+$this-output_id = "";
+
+return $content;
+} // end func endGet
+
+
 } // end class output
-?
\ No newline at end of file
+?



-- 
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]




[PHP-CVS] cvs: php4 /pear/Cache Output.php

2001-03-02 Thread Ulf Wendel

uw  Fri Mar  2 07:18:39 2001 EDT

  Modified files:  
/php4/pear/CacheOutput.php 
  Log:
  Sorry, removed my local settings. Will take some sleep before commiting again!
  
  
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.5 php4/pear/Cache/Output.php:1.6
--- php4/pear/Cache/Output.php:1.5  Fri Mar  2 07:17:22 2001
+++ php4/pear/Cache/Output.php  Fri Mar  2 07:18:39 2001
@@ -17,9 +17,9 @@
 // |  Vinai Kopp [EMAIL PROTECTED]   |
 // +--+
 //
-// $Id: Output.php,v 1.5 2001/03/02 15:17:22 uw Exp $
+// $Id: Output.php,v 1.6 2001/03/02 15:18:39 uw Exp $
 
-require_once SHOP_INCLUDE_DIR . 'Cache/Cache.php';
+require_once 'Cache/Cache.php';
 
 /**
 * Class to cache the output of a script using the output buffering functions



-- 
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]