示例#1
0
文件: Send.php 项目: jlodom/planworld
 /**
  * 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);
 }
示例#2
0
function sendPost($params)
{
    $argToken =& $params[0];
    $otherPartyUsername =& $params[1];
    $sendMessage =& $params[2];
    $sendConfirm = false;
    $tokenObject = new NodeToken();
    $tokenObject->retrieveToken($argToken);
    if ($tokenObject->valid) {
        $sourceUserId = $tokenObject->uid;
        $otherPartyUid = Planworld::nameToId($otherPartyUsername);
        Send::sendMessage($sourceUserId, $otherPartyUid, $sendMessage);
        /* The sendMessage function currently has no return code, so we fake it.*/
        $sendConfirm = true;
        statusCode(201);
    } else {
        $sendConfirm = false;
        statusCode(401);
    }
    return $sendConfirm;
    /* Please see the API notes towards bottom for ways in which this function will change soon.	*/
}
示例#3
0
function xmlrpc_clientSendWrite($method_name, $params)
{
    $argToken =& $params[0];
    $otherPartyUsername =& $params[1];
    $sendMessage =& $params[2];
    $tokenObject = new NodeToken();
    $tokenObject->retrieveToken($argToken);
    $sourceUserId = $tokenObject->uid;
    $otherPartyUid = Planworld::nameToId($otherPartyUsername);
    $sendConfirm = Send::sendMessage($sourceUserId, $otherPartyUid, $sendMessage);
    return $sendConfirm;
    /* Add error checking and remote support (maybe included here), like every other routine above. */
    /* BUG: sendConfirm is empty. See if we can fix that. Probably not. */
}