/[cvs]/nfo/site/htdocs/netfraggle.php
ViewVC logotype

Annotation of /nfo/site/htdocs/netfraggle.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations)
Sun Sep 12 00:42:39 2004 UTC (19 years, 9 months ago) by xabbu
Branch: MAIN
Changes since 1.8: +2 -1 lines
+ added signature to the xmlrpc query function

1 rabit 1.2 <?php
2     /*------------------------------------------------------------------------------
3     --- www.netfrag.org
4     --- NetFraggle client link page.
5     --------------------------------------------------------------------------------
6     --- rabit, 01:28 24.08.2004
7 joko 1.4 --- joko, 04:05 30.08.2004
8 xabbu 1.9 --- $Id: netfraggle.php,v 1.8 2004/09/12 00:29:51 xabbu Exp $
9 rabit 1.2 ------------------------------------------------------------------------------*/
10    
11 joko 1.4 include('inc/common/common.php.inc');
12 rabit 1.2
13     //------------------------------------------------------------------------------
14    
15     // ...NetFraggle interconnection code...
16 joko 1.4 // by now using XML-RPC, see API-Documentation at:
17     // http://pear.php.net/manual/en/package.webservices.xml-rpc.api.php
18    
19     $type = 'XMLRPC';
20    
21     switch ($type) {
22     case 'XMLRPC':
23 joko 1.5 include('libs/XML/Server.php');
24 joko 1.4 $s = new XML_RPC_Server(array(
25 xabbu 1.8 "query" => array(
26     "function" => "nfo_query"
27 xabbu 1.9 "signature" => array(array('struct','struct','struct')),
28 xabbu 1.8 ),
29 joko 1.6 "getContent" => array(
30     "function" => "nfo_get_content",
31     "signature" => array(array('struct', 'string')),
32     ),
33     "listTopics" => array(
34     "function" => "nfo_list_topics",
35     "signature" => array(array('struct', 'struct')),
36     ),
37     "authenticate" => array(
38     "function" => "nfo_authenticate",
39     "signature" => array(array('boolean', 'struct')),
40     ),
41 joko 1.5 "listContents" => array("function" => "nfo_list_contents"),
42     "listUsers" => array("function" => "nfo_list_users"),
43 joko 1.4 ));
44     break;
45 joko 1.5 default:
46 joko 1.4 break;
47     }
48 joko 1.6 #"getContent" => array("function" => "nfo_get_content"),
49     #"signature" => array(array($xmlrpcStruct, $xmlrpcString))
50     #"signature" => array($XML_RPC_Struct, $XML_RPC_String)
51 joko 1.4
52 xabbu 1.8 function nfo_query($params) {
53    
54     $querytxt = $params->getParam(0);
55     $nqlquery = $querytxt->getval();
56     nfo_debug_clean();
57     #nfo_debug_write($params);
58     #nfo_debug_write($nqlquery);
59     $result = array();
60     cms_query($nqlquery,&$result);
61     #nfo_debug_write($result);
62    
63     $structinfo = array();
64     $structcontent = array();
65     $structfields = array();
66    
67     foreach ($result[0] as $key => $value) {
68     $structinfo[$key] = new XML_RPC_Value($value,"string");
69     }
70     foreach ($result[1] as $key => $value) {
71     $structcontent[$key] = new XML_RPC_Value($value,"struct");
72     }
73     foreach ($result[2] as $key => $value) {
74     $structfields[$key] = new XML_RPC_Value($value,"string");
75     }
76     $struct = array();
77     $struct[0] = new XML_RPC_Value($structinfo,"struct");
78     $struct[1] = new XML_RPC_Value($structcontent,"struct");
79     $struct[2] = new XML_RPC_Value($structfields,"struct");
80    
81     $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct"));
82     nfo_debug_write($xmldoc);
83     #nfo_debug_write($xmldoc->serialize());
84    
85     return $xmldoc;
86    
87     }
88    
89 joko 1.4
90 joko 1.6 function nfo_get_content($params) {
91     $ck = $params->getParam(0);
92     $ck = $ck->scalarval();
93 joko 1.5 #nfo_debug_clean();
94 joko 1.6 #nfo_debug_write($ck);
95 joko 1.5 $content = cms_getcontent('xmlpage', $ck);
96 joko 1.6 #nfo_debug_write($content);
97 joko 1.5 #return new XML_RPC_Response(new XML_RPC_Value("content", "string"));
98     $struct = array();
99     foreach ($content as $key => $value) {
100     $struct[$key] = new XML_RPC_Value($value, "string");
101     }
102     $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct"));
103     return $xmldoc;
104 joko 1.4 }
105 joko 1.6
106     function nfo_list_topics($params) {
107 xabbu 1.8 nfo_debug_clean();
108     nfo_debug_write($params);
109     nfo_debug_write("list_topics");
110 joko 1.6 $meta = $params->getParam(0);
111 xabbu 1.8 nfo_debug_write($meta);
112 joko 1.6 $type = $meta->structmem('type');
113     $type = $type->scalarval();
114     #nfo_debug_write("$type");
115     $res = cms_getindex($type);
116 joko 1.7 #nfo_debug_write($res);
117 joko 1.6 $newentries = array();
118     $tmp = new XML_RPC_Value();
119     foreach ($res as $entry) {
120     $newentry = array();
121     foreach ($entry as $key => $value) {
122     $newvalue = new XML_RPC_Value($value, 'string');
123     $newentry[$key] = $newvalue;
124     }
125     #$tmp->addStruct($newentry);
126     array_push($newentries, new XML_RPC_Value($newentry, 'struct'));
127     }
128     $final = new XML_RPC_Value($newentries, 'array');
129     #$final->addArray($tmp);
130     #nfo_debug_write($final);
131     #$res = array('key' => new XML_RPC_Value('value', 'string'));
132     $msg = new XML_RPC_Response($final);
133     #nfo_debug_write($msg);
134     return $msg;
135     }
136    
137     function nfo_authenticate($params) {
138     global $common_sessiondata;
139     #nfo_debug_clean();
140     #nfo_debug_write($params);
141     $meta = $params->getParam(0);
142     $user = $meta->structmem('user');
143     $user = $user->scalarval();
144     $pass = $meta->structmem('pass');
145     $pass = $pass->scalarval();
146     $common_sessiondata['userdata']['name'] = $user;
147     $common_sessiondata['userdata']['password'] = $pass;
148 joko 1.7 #nfo_debug_write($common_sessiondata);
149 joko 1.6 $retval = common_checkauthorisation();
150     return new XML_RPC_Response(new XML_RPC_Value($retval, 'boolean'));
151     }
152    
153     function nfo_list_contents() {
154     }
155    
156 joko 1.4 function nfo_list_users() {
157 joko 1.5 }
158    
159     function nfo_debug_clean() {
160 joko 1.6 `rm dump`;
161 joko 1.5 }
162    
163     function nfo_debug_write($data) {
164     ob_start();
165     print_r($data);
166     $data = ob_get_clean();
167 joko 1.6 $f = fopen('dump', 'a');
168     fputs($f, $data . "\n");
169 joko 1.5 fclose($f);
170 joko 1.4 }
171 rabit 1.2
172     //------------------------------------------------------------------------------
173    
174     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed