Пример #1
0
 /**
  * Send a message from $uid to $to_uid
  */
 function sendMessage($uid, $to_uid, $message)
 {
     if (Planworld::isRemoteUser($to_uid)) {
         list($to_user, $host) = split("@", Planworld::idToName($to_uid));
         $from_user = Planworld::idToName($uid) . "@" . PW_NAME;
         $nodeinfo = Planworld::getNodeInfo($host);
         // make xml-rpc call
         xu_rpc_http_concise(array('method' => 'planworld.send.sendMessage', 'args' => array($from_user, $to_user, $message), 'host' => $nodeinfo['Hostname'], 'uri' => $nodeinfo['Path'], 'port' => $nodeinfo['Port'], 'debug' => 0));
         $query = "INSERT INTO send (uid, to_uid, sent, seen, message) VALUES ({$uid}, {$to_uid}, " . mktime() . ", " . mktime() . ", '" . htmlentities(strip_tags(addslashes($message))) . "')";
     } else {
         $fwd = Planworld::getPreference($to_uid, 'send_forward');
         if ($fwd) {
             // forward the message if necessary
             $fwd_uid = Planworld::nameToId($fwd);
             error_log("forwarding to {$fwd_uid} ({$fwd})");
             if (Planworld::isRemoteUser($fwd_uid)) {
                 $fwd_message = "[fwd:" . Planworld::idToName($to_uid) . "@" . PW_NAME . "] " . $message;
                 list($to_user, $host) = split("@", $fwd);
                 if (!Planworld::isRemoteUser($uid)) {
                     $from_user = Planworld::idToName($uid) . "@" . PW_NAME;
                 } else {
                     $from_user = Planworld::idToName($uid);
                     list($f_user, $f_host) = split('@', $from_user);
                     if ($f_host == $host) {
                         $from_user = $f_user;
                     }
                 }
                 $nodeinfo = Planworld::getNodeInfo($host);
                 // make xml-rpc call
                 xu_rpc_http_concise(array('method' => 'planworld.send.sendMessage', 'args' => array($from_user, $to_user, $fwd_message), 'host' => $nodeinfo['Hostname'], 'uri' => $nodeinfo['Path'], 'port' => $nodeinfo['Port'], 'debug' => 0));
             } else {
                 $fwd_message = "[fwd:" . Planworld::idToName($to_uid) . "] " . $message;
                 Planworld::query("INSERT INTO send (uid, to_uid, sent, message) VALUES ({$uid}, {$fwd_uid}, " . mktime() . ", '" . htmlentities(strip_tags(addslashes($fwd_message))) . "')");
             }
         }
         $query = "INSERT INTO send (uid, to_uid, sent, message) VALUES ({$uid}, {$to_uid}, " . mktime() . ", '" . htmlentities(strip_tags(addslashes($message))) . "')";
     }
     Planworld::query($query);
 }
 /**
  * ruft eine XMLRPC Methode im Moodle auf 
  * @param methode
  * @param argumente - parameter	 
  * @param server debug informationen 
  *        
  * @return objekt mit den Noten der Teilnehmer dieses Kurses
  */
 public function callMoodleXMLRPC($method = null, $args = null, $debug = false)
 {
     if (is_null($method) || empty($method)) {
         $this->errormsg = "Fehler xmlrpc call - Methode fehlt";
         return false;
     }
     $moodle = new moodle();
     $moodlepfad = $moodle->getPfad('1.9');
     $host = parse_url($moodlepfad, PHP_URL_HOST);
     $path = parse_url($moodlepfad, PHP_URL_PATH);
     $port = '';
     $uri = $path . "xmlrpc/xmlrpc.php";
     // Ausgabeeinstellungen
     $output = array('encoding' => 'UTF-8');
     $result = false;
     $callspec = array('user' => isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '', 'pass' => isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '', 'method' => $method, 'host' => $host, 'port' => $port, 'uri' => $uri, 'secure' => false, 'debug' => $debug, 'args' => !is_null($args) ? $args : '', 'output' => $output);
     $result = xu_rpc_http_concise($callspec);
     if (!is_array($result)) {
         $this->errormsg = "Fehler xmlrpc call ";
         return false;
     }
     return $result;
 }
 /**
  * Checks whether a response matches a given answer using SAGE
  *
  * This method will compare the given response to the given answer using the SAGE
  * open source algebra computation software. The software is run by a remote
  * XML-RPC server which is called with both the asnwer and the response and told to
  * compare the two algebraic expressions.
  *
  * @return boolean true if the response matches the answer, false otherwise
  */
 function test_response_by_sage(&$question, &$response, $answer)
 {
     // TODO: Store server information in the Moodle configuration
     $request = array('host' => 'localhost', 'port' => 7777, 'uri' => '');
     // Sets the name of the method to call to full_symbolic_compare
     $request['method'] = 'full_symbolic_compare';
     // Get a list of all the variables to declare
     $vars = $response->get_variables();
     $vars = array_merge($vars, array_diff($vars, $answer->get_variables()));
     // Sets the arguments to the sage string of the response and the list of variables
     $request['args'] = array($answer->sage(), $response->sage(), $vars);
     // Calls the XML-RPC method on the server and returns the response
     return xu_rpc_http_concise($request) == 0;
 }
Пример #4
0
<?php

require_once "utils.php";
$options = array('output_type' => "xml", 'version' => "xmlrpc");
$result = xu_rpc_http_concise(array('method' => "multiply", 'args' => array(5, 6), 'host' => "192.168.0.1", 'uri' => "/~gnat/test/ch11/xmlrpc-server.php", 'options' => $options));
echo "5 * 6 is {$result}";
Пример #5
0
<link href='index.css' rel='stylesheet' type='text/css'>

<?php 
include_once 'utils/utils.php';
$project = $_POST['project'];
if (empty($project)) {
    echo '<h5>You need to select a project!</h5>';
    exit;
}
$aircraft = $_POST['aircraft'];
if (empty($aircraft)) {
    echo '<h5>You need to select an aircraft!</h5>';
    exit;
}
$flight = trim($_POST['flight']);
if (empty($flight)) {
    echo '<h5>You need to enter a flight number!</h5>';
    exit;
}
echo '<h4>Results from the XMLRPC call to the DSM server:</h4>';
$result = xu_rpc_http_concise(array('method' => 'SetProject', 'args' => array($project, $aircraft, $flight), 'host' => 'localhost', 'uri' => '/RPC2', 'port' => '30003', 'debug' => '0', 'output' => 'xmlrpc'));
if ($result) {
    print_r($result);
} else {
    echo "(no response)";
}
echo "<br>";
Пример #6
0
function validatePDF_2($magic, $callback_URL, $fileID, $file)
{
    global $hotdir, $max_processing_seconds, $INP, $NPDF_ERR, $NPDF, $ORIG_ERR, $ORIG_OK, $PROC_ERR, $PROC_OK, $REP_ERR, $REP_OK, $INP_absolute, $xmlrpc, $DEBUG;
    ignore_user_abort();
    // function may take a long time
    set_time_limit($max_processing_seconds + 10);
    // does not work in safe mode
    ini_set("max_execution_time", $max_processing_seconds + 10);
    // does not work in safe mode
    if ($DEBUG) {
        informAdmin("DEBUG: called validatePDF_2( {$magic}, {$callback_URL}, {$fileID}, {$file} )");
    }
    // security issue
    $file = basename($file);
    // to avoid s.th. like '../../../etc/passwd'
    // wait for pitstop to process the file
    $file_log = "{$file}_log.pdf";
    // PitStop names reports like this
    $start_time = time();
    while (file_exists(cleanPath("{$hotdir}/{$INP}/{$file}")) && $start_time + $max_processing_seconds > time()) {
        clearstatcache();
        sleep(5);
    }
    // MISCONCEPTION - PitStop removes the input file before all other files have been written to disk. Especially the Report takes longer.
    // wait for report to appear
    $report_present = false;
    while (!$report_present && $start_time + $max_processing_seconds > time()) {
        clearstatcache();
        $report_present = file_exists(cleanPath("{$hotdir}/{$REP_ERR}/{$file_log}")) || file_exists(cleanPath("{$hotdir}/{$REP_OK}/{$file_log}")) || file_exists(cleanPath("{$hotdir}/{$NPDF_ERR}/{$file_log}"));
        sleep(5);
    }
    if ($start_time + $max_processing_seconds <= time()) {
        // cleanup - not all files will be present, thus neglect warnings
        cleanup($file);
        informAdmin("validation tooks too long. PitStop server not running? HotDir is '{$hotdir}' and input folder is named '{$INP}'");
        return false;
        // validation tooks too long
    }
    sleep(5);
    // let PitStop write all files
    clearstatcache();
    $valid = 2;
    // validation was aborted
    // PitStop has removed the file, now check the result
    if (file_exists(cleanPath("{$hotdir}/{$NPDF}/{$file}"))) {
        $reportFileName = cleanPath("{$hotdir}/{$NPDF_ERR}/{$file_log}");
        $valid = false;
    }
    if (file_exists(cleanPath("{$hotdir}/{$ORIG_ERR}/{$file}"))) {
        $reportFileName = cleanPath("{$hotdir}/{$REP_ERR}/{$file_log}");
        $valid = false;
    }
    if (file_exists(cleanPath("{$hotdir}/{$ORIG_OK}/{$file}"))) {
        $reportFileName = cleanPath("{$hotdir}/{$REP_OK}/{$file_log}");
        $valid = true;
    }
    if ($valid === 2) {
        // cleanup - not all files will be present, thus neglect warnings
        cleanup($file);
        informAdmin("validation was aborted. Input file was removed, but result is not present.");
        return false;
    }
    if ($DEBUG) {
        if ($valid) {
            $temp = "pdf file is valid";
        } else {
            $temp = "file is not valid";
        }
        informAdmin("DEBUG: validation process completed.\n{$temp}");
    }
    // PitStop may produce reports with 350 pages and more. These reports can be as large as 8 MiB.
    // If pdftk (http://www.pdftk.com) is available, truncate the report; otherwise do not send, if too large
    $data = truncate_pdf($reportFileName);
    // call the callback function to announce results of validation
    $server = parse_url($callback_URL);
    $server['port'] = $server['port'] ? $server['port'] : 80;
    if ($xmlrpc['pear']) {
        // use XML_RPC impl. to contact the callback function, which in turn will commit the result to the database
        $client = new XML_RPC_Client($server['path'], $server['host'], $server['port']);
        $params = array(new XML_RPC_Value($data, 'base64'), new XML_RPC_Value($valid, 'boolean'), new XML_RPC_Value($magic, 'int'), new XML_RPC_Value($fileID, 'int'));
        $xmlrpc_message = new XML_RPC_Message('validatePDF_callback', $params);
        if ($DEBUG) {
            $client->setDebug(1);
            ob_start();
        }
        $client->send($xmlrpc_message);
        if ($DEBUG) {
            informAdmin("server reports:\n" . ob_get_contents());
            ob_end_clean();
        }
    } elseif ($xmlrpc['internal']) {
        // use internal impl. to contact the callback function, which in turn will commit the result to the database
        xmlrpc_set_type($data, "base64");
        // converts the string to an object with encoding 'base64'
        $params = array($data, $valid, $magic, $fileID);
        $output = array('output_type' => 'php');
        xu_rpc_http_concise(array(method => 'validatePDF_callback', args => $params, host => $server['host'], uri => $server['path'], port => $server['port'], debug => 0, output => $output));
    }
    if ($DEBUG) {
        informAdmin("DEBUG: callback function validatePDF_callback() at {$callback_URL} was called.");
    }
    // cleanup - not all files will be present, thus neglect warnings
    cleanup($file);
}
Пример #7
0
 /**
  * Calls a remote method via xml-rpc.
  * @param method Method to call.
  * @param params Parameters to use.
  * @private
  */
 function _call($server, $method, $params = null)
 {
     return xu_rpc_http_concise(array('method' => $method, 'args' => $params, 'host' => $server['Hostname'], 'uri' => $server['Path'], 'port' => $server['Port'], 'debug' => 0));
     // 0=none, 1=some, 2=more
 }
Пример #8
0
echo "<br>channel: " . $_POST['channel'];
echo "<br>voltage: " . $_POST['voltage'];
echo "<br>";
if ($mthd == "TestVoltage") {
    if (empty($_POST['voltage']) && $_POST['voltage'] != "0") {
        exit("<h5>You need to select a voltage</h5>')</script>");
    }
    $args = array('device' => $_POST['device'], 'channel' => $_POST['channel'], 'voltage' => $_POST['voltage']);
}
foreach ($hosts as $host) {
    $port = '30004';
    if ($host == "localhost") {
        $port = '30003';
    }
    echo "{$port} {$mthd} {$host}... ";
    $result = xu_rpc_http_concise(array('method' => $mthd, 'args' => $args, 'host' => $host, 'uri' => '/RPC2', 'port' => $port, 'debug' => '0', 'output' => 'xmlrpc'));
    if (empty($result)) {
        echo "(no response)";
    } else {
        if (is_string($result)) {
            echo $result;
        } else {
            if (is_array($result)) {
                echo "<h5>" . $result['faultString'] . "</h5>";
            } else {
                echo "unknown reponse type: " + gettype($result);
            }
        }
    }
    echo "<br>";
}
Пример #9
0
function xu_rpc_http($method, $args, $host, $uri = "/", $port = 80, $debug = false, $timeout = 0, $user = false, $pass = false, $secure = false)
{
    return xu_rpc_http_concise(array('method' => $method, 'args' => $args, 'host' => $host, 'uri' => $uri, 'port' => $port, 'debug' => $debug, 'timeout' => $timeout, 'user' => $user, 'pass' => $pass, 'secure' => $secure));
}
Пример #10
0
function remoteStat($server, $method, $params = '')
{
    return xu_rpc_http_concise(array('method' => $method, 'args' => $params, 'host' => $server['host'], 'uri' => $server['uri'], 'port' => $server['port'], 'debug' => $debug, 'output' => $output));
}
Пример #11
0
function wiki_xmlrpc_post($method, $args = null, $url = null, $auth = null)
{
    if (is_null($url)) {
        //$url = deduce_script_name();
        $url = DATA_PATH . "/RPC2.php";
        // connect to self
    }
    $debug = 0;
    $server = parse_url($url);
    if (empty($server['host'])) {
        $server['host'] = 'localhost';
    }
    if (!empty($_GET['start_debug'])) {
        $debug = 2;
    }
    if (DEBUG & _DEBUG_REMOTE) {
        // xmlrpc remote debugging
        $debug = 2;
        $server['path'] .= '?start_debug=1';
    }
    $params = array('method' => $method, 'args' => $args, 'host' => $server['host'], 'uri' => $server['path'], 'debug' => $debug, 'output' => null);
    //TODO: auth and/or session cookie
    if (isset($auth['sid'])) {
        $params['cookies'] = array(session_name() => $auth['sid']);
    }
    if (isset($auth['user'])) {
        $params['user'] = $auth['user'];
    }
    if (isset($auth['pass'])) {
        $params['pass'] = $auth['pass'];
    }
    $result = xu_rpc_http_concise($params);
    return $result;
}
Пример #12
0
function run_no_param_test($server, $debug, $output, $method)
{
    global $HTTP_GET_VARS;
    echo "<hr>";
    if (!empty($HTTP_GET_VARS['start_debug'])) {
        // zend ide support
        $server['uri'] .= "?start_debug=1";
    }
    $result = xu_rpc_http_concise(array('method' => $method, 'host' => $server['host'], 'uri' => $server['uri'], 'port' => $server['port'], 'debug' => $debug, 'output' => $output));
    if ($result && gettype($result) === "integer") {
        pass($method);
    } else {
        fail($method, false, $result);
    }
    flush();
}
Пример #13
0
<?php

$method = $args = null;
/// GET systax
if (!empty($_GET['port'])) {
    $port = $_GET['port'];
}
if (!empty($_GET['method'])) {
    $method = $_GET['method'];
}
if (!empty($_GET['args'])) {
    $args = $_GET['args'];
}
// /// POST systax (needs work...)
// global $HTTP_RAW_POST_DATA;
// if (!$HTTP_RAW_POST_DATA) {
//    exit('XML-RPC server accepts POST requests only.');
// }
// $data = $HTTP_RAW_POST_DATA;
// exit("$data");
include_once 'utils/utils.php';
$response = xu_rpc_http_concise(array('method' => $method, 'args' => $args, 'host' => 'localhost', 'uri' => '/RPC2', 'port' => $port, 'debug' => '0', 'output' => 'xmlrpc', 'nodecode' => 'true', 'timeout' => '0'));
exit("{$response}");
Пример #14
0
function ident($server, $debug = 0, $output = null)
{
    $method = "interopEchoTests.whichToolkit";
    $result = xu_rpc_http_concise(array('method' => $method, 'host' => $server['host'], 'uri' => $server['uri'], 'port' => $server['port'], 'debug' => $debug, 'output' => $output));
    if ($result && $result['toolkitDocsUrl'] && !$result['faultCode']) {
        pass($method);
        echo "<br>";
        foreach ($result as $key => $value) {
            if (substr($value, 0, 7) === "http://") {
                $value = "<a href='{$value}'>{$value}</a>";
            }
            echo "<b>{$key}:</b> {$value}<br>";
        }
    } else {
        fail($method, false, $result);
    }
}
Пример #15
0
 function call($function, $arguments, &$return)
 {
     $requestprms['host'] = $this->urlparts['host'];
     $requestprms['port'] = $this->urlparts['port'];
     $requestprms['uri'] = $this->urlparts['path'];
     $requestprms['method'] = $function;
     $requestprms['args'] = $arguments;
     $requestprms['debug'] = 0;
     $requestprms['timeout'] = 0;
     $requestprms['user'] = NULL;
     $requestprms['pass'] = NULL;
     $requestprms['secure'] = 0;
     $result = xu_rpc_http_concise($requestprms);
     if (is_array($result) && isset($result['faultCode'])) {
         print 'Error in xmlrpc call \'' . $function . '\'' . "\n";
         print '  code  : ' . $result['faultCode'] . "\n";
         print '  message: ' . $result['faultString'] . "\n";
         return false;
     }
     $return = $result;
     return true;
 }
Пример #16
0
function xu_rpc_http($method, $args, $host, $uri = "/", $port = 80, $debug = false, $timeout = 0, $user = false, $pass = false, $secure = false)
{
    return xu_rpc_http_concise(array(method => $method, args => $args, host => $host, uri => $uri, port => $port, debug => $debug, timeout => $timeout, user => $user, pass => $pass, secure => $secure));
}
Пример #17
0
                 document.location.hostname == "192.168.84.1" ||
                 document.location.hostname == "192.168.184.1" ||
                 document.location.hostname == "acserver" ||
                 document.location.hostname == "acserver.raf.ucar.edu" ||
                 document.location.hostname == "hyper.guest.ucar.edu");

if (is_periodic == false)
  document.title = document.title + " (static page)";
</script>

<?php 
include_once 'utils/utils.php';
//-- ----------------------------------------------------------------------- -->
//-- Query the dsm_server for a list of DSM names and locations.             -->
//-- ----------------------------------------------------------------------- -->
$dsmList = xu_rpc_http_concise(array('method' => 'GetDsmList', 'args' => '', 'host' => 'localhost', 'uri' => '/RPC2', 'port' => '30003', 'debug' => '0', 'output' => 'xmlrpc'));
// TODO - see if xu_rpc_http_concise provides any status variables to test here instead.
if ($dsmList == "") {
    exit("<h5>DSM server not responding!</h5>");
}
// measure the size of the DSM list
$nDSMs = 0;
$maxLen = 0;
foreach ($dsmList as $key => $val) {
    $nDSMs++;
    if ($maxLen < strlen($val)) {
        $maxLen = strlen($val);
    }
}
if ($maxLen < 10) {
    $maxLen = 10;