mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 07:53:39 +01:00
another shot at datetime.iso8601:
- accept both simple and extended format from input - output simple format, if the client sends a HTTP-header "isoDate: simple". This should maybe extended by another possibility, where the information is stored in the session on login. Then there is a good way for all clients, regardless of the use of any combination of Auth-headers, login/cookies and webservers.
This commit is contained in:
parent
ff4a0d24cc
commit
64120e723c
@ -23,12 +23,14 @@
|
|||||||
// contains useful functions for xmlrpc methods
|
// contains useful functions for xmlrpc methods
|
||||||
class xmlrpc_server_shared
|
class xmlrpc_server_shared
|
||||||
{
|
{
|
||||||
|
var $simpledate = False;
|
||||||
|
|
||||||
// convert a date-array or timestamp into a datetime.iso8601 string
|
// convert a date-array or timestamp into a datetime.iso8601 string
|
||||||
function date2iso8601($date)
|
function date2iso8601($date)
|
||||||
{
|
{
|
||||||
if (!is_array($date))
|
if (!is_array($date))
|
||||||
{
|
{
|
||||||
if(strstr($_SERVER['HTTP_USER_AGENT'],"vbXMLRPC"))
|
if($this->simpledate)
|
||||||
{
|
{
|
||||||
return date('Ymd\TH:i:s',$date);
|
return date('Ymd\TH:i:s',$date);
|
||||||
}
|
}
|
||||||
@ -36,7 +38,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$formatstring = "%04d-%02d-%02dT%02d:%02d:%02d";
|
$formatstring = "%04d-%02d-%02dT%02d:%02d:%02d";
|
||||||
if(strstr($_SERVER['HTTP_USER_AGENT'],"vbXMLRPC"))
|
if($this->simpledate)
|
||||||
{
|
{
|
||||||
$formatstring = "%04d%02d%02dT%02d:%02d:%02d";
|
$formatstring = "%04d%02d%02dT%02d:%02d:%02d";
|
||||||
}
|
}
|
||||||
@ -48,8 +50,22 @@
|
|||||||
// convert a datetime.iso8601 string into a datearray or timestamp
|
// convert a datetime.iso8601 string into a datearray or timestamp
|
||||||
function iso86012date($isodate,$timestamp=False)
|
function iso86012date($isodate,$timestamp=False)
|
||||||
{
|
{
|
||||||
if (($arr = split('[-:T]',$isodate)) && count($arr) == 6)
|
$arr = array();
|
||||||
|
|
||||||
|
if (ereg('^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})$',$isodate,$arr))
|
||||||
{
|
{
|
||||||
|
// $isodate is simple ISO8601, remove the difference between split and ereg
|
||||||
|
array_shift($arr);
|
||||||
|
}
|
||||||
|
elseif (($arr = split('[-:T]',$isodate)) && count($arr) == 6)
|
||||||
|
{
|
||||||
|
// $isodate is extended ISO8601, do nothing
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
foreach(array('year','month','mday','hour','min','sec') as $n => $name)
|
foreach(array('year','month','mday','hour','min','sec') as $n => $name)
|
||||||
{
|
{
|
||||||
$date[$name] = (int)$arr[$n];
|
$date[$name] = (int)$arr[$n];
|
||||||
@ -57,8 +73,6 @@
|
|||||||
return $timestamp ? mktime($date['hour'],$date['min'],$date['sec'],
|
return $timestamp ? mktime($date['hour'],$date['min'],$date['sec'],
|
||||||
$date['month'],$date['mday'],$date['year']) : $date;
|
$date['month'],$date['mday'],$date['year']) : $date;
|
||||||
}
|
}
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
// translate cat-ids to array with id-name pairs
|
// translate cat-ids to array with id-name pairs
|
||||||
function cats2xmlrpc($cats)
|
function cats2xmlrpc($cats)
|
||||||
@ -143,6 +157,10 @@
|
|||||||
}
|
}
|
||||||
return $cats;
|
return $cats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSimpleDate($enable=True) {
|
||||||
|
$this->simpledate = $enable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($GLOBALS['phpgw_info']['server']['xmlrpc_type']))
|
if(empty($GLOBALS['phpgw_info']['server']['xmlrpc_type']))
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
/* Note: this command only available under Apache */
|
/* Note: this command only available under Apache */
|
||||||
$headers = getallheaders();
|
$headers = getallheaders();
|
||||||
//print_r($headers);
|
//print_r($headers);
|
||||||
|
$isodate = $headers['isoDate'] ? $headers['isoDate'] : $headers['isodate'];
|
||||||
|
$isodate = ($isodate == 'simple') ? True : False;
|
||||||
|
$server->setSimpleDate($isodate);
|
||||||
$auth_header = $headers['Authorization'] ? $headers['Authorization'] : $headers['authorization'];
|
$auth_header = $headers['Authorization'] ? $headers['Authorization'] : $headers['authorization'];
|
||||||
|
|
||||||
if(eregi('Basic *([^ ]*)',$auth_header,$auth))
|
if(eregi('Basic *([^ ]*)',$auth_header,$auth))
|
||||||
|
Loading…
Reference in New Issue
Block a user