chregu Thu Mar 8 03:57:16 2001 EDT
Modified files:
/php4/pear/CacheContainer.php Output.php
/php4/pear/Cache/Container db.php file.php phplib.php
Log:
Introduced getExpiresAbsolute($expire) function, which translates
relative/human readable/unixtime expire-times in unixtime-format.
Index: php4/pear/Cache/Container.php
diff -u php4/pear/Cache/Container.php:1.6 php4/pear/Cache/Container.php:1.7
--- php4/pear/Cache/Container.php:1.6 Tue Mar 6 07:27:30 2001
+++ php4/pear/Cache/Container.php Thu Mar 8 03:57:15 2001
@@ -14,9 +14,10 @@
// +--+
// | Authors: Ulf Wendel [EMAIL PROTECTED] |
// | Sebastian Bergmann [EMAIL PROTECTED] |
+// | Christian Stocker [EMAIL PROTECTED] |
// +--+
//
-// $Id: Container.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
+// $Id: Container.php,v 1.7 2001/03/08 11:57:15 chregu Exp $
/**
* Common base class of all cache storage container.
@@ -36,7 +37,7 @@
* not recommended!
*
* @author Ulf Wendel [EMAIL PROTECTED]
-* @version $Id: Container.php,v 1.6 2001/03/06 15:27:30 sbergmann Exp $
+* @version $Id: Container.php,v 1.7 2001/03/08 11:57:15 chregu Exp $
* @package Cache
* @access public
* @abstract
@@ -372,5 +373,47 @@
else
return unserialize($data);
} // end func decode
+
+/**
+* Translates human readable/relative times in unixtime
+*
+* @var mixed can be in the following formats:
+* human readable : mmddhhmm[ss]] eg: 20010308095100
+* relative in seconds (1) : +xx eg: +10
+* relative in seconds (2) : x 946681200 eg: 10
+* absolute unixtime : x 2147483648 eg: 2147483648
+* see comments in code for details
+*/
+
+function getExpiresAbsolute($expires)
+
+{
+if (!$expires)
+return 0;
+//for api-compatibility, one has not to provide a "+",
+// if integer is 946681200 (= Jan 01 2000 00:00:00)
+if ('+' == $expires[0] || $expires 946681200)
+{
+return(time() + $expires);
+}
+//if integer is 1000 (= in 3140 years),
+// it must be an absolut unixtime
+// (since the "human readable" definition asks for a higher number)
+elseif ($expires 1000)
+{
+return $expires;
+}
+// else it's "human readable";
+else
+{
+$year = substr($expires, 0, 4);
+$month = substr($expires, 4, 2);
+$day = substr($expires, 6, 2);
+$hour = substr($expires, 8, 2);
+$minute = substr($expires, 10, 2);
+$second = substr($expires, 12, 2);
+return mktime($hour, $minute, $second, $month, $day, $year);
+}
+}
}
?
Index: php4/pear/Cache/Output.php
diff -u php4/pear/Cache/Output.php:1.9 php4/pear/Cache/Output.php:1.10
--- php4/pear/Cache/Output.php:1.9 Tue Mar 6 07:27:30 2001
+++ php4/pear/Cache/Output.php Thu Mar 8 03:57:15 2001
@@ -17,7 +17,7 @@
// | Vinai Kopp [EMAIL PROTECTED] |
// +--+
//
-// $Id: Output.php,v 1.9 2001/03/06 15:27:30 sbergmann Exp $
+// $Id: Output.php,v 1.10 2001/03/08 11:57:15 chregu Exp $
require_once 'Cache.php';
@@ -129,11 +129,11 @@
/*
* 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
+* @parammixed lifetime of the cached data in seconds - 0 for endless. More
+formats available. see Container::getExpiresAbsolute()
* @paramstring additional userdefined data
* @return string cached output
* @access public
-* @see endPrint(), endGet()
+* @see endPrint(), endGet(), Container::getExpiresAbsolute()
*/
function end($expire = 0, $userdata = "") {
$content = ob_get_contents();
Index: php4/pear/Cache/Container/db.php
diff -u php4/pear/Cache/Container/db.php:1.7 php4/pear/Cache/Container/db.php:1.8
--- php4/pear/Cache/Container/db.php:1.7Tue Mar 6 07:27:30 2001
+++ php4/pear/Cache/Container/db.phpThu Mar 8 03:57:16 2001
@@ -17,7 +17,7 @@
// | Chuck Hagenbuch [EMAIL PROTECTED] |
// +--+
//
-// $Id: db.php,v 1.7 2001/03/06 15:27:30 sbergmann Exp $
+// $Id: db.php,v 1.8 2001/03/08 11:57:16 chregu Exp $
require_once 'DB.php';
require_once 'Cache/Container.php';
@@ -52,7 +52,7 @@
* )
*
* @author Sebastian Bergmann [EMAIL