Completed
Pull Request — 1.11.x (#1628)
by José
97:30 queued 69:06
created
main/inc/lib/nusoap/class.soap_server.php 1 patch
Indentation   +1020 added lines, -1020 removed lines patch added patch discarded remove patch
@@ -12,1079 +12,1079 @@  discard block
 block discarded – undo
12 12
 */
13 13
 class nusoap_server extends nusoap_base
14 14
 {
15
-	/**
16
-	 * HTTP headers of request
17
-	 * @var array
18
-	 * @access private
19
-	 */
20
-	var $headers = array();
21
-	/**
22
-	 * HTTP request
23
-	 * @var string
24
-	 * @access private
25
-	 */
26
-	var $request = '';
27
-	/**
28
-	 * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
29
-	 * @var string
30
-	 * @access public
31
-	 */
32
-	var $requestHeaders = '';
33
-	/**
34
-	 * SOAP Headers from request (parsed)
35
-	 * @var mixed
36
-	 * @access public
37
-	 */
38
-	var $requestHeader = NULL;
39
-	/**
40
-	 * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
41
-	 * @var string
42
-	 * @access public
43
-	 */
44
-	var $document = '';
45
-	/**
46
-	 * SOAP payload for request (text)
47
-	 * @var string
48
-	 * @access public
49
-	 */
50
-	var $requestSOAP = '';
51
-	/**
52
-	 * requested method namespace URI
53
-	 * @var string
54
-	 * @access private
55
-	 */
56
-	var $methodURI = '';
57
-	/**
58
-	 * name of method requested
59
-	 * @var string
60
-	 * @access private
61
-	 */
62
-	var $methodname = '';
63
-	/**
64
-	 * method parameters from request
65
-	 * @var array
66
-	 * @access private
67
-	 */
68
-	var $methodparams = array();
69
-	/**
70
-	 * SOAP Action from request
71
-	 * @var string
72
-	 * @access private
73
-	 */
74
-	var $SOAPAction = '';
75
-	/**
76
-	 * character set encoding of incoming (request) messages
77
-	 * @var string
78
-	 * @access public
79
-	 */
80
-	var $xml_encoding = '';
81
-	/**
82
-	 * toggles whether the parser decodes element content w/ utf8_decode()
83
-	 * @var boolean
84
-	 * @access public
85
-	 */
15
+    /**
16
+     * HTTP headers of request
17
+     * @var array
18
+     * @access private
19
+     */
20
+    var $headers = array();
21
+    /**
22
+     * HTTP request
23
+     * @var string
24
+     * @access private
25
+     */
26
+    var $request = '';
27
+    /**
28
+     * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
29
+     * @var string
30
+     * @access public
31
+     */
32
+    var $requestHeaders = '';
33
+    /**
34
+     * SOAP Headers from request (parsed)
35
+     * @var mixed
36
+     * @access public
37
+     */
38
+    var $requestHeader = NULL;
39
+    /**
40
+     * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
41
+     * @var string
42
+     * @access public
43
+     */
44
+    var $document = '';
45
+    /**
46
+     * SOAP payload for request (text)
47
+     * @var string
48
+     * @access public
49
+     */
50
+    var $requestSOAP = '';
51
+    /**
52
+     * requested method namespace URI
53
+     * @var string
54
+     * @access private
55
+     */
56
+    var $methodURI = '';
57
+    /**
58
+     * name of method requested
59
+     * @var string
60
+     * @access private
61
+     */
62
+    var $methodname = '';
63
+    /**
64
+     * method parameters from request
65
+     * @var array
66
+     * @access private
67
+     */
68
+    var $methodparams = array();
69
+    /**
70
+     * SOAP Action from request
71
+     * @var string
72
+     * @access private
73
+     */
74
+    var $SOAPAction = '';
75
+    /**
76
+     * character set encoding of incoming (request) messages
77
+     * @var string
78
+     * @access public
79
+     */
80
+    var $xml_encoding = '';
81
+    /**
82
+     * toggles whether the parser decodes element content w/ utf8_decode()
83
+     * @var boolean
84
+     * @access public
85
+     */
86 86
     var $decode_utf8 = true;
87 87
 
88
-	/**
89
-	 * HTTP headers of response
90
-	 * @var array
91
-	 * @access public
92
-	 */
93
-	var $outgoing_headers = array();
94
-	/**
95
-	 * HTTP response
96
-	 * @var string
97
-	 * @access private
98
-	 */
99
-	var $response = '';
100
-	/**
101
-	 * SOAP headers for response (text or array of soapval or associative array)
102
-	 * @var mixed
103
-	 * @access public
104
-	 */
105
-	var $responseHeaders = '';
106
-	/**
107
-	 * SOAP payload for response (text)
108
-	 * @var string
109
-	 * @access private
110
-	 */
111
-	var $responseSOAP = '';
112
-	/**
113
-	 * method return value to place in response
114
-	 * @var mixed
115
-	 * @access private
116
-	 */
117
-	var $methodreturn = false;
118
-	/**
119
-	 * whether $methodreturn is a string of literal XML
120
-	 * @var boolean
121
-	 * @access public
122
-	 */
123
-	var $methodreturnisliteralxml = false;
124
-	/**
125
-	 * SOAP fault for response (or false)
126
-	 * @var mixed
127
-	 * @access private
128
-	 */
129
-	var $fault = false;
130
-	/**
131
-	 * text indication of result (for debugging)
132
-	 * @var string
133
-	 * @access private
134
-	 */
135
-	var $result = 'successful';
88
+    /**
89
+     * HTTP headers of response
90
+     * @var array
91
+     * @access public
92
+     */
93
+    var $outgoing_headers = array();
94
+    /**
95
+     * HTTP response
96
+     * @var string
97
+     * @access private
98
+     */
99
+    var $response = '';
100
+    /**
101
+     * SOAP headers for response (text or array of soapval or associative array)
102
+     * @var mixed
103
+     * @access public
104
+     */
105
+    var $responseHeaders = '';
106
+    /**
107
+     * SOAP payload for response (text)
108
+     * @var string
109
+     * @access private
110
+     */
111
+    var $responseSOAP = '';
112
+    /**
113
+     * method return value to place in response
114
+     * @var mixed
115
+     * @access private
116
+     */
117
+    var $methodreturn = false;
118
+    /**
119
+     * whether $methodreturn is a string of literal XML
120
+     * @var boolean
121
+     * @access public
122
+     */
123
+    var $methodreturnisliteralxml = false;
124
+    /**
125
+     * SOAP fault for response (or false)
126
+     * @var mixed
127
+     * @access private
128
+     */
129
+    var $fault = false;
130
+    /**
131
+     * text indication of result (for debugging)
132
+     * @var string
133
+     * @access private
134
+     */
135
+    var $result = 'successful';
136 136
 
137
-	/**
138
-	 * assoc array of operations => opData; operations are added by the register()
139
-	 * method or by parsing an external WSDL definition
140
-	 * @var array
141
-	 * @access private
142
-	 */
143
-	var $operations = array();
144
-	/**
145
-	 * wsdl instance (if one)
146
-	 * @var mixed
147
-	 * @access private
148
-	 */
149
-	var $wsdl = false;
150
-	/**
151
-	 * URL for WSDL (if one)
152
-	 * @var mixed
153
-	 * @access private
154
-	 */
155
-	var $externalWSDLURL = false;
156
-	/**
157
-	 * whether to append debug to response as XML comment
158
-	 * @var boolean
159
-	 * @access public
160
-	 */
161
-	var $debug_flag = false;
137
+    /**
138
+     * assoc array of operations => opData; operations are added by the register()
139
+     * method or by parsing an external WSDL definition
140
+     * @var array
141
+     * @access private
142
+     */
143
+    var $operations = array();
144
+    /**
145
+     * wsdl instance (if one)
146
+     * @var mixed
147
+     * @access private
148
+     */
149
+    var $wsdl = false;
150
+    /**
151
+     * URL for WSDL (if one)
152
+     * @var mixed
153
+     * @access private
154
+     */
155
+    var $externalWSDLURL = false;
156
+    /**
157
+     * whether to append debug to response as XML comment
158
+     * @var boolean
159
+     * @access public
160
+     */
161
+    var $debug_flag = false;
162 162
 
163 163
 
164
-	/**
165
-	* constructor
166
-    * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
167
-	*
168
-    * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169
-	* @access   public
170
-	*/
171
-	function __construct($wsdl=false)
164
+    /**
165
+     * constructor
166
+     * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
167
+     *
168
+     * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169
+     * @access   public
170
+     */
171
+    function __construct($wsdl=false)
172 172
     {
173
-		parent::__construct();
174
-		// turn on debugging?
175
-		global $debug;
176
-		global $HTTP_SERVER_VARS;
173
+        parent::__construct();
174
+        // turn on debugging?
175
+        global $debug;
176
+        global $HTTP_SERVER_VARS;
177 177
 
178
-		if (isset($_SERVER)) {
179
-			$this->debug("_SERVER is defined:");
180
-			$this->appendDebug($this->varDump($_SERVER));
181
-		} elseif (isset($HTTP_SERVER_VARS)) {
182
-			$this->debug("HTTP_SERVER_VARS is defined:");
183
-			$this->appendDebug($this->varDump($HTTP_SERVER_VARS));
184
-		} else {
185
-			$this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
186
-		}
178
+        if (isset($_SERVER)) {
179
+            $this->debug("_SERVER is defined:");
180
+            $this->appendDebug($this->varDump($_SERVER));
181
+        } elseif (isset($HTTP_SERVER_VARS)) {
182
+            $this->debug("HTTP_SERVER_VARS is defined:");
183
+            $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
184
+        } else {
185
+            $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
186
+        }
187 187
 
188
-		if (isset($debug)) {
189
-			$this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
190
-			$this->debug_flag = $debug;
191
-		} elseif (isset($_SERVER['QUERY_STRING'])) {
192
-			$qs = explode('&', $_SERVER['QUERY_STRING']);
193
-			foreach ($qs as $v) {
194
-				if (substr($v, 0, 6) == 'debug=') {
195
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
-					$this->debug_flag = substr($v, 6);
197
-				}
198
-			}
199
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
200
-			$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201
-			foreach ($qs as $v) {
202
-				if (substr($v, 0, 6) == 'debug=') {
203
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
-					$this->debug_flag = substr($v, 6);
205
-				}
206
-			}
207
-		}
188
+        if (isset($debug)) {
189
+            $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
190
+            $this->debug_flag = $debug;
191
+        } elseif (isset($_SERVER['QUERY_STRING'])) {
192
+            $qs = explode('&', $_SERVER['QUERY_STRING']);
193
+            foreach ($qs as $v) {
194
+                if (substr($v, 0, 6) == 'debug=') {
195
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
+                    $this->debug_flag = substr($v, 6);
197
+                }
198
+            }
199
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
200
+            $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201
+            foreach ($qs as $v) {
202
+                if (substr($v, 0, 6) == 'debug=') {
203
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
+                    $this->debug_flag = substr($v, 6);
205
+                }
206
+            }
207
+        }
208 208
 
209
-		// wsdl
210
-		if($wsdl){
211
-			$this->debug("In nusoap_server, WSDL is specified");
212
-			if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213
-				$this->wsdl = $wsdl;
209
+        // wsdl
210
+        if($wsdl){
211
+            $this->debug("In nusoap_server, WSDL is specified");
212
+            if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213
+                $this->wsdl = $wsdl;
214 214
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
215
-				$this->externalWSDLURL = $this->wsdl->wsdl;
216
-				$this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
-			} else {
218
-				$this->debug('Create wsdl from ' . $wsdl);
219
-				$this->wsdl = new wsdl($wsdl);
215
+                $this->externalWSDLURL = $this->wsdl->wsdl;
216
+                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
+            } else {
218
+                $this->debug('Create wsdl from ' . $wsdl);
219
+                $this->wsdl = new wsdl($wsdl);
220 220
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
221
-				$this->externalWSDLURL = $wsdl;
222
-			}
223
-			$this->appendDebug($this->wsdl->getDebug());
224
-			$this->wsdl->clearDebug();
225
-			if($err = $this->wsdl->getError()){
226
-				die('WSDL ERROR: '.$err);
227
-			}
228
-		}
229
-	}
221
+                $this->externalWSDLURL = $wsdl;
222
+            }
223
+            $this->appendDebug($this->wsdl->getDebug());
224
+            $this->wsdl->clearDebug();
225
+            if($err = $this->wsdl->getError()){
226
+                die('WSDL ERROR: '.$err);
227
+            }
228
+        }
229
+    }
230 230
 
231
-	/**
232
-	* processes request and returns response
233
-	*
234
-	* @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235
-	* @access   public
236
-	*/
237
-	function service($data){
238
-		global $HTTP_SERVER_VARS;
231
+    /**
232
+     * processes request and returns response
233
+     *
234
+     * @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235
+     * @access   public
236
+     */
237
+    function service($data){
238
+        global $HTTP_SERVER_VARS;
239 239
 
240
-		if (isset($_SERVER['REQUEST_METHOD'])) {
241
-			$rm = $_SERVER['REQUEST_METHOD'];
242
-		} elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
243
-			$rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
244
-		} else {
245
-			$rm = '';
246
-		}
240
+        if (isset($_SERVER['REQUEST_METHOD'])) {
241
+            $rm = $_SERVER['REQUEST_METHOD'];
242
+        } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
243
+            $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
244
+        } else {
245
+            $rm = '';
246
+        }
247 247
 
248
-		if (isset($_SERVER['QUERY_STRING'])) {
249
-			$qs = $_SERVER['QUERY_STRING'];
250
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
251
-			$qs = $HTTP_SERVER_VARS['QUERY_STRING'];
252
-		} else {
253
-			$qs = '';
254
-		}
255
-		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
248
+        if (isset($_SERVER['QUERY_STRING'])) {
249
+            $qs = $_SERVER['QUERY_STRING'];
250
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
251
+            $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
252
+        } else {
253
+            $qs = '';
254
+        }
255
+        $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
256 256
 
257
-		if ($rm == 'POST') {
258
-			$this->debug("In service, invoke the request");
259
-			$this->parse_request($data);
260
-			if (! $this->fault) {
261
-				$this->invoke_method();
262
-			}
263
-			if (! $this->fault) {
264
-				$this->serialize_return();
265
-			}
266
-			$this->send_response();
267
-		} elseif (preg_match('/wsdl/', $qs) ){
268
-			$this->debug("In service, this is a request for WSDL");
269
-			if ($this->externalWSDLURL){
270
-              if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271
-				$this->debug("In service, re-direct for WSDL");
272
-				header('Location: '.$this->externalWSDLURL);
273
-              } else { // assume file
274
-				$this->debug("In service, use file passthru for WSDL");
257
+        if ($rm == 'POST') {
258
+            $this->debug("In service, invoke the request");
259
+            $this->parse_request($data);
260
+            if (! $this->fault) {
261
+                $this->invoke_method();
262
+            }
263
+            if (! $this->fault) {
264
+                $this->serialize_return();
265
+            }
266
+            $this->send_response();
267
+        } elseif (preg_match('/wsdl/', $qs) ){
268
+            $this->debug("In service, this is a request for WSDL");
269
+            if ($this->externalWSDLURL){
270
+                if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271
+                $this->debug("In service, re-direct for WSDL");
272
+                header('Location: '.$this->externalWSDLURL);
273
+                } else { // assume file
274
+                $this->debug("In service, use file passthru for WSDL");
275 275
                 header("Content-Type: text/xml\r\n");
276
-				$pos = strpos($this->externalWSDLURL, "file://");
277
-				if ($pos === false) {
278
-					$filename = $this->externalWSDLURL;
279
-				} else {
280
-					$filename = substr($this->externalWSDLURL, $pos + 7);
281
-				}
276
+                $pos = strpos($this->externalWSDLURL, "file://");
277
+                if ($pos === false) {
278
+                    $filename = $this->externalWSDLURL;
279
+                } else {
280
+                    $filename = substr($this->externalWSDLURL, $pos + 7);
281
+                }
282 282
                 $fp = fopen($this->externalWSDLURL, 'r');
283 283
                 fpassthru($fp);
284
-              }
285
-			} elseif ($this->wsdl) {
286
-				$this->debug("In service, serialize WSDL");
284
+                }
285
+            } elseif ($this->wsdl) {
286
+                $this->debug("In service, serialize WSDL");
287 287
                 header("Content-Type: text/xml; charset=".$this->soap_defencoding."\r\n");
288
-				print $this->wsdl->serialize($this->debug_flag);
289
-				if ($this->debug_flag) {
290
-					$this->debug('wsdl:');
291
-					$this->appendDebug($this->varDump($this->wsdl));
292
-					print $this->getDebugAsXMLComment();
293
-				}
294
-			} else {
295
-				$this->debug("In service, there is no WSDL");
288
+                print $this->wsdl->serialize($this->debug_flag);
289
+                if ($this->debug_flag) {
290
+                    $this->debug('wsdl:');
291
+                    $this->appendDebug($this->varDump($this->wsdl));
292
+                    print $this->getDebugAsXMLComment();
293
+                }
294
+            } else {
295
+                $this->debug("In service, there is no WSDL");
296 296
                 header("Content-Type: text/html; charset=".$this->soap_defencoding."\r\n");
297
-				print "This service does not provide WSDL";
298
-			}
299
-		} elseif ($this->wsdl) {
300
-			$this->debug("In service, return Web description");
301
-			print $this->wsdl->webDescription();
302
-		} else {
303
-			$this->debug("In service, no Web description");
304
-			header("Content-Type: text/html; charset=ISO-8859-1\r\n");
305
-			print "This service does not provide a Web description";
306
-		}
307
-	}
297
+                print "This service does not provide WSDL";
298
+            }
299
+        } elseif ($this->wsdl) {
300
+            $this->debug("In service, return Web description");
301
+            print $this->wsdl->webDescription();
302
+        } else {
303
+            $this->debug("In service, no Web description");
304
+            header("Content-Type: text/html; charset=ISO-8859-1\r\n");
305
+            print "This service does not provide a Web description";
306
+        }
307
+    }
308 308
 
309
-	/**
310
-	* parses HTTP request headers.
311
-	*
312
-	* The following fields are set by this function (when successful)
313
-	*
314
-	* headers
315
-	* request
316
-	* xml_encoding
317
-	* SOAPAction
318
-	*
319
-	* @access   private
320
-	*/
321
-	function parse_http_headers() {
322
-		global $HTTP_SERVER_VARS;
309
+    /**
310
+     * parses HTTP request headers.
311
+     *
312
+     * The following fields are set by this function (when successful)
313
+     *
314
+     * headers
315
+     * request
316
+     * xml_encoding
317
+     * SOAPAction
318
+     *
319
+     * @access   private
320
+     */
321
+    function parse_http_headers() {
322
+        global $HTTP_SERVER_VARS;
323 323
 
324
-		$this->request = '';
325
-		$this->SOAPAction = '';
326
-		if(function_exists('getallheaders')){
327
-			$this->debug("In parse_http_headers, use getallheaders");
328
-			$headers = getallheaders();
329
-			foreach($headers as $k=>$v){
330
-				$k = strtolower($k);
331
-				$this->headers[$k] = $v;
332
-				$this->request .= "$k: $v\r\n";
333
-				$this->debug("$k: $v");
334
-			}
335
-			// get SOAPAction header
336
-			if(isset($this->headers['soapaction'])){
337
-				$this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
338
-			}
339
-			// get the character encoding of the incoming request
340
-			if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
-				$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
-				if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
343
-					$this->xml_encoding = strtoupper($enc);
344
-				} else {
345
-					$this->xml_encoding = 'US-ASCII';
346
-				}
347
-			} else {
348
-				// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349
-				$this->xml_encoding = 'ISO-8859-1';
350
-			}
351
-		} elseif(isset($_SERVER) && is_array($_SERVER)){
352
-			$this->debug("In parse_http_headers, use _SERVER");
353
-			foreach ($_SERVER as $k => $v) {
354
-				if (substr($k, 0, 5) == 'HTTP_') {
355
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
356
-				} else {
357
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
358
-				}
359
-				if ($k == 'soapaction') {
360
-					// get SOAPAction header
361
-					$k = 'SOAPAction';
362
-					$v = str_replace('"', '', $v);
363
-					$v = str_replace('\\', '', $v);
364
-					$this->SOAPAction = $v;
365
-				} else if ($k == 'content-type') {
366
-					// get the character encoding of the incoming request
367
-					if (strpos($v, '=')) {
368
-						$enc = substr(strstr($v, '='), 1);
369
-						$enc = str_replace('"', '', $enc);
370
-						$enc = str_replace('\\', '', $enc);
371
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
372
-							$this->xml_encoding = strtoupper($enc);
373
-						} else {
374
-							$this->xml_encoding = 'US-ASCII';
375
-						}
376
-					} else {
377
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
378
-						$this->xml_encoding = 'ISO-8859-1';
379
-					}
380
-				}
381
-				$this->headers[$k] = $v;
382
-				$this->request .= "$k: $v\r\n";
383
-				$this->debug("$k: $v");
384
-			}
385
-		} elseif (is_array($HTTP_SERVER_VARS)) {
386
-			$this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387
-			foreach ($HTTP_SERVER_VARS as $k => $v) {
388
-				if (substr($k, 0, 5) == 'HTTP_') {
389
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
390
-				} else {
391
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
392
-				}
393
-				if ($k == 'soapaction') {
394
-					// get SOAPAction header
395
-					$k = 'SOAPAction';
396
-					$v = str_replace('"', '', $v);
397
-					$v = str_replace('\\', '', $v);
398
-					$this->SOAPAction = $v;
399
-				} else if ($k == 'content-type') {
400
-					// get the character encoding of the incoming request
401
-					if (strpos($v, '=')) {
402
-						$enc = substr(strstr($v, '='), 1);
403
-						$enc = str_replace('"', '', $enc);
404
-						$enc = str_replace('\\', '', $enc);
405
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
406
-							$this->xml_encoding = strtoupper($enc);
407
-						} else {
408
-							$this->xml_encoding = 'US-ASCII';
409
-						}
410
-					} else {
411
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
412
-						$this->xml_encoding = 'ISO-8859-1';
413
-					}
414
-				}
415
-				$this->headers[$k] = $v;
416
-				$this->request .= "$k: $v\r\n";
417
-				$this->debug("$k: $v");
418
-			}
419
-		} else {
420
-			$this->debug("In parse_http_headers, HTTP headers not accessible");
421
-			$this->setError("HTTP headers not accessible");
422
-		}
423
-	}
324
+        $this->request = '';
325
+        $this->SOAPAction = '';
326
+        if(function_exists('getallheaders')){
327
+            $this->debug("In parse_http_headers, use getallheaders");
328
+            $headers = getallheaders();
329
+            foreach($headers as $k=>$v){
330
+                $k = strtolower($k);
331
+                $this->headers[$k] = $v;
332
+                $this->request .= "$k: $v\r\n";
333
+                $this->debug("$k: $v");
334
+            }
335
+            // get SOAPAction header
336
+            if(isset($this->headers['soapaction'])){
337
+                $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
338
+            }
339
+            // get the character encoding of the incoming request
340
+            if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
+                $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
+                if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
343
+                    $this->xml_encoding = strtoupper($enc);
344
+                } else {
345
+                    $this->xml_encoding = 'US-ASCII';
346
+                }
347
+            } else {
348
+                // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349
+                $this->xml_encoding = 'ISO-8859-1';
350
+            }
351
+        } elseif(isset($_SERVER) && is_array($_SERVER)){
352
+            $this->debug("In parse_http_headers, use _SERVER");
353
+            foreach ($_SERVER as $k => $v) {
354
+                if (substr($k, 0, 5) == 'HTTP_') {
355
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
356
+                } else {
357
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
358
+                }
359
+                if ($k == 'soapaction') {
360
+                    // get SOAPAction header
361
+                    $k = 'SOAPAction';
362
+                    $v = str_replace('"', '', $v);
363
+                    $v = str_replace('\\', '', $v);
364
+                    $this->SOAPAction = $v;
365
+                } else if ($k == 'content-type') {
366
+                    // get the character encoding of the incoming request
367
+                    if (strpos($v, '=')) {
368
+                        $enc = substr(strstr($v, '='), 1);
369
+                        $enc = str_replace('"', '', $enc);
370
+                        $enc = str_replace('\\', '', $enc);
371
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
372
+                            $this->xml_encoding = strtoupper($enc);
373
+                        } else {
374
+                            $this->xml_encoding = 'US-ASCII';
375
+                        }
376
+                    } else {
377
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
378
+                        $this->xml_encoding = 'ISO-8859-1';
379
+                    }
380
+                }
381
+                $this->headers[$k] = $v;
382
+                $this->request .= "$k: $v\r\n";
383
+                $this->debug("$k: $v");
384
+            }
385
+        } elseif (is_array($HTTP_SERVER_VARS)) {
386
+            $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387
+            foreach ($HTTP_SERVER_VARS as $k => $v) {
388
+                if (substr($k, 0, 5) == 'HTTP_') {
389
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
390
+                } else {
391
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
392
+                }
393
+                if ($k == 'soapaction') {
394
+                    // get SOAPAction header
395
+                    $k = 'SOAPAction';
396
+                    $v = str_replace('"', '', $v);
397
+                    $v = str_replace('\\', '', $v);
398
+                    $this->SOAPAction = $v;
399
+                } else if ($k == 'content-type') {
400
+                    // get the character encoding of the incoming request
401
+                    if (strpos($v, '=')) {
402
+                        $enc = substr(strstr($v, '='), 1);
403
+                        $enc = str_replace('"', '', $enc);
404
+                        $enc = str_replace('\\', '', $enc);
405
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
406
+                            $this->xml_encoding = strtoupper($enc);
407
+                        } else {
408
+                            $this->xml_encoding = 'US-ASCII';
409
+                        }
410
+                    } else {
411
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
412
+                        $this->xml_encoding = 'ISO-8859-1';
413
+                    }
414
+                }
415
+                $this->headers[$k] = $v;
416
+                $this->request .= "$k: $v\r\n";
417
+                $this->debug("$k: $v");
418
+            }
419
+        } else {
420
+            $this->debug("In parse_http_headers, HTTP headers not accessible");
421
+            $this->setError("HTTP headers not accessible");
422
+        }
423
+    }
424 424
 
425
-	/**
426
-	* parses a request
427
-	*
428
-	* The following fields are set by this function (when successful)
429
-	*
430
-	* headers
431
-	* request
432
-	* xml_encoding
433
-	* SOAPAction
434
-	* request
435
-	* requestSOAP
436
-	* methodURI
437
-	* methodname
438
-	* methodparams
439
-	* requestHeaders
440
-	* document
441
-	*
442
-	* This sets the fault field on error
443
-	*
444
-	* @param    string $data XML string
445
-	* @access   private
446
-	*/
447
-	function parse_request($data='') {
448
-		$this->debug('entering parse_request()');
449
-		$this->parse_http_headers();
450
-		$this->debug('got character encoding: '.$this->xml_encoding);
451
-		// uncompress if necessary
452
-		if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
-			$this->debug('got content encoding: ' . $this->headers['content-encoding']);
454
-			if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455
-		    	// if decoding works, use it. else assume data wasn't gzencoded
456
-				if (function_exists('gzuncompress')) {
457
-					if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
458
-						$data = $degzdata;
459
-					} elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
460
-						$data = $degzdata;
461
-					} else {
462
-						$this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
463
-						return;
464
-					}
465
-				} else {
466
-					$this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
467
-					return;
468
-				}
469
-			}
470
-		}
471
-		$this->request .= "\r\n".$data;
472
-		$data = $this->parseRequest($this->headers, $data);
473
-		$this->requestSOAP = $data;
474
-		$this->debug('leaving parse_request');
475
-	}
425
+    /**
426
+     * parses a request
427
+     *
428
+     * The following fields are set by this function (when successful)
429
+     *
430
+     * headers
431
+     * request
432
+     * xml_encoding
433
+     * SOAPAction
434
+     * request
435
+     * requestSOAP
436
+     * methodURI
437
+     * methodname
438
+     * methodparams
439
+     * requestHeaders
440
+     * document
441
+     *
442
+     * This sets the fault field on error
443
+     *
444
+     * @param    string $data XML string
445
+     * @access   private
446
+     */
447
+    function parse_request($data='') {
448
+        $this->debug('entering parse_request()');
449
+        $this->parse_http_headers();
450
+        $this->debug('got character encoding: '.$this->xml_encoding);
451
+        // uncompress if necessary
452
+        if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
+            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
454
+            if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455
+                // if decoding works, use it. else assume data wasn't gzencoded
456
+                if (function_exists('gzuncompress')) {
457
+                    if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
458
+                        $data = $degzdata;
459
+                    } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
460
+                        $data = $degzdata;
461
+                    } else {
462
+                        $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
463
+                        return;
464
+                    }
465
+                } else {
466
+                    $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
467
+                    return;
468
+                }
469
+            }
470
+        }
471
+        $this->request .= "\r\n".$data;
472
+        $data = $this->parseRequest($this->headers, $data);
473
+        $this->requestSOAP = $data;
474
+        $this->debug('leaving parse_request');
475
+    }
476 476
 
477
-	/**
478
-	* invokes a PHP function for the requested SOAP method
479
-	*
480
-	* The following fields are set by this function (when successful)
481
-	*
482
-	* methodreturn
483
-	*
484
-	* Note that the PHP function that is called may also set the following
485
-	* fields to affect the response sent to the client
486
-	*
487
-	* responseHeaders
488
-	* outgoing_headers
489
-	*
490
-	* This sets the fault field on error
491
-	*
492
-	* @access   private
493
-	*/
494
-	function invoke_method() {
495
-		$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
477
+    /**
478
+     * invokes a PHP function for the requested SOAP method
479
+     *
480
+     * The following fields are set by this function (when successful)
481
+     *
482
+     * methodreturn
483
+     *
484
+     * Note that the PHP function that is called may also set the following
485
+     * fields to affect the response sent to the client
486
+     *
487
+     * responseHeaders
488
+     * outgoing_headers
489
+     *
490
+     * This sets the fault field on error
491
+     *
492
+     * @access   private
493
+     */
494
+    function invoke_method() {
495
+        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
496 496
 
497
-		//
498
-		// if you are debugging in this area of the code, your service uses a class to implement methods,
499
-		// you use SOAP RPC, and the client is .NET, please be aware of the following...
500
-		// when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
501
-		// method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
502
-		// the XML request and reading the XML response.  you need to add the RequestElementName and
503
-		// ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
504
-		// generates for the method.  these parameters are used to specify the correct XML element names
505
-		// for .NET to use, i.e. the names with the '.' in them.
506
-		//
507
-		$orig_methodname = $this->methodname;
508
-		if ($this->wsdl) {
509
-			if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
-				$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
512
-			} elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513
-				// Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
-				$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
516
-				$this->methodname = $this->opData['name'];
517
-			} else {
518
-				$this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
-				$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
520
-				return;
521
-			}
522
-		} else {
523
-			$this->debug('in invoke_method, no WSDL to validate method');
524
-		}
497
+        //
498
+        // if you are debugging in this area of the code, your service uses a class to implement methods,
499
+        // you use SOAP RPC, and the client is .NET, please be aware of the following...
500
+        // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
501
+        // method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
502
+        // the XML request and reading the XML response.  you need to add the RequestElementName and
503
+        // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
504
+        // generates for the method.  these parameters are used to specify the correct XML element names
505
+        // for .NET to use, i.e. the names with the '.' in them.
506
+        //
507
+        $orig_methodname = $this->methodname;
508
+        if ($this->wsdl) {
509
+            if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
+                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
512
+            } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513
+                // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
+                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
516
+                $this->methodname = $this->opData['name'];
517
+            } else {
518
+                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
+                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
520
+                return;
521
+            }
522
+        } else {
523
+            $this->debug('in invoke_method, no WSDL to validate method');
524
+        }
525 525
 
526
-		// if a . is present in $this->methodname, we see if there is a class in scope,
527
-		// which could be referred to. We will also distinguish between two deliminators,
528
-		// to allow methods to be called a the class or an instance
529
-		if (strpos($this->methodname, '..') > 0) {
530
-			$delim = '..';
531
-		} else if (strpos($this->methodname, '.') > 0) {
532
-			$delim = '.';
533
-		} else {
534
-			$delim = '';
535
-		}
536
-		$this->debug("in invoke_method, delim=$delim");
526
+        // if a . is present in $this->methodname, we see if there is a class in scope,
527
+        // which could be referred to. We will also distinguish between two deliminators,
528
+        // to allow methods to be called a the class or an instance
529
+        if (strpos($this->methodname, '..') > 0) {
530
+            $delim = '..';
531
+        } else if (strpos($this->methodname, '.') > 0) {
532
+            $delim = '.';
533
+        } else {
534
+            $delim = '';
535
+        }
536
+        $this->debug("in invoke_method, delim=$delim");
537 537
 
538
-		$class = '';
539
-		$method = '';
540
-		if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
541
-			$try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
542
-			if (class_exists($try_class)) {
543
-				// get the class and method name
544
-				$class = $try_class;
545
-				$method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
546
-				$this->debug("in invoke_method, class=$class method=$method delim=$delim");
547
-			} else {
548
-				$this->debug("in invoke_method, class=$try_class not found");
549
-			}
550
-		} else {
551
-			$try_class = '';
552
-			$this->debug("in invoke_method, no class to try");
553
-		}
538
+        $class = '';
539
+        $method = '';
540
+        if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
541
+            $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
542
+            if (class_exists($try_class)) {
543
+                // get the class and method name
544
+                $class = $try_class;
545
+                $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
546
+                $this->debug("in invoke_method, class=$class method=$method delim=$delim");
547
+            } else {
548
+                $this->debug("in invoke_method, class=$try_class not found");
549
+            }
550
+        } else {
551
+            $try_class = '';
552
+            $this->debug("in invoke_method, no class to try");
553
+        }
554 554
 
555
-		// does method exist?
556
-		if ($class == '') {
557
-			if (!function_exists($this->methodname)) {
558
-				$this->debug("in invoke_method, function '$this->methodname' not found!");
559
-				$this->result = 'fault: method not found';
560
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561
-				return;
562
-			}
563
-		} else {
564
-			$method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
565
-			if (!in_array($method_to_compare, get_class_methods($class))) {
566
-				$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567
-				$this->result = 'fault: method not found';
568
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569
-				return;
570
-			}
571
-		}
555
+        // does method exist?
556
+        if ($class == '') {
557
+            if (!function_exists($this->methodname)) {
558
+                $this->debug("in invoke_method, function '$this->methodname' not found!");
559
+                $this->result = 'fault: method not found';
560
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561
+                return;
562
+            }
563
+        } else {
564
+            $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
565
+            if (!in_array($method_to_compare, get_class_methods($class))) {
566
+                $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567
+                $this->result = 'fault: method not found';
568
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569
+                return;
570
+            }
571
+        }
572 572
 
573
-		// evaluate message, getting back parameters
574
-		// verify that request parameters match the method's signature
575
-		if(! $this->verify_method($this->methodname,$this->methodparams)){
576
-			// debug
577
-			$this->debug('ERROR: request not verified against method signature');
578
-			$this->result = 'fault: request failed validation against method signature';
579
-			// return fault
580
-			$this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
581
-			return;
582
-		}
573
+        // evaluate message, getting back parameters
574
+        // verify that request parameters match the method's signature
575
+        if(! $this->verify_method($this->methodname,$this->methodparams)){
576
+            // debug
577
+            $this->debug('ERROR: request not verified against method signature');
578
+            $this->result = 'fault: request failed validation against method signature';
579
+            // return fault
580
+            $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
581
+            return;
582
+        }
583 583
 
584
-		// if there are parameters to pass
585
-		$this->debug('in invoke_method, params:');
586
-		$this->appendDebug($this->varDump($this->methodparams));
587
-		$this->debug("in invoke_method, calling '$this->methodname'");
588
-		if (!function_exists('call_user_func_array')) {
589
-			if ($class == '') {
590
-				$this->debug('in invoke_method, calling function using eval()');
591
-				$funcCall = "\$this->methodreturn = $this->methodname(";
592
-			} else {
593
-				if ($delim == '..') {
594
-					$this->debug('in invoke_method, calling class method using eval()');
595
-					$funcCall = "\$this->methodreturn = ".$class."::".$method."(";
596
-				} else {
597
-					$this->debug('in invoke_method, calling instance method using eval()');
598
-					// generate unique instance name
599
-					$instname = "\$inst_".time();
600
-					$funcCall = $instname." = new ".$class."(); ";
601
-					$funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
602
-				}
603
-			}
604
-			if ($this->methodparams) {
605
-				foreach ($this->methodparams as $param) {
606
-					if (is_array($param) || is_object($param)) {
607
-						$this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
608
-						return;
609
-					}
610
-					$funcCall .= "\"$param\",";
611
-				}
612
-				$funcCall = substr($funcCall, 0, -1);
613
-			}
614
-			$funcCall .= ');';
615
-			$this->debug('in invoke_method, function call: '.$funcCall);
616
-			@eval($funcCall);
617
-		} else {
618
-			if ($class == '') {
619
-				$this->debug('in invoke_method, calling function using call_user_func_array()');
620
-				$call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
621
-			} elseif ($delim == '..') {
622
-				$this->debug('in invoke_method, calling class method using call_user_func_array()');
623
-				$call_arg = array ($class, $method);
624
-			} else {
625
-				$this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
-				$instance = new $class ();
627
-				$call_arg = array(&$instance, $method);
628
-			}
629
-			if (is_array($this->methodparams)) {
630
-				$this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
631
-			} else {
632
-				$this->methodreturn = call_user_func_array($call_arg, array());
633
-			}
634
-		}
584
+        // if there are parameters to pass
585
+        $this->debug('in invoke_method, params:');
586
+        $this->appendDebug($this->varDump($this->methodparams));
587
+        $this->debug("in invoke_method, calling '$this->methodname'");
588
+        if (!function_exists('call_user_func_array')) {
589
+            if ($class == '') {
590
+                $this->debug('in invoke_method, calling function using eval()');
591
+                $funcCall = "\$this->methodreturn = $this->methodname(";
592
+            } else {
593
+                if ($delim == '..') {
594
+                    $this->debug('in invoke_method, calling class method using eval()');
595
+                    $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
596
+                } else {
597
+                    $this->debug('in invoke_method, calling instance method using eval()');
598
+                    // generate unique instance name
599
+                    $instname = "\$inst_".time();
600
+                    $funcCall = $instname." = new ".$class."(); ";
601
+                    $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
602
+                }
603
+            }
604
+            if ($this->methodparams) {
605
+                foreach ($this->methodparams as $param) {
606
+                    if (is_array($param) || is_object($param)) {
607
+                        $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
608
+                        return;
609
+                    }
610
+                    $funcCall .= "\"$param\",";
611
+                }
612
+                $funcCall = substr($funcCall, 0, -1);
613
+            }
614
+            $funcCall .= ');';
615
+            $this->debug('in invoke_method, function call: '.$funcCall);
616
+            @eval($funcCall);
617
+        } else {
618
+            if ($class == '') {
619
+                $this->debug('in invoke_method, calling function using call_user_func_array()');
620
+                $call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
621
+            } elseif ($delim == '..') {
622
+                $this->debug('in invoke_method, calling class method using call_user_func_array()');
623
+                $call_arg = array ($class, $method);
624
+            } else {
625
+                $this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
+                $instance = new $class ();
627
+                $call_arg = array(&$instance, $method);
628
+            }
629
+            if (is_array($this->methodparams)) {
630
+                $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
631
+            } else {
632
+                $this->methodreturn = call_user_func_array($call_arg, array());
633
+            }
634
+        }
635 635
         $this->debug('in invoke_method, methodreturn:');
636 636
         $this->appendDebug($this->varDump($this->methodreturn));
637
-		$this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
638
-	}
637
+        $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
638
+    }
639 639
 
640
-	/**
641
-	* serializes the return value from a PHP function into a full SOAP Envelope
642
-	*
643
-	* The following fields are set by this function (when successful)
644
-	*
645
-	* responseSOAP
646
-	*
647
-	* This sets the fault field on error
648
-	*
649
-	* @access   private
650
-	*/
651
-	function serialize_return() {
652
-		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
653
-		// if fault
654
-		if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655
-			$this->debug('got a fault object from method');
656
-			$this->fault = $this->methodreturn;
657
-			return;
658
-		} elseif ($this->methodreturnisliteralxml) {
659
-			$return_val = $this->methodreturn;
660
-		// returned value(s)
661
-		} else {
662
-			$this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663
-			$this->debug('serializing return value');
664
-			if($this->wsdl){
665
-				$opParams = "";
666
-				if (sizeof($this->opData['output']['parts']) > 1) {
667
-					$this->debug('more than one output part, so use the method return unchanged');
668
-			    	$opParams = $this->methodreturn;
669
-			    } elseif (sizeof($this->opData['output']['parts']) == 1) {
670
-					$this->debug('exactly one output part, so wrap the method return in a simple array');
671
-					// TODO: verify that it is not already wrapped!
672
-			    	//foreach ($this->opData['output']['parts'] as $name => $type) {
673
-					//	$this->debug('wrap in element named ' . $name);
674
-			    	//}
675
-			    	$opParams = array($this->methodreturn);
676
-			    }
677
-			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
678
-			    $this->appendDebug($this->wsdl->getDebug());
679
-			    $this->wsdl->clearDebug();
680
-				if($errstr = $this->wsdl->getError()){
681
-					$this->debug('got wsdl error: '.$errstr);
682
-					$this->fault('SOAP-ENV:Server', 'unable to serialize result');
683
-					return;
684
-				}
685
-			} else {
686
-				if (isset($this->methodreturn)) {
687
-					$return_val = $this->serialize_val($this->methodreturn, 'return');
688
-				} else {
689
-					$return_val = '';
690
-					$this->debug('in absence of WSDL, assume void return for backward compatibility');
691
-				}
692
-			}
693
-		}
694
-		$this->debug('return value:');
695
-		$this->appendDebug($this->varDump($return_val));
640
+    /**
641
+     * serializes the return value from a PHP function into a full SOAP Envelope
642
+     *
643
+     * The following fields are set by this function (when successful)
644
+     *
645
+     * responseSOAP
646
+     *
647
+     * This sets the fault field on error
648
+     *
649
+     * @access   private
650
+     */
651
+    function serialize_return() {
652
+        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
653
+        // if fault
654
+        if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655
+            $this->debug('got a fault object from method');
656
+            $this->fault = $this->methodreturn;
657
+            return;
658
+        } elseif ($this->methodreturnisliteralxml) {
659
+            $return_val = $this->methodreturn;
660
+        // returned value(s)
661
+        } else {
662
+            $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663
+            $this->debug('serializing return value');
664
+            if($this->wsdl){
665
+                $opParams = "";
666
+                if (sizeof($this->opData['output']['parts']) > 1) {
667
+                    $this->debug('more than one output part, so use the method return unchanged');
668
+                    $opParams = $this->methodreturn;
669
+                } elseif (sizeof($this->opData['output']['parts']) == 1) {
670
+                    $this->debug('exactly one output part, so wrap the method return in a simple array');
671
+                    // TODO: verify that it is not already wrapped!
672
+                    //foreach ($this->opData['output']['parts'] as $name => $type) {
673
+                    //	$this->debug('wrap in element named ' . $name);
674
+                    //}
675
+                    $opParams = array($this->methodreturn);
676
+                }
677
+                $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
678
+                $this->appendDebug($this->wsdl->getDebug());
679
+                $this->wsdl->clearDebug();
680
+                if($errstr = $this->wsdl->getError()){
681
+                    $this->debug('got wsdl error: '.$errstr);
682
+                    $this->fault('SOAP-ENV:Server', 'unable to serialize result');
683
+                    return;
684
+                }
685
+            } else {
686
+                if (isset($this->methodreturn)) {
687
+                    $return_val = $this->serialize_val($this->methodreturn, 'return');
688
+                } else {
689
+                    $return_val = '';
690
+                    $this->debug('in absence of WSDL, assume void return for backward compatibility');
691
+                }
692
+            }
693
+        }
694
+        $this->debug('return value:');
695
+        $this->appendDebug($this->varDump($return_val));
696 696
 
697
-		$this->debug('serializing response');
698
-		if ($this->wsdl) {
699
-			$this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
700
-			if ($this->opData['style'] == 'rpc') {
701
-				$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
702
-				if ($this->opData['output']['use'] == 'literal') {
703
-					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704
-					if ($this->methodURI) {
705
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
706
-					} else {
707
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
708
-					}
709
-				} else {
710
-					if ($this->methodURI) {
711
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
712
-					} else {
713
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
714
-					}
715
-				}
716
-			} else {
717
-				$this->debug('style is not rpc for serialization: assume document');
718
-				$payload = $return_val;
719
-			}
720
-		} else {
721
-			$this->debug('do not have WSDL for serialization: assume rpc/encoded');
722
-			$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723
-		}
724
-		$this->result = 'successful';
725
-		if($this->wsdl){
726
-			//if($this->debug_flag){
727
-            	$this->appendDebug($this->wsdl->getDebug());
697
+        $this->debug('serializing response');
698
+        if ($this->wsdl) {
699
+            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
700
+            if ($this->opData['style'] == 'rpc') {
701
+                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
702
+                if ($this->opData['output']['use'] == 'literal') {
703
+                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704
+                    if ($this->methodURI) {
705
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
706
+                    } else {
707
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
708
+                    }
709
+                } else {
710
+                    if ($this->methodURI) {
711
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
712
+                    } else {
713
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
714
+                    }
715
+                }
716
+            } else {
717
+                $this->debug('style is not rpc for serialization: assume document');
718
+                $payload = $return_val;
719
+            }
720
+        } else {
721
+            $this->debug('do not have WSDL for serialization: assume rpc/encoded');
722
+            $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723
+        }
724
+        $this->result = 'successful';
725
+        if($this->wsdl){
726
+            //if($this->debug_flag){
727
+                $this->appendDebug($this->wsdl->getDebug());
728 728
             //	}
729
-			if (isset($this->opData['output']['encodingStyle'])) {
730
-				$encodingStyle = $this->opData['output']['encodingStyle'];
731
-			} else {
732
-				$encodingStyle = '';
733
-			}
734
-			// Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
736
-		} else {
737
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
738
-		}
739
-		$this->debug("Leaving serialize_return");
740
-	}
729
+            if (isset($this->opData['output']['encodingStyle'])) {
730
+                $encodingStyle = $this->opData['output']['encodingStyle'];
731
+            } else {
732
+                $encodingStyle = '';
733
+            }
734
+            // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
736
+        } else {
737
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
738
+        }
739
+        $this->debug("Leaving serialize_return");
740
+    }
741 741
 
742
-	/**
743
-	* sends an HTTP response
744
-	*
745
-	* The following fields are set by this function (when successful)
746
-	*
747
-	* outgoing_headers
748
-	* response
749
-	*
750
-	* @access   private
751
-	*/
752
-	function send_response() {
753
-		$this->debug('Enter send_response');
754
-		if ($this->fault) {
755
-			$payload = $this->fault->serialize();
756
-			$this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
757
-			$this->outgoing_headers[] = "Status: 500 Internal Server Error";
758
-		} else {
759
-			$payload = $this->responseSOAP;
760
-			// Some combinations of PHP+Web server allow the Status
761
-			// to come through as a header.  Since OK is the default
762
-			// just do nothing.
763
-			// $this->outgoing_headers[] = "HTTP/1.0 200 OK";
764
-			// $this->outgoing_headers[] = "Status: 200 OK";
765
-		}
742
+    /**
743
+     * sends an HTTP response
744
+     *
745
+     * The following fields are set by this function (when successful)
746
+     *
747
+     * outgoing_headers
748
+     * response
749
+     *
750
+     * @access   private
751
+     */
752
+    function send_response() {
753
+        $this->debug('Enter send_response');
754
+        if ($this->fault) {
755
+            $payload = $this->fault->serialize();
756
+            $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
757
+            $this->outgoing_headers[] = "Status: 500 Internal Server Error";
758
+        } else {
759
+            $payload = $this->responseSOAP;
760
+            // Some combinations of PHP+Web server allow the Status
761
+            // to come through as a header.  Since OK is the default
762
+            // just do nothing.
763
+            // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
764
+            // $this->outgoing_headers[] = "Status: 200 OK";
765
+        }
766 766
         // add debug data if in debug mode
767
-		if(isset($this->debug_flag) && $this->debug_flag){
768
-        	$payload .= $this->getDebugAsXMLComment();
767
+        if(isset($this->debug_flag) && $this->debug_flag){
768
+            $payload .= $this->getDebugAsXMLComment();
769
+        }
770
+        $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
+        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
772
+        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773
+        // Let the Web server decide about this
774
+        //$this->outgoing_headers[] = "Connection: Close\r\n";
775
+        $payload = $this->getHTTPBody($payload);
776
+        $type = $this->getHTTPContentType();
777
+        $charset = $this->getHTTPContentTypeCharset();
778
+        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
779
+        //begin code to compress payload - by John
780
+        // NOTE: there is no way to know whether the Web server will also compress
781
+        // this data.
782
+        if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
783
+            if (strstr($this->headers['accept-encoding'], 'gzip')) {
784
+                if (function_exists('gzencode')) {
785
+                    if (isset($this->debug_flag) && $this->debug_flag) {
786
+                        $payload .= "<!-- Content being gzipped -->";
787
+                    }
788
+                    $this->outgoing_headers[] = "Content-Encoding: gzip";
789
+                    $payload = gzencode($payload);
790
+                } else {
791
+                    if (isset($this->debug_flag) && $this->debug_flag) {
792
+                        $payload .= "<!-- Content will not be gzipped: no gzencode -->";
793
+                    }
794
+                }
795
+            } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
796
+                // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
797
+                // instead of gzcompress output,
798
+                // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
799
+                if (function_exists('gzdeflate')) {
800
+                    if (isset($this->debug_flag) && $this->debug_flag) {
801
+                        $payload .= "<!-- Content being deflated -->";
802
+                    }
803
+                    $this->outgoing_headers[] = "Content-Encoding: deflate";
804
+                    $payload = gzdeflate($payload);
805
+                } else {
806
+                    if (isset($this->debug_flag) && $this->debug_flag) {
807
+                        $payload .= "<!-- Content will not be deflated: no gzcompress -->";
808
+                    }
809
+                }
810
+            }
769 811
         }
770
-		$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
772
-		$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773
-		// Let the Web server decide about this
774
-		//$this->outgoing_headers[] = "Connection: Close\r\n";
775
-		$payload = $this->getHTTPBody($payload);
776
-		$type = $this->getHTTPContentType();
777
-		$charset = $this->getHTTPContentTypeCharset();
778
-		$this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
779
-		//begin code to compress payload - by John
780
-		// NOTE: there is no way to know whether the Web server will also compress
781
-		// this data.
782
-		if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
783
-			if (strstr($this->headers['accept-encoding'], 'gzip')) {
784
-				if (function_exists('gzencode')) {
785
-					if (isset($this->debug_flag) && $this->debug_flag) {
786
-						$payload .= "<!-- Content being gzipped -->";
787
-					}
788
-					$this->outgoing_headers[] = "Content-Encoding: gzip";
789
-					$payload = gzencode($payload);
790
-				} else {
791
-					if (isset($this->debug_flag) && $this->debug_flag) {
792
-						$payload .= "<!-- Content will not be gzipped: no gzencode -->";
793
-					}
794
-				}
795
-			} elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
796
-				// Note: MSIE requires gzdeflate output (no Zlib header and checksum),
797
-				// instead of gzcompress output,
798
-				// which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
799
-				if (function_exists('gzdeflate')) {
800
-					if (isset($this->debug_flag) && $this->debug_flag) {
801
-						$payload .= "<!-- Content being deflated -->";
802
-					}
803
-					$this->outgoing_headers[] = "Content-Encoding: deflate";
804
-					$payload = gzdeflate($payload);
805
-				} else {
806
-					if (isset($this->debug_flag) && $this->debug_flag) {
807
-						$payload .= "<!-- Content will not be deflated: no gzcompress -->";
808
-					}
809
-				}
810
-			}
811
-		}
812
-		//end code
813
-		$this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814
-		reset($this->outgoing_headers);
815
-		foreach($this->outgoing_headers as $hdr){
816
-			header($hdr, false);
817
-		}
818
-		print $payload;
819
-		$this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
820
-	}
812
+        //end code
813
+        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814
+        reset($this->outgoing_headers);
815
+        foreach($this->outgoing_headers as $hdr){
816
+            header($hdr, false);
817
+        }
818
+        print $payload;
819
+        $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
820
+    }
821 821
 
822
-	/**
823
-	* takes the value that was created by parsing the request
824
-	* and compares to the method's signature, if available.
825
-	*
826
-	* @param	string	$operation	The operation to be invoked
827
-	* @param	array	$request	The array of parameter values
828
-	* @return	boolean	Whether the operation was found
829
-	* @access   private
830
-	*/
831
-	function verify_method($operation,$request){
832
-		if(isset($this->wsdl) && is_object($this->wsdl)){
833
-			if($this->wsdl->getOperationData($operation)){
834
-				return true;
835
-			}
836
-	    } elseif(isset($this->operations[$operation])){
837
-			return true;
838
-		}
839
-		return false;
840
-	}
822
+    /**
823
+     * takes the value that was created by parsing the request
824
+     * and compares to the method's signature, if available.
825
+     *
826
+     * @param	string	$operation	The operation to be invoked
827
+     * @param	array	$request	The array of parameter values
828
+     * @return	boolean	Whether the operation was found
829
+     * @access   private
830
+     */
831
+    function verify_method($operation,$request){
832
+        if(isset($this->wsdl) && is_object($this->wsdl)){
833
+            if($this->wsdl->getOperationData($operation)){
834
+                return true;
835
+            }
836
+        } elseif(isset($this->operations[$operation])){
837
+            return true;
838
+        }
839
+        return false;
840
+    }
841 841
 
842
-	/**
843
-	* processes SOAP message received from client
844
-	*
845
-	* @param	array	$headers	The HTTP headers
846
-	* @param	string	$data		unprocessed request data from client
847
-	* @return	mixed	value of the message, decoded into a PHP type
848
-	* @access   private
849
-	*/
842
+    /**
843
+     * processes SOAP message received from client
844
+     *
845
+     * @param	array	$headers	The HTTP headers
846
+     * @param	string	$data		unprocessed request data from client
847
+     * @return	mixed	value of the message, decoded into a PHP type
848
+     * @access   private
849
+     */
850 850
     function parseRequest($headers, $data) {
851
-		$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
852
-		$this->appendDebug($this->varDump($headers));
853
-    	if (!isset($headers['content-type'])) {
854
-			$this->setError('Request not of type text/xml (no content-type header)');
855
-			return false;
856
-    	}
857
-		if (!strstr($headers['content-type'], 'text/xml')) {
858
-			$this->setError('Request not of type text/xml');
859
-			return false;
860
-		}
861
-		if (strpos($headers['content-type'], '=')) {
862
-			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
-			$this->debug('Got response encoding: ' . $enc);
864
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
865
-				$this->xml_encoding = strtoupper($enc);
866
-			} else {
867
-				$this->xml_encoding = 'US-ASCII';
868
-			}
869
-		} else {
870
-			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871
-			$this->xml_encoding = 'ISO-8859-1';
872
-		}
873
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
874
-		// parse response, get soap parser obj
875
-		$parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
851
+        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
852
+        $this->appendDebug($this->varDump($headers));
853
+        if (!isset($headers['content-type'])) {
854
+            $this->setError('Request not of type text/xml (no content-type header)');
855
+            return false;
856
+        }
857
+        if (!strstr($headers['content-type'], 'text/xml')) {
858
+            $this->setError('Request not of type text/xml');
859
+            return false;
860
+        }
861
+        if (strpos($headers['content-type'], '=')) {
862
+            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
+            $this->debug('Got response encoding: ' . $enc);
864
+            if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
865
+                $this->xml_encoding = strtoupper($enc);
866
+            } else {
867
+                $this->xml_encoding = 'US-ASCII';
868
+            }
869
+        } else {
870
+            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871
+            $this->xml_encoding = 'ISO-8859-1';
872
+        }
873
+        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
874
+        // parse response, get soap parser obj
875
+        $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
876 876
 
877
-		// parser debug
878
-		$this->debug("parser debug: \n".$parser->getDebug());
879
-		// if fault occurred during message parsing
880
-		if($err = $parser->getError()){
881
-			$this->result = 'fault: error in msg parsing: '.$err;
882
-			$this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
883
-		// else successfully parsed request into soapval object
884
-		} else {
885
-			// get/set methodname
886
-			$this->methodURI = $parser->root_struct_namespace;
887
-			$this->methodname = $parser->root_struct_name;
888
-			$this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
889
-			$this->debug('calling parser->get_soapbody()');
890
-			$this->methodparams = $parser->get_soapbody();
891
-			// get SOAP headers
892
-			$this->requestHeaders = $parser->getHeaders();
893
-			// get SOAP Header
894
-			$this->requestHeader = $parser->get_soapheader();
877
+        // parser debug
878
+        $this->debug("parser debug: \n".$parser->getDebug());
879
+        // if fault occurred during message parsing
880
+        if($err = $parser->getError()){
881
+            $this->result = 'fault: error in msg parsing: '.$err;
882
+            $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
883
+        // else successfully parsed request into soapval object
884
+        } else {
885
+            // get/set methodname
886
+            $this->methodURI = $parser->root_struct_namespace;
887
+            $this->methodname = $parser->root_struct_name;
888
+            $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
889
+            $this->debug('calling parser->get_soapbody()');
890
+            $this->methodparams = $parser->get_soapbody();
891
+            // get SOAP headers
892
+            $this->requestHeaders = $parser->getHeaders();
893
+            // get SOAP Header
894
+            $this->requestHeader = $parser->get_soapheader();
895 895
             // add document for doclit support
896 896
             $this->document = $parser->document;
897
-		}
898
-	 }
897
+        }
898
+        }
899 899
 
900
-	/**
901
-	* gets the HTTP body for the current response.
902
-	*
903
-	* @param string $soapmsg The SOAP payload
904
-	* @return string The HTTP body, which includes the SOAP payload
905
-	* @access private
906
-	*/
907
-	function getHTTPBody($soapmsg) {
908
-		return $soapmsg;
909
-	}
900
+    /**
901
+     * gets the HTTP body for the current response.
902
+     *
903
+     * @param string $soapmsg The SOAP payload
904
+     * @return string The HTTP body, which includes the SOAP payload
905
+     * @access private
906
+     */
907
+    function getHTTPBody($soapmsg) {
908
+        return $soapmsg;
909
+    }
910 910
 
911
-	/**
912
-	* gets the HTTP content type for the current response.
913
-	*
914
-	* Note: getHTTPBody must be called before this.
915
-	*
916
-	* @return string the HTTP content type for the current response.
917
-	* @access private
918
-	*/
919
-	function getHTTPContentType() {
920
-		return 'text/xml';
921
-	}
911
+    /**
912
+     * gets the HTTP content type for the current response.
913
+     *
914
+     * Note: getHTTPBody must be called before this.
915
+     *
916
+     * @return string the HTTP content type for the current response.
917
+     * @access private
918
+     */
919
+    function getHTTPContentType() {
920
+        return 'text/xml';
921
+    }
922 922
 
923
-	/**
924
-	* gets the HTTP content type charset for the current response.
925
-	* returns false for non-text content types.
926
-	*
927
-	* Note: getHTTPBody must be called before this.
928
-	*
929
-	* @return string the HTTP content type charset for the current response.
930
-	* @access private
931
-	*/
932
-	function getHTTPContentTypeCharset() {
933
-		return $this->soap_defencoding;
934
-	}
923
+    /**
924
+     * gets the HTTP content type charset for the current response.
925
+     * returns false for non-text content types.
926
+     *
927
+     * Note: getHTTPBody must be called before this.
928
+     *
929
+     * @return string the HTTP content type charset for the current response.
930
+     * @access private
931
+     */
932
+    function getHTTPContentTypeCharset() {
933
+        return $this->soap_defencoding;
934
+    }
935 935
 
936
-	/**
937
-	* add a method to the dispatch map (this has been replaced by the register method)
938
-	*
939
-	* @param    string $methodname
940
-	* @param    string $in array of input values
941
-	* @param    string $out array of output values
942
-	* @access   public
943
-	* @deprecated
944
-	*/
945
-	function add_to_map($methodname,$in,$out){
946
-			$this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
947
-	}
936
+    /**
937
+     * add a method to the dispatch map (this has been replaced by the register method)
938
+     *
939
+     * @param    string $methodname
940
+     * @param    string $in array of input values
941
+     * @param    string $out array of output values
942
+     * @access   public
943
+     * @deprecated
944
+     */
945
+    function add_to_map($methodname,$in,$out){
946
+            $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
947
+    }
948 948
 
949
-	/**
950
-	* register a service function with the server
951
-	*
952
-	* @param    string $name the name of the PHP function, class.method or class..method
953
-	* @param    array $in assoc array of input values: key = param name, value = param type
954
-	* @param    array $out assoc array of output values: key = param name, value = param type
955
-	* @param	mixed $namespace the element namespace for the method or false
956
-	* @param	mixed $soapaction the soapaction for the method or false
957
-	* @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
958
-	* @param	mixed $use optional (encoded|literal) or false
959
-	* @param	string $documentation optional Description to include in WSDL
960
-	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961
-	* @access   public
962
-	*/
963
-	function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
964
-		global $HTTP_SERVER_VARS;
949
+    /**
950
+     * register a service function with the server
951
+     *
952
+     * @param    string $name the name of the PHP function, class.method or class..method
953
+     * @param    array $in assoc array of input values: key = param name, value = param type
954
+     * @param    array $out assoc array of output values: key = param name, value = param type
955
+     * @param	mixed $namespace the element namespace for the method or false
956
+     * @param	mixed $soapaction the soapaction for the method or false
957
+     * @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
958
+     * @param	mixed $use optional (encoded|literal) or false
959
+     * @param	string $documentation optional Description to include in WSDL
960
+     * @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961
+     * @access   public
962
+     */
963
+    function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
964
+        global $HTTP_SERVER_VARS;
965 965
 
966
-		if($this->externalWSDLURL){
967
-			die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968
-		}
969
-		if (! $name) {
970
-			die('You must specify a name when you register an operation');
971
-		}
972
-		if (!is_array($in)) {
973
-			die('You must provide an array for operation inputs');
974
-		}
975
-		if (!is_array($out)) {
976
-			die('You must provide an array for operation outputs');
977
-		}
978
-		if(false == $namespace) {
979
-		}
980
-		if(false == $soapaction) {
981
-			if (isset($_SERVER)) {
982
-				$SERVER_NAME = $_SERVER['SERVER_NAME'];
983
-				$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
984
-				$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
985
-			} elseif (isset($HTTP_SERVER_VARS)) {
986
-				$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
987
-				$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
988
-				$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
989
-			} else {
990
-				$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
991
-			}
992
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
993
-        		$SCHEME = 'https';
994
-        	} else {
995
-        		$SCHEME = 'http';
996
-        	}
997
-			$soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998
-		}
999
-		if(false == $style) {
1000
-			$style = "rpc";
1001
-		}
1002
-		if(false == $use) {
1003
-			$use = "encoded";
1004
-		}
1005
-		if ($use == 'encoded' && $encodingStyle == '') {
1006
-			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1007
-		}
966
+        if($this->externalWSDLURL){
967
+            die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968
+        }
969
+        if (! $name) {
970
+            die('You must specify a name when you register an operation');
971
+        }
972
+        if (!is_array($in)) {
973
+            die('You must provide an array for operation inputs');
974
+        }
975
+        if (!is_array($out)) {
976
+            die('You must provide an array for operation outputs');
977
+        }
978
+        if(false == $namespace) {
979
+        }
980
+        if(false == $soapaction) {
981
+            if (isset($_SERVER)) {
982
+                $SERVER_NAME = $_SERVER['SERVER_NAME'];
983
+                $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
984
+                $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
985
+            } elseif (isset($HTTP_SERVER_VARS)) {
986
+                $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
987
+                $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
988
+                $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
989
+            } else {
990
+                $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
991
+            }
992
+            if ($HTTPS == '1' || $HTTPS == 'on') {
993
+                $SCHEME = 'https';
994
+            } else {
995
+                $SCHEME = 'http';
996
+            }
997
+            $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998
+        }
999
+        if(false == $style) {
1000
+            $style = "rpc";
1001
+        }
1002
+        if(false == $use) {
1003
+            $use = "encoded";
1004
+        }
1005
+        if ($use == 'encoded' && $encodingStyle == '') {
1006
+            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1007
+        }
1008 1008
 
1009
-		$this->operations[$name] = array(
1010
-	    'name' => $name,
1011
-	    'in' => $in,
1012
-	    'out' => $out,
1013
-	    'namespace' => $namespace,
1014
-	    'soapaction' => $soapaction,
1015
-	    'style' => $style);
1009
+        $this->operations[$name] = array(
1010
+        'name' => $name,
1011
+        'in' => $in,
1012
+        'out' => $out,
1013
+        'namespace' => $namespace,
1014
+        'soapaction' => $soapaction,
1015
+        'style' => $style);
1016 1016
         if($this->wsdl){
1017
-        	$this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1018
-	    }
1019
-		return true;
1020
-	}
1017
+            $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1018
+        }
1019
+        return true;
1020
+    }
1021 1021
 
1022
-	/**
1023
-	* Specify a fault to be returned to the client.
1024
-	* This also acts as a flag to the server that a fault has occured.
1025
-	*
1026
-	* @param	string $faultcode
1027
-	* @param	string $faultstring
1028
-	* @param	string $faultactor
1029
-	* @param	string $faultdetail
1030
-	* @access   public
1031
-	*/
1032
-	function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1033
-		if ($faultdetail == '' && $this->debug_flag) {
1034
-			$faultdetail = $this->getDebug();
1035
-		}
1036
-		$this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1037
-		$this->fault->soap_defencoding = $this->soap_defencoding;
1038
-	}
1022
+    /**
1023
+     * Specify a fault to be returned to the client.
1024
+     * This also acts as a flag to the server that a fault has occured.
1025
+     *
1026
+     * @param	string $faultcode
1027
+     * @param	string $faultstring
1028
+     * @param	string $faultactor
1029
+     * @param	string $faultdetail
1030
+     * @access   public
1031
+     */
1032
+    function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1033
+        if ($faultdetail == '' && $this->debug_flag) {
1034
+            $faultdetail = $this->getDebug();
1035
+        }
1036
+        $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1037
+        $this->fault->soap_defencoding = $this->soap_defencoding;
1038
+    }
1039 1039
 
1040 1040
     /**
1041
-    * Sets up wsdl object.
1042
-    * Acts as a flag to enable internal WSDL generation
1043
-    *
1044
-    * @param string $serviceName, name of the service
1045
-    * @param mixed $namespace optional 'tns' service namespace or false
1046
-    * @param mixed $endpoint optional URL of service endpoint or false
1047
-    * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1048
-    * @param string $transport optional SOAP transport
1049
-    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050
-    */
1041
+     * Sets up wsdl object.
1042
+     * Acts as a flag to enable internal WSDL generation
1043
+     *
1044
+     * @param string $serviceName, name of the service
1045
+     * @param mixed $namespace optional 'tns' service namespace or false
1046
+     * @param mixed $endpoint optional URL of service endpoint or false
1047
+     * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1048
+     * @param string $transport optional SOAP transport
1049
+     * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050
+     */
1051 1051
     function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1052 1052
     {
1053
-    	global $HTTP_SERVER_VARS;
1053
+        global $HTTP_SERVER_VARS;
1054 1054
 
1055
-		if (isset($_SERVER)) {
1056
-			$SERVER_NAME = $_SERVER['SERVER_NAME'];
1057
-			$SERVER_PORT = $_SERVER['SERVER_PORT'];
1058
-			$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1059
-			$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1060
-		} elseif (isset($HTTP_SERVER_VARS)) {
1061
-			$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1062
-			$SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1063
-			$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1064
-			$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1065
-		} else {
1066
-			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067
-		}
1068
-		// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
-		$colon = strpos($SERVER_NAME,":");
1070
-		if ($colon) {
1071
-		    $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072
-		}
1073
-		if ($SERVER_PORT == 80) {
1074
-			$SERVER_PORT = '';
1075
-		} else {
1076
-			$SERVER_PORT = ':' . $SERVER_PORT;
1077
-		}
1055
+        if (isset($_SERVER)) {
1056
+            $SERVER_NAME = $_SERVER['SERVER_NAME'];
1057
+            $SERVER_PORT = $_SERVER['SERVER_PORT'];
1058
+            $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1059
+            $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1060
+        } elseif (isset($HTTP_SERVER_VARS)) {
1061
+            $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1062
+            $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1063
+            $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1064
+            $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1065
+        } else {
1066
+            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067
+        }
1068
+        // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
+        $colon = strpos($SERVER_NAME,":");
1070
+        if ($colon) {
1071
+            $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072
+        }
1073
+        if ($SERVER_PORT == 80) {
1074
+            $SERVER_PORT = '';
1075
+        } else {
1076
+            $SERVER_PORT = ':' . $SERVER_PORT;
1077
+        }
1078 1078
         if(false == $namespace) {
1079 1079
             $namespace = "http://$SERVER_NAME/soap/$serviceName";
1080 1080
         }
1081 1081
 
1082 1082
         if(false == $endpoint) {
1083
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
1084
-        		$SCHEME = 'https';
1085
-        	} else {
1086
-        		$SCHEME = 'http';
1087
-        	}
1083
+            if ($HTTPS == '1' || $HTTPS == 'on') {
1084
+                $SCHEME = 'https';
1085
+            } else {
1086
+                $SCHEME = 'http';
1087
+            }
1088 1088
             $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
1089 1089
         }
1090 1090
 
@@ -1094,28 +1094,28 @@  discard block
 block discarded – undo
1094 1094
 
1095 1095
         $this->wsdl = new wsdl();
1096 1096
         $this->wsdl->soap_defencoding = $this->soap_defencoding;
1097
-		$this->wsdl->serviceName = $serviceName;
1097
+        $this->wsdl->serviceName = $serviceName;
1098 1098
         $this->wsdl->endpoint = $endpoint;
1099
-		$this->wsdl->namespaces['tns'] = $namespace;
1100
-		$this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1101
-		$this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1102
-		if ($schemaTargetNamespace != $namespace) {
1103
-			$this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1104
-		}
1099
+        $this->wsdl->namespaces['tns'] = $namespace;
1100
+        $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1101
+        $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1102
+        if ($schemaTargetNamespace != $namespace) {
1103
+            $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1104
+        }
1105 1105
         $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
1106 1106
         if ($style == 'document') {
1107
-	        $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1107
+            $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1108 1108
         }
1109 1109
         $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
1110 1110
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
1111 1111
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
1112 1112
         $this->wsdl->bindings[$serviceName.'Binding'] = array(
1113
-        	'name'=>$serviceName.'Binding',
1113
+            'name'=>$serviceName.'Binding',
1114 1114
             'style'=>$style,
1115 1115
             'transport'=>$transport,
1116 1116
             'portType'=>$serviceName.'PortType');
1117 1117
         $this->wsdl->ports[$serviceName.'Port'] = array(
1118
-        	'binding'=>$serviceName.'Binding',
1118
+            'binding'=>$serviceName.'Binding',
1119 1119
             'location'=>$endpoint,
1120 1120
             'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
1121 1121
     }
Please login to merge, or discard this patch.
main/webservices/webservice_session.php 1 patch
Indentation   +361 added lines, -361 removed lines patch added patch discarded remove patch
@@ -14,177 +14,177 @@  discard block
 block discarded – undo
14 14
 class WSSession extends WS
15 15
 {
16 16
 
17
-	/**
18
-	 * Creates a session (helper method)
19
-	 *
20
-	 * @param string Name of the session
21
-	 * @param string Start date, use the 'YYYY-MM-DD' format
22
-	 * @param string End date, use the 'YYYY-MM-DD' format
23
-	 * @param int Access delays of the coach (days before)
24
-	 * @param int Access delays of the coach (days after)
25
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
26
-	 * @param int Visibility
27
-	 * @param string User id field name for the coach
28
-	 * @param string User id value for the coach
29
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
30
-	 * @param string Original session id value
31
-	 * @param array Array of extra fields
32
-	 * @return mixed Generated id in case of success, WSError otherwise
33
-	 */
34
-	protected function createSessionHelper(
35
-		$name,
36
-		$start_date,
37
-		$end_date,
38
-		$nb_days_access_before,
39
-		$nb_days_access_after,
40
-		$nolimit,
41
-		$visibility,
42
-		$user_id_field_name,
43
-		$user_id_value,
44
-		$session_id_field_name,
45
-		$session_id_value,
46
-		$extras
47
-	) {
48
-		// Verify that coach exists and get its id
49
-		$user_id = $this->getUserId($user_id_field_name, $user_id_value);
50
-		if ($user_id instanceof WSError) {
51
-			return $user_id;
52
-		}
17
+    /**
18
+     * Creates a session (helper method)
19
+     *
20
+     * @param string Name of the session
21
+     * @param string Start date, use the 'YYYY-MM-DD' format
22
+     * @param string End date, use the 'YYYY-MM-DD' format
23
+     * @param int Access delays of the coach (days before)
24
+     * @param int Access delays of the coach (days after)
25
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
26
+     * @param int Visibility
27
+     * @param string User id field name for the coach
28
+     * @param string User id value for the coach
29
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
30
+     * @param string Original session id value
31
+     * @param array Array of extra fields
32
+     * @return mixed Generated id in case of success, WSError otherwise
33
+     */
34
+    protected function createSessionHelper(
35
+        $name,
36
+        $start_date,
37
+        $end_date,
38
+        $nb_days_access_before,
39
+        $nb_days_access_after,
40
+        $nolimit,
41
+        $visibility,
42
+        $user_id_field_name,
43
+        $user_id_value,
44
+        $session_id_field_name,
45
+        $session_id_value,
46
+        $extras
47
+    ) {
48
+        // Verify that coach exists and get its id
49
+        $user_id = $this->getUserId($user_id_field_name, $user_id_value);
50
+        if ($user_id instanceof WSError) {
51
+            return $user_id;
52
+        }
53 53
 
54
-		$coachStartDate = null;
55
-		if (!empty($nb_days_access_before)) {
56
-			$day = intval($nb_days_access_before);
57
-			$coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
58
-		}
54
+        $coachStartDate = null;
55
+        if (!empty($nb_days_access_before)) {
56
+            $day = intval($nb_days_access_before);
57
+            $coachStartDate = date('Y-m-d ', strtotime($start_date. ' + '.$day.' days'));
58
+        }
59 59
 
60
-		$coachEndDate = null;
61
-		if (!empty($nb_days_access_after)) {
62
-			$day = intval($nb_days_access_after);
63
-			$coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
64
-		}
60
+        $coachEndDate = null;
61
+        if (!empty($nb_days_access_after)) {
62
+            $day = intval($nb_days_access_after);
63
+            $coachEndDate = date('Y-m-d ', strtotime($end_date. ' + '.$day.' days'));
64
+        }
65 65
 
66
-		// Try to create the session
67
-		$session_id = SessionManager::create_session(
68
-			$name,
69
-			$start_date,
70
-			$end_date,
71
-			$start_date,
72
-			$end_date,
73
-			$coachStartDate,
74
-			$coachEndDate,
75
-			$user_id,
76
-			0,
77
-			$visibility
78
-		);
79
-		if(!is_int($session_id)) {
80
-			return new WSError(301, 'Could not create the session');
81
-		} else {
82
-			// Add the Original session id to the extra fields
83
-			$extras_associative = array();
84
-			if($session_id_field_name != "chamilo_session_id") {
85
-				$extras_associative[$session_id_field_name] = $session_id_value;
86
-			}
87
-			foreach($extras as $extra) {
88
-				$extras_associative[$extra['field_name']] = $extra['field_value'];
89
-			}
90
-			// Create the extra fields
91
-			foreach($extras_associative as $fname => $fvalue) {
92
-				SessionManager::create_session_extra_field($fname, 1, $fname);
93
-				SessionManager::update_session_extra_field_value(
94
-					$session_id,
95
-					$fname,
96
-					$fvalue
97
-				);
98
-			}
99
-			return $session_id;
100
-		}
101
-	}
66
+        // Try to create the session
67
+        $session_id = SessionManager::create_session(
68
+            $name,
69
+            $start_date,
70
+            $end_date,
71
+            $start_date,
72
+            $end_date,
73
+            $coachStartDate,
74
+            $coachEndDate,
75
+            $user_id,
76
+            0,
77
+            $visibility
78
+        );
79
+        if(!is_int($session_id)) {
80
+            return new WSError(301, 'Could not create the session');
81
+        } else {
82
+            // Add the Original session id to the extra fields
83
+            $extras_associative = array();
84
+            if($session_id_field_name != "chamilo_session_id") {
85
+                $extras_associative[$session_id_field_name] = $session_id_value;
86
+            }
87
+            foreach($extras as $extra) {
88
+                $extras_associative[$extra['field_name']] = $extra['field_value'];
89
+            }
90
+            // Create the extra fields
91
+            foreach($extras_associative as $fname => $fvalue) {
92
+                SessionManager::create_session_extra_field($fname, 1, $fname);
93
+                SessionManager::update_session_extra_field_value(
94
+                    $session_id,
95
+                    $fname,
96
+                    $fvalue
97
+                );
98
+            }
99
+            return $session_id;
100
+        }
101
+    }
102 102
 
103
-	/**
104
-	 * Creates a session
105
-	 *
106
-	 * @param string API secret key
107
-	 * @param string Name of the session
108
-	 * @param string Start date, use the 'YYYY-MM-DD' format
109
-	 * @param string End date, use the 'YYYY-MM-DD' format
110
-	 * @param int Access delays of the coach (days before)
111
-	 * @param int Access delays of the coach (days after)
112
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
113
-	 * @param int Visibility
114
-	 * @param string User id field name for the coach
115
-	 * @param string User id value for the coach
116
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
117
-	 * @param string Original session id value
118
-	 * @param array Array of extra fields
119
-	 * @return int Session id generated
120
-	 */
121
-	public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122
-		$verifKey = $this->verifyKey($secret_key);
123
-		if($verifKey instanceof WSError) {
124
-			$this->handleError($verifKey);
125
-		} else {
126
-			$session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
-			if($session_id instanceof WSError) {
128
-				$this->handleError($session_id);
129
-			} else {
130
-				return $session_id;
131
-			}
132
-		}
133
-	}
103
+    /**
104
+     * Creates a session
105
+     *
106
+     * @param string API secret key
107
+     * @param string Name of the session
108
+     * @param string Start date, use the 'YYYY-MM-DD' format
109
+     * @param string End date, use the 'YYYY-MM-DD' format
110
+     * @param int Access delays of the coach (days before)
111
+     * @param int Access delays of the coach (days after)
112
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
113
+     * @param int Visibility
114
+     * @param string User id field name for the coach
115
+     * @param string User id value for the coach
116
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
117
+     * @param string Original session id value
118
+     * @param array Array of extra fields
119
+     * @return int Session id generated
120
+     */
121
+    public function CreateSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
122
+        $verifKey = $this->verifyKey($secret_key);
123
+        if($verifKey instanceof WSError) {
124
+            $this->handleError($verifKey);
125
+        } else {
126
+            $session_id = $this->createSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
127
+            if($session_id instanceof WSError) {
128
+                $this->handleError($session_id);
129
+            } else {
130
+                return $session_id;
131
+            }
132
+        }
133
+    }
134 134
 
135
-	/**
136
-	 * Deletes a session (helper method)
137
-	 *
138
-	 * @param string Session id field name
139
-	 * @param string Session id value
140
-	 * @return mixed True in case of success, WSError otherwise
141
-	 */
142
-	protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
-		if($session_id instanceof WSError) {
145
-			return $session_id;
146
-		} else {
147
-			SessionManager::delete($session_id, true);
148
-			return true;
149
-		}
150
-	}
135
+    /**
136
+     * Deletes a session (helper method)
137
+     *
138
+     * @param string Session id field name
139
+     * @param string Session id value
140
+     * @return mixed True in case of success, WSError otherwise
141
+     */
142
+    protected function deleteSessionHelper($session_id_field_name, $session_id_value) {
143
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
144
+        if($session_id instanceof WSError) {
145
+            return $session_id;
146
+        } else {
147
+            SessionManager::delete($session_id, true);
148
+            return true;
149
+        }
150
+    }
151 151
 
152
-	/**
153
-	 * Deletes a session
154
-	 *
155
-	 * @param string API secret key
156
-	 * @param string Session id field name
157
-	 * @param string Session id value
158
-	 */
159
-	public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160
-		$verifKey = $this->verifyKey($secret_key);
161
-		if($verifKey instanceof WSError) {
162
-			$this->handleError($verifKey);
163
-		} else {
164
-			$result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
-			if($result instanceof WSError) {
166
-				$this->handleError($result);
167
-			}
168
-		}
169
-	}
152
+    /**
153
+     * Deletes a session
154
+     *
155
+     * @param string API secret key
156
+     * @param string Session id field name
157
+     * @param string Session id value
158
+     */
159
+    public function DeleteSession($secret_key, $session_id_field_name, $session_id_value) {
160
+        $verifKey = $this->verifyKey($secret_key);
161
+        if($verifKey instanceof WSError) {
162
+            $this->handleError($verifKey);
163
+        } else {
164
+            $result = $this->deleteSessionHelper($session_id_field_name, $session_id_value);
165
+            if($result instanceof WSError) {
166
+                $this->handleError($result);
167
+            }
168
+        }
169
+    }
170 170
 
171
-	/**
172
-	 * Edits a session (helper method)
173
-	 *
174
-	 * @param string Name of the session
175
-	 * @param string Start date, use the 'YYYY-MM-DD' format
176
-	 * @param string End date, use the 'YYYY-MM-DD' format
177
-	 * @param int Access delays of the coach (days before)
178
-	 * @param int Access delays of the coach (days after)
179
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
180
-	 * @param int Visibility
181
-	 * @param string User id field name for the coach
182
-	 * @param string User id value for the coach
183
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
184
-	 * @param string Original session id value
185
-	 * @param array Array of extra fields
186
-	 * @return mixed True on success, WSError otherwise
187
-	 */
171
+    /**
172
+     * Edits a session (helper method)
173
+     *
174
+     * @param string Name of the session
175
+     * @param string Start date, use the 'YYYY-MM-DD' format
176
+     * @param string End date, use the 'YYYY-MM-DD' format
177
+     * @param int Access delays of the coach (days before)
178
+     * @param int Access delays of the coach (days after)
179
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
180
+     * @param int Visibility
181
+     * @param string User id field name for the coach
182
+     * @param string User id value for the coach
183
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
184
+     * @param string Original session id value
185
+     * @param array Array of extra fields
186
+     * @return mixed True on success, WSError otherwise
187
+     */
188 188
     protected function editSessionHelper(
189 189
         $name,
190 190
         $start_date,
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
         $session_id_value,
200 200
         $extras
201 201
     ) {
202
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
-		if($session_id instanceof WSError) {
204
-			return $session_id;
205
-		} else {
206
-			// Verify that coach exists and get its id
207
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
208
-			if ($user_id instanceof WSError) {
209
-				return $user_id;
210
-			}
202
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
203
+        if($session_id instanceof WSError) {
204
+            return $session_id;
205
+        } else {
206
+            // Verify that coach exists and get its id
207
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
208
+            if ($user_id instanceof WSError) {
209
+                return $user_id;
210
+            }
211 211
 
212 212
             $coachStartDate = null;
213 213
             if (!empty($nb_days_access_before)) {
@@ -234,127 +234,127 @@  discard block
 block discarded – undo
234 234
                 0,
235 235
                 (int)$visibility
236 236
             );
237
-			if(!is_int($result_id)) {
238
-				return new WSError(302, 'Could not edit the session');
239
-			} else {
240
-				if(!empty($extras)) {
241
-					$extras_associative = array();
242
-					foreach($extras as $extra) {
243
-						$extras_associative[$extra['field_name']] = $extra['field_value'];
244
-					}
245
-					// Create the extra fields
246
-					foreach($extras_associative as $fname => $fvalue) {
247
-						SessionManager::create_session_extra_field($fname, 1, $fname);
248
-						SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249
-					}
250
-				}
251
-				return true;
252
-			}
253
-		}
254
-	}
237
+            if(!is_int($result_id)) {
238
+                return new WSError(302, 'Could not edit the session');
239
+            } else {
240
+                if(!empty($extras)) {
241
+                    $extras_associative = array();
242
+                    foreach($extras as $extra) {
243
+                        $extras_associative[$extra['field_name']] = $extra['field_value'];
244
+                    }
245
+                    // Create the extra fields
246
+                    foreach($extras_associative as $fname => $fvalue) {
247
+                        SessionManager::create_session_extra_field($fname, 1, $fname);
248
+                        SessionManager::update_session_extra_field_value($session_id, $fname, $fvalue);
249
+                    }
250
+                }
251
+                return true;
252
+            }
253
+        }
254
+    }
255 255
 
256
-	/**
257
-	 * Edits a session
258
-	 *
259
-	 * @param string API secret key
260
-	 * @param string Name of the session
261
-	 * @param string Start date, use the 'YYYY-MM-DD' format
262
-	 * @param string End date, use the 'YYYY-MM-DD' format
263
-	 * @param int Access delays of the coach (days before)
264
-	 * @param int Access delays of the coach (days after)
265
-	 * @param int Nolimit (0 = no limit of time, 1 = limit of time)
266
-	 * @param int Visibility
267
-	 * @param string User id field name for the coach
268
-	 * @param string User id value for the coach
269
-	 * @param string Original session id field name (use "chamilo_session_id" to use internal id)
270
-	 * @param string Original session id value
271
-	 * @param array Array of extra fields
272
-	 */
273
-	public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274
-		$verifKey = $this->verifyKey($secret_key);
275
-		if($verifKey instanceof WSError) {
276
-			$this->handleError($verifKey);
277
-		} else {
278
-			$result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
-			if($session_id_value instanceof WSError) {
280
-				$this->handleError($result);
281
-			}
282
-		}
283
-	}
256
+    /**
257
+     * Edits a session
258
+     *
259
+     * @param string API secret key
260
+     * @param string Name of the session
261
+     * @param string Start date, use the 'YYYY-MM-DD' format
262
+     * @param string End date, use the 'YYYY-MM-DD' format
263
+     * @param int Access delays of the coach (days before)
264
+     * @param int Access delays of the coach (days after)
265
+     * @param int Nolimit (0 = no limit of time, 1 = limit of time)
266
+     * @param int Visibility
267
+     * @param string User id field name for the coach
268
+     * @param string User id value for the coach
269
+     * @param string Original session id field name (use "chamilo_session_id" to use internal id)
270
+     * @param string Original session id value
271
+     * @param array Array of extra fields
272
+     */
273
+    public function EditSession($secret_key, $name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras) {
274
+        $verifKey = $this->verifyKey($secret_key);
275
+        if($verifKey instanceof WSError) {
276
+            $this->handleError($verifKey);
277
+        } else {
278
+            $result = $this->editSessionHelper($name, $start_date, $end_date, $nb_days_access_before, $nb_days_access_after, $nolimit, $visibility, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $extras);
279
+            if($session_id_value instanceof WSError) {
280
+                $this->handleError($result);
281
+            }
282
+        }
283
+    }
284 284
 
285
-	/**
286
-	 * Change user subscription (helper method)
287
-	 *
288
-	 * @param string User id field name
289
-	 * @param string User id value
290
-	 * @param string Session id field name
291
-	 * @param string Session id value
292
-	 * @param int State (1 to subscribe, 0 to unsubscribe)
293
-	 * @return mixed True on success, WSError otherwise
294
-	 */
295
-	protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
-		if($session_id instanceof WSError) {
298
-			return $session_id;
299
-		} else {
300
-			$user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
-			if($user_id instanceof WSError) {
302
-				return $user_id;
303
-			} else {
304
-				if($state  == 1) {
305
-					SessionManager::subscribe_users_to_session($session_id, array($user_id));
306
-				} else {
307
-					$result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
308
-					if (!$result) {
309
-						return new WSError(303, 'There was an error unsubscribing this user from the session');
310
-					}
311
-				}
312
-				return true;
313
-			}
314
-		}
315
-	}
285
+    /**
286
+     * Change user subscription (helper method)
287
+     *
288
+     * @param string User id field name
289
+     * @param string User id value
290
+     * @param string Session id field name
291
+     * @param string Session id value
292
+     * @param int State (1 to subscribe, 0 to unsubscribe)
293
+     * @return mixed True on success, WSError otherwise
294
+     */
295
+    protected function changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, $state) {
296
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
297
+        if($session_id instanceof WSError) {
298
+            return $session_id;
299
+        } else {
300
+            $user_id = $this->getUserId($user_id_field_name, $user_id_value);
301
+            if($user_id instanceof WSError) {
302
+                return $user_id;
303
+            } else {
304
+                if($state  == 1) {
305
+                    SessionManager::subscribe_users_to_session($session_id, array($user_id));
306
+                } else {
307
+                    $result = SessionManager::unsubscribe_user_from_session($session_id, $user_id);
308
+                    if (!$result) {
309
+                        return new WSError(303, 'There was an error unsubscribing this user from the session');
310
+                    }
311
+                }
312
+                return true;
313
+            }
314
+        }
315
+    }
316 316
 
317
-	/**
318
-	 * Subscribe user to a session
319
-	 *
320
-	 * @param string API secret key
321
-	 * @param string User id field name
322
-	 * @param string User id value
323
-	 * @param string Session id field name
324
-	 * @param string Session id value
325
-	 */
326
-	public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327
-		$verifKey = $this->verifyKey($secret_key);
328
-		if($verifKey instanceof WSError) {
329
-			$this->handleError($verifKey);
330
-		} else {
331
-			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
-			if($result instanceof WSError) {
333
-				$this->handleError($result);
334
-			}
335
-		}
336
-	}
317
+    /**
318
+     * Subscribe user to a session
319
+     *
320
+     * @param string API secret key
321
+     * @param string User id field name
322
+     * @param string User id value
323
+     * @param string Session id field name
324
+     * @param string Session id value
325
+     */
326
+    public function SubscribeUserToSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
327
+        $verifKey = $this->verifyKey($secret_key);
328
+        if($verifKey instanceof WSError) {
329
+            $this->handleError($verifKey);
330
+        } else {
331
+            $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 1);
332
+            if($result instanceof WSError) {
333
+                $this->handleError($result);
334
+            }
335
+        }
336
+    }
337 337
 
338
-	/**
339
-	 * Subscribe user to a session
340
-	 *
341
-	 * @param string API secret key
342
-	 * @param string User id field name
343
-	 * @param string User id value
344
-	 * @param string Session id field name
345
-	 * @param string Session id value
346
-	 */
347
-	public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348
-		$verifKey = $this->verifyKey($secret_key);
349
-		if($verifKey instanceof WSError) {
350
-			$this->handleError($verifKey);
351
-		} else {
352
-			$result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
-			if($result instanceof WSError) {
354
-				$this->handleError($result);
355
-			}
356
-		}
357
-	}
338
+    /**
339
+     * Subscribe user to a session
340
+     *
341
+     * @param string API secret key
342
+     * @param string User id field name
343
+     * @param string User id value
344
+     * @param string Session id field name
345
+     * @param string Session id value
346
+     */
347
+    public function UnsubscribeUserFromSession($secret_key, $user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value) {
348
+        $verifKey = $this->verifyKey($secret_key);
349
+        if($verifKey instanceof WSError) {
350
+            $this->handleError($verifKey);
351
+        } else {
352
+            $result = $this->changeUserSubscription($user_id_field_name, $user_id_value, $session_id_field_name, $session_id_value, 0);
353
+            if($result instanceof WSError) {
354
+                $this->handleError($result);
355
+            }
356
+        }
357
+    }
358 358
     
359 359
     /**
360 360
      * Change Teacher subscription (helper method)
@@ -446,79 +446,79 @@  discard block
 block discarded – undo
446 446
     }
447 447
 
448 448
     /**
449
-	 * Change course subscription
450
-	 *
451
-	 * @param string Course id field name
452
-	 * @param string Course id value
453
-	 * @param string Session id field name
454
-	 * @param string Session id value
455
-	 * @param int State (1 to subscribe, 0 to unsubscribe)
456
-	 * @return mixed True on success, WSError otherwise
457
-	 */
458
-	protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459
-		$session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
-		if($session_id instanceof WSError) {
461
-			return $session_id;
462
-		} else {
463
-			$course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
-			if($course_id instanceof WSError) {
465
-				return $course_id;
466
-			} else {
467
-				if($state  == 1) {
468
-					SessionManager::add_courses_to_session($session_id, array($course_id));
469
-					return true;
470
-				} else {
471
-					$result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
472
-					if ($result) {
473
-						return true;
474
-					} else {
475
-						return new WSError(304, 'Error unsubscribing course from session');
476
-					}
477
-				}
478
-			}
479
-		}
449
+     * Change course subscription
450
+     *
451
+     * @param string Course id field name
452
+     * @param string Course id value
453
+     * @param string Session id field name
454
+     * @param string Session id value
455
+     * @param int State (1 to subscribe, 0 to unsubscribe)
456
+     * @return mixed True on success, WSError otherwise
457
+     */
458
+    protected function changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, $state) {
459
+        $session_id = $this->getSessionId($session_id_field_name, $session_id_value);
460
+        if($session_id instanceof WSError) {
461
+            return $session_id;
462
+        } else {
463
+            $course_id = $this->getCourseId($course_id_field_name, $course_id_value);
464
+            if($course_id instanceof WSError) {
465
+                return $course_id;
466
+            } else {
467
+                if($state  == 1) {
468
+                    SessionManager::add_courses_to_session($session_id, array($course_id));
469
+                    return true;
470
+                } else {
471
+                    $result = SessionManager::unsubscribe_course_from_session($session_id, $course_id);
472
+                    if ($result) {
473
+                        return true;
474
+                    } else {
475
+                        return new WSError(304, 'Error unsubscribing course from session');
476
+                    }
477
+                }
478
+            }
479
+        }
480 480
     }
481 481
 
482
-	/**
483
-	 * Subscribe course to session
484
-	 *
485
-	 * @param string API secret key
486
-	 * @param string Course id field name
487
-	 * @param string Course id value
488
-	 * @param string Session id field name
489
-	 * @param string Session id value
490
-	 */
491
-	public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492
-		$verifKey = $this->verifyKey($secret_key);
493
-		if($verifKey instanceof WSError) {
494
-			$this->handleError($verifKey);
495
-		} else {
496
-			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
-			if($result instanceof WSError) {
498
-				$this->handleError($result);
499
-			}
500
-		}
501
-	}
482
+    /**
483
+     * Subscribe course to session
484
+     *
485
+     * @param string API secret key
486
+     * @param string Course id field name
487
+     * @param string Course id value
488
+     * @param string Session id field name
489
+     * @param string Session id value
490
+     */
491
+    public function SubscribeCourseToSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
492
+        $verifKey = $this->verifyKey($secret_key);
493
+        if($verifKey instanceof WSError) {
494
+            $this->handleError($verifKey);
495
+        } else {
496
+            $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 1);
497
+            if($result instanceof WSError) {
498
+                $this->handleError($result);
499
+            }
500
+        }
501
+    }
502 502
 
503
-	/**
504
-	 * Unsubscribe course from session
505
-	 *
506
-	 * @param string API secret key
507
-	 * @param string Course id field name
508
-	 * @param string Course id value
509
-	 * @param string Session id field name
510
-	 * @param string Session id value
511
-	 */
512
-	public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513
-		$verifKey = $this->verifyKey($secret_key);
514
-		if($verifKey instanceof WSError) {
515
-			$this->handleError($verifKey);
516
-		} else {
517
-			$result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
-			if($result instanceof WSError) {
519
-				$this->handleError($result);
520
-			}
521
-		}
522
-	}
503
+    /**
504
+     * Unsubscribe course from session
505
+     *
506
+     * @param string API secret key
507
+     * @param string Course id field name
508
+     * @param string Course id value
509
+     * @param string Session id field name
510
+     * @param string Session id value
511
+     */
512
+    public function UnsubscribeCourseFromSession($secret_key, $course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value) {
513
+        $verifKey = $this->verifyKey($secret_key);
514
+        if($verifKey instanceof WSError) {
515
+            $this->handleError($verifKey);
516
+        } else {
517
+            $result = $this->changeCourseSubscription($course_id_field_name, $course_id_value, $session_id_field_name, $session_id_value, 0);
518
+            if($result instanceof WSError) {
519
+                $this->handleError($result);
520
+            }
521
+        }
522
+    }
523 523
 
524 524
 }
Please login to merge, or discard this patch.
main/messages/download.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 $message_uid = '';
51 51
 $message_type = array('inbox','outbox');
52 52
 if (in_array($_GET['type'],$message_type)) {
53
-	if ($_GET['type'] == 'inbox') {
54
-		$message_uid = $row_users['user_receiver_id'];
55
-	} else {
56
-		$message_uid = $row_users['user_sender_id'];
57
-	}
53
+    if ($_GET['type'] == 'inbox') {
54
+        $message_uid = $row_users['user_receiver_id'];
55
+    } else {
56
+        $message_uid = $row_users['user_sender_id'];
57
+    }
58 58
 }
59 59
 
60 60
 // allow to the correct user for download this file
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 $userGroup = new UserGroup();
63 63
 
64 64
 if (!empty($row_users['group_id'])) {
65
-	$users_group = $userGroup->get_all_users_by_group($row_users['group_id']);
66
-	if (!in_array($current_uid,array_keys($users_group))) {
67
-		$not_allowed_to_edit = true;
68
-	}
65
+    $users_group = $userGroup->get_all_users_by_group($row_users['group_id']);
66
+    if (!in_array($current_uid,array_keys($users_group))) {
67
+        $not_allowed_to_edit = true;
68
+    }
69 69
 } else {
70
-	if ($current_uid != $message_uid) {
71
-		$not_allowed_to_edit = true;
72
-	}
70
+    if ($current_uid != $message_uid) {
71
+        $not_allowed_to_edit = true;
72
+    }
73 73
 }
74 74
 
75 75
 if ($not_allowed_to_edit) {
76
-	api_not_allowed(true);
77
-	exit;
76
+    api_not_allowed(true);
77
+    exit;
78 78
 }
79 79
 
80 80
 // set the path directory file
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
         true
86 86
     );
87 87
 } else {
88
-	$path_user_info['dir'] = UserManager::getUserPathById($message_uid, 'system');
88
+    $path_user_info['dir'] = UserManager::getUserPathById($message_uid, 'system');
89 89
 }
90 90
 
91 91
 $full_file_name = $path_user_info['dir'].'message_attachments/'.$file_url;
Please login to merge, or discard this patch.
main/inc/lib/online.inc.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
         }
300 300
     }
301 301
 
302
-	//This query will show all registered users. Only for dev purposes.
303
-	/*$query = "SELECT DISTINCT u.id as login_user_id, login_date
302
+    //This query will show all registered users. Only for dev purposes.
303
+    /*$query = "SELECT DISTINCT u.id as login_user_id, login_date
304 304
 	        FROM $track_online_table e, $table_user u
305 305
             GROUP by u.id
306 306
             ORDER BY $column $direction
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
     } else {
328 328
         $time_limit = intval($time_limit);
329 329
     }
330
-	$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
331
-	$friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
332
-	$table_user = Database::get_main_table(TABLE_MAIN_USER);
333
-	$online_time = time() - $time_limit * 60;
334
-	$current_date = api_get_utc_datetime($online_time);
335
-
336
-	if ($friends) {
337
-		// 	who friends from social network is online
338
-		$query = "SELECT DISTINCT count(login_user_id) as count
330
+    $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
331
+    $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
332
+    $table_user = Database::get_main_table(TABLE_MAIN_USER);
333
+    $online_time = time() - $time_limit * 60;
334
+    $current_date = api_get_utc_datetime($online_time);
335
+
336
+    if ($friends) {
337
+        // 	who friends from social network is online
338
+        $query = "SELECT DISTINCT count(login_user_id) as count
339 339
 				  FROM $track_online_table INNER JOIN $friend_user_table
340 340
                   ON (friend_user_id = login_user_id)
341 341
 				  WHERE
@@ -343,20 +343,20 @@  discard block
 block discarded – undo
343 343
 				        friend_user_id <> '".api_get_user_id()."' AND
344 344
 				        relation_type='".USER_RELATION_TYPE_FRIEND."' AND
345 345
 				        user_id = '".api_get_user_id()."' ";
346
-	} else {
347
-		// All users online
348
-		$query = "SELECT count(login_id) as count
346
+    } else {
347
+        // All users online
348
+        $query = "SELECT count(login_id) as count
349 349
                   FROM $track_online_table track INNER JOIN $table_user u
350 350
                   ON (u.id=track.login_user_id)
351 351
                   WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date'  ";
352
-	}
353
-
354
-	if (api_get_multiple_access_url()) {
355
-		$access_url_id = api_get_current_access_url_id();
356
-		if ($access_url_id != -1) {
357
-			if ($friends) {
358
-				// 	friends from social network is online
359
-				$query = "SELECT DISTINCT count(login_user_id) as count
352
+    }
353
+
354
+    if (api_get_multiple_access_url()) {
355
+        $access_url_id = api_get_current_access_url_id();
356
+        if ($access_url_id != -1) {
357
+            if ($friends) {
358
+                // 	friends from social network is online
359
+                $query = "SELECT DISTINCT count(login_user_id) as count
360 360
 							FROM $track_online_table track
361 361
 							INNER JOIN $friend_user_table ON (friend_user_id = login_user_id)
362 362
 							WHERE
@@ -364,29 +364,29 @@  discard block
 block discarded – undo
364 364
 							    login_date >= '".$current_date."' AND
365 365
 							    friend_user_id <> '".api_get_user_id()."' AND
366 366
 							    relation_type='".USER_RELATION_TYPE_FRIEND."'  ";
367
-			} else {
368
-				// all users online
369
-				$query = "SELECT count(login_id) as count FROM $track_online_table  track
367
+            } else {
368
+                // all users online
369
+                $query = "SELECT count(login_id) as count FROM $track_online_table  track
370 370
                           INNER JOIN $table_user u ON (u.id=track.login_user_id)
371 371
 						  WHERE
372 372
 						    u.status != ".ANONYMOUS." AND
373 373
 						    track.access_url_id =  $access_url_id AND
374 374
 						    login_date >= '$current_date' ";
375
-			}
376
-		}
377
-	}
375
+            }
376
+        }
377
+    }
378 378
 
379 379
     // Dev purposes show all users online
380 380
     /*$table_user = Database::get_main_table(TABLE_MAIN_USER);
381 381
     $query = "SELECT count(*)  as count FROM ".$table_user;*/
382 382
 
383
-	$result = Database::query($query);
384
-	if (Database::num_rows($result) > 0) {
385
-		$row = Database::fetch_array($result);
386
-		return $row['count'];
387
-	} else {
388
-		return false;
389
-	}
383
+    $result = Database::query($query);
384
+    if (Database::num_rows($result) > 0) {
385
+        $row = Database::fetch_array($result);
386
+        return $row['count'];
387
+    } else {
388
+        return false;
389
+    }
390 390
 }
391 391
 
392 392
 
@@ -414,52 +414,52 @@  discard block
 block discarded – undo
414 414
     $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
415 415
     $course_code = Database::escape_string($course_code);
416 416
     $courseInfo = api_get_course_info($course_code);
417
-	$courseId = $courseInfo['real_id'];
417
+    $courseId = $courseInfo['real_id'];
418 418
 
419 419
     $from = intval($from);
420 420
     $number_of_items = intval($number_of_items);
421 421
 
422
-	$query = "SELECT login_user_id, login_date FROM $track_online_table
422
+    $query = "SELECT login_user_id, login_date FROM $track_online_table
423 423
               WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date'
424 424
               LIMIT $from, $number_of_items ";
425 425
 
426
-	$result = Database::query($query);
427
-	if ($result) {
428
-		$users_online = array();
426
+    $result = Database::query($query);
427
+    if ($result) {
428
+        $users_online = array();
429 429
 
430
-		while(list($login_user_id, $login_date) = Database::fetch_row($result)) {
430
+        while(list($login_user_id, $login_date) = Database::fetch_row($result)) {
431 431
             $users_online[] = $login_user_id;
432
-		}
433
-		return $users_online;
434
-	} else {
435
-		return false;
436
-	}
432
+        }
433
+        return $users_online;
434
+    } else {
435
+        return false;
436
+    }
437 437
 }
438 438
 
439 439
 function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null)
440 440
 {
441
-	if (empty($coursecode)) {
442
-		return false;
443
-	}
444
-	$track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
445
-	$time_limit = Database::escape_string($time_limit);
441
+    if (empty($coursecode)) {
442
+        return false;
443
+    }
444
+    $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
445
+    $time_limit = Database::escape_string($time_limit);
446 446
 
447 447
     $online_time = time() - $time_limit * 60;
448 448
     $current_date = api_get_utc_datetime($online_time);
449
-	$courseId = api_get_course_int_id($coursecode);
449
+    $courseId = api_get_course_int_id($coursecode);
450 450
 
451
-	if (empty($courseId)) {
452
-		return false;
453
-	}
451
+    if (empty($courseId)) {
452
+        return false;
453
+    }
454 454
 
455
-	$query = "SELECT count(login_user_id) as count
455
+    $query = "SELECT count(login_user_id) as count
456 456
               FROM $track_online_table
457 457
               WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' ";
458
-	$result = Database::query($query);
459
-	if (Database::num_rows($result) > 0) {
460
-		$row = Database::fetch_array($result);
461
-		return $row['count'];
462
-	} else {
463
-		return false;
464
-	}
458
+    $result = Database::query($query);
459
+    if (Database::num_rows($result) > 0) {
460
+        $row = Database::fetch_array($result);
461
+        return $row['count'];
462
+    } else {
463
+        return false;
464
+    }
465 465
 }
Please login to merge, or discard this patch.
main/admin/grade_models.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -110,8 +110,8 @@
 block discarded – undo
110 110
 //With this function we can add actions to the jgrid (edit, delete, etc)
111 111
 $action_links = 'function action_formatter(cellvalue, options, rowObject) {
112 112
      return \'<a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>'.
113
-     '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
114
-     '\';
113
+        '&nbsp;<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;"  href="?sec_token='.$token.'&action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>'.
114
+        '\';
115 115
 }';
116 116
 ?>
117 117
 <script>
Please login to merge, or discard this patch.
main/inc/lib/api.lib.php 1 patch
Indentation   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -626,7 +626,6 @@  discard block
 block discarded – undo
626 626
  * Also, this function provides conversion between path types, in this case the input path points inside the Chamilo area too.
627 627
  *
628 628
  * See $_configuration['course_folder'] in the configuration.php to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters.
629
-
630 629
  * @param string $path (optional)   A path which type is to be converted. Also, it may be a defined constant for a path.
631 630
  * This parameter has meaning when $type parameter has one of the following values: TO_WEB, TO_SYS, TO_REL. Otherwise it is ignored.
632 631
  * @return string                   The requested path or the converted path.
@@ -1733,7 +1732,6 @@  discard block
 block discarded – undo
1733 1732
 
1734 1733
 /**
1735 1734
  * Returns the current course info array.
1736
-
1737 1735
  * Now if the course_code is given, the returned array gives info about that
1738 1736
  * particular course, not specially the current one.
1739 1737
  * @param int $id Numeric ID of the course
@@ -6210,7 +6208,7 @@  discard block
 block discarded – undo
6210 6208
 function api_get_jquery_ui_js($include_jqgrid = false) {
6211 6209
     $libraries = array();
6212 6210
     if ($include_jqgrid) {
6213
-       $libraries[]='jqgrid';
6211
+        $libraries[]='jqgrid';
6214 6212
     }
6215 6213
     return api_get_jquery_libraries_js($libraries);
6216 6214
 }
Please login to merge, or discard this patch.
main/inc/lib/TicketManager.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
         ];
1465 1465
         Database::update($table, $newParams, ['id = ? ' => $ticketId]);
1466 1466
 
1467
-         self::sendNotification(
1467
+            self::sendNotification(
1468 1468
             $ticketId,
1469 1469
             $userId,
1470 1470
             get_lang('TicketUpdated'),
@@ -1926,9 +1926,9 @@  discard block
 block discarded – undo
1926 1926
         return 0;
1927 1927
     }
1928 1928
 
1929
-     /**
1930
-     * @return array
1931
-     */
1929
+        /**
1930
+         * @return array
1931
+         */
1932 1932
     public static function getPriorityList()
1933 1933
     {
1934 1934
         $projects = Database::getManager()->getRepository('ChamiloTicketBundle:Priority')->findAll();
@@ -2343,8 +2343,8 @@  discard block
 block discarded – undo
2343 2343
     }
2344 2344
 
2345 2345
         /**
2346
-     * @return array
2347
-     */
2346
+         * @return array
2347
+         */
2348 2348
     public static function getDefaultPriorityList() {
2349 2349
         return [
2350 2350
             self::PRIORITY_NORMAL,
Please login to merge, or discard this patch.
main/notebook/index.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 
39 39
 // Tool name
40 40
 if ($action === 'addnote') {
41
-	$tool = 'NoteAddNew';
42
-	$interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolNotebook'));
41
+    $tool = 'NoteAddNew';
42
+    $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolNotebook'));
43 43
 }
44 44
 if ($action === 'editnote') {
45
-	$tool = 'ModifyNote';
46
-	$interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolNotebook'));
45
+    $tool = 'ModifyNote';
46
+    $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => get_lang('ToolNotebook'));
47 47
 }
48 48
 
49 49
 // Displaying the header
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         exit;
64 64
     }
65 65
 
66
-	$_SESSION['notebook_view'] = 'creation_date';
66
+    $_SESSION['notebook_view'] = 'creation_date';
67 67
 
68 68
     $form = new FormValidator(
69 69
         'note',
Please login to merge, or discard this patch.
main/inc/lib/extra_field.lib.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
         'changeable',
21 21
         'filter',
22 22
         'extra_field_type',
23
-         /* Enable this when field_loggeable is introduced as a table field (2.0)
23
+            /* Enable this when field_loggeable is introduced as a table field (2.0)
24 24
         'field_loggeable',
25 25
          */
26 26
         'created_at'
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
                 'align' => 'left',
2042 2042
                 'sortable' => 'true',
2043 2043
             ),
2044
-             array(
2044
+                array(
2045 2045
                 'name' => 'visible_to_others',
2046 2046
                 'index' => 'visible_to_others',
2047 2047
                 'width' => '40',
Please login to merge, or discard this patch.