示例#1
0
 /**
  * Modifies cookies already in the jar.
  */
 function edit($id, $content, $author, &$submittor, $approved = false)
 {
     $dbh = Planworld::_connect();
     $query = "UPDATE cookies SET quote='" . addslashes($content) . "', author='" . addslashes($author) . "', s_uid=";
     if (empty($submittor)) {
         $query .= '0';
     } else {
         if (is_object($submittor)) {
             $query .= $submittor->getUserID();
         } else {
             if (is_int($submittor)) {
                 $query .= $submittor;
             } else {
                 if (is_string($submittor)) {
                     $query .= Planworld::nameToID($submittor);
                 }
             }
         }
     }
     if ($approved) {
         $query .= ", approved='Y'";
     } else {
         $query .= ", approved='N'";
     }
     $query .= " WHERE id={$id}";
     Planworld::query($query);
 }
示例#2
0
 /**
  * void Snoop::process ($user, $new, $old)
  * Find new / removed snoop references in $user's plan.
  */
 function process(&$user, $new, $old)
 {
     /* find references in old plan */
     // $old_matches = Snoop::_getReferences($old);
     $dbh = Planworld::_connect();
     $old_matches = $dbh->getCol("SELECT username FROM snoop, users WHERE snoop.uid = users.id AND s_uid = {$user->getUserID()}");
     /* find references in new plan */
     $new_matches = Snoop::_getReferences($new);
     /* find differences */
     $users_to_add = Snoop::snoop_diff($new_matches[1], $old_matches);
     $users_to_del = Snoop::snoop_diff($old_matches, $new_matches[1]);
     $success = true;
     foreach ($users_to_add as $u) {
         if (strstr($u, '@')) {
             list($username, $host) = explode('@', $u);
         }
         $sid = Planworld::nameToID($u);
         if (!isset($host) && $sid > 0) {
             /* valid local user */
             $success = $success && Snoop::addReference($user->getUserID(), $sid);
         } else {
             if (isset($host) && ($node = Planworld::getNodeInfo($host))) {
                 /* remote planworld user */
                 unset($host);
                 /* JLO2 4/12/10 Required to stop permasnoops after calling remote users. */
                 if ($node['Version'] < 2) {
                     Snoop::_call($node, 'snoop.addReference', array($username, $user->getUsername() . '@' . PW_NAME));
                 } else {
                     Snoop::_call($node, 'planworld.snoop.add', array($username, $user->getUsername() . '@' . PW_NAME));
                 }
             }
         }
     }
     foreach ($users_to_del as $u) {
         if (strstr($u, '@')) {
             list($username, $host) = explode('@', $u);
         }
         $sid = Planworld::nameToID($u);
         if (!isset($host) && $sid > 0) {
             /* valid local user */
             $success = $success && Snoop::removeReference($user->getUserID(), $sid);
         } else {
             if (isset($host) && ($node = Planworld::getNodeInfo($host))) {
                 /* remote planworld user */
                 unset($host);
                 /* JLO2 4/12/10 Required to stop permasnoops after calling remote users. */
                 if ($node['Version'] < 2) {
                     Snoop::_call($node, 'snoop.removeReference', array($username, $user->getUsername() . '@' . PW_NAME));
                 } else {
                     Snoop::_call($node, 'planworld.snoop.remove', array($username, $user->getUsername() . '@' . PW_NAME));
                 }
             }
         }
     }
     return $success;
 }
示例#3
0
 /**
  * void add ($uid)
  * Adds $uid to this user's planwatch.
  */
 function add($uid)
 {
     /* no need to fill this entry, as the planwatch will probably be reloaded before it's used */
     if (is_int($uid)) {
         $query = "INSERT INTO planwatch (w_uid, uid) VALUES ({$uid}," . $this->user->getUserID() . ")";
     } else {
         $query = "INSERT INTO planwatch (w_uid, uid) VALUES (" . Planworld::nameToID($uid) . "," . $this->user->getUserID() . ")";
     }
     $this->dbh->query($query);
 }
示例#4
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);
     }
 }
示例#5
0
function xmlrpc_clearSnoop($method_name, $params)
{
    $uid =& $params[0];
    echo $uid;
    Snoop::clearReferences(Planworld::nameToID($uid));
    return true;
}