Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezxmlrpcclient.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezxmlrpcclient.php 6972 2001-09-05 12:21:54Z ce $
5 //
6 // Definition of eZXMLRPCClient class
7 //
8 // B�rd Farstad <bf@ez.no>
9 // Created on: <16-Dec-2000 10:37:45 bf>
10 //
11 // This source file is part of Exponential Basic, publishing software.
12 // Copyright (C) 1999-2000 eZ systems as
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
29
32
55 // include_once( "ezxmlrpc/classes/ezxmlrpcresponse.php" );
56
57 class eZXMLRPCClient
58 {
66 function __construct( $server, $path, $port=80 )
67 {
68 $this->Server = $server;
69 $this->Path = $path;
70 $this->Port = $port;
71 $this->Debug = false;
72 }
73
77 function setDebug( $debug )
78 {
79 if ( $debug == true )
80 $this->Debug = true;
81 else
82 $this->Debug = false;
83
84 }
85
89 function debug()
90 {
91 return $this->Debug;
92 }
93
98 function setTimeOut( $timeout )
99 {
100 $this->TimeOut = $timeout;
101 }
102
106 function timeOut()
107 {
108 return $this->TimeOut;
109 }
110
114 function errorString( )
115 {
116 return $this->ErrorString;
117 }
118
125 function &send( &$call, $useSSL = false )
126 {
127 $rawResponse = 0;
128 if (!$useSSL || !in_array("curl",get_loaded_extensions()))
129 {
130 if ( is_a( $call, "eZXMLRPCCall" ) )
131 {
132 if ( $Timeout != 0 )
133 {
134 $fp = fsockopen( $this->Server,
135 $this->Port,
136 &$this->errorNumber,
137 &$this->errorString,
138 $this->TimeOut );
139 }
140 else
141 {
142 $fp = fsockopen( $this->Server,
143 $this->Port,
144 &$this->errorNumber,
145 &$this->errorString );
146 }
147
148 $payload =& $call->payload();
149
150 // send the XML-RPC call
151 if ( $fp != 0 )
152 {
153 $authentification = "";
154 if ( ( $this->login() != "" ) )
155 {
156 $authentification = "Authorization: Basic " . base64_encode( $this->login() . ":" . $this->password() ) . "\r\n" ;
157 }
158
159 $HTTPCall = "POST " . $this->Path . " HTTP/1.0\r\n" .
160 "User-Agent: eZ xmlrpc client\r\n" .
161 "Host: " . $this->Server . "\r\n" .
162 $authentification .
163 "Content-Type: text/xml\r\n" .
164 "Content-Length: " . strlen( $payload ) . "\r\n\r\n" .
165 $payload;
166
167 if ( !fputs( $fp, $HTTPCall, strlen( $HTTPCall ) ) )
168 {
169 $this->ErrorString = "<b>Error:</b> could not send the XML-RPC call. Could not write to the socket.";
170 return 0;
171 }
172 }
173
174 $rawResponse = "";
175 unSet( $rawResponse );
176
177 // fetch the XML-RPC response
178 while( $data=fread( $fp, 32768 ) )
179 {
180 $rawResponse .= $data;
181 }
182
183 print( $rawResponse );
184 if ( $this->Debug == true )
185 {
186 print( "<pre>" );
187 print( nl2br ( htmlspecialchars( $rawResponse ) ) );
188 print( "</pre>" );
189 }
190
191 // close the socket
192 fclose( $fp );
193
194
195 }
196 }
197 else
198 {
199 // Call was made with useSSL == true
200 // to use this functionality, you must have cURL (curl.haxx.se) installed and compiled into PHP with --with-ssl enabled.
201 if ( is_a( $call, "eZXMLRPCCall" ) )
202 {
203 $URL = "https://".$this->Server.":".$this->Port.$this->Path;
204 $ch = curl_init ($URL);
205 if ( $Timeout != 0 )
206 {
207 curl_setopt ($ch, CURLOPT_TIMEOUT, $this->TimeOut);
208 }
209 $payload =& $call->payload();
210 // send the XML-RPC call
211 if ( $ch != 0 )
212 {
213 curl_setopt ($ch, CURLOPT_RETURNTRANSFER,1);
214 $HTTPCall = "POST " . $this->Path . " HTTP/1.0\r\n" .
215 "User-Agent: eZ xmlrpc client\r\n" .
216 "Host: " . $this->Server . "\r\n" .
217 "Content-Type: text/xml\r\n" .
218 "Content-Length: " . strlen( $payload )."\r\n";
219 if ($this->Username != "")
220 {
221 $HTTPCall .= "Authorization: Basic " . base64_encode($this->Username . ":" . $this->Password) . "\r\n";
222 }
223 $HTTPCall .= "\r\n" . $payload;
224 curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, $HTTPCall);
225 unSet( $rawResponse );
226 $rawResponse = curl_exec ($ch);
227 if ( !$rawResponse )
228 {
229 $this->ErrorString = "<b>Error:</b> could not send the XML-RPC call. Could not write to the socket.";
230 return 0;
231 }
232 }
233 curl_close($ch);
234 }
235 }
236
237 $response = new eZXMLRPCResponse();
238 $response->decodeStream( $rawResponse );
239
240 return $response;
241 }
242
246 function setLogin( $value )
247 {
248
249 $this->Login = $value;
250 }
251
255 function setPassword( $value )
256 {
257 $this->Password = $value;
258 }
259
263 function login()
264 {
265 return $this->Login;
266 }
267
271 function password()
272 {
273 return $this->Password;
274 }
275
277 var $Server;
278
280 var $Path;
281
283 var $Port;
284
286 var $TimeOut=0;
287
289 var $Login;
290
292 var $Password;
293
295 var $ErrorString;
296
298 var $ErrorNumber;
299
301 var $Debug;
302 }
303
304
305 ?>
eZXMLRPCClient
Definition: ezxmlrpcclient.php:58
eZXMLRPCClient\$Server
$Server
The name or IP of the server to communicate with.
Definition: ezxmlrpcclient.php:277
eZXMLRPCClient\$Debug
$Debug
true if debug output should be shown
Definition: ezxmlrpcclient.php:301
eZXMLRPCClient\send
& send(&$call, $useSSL=false)
Definition: ezxmlrpcclient.php:125
eZXMLRPCClient\setLogin
setLogin( $value)
Definition: ezxmlrpcclient.php:246
eZXMLRPCClient\$TimeOut
$TimeOut
How long to wait for the call.
Definition: ezxmlrpcclient.php:286
eZXMLRPCClient\$Login
$Login
The username to use for authentification.
Definition: ezxmlrpcclient.php:289
eZXMLRPCClient\$ErrorString
$ErrorString
The error string.
Definition: ezxmlrpcclient.php:295
eZXMLRPCClient\timeOut
timeOut()
Definition: ezxmlrpcclient.php:106
eZXMLRPCClient\__construct
__construct( $server, $path, $port=80)
Definition: ezxmlrpcclient.php:66
eZXMLRPCClient\password
password()
Definition: ezxmlrpcclient.php:271
eZXMLRPCClient\$Port
$Port
The port of the server to communicate with.
Definition: ezxmlrpcclient.php:283
eZXMLRPCClient\login
login()
Definition: ezxmlrpcclient.php:263
eZXMLRPCClient\debug
debug()
Definition: ezxmlrpcclient.php:89
eZXMLRPCClient\setPassword
setPassword( $value)
Definition: ezxmlrpcclient.php:255
eZXMLRPCClient\setDebug
setDebug( $debug)
Definition: ezxmlrpcclient.php:77
eZXMLRPCClient\$Path
$Path
The path to the XML-RPC server.
Definition: ezxmlrpcclient.php:280
eZXMLRPCClient\$Password
$Password
The password to use for authentification.
Definition: ezxmlrpcclient.php:292
eZXMLRPCClient\setTimeOut
setTimeOut( $timeout)
Definition: ezxmlrpcclient.php:98
eZXMLRPCClient\$ErrorNumber
$ErrorNumber
The error number.
Definition: ezxmlrpcclient.php:298
eZXMLRPCClient\errorString
errorString()
Definition: ezxmlrpcclient.php:114
eZXMLRPCResponse
Definition: ezxmlrpcresponse.php:50
$fp
$fp
Definition: export.php:97
$server
$server
Definition: ezarticle/xmlrpc/xmlrpcserver.php:63
$URL
$URL
Definition: ezgroupeventcalendar/user/dayview.php:80
$debug
$debug
Definition: ezstats/admin/cron.php:36
$response
while(!feof($socket)) $response
Definition: paypalnotify.php:196
Password
</td ></tr >< tr >< td style="color:<?= isset( $error['password1'] ) ?> Password
Definition: step1.php:146
Username
</td ></tr >< tr >< td style="color:<?= isset( $error['username'] ) ?> Username
Definition: step1.php:144
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.