Exemplo n.º 1
0
function snoop_remove_xmlrpc($rpcuser, $host, $remote = 0)
{
    if ($remote == FALSE) {
        $snoop_setter = $_SERVER['USER'];
    } else {
        $snoop_setter = $remote;
    }
    $hostinfo = planworld_node_getinfo($host);
    $f = new xmlrpcmsg('planworld.snoop.remove');
    $f->addParam(new xmlrpcval($rpcuser, "string"));
    $f->addParam(new xmlrpcval($snoop_setter . "@planwatch.org", "string"));
    $c = new xmlrpc_client($hostinfo["directory"], $hostinfo["server"], $hostinfo["port"]);
    $c->setDebug(0);
    $r = $c->send($f);
    if (!$r) {
        $success = FALSE;
    } else {
        $v = $r->value();
        if (!$r->faultCode()) {
            if ($v->kindOf() == 'array') {
                $success = TRUE;
            }
        } else {
            $success = FALSE;
        }
    }
    // If the snoop remove failed for any reason, add it to the queue
    // for later sending. This is done by creating a TIMECODE.remsnoop file in
    // FILE_ROOT/stats which gets picked up by the queue processor in pt.php
    if ($success == FALSE) {
        $queue_array = array("snoop_setter" => $snoop_setter, "snoop_target" => $rpcuser, "snoop_host" => $host);
        file_put_contents("{$_SERVER['FILE_ROOT']}/stats/" . array_sum(explode(" ", microtime())) . ".remsnoop", serialize($queue_array));
    }
    return $success;
}
function plan_get_last_update_crossnode($nodeplanusers, $node)
{
    foreach ($nodeplanusers as $i => $plan) {
        $nodeplanusers[$i] = str_replace('@neon.note.amherst.edu', '', trim($nodeplanusers[$i]));
        $nodeplanusers[$i] = str_replace('@note.amherst.edu', '', trim($nodeplanusers[$i]));
        $xmlarray[$i] = new xmlrpcval($nodeplanusers[$i], 'string');
    }
    $sendarray = new xmlrpcval($xmlarray, "array");
    unset($nodeplanusers);
    unset($xmlarray);
    $f = new xmlrpcmsg('users.getLastUpdate');
    $f->addParam($sendarray);
    $nodeinfo = planworld_node_getinfo($node);
    $c = new xmlrpc_client($nodeinfo['directory'], $nodeinfo['server'], $nodeinfo['port']);
    $c->setDebug(0);
    $r = $c->send($f, 0.1);
    if (!$r) {
        foreach ($nodeplanusers as $i => $plan) {
            $outlist_times["{$plan}{$node}"] = -1;
        }
    } else {
        if (!$r->faultCode()) {
            $nodeplantimes = xmlrpc_decode($r->value());
        }
    }
    if (!$nodeplantimes) {
        $nodeplantimes = array();
    }
    foreach ($nodeplantimes as $i => $time) {
        $outlist_times["{$i}{$node}"] = $time;
    }
    return $outlist_times;
}
Exemplo n.º 3
0
function planworld_xmlrpc_query($node, $message, $params, $debug = FALSE)
{
    $nodeinfo = planworld_node_getinfo($node);
    $f = new xmlrpcmsg($message);
    //		echo "<hr>";
    foreach ($params as $param) {
        if (is_int($param)) {
            $type = "int";
        }
        if (is_string($param)) {
            $type = "string";
        }
        if (is_array($param)) {
            $type = "array";
            if (!isset($param[count($param) - 1])) {
                $type = "struct";
            }
        }
        if (is_bool($param)) {
            $type = xmlrpcBoolean;
        }
        $f->addParam(new xmlrpcval($param, $type));
        //print_r($f);
        //echo "$param : $type<br/>";
        //echo "<hr>";
    }
    $c = new xmlrpc_client($nodeinfo["directory"], $nodeinfo["server"], $nodeinfo["port"]);
    $c->setDebug(FALSE);
    $r = $c->send($f);
    if (!$r) {
        $returnval = "<div class='alert'>{$message} to {$node} failed on send().</div>";
    } else {
        $v = $r->value();
        if (!$r->faultCode()) {
            if ($v->kindOf() == 'scalar') {
                $returnval = $v->scalarval();
            }
        } else {
            if ($debug) {
                $returnval = "Fault: ";
                $returnval .= "Code: " . $r->faultCode() . " Reason '" . $r->faultString() . "'<br/>";
            }
        }
    }
    return $returnval;
}
Exemplo n.º 4
0
function plan_read_xmlrpc($remoteuser = '******', $remotenode = '@note')
{
    if ($nodeinfo = planworld_node_getinfo($remotenode)) {
        if ($_SERVER['USERINFO_ARRAY']['snitchlevel']) {
            $snitch = 1;
        }
        if (!$_SERVER['USER'] || $_SERVER['USER'] == 'guest') {
            output('unauthorized', "you can't read offsite plans if you're not logged in.");
            exit;
        }
        $f = new xmlrpcmsg('planworld.plan.getContent');
        $f->addParam(new xmlrpcval($remoteuser, "string"));
        $f->addParam(new xmlrpcval($_SERVER['USER'] . "@planwatch.org", "string"));
        $f->addParam(new xmlrpcval($snitch, "boolean"));
        $c = new xmlrpc_client($nodeinfo["directory"], $nodeinfo["server"], $nodeinfo["port"]);
        $c->setDebug(0);
        $r = $c->send($f);
        if (!$r) {
            $plan = "<div class='alert'>Could not retrieve {$remoteuser}'s plan from {$nodeinfo['server']}.</div>";
        } else {
            $v = $r->value();
            if (!$r->faultCode()) {
                if ($v->kindOf() == 'scalar') {
                    $plan = WrapWords($v->scalarval(), 80);
                }
            } else {
                $plan = "Fault: ";
                $plan .= "Code: " . $r->faultCode() . " Reason '" . $r->faultString() . "'<br/>";
            }
        }
    } else {
        $plan = plan_read_finger($remoteuser . $remotenode);
    }
    if (strstr($plan, 'plan is not available')) {
        $plan = "{$remoteuser}@{$remotenode} does not allow plan reads outside {$nodeinfo['server']}.<br />You can still <a href='/send/{$remoteuser}{$remotenode}'>send a message</a> if you want to establish contact.";
    }
    return $plan;
}