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