Example #1
0
 public static function mark(GWF_User $user, GWF_Links $link, $bool)
 {
     $userid = $user->getID();
     $linkid = $link->getID();
     $is_fav = self::table(__CLASS__)->getRow($userid, $linkid) !== false;
     if ($is_fav === $bool) {
         return true;
     }
     $row = new self(array('lf_uid' => $userid, 'lf_lid' => $linkid));
     if ($bool) {
         if (!$row->replace()) {
             return false;
         }
     } else {
         if (!$row->delete()) {
             return false;
         }
     }
     if (false === $link->increase('link_favcount', $bool ? 1 : -1)) {
         return false;
     }
     if (false === $link->onCalcPopularity()) {
         return false;
     }
     return true;
 }
Example #2
0
 /**
  * Someone requested chat stuff.
  * @param Module_Chat $module
  * @return unknown_type
  */
 public static function onRequest(Module_Chat $module)
 {
     //		GWF_ChatMsg::cleanupTable($module);
     $time = time();
     $sessid = GWF_Session::getSessID();
     if (false === ($nick = $module->getNickname())) {
         $nick = self::getRandomNickS($sessid);
     }
     $table = self::table(__CLASS__);
     if (false === ($row = $table->getRow($sessid))) {
         # Unknown row
         $row = new self(array('chaton_sessid' => $sessid, 'chaton_name' => $nick, 'chaton_timejoin' => $time, 'chaton_timeaccess' => $time));
         $row->replace();
     } else {
         if ($row->getVar('chaton_timeleft') > 0) {
             $row->saveVars(array('chaton_timejoin' => $time, 'chaton_timeaccess' => $time, 'chaton_timeleft' => 0));
         } else {
             if ($row->getVar('chaton_name') !== $nick) {
                 $row->saveVars(array('chaton_timeleft' => $time));
                 $row = new self(array('chaton_sessid' => $sessid, 'chaton_name' => $nick, 'chaton_timejoin' => $time, 'chaton_timeaccess' => $time));
                 $row->replace();
             } else {
                 $row->saveVars(array('chaton_timeaccess' => $time));
             }
         }
     }
     self::cleanupTable($module);
     return '';
 }
Example #3
0
 public static function getOrCreateByServer(Dog_Server $server)
 {
     if (false !== ($stats = self::getByServer($server))) {
         return $stats;
     }
     $stats = new self(array('dis_sid' => $server->getID(), 'dis_ip' => NULL, 'dis_software' => NULL, 'dis_max_users' => '0', 'dis_max_chans' => '0', 'dis_created_at' => NULL));
     return $stats->replace() ? $stats : false;
 }
Example #4
0
 public static function addTag($linkid, $tagid)
 {
     $maprow = new self(array('ltm_lid' => $linkid, 'ltm_ltid' => $tagid));
     if (false === $maprow->replace()) {
         return false;
     }
     return $maprow;
 }
Example #5
0
 public static function createPeak($cid, $count = 0, $options = 0)
 {
     $peak = new self(array('lcpeak_cid' => $cid, 'lcpeak_peak' => $count, 'lcpeak_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'lcpeak_options' => 0));
     if (false === $peak->replace()) {
         return false;
     }
     return $peak;
 }
Example #6
0
 public static function createStats(SR_Player $player)
 {
     $stats = new self(array('sr4ps_pid' => $player->getID(), 'sr4ps_i_looted' => 0, 'sr4ps_i_sold' => 0, 'sr4ps_i_bought' => 0, 'sr4ps_i_dropped' => 0, 'sr4ps_i_given' => 0, 'sr4ps_i_received' => 0, 'sr4ps_ny_loot' => 0, 'sr4ps_ny_spent' => 0, 'sr4ps_ny_income' => 0, 'sr4ps_ny_given' => 0, 'sr4ps_ny_received' => 0, 'sr4ps_kill_mob' => 0, 'sr4ps_kill_npc' => 0, 'sr4ps_kill_human' => 0, 'sr4ps_kill_runner' => 0));
     if (false === $stats->replace()) {
         return false;
     }
     return $stats;
 }
Example #7
0
 public static function createChannelRecord(Dog_Channel $channel)
 {
     $row = new self(array('dqj_cid' => $channel->getID(), 'dqj_sid' => $channel->getVar('chan_sid'), 'dqj_uid' => 0, 'dqj_duration' => 9999.999900000001, 'dqj_date_quit' => str_repeat('0', 14), 'dqj_date_join' => str_repeat('0', 14), 'dqj_options' => 0));
     if (false === $row->replace()) {
         return false;
     }
     return $row;
 }
Example #8
0
 public static function setFavorite($userid, $siteid, $bool)
 {
     $entry = new self(array('sitefav_uid' => $userid, 'sitefav_sid' => $siteid));
     if ($bool === true) {
         return $entry->replace();
     } else {
         return $entry->delete();
     }
 }
Example #9
0
 private static function createPMOptions(GWF_User $user)
 {
     $row = new self(array('pmo_uid' => $user->getVar('user_id'), 'pmo_options' => 0, 'pmo_auto_folder' => 0, 'pmo_signature' => '', 'pmo_level' => 0));
     if (false === $row->replace()) {
         return false;
     }
     //		$row->setVar('pmo_uid', $user);
     return $row;
 }
Example #10
0
 /**
  * @param $userid int
  * @param $type string
  * @param $data string
  * @return string new token
  */
 public static function createToken($userid, $type, $data = false)
 {
     $token = GWF_Random::randomKey(self::TOKEN_LENGTH);
     $gdodata = array('userid' => $userid, 'type' => $type, 'token' => $token, 'timestamp' => time());
     if (is_string($data)) {
         $gdodata['data'] = $data;
     }
     $ac = new self($gdodata);
     return false === $ac->replace() ? false : $token;
 }
Example #11
0
 /**
  * Get a comments thread.
  * @param string $key
  * @param int $uid
  * @param int $gid
  * @param int $options
  * @return GWF_Comments
  */
 public static function getOrCreateComments($key, $uid = 0, $gid = 0, $options = self::DEFAULT_OPTIONS)
 {
     if (false !== ($c = self::getComments($key))) {
         return $c;
     }
     $c = new self(array('cmts_id' => '0', 'cmts_key' => $key, 'cmts_uid' => $uid, 'cmts_gid' => $gid, 'cmts_count' => 0, 'cmts_thx' => 0, 'cmts_up' => 0, 'cmts_down' => 0, 'cmts_options' => $options));
     if (false === $c->replace()) {
         return false;
     }
     return $c;
 }
Example #12
0
 private static function createByPath($fullpath)
 {
     if (!is_file($fullpath) || !is_readable($fullpath)) {
         return $fullpath;
     }
     $file = new self(array('lf_name' => $fullpath, 'lf_rev' => 0, 'lf_editor' => 0, 'lf_editat' => 0, 'lf_size' => filesize($fullpath), 'lf_data' => file_get_contents($fullpath)));
     if (false === $file->replace()) {
         return false;
     }
     return $file;
 }
Example #13
0
 public static function insertNote(GWF_User $user, $note)
 {
     # no empty notes
     if ($note === '') {
         return false;
     }
     # insert it
     $entry = new self(array('accrm_uid' => $user->getVar('user_id'), 'accrm_note' => $note));
     if (false === $entry->replace()) {
         return false;
     }
     return $note;
 }
Example #14
0
 public static function getLevel(WC_Warbox $box, $level)
 {
     $boxid = $box->getID();
     $elevel = self::escape($level);
     if (false !== ($chall = self::table(__CLASS__)->selectFirstObject('*', "wc_boxid={$boxid} AND wc_level='{$elevel}'", '', '', NULL))) {
         return $chall;
     }
     $chall = new self(array('wc_id' => '0', 'wc_boxid' => $boxid, 'wc_level' => $level, 'wc_score' => '1', 'wc_solvers' => '0', 'wc_created_at' => GWF_Time::getDate(), 'wc_last_solved_at' => NULL, 'wc_last_solved_by' => NULL));
     if (!$chall->replace()) {
         return false;
     }
     return $chall;
 }
Example #15
0
 public static function setWatching(GWF_ForumThread $thread, $cut)
 {
     $tid = $thread->getID();
     # Insert current spectator
     //		GDO::table(__CLASS__);
     $row = new self(array('fowa_sess' => GWF_Session::getSessID(), 'fowa_time' => time(), 'fowa_tid' => $tid));
     if (false === $row->replace()) {
         return false;
     }
     # Delete old
     $cut = time() - $cut;
     if (false === $row->deleteWhere("fowa_time<{$cut}")) {
         return false;
     }
     # Set new amount
     if (false === $thread->saveVar('thread_watchers', $row->countRows("fowa_tid={$tid}"))) {
         return false;
     }
     return true;
 }
Example #16
0
 public static function setGreetMsg(Dog_Server $server, Dog_Channel $channel, $message)
 {
     $msg = new self(array('dgm_cid' => $channel->getID(), 'dgm_msg' => $message, 'dgm_options' => self::ENABLED | self::MODE_CHAN));
     return $msg->replace();
 }
Example #17
0
 private static function _getWarToken($uid)
 {
     $token = new self(array('wt_uid' => $uid, 'wt_token' => self::randomWarToken(), 'wt_date' => GWF_Time::getDate(14)));
     return $token->replace() ? $token : false;
 }
Example #18
0
 public static function createSolvedRow($userid, $challid)
 {
     $back = new self(array('csolve_uid' => $userid, 'csolve_cid' => $challid, 'csolve_date' => '', 'csolve_1st_look' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'csolve_viewcount' => 1, 'csolve_options' => 0, 'csolve_time_taken' => 0, 'csolve_tries' => 0));
     return $back->replace() !== false ? $back : false;
 }
Example #19
0
 /**
  * Set a counter to a fixed value.
  * @param string $key
  * @param int $value
  * @return boolean
  */
 public static function saveCounter($key, $value)
 {
     $row = new self(array('count_key' => $key, 'count_value' => $value));
     return $row->replace();
 }
Example #20
0
 public static function collect($ip)
 {
     $entry = new self(array('ptip_ip' => $ip, 'ptip_time' => GWF_Time::getDate(GWF_Date::LEN_HOUR)));
     return $entry->replace();
 }
Example #21
0
 /**
  * Create a clean profile.
  * @param int $userid
  * @return GWF_Profile
  */
 private static function createProfile($userid)
 {
     $profile = new self(array('prof_uid' => $userid, 'prof_views' => 0, 'prof_about_me' => '', 'prof_options' => 0, 'prof_website' => '', 'prof_level_all' => 0, 'prof_level_contact' => 0, 'prof_firstname' => '', 'prof_lastname' => '', 'prof_street' => '', 'prof_zip' => '', 'prof_city' => '', 'prof_tel' => '', 'prof_mobile' => '', 'prof_icq' => '', 'prof_msn' => '', 'prof_jabber' => '', 'prof_skype' => '', 'prof_yahoo' => '', 'prof_aim' => '', 'prof_irc' => '', 'prof_poi_score' => 0));
     if (false === $profile->replace()) {
         return false;
     }
     return $profile;
 }
Example #22
0
 public static function getWarchall(WC_Warbox $box, $level)
 {
     $boxid = $box->getID();
     $elevel = self::escape($level);
     if (false !== ($chall = self::table(__CLASS__)->selectFirstObject('*', "wf_wbid={$boxid} AND wf_title='{$elevel}'", '', '', NULL))) {
         return $chall;
     }
     $chall = new self(array('wf_id' => '0', 'wf_wbid' => $boxid, 'wf_order' => self::getNextOrder($box), 'wf_cat' => 'exploit', 'wf_score' => '1', 'wf_solvers' => '0', 'wf_title' => $level, 'wf_url' => '', 'wf_authors' => '', 'wf_status' => 'up', 'wf_login' => '', 'wf_flag_enc' => NULL, 'wf_created_at' => GWF_Time::getDate(), 'wf_last_solved_at' => NULL, 'wf_last_solved_by' => NULL, 'wf_options' => self::WARCHALL));
     if (!$chall->replace()) {
         return false;
     }
     return $chall;
 }
Example #23
0
 /**
  * Mark a user as a site-master. Return true on success; false on DB error.
  * @param int $userid
  * @param int $siteid
  * @return boolean
  */
 public static function markSiteMaster($userid, $siteid)
 {
     if (false === ($row = WC_HistoryUser2::getFirstRow($userid, $siteid))) {
         return false;
     }
     if (self::isSiteMaster($userid, $siteid)) {
         if (WECHALL_DEBUG_SCORING) {
             echo GWF_HTML::message('WeChall', 'Was already a Site Master!');
         }
         return true;
     }
     $entry = new self(array('sitemas_uid' => $userid, 'sitemas_sid' => $siteid, 'sitemas_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND, WC_HistoryUser2::getMasterDate($userid, $siteid)), 'sitemas_firstdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND, $row->getVar('userhist_date')), 'sitemas_startperc' => $row->getVar('userhist_percent'), 'sitemas_currperc' => '1', 'sitemas_options' => self::IS_NEW));
     if (WECHALL_DEBUG_SCORING) {
         echo GWF_HTML::message('WeChall', 'Reached Site Master!');
     }
     return $entry->replace();
 }
Example #24
0
 public static function makeSiteAdmin($userid, $siteid)
 {
     $entry = new self(array('siteadmin_uid' => $userid, 'siteadmin_sid' => $siteid));
     return $entry->replace();
 }
Example #25
0
 public static function subscribe($userid, $threadid)
 {
     $sub = new self(array('subscr_uid' => $userid, 'subscr_tid' => $threadid));
     return $sub->replace();
 }
 public static function listenToFilterSlotContent(sfEvent $event, $content)
 {
     $replacer = new self($event->getSubject()->getContentRenderedFor());
     return $replacer->replace($content);
 }
Example #27
0
 public static function addToCat($siteid, $cat)
 {
     $entry = new self(array('sitecat_name' => $cat, 'sitecat_sid' => $siteid));
     return $entry->replace();
 }
Example #28
0
 /**
  * Create a new options row.
  * @param unknown_type $userid
  * @return GWF_ForumOptions
  */
 private static function createOptions($userid)
 {
     $row = new self(array('fopt_uid' => $userid, 'fopt_token' => GWF_Random::randomKey(GWF_Random::TOKEN_LEN), 'fopt_subscr' => self::SUBSCRIBE_NONE, 'fopt_signature' => '', 'fopt_options' => 0, 'fopt_thanks' => 0, 'fopt_upvotes' => 0, 'fopt_downvotes' => 0, 'fopt_posts' => 0));
     if (false === $row->replace()) {
         return false;
     }
     return $row;
 }
Example #29
0
 private static function store($userid, $groupid, $type)
 {
     $entry = new self(array('ugi_uid' => $userid, 'ugi_gid' => $groupid, 'ugi_type' => $type, 'ugi_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)));
     return $entry->replace();
 }
Example #30
0
 public static function ignore($userid, $userid_ignored, $reason = NULL)
 {
     $row = new self(array('pmi_uid' => $userid, 'pmi_uid_ignore' => $userid_ignored, 'pmi_reason' => $reason));
     return $row->replace();
 }