--- nfo/site/htdocs/netfraggle.php 2004/08/31 16:43:35 1.6 +++ nfo/site/htdocs/netfraggle.php 2004/09/20 23:38:14 1.13 @@ -5,7 +5,7 @@ -------------------------------------------------------------------------------- --- rabit, 01:28 24.08.2004 --- joko, 04:05 30.08.2004 ---- $Id: netfraggle.php,v 1.6 2004/08/31 16:43:35 joko Exp $ +--- $Id: netfraggle.php,v 1.13 2004/09/20 23:38:14 xabbu Exp $ ------------------------------------------------------------------------------*/ include('inc/common/common.php.inc'); @@ -22,6 +22,9 @@ case 'XMLRPC': include('libs/XML/Server.php'); $s = new XML_RPC_Server(array( + "query" => array( + "function" => "nfo_query" + ), "getContent" => array( "function" => "nfo_get_content", "signature" => array(array('struct', 'string')), @@ -45,6 +48,74 @@ #"signature" => array(array($xmlrpcStruct, $xmlrpcString)) #"signature" => array($XML_RPC_Struct, $XML_RPC_String) +function nfo_query($params) { + + $querytxt = $params->getParam(0); + $nqlquery = $querytxt->getval(); + nfo_debug_clean(); + #nfo_debug_write($params); + #nfo_debug_write($nqlquery); + $result = array(); + cms_query($nqlquery,&$result); + nfo_debug_write($result); + + $structinfo = array(); + $structcontent = array(); + $structfields = array(); + + foreach ($result[0] as $key => $value) { + if ($key == 'all'){ + $datall = array(); + foreach ($result[0][$key] as $keyall => $valall) { + + if ($keyall == 'fieldlist'){ + $datall2 = array(); + foreach ($result[0][$key][$keyall] as $fieldkey => $fieldval){ + $datall2 = new XML_RPC_Value($fieldval,"string"); + } + $datall[$keyall] = new XML_RPC_Value($datall2,"struct"); + }else{ + if($keyall == 'with'){ + // DO nothing yet + }else{ + $datall[$keyall] = new XML_RPC_Value($valall,"string"); + } + } + } + $structinfo[$key] = new XML_RPC_Value($datall,"struct"); + }else{ + $structinfo[$key] = new XML_RPC_Value($value,"string"); + } + } + + #foreach ($result[1] as $key => $value) { + #$structcontent[$key] = new XML_RPC_Value($value,"struct"); + # } + + foreach ($result[1] as $key => $value) { + $cdata = array(); + foreach($value as $item => $data) { + $cdata[$item] = new XML_RPC_Value($data,"string"); + } + $structcontent[$key] = new XML_RPC_Value($cdata,"struct"); + } + + foreach ($result[2] as $key => $value) { + $structfields[$key] = new XML_RPC_Value($value,"string"); + } + $struct = array(); + $struct[0] = new XML_RPC_Value($structinfo,"struct"); + $struct[1] = new XML_RPC_Value($structcontent,"struct"); + $struct[2] = new XML_RPC_Value($structfields,"struct"); + + $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct")); + nfo_debug_write($xmldoc); + #nfo_debug_write($xmldoc->serialize()); + +return $xmldoc; + +} + function nfo_get_content($params) { $ck = $params->getParam(0); @@ -59,22 +130,20 @@ $struct[$key] = new XML_RPC_Value($value, "string"); } $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct")); - #nfo_debug_write($xmldoc); - #nfo_debug_write($xmldoc->serialize()); return $xmldoc; } function nfo_list_topics($params) { nfo_debug_clean(); - #nfo_debug_write($params); - #nfo_debug_write("list_topics"); + nfo_debug_write($params); + nfo_debug_write("list_topics"); $meta = $params->getParam(0); - #nfo_debug_write($meta); + nfo_debug_write($meta); $type = $meta->structmem('type'); $type = $type->scalarval(); #nfo_debug_write("$type"); $res = cms_getindex($type); - nfo_debug_write($res); + #nfo_debug_write($res); $newentries = array(); $tmp = new XML_RPC_Value(); foreach ($res as $entry) { @@ -106,7 +175,7 @@ $pass = $pass->scalarval(); $common_sessiondata['userdata']['name'] = $user; $common_sessiondata['userdata']['password'] = $pass; - nfo_debug_write($common_sessiondata); + #nfo_debug_write($common_sessiondata); $retval = common_checkauthorisation(); return new XML_RPC_Response(new XML_RPC_Value($retval, 'boolean')); }