0337d704 |
1 | <?php |
2 | /*************************************************************************** |
50a40a33 |
3 | * Copyright (C) 2003-2006 Polytechnique.org * |
0337d704 |
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 |
22 | require_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 | |
33 | class 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']; |
c36b9cb0 |
54 | $requestprms['user'] = $this->urlparts['user']; |
55 | $requestprms['pass'] = $this->urlparts['pass']; |
03a5279f |
56 | $requestprms['method'] = $function; |
57 | $requestprms['args'] = $arguments; |
0337d704 |
58 | $requestprms['timeout'] = 0; |
03a5279f |
59 | $requestprms['secure'] = 0; |
0337d704 |
60 | |
61 | $result = xu_rpc_http_concise($requestprms); |
62 | if (is_array($result) && isset($result['faultCode'])) { |
63 | print('Error in xmlrpc call \''.$function.'\''."\n"); |
64 | print(' code : '.$result['faultCode']."\n"); |
65 | print(' message: '.$result['faultString']."\n"); |
66 | return false; |
67 | } |
68 | $return = $result; |
69 | return true; |
70 | } |
71 | |
72 | } |
73 | |
74 | overload('xmlrpc_client'); |
75 | |
76 | // vim:set et sw=4 sts=4 sws=4: |
77 | ?> |