示例#1
0
文件: User.php 项目: jlodom/planworld
 /**
  * Factory
  * @param uid User to initialize
  * @public
  * @static
  * @returns User
  */
 function &factory($uid)
 {
     if (Planworld::isUser($uid) && !Planworld::isRemoteUser($uid)) {
         $temp = new User($uid);
         return $temp;
     } else {
         if (!Planworld::isUser($uid) && !strstr($uid, '@')) {
             $temp = new User($uid);
             return $temp;
         } else {
             list(, $host) = split('@', $uid);
             $nodeinfo = Planworld::getNodeInfo($host);
             $temp = new RemoteUser($uid, $nodeinfo);
             return $temp;
         }
     }
 }
示例#2
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);
 }
示例#3
0
 /**
  * string Archive::getEntry ($uid, $ts)
  * fetch an entry from $uid's archives with timestamp $ts
  */
 function getEntry($uid, $ts)
 {
     if (Planworld::isRemoteUser($uid)) {
         list($username, $host) = split('@', Planworld::idToName($uid));
         $nodeinfo = Planworld::getNodeInfo($host);
         if ($nodeinfo['Version'] >= 2) {
             return Archive::_call($nodeinfo, 'planworld.archive.get', array($username, $ts));
         }
     } else {
         return Archive::_get('content', $uid, $ts);
     }
 }