/[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.9 by xabbu, Sun Sep 12 00:42:39 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            "signature" => array(array('struct','struct','struct')),
28          ),
29          "getContent" => array(
30            "function" => "nfo_get_content",
31            "signature" => array(array('struct', 'string')),
32          ),
33          "listTopics" => array(
34            "function" => "nfo_list_topics",
35            "signature" => array(array('struct', 'struct')),
36          ),
37          "authenticate" => array(
38            "function" => "nfo_authenticate",
39            "signature" => array(array('boolean', 'struct')),
40          ),
41        "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"),  
42        "listUsers" => array("function" => "nfo_list_users"),        "listUsers" => array("function" => "nfo_list_users"),
43      ));      ));
44      break;      break;
45    default:    default:
46      break;      break;
47  }  }
48          #"getContent" => array("function" => "nfo_get_content"),
49            #"signature" => array(array($xmlrpcStruct, $xmlrpcString))
50            #"signature" => array($XML_RPC_Struct, $XML_RPC_String)
51    
52    function nfo_query($params) {
53      
54      $querytxt = $params->getParam(0);
55      $nqlquery = $querytxt->getval();
56      nfo_debug_clean();
57      #nfo_debug_write($params);
58      #nfo_debug_write($nqlquery);
59      $result = array();
60      cms_query($nqlquery,&$result);
61      #nfo_debug_write($result);
62    
63  function nfo_list_topics() {    $structinfo = array();
64  }    $structcontent = array();
65  function nfo_list_contents() {    $structfields = array();
66      
67      foreach ($result[0] as $key => $value) {
68       $structinfo[$key] = new XML_RPC_Value($value,"string");
69        }
70      foreach ($result[1] as $key => $value)  {
71       $structcontent[$key] = new XML_RPC_Value($value,"struct");
72        }
73      foreach ($result[2] as $key => $value) {
74       $structfields[$key] = new XML_RPC_Value($value,"string");
75       }
76      $struct = array();
77      $struct[0] = new XML_RPC_Value($structinfo,"struct");
78      $struct[1] = new XML_RPC_Value($structcontent,"struct");
79      $struct[2] = new XML_RPC_Value($structfields,"struct");
80      
81      $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct"));
82      nfo_debug_write($xmldoc);
83      #nfo_debug_write($xmldoc->serialize());
84    
85    return $xmldoc;
86      
87  }  }
88  function nfo_get_content($ck) {  
89    
90    function nfo_get_content($params) {
91      $ck = $params->getParam(0);
92      $ck = $ck->scalarval();
93    #nfo_debug_clean();    #nfo_debug_clean();
94    #nfo_debug_write("ck: $ck\n");    #nfo_debug_write($ck);
   $ck = 'Home';  
95    $content = cms_getcontent('xmlpage', $ck);    $content = cms_getcontent('xmlpage', $ck);
96    nfo_debug_write($content);    #nfo_debug_write($content);
97    #return new XML_RPC_Response(new XML_RPC_Value("content", "string"));    #return new XML_RPC_Response(new XML_RPC_Value("content", "string"));
98    $struct = array();    $struct = array();
99    foreach ($content as $key => $value) {    foreach ($content as $key => $value) {
100      $struct[$key] = new XML_RPC_Value($value, "string");      $struct[$key] = new XML_RPC_Value($value, "string");
101    }    }
102    $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());  
103    return $xmldoc;    return $xmldoc;
104  }  }
105    
106    function nfo_list_topics($params) {
107      nfo_debug_clean();
108      nfo_debug_write($params);
109      nfo_debug_write("list_topics");
110      $meta = $params->getParam(0);
111      nfo_debug_write($meta);
112      $type = $meta->structmem('type');
113      $type = $type->scalarval();
114      #nfo_debug_write("$type");
115      $res = cms_getindex($type);
116      #nfo_debug_write($res);
117      $newentries = array();
118      $tmp = new XML_RPC_Value();
119      foreach ($res as $entry) {
120        $newentry = array();
121        foreach ($entry as $key => $value) {
122           $newvalue = new XML_RPC_Value($value, 'string');
123           $newentry[$key] = $newvalue;
124        }
125        #$tmp->addStruct($newentry);
126        array_push($newentries, new XML_RPC_Value($newentry, 'struct'));
127      }
128      $final = new XML_RPC_Value($newentries, 'array');
129      #$final->addArray($tmp);
130      #nfo_debug_write($final);
131      #$res = array('key' => new XML_RPC_Value('value', 'string'));
132      $msg = new XML_RPC_Response($final);
133      #nfo_debug_write($msg);
134      return $msg;
135    }
136    
137    function nfo_authenticate($params) {
138      global $common_sessiondata;
139      #nfo_debug_clean();
140      #nfo_debug_write($params);
141      $meta = $params->getParam(0);
142      $user = $meta->structmem('user');
143      $user = $user->scalarval();
144      $pass = $meta->structmem('pass');
145      $pass = $pass->scalarval();
146      $common_sessiondata['userdata']['name'] = $user;
147      $common_sessiondata['userdata']['password'] = $pass;
148      #nfo_debug_write($common_sessiondata);
149      $retval = common_checkauthorisation();
150      return new XML_RPC_Response(new XML_RPC_Value($retval, 'boolean'));
151    }
152    
153    function nfo_list_contents() {
154    }
155    
156  function nfo_list_users() {  function nfo_list_users() {
157  }  }
158    
159  function nfo_debug_clean() {  function nfo_debug_clean() {
160    #`rm dump`;    `rm dump`;
161  }  }
162    
163  function nfo_debug_write($data) {  function nfo_debug_write($data) {
164    ob_start();    ob_start();
165    print_r($data);    print_r($data);
166    $data = ob_get_clean();    $data = ob_get_clean();
167    $f = fopen('dump', 'w+');    $f = fopen('dump', 'a');
168    fputs($f, $data);    fputs($f, $data . "\n");
169    fclose($f);    fclose($f);
170  }  }
171    

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

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