3 |
## $Id$ |
## $Id$ |
4 |
## -------------------------------------------------------------------------- |
## -------------------------------------------------------------------------- |
5 |
## $Log$ |
## $Log$ |
6 |
|
## Revision 1.5 2002/12/22 13:24:09 jonen |
7 |
|
## + added utf8 encoding at 'send()' toggled by option |
8 |
|
## |
9 |
|
## Revision 1.4 2002/12/19 02:02:25 jonen |
10 |
|
## + minor changes |
11 |
|
## |
12 |
|
## Revision 1.3 2002/12/19 01:59:37 jonen |
13 |
|
## + minor changes: coment debug prints |
14 |
|
## |
15 |
## Revision 1.2 2002/12/05 21:45:31 joko |
## Revision 1.2 2002/12/05 21:45:31 joko |
16 |
## + debugging |
## + debugging |
17 |
## |
## |
41 |
if ($args['Port']) { $this->port = $args['Port']; } |
if ($args['Port']) { $this->port = $args['Port']; } |
42 |
} |
} |
43 |
|
|
44 |
function send($command, $data = "") { |
function send($command, $data = "", $options = array()) { |
45 |
//$encoder = new Text_Encode($data); |
// do 'encode' here and ... |
46 |
//$encoder->toUTF8(); |
if ($options[utf8]) { |
47 |
return $this->call($command, $data, 1); |
$encoder = new TextEncode($data); |
48 |
|
$encoder->toUTF8(); |
49 |
|
} |
50 |
|
// call '_call' with 'decode' |
51 |
|
return $this->_call($command, $data, 1); |
52 |
} |
} |
53 |
|
|
54 |
function call($command, $data = "", $decode = 0) { |
function _call($command, $data = "", $decode = 0) { |
55 |
|
|
56 |
//print "call: <hr>"; |
//print "call: $command<hr>"; |
57 |
|
|
58 |
|
// print Dumper($data); |
59 |
|
|
60 |
// data |
// data |
61 |
$data_enc = XML_RPC_encode($data); |
$data_enc = XML_RPC_encode($data); |
63 |
// message - request |
// message - request |
64 |
$msg = new XML_RPC_Message($command); |
$msg = new XML_RPC_Message($command); |
65 |
$msg->addParam($data_enc); |
$msg->addParam($data_enc); |
66 |
|
//print htmlentities($msg->serialize()); |
67 |
// remote procedure call |
// remote procedure call |
68 |
$rpc = new XML_RPC_Client("/", $this->host, $this->port); |
$rpc = new XML_RPC_Client("/", $this->host, $this->port); |
69 |
$rpc->setDebug(0); |
$rpc->setDebug(0); |
70 |
if ( !$msg_response = $rpc->send($msg) ) { |
if ( !$msg_response = $rpc->send($msg) ) { |
71 |
// TODO: redirect this error elsewhere! |
// TODO: redirect this error elsewhere! |
72 |
//print "RPC-error!<br>"; |
print "RPC-error!<br>"; |
73 |
return; |
return; |
74 |
} |
} |
75 |
// message - response |
// message - response |