示例#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
 /**
  * void Archive::setPrivate ($uid, $ts)
  * make $uid's entry with timestamp $ts private
  */
 function setPrivate($uid, $ts)
 {
     if (is_array($ts) && sizeof($ts) > 0) {
         $dbh =& Planworld::_connect();
         /* construct the query */
         if (is_string($uid)) {
             $uid = Planworld::nameToID($uid);
         } else {
             if (is_object($uid)) {
                 $uid = $uid->getUserID();
             }
         }
         $query = "UPDATE archive SET pub='N' WHERE uid={$uid} AND (posted={$ts[0]}";
         for ($i = 1; $i < sizeof($ts); $i++) {
             $query .= " OR posted={$ts[$i]}";
         }
         $query .= ")";
         /* execute the query */
         $result = $dbh->query($query);
         if (isset($result) && !DB::isError($result)) {
             if ($dbh->affectedRows() < 1) {
                 return ARCHIVE_EMPTY;
             } else {
                 $query = "UPDATE users SET archive_size_pub=archive_size_pub - 1 WHERE id={$uid}";
                 Planworld::query($query);
                 return ARCHIVE_OK;
             }
         } else {
             return ARCHIVE_ERROR;
         }
     } else {
         return Archive::_set('pub', "'N'", $uid, $ts);
     }
 }
示例#3
0
unset($planworld_url_base);
/* includes */
$_base = dirname(__FILE__) . '/';
/* if the authentication system uses $PHP_AUTH_USER (HTTP auth), the
 order of the next 2 files matters; if the auth scripts unset
 $PHP_AUTH_USER, auth.php (or its substitute) must come first in order
 for users to show up in the logs */
require_once $_base . 'config.php';
require_once $_base . 'lib/Planworld.php';
/* Amherst specific alumni conversion for new users */
/*** MUST COME BEFORE auth.php IS INCLUDED ***/
if (isset($_SESSION['note_user'])) {
    if (is_numeric(substr($_SESSION['note_user'], -2)) && !Planworld::isUser($_SESSION['note_user'])) {
        // change the user's name
        $query = "UPDATE users SET username='******'note_user'] . "' WHERE username='******'note_user'], 0, -2) . "'";
        Planworld::query($query);
    }
}
/* end Amherst specific code */
require_once 'auth.php';
require_once $_base . 'lib/Online.php';
require_once $_base . 'lib/User.php';
PEAR::setErrorHandling(PEAR_ERROR_PRINT);
/* set the random function to use (varies by database) */
if (PW_DB_TYPE == 'pgsql') {
    define('PW_RANDOM_FN', 'RANDOM()');
} else {
    if (PW_DB_TYPE == 'mysql') {
        define('PW_RANDOM_FN', 'RAND()');
    }
}
示例#4
0
文件: News.php 项目: jlodom/planworld
 function remove($list)
 {
     if (empty($list)) {
         return;
     } else {
         $dbh = Planworld::_connect();
         if (is_array($list)) {
             $query = "DELETE FROM news WHERE";
             $query .= " id=" . $list[0];
             for ($i = 1; $i < count($list); $i++) {
                 $query .= " OR id=" . $list[$i];
             }
         } else {
             $query = "DELETE FROM news WHERE id={$list}";
         }
         Planworld::query($query);
     }
 }
示例#5
0
 /**
  * int Stats::getNumArchiveEntries ()
  * Returns the number of archive entries.
  */
 function getNumArchiveEntries()
 {
     $dbh = Planworld::_connect();
     $query = "SELECT COUNT(*) AS count FROM archive";
     return (int) Planworld::query($query, 'count');
 }