@@ -8,34 +8,34 @@ discard block |
||
8 | 8 | include("xmlrpc.inc"); |
9 | 9 | |
10 | 10 | // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off |
11 | - if(!isset($HTTP_POST_VARS) && isset($_POST)) |
|
11 | + if (!isset($HTTP_POST_VARS) && isset($_POST)) |
|
12 | 12 | { |
13 | 13 | $HTTP_POST_VARS = $_POST; |
14 | 14 | } |
15 | 15 | |
16 | - if(isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"]!="") |
|
16 | + if (isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"] != "") |
|
17 | 17 | { |
18 | - $stateno=(integer)$HTTP_POST_VARS["stateno"]; |
|
19 | - $f=new xmlrpcmsg('examples.getStateName', |
|
18 | + $stateno = (integer) $HTTP_POST_VARS["stateno"]; |
|
19 | + $f = new xmlrpcmsg('examples.getStateName', |
|
20 | 20 | array(php_xmlrpc_encode($stateno)) |
21 | 21 | ); |
22 | - print "<pre>Sending the following request:\n\n" . htmlentities($f->serialize()) . "\n\nDebug info of server data follows...\n\n"; |
|
23 | - $c=new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); |
|
22 | + print "<pre>Sending the following request:\n\n".htmlentities($f->serialize())."\n\nDebug info of server data follows...\n\n"; |
|
23 | + $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); |
|
24 | 24 | $c->setDebug(1); |
25 | - $r=&$c->send($f); |
|
26 | - if(!$r->faultCode()) |
|
25 | + $r = &$c->send($f); |
|
26 | + if (!$r->faultCode()) |
|
27 | 27 | { |
28 | - $v=$r->value(); |
|
29 | - print "</pre><br/>State number " . $stateno . " is " |
|
30 | - . htmlspecialchars($v->scalarval()) . "<br/>"; |
|
28 | + $v = $r->value(); |
|
29 | + print "</pre><br/>State number ".$stateno." is " |
|
30 | + . htmlspecialchars($v->scalarval())."<br/>"; |
|
31 | 31 | // print "<HR>I got this value back<BR><PRE>" . |
32 | 32 | // htmlentities($r->serialize()). "</PRE><HR>\n"; |
33 | 33 | } |
34 | 34 | else |
35 | 35 | { |
36 | 36 | print "An error occurred: "; |
37 | - print "Code: " . htmlspecialchars($r->faultCode()) |
|
38 | - . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>"; |
|
37 | + print "Code: ".htmlspecialchars($r->faultCode()) |
|
38 | + . " Reason: '".htmlspecialchars($r->faultString())."'</pre><br/>"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | else |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | print "<form action=\"client.php\" method=\"POST\"> |
47 | -<input name=\"stateno\" value=\"" . $stateno . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
|
47 | +<input name=\"stateno\" value=\"" . $stateno."\"><input type=\"submit\" value=\"go\" name=\"submit\"></form> |
|
48 | 48 | <p>Enter a state number to query its name</p>"; |
49 | 49 | |
50 | 50 | ?> |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function xmlrpccall_simple() |
33 | 33 | { |
34 | - if(func_num_args() < 2) |
|
34 | + if (func_num_args()<2) |
|
35 | 35 | { |
36 | 36 | // Incorrect |
37 | 37 | return false; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | $xmlrpcval_array = array(); |
50 | - foreach($varargs as $parameter) |
|
50 | + foreach ($varargs as $parameter) |
|
51 | 51 | { |
52 | 52 | $xmlrpcval_array[] = php_xmlrpc_encode($parameter); |
53 | 53 | } |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | $HTTP_POST_VARS = $_POST; |
22 | 22 | |
23 | 23 | if (isset($HTTP_POST_VARS["server"]) && $HTTP_POST_VARS["server"]) { |
24 | - if ($HTTP_POST_VARS["server"]=="Userland") { |
|
25 | - $XP="/RPC2"; $XS="206.204.24.2"; |
|
24 | + if ($HTTP_POST_VARS["server"] == "Userland") { |
|
25 | + $XP = "/RPC2"; $XS = "206.204.24.2"; |
|
26 | 26 | } else { |
27 | - $XP="/xmlrpc/server.php"; $XS="pingu.heddley.com"; |
|
27 | + $XP = "/xmlrpc/server.php"; $XS = "pingu.heddley.com"; |
|
28 | 28 | } |
29 | - $f=new xmlrpcmsg('mail.send'); |
|
29 | + $f = new xmlrpcmsg('mail.send'); |
|
30 | 30 | $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailto"])); |
31 | 31 | $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailsub"])); |
32 | 32 | $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailmsg"])); |
@@ -35,17 +35,17 @@ discard block |
||
35 | 35 | $f->addParam(new xmlrpcval($HTTP_POST_VARS["mailbcc"])); |
36 | 36 | $f->addParam(new xmlrpcval("text/plain")); |
37 | 37 | |
38 | - $c=new xmlrpc_client($XP, $XS, 80); |
|
38 | + $c = new xmlrpc_client($XP, $XS, 80); |
|
39 | 39 | $c->setDebug(2); |
40 | - $r=&$c->send($f); |
|
40 | + $r = &$c->send($f); |
|
41 | 41 | if (!$r->faultCode()) { |
42 | 42 | print "Mail sent OK<br/>\n"; |
43 | 43 | } else { |
44 | 44 | print "<fonr color=\"red\">"; |
45 | 45 | print "Mail send failed<br/>\n"; |
46 | 46 | print "Fault: "; |
47 | - print "Code: " . htmlspecialchars($r->faultCode()) . |
|
48 | - " Reason: '" . htmlspecialchars($r->faultString()) . "'<br/>"; |
|
47 | + print "Code: ".htmlspecialchars($r->faultCode()). |
|
48 | + " Reason: '".htmlspecialchars($r->faultString())."'<br/>"; |
|
49 | 49 | print "</font><br/>"; |
50 | 50 | } |
51 | 51 | } |
@@ -11,18 +11,18 @@ |
||
11 | 11 | $c->setCredentials("username", "password"); |
12 | 12 | $c->setDebug(2); |
13 | 13 | $r = $c->send($f); |
14 | - if(!$r->faultCode()) |
|
14 | + if (!$r->faultCode()) |
|
15 | 15 | { |
16 | 16 | $v = $r->value(); |
17 | - print "I received:" . htmlspecialchars($v->scalarval()) . "<br/>"; |
|
18 | - print "<hr/>I got this value back<br/>pre>" . |
|
19 | - htmlentities($r->serialize()). "</pre>\n"; |
|
17 | + print "I received:".htmlspecialchars($v->scalarval())."<br/>"; |
|
18 | + print "<hr/>I got this value back<br/>pre>". |
|
19 | + htmlentities($r->serialize())."</pre>\n"; |
|
20 | 20 | } |
21 | 21 | else |
22 | 22 | { |
23 | 23 | print "An error occurred: "; |
24 | - print "Code: " . htmlspecialchars($r->faultCode()) |
|
25 | - . " Reason: '" . ($r->faultString()) . "'<br/>"; |
|
24 | + print "Code: ".htmlspecialchars($r->faultCode()) |
|
25 | + . " Reason: '".($r->faultString())."'<br/>"; |
|
26 | 26 | } |
27 | 27 | ?> |
28 | 28 | </body> |
@@ -1,1 +1,1 @@ |
||
1 | -<html> <head><title>xmlrpc</title></head> <body> <h1>Introspect demo</h1> <h2>Query server for available methods and their description</h2> <h3>The code demonstrates usage of multicall and introspection methods</h3> <?php include("xmlrpc.inc"); function display_error($r) { print "An error occurred: "; print "Code: " . $r->faultCode() . " Reason: '" .$r->faultString()."'<br/>"; } // 'new style' client constuctor $c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php"); print "<h3>methods available at http://" . $c->server . $c->path . "</h3>\n"; $m = new xmlrpcmsg('system.listMethods'); $r =& $c->send($m); if($r->faultCode()) { display_error($r); } else { $v=$r->value(); for($i=0; $i<$v->arraysize(); $i++) { $mname=$v->arraymem($i); print "<h4>" . $mname->scalarval() . "</h4>\n"; // build messages first, add params later $m1 = new xmlrpcmsg('system.methodHelp'); $m2 = new xmlrpcmsg('system.methodSignature'); $val = new xmlrpcval($mname->scalarval(), "string"); $m1->addParam($val); $m2->addParam($val); // send multiple messages in one pass. // If server does not support multicall, client will fall back to 2 separate calls $ms = array($m1, $m2); $rs =& $c->send($ms); if($rs[0]->faultCode()) { display_error($rs[0]); } else { $val=$rs[0]->value(); $txt=$val->scalarval(); if($txt != "") { print "<h4>Documentation</h4><p>${txt}</p>\n"; } else { print "<p>No documentation available.</p>\n"; } } if($rs[1]->faultCode()) { display_error($rs[1]); } else { print "<h4>Signature</h4><p>\n"; $val = $rs[1]->value(); if($val->kindOf()=="array") { for($j=0; $j<$val->arraysize(); $j++) { $x = $val->arraymem($j); $ret = $x->arraymem(0); print "<code>" . $ret->scalarval() . " " . $mname->scalarval() . "("; if($x->arraysize()>1) { for($k=1; $k<$x->arraysize(); $k++) { $y = $x->arraymem($k); print $y->scalarval(); if($k < $x->arraysize()-1) { print ", "; } } } print ")</code><br/>\n"; } } else { print "Signature unknown\n"; } print "</p>\n"; } } } ?> </body> </html> |
|
2 | 1 | \ No newline at end of file |
2 | +<html> <head><title>xmlrpc</title></head> <body> <h1>Introspect demo</h1> <h2>Query server for available methods and their description</h2> <h3>The code demonstrates usage of multicall and introspection methods</h3> <?php include("xmlrpc.inc"); function display_error($r) { print "An error occurred: "; print "Code: ".$r->faultCode()." Reason: '".$r->faultString()."'<br/>"; } // 'new style' client constuctor $c = new xmlrpc_client("http://phpxmlrpc.sourceforge.net/server.php"); print "<h3>methods available at http://".$c->server.$c->path."</h3>\n"; $m = new xmlrpcmsg('system.listMethods'); $r = & $c->send($m); if ($r->faultCode()) { display_error($r); } else { $v = $r->value(); for ($i = 0; $i<$v->arraysize(); $i++) { $mname = $v->arraymem($i); print "<h4>".$mname->scalarval()."</h4>\n"; // build messages first, add params later $m1 = new xmlrpcmsg('system.methodHelp'); $m2 = new xmlrpcmsg('system.methodSignature'); $val = new xmlrpcval($mname->scalarval(), "string"); $m1->addParam($val); $m2->addParam($val); // send multiple messages in one pass. // If server does not support multicall, client will fall back to 2 separate calls $ms = array($m1, $m2); $rs = & $c->send($ms); if ($rs[0]->faultCode()) { display_error($rs[0]); } else { $val = $rs[0]->value(); $txt = $val->scalarval(); if ($txt != "") { print "<h4>Documentation</h4><p>${txt}</p>\n"; } else { print "<p>No documentation available.</p>\n"; } } if ($rs[1]->faultCode()) { display_error($rs[1]); } else { print "<h4>Signature</h4><p>\n"; $val = $rs[1]->value(); if ($val->kindOf() == "array") { for ($j = 0; $j<$val->arraysize(); $j++) { $x = $val->arraymem($j); $ret = $x->arraymem(0); print "<code>".$ret->scalarval()." ".$mname->scalarval()."("; if ($x->arraysize()>1) { for ($k = 1; $k<$x->arraysize(); $k++) { $y = $x->arraymem($k); print $y->scalarval(); if ($k<$x->arraysize()-1) { print ", "; } } } print ")</code><br/>\n"; } } else { print "Signature unknown\n"; } print "</p>\n"; } } } ?> </body> </html> |
|
3 | 3 | \ No newline at end of file |
@@ -1,1 +1,1 @@ |
||
1 | -<html> <head><title>xmlrpc</title></head> <body> <h1>Which toolkit demo</h1> <h2>Query server for toolkit information</h2> <h3>The code demonstrates usage of the php_xmlrpc_decode function</h3> <?php include("xmlrpc.inc"); $f = new xmlrpcmsg('interopEchoTests.whichToolkit', array()); $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); $r = $c->send($f); if(!$r->faultCode()) { $v = php_xmlrpc_decode($r->value()); print "<pre>"; print "name: " . htmlspecialchars($v["toolkitName"]) . "\n"; print "version: " . htmlspecialchars($v["toolkitVersion"]) . "\n"; print "docs: " . htmlspecialchars($v["toolkitDocsUrl"]) . "\n"; print "os: " . htmlspecialchars($v["toolkitOperatingSystem"]) . "\n"; print "</pre>"; } else { print "An error occurred: "; print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'\n"; } ?> </body> </html> |
|
2 | 1 | \ No newline at end of file |
2 | +<html> <head><title>xmlrpc</title></head> <body> <h1>Which toolkit demo</h1> <h2>Query server for toolkit information</h2> <h3>The code demonstrates usage of the php_xmlrpc_decode function</h3> <?php include("xmlrpc.inc"); $f = new xmlrpcmsg('interopEchoTests.whichToolkit', array()); $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80); $r = $c->send($f); if (!$r->faultCode()) { $v = php_xmlrpc_decode($r->value()); print "<pre>"; print "name: ".htmlspecialchars($v["toolkitName"])."\n"; print "version: ".htmlspecialchars($v["toolkitVersion"])."\n"; print "docs: ".htmlspecialchars($v["toolkitDocsUrl"])."\n"; print "os: ".htmlspecialchars($v["toolkitOperatingSystem"])."\n"; print "</pre>"; } else { print "An error occurred: "; print "Code: ".htmlspecialchars($r->faultCode())." Reason: '".htmlspecialchars($r->faultString())."'\n"; } ?> </body> </html> |
|
3 | 3 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $content = file_get_contents($file); |
15 | 15 | $last = 0; |
16 | 16 | $out = ''; |
17 | - while(($start = strpos($content, $starttag, $last)) !== false) |
|
17 | + while (($start = strpos($content, $starttag, $last)) !== false) |
|
18 | 18 | { |
19 | 19 | $end = strpos($content, $endtag, $start); |
20 | 20 | $code = substr($content, $start+strlen($starttag), $end-$start-strlen($starttag)); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $code = highlight_string('<?php '.$code, true); |
27 | 27 | $code = str_replace('<span style="color: #0000BB"><?php <br />', '<span style="color: #0000BB">', $code); |
28 | 28 | //echo($code); |
29 | - $out = $out . substr($content, $last, $start+strlen($starttag)-$last) . $code . $endtag; |
|
29 | + $out = $out.substr($content, $last, $start+strlen($starttag)-$last).$code.$endtag; |
|
30 | 30 | $last = $end+strlen($endtag); |
31 | 31 | } |
32 | 32 | $out .= substr($content, $last, strlen($content)); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $dir = $argv[1]; |
37 | 37 | |
38 | 38 | $files = scandir($dir); |
39 | -foreach($files as $file) |
|
39 | +foreach ($files as $file) |
|
40 | 40 | { |
41 | 41 | if (substr($file, -5, 5) == '.html') |
42 | 42 | { |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | function php_2_xmlrpc_type($phptype) |
29 | 29 | { |
30 | - switch(strtolower($phptype)) |
|
30 | + switch (strtolower($phptype)) |
|
31 | 31 | { |
32 | 32 | case 'string': |
33 | 33 | return $GLOBALS['xmlrpcString']; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | case 'resource': |
50 | 50 | return ''; |
51 | 51 | default: |
52 | - if(class_exists($phptype)) |
|
52 | + if (class_exists($phptype)) |
|
53 | 53 | { |
54 | 54 | return $GLOBALS['xmlrpcStruct']; |
55 | 55 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | function xmlrpc_2_php_type($xmlrpctype) |
70 | 70 | { |
71 | - switch(strtolower($xmlrpctype)) |
|
71 | + switch (strtolower($xmlrpctype)) |
|
72 | 72 | { |
73 | 73 | case 'base64': |
74 | 74 | case 'datetime.iso8601': |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | * @todo if $newfuncname is empty, we could use create_user_func instead of eval, as it is possibly faster |
141 | 141 | * @todo add a verbatim_object_copy parameter to allow avoiding the same obj instance? |
142 | 142 | */ |
143 | - function wrap_php_function($funcname, $newfuncname='', $extra_options=array()) |
|
143 | + function wrap_php_function($funcname, $newfuncname = '', $extra_options = array()) |
|
144 | 144 | { |
145 | 145 | $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; |
146 | 146 | $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; |
147 | - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; |
|
148 | - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; |
|
147 | + $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool) $extra_options['encode_php_objs'] : false; |
|
148 | + $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool) $extra_options['decode_php_objs'] : false; |
|
149 | 149 | $catch_warnings = isset($extra_options['suppress_warnings']) && $extra_options['suppress_warnings'] ? '@' : ''; |
150 | 150 | |
151 | 151 | $exists = false; |
@@ -153,20 +153,20 @@ discard block |
||
153 | 153 | { |
154 | 154 | $funcname = explode('::', $funcname); |
155 | 155 | } |
156 | - if(is_array($funcname)) |
|
156 | + if (is_array($funcname)) |
|
157 | 157 | { |
158 | - if(count($funcname) < 2 || (!is_string($funcname[0]) && !is_object($funcname[0]))) |
|
158 | + if (count($funcname)<2 || (!is_string($funcname[0]) && !is_object($funcname[0]))) |
|
159 | 159 | { |
160 | 160 | error_log('XML-RPC: syntax for function to be wrapped is wrong'); |
161 | 161 | return false; |
162 | 162 | } |
163 | - if(is_string($funcname[0])) |
|
163 | + if (is_string($funcname[0])) |
|
164 | 164 | { |
165 | 165 | $plainfuncname = implode('::', $funcname); |
166 | 166 | } |
167 | - elseif(is_object($funcname[0])) |
|
167 | + elseif (is_object($funcname[0])) |
|
168 | 168 | { |
169 | - $plainfuncname = get_class($funcname[0]) . '->' . $funcname[1]; |
|
169 | + $plainfuncname = get_class($funcname[0]).'->'.$funcname[1]; |
|
170 | 170 | } |
171 | 171 | $exists = method_exists($funcname[0], $funcname[1]); |
172 | 172 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $exists = function_exists($funcname); |
177 | 177 | } |
178 | 178 | |
179 | - if(!$exists) |
|
179 | + if (!$exists) |
|
180 | 180 | { |
181 | 181 | error_log('XML-RPC: function to be wrapped is not defined: '.$plainfuncname); |
182 | 182 | return false; |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | else |
185 | 185 | { |
186 | 186 | // determine name of new php function |
187 | - if($newfuncname == '') |
|
187 | + if ($newfuncname == '') |
|
188 | 188 | { |
189 | - if(is_array($funcname)) |
|
189 | + if (is_array($funcname)) |
|
190 | 190 | { |
191 | - if(is_string($funcname[0])) |
|
191 | + if (is_string($funcname[0])) |
|
192 | 192 | $xmlrpcfuncname = "{$prefix}_".implode('_', $funcname); |
193 | 193 | else |
194 | - $xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]) . '_' . $funcname[1]; |
|
194 | + $xmlrpcfuncname = "{$prefix}_".get_class($funcname[0]).'_'.$funcname[1]; |
|
195 | 195 | } |
196 | 196 | else |
197 | 197 | { |
@@ -202,36 +202,36 @@ discard block |
||
202 | 202 | { |
203 | 203 | $xmlrpcfuncname = $newfuncname; |
204 | 204 | } |
205 | - while($buildit && function_exists($xmlrpcfuncname)) |
|
205 | + while ($buildit && function_exists($xmlrpcfuncname)) |
|
206 | 206 | { |
207 | 207 | $xmlrpcfuncname .= 'x'; |
208 | 208 | } |
209 | 209 | |
210 | 210 | // start to introspect PHP code |
211 | - if(is_array($funcname)) |
|
211 | + if (is_array($funcname)) |
|
212 | 212 | { |
213 | 213 | $func = new ReflectionMethod($funcname[0], $funcname[1]); |
214 | - if($func->isPrivate()) |
|
214 | + if ($func->isPrivate()) |
|
215 | 215 | { |
216 | 216 | error_log('XML-RPC: method to be wrapped is private: '.$plainfuncname); |
217 | 217 | return false; |
218 | 218 | } |
219 | - if($func->isProtected()) |
|
219 | + if ($func->isProtected()) |
|
220 | 220 | { |
221 | 221 | error_log('XML-RPC: method to be wrapped is protected: '.$plainfuncname); |
222 | 222 | return false; |
223 | 223 | } |
224 | - if($func->isConstructor()) |
|
224 | + if ($func->isConstructor()) |
|
225 | 225 | { |
226 | 226 | error_log('XML-RPC: method to be wrapped is the constructor: '.$plainfuncname); |
227 | 227 | return false; |
228 | 228 | } |
229 | - if($func->isDestructor()) |
|
229 | + if ($func->isDestructor()) |
|
230 | 230 | { |
231 | 231 | error_log('XML-RPC: method to be wrapped is the destructor: '.$plainfuncname); |
232 | 232 | return false; |
233 | 233 | } |
234 | - if($func->isAbstract()) |
|
234 | + if ($func->isAbstract()) |
|
235 | 235 | { |
236 | 236 | error_log('XML-RPC: method to be wrapped is abstract: '.$plainfuncname); |
237 | 237 | return false; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | { |
243 | 243 | $func = new ReflectionFunction($funcname); |
244 | 244 | } |
245 | - if($func->isInternal()) |
|
245 | + if ($func->isInternal()) |
|
246 | 246 | { |
247 | 247 | // Note: from PHP 5.1.0 onward, we will possibly be able to use invokeargs |
248 | 248 | // instead of getparameters to fully reflect internal php functions ? |
@@ -262,27 +262,27 @@ discard block |
||
262 | 262 | $paramDocs = array(); |
263 | 263 | |
264 | 264 | $docs = $func->getDocComment(); |
265 | - if($docs != '') |
|
265 | + if ($docs != '') |
|
266 | 266 | { |
267 | 267 | $docs = explode("\n", $docs); |
268 | 268 | $i = 0; |
269 | - foreach($docs as $doc) |
|
269 | + foreach ($docs as $doc) |
|
270 | 270 | { |
271 | 271 | $doc = trim($doc, " \r\t/*"); |
272 | - if(strlen($doc) && strpos($doc, '@') !== 0 && !$i) |
|
272 | + if (strlen($doc) && strpos($doc, '@') !== 0 && !$i) |
|
273 | 273 | { |
274 | - if($desc) |
|
274 | + if ($desc) |
|
275 | 275 | { |
276 | 276 | $desc .= "\n"; |
277 | 277 | } |
278 | 278 | $desc .= $doc; |
279 | 279 | } |
280 | - elseif(strpos($doc, '@param') === 0) |
|
280 | + elseif (strpos($doc, '@param') === 0) |
|
281 | 281 | { |
282 | 282 | // syntax: @param type [$name] desc |
283 | - if(preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches)) |
|
283 | + if (preg_match('/@param\s+(\S+)(\s+\$\S+)?\s+(.+)/', $doc, $matches)) |
|
284 | 284 | { |
285 | - if(strpos($matches[1], '|')) |
|
285 | + if (strpos($matches[1], '|')) |
|
286 | 286 | { |
287 | 287 | //$paramDocs[$i]['type'] = explode('|', $matches[1]); |
288 | 288 | $paramDocs[$i]['type'] = 'mixed'; |
@@ -296,14 +296,14 @@ discard block |
||
296 | 296 | } |
297 | 297 | $i++; |
298 | 298 | } |
299 | - elseif(strpos($doc, '@return') === 0) |
|
299 | + elseif (strpos($doc, '@return') === 0) |
|
300 | 300 | { |
301 | 301 | // syntax: @return type desc |
302 | 302 | //$returns = preg_split('/\s+/', $doc); |
303 | - if(preg_match('/@return\s+(\S+)\s+(.+)/', $doc, $matches)) |
|
303 | + if (preg_match('/@return\s+(\S+)\s+(.+)/', $doc, $matches)) |
|
304 | 304 | { |
305 | 305 | $returns = php_2_xmlrpc_type($matches[1]); |
306 | - if(isset($matches[2])) |
|
306 | + if (isset($matches[2])) |
|
307 | 307 | { |
308 | 308 | $returnsDocs = $matches[2]; |
309 | 309 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | // execute introspection of actual function prototype |
316 | 316 | $params = array(); |
317 | 317 | $i = 0; |
318 | - foreach($func->getParameters() as $paramobj) |
|
318 | + foreach ($func->getParameters() as $paramobj) |
|
319 | 319 | { |
320 | 320 | $params[$i] = array(); |
321 | 321 | $params[$i]['name'] = '$'.$paramobj->getName(); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $parsvariations = array(); |
331 | 331 | $pars = array(); |
332 | 332 | $pnum = count($params); |
333 | - foreach($params as $param) |
|
333 | + foreach ($params as $param) |
|
334 | 334 | { |
335 | 335 | if (isset($paramDocs[$i]['name']) && $paramDocs[$i]['name'] && strtolower($paramDocs[$i]['name']) != strtolower($param['name'])) |
336 | 336 | { |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | $paramDocs[$i]['type'] = 'mixed'; |
339 | 339 | } |
340 | 340 | |
341 | - if($param['isoptional']) |
|
341 | + if ($param['isoptional']) |
|
342 | 342 | { |
343 | 343 | // this particular parameter is optional. save as valid previous list of parameters |
344 | 344 | $innercode .= "if (\$paramcount > $i) {\n"; |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | |
357 | 357 | $pars[] = "\$p$i"; |
358 | 358 | $i++; |
359 | - if($param['isoptional']) |
|
359 | + if ($param['isoptional']) |
|
360 | 360 | { |
361 | 361 | $innercode .= "}\n"; |
362 | 362 | } |
363 | - if($i == $pnum) |
|
363 | + if ($i == $pnum) |
|
364 | 364 | { |
365 | 365 | // last allowed parameters combination |
366 | 366 | $parsvariations[] = $pars; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | |
370 | 370 | $sigs = array(); |
371 | 371 | $psigs = array(); |
372 | - if(count($parsvariations) == 0) |
|
372 | + if (count($parsvariations) == 0) |
|
373 | 373 | { |
374 | 374 | // only known good synopsis = no parameters |
375 | 375 | $parsvariations[] = array(); |
@@ -380,24 +380,24 @@ discard block |
||
380 | 380 | $minpars = count($parsvariations[0]); |
381 | 381 | } |
382 | 382 | |
383 | - if($minpars) |
|
383 | + if ($minpars) |
|
384 | 384 | { |
385 | 385 | // add to code the check for min params number |
386 | 386 | // NB: this check needs to be done BEFORE decoding param values |
387 | - $innercode = "\$paramcount = \$msg->getNumParams();\n" . |
|
388 | - "if (\$paramcount < $minpars) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}');\n" . $innercode; |
|
387 | + $innercode = "\$paramcount = \$msg->getNumParams();\n". |
|
388 | + "if (\$paramcount < $minpars) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}');\n".$innercode; |
|
389 | 389 | } |
390 | 390 | else |
391 | 391 | { |
392 | - $innercode = "\$paramcount = \$msg->getNumParams();\n" . $innercode; |
|
392 | + $innercode = "\$paramcount = \$msg->getNumParams();\n".$innercode; |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | $innercode .= "\$np = false;\n"; |
396 | 396 | // since there are no closures in php, if we are given an object instance, |
397 | 397 | // we store a pointer to it in a global var... |
398 | - if ( is_array($funcname) && is_object($funcname[0]) ) |
|
398 | + if (is_array($funcname) && is_object($funcname[0])) |
|
399 | 399 | { |
400 | - $GLOBALS['xmlrpcWPFObjHolder'][$xmlrpcfuncname] =& $funcname[0]; |
|
400 | + $GLOBALS['xmlrpcWPFObjHolder'][$xmlrpcfuncname] = & $funcname[0]; |
|
401 | 401 | $innercode .= "\$obj =& \$GLOBALS['xmlrpcWPFObjHolder']['$xmlrpcfuncname'];\n"; |
402 | 402 | $realfuncname = '$obj->'.$funcname[1]; |
403 | 403 | } |
@@ -405,13 +405,13 @@ discard block |
||
405 | 405 | { |
406 | 406 | $realfuncname = $plainfuncname; |
407 | 407 | } |
408 | - foreach($parsvariations as $pars) |
|
408 | + foreach ($parsvariations as $pars) |
|
409 | 409 | { |
410 | - $innercode .= "if (\$paramcount == " . count($pars) . ") \$retval = {$catch_warnings}$realfuncname(" . implode(',', $pars) . "); else\n"; |
|
410 | + $innercode .= "if (\$paramcount == ".count($pars).") \$retval = {$catch_warnings}$realfuncname(".implode(',', $pars)."); else\n"; |
|
411 | 411 | // build a 'generic' signature (only use an appropriate return type) |
412 | 412 | $sig = array($returns); |
413 | 413 | $psig = array($returnsDocs); |
414 | - for($i=0; $i < count($pars); $i++) |
|
414 | + for ($i = 0; $i<count($pars); $i++) |
|
415 | 415 | { |
416 | 416 | if (isset($paramDocs[$i]['type'])) |
417 | 417 | { |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | $innercode .= "if (\$np) return new {$prefix}resp(0, {$GLOBALS['xmlrpcerr']['incorrect_params']}, '{$GLOBALS['xmlrpcstr']['incorrect_params']}'); else {\n"; |
431 | 431 | //$innercode .= "if (\$_xmlrpcs_error_occurred) return new xmlrpcresp(0, $GLOBALS['xmlrpcerr']user, \$_xmlrpcs_error_occurred); else\n"; |
432 | 432 | $innercode .= "if (is_a(\$retval, '{$prefix}resp')) return \$retval; else\n"; |
433 | - if($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64']) |
|
433 | + if ($returns == $GLOBALS['xmlrpcDateTime'] || $returns == $GLOBALS['xmlrpcBase64']) |
|
434 | 434 | { |
435 | 435 | $innercode .= "return new {$prefix}resp(new {$prefix}val(\$retval, '$returns'));"; |
436 | 436 | } |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | // shall we exclude functions returning by ref? |
445 | 445 | // if($func->returnsReference()) |
446 | 446 | // return false; |
447 | - $code = "function $xmlrpcfuncname(\$msg) {\n" . $innercode . "}\n}"; |
|
447 | + $code = "function $xmlrpcfuncname(\$msg) {\n".$innercode."}\n}"; |
|
448 | 448 | //print_r($code); |
449 | 449 | if ($buildit) |
450 | 450 | { |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | // alternative |
454 | 454 | //$xmlrpcfuncname = create_function('$m', $innercode); |
455 | 455 | |
456 | - if(!$allOK) |
|
456 | + if (!$allOK) |
|
457 | 457 | { |
458 | 458 | error_log('XML-RPC: could not create function '.$xmlrpcfuncname.' to wrap php function '.$plainfuncname); |
459 | 459 | return false; |
@@ -481,26 +481,26 @@ discard block |
||
481 | 481 | * @todo get_class_methods will return both static and non-static methods. |
482 | 482 | * we have to differentiate the action, depending on whether we received a class name or object |
483 | 483 | */ |
484 | - function wrap_php_class($classname, $extra_options=array()) |
|
484 | + function wrap_php_class($classname, $extra_options = array()) |
|
485 | 485 | { |
486 | 486 | $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : ''; |
487 | 487 | $methodtype = isset($extra_options['method_type']) ? $extra_options['method_type'] : 'auto'; |
488 | 488 | |
489 | 489 | $result = array(); |
490 | 490 | $mlist = get_class_methods($classname); |
491 | - foreach($mlist as $mname) |
|
491 | + foreach ($mlist as $mname) |
|
492 | 492 | { |
493 | 493 | if ($methodfilter == '' || preg_match($methodfilter, $mname)) |
494 | 494 | { |
495 | 495 | // echo $mlist."\n"; |
496 | 496 | $func = new ReflectionMethod($classname, $mname); |
497 | - if(!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract()) |
|
497 | + if (!$func->isPrivate() && !$func->isProtected() && !$func->isConstructor() && !$func->isDestructor() && !$func->isAbstract()) |
|
498 | 498 | { |
499 | - if(($func->isStatic && ($methodtype == 'all' || $methodtype == 'static' || ($methodtype == 'auto' && is_string($classname)))) || |
|
499 | + if (($func->isStatic && ($methodtype == 'all' || $methodtype == 'static' || ($methodtype == 'auto' && is_string($classname)))) || |
|
500 | 500 | (!$func->isStatic && ($methodtype == 'all' || $methodtype == 'nonstatic' || ($methodtype == 'auto' && is_object($classname))))) |
501 | 501 | { |
502 | 502 | $methodwrap = wrap_php_function(array($classname, $mname), '', $extra_options); |
503 | - if ( $methodwrap ) |
|
503 | + if ($methodwrap) |
|
504 | 504 | { |
505 | 505 | $result[$methodwrap['function']] = $methodwrap['function']; |
506 | 506 | } |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | * bool debug set it to 1 or 2 to see debug results of querying server for method synopsis |
549 | 549 | * @return string the name of the generated php function (or false) - OR AN ARRAY... |
550 | 550 | */ |
551 | - function wrap_xmlrpc_method($client, $methodname, $extra_options=0, $timeout=0, $protocol='', $newfuncname='') |
|
551 | + function wrap_xmlrpc_method($client, $methodname, $extra_options = 0, $timeout = 0, $protocol = '', $newfuncname = '') |
|
552 | 552 | { |
553 | 553 | // mind numbing: let caller use sane calling convention (as per javadoc, 3 params), |
554 | 554 | // OR the 2.0 calling convention (no options) - we really love backward compat, don't we? |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | } |
560 | 560 | else |
561 | 561 | { |
562 | - $signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0; |
|
563 | - $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0; |
|
562 | + $signum = isset($extra_options['signum']) ? (int) $extra_options['signum'] : 0; |
|
563 | + $timeout = isset($extra_options['timeout']) ? (int) $extra_options['timeout'] : 0; |
|
564 | 564 | $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : ''; |
565 | 565 | $newfuncname = isset($extra_options['new_function_name']) ? $extra_options['new_function_name'] : ''; |
566 | 566 | } |
@@ -568,10 +568,10 @@ discard block |
||
568 | 568 | //$verbatim_client_copy = in_array('simple_client_copy', $extra_options) ? 1 : |
569 | 569 | // in_array('build_class_code', $extra_options) ? 2 : 0; |
570 | 570 | |
571 | - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; |
|
572 | - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; |
|
571 | + $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool) $extra_options['encode_php_objs'] : false; |
|
572 | + $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool) $extra_options['decode_php_objs'] : false; |
|
573 | 573 | // it seems like the meaning of 'simple_client_copy' here is swapped wrt client_copy_mode later on... |
574 | - $simple_client_copy = isset($extra_options['simple_client_copy']) ? (int)($extra_options['simple_client_copy']) : 0; |
|
574 | + $simple_client_copy = isset($extra_options['simple_client_copy']) ? (int) ($extra_options['simple_client_copy']) : 0; |
|
575 | 575 | $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; |
576 | 576 | $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; |
577 | 577 | if (isset($extra_options['return_on_fault'])) |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | $msg = new $msgclass('system.methodSignature'); |
594 | 594 | $msg->addparam(new $valclass($methodname)); |
595 | 595 | $client->setDebug($debug); |
596 | - $response =& $client->send($msg, $timeout, $protocol); |
|
597 | - if($response->faultCode()) |
|
596 | + $response = & $client->send($msg, $timeout, $protocol); |
|
597 | + if ($response->faultCode()) |
|
598 | 598 | { |
599 | 599 | error_log('XML-RPC: could not retrieve method signature from remote server for method '.$methodname); |
600 | 600 | return false; |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | { |
607 | 607 | $msig = $decodefunc($msig); |
608 | 608 | } |
609 | - if(!is_array($msig) || count($msig) <= $signum) |
|
609 | + if (!is_array($msig) || count($msig)<=$signum) |
|
610 | 610 | { |
611 | 611 | error_log('XML-RPC: could not retrieve method signature nr.'.$signum.' from remote server for method '.$methodname); |
612 | 612 | return false; |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | else |
615 | 615 | { |
616 | 616 | // pick a suitable name for the new function, avoiding collisions |
617 | - if($newfuncname != '') |
|
617 | + if ($newfuncname != '') |
|
618 | 618 | { |
619 | 619 | $xmlrpcfuncname = $newfuncname; |
620 | 620 | } |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | $xmlrpcfuncname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), |
626 | 626 | array('_', ''), $methodname); |
627 | 627 | } |
628 | - while($buildit && function_exists($xmlrpcfuncname)) |
|
628 | + while ($buildit && function_exists($xmlrpcfuncname)) |
|
629 | 629 | { |
630 | 630 | $xmlrpcfuncname .= 'x'; |
631 | 631 | } |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | $mdesc = ''; |
635 | 635 | // if in 'offline' mode, get method description too. |
636 | 636 | // in online mode, favour speed of operation |
637 | - if(!$buildit) |
|
637 | + if (!$buildit) |
|
638 | 638 | { |
639 | 639 | $msg = new $msgclass('system.methodHelp'); |
640 | 640 | $msg->addparam(new $valclass($methodname)); |
641 | - $response =& $client->send($msg, $timeout, $protocol); |
|
641 | + $response = & $client->send($msg, $timeout, $protocol); |
|
642 | 642 | if (!$response->faultCode()) |
643 | 643 | { |
644 | 644 | $mdesc = $response->value(); |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | eval($results['source'].'$allOK=1;'); |
662 | 662 | // alternative |
663 | 663 | //$xmlrpcfuncname = create_function('$m', $innercode); |
664 | - if($allOK) |
|
664 | + if ($allOK) |
|
665 | 665 | { |
666 | 666 | return $xmlrpcfuncname; |
667 | 667 | } |
@@ -688,15 +688,15 @@ discard block |
||
688 | 688 | * @param array $extra_options list of options for wrapped code |
689 | 689 | * @return mixed false on error, the name of the created class if all ok or an array with code, class name and comments (if the appropriatevoption is set in extra_options) |
690 | 690 | */ |
691 | - function wrap_xmlrpc_server($client, $extra_options=array()) |
|
691 | + function wrap_xmlrpc_server($client, $extra_options = array()) |
|
692 | 692 | { |
693 | 693 | $methodfilter = isset($extra_options['method_filter']) ? $extra_options['method_filter'] : ''; |
694 | 694 | //$signum = isset($extra_options['signum']) ? (int)$extra_options['signum'] : 0; |
695 | - $timeout = isset($extra_options['timeout']) ? (int)$extra_options['timeout'] : 0; |
|
695 | + $timeout = isset($extra_options['timeout']) ? (int) $extra_options['timeout'] : 0; |
|
696 | 696 | $protocol = isset($extra_options['protocol']) ? $extra_options['protocol'] : ''; |
697 | 697 | $newclassname = isset($extra_options['new_class_name']) ? $extra_options['new_class_name'] : ''; |
698 | - $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool)$extra_options['encode_php_objs'] : false; |
|
699 | - $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool)$extra_options['decode_php_objs'] : false; |
|
698 | + $encode_php_objects = isset($extra_options['encode_php_objs']) ? (bool) $extra_options['encode_php_objs'] : false; |
|
699 | + $decode_php_objects = isset($extra_options['decode_php_objs']) ? (bool) $extra_options['decode_php_objs'] : false; |
|
700 | 700 | $verbatim_client_copy = isset($extra_options['simple_client_copy']) ? !($extra_options['simple_client_copy']) : true; |
701 | 701 | $buildit = isset($extra_options['return_source']) ? !($extra_options['return_source']) : true; |
702 | 702 | $prefix = isset($extra_options['prefix']) ? $extra_options['prefix'] : 'xmlrpc'; |
@@ -706,8 +706,8 @@ discard block |
||
706 | 706 | $decodefunc = 'php_'.$prefix.'_decode'; |
707 | 707 | |
708 | 708 | $msg = new $msgclass('system.listMethods'); |
709 | - $response =& $client->send($msg, $timeout, $protocol); |
|
710 | - if($response->faultCode()) |
|
709 | + $response = & $client->send($msg, $timeout, $protocol); |
|
710 | + if ($response->faultCode()) |
|
711 | 711 | { |
712 | 712 | error_log('XML-RPC: could not retrieve method list from remote server'); |
713 | 713 | return false; |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | { |
720 | 720 | $mlist = $decodefunc($mlist); |
721 | 721 | } |
722 | - if(!is_array($mlist) || !count($mlist)) |
|
722 | + if (!is_array($mlist) || !count($mlist)) |
|
723 | 723 | { |
724 | 724 | error_log('XML-RPC: could not retrieve meaningful method list from remote server'); |
725 | 725 | return false; |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | else |
728 | 728 | { |
729 | 729 | // pick a suitable name for the new function, avoiding collisions |
730 | - if($newclassname != '') |
|
730 | + if ($newclassname != '') |
|
731 | 731 | { |
732 | 732 | $xmlrpcclassname = $newclassname; |
733 | 733 | } |
@@ -736,7 +736,7 @@ discard block |
||
736 | 736 | $xmlrpcclassname = $prefix.'_'.preg_replace(array('/\./', '/[^a-zA-Z0-9_\x7f-\xff]/'), |
737 | 737 | array('_', ''), $client->server).'_client'; |
738 | 738 | } |
739 | - while($buildit && class_exists($xmlrpcclassname)) |
|
739 | + while ($buildit && class_exists($xmlrpcclassname)) |
|
740 | 740 | { |
741 | 741 | $xmlrpcclassname .= 'x'; |
742 | 742 | } |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | 'decode_php_objs' => $decode_php_objects |
753 | 753 | ); |
754 | 754 | /// @todo build javadoc for class definition, too |
755 | - foreach($mlist as $mname) |
|
755 | + foreach ($mlist as $mname) |
|
756 | 756 | { |
757 | 757 | if ($methodfilter == '' || preg_match($methodfilter, $mname)) |
758 | 758 | { |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | eval($source.'$allOK=1;'); |
781 | 781 | // alternative |
782 | 782 | //$xmlrpcfuncname = create_function('$m', $innercode); |
783 | - if($allOK) |
|
783 | + if ($allOK) |
|
784 | 784 | { |
785 | 785 | return $xmlrpcclassname; |
786 | 786 | } |
@@ -807,12 +807,12 @@ discard block |
||
807 | 807 | * @access private |
808 | 808 | */ |
809 | 809 | function build_remote_method_wrapper_code($client, $methodname, $xmlrpcfuncname, |
810 | - $msig, $mdesc='', $timeout=0, $protocol='', $client_copy_mode=0, $prefix='xmlrpc', |
|
811 | - $decode_php_objects=false, $encode_php_objects=false, $decode_fault=false, |
|
812 | - $fault_response='') |
|
810 | + $msig, $mdesc = '', $timeout = 0, $protocol = '', $client_copy_mode = 0, $prefix = 'xmlrpc', |
|
811 | + $decode_php_objects = false, $encode_php_objects = false, $decode_fault = false, |
|
812 | + $fault_response = '') |
|
813 | 813 | { |
814 | 814 | $code = "function $xmlrpcfuncname ("; |
815 | - if ($client_copy_mode < 2) |
|
815 | + if ($client_copy_mode<2) |
|
816 | 816 | { |
817 | 817 | // client copy mode 0 or 1 == partial / full client copy in emitted code |
818 | 818 | $innercode = build_client_wrapper_code($client, $client_copy_mode, $prefix); |
@@ -840,11 +840,11 @@ discard block |
||
840 | 840 | // param parsing |
841 | 841 | $plist = array(); |
842 | 842 | $pcount = count($msig); |
843 | - for($i = 1; $i < $pcount; $i++) |
|
843 | + for ($i = 1; $i<$pcount; $i++) |
|
844 | 844 | { |
845 | 845 | $plist[] = "\$p$i"; |
846 | 846 | $ptype = $msig[$i]; |
847 | - if($ptype == 'i4' || $ptype == 'int' || $ptype == 'boolean' || $ptype == 'double' || |
|
847 | + if ($ptype == 'i4' || $ptype == 'int' || $ptype == 'boolean' || $ptype == 'double' || |
|
848 | 848 | $ptype == 'string' || $ptype == 'dateTime.iso8601' || $ptype == 'base64' || $ptype == 'null') |
849 | 849 | { |
850 | 850 | // only build directly xmlrpcvals when type is known and scalar |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | $innercode .= "\$msg->addparam(\$p$i);\n"; |
865 | 865 | $mdesc .= '* @param '.xmlrpc_2_php_type($ptype)." \$p$i\n"; |
866 | 866 | } |
867 | - if ($client_copy_mode < 2) |
|
867 | + if ($client_copy_mode<2) |
|
868 | 868 | { |
869 | 869 | $plist[] = '$debug=0'; |
870 | 870 | $mdesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n"; |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | $innercode .= "if (\$res->faultcode()) return $respcode; else return php_{$prefix}_decode(\$res->value());"; |
898 | 898 | } |
899 | 899 | |
900 | - $code = $code . $plist. ") {\n" . $innercode . "\n}\n"; |
|
900 | + $code = $code.$plist.") {\n".$innercode."\n}\n"; |
|
901 | 901 | |
902 | 902 | return array('source' => $code, 'docstring' => $mdesc); |
903 | 903 | } |
@@ -908,18 +908,18 @@ discard block |
||
908 | 908 | * valid php code is emitted. |
909 | 909 | * @access private |
910 | 910 | */ |
911 | - function build_client_wrapper_code($client, $verbatim_client_copy, $prefix='xmlrpc') |
|
911 | + function build_client_wrapper_code($client, $verbatim_client_copy, $prefix = 'xmlrpc') |
|
912 | 912 | { |
913 | 913 | $code = "\$client = new {$prefix}_client('".str_replace("'", "\'", $client->path). |
914 | - "', '" . str_replace("'", "\'", $client->server) . "', $client->port);\n"; |
|
914 | + "', '".str_replace("'", "\'", $client->server)."', $client->port);\n"; |
|
915 | 915 | |
916 | 916 | // copy all client fields to the client that will be generated runtime |
917 | 917 | // (this provides for future expansion or subclassing of client obj) |
918 | 918 | if ($verbatim_client_copy) |
919 | 919 | { |
920 | - foreach($client as $fld => $val) |
|
920 | + foreach ($client as $fld => $val) |
|
921 | 921 | { |
922 | - if($fld != 'debug' && $fld != 'return_type') |
|
922 | + if ($fld != 'debug' && $fld != 'return_type') |
|
923 | 923 | { |
924 | 924 | $val = var_export($val, true); |
925 | 925 | $code .= "\$client->$fld = $val;\n"; |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | ); |
58 | 58 | |
59 | 59 | /* Functions that implement system.XXX methods of xmlrpc servers */ |
60 | - $_xmlrpcs_getCapabilities_sig=array(array($GLOBALS['xmlrpcStruct'])); |
|
61 | - $_xmlrpcs_getCapabilities_doc='This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to'; |
|
62 | - $_xmlrpcs_getCapabilities_sdoc=array(array('list of capabilities, described as structs with a version number and url for the spec')); |
|
63 | - function _xmlrpcs_getCapabilities($server, $m=null) |
|
60 | + $_xmlrpcs_getCapabilities_sig = array(array($GLOBALS['xmlrpcStruct'])); |
|
61 | + $_xmlrpcs_getCapabilities_doc = 'This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to'; |
|
62 | + $_xmlrpcs_getCapabilities_sdoc = array(array('list of capabilities, described as structs with a version number and url for the spec')); |
|
63 | + function _xmlrpcs_getCapabilities($server, $m = null) |
|
64 | 64 | { |
65 | 65 | $outAr = $GLOBALS['xmlrpcs_capabilities']; |
66 | 66 | // NIL extension |
@@ -75,117 +75,117 @@ discard block |
||
75 | 75 | |
76 | 76 | // listMethods: signature was either a string, or nothing. |
77 | 77 | // The useless string variant has been removed |
78 | - $_xmlrpcs_listMethods_sig=array(array($GLOBALS['xmlrpcArray'])); |
|
79 | - $_xmlrpcs_listMethods_doc='This method lists all the methods that the XML-RPC server knows how to dispatch'; |
|
80 | - $_xmlrpcs_listMethods_sdoc=array(array('list of method names')); |
|
81 | - function _xmlrpcs_listMethods($server, $m=null) // if called in plain php values mode, second param is missing |
|
78 | + $_xmlrpcs_listMethods_sig = array(array($GLOBALS['xmlrpcArray'])); |
|
79 | + $_xmlrpcs_listMethods_doc = 'This method lists all the methods that the XML-RPC server knows how to dispatch'; |
|
80 | + $_xmlrpcs_listMethods_sdoc = array(array('list of method names')); |
|
81 | + function _xmlrpcs_listMethods($server, $m = null) // if called in plain php values mode, second param is missing |
|
82 | 82 | { |
83 | 83 | |
84 | - $outAr=array(); |
|
85 | - foreach($server->dmap as $key => $val) |
|
84 | + $outAr = array(); |
|
85 | + foreach ($server->dmap as $key => $val) |
|
86 | 86 | { |
87 | - $outAr[]=new xmlrpcval($key, 'string'); |
|
87 | + $outAr[] = new xmlrpcval($key, 'string'); |
|
88 | 88 | } |
89 | - if($server->allow_system_funcs) |
|
89 | + if ($server->allow_system_funcs) |
|
90 | 90 | { |
91 | - foreach($GLOBALS['_xmlrpcs_dmap'] as $key => $val) |
|
91 | + foreach ($GLOBALS['_xmlrpcs_dmap'] as $key => $val) |
|
92 | 92 | { |
93 | - $outAr[]=new xmlrpcval($key, 'string'); |
|
93 | + $outAr[] = new xmlrpcval($key, 'string'); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | return new xmlrpcresp(new xmlrpcval($outAr, 'array')); |
97 | 97 | } |
98 | 98 | |
99 | - $_xmlrpcs_methodSignature_sig=array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString'])); |
|
100 | - $_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; |
|
101 | - $_xmlrpcs_methodSignature_sdoc=array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); |
|
99 | + $_xmlrpcs_methodSignature_sig = array(array($GLOBALS['xmlrpcArray'], $GLOBALS['xmlrpcString'])); |
|
100 | + $_xmlrpcs_methodSignature_doc = 'Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)'; |
|
101 | + $_xmlrpcs_methodSignature_sdoc = array(array('list of known signatures, each sig being an array of xmlrpc type names', 'name of method to be described')); |
|
102 | 102 | function _xmlrpcs_methodSignature($server, $m) |
103 | 103 | { |
104 | 104 | // let accept as parameter both an xmlrpcval or string |
105 | 105 | if (is_object($m)) |
106 | 106 | { |
107 | - $methName=$m->getParam(0); |
|
108 | - $methName=$methName->scalarval(); |
|
107 | + $methName = $m->getParam(0); |
|
108 | + $methName = $methName->scalarval(); |
|
109 | 109 | } |
110 | 110 | else |
111 | 111 | { |
112 | - $methName=$m; |
|
112 | + $methName = $m; |
|
113 | 113 | } |
114 | - if(strpos($methName, "system.") === 0) |
|
114 | + if (strpos($methName, "system.") === 0) |
|
115 | 115 | { |
116 | - $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; |
|
116 | + $dmap = $GLOBALS['_xmlrpcs_dmap']; $sysCall = 1; |
|
117 | 117 | } |
118 | 118 | else |
119 | 119 | { |
120 | - $dmap=$server->dmap; $sysCall=0; |
|
120 | + $dmap = $server->dmap; $sysCall = 0; |
|
121 | 121 | } |
122 | - if(isset($dmap[$methName])) |
|
122 | + if (isset($dmap[$methName])) |
|
123 | 123 | { |
124 | - if(isset($dmap[$methName]['signature'])) |
|
124 | + if (isset($dmap[$methName]['signature'])) |
|
125 | 125 | { |
126 | - $sigs=array(); |
|
127 | - foreach($dmap[$methName]['signature'] as $inSig) |
|
126 | + $sigs = array(); |
|
127 | + foreach ($dmap[$methName]['signature'] as $inSig) |
|
128 | 128 | { |
129 | - $cursig=array(); |
|
130 | - foreach($inSig as $sig) |
|
129 | + $cursig = array(); |
|
130 | + foreach ($inSig as $sig) |
|
131 | 131 | { |
132 | - $cursig[]=new xmlrpcval($sig, 'string'); |
|
132 | + $cursig[] = new xmlrpcval($sig, 'string'); |
|
133 | 133 | } |
134 | - $sigs[]=new xmlrpcval($cursig, 'array'); |
|
134 | + $sigs[] = new xmlrpcval($cursig, 'array'); |
|
135 | 135 | } |
136 | - $r=new xmlrpcresp(new xmlrpcval($sigs, 'array')); |
|
136 | + $r = new xmlrpcresp(new xmlrpcval($sigs, 'array')); |
|
137 | 137 | } |
138 | 138 | else |
139 | 139 | { |
140 | 140 | // NB: according to the official docs, we should be returning a |
141 | 141 | // "none-array" here, which means not-an-array |
142 | - $r=new xmlrpcresp(new xmlrpcval('undef', 'string')); |
|
142 | + $r = new xmlrpcresp(new xmlrpcval('undef', 'string')); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | else |
146 | 146 | { |
147 | - $r=new xmlrpcresp(0,$GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); |
|
147 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); |
|
148 | 148 | } |
149 | 149 | return $r; |
150 | 150 | } |
151 | 151 | |
152 | - $_xmlrpcs_methodHelp_sig=array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); |
|
153 | - $_xmlrpcs_methodHelp_doc='Returns help text if defined for the method passed, otherwise returns an empty string'; |
|
154 | - $_xmlrpcs_methodHelp_sdoc=array(array('method description', 'name of the method to be described')); |
|
152 | + $_xmlrpcs_methodHelp_sig = array(array($GLOBALS['xmlrpcString'], $GLOBALS['xmlrpcString'])); |
|
153 | + $_xmlrpcs_methodHelp_doc = 'Returns help text if defined for the method passed, otherwise returns an empty string'; |
|
154 | + $_xmlrpcs_methodHelp_sdoc = array(array('method description', 'name of the method to be described')); |
|
155 | 155 | function _xmlrpcs_methodHelp($server, $m) |
156 | 156 | { |
157 | 157 | // let accept as parameter both an xmlrpcval or string |
158 | 158 | if (is_object($m)) |
159 | 159 | { |
160 | - $methName=$m->getParam(0); |
|
161 | - $methName=$methName->scalarval(); |
|
160 | + $methName = $m->getParam(0); |
|
161 | + $methName = $methName->scalarval(); |
|
162 | 162 | } |
163 | 163 | else |
164 | 164 | { |
165 | - $methName=$m; |
|
165 | + $methName = $m; |
|
166 | 166 | } |
167 | - if(strpos($methName, "system.") === 0) |
|
167 | + if (strpos($methName, "system.") === 0) |
|
168 | 168 | { |
169 | - $dmap=$GLOBALS['_xmlrpcs_dmap']; $sysCall=1; |
|
169 | + $dmap = $GLOBALS['_xmlrpcs_dmap']; $sysCall = 1; |
|
170 | 170 | } |
171 | 171 | else |
172 | 172 | { |
173 | - $dmap=$server->dmap; $sysCall=0; |
|
173 | + $dmap = $server->dmap; $sysCall = 0; |
|
174 | 174 | } |
175 | - if(isset($dmap[$methName])) |
|
175 | + if (isset($dmap[$methName])) |
|
176 | 176 | { |
177 | - if(isset($dmap[$methName]['docstring'])) |
|
177 | + if (isset($dmap[$methName]['docstring'])) |
|
178 | 178 | { |
179 | - $r=new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string'); |
|
179 | + $r = new xmlrpcresp(new xmlrpcval($dmap[$methName]['docstring']), 'string'); |
|
180 | 180 | } |
181 | 181 | else |
182 | 182 | { |
183 | - $r=new xmlrpcresp(new xmlrpcval('', 'string')); |
|
183 | + $r = new xmlrpcresp(new xmlrpcval('', 'string')); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | else |
187 | 187 | { |
188 | - $r=new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); |
|
188 | + $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['introspect_unknown'], $GLOBALS['xmlrpcstr']['introspect_unknown']); |
|
189 | 189 | } |
190 | 190 | return $r; |
191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | $_xmlrpcs_multicall_sdoc = array(array('list of response structs, where each struct has the usual members', 'list of calls, with each call being represented as a struct, with members "methodname" and "params"')); |
196 | 196 | function _xmlrpcs_multicall_error($err) |
197 | 197 | { |
198 | - if(is_string($err)) |
|
198 | + if (is_string($err)) |
|
199 | 199 | { |
200 | 200 | $str = $GLOBALS['xmlrpcstr']["multicall_${err}"]; |
201 | 201 | $code = $GLOBALS['xmlrpcerr']["multicall_${err}"]; |
@@ -213,52 +213,52 @@ discard block |
||
213 | 213 | |
214 | 214 | function _xmlrpcs_multicall_do_call($server, $call) |
215 | 215 | { |
216 | - if($call->kindOf() != 'struct') |
|
216 | + if ($call->kindOf() != 'struct') |
|
217 | 217 | { |
218 | 218 | return _xmlrpcs_multicall_error('notstruct'); |
219 | 219 | } |
220 | 220 | $methName = @$call->structmem('methodName'); |
221 | - if(!$methName) |
|
221 | + if (!$methName) |
|
222 | 222 | { |
223 | 223 | return _xmlrpcs_multicall_error('nomethod'); |
224 | 224 | } |
225 | - if($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') |
|
225 | + if ($methName->kindOf() != 'scalar' || $methName->scalartyp() != 'string') |
|
226 | 226 | { |
227 | 227 | return _xmlrpcs_multicall_error('notstring'); |
228 | 228 | } |
229 | - if($methName->scalarval() == 'system.multicall') |
|
229 | + if ($methName->scalarval() == 'system.multicall') |
|
230 | 230 | { |
231 | 231 | return _xmlrpcs_multicall_error('recursion'); |
232 | 232 | } |
233 | 233 | |
234 | 234 | $params = @$call->structmem('params'); |
235 | - if(!$params) |
|
235 | + if (!$params) |
|
236 | 236 | { |
237 | 237 | return _xmlrpcs_multicall_error('noparams'); |
238 | 238 | } |
239 | - if($params->kindOf() != 'array') |
|
239 | + if ($params->kindOf() != 'array') |
|
240 | 240 | { |
241 | 241 | return _xmlrpcs_multicall_error('notarray'); |
242 | 242 | } |
243 | 243 | $numParams = $params->arraysize(); |
244 | 244 | |
245 | 245 | $msg = new xmlrpcmsg($methName->scalarval()); |
246 | - for($i = 0; $i < $numParams; $i++) |
|
246 | + for ($i = 0; $i<$numParams; $i++) |
|
247 | 247 | { |
248 | - if(!$msg->addParam($params->arraymem($i))) |
|
248 | + if (!$msg->addParam($params->arraymem($i))) |
|
249 | 249 | { |
250 | 250 | $i++; |
251 | 251 | return _xmlrpcs_multicall_error(new xmlrpcresp(0, |
252 | 252 | $GLOBALS['xmlrpcerr']['incorrect_params'], |
253 | - $GLOBALS['xmlrpcstr']['incorrect_params'] . ": probable xml error in param " . $i)); |
|
253 | + $GLOBALS['xmlrpcstr']['incorrect_params'].": probable xml error in param ".$i)); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | 257 | $result = $server->execute($msg); |
258 | 258 | |
259 | - if($result->faultCode() != 0) |
|
259 | + if ($result->faultCode() != 0) |
|
260 | 260 | { |
261 | - return _xmlrpcs_multicall_error($result); // Method returned fault. |
|
261 | + return _xmlrpcs_multicall_error($result); // Method returned fault. |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | return new xmlrpcval(array($result->value()), 'array'); |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | |
267 | 267 | function _xmlrpcs_multicall_do_call_phpvals($server, $call) |
268 | 268 | { |
269 | - if(!is_array($call)) |
|
269 | + if (!is_array($call)) |
|
270 | 270 | { |
271 | 271 | return _xmlrpcs_multicall_error('notstruct'); |
272 | 272 | } |
273 | - if(!array_key_exists('methodName', $call)) |
|
273 | + if (!array_key_exists('methodName', $call)) |
|
274 | 274 | { |
275 | 275 | return _xmlrpcs_multicall_error('nomethod'); |
276 | 276 | } |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | { |
279 | 279 | return _xmlrpcs_multicall_error('notstring'); |
280 | 280 | } |
281 | - if($call['methodName'] == 'system.multicall') |
|
281 | + if ($call['methodName'] == 'system.multicall') |
|
282 | 282 | { |
283 | 283 | return _xmlrpcs_multicall_error('recursion'); |
284 | 284 | } |
285 | - if(!array_key_exists('params', $call)) |
|
285 | + if (!array_key_exists('params', $call)) |
|
286 | 286 | { |
287 | 287 | return _xmlrpcs_multicall_error('noparams'); |
288 | 288 | } |
289 | - if(!is_array($call['params'])) |
|
289 | + if (!is_array($call['params'])) |
|
290 | 290 | { |
291 | 291 | return _xmlrpcs_multicall_error('notarray'); |
292 | 292 | } |
@@ -295,14 +295,14 @@ discard block |
||
295 | 295 | // base64 or datetime values, but they will be listed as strings here... |
296 | 296 | $numParams = count($call['params']); |
297 | 297 | $pt = array(); |
298 | - foreach($call['params'] as $val) |
|
298 | + foreach ($call['params'] as $val) |
|
299 | 299 | $pt[] = php_2_xmlrpc_type(gettype($val)); |
300 | 300 | |
301 | 301 | $result = $server->execute($call['methodName'], $call['params'], $pt); |
302 | 302 | |
303 | - if($result->faultCode() != 0) |
|
303 | + if ($result->faultCode() != 0) |
|
304 | 304 | { |
305 | - return _xmlrpcs_multicall_error($result); // Method returned fault. |
|
305 | + return _xmlrpcs_multicall_error($result); // Method returned fault. |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | return new xmlrpcval(array($result->value()), 'array'); |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | { |
317 | 317 | $calls = $m->getParam(0); |
318 | 318 | $numCalls = $calls->arraysize(); |
319 | - for($i = 0; $i < $numCalls; $i++) |
|
319 | + for ($i = 0; $i<$numCalls; $i++) |
|
320 | 320 | { |
321 | 321 | $call = $calls->arraymem($i); |
322 | 322 | $result[$i] = _xmlrpcs_multicall_do_call($server, $call); |
@@ -324,8 +324,8 @@ discard block |
||
324 | 324 | } |
325 | 325 | else |
326 | 326 | { |
327 | - $numCalls=count($m); |
|
328 | - for($i = 0; $i < $numCalls; $i++) |
|
327 | + $numCalls = count($m); |
|
328 | + for ($i = 0; $i<$numCalls; $i++) |
|
329 | 329 | { |
330 | 330 | $result[$i] = _xmlrpcs_multicall_do_call_phpvals($server, $m[$i]); |
331 | 331 | } |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | return new xmlrpcresp(new xmlrpcval($result, 'array')); |
335 | 335 | } |
336 | 336 | |
337 | - $GLOBALS['_xmlrpcs_dmap']=array( |
|
337 | + $GLOBALS['_xmlrpcs_dmap'] = array( |
|
338 | 338 | 'system.listMethods' => array( |
339 | 339 | 'function' => '_xmlrpcs_listMethods', |
340 | 340 | 'signature' => $_xmlrpcs_listMethods_sig, |
@@ -374,24 +374,24 @@ discard block |
||
374 | 374 | * NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors. |
375 | 375 | * |
376 | 376 | */ |
377 | - function _xmlrpcs_errorHandler($errcode, $errstring, $filename=null, $lineno=null, $context=null) |
|
377 | + function _xmlrpcs_errorHandler($errcode, $errstring, $filename = null, $lineno = null, $context = null) |
|
378 | 378 | { |
379 | 379 | // obey the @ protocol |
380 | 380 | if (error_reporting() == 0) |
381 | 381 | return; |
382 | 382 | |
383 | 383 | //if($errcode != E_NOTICE && $errcode != E_WARNING && $errcode != E_USER_NOTICE && $errcode != E_USER_WARNING) |
384 | - if($errcode != E_STRICT) |
|
384 | + if ($errcode != E_STRICT) |
|
385 | 385 | { |
386 | - $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'] . $errstring . "\n"; |
|
386 | + $GLOBALS['_xmlrpcs_occurred_errors'] = $GLOBALS['_xmlrpcs_occurred_errors'].$errstring."\n"; |
|
387 | 387 | } |
388 | 388 | // Try to avoid as much as possible disruption to the previous error handling |
389 | 389 | // mechanism in place |
390 | - if($GLOBALS['_xmlrpcs_prev_ehandler'] == '') |
|
390 | + if ($GLOBALS['_xmlrpcs_prev_ehandler'] == '') |
|
391 | 391 | { |
392 | 392 | // The previous error handler was the default: all we should do is log error |
393 | 393 | // to the default error log (if level high enough) |
394 | - if(ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) |
|
394 | + if (ini_get('log_errors') && (intval(ini_get('error_reporting')) & $errcode)) |
|
395 | 395 | { |
396 | 396 | error_log($errstring); |
397 | 397 | } |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | else |
400 | 400 | { |
401 | 401 | // Pass control on to previous error handler, trying to avoid loops... |
402 | - if($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') |
|
402 | + if ($GLOBALS['_xmlrpcs_prev_ehandler'] != '_xmlrpcs_errorHandler') |
|
403 | 403 | { |
404 | 404 | // NB: this code will NOT work on php < 4.0.2: only 2 params were used for error handlers |
405 | - if(is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) |
|
405 | + if (is_array($GLOBALS['_xmlrpcs_prev_ehandler'])) |
|
406 | 406 | { |
407 | 407 | // the following works both with static class methods and plain object methods as error handler |
408 | 408 | call_user_func_array($GLOBALS['_xmlrpcs_prev_ehandler'], array($errcode, $errstring, $filename, $lineno, $context)); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | - $GLOBALS['_xmlrpc_debuginfo']=''; |
|
418 | + $GLOBALS['_xmlrpc_debuginfo'] = ''; |
|
419 | 419 | |
420 | 420 | /** |
421 | 421 | * Add a string to the debug info that can be later seralized by the server |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | */ |
428 | 428 | function xmlrpc_debugmsg($m) |
429 | 429 | { |
430 | - $GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n"; |
|
430 | + $GLOBALS['_xmlrpc_debuginfo'] .= $m."\n"; |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | class xmlrpc_server |
@@ -436,20 +436,20 @@ discard block |
||
436 | 436 | * Array defining php functions exposed as xmlrpc methods by this server |
437 | 437 | * @access private |
438 | 438 | */ |
439 | - var $dmap=array(); |
|
439 | + var $dmap = array(); |
|
440 | 440 | /** |
441 | 441 | * Defines how functions in dmap will be invoked: either using an xmlrpc msg object |
442 | 442 | * or plain php values. |
443 | 443 | * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals' |
444 | 444 | */ |
445 | - var $functions_parameters_type='xmlrpcvals'; |
|
445 | + var $functions_parameters_type = 'xmlrpcvals'; |
|
446 | 446 | /** |
447 | 447 | * Option used for fine-tuning the encoding the php values returned from |
448 | 448 | * functions registered in the dispatch map when the functions_parameters_types |
449 | 449 | * member is set to 'phpvals' |
450 | 450 | * @see php_xmlrpc_encode for a list of values |
451 | 451 | */ |
452 | - var $phpvals_encoding_options = array( 'auto_dates' ); |
|
452 | + var $phpvals_encoding_options = array('auto_dates'); |
|
453 | 453 | /// controls whether the server is going to echo debugging messages back to the client as comments in response body. valid values: 0,1,2,3 |
454 | 454 | var $debug = 1; |
455 | 455 | /** |
@@ -497,11 +497,11 @@ discard block |
||
497 | 497 | * @param array $dispmap the dispatch map with definition of exposed services |
498 | 498 | * @param boolean $servicenow set to false to prevent the server from running upon construction |
499 | 499 | */ |
500 | - function __construct($dispMap=null, $serviceNow=true) |
|
500 | + function __construct($dispMap = null, $serviceNow = true) |
|
501 | 501 | { |
502 | 502 | // if ZLIB is enabled, let the server by default accept compressed requests, |
503 | 503 | // and compress responses sent to clients that support them |
504 | - if(function_exists('gzinflate')) |
|
504 | + if (function_exists('gzinflate')) |
|
505 | 505 | { |
506 | 506 | $this->accepted_compression = array('gzip', 'deflate'); |
507 | 507 | $this->compress_response = true; |
@@ -519,10 +519,10 @@ discard block |
||
519 | 519 | * instead, you can use the class add_to_map() function |
520 | 520 | * to add functions manually (borrowed from SOAPX4) |
521 | 521 | */ |
522 | - if($dispMap) |
|
522 | + if ($dispMap) |
|
523 | 523 | { |
524 | 524 | $this->dmap = $dispMap; |
525 | - if($serviceNow) |
|
525 | + if ($serviceNow) |
|
526 | 526 | { |
527 | 527 | $this->service(); |
528 | 528 | } |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | /** |
533 | 533 | * @deprecated |
534 | 534 | */ |
535 | - function xmlrpc_client($dispMap=null, $serviceNow=true) |
|
535 | + function xmlrpc_client($dispMap = null, $serviceNow = true) |
|
536 | 536 | { |
537 | 537 | self::__construct($dispMap, $serviceNow); |
538 | 538 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | function setDebug($in) |
555 | 555 | { |
556 | - $this->debug=$in; |
|
556 | + $this->debug = $in; |
|
557 | 557 | } |
558 | 558 | |
559 | 559 | /** |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | * @param string $charset_encoding the target charset encoding for the serialization |
562 | 562 | * @return string an XML comment (or two) |
563 | 563 | */ |
564 | - function serializeDebug($charset_encoding='') |
|
564 | + function serializeDebug($charset_encoding = '') |
|
565 | 565 | { |
566 | 566 | // Tough encoding problem: which internal charset should we assume for debug info? |
567 | 567 | // It might contain a copy of raw data received from client, ie with unknown encoding, |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | { |
574 | 574 | $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; |
575 | 575 | } |
576 | - if($GLOBALS['_xmlrpc_debuginfo']!='') |
|
576 | + if ($GLOBALS['_xmlrpc_debuginfo'] != '') |
|
577 | 577 | { |
578 | 578 | |
579 | - $out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n"; |
|
579 | + $out .= "<!-- DEBUG INFO:\n".xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding)."\n-->\n"; |
|
580 | 580 | // NB: a better solution MIGHT be to use CDATA, but we need to insert it |
581 | 581 | // into return payload AFTER the beginning tag |
582 | 582 | //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n"; |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @return xmlrpcresp the response object (usually not used by caller...) |
591 | 591 | * @access public |
592 | 592 | */ |
593 | - function service($data=null, $return_payload=false) |
|
593 | + function service($data = null, $return_payload = false) |
|
594 | 594 | { |
595 | 595 | if ($data === null) |
596 | 596 | { |
@@ -603,30 +603,30 @@ discard block |
||
603 | 603 | $this->debug_info = ''; |
604 | 604 | |
605 | 605 | // Echo back what we received, before parsing it |
606 | - if($this->debug > 1) |
|
606 | + if ($this->debug>1) |
|
607 | 607 | { |
608 | - $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); |
|
608 | + $this->debugmsg("+++GOT+++\n".$data."\n+++END+++"); |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding); |
612 | 612 | if (!$r) |
613 | 613 | { |
614 | - $r=$this->parseRequest($data, $req_charset); |
|
614 | + $r = $this->parseRequest($data, $req_charset); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | // save full body of request into response, for more debugging usages |
618 | 618 | $r->raw_data = $raw_data; |
619 | 619 | |
620 | - if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) |
|
620 | + if ($this->debug>2 && $GLOBALS['_xmlrpcs_occurred_errors']) |
|
621 | 621 | { |
622 | - $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . |
|
623 | - $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++"); |
|
622 | + $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n". |
|
623 | + $GLOBALS['_xmlrpcs_occurred_errors']."+++END+++"); |
|
624 | 624 | } |
625 | 625 | |
626 | - $payload=$this->xml_header($resp_charset); |
|
627 | - if($this->debug > 0) |
|
626 | + $payload = $this->xml_header($resp_charset); |
|
627 | + if ($this->debug>0) |
|
628 | 628 | { |
629 | - $payload = $payload . $this->serializeDebug($resp_charset); |
|
629 | + $payload = $payload.$this->serializeDebug($resp_charset); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | // G. Giunta 2006-01-27: do not create response serialization if it has |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | { |
636 | 636 | $r->serialize($resp_charset); |
637 | 637 | } |
638 | - $payload = $payload . $r->payload; |
|
638 | + $payload = $payload.$r->payload; |
|
639 | 639 | |
640 | 640 | if ($return_payload) |
641 | 641 | { |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | // if we get a warning/error that has output some text before here, then we cannot |
646 | 646 | // add a new header. We cannot say we are sending xml, either... |
647 | - if(!headers_sent()) |
|
647 | + if (!headers_sent()) |
|
648 | 648 | { |
649 | 649 | header('Content-Type: '.$r->content_type); |
650 | 650 | // we do not know if client actually told us an accepted charset, but if he did |
@@ -655,10 +655,10 @@ discard block |
||
655 | 655 | // if we can do it, and we want to do it, and client asked us to, |
656 | 656 | // and php ini settings do not force it already |
657 | 657 | $php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'); |
658 | - if($this->compress_response && function_exists('gzencode') && $resp_encoding != '' |
|
658 | + if ($this->compress_response && function_exists('gzencode') && $resp_encoding != '' |
|
659 | 659 | && $php_no_self_compress) |
660 | 660 | { |
661 | - if(strpos($resp_encoding, 'gzip') !== false) |
|
661 | + if (strpos($resp_encoding, 'gzip') !== false) |
|
662 | 662 | { |
663 | 663 | $payload = gzencode($payload); |
664 | 664 | header("Content-Encoding: gzip"); |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | |
675 | 675 | // do not ouput content-length header if php is compressing output for us: |
676 | 676 | // it will mess up measurements |
677 | - if($php_no_self_compress) |
|
677 | + if ($php_no_self_compress) |
|
678 | 678 | { |
679 | - header('Content-Length: ' . (int)strlen($payload)); |
|
679 | + header('Content-Length: '.(int) strlen($payload)); |
|
680 | 680 | } |
681 | 681 | } |
682 | 682 | else |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * @param array $sigdoc the array of valid method signatures docs (one string per param, one for return type) |
700 | 700 | * @access public |
701 | 701 | */ |
702 | - function add_to_map($methodname,$function,$sig=null,$doc=false,$sigdoc=false) |
|
702 | + function add_to_map($methodname, $function, $sig = null, $doc = false, $sigdoc = false) |
|
703 | 703 | { |
704 | 704 | $this->dmap[$methodname] = array( |
705 | 705 | 'function' => $function, |
@@ -733,47 +733,47 @@ discard block |
||
733 | 733 | { |
734 | 734 | $numParams = count($in); |
735 | 735 | } |
736 | - foreach($sig as $cursig) |
|
736 | + foreach ($sig as $cursig) |
|
737 | 737 | { |
738 | - if(count($cursig)==$numParams+1) |
|
738 | + if (count($cursig) == $numParams+1) |
|
739 | 739 | { |
740 | - $itsOK=1; |
|
741 | - for($n=0; $n<$numParams; $n++) |
|
740 | + $itsOK = 1; |
|
741 | + for ($n = 0; $n<$numParams; $n++) |
|
742 | 742 | { |
743 | 743 | if (is_object($in)) |
744 | 744 | { |
745 | - $p=$in->getParam($n); |
|
746 | - if($p->kindOf() == 'scalar') |
|
745 | + $p = $in->getParam($n); |
|
746 | + if ($p->kindOf() == 'scalar') |
|
747 | 747 | { |
748 | - $pt=$p->scalartyp(); |
|
748 | + $pt = $p->scalartyp(); |
|
749 | 749 | } |
750 | 750 | else |
751 | 751 | { |
752 | - $pt=$p->kindOf(); |
|
752 | + $pt = $p->kindOf(); |
|
753 | 753 | } |
754 | 754 | } |
755 | 755 | else |
756 | 756 | { |
757 | - $pt= $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4... |
|
757 | + $pt = $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4... |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | // param index is $n+1, as first member of sig is return type |
761 | - if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) |
|
761 | + if ($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) |
|
762 | 762 | { |
763 | - $itsOK=0; |
|
764 | - $pno=$n+1; |
|
765 | - $wanted=$cursig[$n+1]; |
|
766 | - $got=$pt; |
|
763 | + $itsOK = 0; |
|
764 | + $pno = $n+1; |
|
765 | + $wanted = $cursig[$n+1]; |
|
766 | + $got = $pt; |
|
767 | 767 | break; |
768 | 768 | } |
769 | 769 | } |
770 | - if($itsOK) |
|
770 | + if ($itsOK) |
|
771 | 771 | { |
772 | - return array(1,''); |
|
772 | + return array(1, ''); |
|
773 | 773 | } |
774 | 774 | } |
775 | 775 | } |
776 | - if(isset($wanted)) |
|
776 | + if (isset($wanted)) |
|
777 | 777 | { |
778 | 778 | return array(0, "Wanted ${wanted}, got ${got} at param ${pno}"); |
779 | 779 | } |
@@ -797,12 +797,12 @@ discard block |
||
797 | 797 | error_log('XML-RPC: '.__METHOD__.': cannot parse request headers as $_SERVER is not populated'); |
798 | 798 | } |
799 | 799 | |
800 | - if($this->debug > 1) |
|
800 | + if ($this->debug>1) |
|
801 | 801 | { |
802 | - if(function_exists('getallheaders')) |
|
802 | + if (function_exists('getallheaders')) |
|
803 | 803 | { |
804 | 804 | $this->debugmsg(''); // empty line |
805 | - foreach(getallheaders() as $name => $val) |
|
805 | + foreach (getallheaders() as $name => $val) |
|
806 | 806 | { |
807 | 807 | $this->debugmsg("HEADER: $name: $val"); |
808 | 808 | } |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | |
811 | 811 | } |
812 | 812 | |
813 | - if(isset($_SERVER['HTTP_CONTENT_ENCODING'])) |
|
813 | + if (isset($_SERVER['HTTP_CONTENT_ENCODING'])) |
|
814 | 814 | { |
815 | 815 | $content_encoding = str_replace('x-', '', $_SERVER['HTTP_CONTENT_ENCODING']); |
816 | 816 | } |
@@ -820,26 +820,26 @@ discard block |
||
820 | 820 | } |
821 | 821 | |
822 | 822 | // check if request body has been compressed and decompress it |
823 | - if($content_encoding != '' && strlen($data)) |
|
823 | + if ($content_encoding != '' && strlen($data)) |
|
824 | 824 | { |
825 | - if($content_encoding == 'deflate' || $content_encoding == 'gzip') |
|
825 | + if ($content_encoding == 'deflate' || $content_encoding == 'gzip') |
|
826 | 826 | { |
827 | 827 | // if decoding works, use it. else assume data wasn't gzencoded |
828 | - if(function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) |
|
828 | + if (function_exists('gzinflate') && in_array($content_encoding, $this->accepted_compression)) |
|
829 | 829 | { |
830 | - if($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) |
|
830 | + if ($content_encoding == 'deflate' && $degzdata = @gzuncompress($data)) |
|
831 | 831 | { |
832 | 832 | $data = $degzdata; |
833 | - if($this->debug > 1) |
|
833 | + if ($this->debug>1) |
|
834 | 834 | { |
835 | - $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); |
|
835 | + $this->debugmsg("\n+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
836 | 836 | } |
837 | 837 | } |
838 | - elseif($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) |
|
838 | + elseif ($content_encoding == 'gzip' && $degzdata = @gzinflate(substr($data, 10))) |
|
839 | 839 | { |
840 | 840 | $data = $degzdata; |
841 | - if($this->debug > 1) |
|
842 | - $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n" . $data . "\n+++END+++"); |
|
841 | + if ($this->debug>1) |
|
842 | + $this->debugmsg("+++INFLATED REQUEST+++[".strlen($data)." chars]+++\n".$data."\n+++END+++"); |
|
843 | 843 | } |
844 | 844 | else |
845 | 845 | { |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | * @return xmlrpcresp |
913 | 913 | * @access private |
914 | 914 | */ |
915 | - function parseRequest($data, $req_encoding='') |
|
915 | + function parseRequest($data, $req_encoding = '') |
|
916 | 916 | { |
917 | 917 | // 2005/05/07 commented and moved into caller function code |
918 | 918 | //if($data=='') |
@@ -924,16 +924,16 @@ discard block |
||
924 | 924 | // so we do not try to convert them into xml character entities |
925 | 925 | //$data = xmlrpc_html_entity_xlate($data); |
926 | 926 | |
927 | - $GLOBALS['_xh']=array(); |
|
928 | - $GLOBALS['_xh']['ac']=''; |
|
929 | - $GLOBALS['_xh']['stack']=array(); |
|
927 | + $GLOBALS['_xh'] = array(); |
|
928 | + $GLOBALS['_xh']['ac'] = ''; |
|
929 | + $GLOBALS['_xh']['stack'] = array(); |
|
930 | 930 | $GLOBALS['_xh']['valuestack'] = array(); |
931 | - $GLOBALS['_xh']['params']=array(); |
|
932 | - $GLOBALS['_xh']['pt']=array(); |
|
933 | - $GLOBALS['_xh']['isf']=0; |
|
934 | - $GLOBALS['_xh']['isf_reason']=''; |
|
935 | - $GLOBALS['_xh']['method']=false; // so we can check later if we got a methodname or not |
|
936 | - $GLOBALS['_xh']['rt']=''; |
|
931 | + $GLOBALS['_xh']['params'] = array(); |
|
932 | + $GLOBALS['_xh']['pt'] = array(); |
|
933 | + $GLOBALS['_xh']['isf'] = 0; |
|
934 | + $GLOBALS['_xh']['isf_reason'] = ''; |
|
935 | + $GLOBALS['_xh']['method'] = false; // so we can check later if we got a methodname or not |
|
936 | + $GLOBALS['_xh']['rt'] = ''; |
|
937 | 937 | |
938 | 938 | // decompose incoming XML into request structure |
939 | 939 | |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | if (extension_loaded('mbstring')) { |
952 | 952 | $data = mb_convert_encoding($data, 'UTF-8', $req_encoding); |
953 | 953 | } else { |
954 | - error_log('XML-RPC: ' . __METHOD__ . ': invalid charset encoding of received request: ' . $req_encoding); |
|
954 | + error_log('XML-RPC: '.__METHOD__.': invalid charset encoding of received request: '.$req_encoding); |
|
955 | 955 | } |
956 | 956 | } |
957 | 957 | } |
@@ -980,10 +980,10 @@ discard block |
||
980 | 980 | xml_set_element_handler($parser, 'xmlrpc_se', 'xmlrpc_ee'); |
981 | 981 | xml_set_character_data_handler($parser, 'xmlrpc_cd'); |
982 | 982 | xml_set_default_handler($parser, 'xmlrpc_dh'); |
983 | - if(!xml_parse($parser, $data, 1)) |
|
983 | + if (!xml_parse($parser, $data, 1)) |
|
984 | 984 | { |
985 | 985 | // return XML error as a faultCode |
986 | - $r=new xmlrpcresp(0, |
|
986 | + $r = new xmlrpcresp(0, |
|
987 | 987 | $GLOBALS['xmlrpcerrxml']+xml_get_error_code($parser), |
988 | 988 | sprintf('XML error: %s at line %d, column %d', |
989 | 989 | xml_error_string(xml_get_error_code($parser)), |
@@ -993,9 +993,9 @@ discard block |
||
993 | 993 | elseif ($GLOBALS['_xh']['isf']) |
994 | 994 | { |
995 | 995 | xml_parser_free($parser); |
996 | - $r=new xmlrpcresp(0, |
|
996 | + $r = new xmlrpcresp(0, |
|
997 | 997 | $GLOBALS['xmlrpcerr']['invalid_request'], |
998 | - $GLOBALS['xmlrpcstr']['invalid_request'] . ' ' . $GLOBALS['_xh']['isf_reason']); |
|
998 | + $GLOBALS['xmlrpcstr']['invalid_request'].' '.$GLOBALS['_xh']['isf_reason']); |
|
999 | 999 | } |
1000 | 1000 | else |
1001 | 1001 | { |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | // registered as phpvals) that would mean a useless encode+decode pass |
1007 | 1007 | if ($this->functions_parameters_type != 'xmlrpcvals' || (isset($this->dmap[$GLOBALS['_xh']['method']]['parameters_type']) && ($this->dmap[$GLOBALS['_xh']['method']]['parameters_type'] == 'phpvals'))) |
1008 | 1008 | { |
1009 | - if($this->debug > 1) |
|
1009 | + if ($this->debug>1) |
|
1010 | 1010 | { |
1011 | 1011 | $this->debugmsg("\n+++PARSED+++\n".var_export($GLOBALS['_xh']['params'], true)."\n+++END+++"); |
1012 | 1012 | } |
@@ -1015,14 +1015,14 @@ discard block |
||
1015 | 1015 | else |
1016 | 1016 | { |
1017 | 1017 | // build an xmlrpcmsg object with data parsed from xml |
1018 | - $m=new xmlrpcmsg($GLOBALS['_xh']['method']); |
|
1018 | + $m = new xmlrpcmsg($GLOBALS['_xh']['method']); |
|
1019 | 1019 | // now add parameters in |
1020 | - for($i=0; $i<count($GLOBALS['_xh']['params']); $i++) |
|
1020 | + for ($i = 0; $i<count($GLOBALS['_xh']['params']); $i++) |
|
1021 | 1021 | { |
1022 | 1022 | $m->addParam($GLOBALS['_xh']['params'][$i]); |
1023 | 1023 | } |
1024 | 1024 | |
1025 | - if($this->debug > 1) |
|
1025 | + if ($this->debug>1) |
|
1026 | 1026 | { |
1027 | 1027 | $this->debugmsg("\n+++PARSED+++\n".var_export($m, true)."\n+++END+++"); |
1028 | 1028 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
1040 | 1040 | * @return xmlrpcresp |
1041 | 1041 | * @access private |
1042 | 1042 | */ |
1043 | - function execute($m, $params=null, $paramtypes=null) |
|
1043 | + function execute($m, $params = null, $paramtypes = null) |
|
1044 | 1044 | { |
1045 | 1045 | if (is_object($m)) |
1046 | 1046 | { |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | $sysCall = $this->allow_system_funcs && (strpos($methName, "system.") === 0); |
1054 | 1054 | $dmap = $sysCall ? $GLOBALS['_xmlrpcs_dmap'] : $this->dmap; |
1055 | 1055 | |
1056 | - if(!isset($dmap[$methName]['function'])) |
|
1056 | + if (!isset($dmap[$methName]['function'])) |
|
1057 | 1057 | { |
1058 | 1058 | // No such method |
1059 | 1059 | return new xmlrpcresp(0, |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | // Check signature |
1065 | - if(isset($dmap[$methName]['signature'])) |
|
1065 | + if (isset($dmap[$methName]['signature'])) |
|
1066 | 1066 | { |
1067 | 1067 | $sig = $dmap[$methName]['signature']; |
1068 | 1068 | if (is_object($m)) |
@@ -1073,37 +1073,37 @@ discard block |
||
1073 | 1073 | { |
1074 | 1074 | list($ok, $errstr) = $this->verifySignature($paramtypes, $sig); |
1075 | 1075 | } |
1076 | - if(!$ok) |
|
1076 | + if (!$ok) |
|
1077 | 1077 | { |
1078 | 1078 | // Didn't match. |
1079 | 1079 | return new xmlrpcresp( |
1080 | 1080 | 0, |
1081 | 1081 | $GLOBALS['xmlrpcerr']['incorrect_params'], |
1082 | - $GLOBALS['xmlrpcstr']['incorrect_params'] . ": ${errstr}" |
|
1082 | + $GLOBALS['xmlrpcstr']['incorrect_params'].": ${errstr}" |
|
1083 | 1083 | ); |
1084 | 1084 | } |
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | $func = $dmap[$methName]['function']; |
1088 | 1088 | // let the 'class::function' syntax be accepted in dispatch maps |
1089 | - if(is_string($func) && strpos($func, '::')) |
|
1089 | + if (is_string($func) && strpos($func, '::')) |
|
1090 | 1090 | { |
1091 | 1091 | $func = explode('::', $func); |
1092 | 1092 | } |
1093 | 1093 | // verify that function to be invoked is in fact callable |
1094 | - if(!is_callable($func)) |
|
1094 | + if (!is_callable($func)) |
|
1095 | 1095 | { |
1096 | 1096 | error_log("XML-RPC: ".__METHOD__.": function $func registered as method handler is not callable"); |
1097 | 1097 | return new xmlrpcresp( |
1098 | 1098 | 0, |
1099 | 1099 | $GLOBALS['xmlrpcerr']['server_error'], |
1100 | - $GLOBALS['xmlrpcstr']['server_error'] . ": no function matches method" |
|
1100 | + $GLOBALS['xmlrpcstr']['server_error'].": no function matches method" |
|
1101 | 1101 | ); |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | // If debug level is 3, we should catch all errors generated during |
1105 | 1105 | // processing of user function, and log them as part of response |
1106 | - if($this->debug > 2) |
|
1106 | + if ($this->debug>2) |
|
1107 | 1107 | { |
1108 | 1108 | $GLOBALS['_xmlrpcs_prev_ehandler'] = set_error_handler('_xmlrpcs_errorHandler'); |
1109 | 1109 | } |
@@ -1112,7 +1112,7 @@ discard block |
||
1112 | 1112 | // Allow mixed-convention servers |
1113 | 1113 | if (is_object($m)) |
1114 | 1114 | { |
1115 | - if($sysCall) |
|
1115 | + if ($sysCall) |
|
1116 | 1116 | { |
1117 | 1117 | $r = call_user_func($func, $this, $m); |
1118 | 1118 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
1132 | 1132 | $r = new xmlrpcresp( |
1133 | 1133 | 0, |
1134 | 1134 | $GLOBALS['xmlrpcerr']['server_error'], |
1135 | - $GLOBALS['xmlrpcstr']['server_error'] . ": function does not return xmlrpcresp object" |
|
1135 | + $GLOBALS['xmlrpcstr']['server_error'].": function does not return xmlrpcresp object" |
|
1136 | 1136 | ); |
1137 | 1137 | } |
1138 | 1138 | } |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | else |
1141 | 1141 | { |
1142 | 1142 | // call a 'plain php' function |
1143 | - if($sysCall) |
|
1143 | + if ($sysCall) |
|
1144 | 1144 | { |
1145 | 1145 | array_unshift($params, $this); |
1146 | 1146 | $r = call_user_func_array($func, $params); |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | // an eror response |
1156 | 1156 | if (is_array($r) && array_key_exists('faultCode', $r) && array_key_exists('faultString', $r)) |
1157 | 1157 | { |
1158 | - $r = new xmlrpcresp(0, (integer)$r['faultCode'], (string)$r['faultString']); |
|
1158 | + $r = new xmlrpcresp(0, (integer) $r['faultCode'], (string) $r['faultString']); |
|
1159 | 1159 | } |
1160 | 1160 | else |
1161 | 1161 | { |
@@ -1178,11 +1178,11 @@ discard block |
||
1178 | 1178 | } |
1179 | 1179 | } |
1180 | 1180 | } |
1181 | - catch(Exception $e) |
|
1181 | + catch (Exception $e) |
|
1182 | 1182 | { |
1183 | 1183 | // (barring errors in the lib) an uncatched exception happened |
1184 | 1184 | // in the called function, we wrap it in a proper error-response |
1185 | - switch($this->exception_handling) |
|
1185 | + switch ($this->exception_handling) |
|
1186 | 1186 | { |
1187 | 1187 | case 2: |
1188 | 1188 | throw $e; |
@@ -1194,11 +1194,11 @@ discard block |
||
1194 | 1194 | $r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['server_error'], $GLOBALS['xmlrpcstr']['server_error']); |
1195 | 1195 | } |
1196 | 1196 | } |
1197 | - if($this->debug > 2) |
|
1197 | + if ($this->debug>2) |
|
1198 | 1198 | { |
1199 | 1199 | // note: restore the error handler we found before calling the |
1200 | 1200 | // user func, even if it has been changed inside the func itself |
1201 | - if($GLOBALS['_xmlrpcs_prev_ehandler']) |
|
1201 | + if ($GLOBALS['_xmlrpcs_prev_ehandler']) |
|
1202 | 1202 | { |
1203 | 1203 | set_error_handler($GLOBALS['_xmlrpcs_prev_ehandler']); |
1204 | 1204 | } |
@@ -1223,15 +1223,15 @@ discard block |
||
1223 | 1223 | /** |
1224 | 1224 | * @access private |
1225 | 1225 | */ |
1226 | - function xml_header($charset_encoding='') |
|
1226 | + function xml_header($charset_encoding = '') |
|
1227 | 1227 | { |
1228 | 1228 | if ($charset_encoding != '') |
1229 | 1229 | { |
1230 | - return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?" . ">\n"; |
|
1230 | + return "<?xml version=\"1.0\" encoding=\"$charset_encoding\"?".">\n"; |
|
1231 | 1231 | } |
1232 | 1232 | else |
1233 | 1233 | { |
1234 | - return "<?xml version=\"1.0\"?" . ">\n"; |
|
1234 | + return "<?xml version=\"1.0\"?".">\n"; |
|
1235 | 1235 | } |
1236 | 1236 | } |
1237 | 1237 | |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | */ |
1242 | 1242 | function echoInput() |
1243 | 1243 | { |
1244 | - $r=new xmlrpcresp(new xmlrpcval( "'Aha said I: '" . $GLOBALS['HTTP_RAW_POST_DATA'], 'string')); |
|
1244 | + $r = new xmlrpcresp(new xmlrpcval("'Aha said I: '".$GLOBALS['HTTP_RAW_POST_DATA'], 'string')); |
|
1245 | 1245 | print $r->serialize(); |
1246 | 1246 | } |
1247 | 1247 | } |