From 57ba2dfff8ca38b0f84d9309263c873d6d0a2d59 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Thu, 23 Aug 2001 06:47:50 +0000 Subject: [PATCH] Handle multi-dimensional array input, decode those xmlrpcvals --- phpgwapi/inc/class.interserver.inc.php | 5 +- phpgwapi/inc/class.xmlrpc_server.inc.php | 78 +++++++++++++++++++----- 2 files changed, 67 insertions(+), 16 deletions(-) diff --git a/phpgwapi/inc/class.interserver.inc.php b/phpgwapi/inc/class.interserver.inc.php index 5a0ee6253e..405c0ac29e 100644 --- a/phpgwapi/inc/class.interserver.inc.php +++ b/phpgwapi/inc/class.interserver.inc.php @@ -221,11 +221,12 @@ $f = CreateObject('phpgwapi.xmlrpcmsg', $method_name, $arr,'struct'); } - $this->debug("
" . htmlentities($f->serialize()) . "
\n",$debug); + $this->debug('
' . htmlentities($f->serialize()) . '
' . "\n",$debug); $c = CreateObject('phpgwapi.xmlrpc_client',$this->urlparts['xmlrpc'], $hostpart, 80); $c->username = $this->sessionid; $c->password = $this->kp3; - $c->setDebug(1); +// _debug_array($c); + $c->setDebug(0); $r = $c->send($f); if (!$r) { diff --git a/phpgwapi/inc/class.xmlrpc_server.inc.php b/phpgwapi/inc/class.xmlrpc_server.inc.php index 5903cb36c0..ac57d9a556 100644 --- a/phpgwapi/inc/class.xmlrpc_server.inc.php +++ b/phpgwapi/inc/class.xmlrpc_server.inc.php @@ -25,6 +25,7 @@ class xmlrpc_server { var $dmap = array(); + var $authed = False; function xmlrpc_server($dispMap='', $serviceNow=0) { @@ -183,13 +184,16 @@ } if(!isset($dmap[$methName]['function'])) { - /* phpgw mod - fetch the (bo) class methods to create the dmap */ - $method = $methName; - $tmp = explode('.',$methName); - $methName = $tmp[2]; - $listmeth = $tmp[0] . '.' . $tmp[1] . '.' . 'list_methods'; - $dmap = ExecMethod($listmeth,'xmlrpc'); - $this->dmap = $dmap; + if($this->authed) + { + /* phpgw mod - fetch the (bo) class methods to create the dmap */ + $method = $methName; + $tmp = explode('.',$methName); + $methName = $tmp[2]; + $listmeth = $tmp[0] . '.' . $tmp[1] . '.' . 'list_methods'; + $dmap = ExecMethod($listmeth,'xmlrpc'); + $this->dmap = $dmap; + } } if (isset($dmap[$methName]['function'])) { @@ -222,15 +226,53 @@ $code = '$p = ' . $params . ';'; eval($code); $params = $p->getval(); + /* _debug_array($params); */ + if(gettype($params) == 'array') + { + @reset($params); + while(list($key,$val) = @each($params)) + { + if(gettype($val) == 'array') + { + @reset($val); + while(list($key1,$val1) = @each($val)) + { + $tmp = ''; + if(get_class($val1) == 'xmlrpcval') + { + $tmp[$key1] = $val1->getval(); + /* echo '
Adding xmlrpc val1: ' . $tmp[$key1] . "\n"; */ + } + else + { + /* echo '
Adding val1: ' . $val1 . "\n"; */ + $tmp[$key1] = $val1; + } + } + $_params[$key] = $tmp; + } + else + { + /* echo '
Adding val: ' . $val . "\n"; */ + $_params[$key] = $val; + } + } + $params = $_params; + } + /* _debug_array($params); */ $res = ExecMethod($method,$params); + /* _debug_array($res);exit; */ + @reset($res); while(list($key,$val) = @each($res)) { if(gettype($val) == 'array') { + @reset($val); while(list($x,$y) = @each($val)) { - $ele[$x] = CreateObject('phpgwapi.xmlrpcval',$y,'string'); + $aa[$x] = CreateObject('phpgwapi.xmlrpcval',$y,'string'); } + $ele[$key] = CreateObject('phpgwapi.xmlrpcval',$aa,'struct'); } else { @@ -238,6 +280,7 @@ } } $r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$ele,'struct')); + /* _debug_array($r);exit; */ } } } @@ -254,12 +297,19 @@ else { // else prepare error response - $r = CreateObject( - 'phpgwapi.xmlrpcresp', - CreateObject('phpgwapi.xmlrpcval'), - $GLOBALS['xmlrpcerr']['unknown_method'], - $GLOBALS['xmlrpcstr']['unknown_method'] - ); + if(!$this->authed) + { + $r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval','UNAUTHORIZED','string')); + } + else + { + $r = CreateObject( + 'phpgwapi.xmlrpcresp', + CreateObject('phpgwapi.xmlrpcval'), + $GLOBALS['xmlrpcerr']['unknown_method'], + $GLOBALS['xmlrpcstr']['unknown_method'] + ); + } } } return $r;