| 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.11 2004/09/15 16:39:06 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 |
), |
| 28 |
"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 |
"listContents" => array("function" => "nfo_list_contents"), |
| 41 |
"listUsers" => array("function" => "nfo_list_users"), |
| 42 |
)); |
| 43 |
break; |
| 44 |
default: |
| 45 |
break; |
| 46 |
} |
| 47 |
#"getContent" => array("function" => "nfo_get_content"), |
| 48 |
#"signature" => array(array($xmlrpcStruct, $xmlrpcString)) |
| 49 |
#"signature" => array($XML_RPC_Struct, $XML_RPC_String) |
| 50 |
|
| 51 |
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 |
nfo_debug_write($result); |
| 61 |
|
| 62 |
$structinfo = array(); |
| 63 |
$structcontent = array(); |
| 64 |
$structfields = array(); |
| 65 |
|
| 66 |
foreach ($result[0] as $key => $value) { |
| 67 |
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 |
if($keyall == 'with'){ |
| 79 |
// DO nothing yet |
| 80 |
}else{ |
| 81 |
$datall[$keyall] = new XML_RPC_Value($valall,"string"); |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
$structinfo[$key] = new XML_RPC_Value($datall,"struct"); |
| 86 |
}else{ |
| 87 |
$structinfo[$key] = new XML_RPC_Value($value,"string"); |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
#foreach ($result[1] as $key => $value) { |
| 92 |
#$structcontent[$key] = new XML_RPC_Value($value,"struct"); |
| 93 |
# } |
| 94 |
|
| 95 |
foreach ($result[1] as $key => $value) { |
| 96 |
$cdata = array(); |
| 97 |
foreach($value as $item => $data) { |
| 98 |
$cdata[$item] = new XML_RPC_Value($data,"string"); |
| 99 |
} |
| 100 |
$structcontent[$key] = new XML_RPC_Value($cdata,"struct"); |
| 101 |
} |
| 102 |
|
| 103 |
foreach ($result[2] as $key => $value) { |
| 104 |
$structfields[$key] = new XML_RPC_Value($value,"string"); |
| 105 |
} |
| 106 |
$struct = array(); |
| 107 |
$struct[0] = new XML_RPC_Value($structinfo,"struct"); |
| 108 |
$struct[1] = new XML_RPC_Value($structcontent,"struct"); |
| 109 |
$struct[2] = new XML_RPC_Value($structfields,"struct"); |
| 110 |
|
| 111 |
$xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct")); |
| 112 |
nfo_debug_write($xmldoc); |
| 113 |
#nfo_debug_write($xmldoc->serialize()); |
| 114 |
|
| 115 |
return $xmldoc; |
| 116 |
|
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
function nfo_get_content($params) { |
| 121 |
$ck = $params->getParam(0); |
| 122 |
$ck = $ck->scalarval(); |
| 123 |
#nfo_debug_clean(); |
| 124 |
#nfo_debug_write($ck); |
| 125 |
$content = cms_getcontent('xmlpage', $ck); |
| 126 |
#nfo_debug_write($content); |
| 127 |
#return new XML_RPC_Response(new XML_RPC_Value("content", "string")); |
| 128 |
$struct = array(); |
| 129 |
foreach ($content as $key => $value) { |
| 130 |
$struct[$key] = new XML_RPC_Value($value, "string"); |
| 131 |
} |
| 132 |
$xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct")); |
| 133 |
return $xmldoc; |
| 134 |
} |
| 135 |
|
| 136 |
function nfo_list_topics($params) { |
| 137 |
nfo_debug_clean(); |
| 138 |
nfo_debug_write($params); |
| 139 |
nfo_debug_write("list_topics"); |
| 140 |
$meta = $params->getParam(0); |
| 141 |
nfo_debug_write($meta); |
| 142 |
$type = $meta->structmem('type'); |
| 143 |
$type = $type->scalarval(); |
| 144 |
#nfo_debug_write("$type"); |
| 145 |
$res = cms_getindex($type); |
| 146 |
#nfo_debug_write($res); |
| 147 |
$newentries = array(); |
| 148 |
$tmp = new XML_RPC_Value(); |
| 149 |
foreach ($res as $entry) { |
| 150 |
$newentry = array(); |
| 151 |
foreach ($entry as $key => $value) { |
| 152 |
$newvalue = new XML_RPC_Value($value, 'string'); |
| 153 |
$newentry[$key] = $newvalue; |
| 154 |
} |
| 155 |
#$tmp->addStruct($newentry); |
| 156 |
array_push($newentries, new XML_RPC_Value($newentry, 'struct')); |
| 157 |
} |
| 158 |
$final = new XML_RPC_Value($newentries, 'array'); |
| 159 |
#$final->addArray($tmp); |
| 160 |
#nfo_debug_write($final); |
| 161 |
#$res = array('key' => new XML_RPC_Value('value', 'string')); |
| 162 |
$msg = new XML_RPC_Response($final); |
| 163 |
#nfo_debug_write($msg); |
| 164 |
return $msg; |
| 165 |
} |
| 166 |
|
| 167 |
function nfo_authenticate($params) { |
| 168 |
global $common_sessiondata; |
| 169 |
#nfo_debug_clean(); |
| 170 |
#nfo_debug_write($params); |
| 171 |
$meta = $params->getParam(0); |
| 172 |
$user = $meta->structmem('user'); |
| 173 |
$user = $user->scalarval(); |
| 174 |
$pass = $meta->structmem('pass'); |
| 175 |
$pass = $pass->scalarval(); |
| 176 |
$common_sessiondata['userdata']['name'] = $user; |
| 177 |
$common_sessiondata['userdata']['password'] = $pass; |
| 178 |
#nfo_debug_write($common_sessiondata); |
| 179 |
$retval = common_checkauthorisation(); |
| 180 |
return new XML_RPC_Response(new XML_RPC_Value($retval, 'boolean')); |
| 181 |
} |
| 182 |
|
| 183 |
function nfo_list_contents() { |
| 184 |
} |
| 185 |
|
| 186 |
function nfo_list_users() { |
| 187 |
} |
| 188 |
|
| 189 |
function nfo_debug_clean() { |
| 190 |
`rm dump`; |
| 191 |
} |
| 192 |
|
| 193 |
function nfo_debug_write($data) { |
| 194 |
ob_start(); |
| 195 |
print_r($data); |
| 196 |
$data = ob_get_clean(); |
| 197 |
$f = fopen('dump', 'a'); |
| 198 |
fputs($f, $data . "\n"); |
| 199 |
fclose($f); |
| 200 |
} |
| 201 |
|
| 202 |
//------------------------------------------------------------------------------ |
| 203 |
|
| 204 |
?> |