<?php
require_once 'XML/RPC.php';

$input = 8;
if (isset($_GET['inimagename'])) {
$params = array(new XML_RPC_Value(str_replace('+',' ',urldecode($_GET['inimagename'])), 'string'));
$msg = new XML_RPC_Message('function_agifbase64', $params);
} else if (isset($_GET['inint'])) {
$input=str_replace('+',' ',urldecode($_GET['inint']));
$params = array(new XML_RPC_Value($input, 'int'));
$msg = new XML_RPC_Message('function_times2', $params);
} else {
$params = array(new XML_RPC_Value($input, 'int'));
$msg = new XML_RPC_Message('function_times2', $params);
}

$cli = new XML_RPC_Client('/xmlrpc.php', 'rjmprogramming.com.au');
// $cli->setDebug(1);
$resp = $cli->send($msg);

if (!$resp) {
    echo 'Communication error: ' . $cli->errstr;
    exit;
}

if (!$resp->faultCode()) {
    $val = $resp->value();
    if (isset($_GET['inimagename'])) {
    echo 'Base64 output is ' . $val->scalarval() . "<br><details><summary>Base64 Data URL version of image below ...</summary><textarea>" . $val->scalarval() . "</textarea></details><br><img src='" . $val->scalarval() . "'></img>";
    } else {
    echo $input . ' times 2 is ' . $val->scalarval();
    }
} else {
    /*
     * Display problems that have been gracefully cought and
     * reported by the xmlrpc.php script.
     */
    echo 'Fault Code: ' . $resp->faultCode() . "\n";
    echo 'Fault Reason: ' . $resp->faultString() . "\n";
}
?>
