[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] api/rpc class.rpc_xmlrpc.php,1.1.2.7,1.1.2.8
From: |
Dan Kuykendall <address@hidden> |
Subject: |
[Phpgroupware-cvs] api/rpc class.rpc_xmlrpc.php,1.1.2.7,1.1.2.8 |
Date: |
Thu, 30 Oct 2003 23:44:24 +0000 |
Update of /cvsroot/phpgroupware/api/rpc
In directory subversions:/tmp/cvs-serv15785/api/rpc
Modified Files:
Tag: proposal-branch
class.rpc_xmlrpc.php
Log Message:
fixed xmlrpc parsing routines
Index: class.rpc_xmlrpc.php
===================================================================
RCS file: /cvsroot/phpgroupware/api/rpc/Attic/class.rpc_xmlrpc.php,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** class.rpc_xmlrpc.php 29 Oct 2003 20:14:23 -0000 1.1.2.7
--- class.rpc_xmlrpc.php 30 Oct 2003 23:44:21 -0000 1.1.2.8
***************
*** 240,371 ****
}
! $GLOBALS['methodCall'] = xml2var($xmlrpc_input);
! if(isset($GLOBALS['methodCall']['methodName']))
{
! $this->op =
$GLOBALS['methodCall']['methodName'];
! if($this->op == 'api.base.login')
! {
! /* pick up the username */
!
if(isset($GLOBALS['methodCall']['params']['param'][0]['value']))
! {
!
if(isset($GLOBALS['methodCall']['params']['param'][0]['value']['string']))
! {
!
$GLOBALS['HTTP_GET_VARS']['phpgw_user'] =
$GLOBALS['methodCall']['params']['param'][0]['value']['string'];
! }
! else
! {
!
$GLOBALS['HTTP_GET_VARS']['phpgw_user'] =
$GLOBALS['methodCall']['params']['param'][0]['value'];
! }
! }
! /* pick up the password */
!
if(isset($GLOBALS['methodCall']['params']['param'][1]['value']))
! {
!
if(isset($GLOBALS['methodCall']['params']['param'][1]['value']['string']))
! {
!
$GLOBALS['HTTP_GET_VARS']['phpgw_pass'] =
$GLOBALS['methodCall']['params']['param'][1]['value']['string'];
! }
! else
! {
!
$GLOBALS['HTTP_GET_VARS']['phpgw_pass'] =
$GLOBALS['methodCall']['params']['param'][1]['value'];
! }
! }
! unset($GLOBALS['methodCall']['params']);
! }
!
! if(is_array($GLOBALS['methodCall']['params']))
! {
!
$this->parse_params($GLOBALS['methodCall']['params']);
! }
}
}
! function parse_params($params)
{
! foreach($params as $key=>$val)
{
! if(isset($val['value']))
! {
! $this->parse_param_sub($val);
! }
! else
! {
! foreach($val as $subkey=>$subval)
{
! if(is_array($subval))
{
!
$this->parse_params($subval);
}
! else
{
!
$this->parse_param_sub($subval);
}
}
! }
! }
! }
!
! function parse_param_sub($param)
! {
! if(!is_array($param['value']))
! {
! if($this->first_input)
! {
! $GLOBALS['HTTP_GET_VARS']['sid'] =
$param['value'];
! }
! else
! {
! if(isset($param['name']))
{
! $this->inputs[$param['name']] =
$param['value'][$type];
}
else
{
! $this->inputs[] =
$param['value'][$type];
! }
! $this->inputs[] = $param['value'];
! $this->first_input = False;
! }
! }
! else
! {
! $type = key($param['value']);
! switch ($type)
! {
! case 'struct':
! case 'member':
!
$this->parse_params($param['value']);
! break;
! case 'base64':
! $val['value'][$type] =
base64_decode($param['value'][$type]);
! if($this->first_input)
{
!
$GLOBALS['HTTP_GET_VARS']['sid'] = $val['value'][$type];
}
! case 'boolean':
!
settype($param['value'][$type],'boolean');
! case 'int':
! case 'i4':
! case 'double':
! case 'dateTime.iso8601':
! case 'string':
! default:
! if(!$this->first_input)
{
!
if(isset($param['name']))
{
!
$this->inputs[$param['name']] = $param['value'][$type];
}
else
{
! $this->inputs[]
= $param['value'][$type];
}
! }
! $this->first_input = False;
! }
}
}
-
function add_vars($params)
{
--- 240,460 ----
}
! $parser = xml_parser_create();
! xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING,
0);
! xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE,
1);
! xml_parse_into_struct($parser, $xmlrpc_input,
$xml_vals, $xml_index);
! xml_parser_free($parser);
! $this->xml_index = $xml_index;
! $this->xml_vals = $xml_vals;
! unset($xml_index, $xml_vals);
!
if(!isset($this->xml_vals[$this->xml_index['methodName'][0]]['value']))
{
! $GLOBALS['phpgw']->finish(False);
! $error_result = "<?xml version=\"1.0\"?>\n";
! $error_result .= "<methodResponse>\n";
! $error_result .= " <fault>\n";
! $error_result .= " <value>\n";
! $error_result .= "
<struct>\n";
! $error_result .= "
<member>\n";
! $error_result .= "
<name>faultCode</name>\n";
! $error_result .= "
<value><int>1</int></value>\n";
! $error_result .= "
</member>\n";
! $error_result .= "
<member>\n";
! $error_result .= "
<name>faultString</name>\n";
! $error_result .= "
<value><string>Invalid xmlrpc packet. methodName
missing.</string></value>\n";
! $error_result .= "
</member>\n";
! $error_result .= "
</struct>\n";
! $error_result .= " </value>\n";
! $error_result .= " </fault>\n";
! $error_result .= "</methodResponse>\n";
! exit;
! }
! $this->op =
$this->xml_vals[$this->xml_index['methodName'][0]]['value'];
!
! $GLOBALS['methodCall'] = xml2var($xmlrpc_input);
!
! if(count($this->xml_index['params']) == 2)
! {
! $this->i = $this->xml_index['params'][0];
! $this->xml_vals_count = count($this->xml_vals);
! $this->inputs = $this->parse_params();
}
}
! function parse_params()
{
! switch($this->xml_vals[$this->i]['type'])
{
! case 'complete':
! $this->input_num++;
! switch($this->xml_vals[$this->i]['tag'])
{
! case 'value':
! $back = 1;
! $value =
$this->xml_vals[$this->i]['value'];
! break;
! case 'base64':
! $back = 2;
! $value =
base64_decode($this->xml_vals[$this->i]['value']);
! break;
! case 'boolean':
! $back = 2;
! $value =
$this->xml_vals[$this->i]['value'];
!
settype($value,'boolean');
! break;
! case 'int':
! case 'i4':
! case 'double':
! case 'dateTime.iso8601':
! case 'string':
! $back = 2;
! $value =
$this->xml_vals[$this->i]['value'];
! break;
! }
! $this->i++;
!
! if($this->op == 'api.base.login')
! {
! if($this->input_num == 1)
{
!
$GLOBALS['HTTP_GET_VARS']['phpgw_user'] = $value;
}
! elseif($this->input_num == 2)
{
!
$GLOBALS['HTTP_GET_VARS']['phpgw_pass'] = $value;
}
+ return;
}
! elseif($this->input_num == 1)
{
!
$GLOBALS['HTTP_GET_VARS']['sid'] = $value;
! return;
}
else
{
! return $value;
! if(isset($name))
{
! return
array($name=>$value);
}
! else
{
! return $value;
! }
! }
! break;
! case 'open':
! switch
($this->xml_vals[$this->i]['tag'])
! {
! case 'params':
! case 'param':
! $this->i++;
!
while($this->xml_vals[$this->i]['type'] != 'close')
{
! $tmp =
$this->parse_params();
! if(isset($tmp))
! {
!
$result[] = $tmp;
! }
! $this->i++;
! }
! if(count($result) == 1)
! {
! return
$result[0];
}
else
{
! return $result;
}
! break;
! case 'array':
! $this->i++;
! $this->i++;
!
while($this->xml_vals[$this->i]['type'] != 'close')
! {
! $tmp =
$this->parse_params();
! if(isset($tmp))
! {
!
$result[] = $tmp;
! }
! $this->i++;
! }
! $this->i++;
! $this->i++;
! if(count($result) == 1)
! {
! return
$result[0];
! }
! else
! {
! return $result;
! }
! break;
!
! case 'struct':
! $this->i++;
! $this->i++;
!
while($this->xml_vals[$this->i]['type'] != 'close')
! {
!
if($this->xml_vals[$this->i]['tag'] == 'name')
! {
!
if(isset($this->xml_vals[$this->i]['value']))
! {
!
$name = $this->xml_vals[$this->i]['value'];
! }
!
$this->i++;
! }
! $tmp =
$this->parse_params();
!
!
if($this->xml_vals[$this->i+1]['tag'] == 'name')
! {
!
if(isset($this->xml_vals[$this->i+1]['value']))
! {
!
$name = $this->xml_vals[$this->i+1]['value'];
! }
!
//$this->i++;
! }
!
! if(isset($tmp))
! {
!
if(isset($name))
! {
!
$result[$name] = $tmp;
! }
! else
! {
!
$result[] = $tmp;
! }
!
! }
! $this->i++;
! $this->i++;
! }
! $this->i++;
! $this->i++;
! reset ($result);
! if(count($result) == 1
&& key($result) === 0)
! {
! return
$result[0];
! }
! else
! {
! return $result;
! }
! break;
!
! case 'value':
! $this->i++;
! return
$this->parse_params();
! break;
! }
! break;
! case 'close':
! return;
! break;
}
}
function add_vars($params)
{
***************
*** 412,415 ****
--- 501,508 ----
}
$result .= "</struct>\n";
+ /* Im not clear why its double
struct'ing, but it is and this is how I fixed it for now /*
+ /* If you dont like this hack, fix it.
Dan*/
+ $result = str_replace
("<struct>\n<struct>\n", "<struct>\n", $result);
+ $result = str_replace
("</struct>\n</struct>\n", "</struct>\n", $result);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] api/rpc class.rpc_xmlrpc.php,1.1.2.7,1.1.2.8,
Dan Kuykendall <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] phpgroupware test_xmlrpc.php, 1.1.2.3, 1.1.2.4 test_xmlrpc.xml, 1.1.2.5, 1.1.2.6
- Next by Date:
[Phpgroupware-cvs] api/rpc class.rpc_xmlrpc.php,1.1.2.8,1.1.2.9
- Previous by thread:
[Phpgroupware-cvs] phpgroupware test_xmlrpc.php, 1.1.2.3, 1.1.2.4 test_xmlrpc.xml, 1.1.2.5, 1.1.2.6
- Next by thread:
[Phpgroupware-cvs] api/rpc class.rpc_xmlrpc.php,1.1.2.8,1.1.2.9
- Index(es):