2001-08-08 01:00:28 +02:00
|
|
|
<?php
|
2001-08-30 02:29:55 +02:00
|
|
|
// Copyright (c) 1999,2000,2001 Edd Dumbill.
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions
|
|
|
|
// are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
//
|
|
|
|
// * Neither the name of the "XML-RPC for PHP" nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
// REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
// OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2001-12-03 22:49:14 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
/* BEGIN server class */
|
|
|
|
class xmlrpc_server
|
|
|
|
{
|
|
|
|
var $dmap = array();
|
2001-08-23 08:47:50 +02:00
|
|
|
var $authed = False;
|
2001-08-26 20:24:48 +02:00
|
|
|
var $req_array = array();
|
|
|
|
var $resp_struct = array();
|
2003-08-28 16:31:11 +02:00
|
|
|
var $debug = False;
|
|
|
|
var $method_requested;
|
2003-10-21 23:05:23 +02:00
|
|
|
var $log = False; //'/tmp/xmlrpc.log';
|
2001-08-08 01:00:28 +02:00
|
|
|
|
2001-08-19 03:18:38 +02:00
|
|
|
function xmlrpc_server($dispMap='', $serviceNow=0)
|
2001-08-08 01:00:28 +02:00
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
global $HTTP_RAW_POST_DATA;
|
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
// dispMap is a despatch array of methods
|
|
|
|
// mapped to function names and signatures
|
|
|
|
// if a method
|
|
|
|
// doesn't appear in the map then an unknown
|
|
|
|
// method error is generated
|
2001-08-19 03:18:38 +02:00
|
|
|
if($dispMap)
|
2001-08-08 01:00:28 +02:00
|
|
|
{
|
2001-08-19 03:18:38 +02:00
|
|
|
$this->dmap = $dispMap;
|
|
|
|
if ($serviceNow)
|
|
|
|
{
|
|
|
|
$this->service();
|
|
|
|
}
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function serializeDebug()
|
|
|
|
{
|
2001-08-09 04:54:56 +02:00
|
|
|
if ($GLOBALS['_xmlrpc_debuginfo'] != '')
|
2001-08-08 01:00:28 +02:00
|
|
|
{
|
2001-08-09 04:54:56 +02:00
|
|
|
return "<!-- DEBUG INFO:\n\n" . $GLOBALS['_xmlrpc_debuginfo'] . "\n-->\n";
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function service()
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
global $HTTP_RAW_POST_DATA;
|
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
$r = $this->parseRequest();
|
2003-10-26 19:37:45 +01:00
|
|
|
if ($r == False)
|
2003-10-21 23:05:23 +02:00
|
|
|
{
|
|
|
|
header('WWW-Authenticate: Basic realm="eGroupWare xmlrpc"');
|
|
|
|
header('HTTP/1.0 401 Unauthorized');
|
|
|
|
// for the log:
|
|
|
|
$payload = "WWW-Authenticate: Basic realm=\"eGroupWare xmlrpc\"\nHTTP/1.0 401 Unauthorized\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$payload = "<?xml version=\"1.0\"?>\n" . $this->serializeDebug() . $r->serialize();
|
|
|
|
Header("Content-type: text/xml\r\nContent-length: " . strlen($payload));
|
2003-10-26 19:37:45 +01:00
|
|
|
echo $GLOBALS['phpgw']->translation->convert($payload,$GLOBALS['phpgw']->translation->charset(),'utf-8');
|
2003-10-21 23:05:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->log)
|
|
|
|
{
|
|
|
|
$fp = fopen($this->log,'a+');
|
|
|
|
fwrite($fp,"\n\n".date('Y-m-d H:i:s')." authorized=".
|
|
|
|
($this->authed?$GLOBALS['phpgw_info']['user']['account_lid']:'False').
|
|
|
|
", method='$this->last_method'\n");
|
|
|
|
fwrite($fp,"==== GOT ============================\n".$HTTP_RAW_POST_DATA.
|
|
|
|
"\n==== RETURNED =======================\n");
|
|
|
|
fputs($fp,$payload);
|
|
|
|
fclose($fp);
|
|
|
|
}
|
2003-08-28 16:31:11 +02:00
|
|
|
|
|
|
|
if ($this->debug)
|
|
|
|
{
|
|
|
|
$this->echoInput();
|
|
|
|
|
|
|
|
$fp = fopen('/tmp/xmlrpc_debug.out','w');
|
|
|
|
fputs($fp,$payload);
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
|
|
|
|
2001-08-19 03:18:38 +02:00
|
|
|
/*
|
|
|
|
add a method to the dispatch map
|
|
|
|
*/
|
|
|
|
function add_to_map($methodname,$function,$sig,$doc)
|
|
|
|
{
|
|
|
|
$this->dmap[$methodname] = array(
|
|
|
|
'function' => $function,
|
|
|
|
'signature' => $sig,
|
|
|
|
'docstring' => $doc
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
function verifySignature($in, $sig)
|
|
|
|
{
|
|
|
|
for($i=0; $i<sizeof($sig); $i++)
|
|
|
|
{
|
|
|
|
// check each possible signature in turn
|
|
|
|
$cursig = $sig[$i];
|
|
|
|
if (sizeof($cursig) == $in->getNumParams()+1)
|
|
|
|
{
|
|
|
|
$itsOK = 1;
|
|
|
|
for($n=0; $n<$in->getNumParams(); $n++)
|
|
|
|
{
|
|
|
|
$p = $in->getParam($n);
|
|
|
|
// print "<!-- $p -->\n";
|
|
|
|
if ($p->kindOf() == 'scalar')
|
|
|
|
{
|
|
|
|
$pt = $p->scalartyp();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$pt = $p->kindOf();
|
|
|
|
}
|
|
|
|
// $n+1 as first type of sig is return type
|
|
|
|
if ($pt != $cursig[$n+1])
|
|
|
|
{
|
|
|
|
$itsOK = 0;
|
|
|
|
$pno = $n+1;
|
|
|
|
$wanted = $cursig[$n+1];
|
|
|
|
$got = $pt;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($itsOK)
|
|
|
|
{
|
|
|
|
return array(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-20 18:33:26 +02:00
|
|
|
return array(0, "Wanted $wanted, got $got at param $pno)");
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
|
|
|
|
2001-08-26 17:17:24 +02:00
|
|
|
function reqtoarray($_req,$recursed=False)
|
2001-08-26 06:30:06 +02:00
|
|
|
{
|
2001-08-26 17:17:24 +02:00
|
|
|
switch(gettype($_req))
|
2001-08-26 06:30:06 +02:00
|
|
|
{
|
2001-08-26 17:17:24 +02:00
|
|
|
case 'object':
|
|
|
|
if($recursed)
|
|
|
|
{
|
|
|
|
return $_req->getval();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-26 20:24:48 +02:00
|
|
|
$this->req_array = $_req->getval();
|
2001-08-26 17:17:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'array':
|
|
|
|
@reset($_req);
|
2001-08-26 20:24:48 +02:00
|
|
|
$ele = array();
|
2001-08-26 17:17:24 +02:00
|
|
|
while(list($key,$val) = @each($_req))
|
|
|
|
{
|
2001-08-26 20:24:48 +02:00
|
|
|
if($recursed)
|
|
|
|
{
|
|
|
|
$ele[$key] = $this->reqtoarray($val,True);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->req_array[$key] = $this->reqtoarray($val,True);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($recursed)
|
|
|
|
{
|
|
|
|
return $ele;
|
2001-08-26 17:17:24 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'string':
|
2001-08-26 20:24:48 +02:00
|
|
|
case 'integer':
|
2001-08-26 17:17:24 +02:00
|
|
|
if($recursed)
|
|
|
|
{
|
|
|
|
return $_req;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->req_array[] = $_req;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-25 18:08:05 +02:00
|
|
|
function build_resp($_res)
|
2001-08-26 17:17:24 +02:00
|
|
|
{
|
2001-11-13 22:03:24 +01:00
|
|
|
if (is_array($_res))
|
2001-08-26 17:17:24 +02:00
|
|
|
{
|
2003-10-25 18:08:05 +02:00
|
|
|
foreach($_res as $key => $val)
|
2001-08-27 05:09:14 +02:00
|
|
|
{
|
|
|
|
$ele[$key] = $this->build_resp($val,True);
|
|
|
|
}
|
2003-10-25 18:08:05 +02:00
|
|
|
return CreateObject('phpgwapi.xmlrpcval',$ele,'struct');
|
2001-08-27 05:09:14 +02:00
|
|
|
}
|
2003-10-25 18:08:05 +02:00
|
|
|
$_type = (is_integer($_res) ? 'int' : gettype($_res));
|
|
|
|
|
2003-10-25 18:43:23 +02:00
|
|
|
if ($_type == string && ereg('^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$',$_res))
|
2001-08-27 05:09:14 +02:00
|
|
|
{
|
2003-10-25 18:08:05 +02:00
|
|
|
$_type = 'dateTime.iso8601';
|
|
|
|
}
|
|
|
|
// Passing an integer of 0 to the xmlrpcval constructor results in the value being lost. (jengo)
|
|
|
|
if ($_type == 'int' && $_res == 0)
|
|
|
|
{
|
|
|
|
return CreateObject('phpgwapi.xmlrpcval','0',$_type);
|
2001-08-26 06:30:06 +02:00
|
|
|
}
|
2003-10-25 18:08:05 +02:00
|
|
|
return CreateObject('phpgwapi.xmlrpcval',$_res,$_type);
|
2001-08-26 06:30:06 +02:00
|
|
|
}
|
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
function parseRequest($data='')
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
global $HTTP_RAW_POST_DATA;
|
2003-10-26 19:37:45 +01:00
|
|
|
|
|
|
|
$r = False;
|
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
if ($data == '')
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
$data = $HTTP_RAW_POST_DATA;
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
2001-08-09 04:54:56 +02:00
|
|
|
$parser = xml_parser_create($GLOBALS['xmlrpc_defencoding']);
|
2003-10-26 19:37:45 +01:00
|
|
|
|
2001-08-09 04:54:56 +02:00
|
|
|
$GLOBALS['_xh'][$parser] = array();
|
|
|
|
$GLOBALS['_xh'][$parser]['st'] = '';
|
2003-10-25 18:08:05 +02:00
|
|
|
$GLOBALS['_xh'][$parser]['cm'] = 0;
|
2003-10-26 19:37:45 +01:00
|
|
|
$GLOBALS['_xh'][$parser]['isf'] = 0;
|
2001-08-09 04:54:56 +02:00
|
|
|
$GLOBALS['_xh'][$parser]['params'] = array();
|
|
|
|
$GLOBALS['_xh'][$parser]['method'] = '';
|
2001-08-08 01:00:28 +02:00
|
|
|
|
|
|
|
// decompose incoming XML into request structure
|
|
|
|
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
|
|
|
|
xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee');
|
|
|
|
xml_set_character_data_handler($parser, 'xmlrpc_cd');
|
|
|
|
xml_set_default_handler($parser, 'xmlrpc_dh');
|
|
|
|
if (!xml_parse($parser, $data, 1))
|
|
|
|
{
|
|
|
|
// return XML error as a faultCode
|
2001-12-06 16:51:06 +01:00
|
|
|
$r = CreateObject('phpgwapi.xmlrpcresp','',
|
2001-08-09 04:54:56 +02:00
|
|
|
$GLOBALS['xmlrpcerrxml'] + xml_get_error_code($parser),
|
2001-08-08 01:00:28 +02:00
|
|
|
sprintf('XML error: %s at line %d',
|
|
|
|
xml_error_string(xml_get_error_code($parser)),
|
|
|
|
xml_get_current_line_number($parser))
|
|
|
|
);
|
|
|
|
xml_parser_free($parser);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xml_parser_free($parser);
|
2001-08-09 04:54:56 +02:00
|
|
|
$m = CreateObject('phpgwapi.xmlrpcmsg',$GLOBALS['_xh'][$parser]['method']);
|
2001-08-08 01:00:28 +02:00
|
|
|
// now add parameters in
|
2001-12-03 22:49:14 +01:00
|
|
|
$plist = '';
|
2001-08-09 04:54:56 +02:00
|
|
|
for($i=0; $i<sizeof($GLOBALS['_xh'][$parser]['params']); $i++)
|
2001-08-08 01:00:28 +02:00
|
|
|
{
|
2001-08-09 04:54:56 +02:00
|
|
|
//print "<!-- " . $GLOBALS['_xh'][$parser]['params'][$i]. "-->\n";
|
|
|
|
$plist .= "$i - " . $GLOBALS['_xh'][$parser]['params'][$i]. " \n";
|
|
|
|
$code = '$m->addParam(' . $GLOBALS['_xh'][$parser]['params'][$i] . ');';
|
2003-12-20 19:29:02 +01:00
|
|
|
$code = str_replace(',,',",'',",$code);
|
2001-08-08 01:00:28 +02:00
|
|
|
eval($code);
|
|
|
|
}
|
|
|
|
// uncomment this to really see what the server's getting!
|
|
|
|
// xmlrpc_debugmsg($plist);
|
|
|
|
// now to deal with the method
|
2001-11-30 01:48:25 +01:00
|
|
|
$methName = $GLOBALS['_xh'][$parser]['method'];
|
|
|
|
$_methName = $GLOBALS['_xh'][$parser]['method'];
|
2003-10-21 23:05:23 +02:00
|
|
|
$this->last_method = $methName;
|
2001-11-30 01:48:25 +01:00
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
if (ereg("^system\.", $methName))
|
|
|
|
{
|
2001-08-09 04:54:56 +02:00
|
|
|
$dmap = $GLOBALS['_xmlrpcs_dmap'];
|
|
|
|
$sysCall=1;
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-09 04:54:56 +02:00
|
|
|
$dmap = $this->dmap;
|
|
|
|
$sysCall=0;
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
2001-11-30 01:48:25 +01:00
|
|
|
|
|
|
|
if (!isset($dmap[$methName]['function']))
|
2001-08-09 01:28:03 +02:00
|
|
|
{
|
2001-12-04 15:22:20 +01:00
|
|
|
if($sysCall && $this->authed)
|
|
|
|
{
|
|
|
|
$r = CreateObject('phpgwapi.xmlrpcresp',
|
2001-12-06 16:51:06 +01:00
|
|
|
'',
|
|
|
|
$GLOBALS['xmlrpcerr']['unknown_method'],
|
|
|
|
$GLOBALS['xmlrpcstr']['unknown_method'] . ': ' . $methName
|
2001-12-04 15:22:20 +01:00
|
|
|
);
|
|
|
|
return $r;
|
|
|
|
}
|
2001-11-30 01:48:25 +01:00
|
|
|
if ($this->authed)
|
2001-08-23 08:47:50 +02:00
|
|
|
{
|
|
|
|
/* phpgw mod - fetch the (bo) class methods to create the dmap */
|
2003-08-28 16:31:11 +02:00
|
|
|
// This part is to update session action to match
|
|
|
|
$this->method_requested = $methName;
|
|
|
|
|
2001-08-23 08:47:50 +02:00
|
|
|
$method = $methName;
|
|
|
|
$tmp = explode('.',$methName);
|
|
|
|
$methName = $tmp[2];
|
2001-09-06 10:33:42 +02:00
|
|
|
$service = $tmp[1];
|
|
|
|
$class = $tmp[0];
|
2001-12-28 17:29:27 +01:00
|
|
|
|
2001-11-30 01:48:25 +01:00
|
|
|
if (ereg('^service',$method))
|
2001-09-06 10:33:42 +02:00
|
|
|
{
|
|
|
|
$t = 'phpgwapi.' . $class . '.exec';
|
|
|
|
$dmap = ExecMethod($t,array($service,'list_methods','xmlrpc'));
|
|
|
|
}
|
2001-12-28 17:29:27 +01:00
|
|
|
elseif($GLOBALS['phpgw']->acl->check('run',1,$class))
|
2001-09-06 10:33:42 +02:00
|
|
|
{
|
2001-12-28 17:29:27 +01:00
|
|
|
/* This only happens if they have app access. If not, we will
|
|
|
|
* return a fault below.
|
|
|
|
*/
|
2001-12-28 19:41:33 +01:00
|
|
|
$listmeth = $class . '.' . $service . '.' . 'list_methods';
|
2001-09-06 10:33:42 +02:00
|
|
|
$dmap = ExecMethod($listmeth,'xmlrpc');
|
|
|
|
}
|
2001-12-28 19:41:33 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$r = CreateObject('phpgwapi.xmlrpcresp',
|
|
|
|
'',
|
|
|
|
$GLOBALS['xmlrpcerr']['no_access'],
|
|
|
|
$GLOBALS['xmlrpcstr']['no_access']
|
|
|
|
);
|
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
|
2001-08-23 08:47:50 +02:00
|
|
|
$this->dmap = $dmap;
|
2001-09-06 10:33:42 +02:00
|
|
|
/* _debug_array($this->dmap);exit; */
|
2001-08-23 08:47:50 +02:00
|
|
|
}
|
2001-08-09 01:28:03 +02:00
|
|
|
}
|
2001-11-30 01:48:25 +01:00
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
if (isset($dmap[$methName]['function']))
|
|
|
|
{
|
|
|
|
// dispatch if exists
|
|
|
|
if (isset($dmap[$methName]['signature']))
|
|
|
|
{
|
|
|
|
$sr = $this->verifySignature($m, $dmap[$methName]['signature'] );
|
|
|
|
}
|
|
|
|
if ( (!isset($dmap[$methName]['signature'])) || $sr[0])
|
|
|
|
{
|
|
|
|
// if no signature or correct signature
|
|
|
|
if ($sysCall)
|
|
|
|
{
|
|
|
|
$code = '$r=' . $dmap[$methName]['function'] . '($this, $m);';
|
2003-12-20 19:29:02 +01:00
|
|
|
$code = str_replace(',,',",'',",$code);
|
2001-08-08 01:00:28 +02:00
|
|
|
eval($code);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-30 01:48:25 +01:00
|
|
|
if (function_exists($dmap[$methName]['function']))
|
2001-08-09 01:28:03 +02:00
|
|
|
{
|
|
|
|
$code = '$r =' . $dmap[$methName]['function'] . '($m);';
|
2003-12-20 19:29:02 +01:00
|
|
|
$code = str_replace(',,',",'',",$code);
|
2001-08-20 18:33:26 +02:00
|
|
|
eval($code);
|
2001-08-09 01:28:03 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-13 22:03:24 +01:00
|
|
|
/* phpgw mod - finally, execute the function call and return the values */
|
2001-08-20 18:33:26 +02:00
|
|
|
$params = $GLOBALS['_xh'][$parser]['params'][0];
|
|
|
|
$code = '$p = ' . $params . ';';
|
2001-11-16 19:23:21 +01:00
|
|
|
if (count($params) != 0)
|
|
|
|
{
|
|
|
|
eval($code);
|
|
|
|
$params = $p->getval();
|
|
|
|
}
|
2001-08-26 17:17:24 +02:00
|
|
|
|
|
|
|
// _debug_array($params);
|
2001-11-13 22:03:24 +01:00
|
|
|
$this->reqtoarray($params);
|
2003-10-26 19:37:45 +01:00
|
|
|
// decode from utf-8 to our charset
|
|
|
|
$this->req_array = $GLOBALS['phpgw']->translation->convert($this->req_array,'utf-8');
|
2001-08-26 17:17:24 +02:00
|
|
|
//_debug_array($this->req_array);
|
2001-11-30 01:48:25 +01:00
|
|
|
if (ereg('^service',$method))
|
2001-09-06 10:33:42 +02:00
|
|
|
{
|
|
|
|
$res = ExecMethod('phpgwapi.service.exec',array($service,$methName,$this->req_array));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-30 01:48:25 +01:00
|
|
|
list($s,$c,$m) = explode('.',$_methName);
|
|
|
|
$res = ExecMethod($s . '.' . $c . '.' . $dmap[$methName]['function'],$this->req_array);
|
2001-09-06 10:33:42 +02:00
|
|
|
}
|
2001-11-13 22:03:24 +01:00
|
|
|
/* $res = ExecMethod($method,$params); */
|
|
|
|
/* _debug_array($res);exit; */
|
2003-10-25 18:08:05 +02:00
|
|
|
$this->resp_struct = array($this->build_resp($res,True));
|
2003-08-28 16:31:11 +02:00
|
|
|
/*_debug_array($this->resp_struct); */
|
2001-08-27 05:09:14 +02:00
|
|
|
@reset($this->resp_struct);
|
2001-11-13 22:03:24 +01:00
|
|
|
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$this->resp_struct,'struct'));
|
|
|
|
/* _debug_array($r); */
|
2001-08-09 01:28:03 +02:00
|
|
|
}
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-12-04 15:22:20 +01:00
|
|
|
$r = CreateObject('phpgwapi.xmlrpcresp',
|
2001-12-06 16:51:06 +01:00
|
|
|
'',
|
|
|
|
$GLOBALS['xmlrpcerr']['incorrect_params'],
|
|
|
|
$GLOBALS['xmlrpcstr']['incorrect_params'] . ': ' . $sr[1]
|
2001-08-08 01:00:28 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// else prepare error response
|
2001-08-23 08:47:50 +02:00
|
|
|
if(!$this->authed)
|
|
|
|
{
|
2003-10-21 23:05:23 +02:00
|
|
|
$r = False; // send 401 header to force authorization
|
|
|
|
/*CreateObject('phpgwapi.xmlrpcresp',
|
2001-12-04 15:22:20 +01:00
|
|
|
CreateObject('phpgwapi.xmlrpcval',
|
2001-12-06 16:51:06 +01:00
|
|
|
'UNAUTHORIZED',
|
2001-12-04 15:22:20 +01:00
|
|
|
'string'
|
|
|
|
)
|
2003-10-21 23:05:23 +02:00
|
|
|
);*/
|
2001-08-23 08:47:50 +02:00
|
|
|
}
|
2001-12-06 16:51:06 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$r = CreateObject('phpgwapi.xmlrpcresp',
|
|
|
|
'',
|
|
|
|
$GLOBALS['xmlrpcerr']['unknown_method'],
|
|
|
|
$GLOBALS['xmlrpcstr']['unknown_method'] . ': ' . $methName
|
|
|
|
);
|
|
|
|
}
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
|
|
|
|
function echoInput()
|
|
|
|
{
|
2003-08-28 16:31:11 +02:00
|
|
|
global $HTTP_RAW_POST_DATA;
|
|
|
|
|
2001-08-08 01:00:28 +02:00
|
|
|
// a debugging routine: just echos back the input
|
|
|
|
// packet as a string value
|
|
|
|
|
2003-08-28 16:31:11 +02:00
|
|
|
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',"'Aha said I: '" . $HTTP_RAW_POST_DATA,'string'));
|
|
|
|
//echo $r->serialize();
|
|
|
|
|
|
|
|
$fp = fopen('/tmp/xmlrpc_debug.in','w');
|
|
|
|
fputs($fp,$r->serialize);
|
|
|
|
fputs($fp,$HTTP_RAW_POST_DATA);
|
|
|
|
fclose($fp);
|
2001-08-08 01:00:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|