Completed
Push — 1.11.x ( 60645e...aacf46 )
by José
76:05 queued 37:57
created
main/inc/lib/nusoap/class.soap_fault.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -12,72 +12,72 @@
 block discarded – undo
12 12
 * @access public
13 13
 */
14 14
 class nusoap_fault extends nusoap_base {
15
-	/**
16
-	 * The fault code (client|server)
17
-	 * @var string
18
-	 * @access private
19
-	 */
20
-	var $faultcode;
21
-	/**
22
-	 * The fault actor
23
-	 * @var string
24
-	 * @access private
25
-	 */
26
-	var $faultactor;
27
-	/**
28
-	 * The fault string, a description of the fault
29
-	 * @var string
30
-	 * @access private
31
-	 */
32
-	var $faultstring;
33
-	/**
34
-	 * The fault detail, typically a string or array of string
35
-	 * @var mixed
36
-	 * @access private
37
-	 */
38
-	var $faultdetail;
15
+    /**
16
+     * The fault code (client|server)
17
+     * @var string
18
+     * @access private
19
+     */
20
+    var $faultcode;
21
+    /**
22
+     * The fault actor
23
+     * @var string
24
+     * @access private
25
+     */
26
+    var $faultactor;
27
+    /**
28
+     * The fault string, a description of the fault
29
+     * @var string
30
+     * @access private
31
+     */
32
+    var $faultstring;
33
+    /**
34
+     * The fault detail, typically a string or array of string
35
+     * @var mixed
36
+     * @access private
37
+     */
38
+    var $faultdetail;
39 39
 
40
-	/**
41
-	* constructor
42
-    *
43
-    * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server)
44
-    * @param string $faultactor only used when msg routed between multiple actors
45
-    * @param string $faultstring human readable error message
46
-    * @param mixed $faultdetail detail, typically a string or array of string
47
-	*/
48
-	function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
49
-		parent::nusoap_base();
50
-		$this->faultcode = $faultcode;
51
-		$this->faultactor = $faultactor;
52
-		$this->faultstring = $faultstring;
53
-		$this->faultdetail = $faultdetail;
54
-	}
40
+    /**
41
+     * constructor
42
+     *
43
+     * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server)
44
+     * @param string $faultactor only used when msg routed between multiple actors
45
+     * @param string $faultstring human readable error message
46
+     * @param mixed $faultdetail detail, typically a string or array of string
47
+     */
48
+    function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
49
+        parent::nusoap_base();
50
+        $this->faultcode = $faultcode;
51
+        $this->faultactor = $faultactor;
52
+        $this->faultstring = $faultstring;
53
+        $this->faultdetail = $faultdetail;
54
+    }
55 55
 
56
-	/**
57
-	* serialize a fault
58
-	*
59
-	* @return	string	The serialization of the fault instance.
60
-	* @access   public
61
-	*/
62
-	function serialize(){
63
-		$ns_string = '';
64
-		foreach($this->namespaces as $k => $v){
65
-			$ns_string .= "\n  xmlns:$k=\"$v\"";
66
-		}
67
-		$return_msg =
68
-			'<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
69
-			'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
70
-				'<SOAP-ENV:Body>'.
71
-				'<SOAP-ENV:Fault>'.
72
-					$this->serialize_val($this->faultcode, 'faultcode').
73
-					$this->serialize_val($this->faultactor, 'faultactor').
74
-					$this->serialize_val($this->faultstring, 'faultstring').
75
-					$this->serialize_val($this->faultdetail, 'detail').
76
-				'</SOAP-ENV:Fault>'.
77
-				'</SOAP-ENV:Body>'.
78
-			'</SOAP-ENV:Envelope>';
79
-		return $return_msg;
80
-	}
56
+    /**
57
+     * serialize a fault
58
+     *
59
+     * @return	string	The serialization of the fault instance.
60
+     * @access   public
61
+     */
62
+    function serialize(){
63
+        $ns_string = '';
64
+        foreach($this->namespaces as $k => $v){
65
+            $ns_string .= "\n  xmlns:$k=\"$v\"";
66
+        }
67
+        $return_msg =
68
+            '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
69
+            '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
70
+                '<SOAP-ENV:Body>'.
71
+                '<SOAP-ENV:Fault>'.
72
+                    $this->serialize_val($this->faultcode, 'faultcode').
73
+                    $this->serialize_val($this->faultactor, 'faultactor').
74
+                    $this->serialize_val($this->faultstring, 'faultstring').
75
+                    $this->serialize_val($this->faultdetail, 'detail').
76
+                '</SOAP-ENV:Fault>'.
77
+                '</SOAP-ENV:Body>'.
78
+            '</SOAP-ENV:Envelope>';
79
+        return $return_msg;
80
+    }
81 81
 }
82 82
 
83 83
 /**
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     * @param string $faultstring human readable error message
46 46
     * @param mixed $faultdetail detail, typically a string or array of string
47 47
 	*/
48
-	function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
48
+	function nusoap_fault($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '') {
49 49
 		parent::nusoap_base();
50 50
 		$this->faultcode = $faultcode;
51 51
 		$this->faultactor = $faultactor;
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 	* @return	string	The serialization of the fault instance.
60 60
 	* @access   public
61 61
 	*/
62
-	function serialize(){
62
+	function serialize() {
63 63
 		$ns_string = '';
64
-		foreach($this->namespaces as $k => $v){
64
+		foreach ($this->namespaces as $k => $v) {
65 65
 			$ns_string .= "\n  xmlns:$k=\"$v\"";
66 66
 		}
67 67
 		$return_msg =
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_parser.php 3 patches
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	var $root_struct_name = '';
19 19
 	var $root_struct_namespace = '';
20 20
 	var $root_header = '';
21
-    var $document = '';			// incoming SOAP body (text)
21
+    var $document = ''; // incoming SOAP body (text)
22 22
 	// determines where in the message we are (envelope,header,body,method)
23 23
 	var $status = '';
24 24
 	var $position = 0;
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	var $fault_detail = '';
34 34
 	var $depth_array = array();
35 35
 	var $debug_flag = true;
36
-	var $soapresponse = NULL;	// parsed SOAP Body
37
-	var $soapheader = NULL;		// parsed SOAP Header
38
-	var $responseHeaders = '';	// incoming SOAP headers (text)
36
+	var $soapresponse = NULL; // parsed SOAP Body
37
+	var $soapheader = NULL; // parsed SOAP Header
38
+	var $responseHeaders = ''; // incoming SOAP headers (text)
39 39
 	var $body_position = 0;
40 40
 	// for multiref parsing:
41 41
 	// array of id => pos
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	* @param    string $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55 55
 	* @access   public
56 56
 	*/
57
-	function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
57
+	function nusoap_parser($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) {
58 58
 		parent::nusoap_base();
59 59
 		$this->xml = $xml;
60 60
 		$this->xml_encoding = $encoding;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$this->decode_utf8 = $decode_utf8;
63 63
 
64 64
 		// Check whether content has been read.
65
-		if(!empty($this->xml)){
65
+		if (!empty($this->xml)) {
66 66
 			// Check XML encoding
67 67
 			$pos_xml = strpos($xml, '<?xml');
68 68
 			if ($pos_xml !== FALSE) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 				if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
71 71
 					$xml_encoding = $res[1];
72 72
 					if (strtoupper($xml_encoding) != $encoding) {
73
-						$err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
73
+						$err = "Charset from HTTP Content-Type '".$encoding."' does not match encoding from XML declaration '".$xml_encoding."'";
74 74
 						$this->debug($err);
75 75
 						if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
76 76
 							$this->setError($err);
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 			// Set the object for the parser.
97 97
 			xml_set_object($this->parser, $this);
98 98
 			// Set the element handlers for the parser.
99
-			xml_set_element_handler($this->parser, 'start_element','end_element');
100
-			xml_set_character_data_handler($this->parser,'character_data');
99
+			xml_set_element_handler($this->parser, 'start_element', 'end_element');
100
+			xml_set_character_data_handler($this->parser, 'character_data');
101 101
 
102 102
 			xml_parse($this->parser, $this->xml);
103 103
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 			    xml_get_current_line_number($this->parser),
110 110
 			    xml_error_string(xml_get_error_code($this->parser)));
111 111
 				$this->debug($err);
112
-				$this->debug("XML payload:\n" . $xml);
112
+				$this->debug("XML payload:\n".$xml);
113 113
 				$this->setError($err);
114 114
 			} else {
115 115
 				$this->debug('in nusoap_parser ctor, message:');
@@ -118,18 +118,18 @@  discard block
 block discarded – undo
118 118
 				// get final value
119 119
 				$this->soapresponse = $this->message[$this->root_struct]['result'];
120 120
 				// get header value
121
-				if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
121
+				if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) {
122 122
 					$this->soapheader = $this->message[$this->root_header]['result'];
123 123
 				}
124 124
 				// resolve hrefs/ids
125
-				if(sizeof($this->multirefs) > 0){
126
-					foreach($this->multirefs as $id => $hrefs){
125
+				if (sizeof($this->multirefs) > 0) {
126
+					foreach ($this->multirefs as $id => $hrefs) {
127 127
 						$this->debug('resolving multirefs for id: '.$id);
128 128
 						$idVal = $this->buildVal($this->ids[$id]);
129 129
 						if (is_array($idVal) && isset($idVal['!id'])) {
130 130
 							unset($idVal['!id']);
131 131
 						}
132
-						foreach($hrefs as $refPos => $ref){
132
+						foreach ($hrefs as $refPos => $ref) {
133 133
 							$this->debug('resolving href at pos '.$refPos);
134 134
 							$this->multirefs[$id][$refPos] = $idVal;
135 135
 						}
@@ -157,13 +157,13 @@  discard block
 block discarded – undo
157 157
 		// update class level pos
158 158
 		$pos = $this->position++;
159 159
 		// and set mine
160
-		$this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
160
+		$this->message[$pos] = array('pos' => $pos, 'children'=>'', 'cdata'=>'');
161 161
 		// depth = how many levels removed from root?
162 162
 		// set mine as current global depth and increment global depth value
163 163
 		$this->message[$pos]['depth'] = $this->depth++;
164 164
 
165 165
 		// else add self as child to whoever the current parent is
166
-		if($pos != 0){
166
+		if ($pos != 0) {
167 167
 			$this->message[$this->parent]['children'] .= '|'.$pos;
168 168
 		}
169 169
 		// set my parent
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 		// set self as current value for this depth
174 174
 		$this->depth_array[$this->depth] = $pos;
175 175
 		// get element prefix
176
-		if(strpos($name,':')){
176
+		if (strpos($name, ':')) {
177 177
 			// get ns prefix
178
-			$prefix = substr($name,0,strpos($name,':'));
178
+			$prefix = substr($name, 0, strpos($name, ':'));
179 179
 			// get unqualified name
180
-			$name = substr(strstr($name,':'),1);
180
+			$name = substr(strstr($name, ':'), 1);
181 181
 		}
182 182
 		// set status
183 183
 		if ($name == 'Envelope' && $this->status == '') {
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 		} elseif ($name == 'Header' && $this->status == 'envelope') {
186 186
 			$this->root_header = $pos;
187 187
 			$this->status = 'header';
188
-		} elseif ($name == 'Body' && $this->status == 'envelope'){
188
+		} elseif ($name == 'Body' && $this->status == 'envelope') {
189 189
 			$this->status = 'body';
190 190
 			$this->body_position = $pos;
191 191
 		// set method
192
-		} elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
192
+		} elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) {
193 193
 			$this->status = 'method';
194 194
 			$this->root_struct_name = $name;
195 195
 			$this->root_struct = $pos;
@@ -205,23 +205,23 @@  discard block
 block discarded – undo
205 205
 
206 206
 		// loop through atts, logging ns and type declarations
207 207
         $attstr = '';
208
-		foreach($attrs as $key => $value){
208
+		foreach ($attrs as $key => $value) {
209 209
         	$key_prefix = $this->getPrefix($key);
210 210
 			$key_localpart = $this->getLocalPart($key);
211 211
 			// if ns declarations, add to class level array of valid namespaces
212
-            if($key_prefix == 'xmlns'){
213
-				if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
212
+            if ($key_prefix == 'xmlns') {
213
+				if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) {
214 214
 					$this->XMLSchemaVersion = $value;
215 215
 					$this->namespaces['xsd'] = $this->XMLSchemaVersion;
216 216
 					$this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
217 217
 				}
218 218
                 $this->namespaces[$key_localpart] = $value;
219 219
 				// set method namespace
220
-				if($name == $this->root_struct_name){
220
+				if ($name == $this->root_struct_name) {
221 221
 					$this->methodNamespace = $value;
222 222
 				}
223 223
 			// if it's a type declaration, set type
224
-        } elseif($key_localpart == 'type'){
224
+        } elseif ($key_localpart == 'type') {
225 225
         		if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
226 226
         			// do nothing: already processed arrayType
227 227
         		} else {
@@ -229,14 +229,14 @@  discard block
 block discarded – undo
229 229
 	                $value_localpart = $this->getLocalPart($value);
230 230
 					$this->message[$pos]['type'] = $value_localpart;
231 231
 					$this->message[$pos]['typePrefix'] = $value_prefix;
232
-	                if(isset($this->namespaces[$value_prefix])){
232
+	                if (isset($this->namespaces[$value_prefix])) {
233 233
 	                	$this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
234
-	                } else if(isset($attrs['xmlns:'.$value_prefix])) {
234
+	                } else if (isset($attrs['xmlns:'.$value_prefix])) {
235 235
 						$this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
236 236
 	                }
237 237
 					// should do something here with the namespace of specified type?
238 238
 				}
239
-			} elseif($key_localpart == 'arrayType'){
239
+			} elseif ($key_localpart == 'arrayType') {
240 240
 				$this->message[$pos]['type'] = 'array';
241 241
 				/* do arrayType ereg here
242 242
 				[1]    arrayTypeValue    ::=    atype asize
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 				[6]    nextDimension    ::=    Digit+ ','
248 248
 				*/
249 249
 				$expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
250
-				if(preg_match($expr,$value,$regs)){
250
+				if (preg_match($expr, $value, $regs)) {
251 251
 					$this->message[$pos]['typePrefix'] = $regs[1];
252 252
 					$this->message[$pos]['arrayTypePrefix'] = $regs[1];
253 253
 	                if (isset($this->namespaces[$regs[1]])) {
@@ -260,22 +260,22 @@  discard block
 block discarded – undo
260 260
 					$this->message[$pos]['arrayCols'] = $regs[4];
261 261
 				}
262 262
 			// specifies nil value (or not)
263
-			} elseif ($key_localpart == 'nil'){
263
+			} elseif ($key_localpart == 'nil') {
264 264
 				$this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
265 265
 			// some other attribute
266 266
 			} elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
267
-				$this->message[$pos]['xattrs']['!' . $key] = $value;
267
+				$this->message[$pos]['xattrs']['!'.$key] = $value;
268 268
 			}
269 269
 
270 270
 			if ($key == 'xmlns') {
271 271
 				$this->default_namespace = $value;
272 272
 			}
273 273
 			// log id
274
-			if($key == 'id'){
274
+			if ($key == 'id') {
275 275
 				$this->ids[$value] = $pos;
276 276
 			}
277 277
 			// root
278
-			if($key_localpart == 'root' && $value == 1){
278
+			if ($key_localpart == 'root' && $value == 1) {
279 279
 				$this->status = 'method';
280 280
 				$this->root_struct_name = $name;
281 281
 				$this->root_struct = $pos;
@@ -285,18 +285,18 @@  discard block
 block discarded – undo
285 285
             $attstr .= " $key=\"$value\"";
286 286
 		}
287 287
         // get namespace - must be done after namespace atts are processed
288
-		if(isset($prefix)){
288
+		if (isset($prefix)) {
289 289
 			$this->message[$pos]['namespace'] = $this->namespaces[$prefix];
290 290
 			$this->default_namespace = $this->namespaces[$prefix];
291 291
 		} else {
292 292
 			$this->message[$pos]['namespace'] = $this->default_namespace;
293 293
 		}
294
-        if($this->status == 'header'){
294
+        if ($this->status == 'header') {
295 295
         	if ($this->root_header != $pos) {
296
-	        	$this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
296
+	        	$this->responseHeaders .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>";
297 297
 	        }
298
-        } elseif($this->root_struct_name != ''){
299
-        	$this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
298
+        } elseif ($this->root_struct_name != '') {
299
+        	$this->document .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>";
300 300
         }
301 301
 	}
302 302
 
@@ -312,27 +312,27 @@  discard block
 block discarded – undo
312 312
 		$pos = $this->depth_array[$this->depth--];
313 313
 
314 314
         // get element prefix
315
-		if(strpos($name,':')){
315
+		if (strpos($name, ':')) {
316 316
 			// get ns prefix
317
-			$prefix = substr($name,0,strpos($name,':'));
317
+			$prefix = substr($name, 0, strpos($name, ':'));
318 318
 			// get unqualified name
319
-			$name = substr(strstr($name,':'),1);
319
+			$name = substr(strstr($name, ':'), 1);
320 320
 		}
321 321
 		
322 322
 		// build to native type
323
-		if(isset($this->body_position) && $pos > $this->body_position){
323
+		if (isset($this->body_position) && $pos > $this->body_position) {
324 324
 			// deal w/ multirefs
325
-			if(isset($this->message[$pos]['attrs']['href'])){
325
+			if (isset($this->message[$pos]['attrs']['href'])) {
326 326
 				// get id
327
-				$id = substr($this->message[$pos]['attrs']['href'],1);
327
+				$id = substr($this->message[$pos]['attrs']['href'], 1);
328 328
 				// add placeholder to href array
329 329
 				$this->multirefs[$id][$pos] = 'placeholder';
330 330
 				// add set a reference to it as the result value
331
-				$this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
331
+				$this->message[$pos]['result'] = & $this->multirefs[$id][$pos];
332 332
             // build complexType values
333
-			} elseif($this->message[$pos]['children'] != ''){
333
+			} elseif ($this->message[$pos]['children'] != '') {
334 334
 				// if result has already been generated (struct/array)
335
-				if(!isset($this->message[$pos]['result'])){
335
+				if (!isset($this->message[$pos]['result'])) {
336 336
 					$this->message[$pos]['result'] = $this->buildVal($pos);
337 337
 				}
338 338
 			// build complexType values of attributes and possibly simpleContent
@@ -382,15 +382,15 @@  discard block
 block discarded – undo
382 382
 		}
383 383
 		
384 384
         // for doclit
385
-        if($this->status == 'header'){
385
+        if ($this->status == 'header') {
386 386
         	if ($this->root_header != $pos) {
387
-	        	$this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
387
+	        	$this->responseHeaders .= "</".(isset($prefix) ? $prefix.':' : '')."$name>";
388 388
 	        }
389
-        } elseif($pos >= $this->root_struct){
390
-        	$this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
389
+        } elseif ($pos >= $this->root_struct) {
390
+        	$this->document .= "</".(isset($prefix) ? $prefix.':' : '')."$name>";
391 391
         }
392 392
 		// switch status
393
-		if ($pos == $this->root_struct){
393
+		if ($pos == $this->root_struct) {
394 394
 			$this->status = 'body';
395 395
 			$this->root_struct_namespace = $this->message[$pos]['namespace'];
396 396
 		} elseif ($pos == $this->root_header) {
@@ -416,17 +416,17 @@  discard block
 block discarded – undo
416 416
 	function character_data($parser, $data)
417 417
     {
418 418
 		$pos = $this->depth_array[$this->depth];
419
-		if ($this->xml_encoding == 'UTF-8'){
419
+		if ($this->xml_encoding == 'UTF-8') {
420 420
 			// TODO: add an option to disable this for folks who want
421 421
 			// raw UTF-8 that, e.g., might not map to iso-8859-1
422 422
 			// TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
423
-			if($this->decode_utf8){
423
+			if ($this->decode_utf8) {
424 424
 				$data = utf8_decode($data);
425 425
 			}
426 426
 		}
427 427
         $this->message[$pos]['cdata'] .= $data;
428 428
         // for doclit
429
-        if($this->status == 'header'){
429
+        if ($this->status == 'header') {
430 430
         	$this->responseHeaders .= $data;
431 431
         } else {
432 432
         	$this->document .= $data;
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 	* @access   public
441 441
 	* @deprecated	use get_soapbody instead
442 442
 	*/
443
-	function get_response(){
443
+	function get_response() {
444 444
 		return $this->soapresponse;
445 445
 	}
446 446
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	* @return	mixed
451 451
 	* @access   public
452 452
 	*/
453
-	function get_soapbody(){
453
+	function get_soapbody() {
454 454
 		return $this->soapresponse;
455 455
 	}
456 456
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 	* @return	mixed
461 461
 	* @access   public
462 462
 	*/
463
-	function get_soapheader(){
463
+	function get_soapheader() {
464 464
 		return $this->soapheader;
465 465
 	}
466 466
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	* @return	string XML or empty if no Header
471 471
 	* @access   public
472 472
 	*/
473
-	function getHeaders(){
473
+	function getHeaders() {
474 474
 	    return $this->responseHeaders;
475 475
 	}
476 476
 
@@ -527,40 +527,40 @@  discard block
 block discarded – undo
527 527
 	* @return	mixed	PHP value
528 528
 	* @access   private
529 529
 	*/
530
-	function buildVal($pos){
531
-		if(!isset($this->message[$pos]['type'])){
530
+	function buildVal($pos) {
531
+		if (!isset($this->message[$pos]['type'])) {
532 532
 			$this->message[$pos]['type'] = '';
533 533
 		}
534 534
 		$this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
535 535
 		// if there are children...
536
-		if($this->message[$pos]['children'] != ''){
536
+		if ($this->message[$pos]['children'] != '') {
537 537
 			$this->debug('in buildVal, there are children');
538
-			$children = explode('|',$this->message[$pos]['children']);
538
+			$children = explode('|', $this->message[$pos]['children']);
539 539
 			array_shift($children); // knock off empty
540 540
 			// md array
541
-			if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
542
-            	$r=0; // rowcount
543
-            	$c=0; // colcount
544
-            	foreach($children as $child_pos){
541
+			if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') {
542
+            	$r = 0; // rowcount
543
+            	$c = 0; // colcount
544
+            	foreach ($children as $child_pos) {
545 545
 					$this->debug("in buildVal, got an MD array element: $r, $c");
546 546
 					$params[$r][] = $this->message[$child_pos]['result'];
547 547
 				    $c++;
548
-				    if($c == $this->message[$pos]['arrayCols']){
548
+				    if ($c == $this->message[$pos]['arrayCols']) {
549 549
 				    	$c = 0;
550 550
 						$r++;
551 551
 				    }
552 552
                 }
553 553
             // array
554
-			} elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
554
+			} elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
555 555
                 $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
556
-                foreach($children as $child_pos){
556
+                foreach ($children as $child_pos) {
557 557
                 	$params[] = &$this->message[$child_pos]['result'];
558 558
                 }
559 559
             // apache Map type: java hashtable
560
-            } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){
560
+            } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
561 561
                 $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']);
562
-                foreach($children as $child_pos){
563
-                	$kv = explode("|",$this->message[$child_pos]['children']);
562
+                foreach ($children as $child_pos) {
563
+                	$kv = explode("|", $this->message[$child_pos]['children']);
564 564
                    	$params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
565 565
                 }
566 566
             // generic compound type
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
 					$notstruct = 0;
575 575
 	            }
576 576
             	//
577
-            	foreach($children as $child_pos){
578
-            		if($notstruct){
577
+            	foreach ($children as $child_pos) {
578
+            		if ($notstruct) {
579 579
             			$params[] = &$this->message[$child_pos]['result'];
580 580
             		} else {
581 581
             			if (isset($params[$this->message[$child_pos]['name']])) {
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
 	* @param    string $encoding character encoding scheme of message
53 53
 	* @param    string $method method for which XML is parsed (unused?)
54 54
 	* @param    bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55
-	* @return void|bool
55
+	* @return false|null
56 56
 	* @access   public
57 57
 	*/
58 58
 	function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
Please login to merge, or discard this patch.
Indentation   +546 added lines, -546 removed lines patch added patch discarded remove patch
@@ -11,235 +11,235 @@  discard block
 block discarded – undo
11 11
 */
12 12
 class nusoap_parser extends nusoap_base
13 13
 {
14
-	var $xml = '';
15
-	var $xml_encoding = '';
16
-	var $method = '';
17
-	var $root_struct = '';
18
-	var $root_struct_name = '';
19
-	var $root_struct_namespace = '';
20
-	var $root_header = '';
14
+    var $xml = '';
15
+    var $xml_encoding = '';
16
+    var $method = '';
17
+    var $root_struct = '';
18
+    var $root_struct_name = '';
19
+    var $root_struct_namespace = '';
20
+    var $root_header = '';
21 21
     var $document = '';			// incoming SOAP body (text)
22
-	// determines where in the message we are (envelope,header,body,method)
23
-	var $status = '';
24
-	var $position = 0;
25
-	var $depth = 0;
26
-	var $default_namespace = '';
27
-	var $namespaces = array();
28
-	var $message = array();
22
+    // determines where in the message we are (envelope,header,body,method)
23
+    var $status = '';
24
+    var $position = 0;
25
+    var $depth = 0;
26
+    var $default_namespace = '';
27
+    var $namespaces = array();
28
+    var $message = array();
29 29
     var $parent;
30
-	var $fault = false;
31
-	var $fault_code = '';
32
-	var $fault_str = '';
33
-	var $fault_detail = '';
34
-	var $depth_array = array();
35
-	var $debug_flag = true;
36
-	var $soapresponse = NULL;	// parsed SOAP Body
37
-	var $soapheader = NULL;		// parsed SOAP Header
38
-	var $responseHeaders = '';	// incoming SOAP headers (text)
39
-	var $body_position = 0;
40
-	// for multiref parsing:
41
-	// array of id => pos
42
-	var $ids = array();
43
-	// array of id => hrefs => pos
44
-	var $multirefs = array();
45
-	// toggle for auto-decoding element content
46
-	var $decode_utf8 = true;
30
+    var $fault = false;
31
+    var $fault_code = '';
32
+    var $fault_str = '';
33
+    var $fault_detail = '';
34
+    var $depth_array = array();
35
+    var $debug_flag = true;
36
+    var $soapresponse = NULL;	// parsed SOAP Body
37
+    var $soapheader = NULL;		// parsed SOAP Header
38
+    var $responseHeaders = '';	// incoming SOAP headers (text)
39
+    var $body_position = 0;
40
+    // for multiref parsing:
41
+    // array of id => pos
42
+    var $ids = array();
43
+    // array of id => hrefs => pos
44
+    var $multirefs = array();
45
+    // toggle for auto-decoding element content
46
+    var $decode_utf8 = true;
47 47
 
48
-	/**
49
-	* constructor that actually does the parsing
50
-	*
51
-	* @param    string $xml SOAP message
52
-	* @param    string $encoding character encoding scheme of message
53
-	* @param    string $method method for which XML is parsed (unused?)
54
-	* @param    bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55
-	* @return void|bool
56
-	* @access   public
57
-	*/
58
-	function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
59
-		parent::nusoap_base();
60
-		$this->xml = $xml;
61
-		$this->xml_encoding = $encoding;
62
-		$this->method = $method;
63
-		$this->decode_utf8 = $decode_utf8;
48
+    /**
49
+     * constructor that actually does the parsing
50
+     *
51
+     * @param    string $xml SOAP message
52
+     * @param    string $encoding character encoding scheme of message
53
+     * @param    string $method method for which XML is parsed (unused?)
54
+     * @param    bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1
55
+     * @return void|bool
56
+     * @access   public
57
+     */
58
+    function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
59
+        parent::nusoap_base();
60
+        $this->xml = $xml;
61
+        $this->xml_encoding = $encoding;
62
+        $this->method = $method;
63
+        $this->decode_utf8 = $decode_utf8;
64 64
 
65
-		// Check whether content has been read.
66
-		if(!empty($this->xml)){
67
-			// Check XML encoding
68
-			$pos_xml = strpos($xml, '<?xml');
69
-			if ($pos_xml !== FALSE) {
70
-				$xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
71
-				if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
72
-					$xml_encoding = $res[1];
73
-					if (strtoupper($xml_encoding) != $encoding) {
74
-						$err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
75
-						$this->debug($err);
76
-						if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
77
-							$this->setError($err);
78
-							return false;
79
-						}
80
-						// when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
81
-					} else {
82
-						$this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
83
-					}
84
-				} else {
85
-					$this->debug('No encoding specified in XML declaration');
86
-				}
87
-			} else {
88
-				$this->debug('No XML declaration');
89
-			}
90
-			$this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
91
-			// Create an XML parser - why not xml_parser_create_ns?
92
-			$this->parser = xml_parser_create($this->xml_encoding);
93
-			// Set the options for parsing the XML data.
94
-			//xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
95
-			xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
96
-			xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
97
-			// Set the object for the parser.
98
-			xml_set_object($this->parser, $this);
99
-			// Set the element handlers for the parser.
100
-			xml_set_element_handler($this->parser, 'start_element','end_element');
101
-			xml_set_character_data_handler($this->parser,'character_data');
65
+        // Check whether content has been read.
66
+        if(!empty($this->xml)){
67
+            // Check XML encoding
68
+            $pos_xml = strpos($xml, '<?xml');
69
+            if ($pos_xml !== FALSE) {
70
+                $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
71
+                if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
72
+                    $xml_encoding = $res[1];
73
+                    if (strtoupper($xml_encoding) != $encoding) {
74
+                        $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
75
+                        $this->debug($err);
76
+                        if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
77
+                            $this->setError($err);
78
+                            return false;
79
+                        }
80
+                        // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
81
+                    } else {
82
+                        $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
83
+                    }
84
+                } else {
85
+                    $this->debug('No encoding specified in XML declaration');
86
+                }
87
+            } else {
88
+                $this->debug('No XML declaration');
89
+            }
90
+            $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
91
+            // Create an XML parser - why not xml_parser_create_ns?
92
+            $this->parser = xml_parser_create($this->xml_encoding);
93
+            // Set the options for parsing the XML data.
94
+            //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
95
+            xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
96
+            xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
97
+            // Set the object for the parser.
98
+            xml_set_object($this->parser, $this);
99
+            // Set the element handlers for the parser.
100
+            xml_set_element_handler($this->parser, 'start_element','end_element');
101
+            xml_set_character_data_handler($this->parser,'character_data');
102 102
 
103
-			xml_parse($this->parser, $this->xml);
103
+            xml_parse($this->parser, $this->xml);
104 104
 
105
-			// Parse the XML file.
106
-			//if (!xml_parse($this->parser,$xml,true)){
107
-			if (false) {
108
-			    // Display an error message.
109
-			    $err = sprintf('XML error parsing SOAP payload on line %d: %s',
110
-			    xml_get_current_line_number($this->parser),
111
-			    xml_error_string(xml_get_error_code($this->parser)));
112
-				$this->debug($err);
113
-				$this->debug("XML payload:\n" . $xml);
114
-				$this->setError($err);
115
-			} else {
116
-				$this->debug('in nusoap_parser ctor, message:');
117
-				$this->appendDebug($this->varDump($this->message));
118
-				$this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
119
-				// get final value
120
-				$this->soapresponse = $this->message[$this->root_struct]['result'];
121
-				// get header value
122
-				if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
123
-					$this->soapheader = $this->message[$this->root_header]['result'];
124
-				}
125
-				// resolve hrefs/ids
126
-				if(sizeof($this->multirefs) > 0){
127
-					foreach($this->multirefs as $id => $hrefs){
128
-						$this->debug('resolving multirefs for id: '.$id);
129
-						$idVal = $this->buildVal($this->ids[$id]);
130
-						if (is_array($idVal) && isset($idVal['!id'])) {
131
-							unset($idVal['!id']);
132
-						}
133
-						foreach($hrefs as $refPos => $ref){
134
-							$this->debug('resolving href at pos '.$refPos);
135
-							$this->multirefs[$id][$refPos] = $idVal;
136
-						}
137
-					}
138
-				}
139
-			}
140
-			xml_parser_free($this->parser);
141
-		} else {
142
-			$this->debug('xml was empty, didn\'t parse!');
143
-			$this->setError('xml was empty, didn\'t parse!');
144
-		}
145
-	}
105
+            // Parse the XML file.
106
+            //if (!xml_parse($this->parser,$xml,true)){
107
+            if (false) {
108
+                // Display an error message.
109
+                $err = sprintf('XML error parsing SOAP payload on line %d: %s',
110
+                xml_get_current_line_number($this->parser),
111
+                xml_error_string(xml_get_error_code($this->parser)));
112
+                $this->debug($err);
113
+                $this->debug("XML payload:\n" . $xml);
114
+                $this->setError($err);
115
+            } else {
116
+                $this->debug('in nusoap_parser ctor, message:');
117
+                $this->appendDebug($this->varDump($this->message));
118
+                $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
119
+                // get final value
120
+                $this->soapresponse = $this->message[$this->root_struct]['result'];
121
+                // get header value
122
+                if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
123
+                    $this->soapheader = $this->message[$this->root_header]['result'];
124
+                }
125
+                // resolve hrefs/ids
126
+                if(sizeof($this->multirefs) > 0){
127
+                    foreach($this->multirefs as $id => $hrefs){
128
+                        $this->debug('resolving multirefs for id: '.$id);
129
+                        $idVal = $this->buildVal($this->ids[$id]);
130
+                        if (is_array($idVal) && isset($idVal['!id'])) {
131
+                            unset($idVal['!id']);
132
+                        }
133
+                        foreach($hrefs as $refPos => $ref){
134
+                            $this->debug('resolving href at pos '.$refPos);
135
+                            $this->multirefs[$id][$refPos] = $idVal;
136
+                        }
137
+                    }
138
+                }
139
+            }
140
+            xml_parser_free($this->parser);
141
+        } else {
142
+            $this->debug('xml was empty, didn\'t parse!');
143
+            $this->setError('xml was empty, didn\'t parse!');
144
+        }
145
+    }
146 146
 
147
-	/**
148
-	* start-element handler
149
-	*
150
-	* @param    resource $parser XML parser object
151
-	* @param    string $name element name
152
-	* @param    array $attrs associative array of attributes
153
-	* @access   private
154
-	*/
155
-	function start_element($parser, $name, $attrs) {
147
+    /**
148
+     * start-element handler
149
+     *
150
+     * @param    resource $parser XML parser object
151
+     * @param    string $name element name
152
+     * @param    array $attrs associative array of attributes
153
+     * @access   private
154
+     */
155
+    function start_element($parser, $name, $attrs) {
156 156
 
157
-		// position in a total number of elements, starting from 0
158
-		// update class level pos
159
-		$pos = $this->position++;
160
-		// and set mine
161
-		$this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
162
-		// depth = how many levels removed from root?
163
-		// set mine as current global depth and increment global depth value
164
-		$this->message[$pos]['depth'] = $this->depth++;
157
+        // position in a total number of elements, starting from 0
158
+        // update class level pos
159
+        $pos = $this->position++;
160
+        // and set mine
161
+        $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
162
+        // depth = how many levels removed from root?
163
+        // set mine as current global depth and increment global depth value
164
+        $this->message[$pos]['depth'] = $this->depth++;
165 165
 
166
-		// else add self as child to whoever the current parent is
167
-		if($pos != 0){
168
-			$this->message[$this->parent]['children'] .= '|'.$pos;
169
-		}
170
-		// set my parent
171
-		$this->message[$pos]['parent'] = $this->parent;
172
-		// set self as current parent
173
-		$this->parent = $pos;
174
-		// set self as current value for this depth
175
-		$this->depth_array[$this->depth] = $pos;
176
-		// get element prefix
177
-		if(strpos($name,':')){
178
-			// get ns prefix
179
-			$prefix = substr($name,0,strpos($name,':'));
180
-			// get unqualified name
181
-			$name = substr(strstr($name,':'),1);
182
-		}
183
-		// set status
184
-		if ($name == 'Envelope' && $this->status == '') {
185
-			$this->status = 'envelope';
186
-		} elseif ($name == 'Header' && $this->status == 'envelope') {
187
-			$this->root_header = $pos;
188
-			$this->status = 'header';
189
-		} elseif ($name == 'Body' && $this->status == 'envelope'){
190
-			$this->status = 'body';
191
-			$this->body_position = $pos;
192
-		// set method
193
-		} elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
194
-			$this->status = 'method';
195
-			$this->root_struct_name = $name;
196
-			$this->root_struct = $pos;
197
-			$this->message[$pos]['type'] = 'struct';
198
-			$this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
199
-		}
200
-		// set my status
201
-		$this->message[$pos]['status'] = $this->status;
202
-		// set name
203
-		$this->message[$pos]['name'] = htmlspecialchars($name);
204
-		// set attrs
205
-		$this->message[$pos]['attrs'] = $attrs;
166
+        // else add self as child to whoever the current parent is
167
+        if($pos != 0){
168
+            $this->message[$this->parent]['children'] .= '|'.$pos;
169
+        }
170
+        // set my parent
171
+        $this->message[$pos]['parent'] = $this->parent;
172
+        // set self as current parent
173
+        $this->parent = $pos;
174
+        // set self as current value for this depth
175
+        $this->depth_array[$this->depth] = $pos;
176
+        // get element prefix
177
+        if(strpos($name,':')){
178
+            // get ns prefix
179
+            $prefix = substr($name,0,strpos($name,':'));
180
+            // get unqualified name
181
+            $name = substr(strstr($name,':'),1);
182
+        }
183
+        // set status
184
+        if ($name == 'Envelope' && $this->status == '') {
185
+            $this->status = 'envelope';
186
+        } elseif ($name == 'Header' && $this->status == 'envelope') {
187
+            $this->root_header = $pos;
188
+            $this->status = 'header';
189
+        } elseif ($name == 'Body' && $this->status == 'envelope'){
190
+            $this->status = 'body';
191
+            $this->body_position = $pos;
192
+        // set method
193
+        } elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
194
+            $this->status = 'method';
195
+            $this->root_struct_name = $name;
196
+            $this->root_struct = $pos;
197
+            $this->message[$pos]['type'] = 'struct';
198
+            $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
199
+        }
200
+        // set my status
201
+        $this->message[$pos]['status'] = $this->status;
202
+        // set name
203
+        $this->message[$pos]['name'] = htmlspecialchars($name);
204
+        // set attrs
205
+        $this->message[$pos]['attrs'] = $attrs;
206 206
 
207
-		// loop through atts, logging ns and type declarations
207
+        // loop through atts, logging ns and type declarations
208 208
         $attstr = '';
209
-		foreach($attrs as $key => $value){
210
-        	$key_prefix = $this->getPrefix($key);
211
-			$key_localpart = $this->getLocalPart($key);
212
-			// if ns declarations, add to class level array of valid namespaces
209
+        foreach($attrs as $key => $value){
210
+            $key_prefix = $this->getPrefix($key);
211
+            $key_localpart = $this->getLocalPart($key);
212
+            // if ns declarations, add to class level array of valid namespaces
213 213
             if($key_prefix == 'xmlns'){
214
-				if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
215
-					$this->XMLSchemaVersion = $value;
216
-					$this->namespaces['xsd'] = $this->XMLSchemaVersion;
217
-					$this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
218
-				}
214
+                if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
215
+                    $this->XMLSchemaVersion = $value;
216
+                    $this->namespaces['xsd'] = $this->XMLSchemaVersion;
217
+                    $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
218
+                }
219 219
                 $this->namespaces[$key_localpart] = $value;
220
-				// set method namespace
221
-				if($name == $this->root_struct_name){
222
-					$this->methodNamespace = $value;
223
-				}
224
-			// if it's a type declaration, set type
220
+                // set method namespace
221
+                if($name == $this->root_struct_name){
222
+                    $this->methodNamespace = $value;
223
+                }
224
+            // if it's a type declaration, set type
225 225
         } elseif($key_localpart == 'type'){
226
-        		if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
227
-        			// do nothing: already processed arrayType
228
-        		} else {
229
-	            	$value_prefix = $this->getPrefix($value);
230
-	                $value_localpart = $this->getLocalPart($value);
231
-					$this->message[$pos]['type'] = $value_localpart;
232
-					$this->message[$pos]['typePrefix'] = $value_prefix;
233
-	                if(isset($this->namespaces[$value_prefix])){
234
-	                	$this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
235
-	                } else if(isset($attrs['xmlns:'.$value_prefix])) {
236
-						$this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
237
-	                }
238
-					// should do something here with the namespace of specified type?
239
-				}
240
-			} elseif($key_localpart == 'arrayType'){
241
-				$this->message[$pos]['type'] = 'array';
242
-				/* do arrayType ereg here
226
+                if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
227
+                    // do nothing: already processed arrayType
228
+                } else {
229
+                    $value_prefix = $this->getPrefix($value);
230
+                    $value_localpart = $this->getLocalPart($value);
231
+                    $this->message[$pos]['type'] = $value_localpart;
232
+                    $this->message[$pos]['typePrefix'] = $value_prefix;
233
+                    if(isset($this->namespaces[$value_prefix])){
234
+                        $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
235
+                    } else if(isset($attrs['xmlns:'.$value_prefix])) {
236
+                        $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
237
+                    }
238
+                    // should do something here with the namespace of specified type?
239
+                }
240
+            } elseif($key_localpart == 'arrayType'){
241
+                $this->message[$pos]['type'] = 'array';
242
+                /* do arrayType ereg here
243 243
 				[1]    arrayTypeValue    ::=    atype asize
244 244
 				[2]    atype    ::=    QName rank*
245 245
 				[3]    rank    ::=    '[' (',')* ']'
@@ -247,129 +247,129 @@  discard block
 block discarded – undo
247 247
 				[5]    length    ::=    nextDimension* Digit+
248 248
 				[6]    nextDimension    ::=    Digit+ ','
249 249
 				*/
250
-				$expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
251
-				if(preg_match($expr,$value,$regs)){
252
-					$this->message[$pos]['typePrefix'] = $regs[1];
253
-					$this->message[$pos]['arrayTypePrefix'] = $regs[1];
254
-	                if (isset($this->namespaces[$regs[1]])) {
255
-	                	$this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
256
-	                } else if (isset($attrs['xmlns:'.$regs[1]])) {
257
-						$this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
258
-	                }
259
-					$this->message[$pos]['arrayType'] = $regs[2];
260
-					$this->message[$pos]['arraySize'] = $regs[3];
261
-					$this->message[$pos]['arrayCols'] = $regs[4];
262
-				}
263
-			// specifies nil value (or not)
264
-			} elseif ($key_localpart == 'nil'){
265
-				$this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
266
-			// some other attribute
267
-			} elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
268
-				$this->message[$pos]['xattrs']['!' . $key] = $value;
269
-			}
250
+                $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
251
+                if(preg_match($expr,$value,$regs)){
252
+                    $this->message[$pos]['typePrefix'] = $regs[1];
253
+                    $this->message[$pos]['arrayTypePrefix'] = $regs[1];
254
+                    if (isset($this->namespaces[$regs[1]])) {
255
+                        $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
256
+                    } else if (isset($attrs['xmlns:'.$regs[1]])) {
257
+                        $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
258
+                    }
259
+                    $this->message[$pos]['arrayType'] = $regs[2];
260
+                    $this->message[$pos]['arraySize'] = $regs[3];
261
+                    $this->message[$pos]['arrayCols'] = $regs[4];
262
+                }
263
+            // specifies nil value (or not)
264
+            } elseif ($key_localpart == 'nil'){
265
+                $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
266
+            // some other attribute
267
+            } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
268
+                $this->message[$pos]['xattrs']['!' . $key] = $value;
269
+            }
270 270
 
271
-			if ($key == 'xmlns') {
272
-				$this->default_namespace = $value;
273
-			}
274
-			// log id
275
-			if($key == 'id'){
276
-				$this->ids[$value] = $pos;
277
-			}
278
-			// root
279
-			if($key_localpart == 'root' && $value == 1){
280
-				$this->status = 'method';
281
-				$this->root_struct_name = $name;
282
-				$this->root_struct = $pos;
283
-				$this->debug("found root struct $this->root_struct_name, pos $pos");
284
-			}
271
+            if ($key == 'xmlns') {
272
+                $this->default_namespace = $value;
273
+            }
274
+            // log id
275
+            if($key == 'id'){
276
+                $this->ids[$value] = $pos;
277
+            }
278
+            // root
279
+            if($key_localpart == 'root' && $value == 1){
280
+                $this->status = 'method';
281
+                $this->root_struct_name = $name;
282
+                $this->root_struct = $pos;
283
+                $this->debug("found root struct $this->root_struct_name, pos $pos");
284
+            }
285 285
             // for doclit
286 286
             $attstr .= " $key=\"$value\"";
287
-		}
287
+        }
288 288
         // get namespace - must be done after namespace atts are processed
289
-		if(isset($prefix)){
290
-			$this->message[$pos]['namespace'] = $this->namespaces[$prefix];
291
-			$this->default_namespace = $this->namespaces[$prefix];
292
-		} else {
293
-			$this->message[$pos]['namespace'] = $this->default_namespace;
294
-		}
289
+        if(isset($prefix)){
290
+            $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
291
+            $this->default_namespace = $this->namespaces[$prefix];
292
+        } else {
293
+            $this->message[$pos]['namespace'] = $this->default_namespace;
294
+        }
295 295
         if($this->status == 'header'){
296
-        	if ($this->root_header != $pos) {
297
-	        	$this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
298
-	        }
296
+            if ($this->root_header != $pos) {
297
+                $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
298
+            }
299 299
         } elseif($this->root_struct_name != ''){
300
-        	$this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
300
+            $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
301 301
         }
302
-	}
302
+    }
303 303
 
304
-	/**
305
-	* end-element handler
306
-	*
307
-	* @param    resource $parser XML parser object
308
-	* @param    string $name element name
309
-	* @access   private
310
-	*/
311
-	function end_element($parser, $name) {
312
-		// position of current element is equal to the last value left in depth_array for my depth
313
-		$pos = $this->depth_array[$this->depth--];
304
+    /**
305
+     * end-element handler
306
+     *
307
+     * @param    resource $parser XML parser object
308
+     * @param    string $name element name
309
+     * @access   private
310
+     */
311
+    function end_element($parser, $name) {
312
+        // position of current element is equal to the last value left in depth_array for my depth
313
+        $pos = $this->depth_array[$this->depth--];
314 314
 
315 315
         // get element prefix
316
-		if(strpos($name,':')){
317
-			// get ns prefix
318
-			$prefix = substr($name,0,strpos($name,':'));
319
-			// get unqualified name
320
-			$name = substr(strstr($name,':'),1);
321
-		}
316
+        if(strpos($name,':')){
317
+            // get ns prefix
318
+            $prefix = substr($name,0,strpos($name,':'));
319
+            // get unqualified name
320
+            $name = substr(strstr($name,':'),1);
321
+        }
322 322
 		
323
-		// build to native type
324
-		if(isset($this->body_position) && $pos > $this->body_position){
325
-			// deal w/ multirefs
326
-			if(isset($this->message[$pos]['attrs']['href'])){
327
-				// get id
328
-				$id = substr($this->message[$pos]['attrs']['href'],1);
329
-				// add placeholder to href array
330
-				$this->multirefs[$id][$pos] = 'placeholder';
331
-				// add set a reference to it as the result value
332
-				$this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
323
+        // build to native type
324
+        if(isset($this->body_position) && $pos > $this->body_position){
325
+            // deal w/ multirefs
326
+            if(isset($this->message[$pos]['attrs']['href'])){
327
+                // get id
328
+                $id = substr($this->message[$pos]['attrs']['href'],1);
329
+                // add placeholder to href array
330
+                $this->multirefs[$id][$pos] = 'placeholder';
331
+                // add set a reference to it as the result value
332
+                $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
333 333
             // build complexType values
334
-			} elseif($this->message[$pos]['children'] != ''){
335
-				// if result has already been generated (struct/array)
336
-				if(!isset($this->message[$pos]['result'])){
337
-					$this->message[$pos]['result'] = $this->buildVal($pos);
338
-				}
339
-			// build complexType values of attributes and possibly simpleContent
340
-			} elseif (isset($this->message[$pos]['xattrs'])) {
341
-				if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
342
-					$this->message[$pos]['xattrs']['!'] = null;
343
-				} elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
344
-	            	if (isset($this->message[$pos]['type'])) {
345
-						$this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
346
-					} else {
347
-						$parent = $this->message[$pos]['parent'];
348
-						if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
349
-							$this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
350
-						} else {
351
-							$this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
352
-						}
353
-					}
354
-				}
355
-				$this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
356
-			// set value of simpleType (or nil complexType)
357
-			} else {
358
-            	//$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
359
-				if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
360
-					$this->message[$pos]['xattrs']['!'] = null;
361
-				} elseif (isset($this->message[$pos]['type'])) {
362
-					$this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
363
-				} else {
364
-					$parent = $this->message[$pos]['parent'];
365
-					if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
366
-						$this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
367
-					} else {
368
-						$this->message[$pos]['result'] = $this->message[$pos]['cdata'];
369
-					}
370
-				}
334
+            } elseif($this->message[$pos]['children'] != ''){
335
+                // if result has already been generated (struct/array)
336
+                if(!isset($this->message[$pos]['result'])){
337
+                    $this->message[$pos]['result'] = $this->buildVal($pos);
338
+                }
339
+            // build complexType values of attributes and possibly simpleContent
340
+            } elseif (isset($this->message[$pos]['xattrs'])) {
341
+                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
342
+                    $this->message[$pos]['xattrs']['!'] = null;
343
+                } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
344
+                    if (isset($this->message[$pos]['type'])) {
345
+                        $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
346
+                    } else {
347
+                        $parent = $this->message[$pos]['parent'];
348
+                        if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
349
+                            $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
350
+                        } else {
351
+                            $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
352
+                        }
353
+                    }
354
+                }
355
+                $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
356
+            // set value of simpleType (or nil complexType)
357
+            } else {
358
+                //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
359
+                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
360
+                    $this->message[$pos]['xattrs']['!'] = null;
361
+                } elseif (isset($this->message[$pos]['type'])) {
362
+                    $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
363
+                } else {
364
+                    $parent = $this->message[$pos]['parent'];
365
+                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
366
+                        $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
367
+                    } else {
368
+                        $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
369
+                    }
370
+                }
371 371
 
372
-				/* add value to parent's result, if parent is struct/array
372
+                /* add value to parent's result, if parent is struct/array
373 373
 				$parent = $this->message[$pos]['parent'];
374 374
 				if($this->message[$parent]['type'] != 'map'){
375 375
 					if(strtolower($this->message[$parent]['type']) == 'array'){
@@ -379,261 +379,261 @@  discard block
 block discarded – undo
379 379
 					}
380 380
 				}
381 381
 				*/
382
-			}
383
-		}
382
+            }
383
+        }
384 384
 		
385 385
         // for doclit
386 386
         if($this->status == 'header'){
387
-        	if ($this->root_header != $pos) {
388
-	        	$this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
389
-	        }
387
+            if ($this->root_header != $pos) {
388
+                $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
389
+            }
390 390
         } elseif($pos >= $this->root_struct){
391
-        	$this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
391
+            $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
392 392
         }
393
-		// switch status
394
-		if ($pos == $this->root_struct){
395
-			$this->status = 'body';
396
-			$this->root_struct_namespace = $this->message[$pos]['namespace'];
397
-		} elseif ($pos == $this->root_header) {
398
-			$this->status = 'envelope';
399
-		} elseif ($name == 'Body' && $this->status == 'body') {
400
-			$this->status = 'envelope';
401
-		} elseif ($name == 'Header' && $this->status == 'header') { // will never happen
402
-			$this->status = 'envelope';
403
-		} elseif ($name == 'Envelope' && $this->status == 'envelope') {
404
-			$this->status = '';
405
-		}
406
-		// set parent back to my parent
407
-		$this->parent = $this->message[$pos]['parent'];
408
-	}
393
+        // switch status
394
+        if ($pos == $this->root_struct){
395
+            $this->status = 'body';
396
+            $this->root_struct_namespace = $this->message[$pos]['namespace'];
397
+        } elseif ($pos == $this->root_header) {
398
+            $this->status = 'envelope';
399
+        } elseif ($name == 'Body' && $this->status == 'body') {
400
+            $this->status = 'envelope';
401
+        } elseif ($name == 'Header' && $this->status == 'header') { // will never happen
402
+            $this->status = 'envelope';
403
+        } elseif ($name == 'Envelope' && $this->status == 'envelope') {
404
+            $this->status = '';
405
+        }
406
+        // set parent back to my parent
407
+        $this->parent = $this->message[$pos]['parent'];
408
+    }
409 409
 
410
-	/**
411
-	* element content handler
412
-	*
413
-	* @param    resource $parser XML parser object
414
-	* @param    string $data element content
415
-	* @access   private
416
-	*/
417
-	function character_data($parser, $data)
410
+    /**
411
+     * element content handler
412
+     *
413
+     * @param    resource $parser XML parser object
414
+     * @param    string $data element content
415
+     * @access   private
416
+     */
417
+    function character_data($parser, $data)
418 418
     {
419
-		$pos = $this->depth_array[$this->depth];
420
-		if ($this->xml_encoding == 'UTF-8'){
421
-			// TODO: add an option to disable this for folks who want
422
-			// raw UTF-8 that, e.g., might not map to iso-8859-1
423
-			// TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
424
-			if($this->decode_utf8){
425
-				$data = utf8_decode($data);
426
-			}
427
-		}
419
+        $pos = $this->depth_array[$this->depth];
420
+        if ($this->xml_encoding == 'UTF-8'){
421
+            // TODO: add an option to disable this for folks who want
422
+            // raw UTF-8 that, e.g., might not map to iso-8859-1
423
+            // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
424
+            if($this->decode_utf8){
425
+                $data = utf8_decode($data);
426
+            }
427
+        }
428 428
         $this->message[$pos]['cdata'] .= $data;
429 429
         // for doclit
430 430
         if($this->status == 'header'){
431
-        	$this->responseHeaders .= $data;
431
+            $this->responseHeaders .= $data;
432 432
         } else {
433
-        	$this->document .= $data;
433
+            $this->document .= $data;
434 434
         }
435
-	}
435
+    }
436 436
 
437
-	/**
438
-	* get the parsed message (SOAP Body)
439
-	*
440
-	* @return	mixed
441
-	* @access   public
442
-	* @deprecated	use get_soapbody instead
443
-	*/
444
-	function get_response(){
445
-		return $this->soapresponse;
446
-	}
437
+    /**
438
+     * get the parsed message (SOAP Body)
439
+     *
440
+     * @return	mixed
441
+     * @access   public
442
+     * @deprecated	use get_soapbody instead
443
+     */
444
+    function get_response(){
445
+        return $this->soapresponse;
446
+    }
447 447
 
448
-	/**
449
-	* get the parsed SOAP Body (NULL if there was none)
450
-	*
451
-	* @return	mixed
452
-	* @access   public
453
-	*/
454
-	function get_soapbody(){
455
-		return $this->soapresponse;
456
-	}
448
+    /**
449
+     * get the parsed SOAP Body (NULL if there was none)
450
+     *
451
+     * @return	mixed
452
+     * @access   public
453
+     */
454
+    function get_soapbody(){
455
+        return $this->soapresponse;
456
+    }
457 457
 
458
-	/**
459
-	* get the parsed SOAP Header (NULL if there was none)
460
-	*
461
-	* @return	mixed
462
-	* @access   public
463
-	*/
464
-	function get_soapheader(){
465
-		return $this->soapheader;
466
-	}
458
+    /**
459
+     * get the parsed SOAP Header (NULL if there was none)
460
+     *
461
+     * @return	mixed
462
+     * @access   public
463
+     */
464
+    function get_soapheader(){
465
+        return $this->soapheader;
466
+    }
467 467
 
468
-	/**
469
-	* get the unparsed SOAP Header
470
-	*
471
-	* @return	string XML or empty if no Header
472
-	* @access   public
473
-	*/
474
-	function getHeaders(){
475
-	    return $this->responseHeaders;
476
-	}
468
+    /**
469
+     * get the unparsed SOAP Header
470
+     *
471
+     * @return	string XML or empty if no Header
472
+     * @access   public
473
+     */
474
+    function getHeaders(){
475
+        return $this->responseHeaders;
476
+    }
477 477
 
478
-	/**
479
-	* decodes simple types into PHP variables
480
-	*
481
-	* @param    string $value value to decode
482
-	* @param    string $type XML type to decode
483
-	* @param    string $typens XML type namespace to decode
484
-	* @return	mixed PHP value
485
-	* @access   private
486
-	*/
487
-	function decodeSimple($value, $type, $typens) {
488
-		// TODO: use the namespace!
489
-		if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
490
-			return (string) $value;
491
-		}
492
-		if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
493
-			return (int) $value;
494
-		}
495
-		if ($type == 'float' || $type == 'double' || $type == 'decimal') {
496
-			return (double) $value;
497
-		}
498
-		if ($type == 'boolean') {
499
-			if (strtolower($value) == 'false' || strtolower($value) == 'f') {
500
-				return false;
501
-			}
502
-			return (boolean) $value;
503
-		}
504
-		if ($type == 'base64' || $type == 'base64Binary') {
505
-			$this->debug('Decode base64 value');
506
-			return base64_decode($value);
507
-		}
508
-		// obscure numeric types
509
-		if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
510
-			|| $type == 'nonNegativeInteger' || $type == 'positiveInteger'
511
-			|| $type == 'unsignedInt'
512
-			|| $type == 'unsignedShort' || $type == 'unsignedByte') {
513
-			return (int) $value;
514
-		}
515
-		// bogus: parser treats array with no elements as a simple type
516
-		if ($type == 'array') {
517
-			return array();
518
-		}
519
-		// everything else
520
-		return (string) $value;
521
-	}
478
+    /**
479
+     * decodes simple types into PHP variables
480
+     *
481
+     * @param    string $value value to decode
482
+     * @param    string $type XML type to decode
483
+     * @param    string $typens XML type namespace to decode
484
+     * @return	mixed PHP value
485
+     * @access   private
486
+     */
487
+    function decodeSimple($value, $type, $typens) {
488
+        // TODO: use the namespace!
489
+        if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
490
+            return (string) $value;
491
+        }
492
+        if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
493
+            return (int) $value;
494
+        }
495
+        if ($type == 'float' || $type == 'double' || $type == 'decimal') {
496
+            return (double) $value;
497
+        }
498
+        if ($type == 'boolean') {
499
+            if (strtolower($value) == 'false' || strtolower($value) == 'f') {
500
+                return false;
501
+            }
502
+            return (boolean) $value;
503
+        }
504
+        if ($type == 'base64' || $type == 'base64Binary') {
505
+            $this->debug('Decode base64 value');
506
+            return base64_decode($value);
507
+        }
508
+        // obscure numeric types
509
+        if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
510
+            || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
511
+            || $type == 'unsignedInt'
512
+            || $type == 'unsignedShort' || $type == 'unsignedByte') {
513
+            return (int) $value;
514
+        }
515
+        // bogus: parser treats array with no elements as a simple type
516
+        if ($type == 'array') {
517
+            return array();
518
+        }
519
+        // everything else
520
+        return (string) $value;
521
+    }
522 522
 
523
-	/**
524
-	* builds response structures for compound values (arrays/structs)
525
-	* and scalars
526
-	*
527
-	* @param    integer $pos position in node tree
528
-	* @return	mixed	PHP value
529
-	* @access   private
530
-	*/
531
-	function buildVal($pos){
532
-		if(!isset($this->message[$pos]['type'])){
533
-			$this->message[$pos]['type'] = '';
534
-		}
535
-		$this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
536
-		// if there are children...
537
-		if($this->message[$pos]['children'] != ''){
538
-			$this->debug('in buildVal, there are children');
539
-			$children = explode('|',$this->message[$pos]['children']);
540
-			array_shift($children); // knock off empty
541
-			// md array
542
-			if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
543
-            	$r=0; // rowcount
544
-            	$c=0; // colcount
545
-            	foreach($children as $child_pos){
546
-					$this->debug("in buildVal, got an MD array element: $r, $c");
547
-					$params[$r][] = $this->message[$child_pos]['result'];
548
-				    $c++;
549
-				    if($c == $this->message[$pos]['arrayCols']){
550
-				    	$c = 0;
551
-						$r++;
552
-				    }
523
+    /**
524
+     * builds response structures for compound values (arrays/structs)
525
+     * and scalars
526
+     *
527
+     * @param    integer $pos position in node tree
528
+     * @return	mixed	PHP value
529
+     * @access   private
530
+     */
531
+    function buildVal($pos){
532
+        if(!isset($this->message[$pos]['type'])){
533
+            $this->message[$pos]['type'] = '';
534
+        }
535
+        $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
536
+        // if there are children...
537
+        if($this->message[$pos]['children'] != ''){
538
+            $this->debug('in buildVal, there are children');
539
+            $children = explode('|',$this->message[$pos]['children']);
540
+            array_shift($children); // knock off empty
541
+            // md array
542
+            if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
543
+                $r=0; // rowcount
544
+                $c=0; // colcount
545
+                foreach($children as $child_pos){
546
+                    $this->debug("in buildVal, got an MD array element: $r, $c");
547
+                    $params[$r][] = $this->message[$child_pos]['result'];
548
+                    $c++;
549
+                    if($c == $this->message[$pos]['arrayCols']){
550
+                        $c = 0;
551
+                        $r++;
552
+                    }
553 553
                 }
554 554
             // array
555
-			} elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
555
+            } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
556 556
                 $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
557 557
                 foreach($children as $child_pos){
558
-                	$params[] = &$this->message[$child_pos]['result'];
558
+                    $params[] = &$this->message[$child_pos]['result'];
559 559
                 }
560 560
             // apache Map type: java hashtable
561 561
             } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){
562 562
                 $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']);
563 563
                 foreach($children as $child_pos){
564
-                	$kv = explode("|",$this->message[$child_pos]['children']);
565
-                   	$params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
564
+                    $kv = explode("|",$this->message[$child_pos]['children']);
565
+                        $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
566 566
                 }
567 567
             // generic compound type
568 568
             //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
569
-		    } else {
570
-	    		// Apache Vector type: treat as an array
569
+            } else {
570
+                // Apache Vector type: treat as an array
571 571
                 $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']);
572
-				if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
573
-					$notstruct = 1;
574
-				} else {
575
-					$notstruct = 0;
576
-	            }
577
-            	//
578
-            	foreach($children as $child_pos){
579
-            		if($notstruct){
580
-            			$params[] = &$this->message[$child_pos]['result'];
581
-            		} else {
582
-            			if (isset($params[$this->message[$child_pos]['name']])) {
583
-            				// de-serialize repeated element name into an array
584
-            				if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
585
-            					$params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
586
-            				}
587
-            				$params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
588
-            			} else {
589
-					    	$params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
590
-					    }
591
-                	}
572
+                if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
573
+                    $notstruct = 1;
574
+                } else {
575
+                    $notstruct = 0;
592 576
                 }
593
-			}
594
-			if (isset($this->message[$pos]['xattrs'])) {
577
+                //
578
+                foreach($children as $child_pos){
579
+                    if($notstruct){
580
+                        $params[] = &$this->message[$child_pos]['result'];
581
+                    } else {
582
+                        if (isset($params[$this->message[$child_pos]['name']])) {
583
+                            // de-serialize repeated element name into an array
584
+                            if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
585
+                                $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
586
+                            }
587
+                            $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
588
+                        } else {
589
+                            $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
590
+                        }
591
+                    }
592
+                }
593
+            }
594
+            if (isset($this->message[$pos]['xattrs'])) {
595 595
                 $this->debug('in buildVal, handling attributes');
596
-				foreach ($this->message[$pos]['xattrs'] as $n => $v) {
597
-					$params[$n] = $v;
598
-				}
599
-			}
600
-			// handle simpleContent
601
-			if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
596
+                foreach ($this->message[$pos]['xattrs'] as $n => $v) {
597
+                    $params[$n] = $v;
598
+                }
599
+            }
600
+            // handle simpleContent
601
+            if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
602 602
                 $this->debug('in buildVal, handling simpleContent');
603
-            	if (isset($this->message[$pos]['type'])) {
604
-					$params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
605
-				} else {
606
-					$parent = $this->message[$pos]['parent'];
607
-					if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
608
-						$params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
609
-					} else {
610
-						$params['!'] = $this->message[$pos]['cdata'];
611
-					}
612
-				}
613
-			}
614
-			$ret = is_array($params) ? $params : array();
615
-			$this->debug('in buildVal, return:');
616
-			//$this->appendDebug($this->varDump($ret));
617
-			return $ret;
618
-		} else {
619
-        	$this->debug('in buildVal, no children, building scalar');
620
-			$cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
621
-        	if (isset($this->message[$pos]['type'])) {
622
-				$ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
623
-				$this->debug("in buildVal, return: $ret");
624
-				return $ret;
625
-			}
626
-			$parent = $this->message[$pos]['parent'];
627
-			if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
628
-				$ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
629
-				$this->debug("in buildVal, return: $ret");
630
-				return $ret;
631
-			}
632
-           	$ret = $this->message[$pos]['cdata'];
633
-			$this->debug("in buildVal, return: $ret");
634
-           	return $ret;
635
-		}
636
-	}
603
+                if (isset($this->message[$pos]['type'])) {
604
+                    $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
605
+                } else {
606
+                    $parent = $this->message[$pos]['parent'];
607
+                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
608
+                        $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
609
+                    } else {
610
+                        $params['!'] = $this->message[$pos]['cdata'];
611
+                    }
612
+                }
613
+            }
614
+            $ret = is_array($params) ? $params : array();
615
+            $this->debug('in buildVal, return:');
616
+            //$this->appendDebug($this->varDump($ret));
617
+            return $ret;
618
+        } else {
619
+            $this->debug('in buildVal, no children, building scalar');
620
+            $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
621
+            if (isset($this->message[$pos]['type'])) {
622
+                $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
623
+                $this->debug("in buildVal, return: $ret");
624
+                return $ret;
625
+            }
626
+            $parent = $this->message[$pos]['parent'];
627
+            if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
628
+                $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
629
+                $this->debug("in buildVal, return: $ret");
630
+                return $ret;
631
+            }
632
+                $ret = $this->message[$pos]['cdata'];
633
+            $this->debug("in buildVal, return: $ret");
634
+                return $ret;
635
+        }
636
+    }
637 637
 }
638 638
 
639 639
 /**
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.wsdlcache.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -16,189 +16,189 @@
 block discarded – undo
16 16
 * @access public 
17 17
 */
18 18
 class nusoap_wsdlcache {
19
-	/**
20
-	 *	@var resource
21
-	 *	@access private
22
-	 */
23
-	var $fplock;
24
-	/**
25
-	 *	@var integer
26
-	 *	@access private
27
-	 */
28
-	var $cache_lifetime;
29
-	/**
30
-	 *	@var string
31
-	 *	@access private
32
-	 */
33
-	var $cache_dir;
34
-	/**
35
-	 *	@var string
36
-	 *	@access public
37
-	 */
38
-	var $debug_str = '';
19
+    /**
20
+     *	@var resource
21
+     *	@access private
22
+     */
23
+    var $fplock;
24
+    /**
25
+     *	@var integer
26
+     *	@access private
27
+     */
28
+    var $cache_lifetime;
29
+    /**
30
+     *	@var string
31
+     *	@access private
32
+     */
33
+    var $cache_dir;
34
+    /**
35
+     *	@var string
36
+     *	@access public
37
+     */
38
+    var $debug_str = '';
39 39
 
40
-	/**
41
-	* constructor
42
-	*
43
-	* @param string $cache_dir directory for cache-files
44
-	* @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
45
-	* @access public
46
-	*/
47
-	function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) {
48
-		$this->fplock = array();
49
-		$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
50
-		$this->cache_lifetime = $cache_lifetime;
51
-	}
40
+    /**
41
+     * constructor
42
+     *
43
+     * @param string $cache_dir directory for cache-files
44
+     * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
45
+     * @access public
46
+     */
47
+    function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) {
48
+        $this->fplock = array();
49
+        $this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
50
+        $this->cache_lifetime = $cache_lifetime;
51
+    }
52 52
 
53
-	/**
54
-	* creates the filename used to cache a wsdl instance
55
-	*
56
-	* @param string $wsdl The URL of the wsdl instance
57
-	* @return string The filename used to cache the instance
58
-	* @access private
59
-	*/
60
-	function createFilename($wsdl) {
61
-		return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
62
-	}
53
+    /**
54
+     * creates the filename used to cache a wsdl instance
55
+     *
56
+     * @param string $wsdl The URL of the wsdl instance
57
+     * @return string The filename used to cache the instance
58
+     * @access private
59
+     */
60
+    function createFilename($wsdl) {
61
+        return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
62
+    }
63 63
 
64
-	/**
65
-	* adds debug data to the class level debug string
66
-	*
67
-	* @param    string $string debug data
68
-	* @access   private
69
-	*/
70
-	function debug($string){
71
-		$this->debug_str .= get_class($this).": $string\n";
72
-	}
64
+    /**
65
+     * adds debug data to the class level debug string
66
+     *
67
+     * @param    string $string debug data
68
+     * @access   private
69
+     */
70
+    function debug($string){
71
+        $this->debug_str .= get_class($this).": $string\n";
72
+    }
73 73
 
74
-	/**
75
-	* gets a wsdl instance from the cache
76
-	*
77
-	* @param string $wsdl The URL of the wsdl instance
78
-	* @return object wsdl The cached wsdl instance, null if the instance is not in the cache
79
-	* @access public
80
-	*/
81
-	function get($wsdl) {
82
-		$filename = $this->createFilename($wsdl);
83
-		if ($this->obtainMutex($filename, "r")) {
84
-			// check for expired WSDL that must be removed from the cache
85
- 			if ($this->cache_lifetime > 0) {
86
-				if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
87
-					unlink($filename);
88
-					$this->debug("Expired $wsdl ($filename) from cache");
89
-					$this->releaseMutex($filename);
90
-					return null;
91
-  				}
92
-			}
93
-			// see what there is to return
94
-			if (!file_exists($filename)) {
95
-				$this->debug("$wsdl ($filename) not in cache (1)");
96
-				$this->releaseMutex($filename);
97
-				return null;
98
-			}
99
-			$fp = @fopen($filename, "r");
100
-			if ($fp) {
101
-				$s = implode("", @file($filename));
102
-				fclose($fp);
103
-				$this->debug("Got $wsdl ($filename) from cache");
104
-			} else {
105
-				$s = null;
106
-				$this->debug("$wsdl ($filename) not in cache (2)");
107
-			}
108
-			$this->releaseMutex($filename);
109
-			return (!is_null($s)) ? unserialize($s) : null;
110
-		} else {
111
-			$this->debug("Unable to obtain mutex for $filename in get");
112
-		}
113
-		return null;
114
-	}
74
+    /**
75
+     * gets a wsdl instance from the cache
76
+     *
77
+     * @param string $wsdl The URL of the wsdl instance
78
+     * @return object wsdl The cached wsdl instance, null if the instance is not in the cache
79
+     * @access public
80
+     */
81
+    function get($wsdl) {
82
+        $filename = $this->createFilename($wsdl);
83
+        if ($this->obtainMutex($filename, "r")) {
84
+            // check for expired WSDL that must be removed from the cache
85
+                if ($this->cache_lifetime > 0) {
86
+                if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
87
+                    unlink($filename);
88
+                    $this->debug("Expired $wsdl ($filename) from cache");
89
+                    $this->releaseMutex($filename);
90
+                    return null;
91
+                    }
92
+            }
93
+            // see what there is to return
94
+            if (!file_exists($filename)) {
95
+                $this->debug("$wsdl ($filename) not in cache (1)");
96
+                $this->releaseMutex($filename);
97
+                return null;
98
+            }
99
+            $fp = @fopen($filename, "r");
100
+            if ($fp) {
101
+                $s = implode("", @file($filename));
102
+                fclose($fp);
103
+                $this->debug("Got $wsdl ($filename) from cache");
104
+            } else {
105
+                $s = null;
106
+                $this->debug("$wsdl ($filename) not in cache (2)");
107
+            }
108
+            $this->releaseMutex($filename);
109
+            return (!is_null($s)) ? unserialize($s) : null;
110
+        } else {
111
+            $this->debug("Unable to obtain mutex for $filename in get");
112
+        }
113
+        return null;
114
+    }
115 115
 
116
-	/**
117
-	* obtains the local mutex
118
-	*
119
-	* @param string $filename The Filename of the Cache to lock
120
-	* @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
121
-	* @return boolean Lock successfully obtained ?!
122
-	* @access private
123
-	*/
124
-	function obtainMutex($filename, $mode) {
125
-		if (isset($this->fplock[md5($filename)])) {
126
-			$this->debug("Lock for $filename already exists");
127
-			return false;
128
-		}
129
-		$this->fplock[md5($filename)] = fopen($filename.".lock", "w");
130
-		if ($mode == "r") {
131
-			return flock($this->fplock[md5($filename)], LOCK_SH);
132
-		} else {
133
-			return flock($this->fplock[md5($filename)], LOCK_EX);
134
-		}
135
-	}
116
+    /**
117
+     * obtains the local mutex
118
+     *
119
+     * @param string $filename The Filename of the Cache to lock
120
+     * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
121
+     * @return boolean Lock successfully obtained ?!
122
+     * @access private
123
+     */
124
+    function obtainMutex($filename, $mode) {
125
+        if (isset($this->fplock[md5($filename)])) {
126
+            $this->debug("Lock for $filename already exists");
127
+            return false;
128
+        }
129
+        $this->fplock[md5($filename)] = fopen($filename.".lock", "w");
130
+        if ($mode == "r") {
131
+            return flock($this->fplock[md5($filename)], LOCK_SH);
132
+        } else {
133
+            return flock($this->fplock[md5($filename)], LOCK_EX);
134
+        }
135
+    }
136 136
 
137
-	/**
138
-	* adds a wsdl instance to the cache
139
-	*
140
-	* @param object wsdl $wsdl_instance The wsdl instance to add
141
-	* @return boolean WSDL successfully cached
142
-	* @access public
143
-	*/
144
-	function put($wsdl_instance) {
145
-		$filename = $this->createFilename($wsdl_instance->wsdl);
146
-		$s = serialize($wsdl_instance);
147
-		if ($this->obtainMutex($filename, "w")) {
148
-			$fp = fopen($filename, "w");
149
-			if (! $fp) {
150
-				$this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
151
-				$this->releaseMutex($filename);
152
-				return false;
153
-			}
154
-			fputs($fp, $s);
155
-			fclose($fp);
156
-			$this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
157
-			$this->releaseMutex($filename);
158
-			return true;
159
-		} else {
160
-			$this->debug("Unable to obtain mutex for $filename in put");
161
-		}
162
-		return false;
163
-	}
137
+    /**
138
+     * adds a wsdl instance to the cache
139
+     *
140
+     * @param object wsdl $wsdl_instance The wsdl instance to add
141
+     * @return boolean WSDL successfully cached
142
+     * @access public
143
+     */
144
+    function put($wsdl_instance) {
145
+        $filename = $this->createFilename($wsdl_instance->wsdl);
146
+        $s = serialize($wsdl_instance);
147
+        if ($this->obtainMutex($filename, "w")) {
148
+            $fp = fopen($filename, "w");
149
+            if (! $fp) {
150
+                $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
151
+                $this->releaseMutex($filename);
152
+                return false;
153
+            }
154
+            fputs($fp, $s);
155
+            fclose($fp);
156
+            $this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
157
+            $this->releaseMutex($filename);
158
+            return true;
159
+        } else {
160
+            $this->debug("Unable to obtain mutex for $filename in put");
161
+        }
162
+        return false;
163
+    }
164 164
 
165
-	/**
166
-	* releases the local mutex
167
-	*
168
-	* @param string $filename The Filename of the Cache to lock
169
-	* @return boolean Lock successfully released
170
-	* @access private
171
-	*/
172
-	function releaseMutex($filename) {
173
-		$ret = flock($this->fplock[md5($filename)], LOCK_UN);
174
-		fclose($this->fplock[md5($filename)]);
175
-		unset($this->fplock[md5($filename)]);
176
-		if (! $ret) {
177
-			$this->debug("Not able to release lock for $filename");
178
-		}
179
-		return $ret;
180
-	}
165
+    /**
166
+     * releases the local mutex
167
+     *
168
+     * @param string $filename The Filename of the Cache to lock
169
+     * @return boolean Lock successfully released
170
+     * @access private
171
+     */
172
+    function releaseMutex($filename) {
173
+        $ret = flock($this->fplock[md5($filename)], LOCK_UN);
174
+        fclose($this->fplock[md5($filename)]);
175
+        unset($this->fplock[md5($filename)]);
176
+        if (! $ret) {
177
+            $this->debug("Not able to release lock for $filename");
178
+        }
179
+        return $ret;
180
+    }
181 181
 
182
-	/**
183
-	* removes a wsdl instance from the cache
184
-	*
185
-	* @param string $wsdl The URL of the wsdl instance
186
-	* @return boolean Whether there was an instance to remove
187
-	* @access public
188
-	*/
189
-	function remove($wsdl) {
190
-		$filename = $this->createFilename($wsdl);
191
-		if (!file_exists($filename)) {
192
-			$this->debug("$wsdl ($filename) not in cache to be removed");
193
-			return false;
194
-		}
195
-		// ignore errors obtaining mutex
196
-		$this->obtainMutex($filename, "w");
197
-		$ret = unlink($filename);
198
-		$this->debug("Removed ($ret) $wsdl ($filename) from cache");
199
-		$this->releaseMutex($filename);
200
-		return $ret;
201
-	}
182
+    /**
183
+     * removes a wsdl instance from the cache
184
+     *
185
+     * @param string $wsdl The URL of the wsdl instance
186
+     * @return boolean Whether there was an instance to remove
187
+     * @access public
188
+     */
189
+    function remove($wsdl) {
190
+        $filename = $this->createFilename($wsdl);
191
+        if (!file_exists($filename)) {
192
+            $this->debug("$wsdl ($filename) not in cache to be removed");
193
+            return false;
194
+        }
195
+        // ignore errors obtaining mutex
196
+        $this->obtainMutex($filename, "w");
197
+        $ret = unlink($filename);
198
+        $this->debug("Removed ($ret) $wsdl ($filename) from cache");
199
+        $this->releaseMutex($filename);
200
+        return $ret;
201
+    }
202 202
 }
203 203
 
204 204
 /**
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	* @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
45 45
 	* @access public
46 46
 	*/
47
-	function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) {
47
+	function nusoap_wsdlcache($cache_dir = '.', $cache_lifetime = 0) {
48 48
 		$this->fplock = array();
49 49
 		$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
50 50
 		$this->cache_lifetime = $cache_lifetime;
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	* @access private
59 59
 	*/
60 60
 	function createFilename($wsdl) {
61
-		return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
61
+		return $this->cache_dir.'/wsdlcache-'.md5($wsdl);
62 62
 	}
63 63
 
64 64
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	* @param    string $string debug data
68 68
 	* @access   private
69 69
 	*/
70
-	function debug($string){
70
+	function debug($string) {
71 71
 		$this->debug_str .= get_class($this).": $string\n";
72 72
 	}
73 73
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		$s = serialize($wsdl_instance);
147 147
 		if ($this->obtainMutex($filename, "w")) {
148 148
 			$fp = fopen($filename, "w");
149
-			if (! $fp) {
149
+			if (!$fp) {
150 150
 				$this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
151 151
 				$this->releaseMutex($filename);
152 152
 				return false;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		$ret = flock($this->fplock[md5($filename)], LOCK_UN);
174 174
 		fclose($this->fplock[md5($filename)]);
175 175
 		unset($this->fplock[md5($filename)]);
176
-		if (! $ret) {
176
+		if (!$ret) {
177 177
 			$this->debug("Not able to release lock for $filename");
178 178
 		}
179 179
 		return $ret;
Please login to merge, or discard this patch.
main/inc/lib/add_many_session_to_category_functions.lib.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
      * @assert () !== ''
22 22
      * @assert ('abc','single') !== ''
23 23
      */
24
-    function search_courses($needle,$type)
24
+    function search_courses($needle, $type)
25 25
     {
26 26
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
27 27
 		$xajax_response = new xajaxResponse();
28 28
 		$return = '';
29
-		if(!empty($needle) && !empty($type)) {
29
+		if (!empty($needle) && !empty($type)) {
30 30
 			// xajax send utf8 datas... datas in db can be non-utf8 datas
31 31
 			$charset = api_get_system_encoding();
32 32
 			$needle = api_convert_encoding($needle, $charset, 'utf-8');
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 			$course_list = array();
39 39
 
40 40
 			$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
41
-			while($course = Database :: fetch_array($rs)) {
41
+			while ($course = Database :: fetch_array($rs)) {
42 42
 				$course_list[] = $course['id'];
43
-				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
43
+				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'], ENT_QUOTES).'">'.$course['name'].'</option>';
44 44
 			}
45 45
 			$return .= '</select>';
46
-			$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
46
+			$xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return));
47 47
 		}
48 48
 		$_SESSION['course_list'] = $course_list;
49 49
 		return $xajax_response;
Please login to merge, or discard this patch.
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,29 +25,29 @@
 block discarded – undo
25 25
     function search_courses($needle,$type)
26 26
     {
27 27
         $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
28
-		$xajax_response = new xajaxResponse();
29
-		$return = '';
30
-		if(!empty($needle) && !empty($type)) {
31
-			// xajax send utf8 datas... datas in db can be non-utf8 datas
32
-			$charset = api_get_system_encoding();
33
-			$needle = api_convert_encoding($needle, $charset, 'utf-8');
34
-			$needle = Database::escape_string($needle);
28
+        $xajax_response = new xajaxResponse();
29
+        $return = '';
30
+        if(!empty($needle) && !empty($type)) {
31
+            // xajax send utf8 datas... datas in db can be non-utf8 datas
32
+            $charset = api_get_system_encoding();
33
+            $needle = api_convert_encoding($needle, $charset, 'utf-8');
34
+            $needle = Database::escape_string($needle);
35 35
 
36
-			$sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
36
+            $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id';
37 37
 
38
-			$rs = Database::query($sql);
39
-			$course_list = array();
38
+            $rs = Database::query($sql);
39
+            $course_list = array();
40 40
 
41
-			$return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
42
-			while($course = Database :: fetch_array($rs)) {
43
-				$course_list[] = $course['id'];
44
-				$return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
45
-			}
46
-			$return .= '</select>';
47
-			$xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
48
-		}
49
-		$_SESSION['course_list'] = $course_list;
41
+            $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">';
42
+            while($course = Database :: fetch_array($rs)) {
43
+                $course_list[] = $course['id'];
44
+                $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>';
45
+            }
46
+            $return .= '</select>';
47
+            $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return));
48
+        }
49
+        $_SESSION['course_list'] = $course_list;
50 50
         
51
-		return $xajax_response;
52
-	}
51
+        return $xajax_response;
52
+    }
53 53
 }
Please login to merge, or discard this patch.
main/inc/lib/statistics.lib.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -666,7 +666,7 @@
 block discarded – undo
666 666
         $res = Database::query($sql);
667 667
         $count1 = Database::fetch_object($res);
668 668
         $sql = "SELECT COUNT(*) AS n FROM $user_table as u $table ".
669
-               "WHERE LENGTH(picture_uri) > 0 $url_condition2";
669
+                "WHERE LENGTH(picture_uri) > 0 $url_condition2";
670 670
         $res = Database::query($sql);
671 671
         $count2 = Database::fetch_object($res);
672 672
         // #users without picture
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
         $course_user_table = Database:: get_main_table(TABLE_MAIN_COURSE_USER);
105 105
         $course_table = Database:: get_main_table(TABLE_MAIN_COURSE);
106 106
         $user_table = Database:: get_main_table(TABLE_MAIN_USER);
107
-        $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
107
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
108 108
         $current_url_id = api_get_current_access_url_id();
109
-        $active_filter = $onlyActive?' AND active=1':'';
110
-        $status_filter = isset($status)?' AND status = '.intval($status):'';
109
+        $active_filter = $onlyActive ? ' AND active=1' : '';
110
+        $status_filter = isset($status) ? ' AND status = '.intval($status) : '';
111 111
 
112 112
         if (api_is_multiple_url_enabled()) {
113 113
             $sql = "SELECT COUNT(DISTINCT(u.user_id)) AS number
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                     FROM $user_table
132 132
                     WHERE 1=1 $status_filter $active_filter";
133 133
             if (isset($categoryCode)) {
134
-                $status_filter = isset($status)?' AND status = '.intval($status):'';
134
+                $status_filter = isset($status) ? ' AND status = '.intval($status) : '';
135 135
                 $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number
136 136
                         FROM $course_user_table cu, $course_table c
137 137
                         WHERE
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     public static function countSessions()
157 157
     {
158 158
         $session_table = Database :: get_main_table(TABLE_MAIN_SESSION);
159
-        $access_url_rel_session_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
159
+        $access_url_rel_session_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
160 160
         if (api_is_multiple_url_enabled()) {
161 161
             $current_url_id = api_get_current_access_url_id();
162 162
             $sql = "SELECT COUNT(id) AS number
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
     public static function getNumberOfActivities()
180 180
     {
181 181
         // Database table definitions
182
-        $track_e_default  = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
182
+        $track_e_default = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
183 183
         $table_user = Database::get_main_table(TABLE_MAIN_USER);
184
-        $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
184
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
185 185
         $current_url_id = api_get_current_access_url_id();
186 186
         if (api_is_multiple_url_enabled()) {
187 187
             $sql = "SELECT count(default_id) AS total_number_of_items
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         $from = intval($from);
230 230
         $numberOfItems = intval($numberOfItems);
231 231
 
232
-        if (!in_array($direction, array('ASC','DESC'))) {
232
+        if (!in_array($direction, array('ASC', 'DESC'))) {
233 233
             $direction = 'DESC';
234 234
         }
235 235
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         $sql .= " LIMIT $from,$numberOfItems ";
281 281
 
282 282
         $res = Database::query($sql);
283
-        $activities = array ();
283
+        $activities = array();
284 284
         while ($row = Database::fetch_row($res)) {
285 285
 
286 286
             if (strpos($row[1], '_object') === false && strpos($row[1], '_array') === false) {
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
         $sql = "SELECT code, name FROM $categoryTable
349 349
                 ORDER BY tree_pos";
350 350
         $res = Database::query($sql);
351
-        $categories = array ();
351
+        $categories = array();
352 352
         while ($category = Database::fetch_object($res)) {
353 353
             $categories[$category->code] = $category->name;
354 354
         }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
             $data_max = ($data_max < $value ? $value : $data_max);
370 370
         }
371 371
         reset($data);
372
-        $result = array ();
372
+        $result = array();
373 373
         $delta = $max / $data_max;
374 374
         foreach ($data as $index => $value) {
375 375
             $result[$index] = (int) round($value * $delta);
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
             } else {
404 404
                 $number_label = Statistics::makeSizeString($number);
405 405
             }
406
-            $percentage = ($total>0?number_format(100*$number/$total, 1, ',', '.'):'0');
406
+            $percentage = ($total > 0 ? number_format(100 * $number / $total, 1, ',', '.') : '0');
407 407
 
408
-            echo '<tr class="row_'.($i%2 == 0 ? 'odd' : 'even').'">
408
+            echo '<tr class="row_'.($i % 2 == 0 ? 'odd' : 'even').'">
409 409
                     <td width="150">'.$subtitle.'</td>
410 410
                     <td width="550">'.Display::bar_progress($percentage, false).'</td>
411 411
                     <td align="right">'.$number_label.'</td>';
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 echo '<td align="right"> '.$percentage.'%</td>';
414 414
             }
415 415
             echo '</tr>';
416
-            $i ++;
416
+            $i++;
417 417
         }
418 418
         if ($showTotal) {
419 419
             if (!$isFileSize) {
@@ -433,17 +433,17 @@  discard block
 block discarded – undo
433 433
     public static function printLoginStats($type)
434 434
     {
435 435
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
436
-        $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
436
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
437 437
         $current_url_id = api_get_current_access_url_id();
438 438
 
439 439
         $table_url = null;
440 440
         $where_url = null;
441 441
         $now = api_get_utc_datetime();
442
-        $where_url_last = ' WHERE login_date > DATE_SUB("' . $now . '",INTERVAL 1 %s)';
442
+        $where_url_last = ' WHERE login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)';
443 443
         if (api_is_multiple_url_enabled()) {
444 444
             $table_url = ", $access_url_rel_user_table";
445 445
             $where_url = " WHERE login_user_id=user_id AND access_url_id='".$current_url_id."'";
446
-            $where_url_last = ' AND login_date > DATE_SUB("' . $now . '",INTERVAL 1 %s)';
446
+            $where_url_last = ' AND login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)';
447 447
         }
448 448
 
449 449
         $period = get_lang('PeriodMonth');
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
                         GROUP BY stat_date 
463 463
                         ORDER BY stat_date ";
464 464
                 $sql_last_x = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins 
465
-                               FROM ".$table.$table_url.$where_url.sprintf($where_url_last,'DAY')." 
465
+                               FROM ".$table.$table_url.$where_url.sprintf($where_url_last, 'DAY')." 
466 466
                                GROUP BY stat_date 
467 467
                                ORDER BY stat_date ";
468 468
                 break;
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
                         GROUP BY stat_date 
475 475
                         ORDER BY DATE_FORMAT( login_date, '%w' ) ";
476 476
                 $sql_last_x = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date, count( login_id ) AS number_of_logins 
477
-                               FROM ".$table.$table_url.$where_url.sprintf($where_url_last,'WEEK')." 
477
+                               FROM ".$table.$table_url.$where_url.sprintf($where_url_last, 'WEEK')." 
478 478
                                GROUP BY stat_date 
479 479
                                ORDER BY DATE_FORMAT( login_date, '%w' ) ";
480 480
                 break;
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
     {
519 519
         $totalLogin = array();
520 520
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
521
-        $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
521
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
522 522
         $current_url_id = api_get_current_access_url_id();
523 523
         if (api_is_multiple_url_enabled()) {
524 524
             $table_url = ", $access_url_rel_user_table";
525 525
             $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'";
526 526
         } else {
527 527
             $table_url = '';
528
-            $where_url='';
528
+            $where_url = '';
529 529
         }
530 530
         $now = api_get_utc_datetime();
531 531
         $field = 'login_user_id';
@@ -557,14 +557,14 @@  discard block
 block discarded – undo
557 557
     {
558 558
         $totalLogin = [];
559 559
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
560
-        $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
560
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
561 561
         $current_url_id = api_get_current_access_url_id();
562 562
         if (api_is_multiple_url_enabled()) {
563 563
             $table_url = ", $access_url_rel_user_table";
564 564
             $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'";
565 565
         } else {
566 566
             $table_url = '';
567
-            $where_url='';
567
+            $where_url = '';
568 568
         }
569 569
         $now = api_get_utc_datetime();
570 570
         $field = 'login_user_id';
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
         $sql = "SELECT count($field) AS number, date(login_date) as login_date FROM $table $table_url WHERE DATE_ADD(login_date, INTERVAL 15 DAY) >= '$now' $where_url GROUP BY date(login_date)";
575 575
 
576 576
         $res = Database::query($sql);
577
-        while ($row = Database::fetch_array($res,'ASSOC')){
577
+        while ($row = Database::fetch_array($res, 'ASSOC')) {
578 578
             $totalLogin[$row['login_date']] = $row['number'];
579 579
         }
580 580
 
@@ -668,13 +668,13 @@  discard block
 block discarded – undo
668 668
     public static function printUserPicturesStats()
669 669
     {
670 670
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
671
-        $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
671
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
672 672
         $current_url_id = api_get_current_access_url_id();
673 673
         $url_condition = null;
674 674
         $url_condition2 = null;
675 675
         $table = null;
676 676
         if (api_is_multiple_url_enabled()) {
677
-            $url_condition =  ", $access_url_rel_user_table as url WHERE url.user_id=u.user_id AND access_url_id='".$current_url_id."'";
677
+            $url_condition = ", $access_url_rel_user_table as url WHERE url.user_id=u.user_id AND access_url_id='".$current_url_id."'";
678 678
             $url_condition2 = " AND url.user_id=u.user_id AND access_url_id='".$current_url_id."'";
679 679
             $table = ", $access_url_rel_user_table as url ";
680 680
         }
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
             'width=200px',
707 707
             false
708 708
         );
709
-        $renderer =& $form->defaultRenderer();
709
+        $renderer = & $form->defaultRenderer();
710 710
         $renderer->setCustomElementTemplate('<span>{element}</span> ');
711 711
         $form->addElement('hidden', 'report', 'activities');
712 712
         $form->addElement('hidden', 'activities_direction', 'DESC');
@@ -756,10 +756,10 @@  discard block
 block discarded – undo
756 756
         $columns[1] = 'access_date';
757 757
         $sql_order[SORT_ASC] = 'ASC';
758 758
         $sql_order[SORT_DESC] = 'DESC';
759
-        $per_page = isset($_GET['per_page'])?intval($_GET['per_page']) : 10;
760
-        $page_nr = isset($_GET['page_nr'])?intval($_GET['page_nr']) : 1;
761
-        $column = isset($_GET['column'])?intval($_GET['column']) : 0;
762
-        $date_diff = isset($_GET['date_diff'])?intval($_GET['date_diff']) : 60;
759
+        $per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10;
760
+        $page_nr = isset($_GET['page_nr']) ? intval($_GET['page_nr']) : 1;
761
+        $column = isset($_GET['column']) ? intval($_GET['column']) : 0;
762
+        $date_diff = isset($_GET['date_diff']) ? intval($_GET['date_diff']) : 60;
763 763
         $direction = isset($_GET['direction']) ? $_GET['direction'] : SORT_ASC;
764 764
 
765 765
         if (!in_array($direction, array(SORT_ASC, SORT_DESC))) {
@@ -787,25 +787,25 @@  discard block
 block discarded – undo
787 787
                         access_url_id='".$current_url_id."'
788 788
                    GROUP BY c_id
789 789
                    HAVING c_id <> ''
790
-                   AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff;
790
+                   AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ".$date_diff;
791 791
         } else {
792 792
             $sql = "SELECT * FROM $table
793 793
                    GROUP BY c_id
794 794
                    HAVING c_id <> ''
795
-                   AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff;
795
+                   AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ".$date_diff;
796 796
         }
797 797
         $sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction];
798
-        $from = ($page_nr -1) * $per_page;
798
+        $from = ($page_nr - 1) * $per_page;
799 799
         $sql .= ' LIMIT '.$from.','.$per_page;
800 800
 
801 801
         echo '<p>'.get_lang('LastAccess').' &gt;= '.$date_diff.' '.get_lang('Days').'</p>';
802 802
         $res = Database::query($sql);
803 803
         if (Database::num_rows($res) > 0) {
804
-            $courses = array ();
804
+            $courses = array();
805 805
             while ($obj = Database::fetch_object($res)) {
806 806
                 $courseInfo = api_get_course_info_by_id($obj->c_id);
807
-                $course = array ();
808
-                $course[]= '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>';
807
+                $course = array();
808
+                $course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>';
809 809
                 // Allow sort by date hiding the numerical date
810 810
                 $course[] = '<span style="display:none;">'.$obj->access_date.'</span>'.api_convert_and_format_date($obj->access_date);
811 811
                 $courses[] = $course;
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
     {
882 882
         $user_friend_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
883 883
         $user_table = Database::get_main_table(TABLE_MAIN_USER);
884
-        $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
884
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
885 885
         $current_url_id = api_get_current_access_url_id();
886 886
 
887 887
         if (api_is_multiple_url_enabled()) {
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
     {
914 914
         $totalLogin = array();
915 915
         $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
916
-        $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
916
+        $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
917 917
         $current_url_id = api_get_current_access_url_id();
918 918
         $total = self::countUsers();
919 919
         if (api_is_multiple_url_enabled()) {
@@ -921,14 +921,14 @@  discard block
 block discarded – undo
921 921
             $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'";
922 922
         } else {
923 923
             $table_url = '';
924
-            $where_url='';
924
+            $where_url = '';
925 925
         }
926 926
         $now = api_get_utc_datetime();
927
-        $sql[get_lang('ThisDay')]    =
927
+        $sql[get_lang('ThisDay')] =
928 928
             "SELECT count(distinct(login_user_id)) AS number ".
929 929
             " FROM $table $table_url ".
930 930
             " WHERE DATE_ADD(login_date, INTERVAL 1 DAY) >= '$now' $where_url";
931
-        $sql[get_lang('Last7days')]  =
931
+        $sql[get_lang('Last7days')] =
932 932
             "SELECT count(distinct(login_user_id)) AS number ".
933 933
             " FROM $table $table_url ".
934 934
             " WHERE DATE_ADD(login_date, INTERVAL 7 DAY) >= '$now' $where_url";
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
             "SELECT count(distinct(login_user_id)) AS number ".
941 941
             " FROM $table $table_url ".
942 942
             " WHERE DATE_ADD(login_date, INTERVAL 6 MONTH) >= '$now' $where_url";
943
-        $sql[get_lang('NeverConnected')]      =
943
+        $sql[get_lang('NeverConnected')] =
944 944
             "SELECT count(distinct(login_user_id)) AS number ".
945 945
             " FROM $table $table_url WHERE 1=1 $where_url";
946 946
         foreach ($sql as $index => $query) {
Please login to merge, or discard this patch.
main/inc/lib/opengraph/OpenGraph.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 
19 19
 class OpenGraph implements Iterator
20 20
 {
21
-  /**
22
-   * There are base schema's based on type, this is just
23
-   * a map so that the schema can be obtained
24
-   *
25
-   */
21
+    /**
22
+     * There are base schema's based on type, this is just
23
+     * a map so that the schema can be obtained
24
+     *
25
+     */
26 26
     public static $TYPES = array(
27 27
         'activity' => array('activity', 'sport'),
28 28
         'business' => array('bar', 'company', 'cafe', 'hotel', 'restaurant'),
@@ -34,19 +34,19 @@  discard block
 block discarded – undo
34 34
         'website' => array('blog', 'website'),
35 35
     );
36 36
 
37
-  /**
38
-   * Holds all the Open Graph values we've parsed from a page
39
-   *
40
-   */
37
+    /**
38
+     * Holds all the Open Graph values we've parsed from a page
39
+     *
40
+     */
41 41
     private $_values = array();
42 42
 
43
-  /**
44
-   * Fetches a URI and parses it for Open Graph data, returns
45
-   * false on error.
46
-   *
47
-   * @param $URI    URI to page to parse for Open Graph data
48
-   * @return OpenGraph
49
-   */
43
+    /**
44
+     * Fetches a URI and parses it for Open Graph data, returns
45
+     * false on error.
46
+     *
47
+     * @param $URI    URI to page to parse for Open Graph data
48
+     * @return OpenGraph
49
+     */
50 50
     static public function fetch($URI) {
51 51
         $curl = curl_init($URI);
52 52
 
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
         }
70 70
     }
71 71
 
72
-  /**
73
-   * Parses HTML and extracts Open Graph data, this assumes
74
-   * the document is at least well formed.
75
-   *
76
-   * @param $HTML    HTML to parse
77
-   * @return OpenGraph
78
-   */
72
+    /**
73
+     * Parses HTML and extracts Open Graph data, this assumes
74
+     * the document is at least well formed.
75
+     *
76
+     * @param $HTML    HTML to parse
77
+     * @return OpenGraph
78
+     */
79 79
     static private function _parse($HTML) {
80 80
         $old_libxml_error = libxml_use_internal_errors(true);
81 81
 
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
         return $page;
141 141
     }
142 142
 
143
-  /**
144
-   * Helper method to access attributes directly
145
-   * Example:
146
-   * $graph->title
147
-   *
148
-   * @param $key    Key to fetch from the lookup
149
-   */
143
+    /**
144
+     * Helper method to access attributes directly
145
+     * Example:
146
+     * $graph->title
147
+     *
148
+     * @param $key    Key to fetch from the lookup
149
+     */
150 150
     public function __get($key) {
151 151
         if (array_key_exists($key, $this->_values)) {
152 152
             return $this->_values[$key];
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
         }
162 162
     }
163 163
 
164
-  /**
165
-   * Return all the keys found on the page
166
-   *
167
-   * @return array
168
-   */
164
+    /**
165
+     * Return all the keys found on the page
166
+     *
167
+     * @return array
168
+     */
169 169
     public function keys() {
170 170
         return array_keys($this->_values);
171 171
     }
172 172
 
173
-  /**
174
-   * Helper method to check an attribute exists
175
-   *
176
-   * @param $key
177
-   */
173
+    /**
174
+     * Helper method to check an attribute exists
175
+     *
176
+     * @param $key
177
+     */
178 178
     public function __isset($key) {
179 179
         return array_key_exists($key, $this->_values);
180 180
     }
181 181
 
182
-  /**
183
-   * Will return true if the page has location data embedded
184
-   *
185
-   * @return boolean Check if the page has location data
186
-   */
182
+    /**
183
+     * Will return true if the page has location data embedded
184
+     *
185
+     * @return boolean Check if the page has location data
186
+     */
187 187
     public function hasLocation() {
188 188
         if (array_key_exists('latitude', $this->_values) && array_key_exists('longitude', $this->_values)) {
189 189
             return true;
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
         return $valid_address;
198 198
     }
199 199
 
200
-  /**
201
-   * Iterator code
202
-   */
200
+    /**
201
+     * Iterator code
202
+     */
203 203
     private $_position = 0;
204 204
     public function rewind() { reset($this->_values); $this->_position = 0; }
205 205
     public function current() { return current($this->_values); }
Please login to merge, or discard this patch.
main/inc/lib/events_dispatcher.class.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,9 +18,11 @@
 block discarded – undo
18 18
 
19 19
         foreach ($event_config[$event_name]["actions"] as $func) {
20 20
             $execute = true;
21
-            if (!function_exists($func)) // if the function doesn't exist, we log
21
+            if (!function_exists($func)) {
22
+                // if the function doesn't exist, we log
22 23
             {
23 24
                 error_log("EventsDispatcher warning : ".$func." does not exist.");
25
+            }
24 26
                 $execute = false;
25 27
             }
26 28
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
     }
39 39
 
40 40
     /**
41
-     * @return bool
41
+     * @return false|null
42 42
      */
43 43
     public function create_user_folder()
44 44
     {
Please login to merge, or discard this patch.
main/inc/lib/javascript/chat/video.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
 $idUserLocal = api_get_user_id();
35 35
 $userLocal = api_get_user_info($idUserLocal, true);
36 36
 $htmlHeadXtra[] = '<script type="text/javascript" src="'
37
-    . api_get_path(WEB_PATH) . 'web/assets/SimpleWebRTC/latest.js'
38
-    . '"></script>' . "\n";
37
+    . api_get_path(WEB_PATH).'web/assets/SimpleWebRTC/latest.js'
38
+    . '"></script>'."\n";
39 39
 
40 40
 $template = new Template();
41 41
 $template->assign('room_name', $chatVideo->getRoomName());
Please login to merge, or discard this patch.
main/inc/lib/internationalization.lib.php 4 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1710,8 +1710,7 @@
 block discarded – undo
1710 1710
             }
1711 1711
         }
1712 1712
         return false;
1713
-    }
1714
-    elseif (is_array($encoding2)) {
1713
+    } elseif (is_array($encoding2)) {
1715 1714
         foreach ($encoding2 as $encoding) {
1716 1715
             if (api_equal_encodings($encoding1, $encoding, $strict)) {
1717 1716
                 return true;
Please login to merge, or discard this patch.
Doc Comments   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -422,6 +422,7 @@  discard block
 block discarded – undo
422 422
  * If null, the timezone will be determined based on user preference,
423 423
  * or timezone chosen by the admin for the platform.
424 424
  * @param string The timezone to be converted from. If null, UTC will be assumed.
425
+ * @param string $to_timezone
425 426
  * @return string The converted time formatted as Y-m-d H:i:s
426 427
  *
427 428
  * @author Guillaume Viguier <[email protected]>
@@ -670,6 +671,7 @@  discard block
 block discarded – undo
670 671
  * @param mixed The time to be converted
671 672
  * @param mixed Format to be used (TIME_NO_SEC_FORMAT, DATE_FORMAT_SHORT, DATE_FORMAT_LONG, DATE_TIME_FORMAT_LONG)
672 673
  * @param string Timezone to be converted from. If null, UTC will be assumed.
674
+ * @param string $from_timezone
673 675
  * @return string Converted and localized date
674 676
  *
675 677
  * @author Guillaume Viguier <[email protected]>
@@ -739,7 +741,7 @@  discard block
 block discarded – undo
739 741
  * @param int|string $format (optional)	The person name format. It may be a pattern-string (for example '%t %l, %f' or '%T %F %L', ...) or some of the constants PERSON_NAME_COMMON_CONVENTION (default), PERSON_NAME_WESTERN_ORDER, PERSON_NAME_EASTERN_ORDER, PERSON_NAME_LIBRARY_ORDER.
740 742
  * @param string $language (optional)	The language id. If it is omitted, the current interface language is assumed. This parameter has meaning with the format PERSON_NAME_COMMON_CONVENTION only.
741 743
  * @param string $encoding (optional)	The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
742
- * @return bool							The result is sort of full name of the person.
744
+ * @return string							The result is sort of full name of the person.
743 745
  * Sample results:
744 746
  * Peter Ustinoff or Dr. Peter Ustinoff     - the Western order
745 747
  * Ustinoff Peter or Dr. Ustinoff Peter     - the Eastern order
@@ -1058,8 +1060,8 @@  discard block
 block discarded – undo
1058 1060
 
1059 1061
 /**
1060 1062
  * This function returns a string or an array with all occurrences of search in subject (ignoring case) replaced with the given replace value.
1061
- * @param mixed $search					String or array of strings to be found.
1062
- * @param mixed $replace				String or array of strings used for replacement.
1063
+ * @param string $search					String or array of strings to be found.
1064
+ * @param string $replace				String or array of strings used for replacement.
1063 1065
  * @param mixed $subject				String or array of strings being searched.
1064 1066
  * @param int $count (optional)			The number of matched and replaced needles will be returned in count, which is passed by reference.
1065 1067
  * @param string $encoding (optional)	The used internally by this function character encoding.
@@ -1122,10 +1124,10 @@  discard block
 block discarded – undo
1122 1124
 /**
1123 1125
  * Finds first occurrence of a string within another, case insensitive.
1124 1126
  * @param string $haystack					The string from which to get the first occurrence.
1125
- * @param mixed $needle						The string to be found.
1127
+ * @param string $needle						The string to be found.
1126 1128
  * @param bool $before_needle (optional)	Determines which portion of $haystack this function returns. The default value is FALSE.
1127 1129
  * @param string $encoding (optional)		The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
1128
- * @return mixed							Returns the portion of $haystack, or FALSE if $needle is not found.
1130
+ * @return false|string							Returns the portion of $haystack, or FALSE if $needle is not found.
1129 1131
  * Notes:
1130 1132
  * If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character.
1131 1133
  * If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence of $needle.
@@ -1181,7 +1183,7 @@  discard block
 block discarded – undo
1181 1183
  * @param mixed $needle						The string which first character is to be found.
1182 1184
  * @param bool $before_needle (optional)	Determines which portion of $haystack this function returns. The default value is FALSE.
1183 1185
  * @param string $encoding (optional)		The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
1184
- * @return mixed							Returns the portion of $haystack, or FALSE if the first character from $needle is not found.
1186
+ * @return false|string							Returns the portion of $haystack, or FALSE if the first character from $needle is not found.
1185 1187
  * Notes:
1186 1188
  * If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character.
1187 1189
  * If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence.
@@ -1248,7 +1250,7 @@  discard block
 block discarded – undo
1248 1250
  * @param mixed $needle						The string to be found.
1249 1251
  * @param bool $before_needle (optional)	Determines which portion of $haystack this function returns. The default value is FALSE.
1250 1252
  * @param string $encoding (optional)		The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
1251
- * @return mixed							Returns the portion of $haystack, or FALSE if $needle is not found.
1253
+ * @return false|string							Returns the portion of $haystack, or FALSE if $needle is not found.
1252 1254
  * Notes:
1253 1255
  * If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character.
1254 1256
  * If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence of $needle.
@@ -1429,8 +1431,8 @@  discard block
 block discarded – undo
1429 1431
 
1430 1432
 /**
1431 1433
  * Performs a regular expression search and replace, UTF-8 aware when it is applicable.
1432
- * @param string|array $pattern			The pattern to search for. It can be either a string or an array with strings.
1433
- * @param string|array $replacement		The string or an array with strings to replace.
1434
+ * @param string $pattern			The pattern to search for. It can be either a string or an array with strings.
1435
+ * @param string $replacement		The string or an array with strings to replace.
1434 1436
  * @param string|array $subject			The string or an array with strings to search and replace.
1435 1437
  * @param int $limit					The maximum possible replacements for each pattern in each subject string. Defaults to -1 (no limit).
1436 1438
  * @param int &$count					If specified, this variable will be filled with the number of replacements done.
@@ -1578,7 +1580,7 @@  discard block
 block discarded – undo
1578 1580
 
1579 1581
 /**
1580 1582
  * This function checks whether two $encoding are equal (same, equvalent).
1581
- * @param string|array $encoding1		The first encoding
1583
+ * @param string $encoding1		The first encoding
1582 1584
  * @param string|array $encoding2		The second encoding
1583 1585
  * @param bool $strict					When this parameter is TRUE the comparison ignores aliases of encodings.
1584 1586
  * When the parameter is FALSE, aliases are taken into account.
@@ -1682,6 +1684,7 @@  discard block
 block discarded – undo
1682 1684
 /**
1683 1685
  * Checks a string for UTF-8 validity.
1684 1686
  *
1687
+ * @param string $string
1685 1688
  */
1686 1689
 function api_is_valid_utf8(&$string)
1687 1690
 {
@@ -1824,7 +1827,7 @@  discard block
 block discarded – undo
1824 1827
 /**
1825 1828
  * Replaces non-valid formats for person names with the default (English) format.
1826 1829
  * @param string $format	The input format to be verified.
1827
- * @return bool				Returns the same format if is is valid, otherwise returns a valid English format.
1830
+ * @return string				Returns the same format if is is valid, otherwise returns a valid English format.
1828 1831
  */
1829 1832
 function _api_validate_person_name_format($format) {
1830 1833
     if (empty($format) || stripos($format, '%f') === false || stripos($format, '%l') === false) {
@@ -1951,6 +1954,9 @@  discard block
 block discarded – undo
1951 1954
 
1952 1955
 // This function checks whether the function _api_convert_encoding() (the php-
1953 1956
 // implementation) is able to convert from/to a given encoding.
1957
+/**
1958
+ * @param string $encoding
1959
+ */
1954 1960
 function _api_convert_encoding_supports($encoding) {
1955 1961
     static $supports = array();
1956 1962
     if (!isset($supports[$encoding])) {
@@ -1961,7 +1967,7 @@  discard block
 block discarded – undo
1961 1967
 
1962 1968
 /**
1963 1969
  * Given a date object, return a human or ISO format, with or without h:m:s
1964
- * @param object $date The Date object
1970
+ * @param DateTime $date The Date object
1965 1971
  * @param bool $showTime Whether to show the time and date (true) or only the date (false)
1966 1972
  * @param bool $humanForm Whether to show day-month-year (true) or year-month-day (false)
1967 1973
  * @return string Formatted date
Please login to merge, or discard this patch.
Indentation   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
     }
100 100
 
101 101
     if (!isset($used_lang_vars)) {
102
-    	$used_lang_vars = array();
102
+        $used_lang_vars = array();
103 103
     }
104 104
 
105 105
     // Caching results from some API functions, for speed.
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     static $text_direction = array();
289 289
 
290 290
     if (empty($language)) {
291
-    	$language = api_get_interface_language();
291
+        $language = api_get_interface_language();
292 292
     }
293 293
     if (!isset($text_direction[$language])) {
294 294
         $text_direction[$language] = in_array(api_purify_language_id($language),
@@ -1703,7 +1703,6 @@  discard block
 block discarded – undo
1703 1703
 
1704 1704
 /**
1705 1705
  * Return true a date is valid
1706
-
1707 1706
  * @param string $date example: 2014-06-30 13:05:05
1708 1707
  * @param string $format example: "Y-m-d H:i:s"
1709 1708
  *
@@ -1973,15 +1972,15 @@  discard block
 block discarded – undo
1973 1972
 {
1974 1973
     if ($showTime) {
1975 1974
         if ($humanForm) {
1976
-           return $date->format('j M Y H:i:s');
1975
+            return $date->format('j M Y H:i:s');
1977 1976
         } else {
1978
-           return $date->format('Y-m-d H:i:s');
1977
+            return $date->format('Y-m-d H:i:s');
1979 1978
         }
1980 1979
     } else {
1981 1980
         if ($humanForm) {
1982
-           return $date->format('j M Y');
1981
+            return $date->format('j M Y');
1983 1982
         } else {
1984
-           return $date->format('Y-m-d');
1983
+            return $date->format('Y-m-d');
1985 1984
         }
1986 1985
     }
1987 1986
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -628,10 +628,10 @@  discard block
 block discarded – undo
628 628
         $date_format = str_replace(
629 629
             array('%A', '%a', '%B', '%b'),
630 630
             array(
631
-                $translated['days_long'][(int)strftime('%w', $time)],
632
-                $translated['days_short'][(int)strftime('%w', $time)],
633
-                $translated['months_long'][(int)strftime('%m', $time) - 1],
634
-                $translated['months_short'][(int)strftime('%m', $time) - 1],
631
+                $translated['days_long'][(int) strftime('%w', $time)],
632
+                $translated['days_short'][(int) strftime('%w', $time)],
633
+                $translated['months_long'][(int) strftime('%m', $time) - 1],
634
+                $translated['months_short'][(int) strftime('%m', $time) - 1],
635 635
             ),
636 636
             $date_format
637 637
         );
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 
659 659
 function date_to_str_ago($date, $timeZone = 'UTC')
660 660
 {
661
-    if ($date === '0000-00-00 00:00:00')  {
661
+    if ($date === '0000-00-00 00:00:00') {
662 662
 
663 663
         return '';
664 664
     }
@@ -1573,7 +1573,7 @@  discard block
 block discarded – undo
1573 1573
  * @return string					Returns the encoding identificator modified in suitable for comparison way.
1574 1574
  */
1575 1575
 function api_refine_encoding_id($encoding) {
1576
-    if (is_array($encoding)){
1576
+    if (is_array($encoding)) {
1577 1577
         return array_map('api_refine_encoding_id', $encoding);
1578 1578
     }
1579 1579
     return strtoupper(str_replace('_', '-', $encoding));
Please login to merge, or discard this patch.