--- nfo/site/htdocs/netfraggle.php 2004/08/30 02:33:26 1.4 +++ nfo/site/htdocs/netfraggle.php 2004/08/31 16:43:35 1.6 @@ -5,7 +5,7 @@ -------------------------------------------------------------------------------- --- rabit, 01:28 24.08.2004 --- joko, 04:05 30.08.2004 ---- $Id: netfraggle.php,v 1.4 2004/08/30 02:33:26 joko Exp $ +--- $Id: netfraggle.php,v 1.6 2004/08/31 16:43:35 joko Exp $ ------------------------------------------------------------------------------*/ include('inc/common/common.php.inc'); @@ -20,29 +20,116 @@ switch ($type) { case 'XMLRPC': + include('libs/XML/Server.php'); $s = new XML_RPC_Server(array( - "nfo.listTopics" => array("function" => "nfo_list_topics"), - "nfo.listContents" => array("function" => "nfo_list_contents"), - "nfo.getContent" => array("function" => "nfo_get_content"), - "nfo.listUsers" => array("function" => "nfo_list_users"), + "getContent" => array( + "function" => "nfo_get_content", + "signature" => array(array('struct', 'string')), + ), + "listTopics" => array( + "function" => "nfo_list_topics", + "signature" => array(array('struct', 'struct')), + ), + "authenticate" => array( + "function" => "nfo_authenticate", + "signature" => array(array('boolean', 'struct')), + ), + "listContents" => array("function" => "nfo_list_contents"), + "listUsers" => array("function" => "nfo_list_users"), )); break; - case default: + default: break; } + #"getContent" => array("function" => "nfo_get_content"), + #"signature" => array(array($xmlrpcStruct, $xmlrpcString)) + #"signature" => array($XML_RPC_Struct, $XML_RPC_String) + + +function nfo_get_content($params) { + $ck = $params->getParam(0); + $ck = $ck->scalarval(); + #nfo_debug_clean(); + #nfo_debug_write($ck); + $content = cms_getcontent('xmlpage', $ck); + #nfo_debug_write($content); + #return new XML_RPC_Response(new XML_RPC_Value("content", "string")); + $struct = array(); + foreach ($content as $key => $value) { + $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"); + $meta = $params->getParam(0); + #nfo_debug_write($meta); + $type = $meta->structmem('type'); + $type = $type->scalarval(); + #nfo_debug_write("$type"); + $res = cms_getindex($type); + nfo_debug_write($res); + $newentries = array(); + $tmp = new XML_RPC_Value(); + foreach ($res as $entry) { + $newentry = array(); + foreach ($entry as $key => $value) { + $newvalue = new XML_RPC_Value($value, 'string'); + $newentry[$key] = $newvalue; + } + #$tmp->addStruct($newentry); + array_push($newentries, new XML_RPC_Value($newentry, 'struct')); + } + $final = new XML_RPC_Value($newentries, 'array'); + #$final->addArray($tmp); + #nfo_debug_write($final); + #$res = array('key' => new XML_RPC_Value('value', 'string')); + $msg = new XML_RPC_Response($final); + #nfo_debug_write($msg); + return $msg; +} -function nfo_list_topics() { +function nfo_authenticate($params) { + global $common_sessiondata; + #nfo_debug_clean(); + #nfo_debug_write($params); + $meta = $params->getParam(0); + $user = $meta->structmem('user'); + $user = $user->scalarval(); + $pass = $meta->structmem('pass'); + $pass = $pass->scalarval(); + $common_sessiondata['userdata']['name'] = $user; + $common_sessiondata['userdata']['password'] = $pass; + nfo_debug_write($common_sessiondata); + $retval = common_checkauthorisation(); + return new XML_RPC_Response(new XML_RPC_Value($retval, 'boolean')); } + function nfo_list_contents() { } -function nfo_get_content($ck) { - $content = cms_getcontent($ck); - return new XML_RPC_Response(new XML_RPC_Value("content", "array" | "struct")); -} + function nfo_list_users() { } +function nfo_debug_clean() { + `rm dump`; +} + +function nfo_debug_write($data) { + ob_start(); + print_r($data); + $data = ob_get_clean(); + $f = fopen('dump', 'a'); + fputs($f, $data . "\n"); + fclose($f); +} + //------------------------------------------------------------------------------ ?>