forked from extern/egroupware
another shot at datetime.iso8601:
- accept both simple and extended format from input - output simple format, if + either the client is vbXMLRPC + or the client sends a HTTP-header "isoDate: simple"
This commit is contained in:
parent
22bac121d5
commit
dd2984573c
@ -22,12 +22,14 @@
|
||||
// contains useful functions for xmlrpc methods
|
||||
class xmlrpc_server_shared
|
||||
{
|
||||
var $simpledate = False;
|
||||
|
||||
// convert a date-array or timestamp into a datetime.iso8601 string
|
||||
function date2iso8601($date)
|
||||
{
|
||||
if (!is_array($date))
|
||||
{
|
||||
if(strstr($_SERVER['HTTP_USER_AGENT'],"vbXMLRPC"))
|
||||
if($this->simpledate)
|
||||
{
|
||||
return date('Ymd\TH:i:s',$date);
|
||||
}
|
||||
@ -35,7 +37,7 @@
|
||||
}
|
||||
|
||||
$formatstring = "%04d-%02d-%02dT%02d:%02d:%02d";
|
||||
if(strstr($_SERVER['HTTP_USER_AGENT'],"vbXMLRPC"))
|
||||
if($this->simpledate)
|
||||
{
|
||||
$formatstring = "%04d%02d%02dT%02d:%02d:%02d";
|
||||
}
|
||||
@ -47,8 +49,22 @@
|
||||
// convert a datetime.iso8601 string into a datearray or timestamp
|
||||
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)
|
||||
{
|
||||
$date[$name] = (int)$arr[$n];
|
||||
@ -56,8 +72,6 @@
|
||||
return $timestamp ? mktime($date['hour'],$date['min'],$date['sec'],
|
||||
$date['month'],$date['mday'],$date['year']) : $date;
|
||||
}
|
||||
return False;
|
||||
}
|
||||
|
||||
// translate cat-ids to array with id-name pairs
|
||||
function cats2xmlrpc($cats)
|
||||
@ -142,6 +156,10 @@
|
||||
}
|
||||
return $cats;
|
||||
}
|
||||
|
||||
function setSimpleDate($enable=True) {
|
||||
$this->simpledate = $enable;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($GLOBALS['phpgw_info']['server']['xmlrpc_type']))
|
||||
|
49
xmlrpc.php
Normal file
49
xmlrpc.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* eGroupWare xmlrpc server *
|
||||
* http://www.egroupware.org *
|
||||
* This file written by Miles Lott <milos@groupwhere.org> *
|
||||
* -------------------------------------------- *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU General Public License as published by the *
|
||||
* Free Software Foundation; either version 2 of the License, or (at your *
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
/* $Source$ */
|
||||
|
||||
$GLOBALS['phpgw_info'] = array();
|
||||
$GLOBALS['phpgw_info']['flags'] = array(
|
||||
'currentapp' => 'login',
|
||||
'noheader' => True,
|
||||
'disable_Template_class' => True
|
||||
);
|
||||
include('header.inc.php');
|
||||
|
||||
$server = CreateObject('phpgwapi.xmlrpc_server');
|
||||
/* uncomment here if you want to show all of the testing functions for compatibility */
|
||||
//include(PHPGW_API_INC . '/xmlrpc.interop.php');
|
||||
|
||||
/* Note: this command only available under Apache */
|
||||
$headers = getallheaders();
|
||||
//print_r($headers);
|
||||
$isodate = $headers['isoDate'] ? $headers['isoDate'] : $headers['isodate'];
|
||||
$isodate = ($isodate == 'simple' || strstr($_SERVER['HTTP_USER_AGENT'],"vbXMLRPC")) ? True : False;
|
||||
$server->setSimpleDate($isodate);
|
||||
$auth_header = $headers['Authorization'] ? $headers['Authorization'] : $headers['authorization'];
|
||||
|
||||
if(eregi('Basic *([^ ]*)',$auth_header,$auth))
|
||||
{
|
||||
list($sessionid,$kp3) = explode(':',base64_decode($auth[1]));
|
||||
//echo "auth='$auth[1]', sessionid='$sessionid', kp3='$kp3'\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sessionid = get_var('sessionid',array('COOKIE','GET'));
|
||||
$kp3 = get_var('kp3',array('COOKIE','GET'));
|
||||
}
|
||||
$server->authed = $GLOBALS['phpgw']->session->verify($sessionid,$kp3);
|
||||
|
||||
$server->service($_SERVER['HTTP_RAW_POST_DATA']);
|
||||
?>
|
Loading…
Reference in New Issue
Block a user