1 |
<?php |
2 |
/*------------------------------------------------------------------------------ |
3 |
--- www.netfrag.org |
4 |
--- NetFraggle client link page. |
5 |
-------------------------------------------------------------------------------- |
6 |
--- rabit, 01:28 24.08.2004 |
7 |
--- joko, 04:05 30.08.2004 |
8 |
--- $Id: netfraggle.php,v 1.8 2004/09/12 00:29:51 xabbu Exp $ |
9 |
------------------------------------------------------------------------------*/ |
10 |
|
11 |
include('inc/common/common.php.inc'); |
12 |
|
13 |
//------------------------------------------------------------------------------ |
14 |
|
15 |
// ...NetFraggle interconnection code... |
16 |
// 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 |
include('libs/XML/Server.php'); |
24 |
$s = new XML_RPC_Server(array( |
25 |
"query" => array( |
26 |
"function" => "nfo_query" |
27 |
"signature" => array(array('struct','struct','struct')), |
28 |
), |
29 |
"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 |
"listContents" => array("function" => "nfo_list_contents"), |
42 |
"listUsers" => array("function" => "nfo_list_users"), |
43 |
)); |
44 |
break; |
45 |
default: |
46 |
break; |
47 |
} |
48 |
#"getContent" => array("function" => "nfo_get_content"), |
49 |
#"signature" => array(array($xmlrpcStruct, $xmlrpcString)) |
50 |
#"signature" => array($XML_RPC_Struct, $XML_RPC_String) |
51 |
|
52 |
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 |
|
90 |
function nfo_get_content($params) { |
91 |
$ck = $params->getParam(0); |
92 |
$ck = $ck->scalarval(); |
93 |
#nfo_debug_clean(); |
94 |
#nfo_debug_write($ck); |
95 |
$content = cms_getcontent('xmlpage', $ck); |
96 |
#nfo_debug_write($content); |
97 |
#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 |
} |
105 |
|
106 |
function nfo_list_topics($params) { |
107 |
nfo_debug_clean(); |
108 |
nfo_debug_write($params); |
109 |
nfo_debug_write("list_topics"); |
110 |
$meta = $params->getParam(0); |
111 |
nfo_debug_write($meta); |
112 |
$type = $meta->structmem('type'); |
113 |
$type = $type->scalarval(); |
114 |
#nfo_debug_write("$type"); |
115 |
$res = cms_getindex($type); |
116 |
#nfo_debug_write($res); |
117 |
$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 |
#nfo_debug_write($common_sessiondata); |
149 |
$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 |
function nfo_list_users() { |
157 |
} |
158 |
|
159 |
function nfo_debug_clean() { |
160 |
`rm dump`; |
161 |
} |
162 |
|
163 |
function nfo_debug_write($data) { |
164 |
ob_start(); |
165 |
print_r($data); |
166 |
$data = ob_get_clean(); |
167 |
$f = fopen('dump', 'a'); |
168 |
fputs($f, $data . "\n"); |
169 |
fclose($f); |
170 |
} |
171 |
|
172 |
//------------------------------------------------------------------------------ |
173 |
|
174 |
?> |