<?php
-include_once __DIR__ . "/../../vendor/autoload.php";
+require_once __DIR__ . "/_prepend.php";
use PhpXmlRpc\Value;
is the comment itself. Returns the number of comments against that
ID.';
-function addComment($m)
+function addComment($req)
{
$err = "";
// since validation has already been carried out for us,
// we know we got exactly 3 string values
$encoder = new PhpXmlRpc\Encoder();
- $n = $encoder->decode($m);
+ $n = $encoder->decode($req);
$msgID = $n[0];
$name = $n[1];
$comment = $n[2];
return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
} else {
// otherwise, we create the right response
- // with the state name
return new PhpXmlRpc\Response(new PhpXmlRpc\Value($count, "int"));
}
}
is the sole argument. Each array item is a struct containing name
and comment text.';
-function getComments($m)
+function getComments($req)
{
$err = "";
$ra = array();
- $msgID = php_xmlrpc_decode($m->getParam(0));
+ $encoder = new PhpXmlRpc\Encoder();
+ $msgID = $encoder->decode($req->getParam(0));
$dbh = dba_open("/tmp/comments.db", "r", "db2");
if ($dbh) {
$countID = "${msgID}_count";
return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
} else {
// otherwise, we create the right response
- // with the state name
- $encoder = new PhpXmlRpc\Encoder();
return new PhpXmlRpc\Response($encoder->encode($ra));
}
}
-$s = new PhpXmlRpc\Server(array(
+// NB: take care not to output anything else after this call, as it will mess up the responses and it will be hard to
+// debug. In case you have to do so, at least re-emit a correct Content-Length http header (requires output buffering)
+
+$srv = new PhpXmlRpc\Server(array(
"discuss.addComment" => array(
"function" => "addComment",
"signature" => $addComment_sig,
"docstring" => $getComments_doc,
),
));
+
+require_once __DIR__ . "/_append.php";