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