Passed
Push — master ( 251b1a...cf6e60 )
by Gaetano
08:24
created

demo/client/getstatename.php (1 issue)

Labels
Severity
1
<?php
2
require_once __DIR__ . "/_prepend.php";
3
4 1
output('<html lang="en">
5
<head><title>xmlrpc - Getstatename demo</title></head>
6
<body>
7
<h1>Getstatename demo</h1>
8
<h2>Send a U.S. state number to the server and get back the state name</h2>
9
<h3>The code demonstrates usage of automatic encoding/decoding of php variables into xmlrpc values</h3>
10
<p>You can see the source to this page here: <a href="getstatename.php?showSource=1">getstatename.php</a></p>
11
');
12
13 1
if (isset($_POST["stateno"]) && $_POST["stateno"] != "") {
14 1
    $stateNo = (integer)$_POST["stateno"];
15 1
    $encoder = new PhpXmlRpc\Encoder();
16 1
    $req = new PhpXmlRpc\Request('examples.getStateName',
17 1
        array($encoder->encode($stateNo))
18
    );
19 1
    output("Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . "\n\n</pre>Debug info of server data follows...\n\n");
20 1
    $client = new PhpXmlRpc\Client(XMLRPCSERVER);
21 1
    $client->setDebug(1);
22 1
    $r = $client->send($req);
23 1
    if (!$r->faultCode()) {
24 1
        $v = $r->value();
25 1
        output("<br/>State number <b>" . $stateNo . "</b> is <b>"
26 1
            . htmlspecialchars($encoder->decode($v)) . "</b><br/><br/>");
0 ignored issues
show
$v of type integer is incompatible with the type PhpXmlRpc\Request|PhpXmlRpc\Value expected by parameter $xmlrpcVal of PhpXmlRpc\Encoder::decode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
            . htmlspecialchars($encoder->decode(/** @scrutinizer ignore-type */ $v)) . "</b><br/><br/>");
Loading history...
27
    } else {
28
        output("An error occurred: ");
29
        output("Code: " . htmlspecialchars($r->faultCode())
30
            . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>");
31
    }
32
} else {
33 1
    $stateNo = "";
34
}
35
36 1
output("<form action=\"getstatename.php\" method=\"POST\">
37 1
<input name=\"stateno\" value=\"" . $stateNo . "\">
38
<input type=\"submit\" value=\"go\" name=\"submit\">
39
</form>
40
<p>Enter a state number to query its name</p>");
41
42
output("</body></html>\n");
43