--- nfo/site/htdocs/netfraggle.php 2004/08/30 11:27:30 1.5 +++ 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.5 2004/08/30 11:27:30 joko Exp $ +--- $Id: netfraggle.php,v 1.6 2004/08/31 16:43:35 joko Exp $ ------------------------------------------------------------------------------*/ include('inc/common/common.php.inc'); @@ -22,28 +22,37 @@ case 'XMLRPC': include('libs/XML/Server.php'); $s = new XML_RPC_Server(array( - "listTopics" => array("function" => "nfo_list_topics"), + "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"), - #"getContent" => array("function" => "nfo_get_content", "signature" => array($xmlrpcStruct, xmlrpcString)), - "getContent" => array("function" => "nfo_get_content"), "listUsers" => array("function" => "nfo_list_users"), )); break; default: break; } + #"getContent" => array("function" => "nfo_get_content"), + #"signature" => array(array($xmlrpcStruct, $xmlrpcString)) + #"signature" => array($XML_RPC_Struct, $XML_RPC_String) -function nfo_list_topics() { -} -function nfo_list_contents() { -} -function nfo_get_content($ck) { +function nfo_get_content($params) { + $ck = $params->getParam(0); + $ck = $ck->scalarval(); #nfo_debug_clean(); - #nfo_debug_write("ck: $ck\n"); - $ck = 'Home'; + #nfo_debug_write($ck); $content = cms_getcontent('xmlpage', $ck); - nfo_debug_write($content); + #nfo_debug_write($content); #return new XML_RPC_Response(new XML_RPC_Value("content", "string")); $struct = array(); foreach ($content as $key => $value) { @@ -51,22 +60,73 @@ } $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct")); #nfo_debug_write($xmldoc); - nfo_debug_write($xmldoc->serialize()); + #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_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_list_users() { } function nfo_debug_clean() { - #`rm dump`; + `rm dump`; } function nfo_debug_write($data) { ob_start(); print_r($data); $data = ob_get_clean(); - $f = fopen('dump', 'w+'); - fputs($f, $data); + $f = fopen('dump', 'a'); + fputs($f, $data . "\n"); fclose($f); }