/[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.14 - (hide annotations)
Tue Sep 21 12:04:45 2004 UTC (19 years, 9 months ago) by xabbu
Branch: MAIN
Changes since 1.13: +24 -26 lines
U function query will now work with the updated query_cms and netfraggle. (Bugfix in parsing the debug array ($result[0])

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.14 --- $Id: netfraggle.php,v 1.12 2004/09/20 23:33:03 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 xabbu 1.10 "function" => "nfo_query"
27 xabbu 1.8 ),
28 joko 1.6 "getContent" => array(
29     "function" => "nfo_get_content",
30     "signature" => array(array('struct', 'string')),
31     ),
32     "listTopics" => array(
33     "function" => "nfo_list_topics",
34     "signature" => array(array('struct', 'struct')),
35     ),
36     "authenticate" => array(
37     "function" => "nfo_authenticate",
38     "signature" => array(array('boolean', 'struct')),
39     ),
40 joko 1.5 "listContents" => array("function" => "nfo_list_contents"),
41     "listUsers" => array("function" => "nfo_list_users"),
42 joko 1.4 ));
43     break;
44 joko 1.5 default:
45 joko 1.4 break;
46     }
47 joko 1.6 #"getContent" => array("function" => "nfo_get_content"),
48     #"signature" => array(array($xmlrpcStruct, $xmlrpcString))
49     #"signature" => array($XML_RPC_Struct, $XML_RPC_String)
50 joko 1.4
51 xabbu 1.8 function nfo_query($params) {
52    
53     $querytxt = $params->getParam(0);
54     $nqlquery = $querytxt->getval();
55 xabbu 1.14 #nfo_debug_clean();
56 xabbu 1.8 #nfo_debug_write($params);
57     #nfo_debug_write($nqlquery);
58     $result = array();
59     cms_query($nqlquery,&$result);
60 xabbu 1.14 #nfo_debug_write($result);
61 xabbu 1.8
62     $structinfo = array();
63     $structcontent = array();
64     $structfields = array();
65    
66     foreach ($result[0] as $key => $value) {
67 xabbu 1.14 $datall = array();
68 xabbu 1.12 if ($key == 'all'){
69 xabbu 1.14 #nfo_debug_write($value);
70 xabbu 1.12 foreach ($result[0][$key] as $keyall => $valall) {
71 xabbu 1.14 $datall2 = array();
72     if ($keyall == 'fieldlist'){
73     foreach ($result[0][$key][$keyall] as $fieldkey => $fieldval)
74     {
75     $datall2[$fieldkey] = new XML_RPC_Value($fieldval,"string");
76 xabbu 1.12 }
77 xabbu 1.14 $datall[$keyall] = new XML_RPC_Value($datall2,"struct");
78     }elseif($keyall == 'with'){
79     //nothing yet
80     }else{
81     $datall[$keyall] = new XML_RPC_Value($valall,"string");
82     }
83     }
84    
85 xabbu 1.12 $structinfo[$key] = new XML_RPC_Value($datall,"struct");
86 xabbu 1.14
87 xabbu 1.12 }else{
88     $structinfo[$key] = new XML_RPC_Value($value,"string");
89     }
90 xabbu 1.14 }
91    
92 xabbu 1.11 foreach ($result[1] as $key => $value) {
93     $cdata = array();
94     foreach($value as $item => $data) {
95     $cdata[$item] = new XML_RPC_Value($data,"string");
96     }
97     $structcontent[$key] = new XML_RPC_Value($cdata,"struct");
98     }
99    
100 xabbu 1.8 foreach ($result[2] as $key => $value) {
101     $structfields[$key] = new XML_RPC_Value($value,"string");
102 xabbu 1.14 }
103    
104 xabbu 1.8 $struct = array();
105     $struct[0] = new XML_RPC_Value($structinfo,"struct");
106     $struct[1] = new XML_RPC_Value($structcontent,"struct");
107     $struct[2] = new XML_RPC_Value($structfields,"struct");
108    
109     $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct"));
110 xabbu 1.14 #nfo_debug_write($xmldoc);
111 xabbu 1.8 #nfo_debug_write($xmldoc->serialize());
112    
113     return $xmldoc;
114    
115     }
116    
117 joko 1.4
118 joko 1.6 function nfo_get_content($params) {
119     $ck = $params->getParam(0);
120     $ck = $ck->scalarval();
121 joko 1.5 #nfo_debug_clean();
122 joko 1.6 #nfo_debug_write($ck);
123 joko 1.5 $content = cms_getcontent('xmlpage', $ck);
124 joko 1.6 #nfo_debug_write($content);
125 joko 1.5 #return new XML_RPC_Response(new XML_RPC_Value("content", "string"));
126     $struct = array();
127     foreach ($content as $key => $value) {
128     $struct[$key] = new XML_RPC_Value($value, "string");
129     }
130     $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct"));
131     return $xmldoc;
132 joko 1.4 }
133 joko 1.6
134     function nfo_list_topics($params) {
135 xabbu 1.8 nfo_debug_clean();
136     nfo_debug_write($params);
137     nfo_debug_write("list_topics");
138 joko 1.6 $meta = $params->getParam(0);
139 xabbu 1.8 nfo_debug_write($meta);
140 joko 1.6 $type = $meta->structmem('type');
141     $type = $type->scalarval();
142     #nfo_debug_write("$type");
143     $res = cms_getindex($type);
144 joko 1.7 #nfo_debug_write($res);
145 joko 1.6 $newentries = array();
146     $tmp = new XML_RPC_Value();
147     foreach ($res as $entry) {
148     $newentry = array();
149     foreach ($entry as $key => $value) {
150     $newvalue = new XML_RPC_Value($value, 'string');
151     $newentry[$key] = $newvalue;
152     }
153     #$tmp->addStruct($newentry);
154     array_push($newentries, new XML_RPC_Value($newentry, 'struct'));
155     }
156     $final = new XML_RPC_Value($newentries, 'array');
157     #$final->addArray($tmp);
158     #nfo_debug_write($final);
159     #$res = array('key' => new XML_RPC_Value('value', 'string'));
160     $msg = new XML_RPC_Response($final);
161     #nfo_debug_write($msg);
162     return $msg;
163     }
164    
165     function nfo_authenticate($params) {
166     global $common_sessiondata;
167     #nfo_debug_clean();
168     #nfo_debug_write($params);
169     $meta = $params->getParam(0);
170     $user = $meta->structmem('user');
171     $user = $user->scalarval();
172     $pass = $meta->structmem('pass');
173     $pass = $pass->scalarval();
174     $common_sessiondata['userdata']['name'] = $user;
175     $common_sessiondata['userdata']['password'] = $pass;
176 joko 1.7 #nfo_debug_write($common_sessiondata);
177 joko 1.6 $retval = common_checkauthorisation();
178     return new XML_RPC_Response(new XML_RPC_Value($retval, 'boolean'));
179     }
180    
181     function nfo_list_contents() {
182     }
183    
184 joko 1.4 function nfo_list_users() {
185 joko 1.5 }
186    
187     function nfo_debug_clean() {
188 joko 1.6 `rm dump`;
189 joko 1.5 }
190    
191     function nfo_debug_write($data) {
192     ob_start();
193     print_r($data);
194     $data = ob_get_clean();
195 joko 1.6 $f = fopen('dump', 'a');
196     fputs($f, $data . "\n");
197 joko 1.5 fclose($f);
198 joko 1.4 }
199 rabit 1.2
200     //------------------------------------------------------------------------------
201    
202     ?>

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