/** * 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); }