rename include
[platal.git] / include / platal / xmlrpc-client.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
03a5279f 22require_once 'platal/xmlrpc-server.inc.php';
0337d704 23
24/* taken from : http://fr2.php.net/xml-rpc
25 * Author mboeren@php.net
26 *
27 * Usage:
28 * $client = new xmlrpc_client("http://localhost:7080");
29 * print $client->echo('x')."\n";
30 * print $client->add(1, 3)."\n";
31 */
32
33class xmlrpc_client
34{
35 var $url;
36 var $urlparts;
37
38 function xmlrpc_client($url)
39 {
40 $this->url = $url;
41 $this->urlparts = parse_url($this->url);
03a5279f 42 foreach (array('scheme', 'host', 'user', 'pass', 'path', 'query', 'fragment') as $part) {
0337d704 43 if (!isset($this->urlparts[$part])) {
03a5279f 44 $this->urlparts[$part] = null;
0337d704 45 }
46 }
47 }
48
49 function __call($function, $arguments, &$return)
50 {
03a5279f 51 $requestprms['host'] = $this->urlparts['host'];
52 $requestprms['port'] = $this->urlparts['port'];
53 $requestprms['uri'] = $this->urlparts['path'];
54 $requestprms['method'] = $function;
55 $requestprms['args'] = $arguments;
56 $requestprms['debug'] = 0;
0337d704 57 $requestprms['timeout'] = 0;
03a5279f 58 $requestprms['user'] = $this->urlparts['user'];
59 $requestprms['pass'] = $this->urlparts['pass'];
60 $requestprms['secure'] = 0;
0337d704 61
62 $result = xu_rpc_http_concise($requestprms);
63 if (is_array($result) && isset($result['faultCode'])) {
64 print('Error in xmlrpc call \''.$function.'\''."\n");
65 print(' code : '.$result['faultCode']."\n");
66 print(' message: '.$result['faultString']."\n");
67 return false;
68 }
69 $return = $result;
70 return true;
71 }
72
73}
74
75overload('xmlrpc_client');
76
77// vim:set et sw=4 sts=4 sws=4:
78?>