/[cvs]/nfo/site/htdocs/netfraggle.php
ViewVC logotype

Diff of /nfo/site/htdocs/netfraggle.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by joko, Mon Aug 30 11:27:30 2004 UTC revision 1.10 by xabbu, Mon Sep 13 18:49:02 2004 UTC
# Line 22  switch ($type) { Line 22  switch ($type) {
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       $structinfo[$key] = new XML_RPC_Value($value,"string");
68        }
69      foreach ($result[1] as $key => $value)  {
70       $structcontent[$key] = new XML_RPC_Value($value,"struct");
71        }
72      foreach ($result[2] as $key => $value) {
73       $structfields[$key] = new XML_RPC_Value($value,"string");
74       }
75      $struct = array();
76      $struct[0] = new XML_RPC_Value($structinfo,"struct");
77      $struct[1] = new XML_RPC_Value($structcontent,"struct");
78      $struct[2] = new XML_RPC_Value($structfields,"struct");
79      
80      $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct"));
81      nfo_debug_write($xmldoc);
82      #nfo_debug_write($xmldoc->serialize());
83    
84    return $xmldoc;
85      
86  }  }
87  function nfo_get_content($ck) {  
88    
89    function nfo_get_content($params) {
90      $ck = $params->getParam(0);
91      $ck = $ck->scalarval();
92    #nfo_debug_clean();    #nfo_debug_clean();
93    #nfo_debug_write("ck: $ck\n");    #nfo_debug_write($ck);
   $ck = 'Home';  
94    $content = cms_getcontent('xmlpage', $ck);    $content = cms_getcontent('xmlpage', $ck);
95    nfo_debug_write($content);    #nfo_debug_write($content);
96    #return new XML_RPC_Response(new XML_RPC_Value("content", "string"));    #return new XML_RPC_Response(new XML_RPC_Value("content", "string"));
97    $struct = array();    $struct = array();
98    foreach ($content as $key => $value) {    foreach ($content as $key => $value) {
99      $struct[$key] = new XML_RPC_Value($value, "string");      $struct[$key] = new XML_RPC_Value($value, "string");
100    }    }
101    $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());  
102    return $xmldoc;    return $xmldoc;
103  }  }
104    
105    function nfo_list_topics($params) {
106      nfo_debug_clean();
107      nfo_debug_write($params);
108      nfo_debug_write("list_topics");
109      $meta = $params->getParam(0);
110      nfo_debug_write($meta);
111      $type = $meta->structmem('type');
112      $type = $type->scalarval();
113      #nfo_debug_write("$type");
114      $res = cms_getindex($type);
115      #nfo_debug_write($res);
116      $newentries = array();
117      $tmp = new XML_RPC_Value();
118      foreach ($res as $entry) {
119        $newentry = array();
120        foreach ($entry as $key => $value) {
121           $newvalue = new XML_RPC_Value($value, 'string');
122           $newentry[$key] = $newvalue;
123        }
124        #$tmp->addStruct($newentry);
125        array_push($newentries, new XML_RPC_Value($newentry, 'struct'));
126      }
127      $final = new XML_RPC_Value($newentries, 'array');
128      #$final->addArray($tmp);
129      #nfo_debug_write($final);
130      #$res = array('key' => new XML_RPC_Value('value', 'string'));
131      $msg = new XML_RPC_Response($final);
132      #nfo_debug_write($msg);
133      return $msg;
134    }
135    
136    function nfo_authenticate($params) {
137      global $common_sessiondata;
138      #nfo_debug_clean();
139      #nfo_debug_write($params);
140      $meta = $params->getParam(0);
141      $user = $meta->structmem('user');
142      $user = $user->scalarval();
143      $pass = $meta->structmem('pass');
144      $pass = $pass->scalarval();
145      $common_sessiondata['userdata']['name'] = $user;
146      $common_sessiondata['userdata']['password'] = $pass;
147      #nfo_debug_write($common_sessiondata);
148      $retval = common_checkauthorisation();
149      return new XML_RPC_Response(new XML_RPC_Value($retval, 'boolean'));
150    }
151    
152    function nfo_list_contents() {
153    }
154    
155  function nfo_list_users() {  function nfo_list_users() {
156  }  }
157    
158  function nfo_debug_clean() {  function nfo_debug_clean() {
159    #`rm dump`;    `rm dump`;
160  }  }
161    
162  function nfo_debug_write($data) {  function nfo_debug_write($data) {
163    ob_start();    ob_start();
164    print_r($data);    print_r($data);
165    $data = ob_get_clean();    $data = ob_get_clean();
166    $f = fopen('dump', 'w+');    $f = fopen('dump', 'a');
167    fputs($f, $data);    fputs($f, $data . "\n");
168    fclose($f);    fclose($f);
169  }  }
170    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.10

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed