cvs: pear /HTTP_Header Header.php
| From: | Wolfram Kriesing | Date: | Fri, 17 Jan 2003 15:36:13 +0000 |
| Subject: | cvs: pear /HTTP_Header Header.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8343@lists.php.net to get a copy of this message | ||
cain Fri Jan 17 10:36:13 2003 EDT
Modified files:
/pear/HTTP_Header Header.php
Log:
- add method dateToTimestamp
Index: pear/HTTP_Header/Header.php
diff -u pear/HTTP_Header/Header.php:1.1.1.1 pear/HTTP_Header/Header.php:1.2
--- pear/HTTP_Header/Header.php:1.1.1.1 Fri Jan 17 03:57:24 2003
+++ pear/HTTP_Header/Header.php Fri Jan 17 10:36:13 2003
@@ -15,11 +15,11 @@
// | Authors: Wolfram Kriesing <wk@visionp.de> |
// | |
// +----------------------------------------------------------------------+//
-// $Id: Header.php,v 1.1.1.1 2003/01/17 08:57:24 cain Exp $
+// $Id: Header.php,v 1.2 2003/01/17 15:36:13 cain Exp $
require_once 'PEAR.php';
require_once 'HTTP.php';
-
+
define( HTTP_HEADER_STATUS_304 , '304 Not modified' );
@@ -29,7 +29,7 @@
/**
*
*/
-class HTTP_Header extends PEAR
+class HTTP_Header extends HTTP
{
/**
@@ -55,7 +55,7 @@
* @param
* @param mixed if the value is not given the default value depends on the $key
*/
- function setHeader( $key , $value=null )
+ function setHeader ( $key , $value=null )
{
//FIXXXME do sanity checks, i.e. if the headers are valid, etc.
// may be check protocol too (HTTP 1.0/1.1)
@@ -75,7 +75,7 @@
*
*
*/
- function getHeader( $key=null )
+ function getHeader ( $key=null )
{
if( $key==null )
return $this->_headers;
@@ -88,16 +88,20 @@
* @param array the keys that shall be sent, if the array is empty all
* the headers will be sent (all headers that you would get vie
$this->getHeader())
*/
- function sendHeaders( $keys=array() )
+ function sendHeaders ( $keys=array() )
{
- foreach( $this->_headers as $key=>$value ) {
+ foreach ( $this->_headers as $key=>$value ) {
header( "$key: $value" );
}
}
-
- function sendStatusCode( $code )
+
+ /**
+ *
+ *
+ */
+ function sendStatusCode ( $code )
{
- if( is_int($code) ) {
+ if ( is_int($code) ) {
// if the $code is an int we get the constant here
// is there an easier way to build a constant dynamically?
eval("\$code = HTTP_HEADER_STATUS_".$code.';');
@@ -105,8 +109,30 @@
header( 'HTTP/'.$this->_httpVersion.' '.$code );
}
-
-
+
+ /**
+ * converts dates like
+ * January, 17-Fri-03 14:49:43 GMT
+ * into a timestamp, strtotime doesnt do it :-(
+ */
+ function dateToTimestamp( $date )
+ {
+ $months =
array_flip(array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'));
+
+ preg_match( '~([^,]*),\s(\d+)-...-(\d+)\s(\d+):(\d+):(\d+).*~' , $date ,
$splitDate );
+ $splitDate[1] = substr($splitDate[1],0,3);
+ $timestamp = mktime( $splitDate[4] , $splitDate[5] , $splitDate[6] ,
$months[$splitDate[1]]+1 , $splitDate[2] , $splitDate[3] );
+
+ return $timestamp;
+// $dateTime = new I18N_DateTime('de');
+//print $dateTime->format($timestamp);
+/*
+ $dateTime = new I18N_DateTime('de');
+print $_SERVER['HTTP_IF_MODIFIED_SINCE'].'<br>';
+print strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']).'<br>';
+ print $dateTime->format(strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']));
+*/
+ }
}
?>