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 |
joko |
1.7 |
--- $Id: netfraggle.php,v 1.6 2004/08/31 16:43:35 joko 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 |
joko |
1.6 |
"getContent" => array( |
26 |
|
|
"function" => "nfo_get_content", |
27 |
|
|
"signature" => array(array('struct', 'string')), |
28 |
|
|
), |
29 |
|
|
"listTopics" => array( |
30 |
|
|
"function" => "nfo_list_topics", |
31 |
|
|
"signature" => array(array('struct', 'struct')), |
32 |
|
|
), |
33 |
|
|
"authenticate" => array( |
34 |
|
|
"function" => "nfo_authenticate", |
35 |
|
|
"signature" => array(array('boolean', 'struct')), |
36 |
|
|
), |
37 |
joko |
1.5 |
"listContents" => array("function" => "nfo_list_contents"), |
38 |
|
|
"listUsers" => array("function" => "nfo_list_users"), |
39 |
joko |
1.4 |
)); |
40 |
|
|
break; |
41 |
joko |
1.5 |
default: |
42 |
joko |
1.4 |
break; |
43 |
|
|
} |
44 |
joko |
1.6 |
#"getContent" => array("function" => "nfo_get_content"), |
45 |
|
|
#"signature" => array(array($xmlrpcStruct, $xmlrpcString)) |
46 |
|
|
#"signature" => array($XML_RPC_Struct, $XML_RPC_String) |
47 |
joko |
1.4 |
|
48 |
|
|
|
49 |
joko |
1.6 |
function nfo_get_content($params) { |
50 |
|
|
$ck = $params->getParam(0); |
51 |
|
|
$ck = $ck->scalarval(); |
52 |
joko |
1.5 |
#nfo_debug_clean(); |
53 |
joko |
1.6 |
#nfo_debug_write($ck); |
54 |
joko |
1.5 |
$content = cms_getcontent('xmlpage', $ck); |
55 |
joko |
1.6 |
#nfo_debug_write($content); |
56 |
joko |
1.5 |
#return new XML_RPC_Response(new XML_RPC_Value("content", "string")); |
57 |
|
|
$struct = array(); |
58 |
|
|
foreach ($content as $key => $value) { |
59 |
|
|
$struct[$key] = new XML_RPC_Value($value, "string"); |
60 |
|
|
} |
61 |
|
|
$xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct")); |
62 |
|
|
#nfo_debug_write($xmldoc); |
63 |
joko |
1.6 |
#nfo_debug_write($xmldoc->serialize()); |
64 |
joko |
1.5 |
return $xmldoc; |
65 |
joko |
1.4 |
} |
66 |
joko |
1.6 |
|
67 |
|
|
function nfo_list_topics($params) { |
68 |
joko |
1.7 |
#nfo_debug_clean(); |
69 |
joko |
1.6 |
#nfo_debug_write($params); |
70 |
|
|
#nfo_debug_write("list_topics"); |
71 |
|
|
$meta = $params->getParam(0); |
72 |
|
|
#nfo_debug_write($meta); |
73 |
|
|
$type = $meta->structmem('type'); |
74 |
|
|
$type = $type->scalarval(); |
75 |
|
|
#nfo_debug_write("$type"); |
76 |
|
|
$res = cms_getindex($type); |
77 |
joko |
1.7 |
#nfo_debug_write($res); |
78 |
joko |
1.6 |
$newentries = array(); |
79 |
|
|
$tmp = new XML_RPC_Value(); |
80 |
|
|
foreach ($res as $entry) { |
81 |
|
|
$newentry = array(); |
82 |
|
|
foreach ($entry as $key => $value) { |
83 |
|
|
$newvalue = new XML_RPC_Value($value, 'string'); |
84 |
|
|
$newentry[$key] = $newvalue; |
85 |
|
|
} |
86 |
|
|
#$tmp->addStruct($newentry); |
87 |
|
|
array_push($newentries, new XML_RPC_Value($newentry, 'struct')); |
88 |
|
|
} |
89 |
|
|
$final = new XML_RPC_Value($newentries, 'array'); |
90 |
|
|
#$final->addArray($tmp); |
91 |
|
|
#nfo_debug_write($final); |
92 |
|
|
#$res = array('key' => new XML_RPC_Value('value', 'string')); |
93 |
|
|
$msg = new XML_RPC_Response($final); |
94 |
|
|
#nfo_debug_write($msg); |
95 |
|
|
return $msg; |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
function nfo_authenticate($params) { |
99 |
|
|
global $common_sessiondata; |
100 |
|
|
#nfo_debug_clean(); |
101 |
|
|
#nfo_debug_write($params); |
102 |
|
|
$meta = $params->getParam(0); |
103 |
|
|
$user = $meta->structmem('user'); |
104 |
|
|
$user = $user->scalarval(); |
105 |
|
|
$pass = $meta->structmem('pass'); |
106 |
|
|
$pass = $pass->scalarval(); |
107 |
|
|
$common_sessiondata['userdata']['name'] = $user; |
108 |
|
|
$common_sessiondata['userdata']['password'] = $pass; |
109 |
joko |
1.7 |
#nfo_debug_write($common_sessiondata); |
110 |
joko |
1.6 |
$retval = common_checkauthorisation(); |
111 |
|
|
return new XML_RPC_Response(new XML_RPC_Value($retval, 'boolean')); |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
function nfo_list_contents() { |
115 |
|
|
} |
116 |
|
|
|
117 |
joko |
1.4 |
function nfo_list_users() { |
118 |
joko |
1.5 |
} |
119 |
|
|
|
120 |
|
|
function nfo_debug_clean() { |
121 |
joko |
1.6 |
`rm dump`; |
122 |
joko |
1.5 |
} |
123 |
|
|
|
124 |
|
|
function nfo_debug_write($data) { |
125 |
|
|
ob_start(); |
126 |
|
|
print_r($data); |
127 |
|
|
$data = ob_get_clean(); |
128 |
joko |
1.6 |
$f = fopen('dump', 'a'); |
129 |
|
|
fputs($f, $data . "\n"); |
130 |
joko |
1.5 |
fclose($f); |
131 |
joko |
1.4 |
} |
132 |
rabit |
1.2 |
|
133 |
|
|
//------------------------------------------------------------------------------ |
134 |
|
|
|
135 |
|
|
?> |