<?php echo $tVars['site_quickjump']; $headers = array(array($tLang->lang('th_userhist_date')), array($tLang->lang('th_user_name')), array($tLang->lang('th_userhist_comment'))); echo $tVars['pagemenu']; $result = $tVars['result']; $hist = new WC_HistoryUser2(false); echo GWF_Table::start(); echo GWF_Table::displayHeaders1($headers, ''); while (false !== ($row = $hist->fetch($result, GDO::ARRAY_O))) { echo GWF_Table::rowStart(); echo GWF_Table::column($row->displayDate()); echo GWF_Table::column($row->displayUser()); echo GWF_Table::column($row->displayComment()); echo GWF_Table::rowEnd(); } $hist->free($result); echo GWF_Table::end(); echo $tVars['pagemenu'];
private function onUnFreeze($data) { if (false !== ($err = GWF_Form::validateCSRF_WeakS())) { return GWF_HTML::error('WeChall', $err); } if (!is_array($data)) { return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__)); } foreach ($data as $key => $value) { break; } $data = explode(',', $key); if (count($data) !== 2) { return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__)); } $userid = intval($data[0]); $siteid = intval($data[1]); if (false === ($user = GWF_User::getByID($userid))) { return GWF_HTML::err('ERR_UNKNOWN_USER'); } if (false === ($site = WC_Site::getByID($siteid))) { return $this->module->error('err_site'); } if (WC_Freeze::isUserFrozenOnSite($userid, $siteid)) { # Unfreeze if (false === WC_Freeze::unfreezeUser($userid, $siteid)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } # Insert event. $rank = WC_RegAt::calcExactRank($user); WC_HistoryUser2::insertEntry($user, $site, 'unban'); } # Done return $this->module->message('msg_unfrozen', array($user->displayUsername(), $site->displayName())); }
private function onUnLinkSite($array) { if (false !== ($error = GWF_Form::validateCSRF_WeakS())) { return GWF_HTML::error('WeChall', $error); } if (!is_array($array)) { return ''; } // TODO: Replace with appropiate PHP function foreach ($array as $siteid => $stub) { break; } if (false === ($site = WC_Site::getByID($siteid))) { return $this->module->error('err_site'); } $user = GWF_Session::getUser(); $userid = GWF_Session::getUserID(); $old_totalscore = $user->getVar('user_level'); if (WC_Freeze::isUserFrozen($userid)) { return $this->module->error('err_frozen'); } if (false === ($regat = WC_RegAt::getRegatRow($userid, $site->getID()))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === WC_RegAt::unlink($userid, $site->getID())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $site->increase('site_linkcount', -1); WC_RegAt::calcTotalscores(); # (GWF_Session::getUser()); $user = GWF_User::getByID($userid); $new_totalscore = $user->getVar('user_level'); require_once GWF_CORE_PATH . 'module/WeChall/WC_HistoryUser2.php'; WC_HistoryUser2::insertEntry($user, $site, 'unlink', 0, $regat->getOnsiteScore(), $new_totalscore - $old_totalscore); return $this->module->message('msg_site_unlinked', array($site->displayName())); }
/** * 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(); }
/** * A score change occured for this site/regat, * thus we need to recalc all scores influenced by this site. (or skip that part on DDOS) * @param GWF_User $user * @param WC_RegAt $regat * @param int $new_score * @param boolean $recalc_scores * @param boolean $onlink * @return GWF_Result */ public function onUpdateUserB(GWF_User $user, $regat, $new_score, $recalc_scores = true, $onlink = false, $challs_solved = -1) { $old_score = $regat->getOnsiteScore(); $old_totalscore = $this->calcScore($regat); $max = $this->getOnsiteScore(); if ($max <= 0) { $solved = $old_solved = 0; } else { $solved = $new_score / $max; $old_solved = $old_score / $max; } $regat->saveVars(array('regat_solved' => $solved, 'regat_onsitescore' => $new_score, 'regat_lastdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'regat_challsolved' => $challs_solved)); if ($recalc_scores) { $this->recalcSite(); } $new_totalscore = $this->calcScore($regat); $scoregain = $new_totalscore - $old_totalscore; # Insert into User History $comment = $this->getUserHistComment($old_score, $new_score, $onlink, $scoregain); $user = GWF_User::getByID($user->getID()); require_once 'WC_HistoryUser2.php'; $type = $this->getUserHistType($old_score, $new_score, $onlink); if (false === WC_HistoryUser2::insertEntry($user, $this, $type, $new_score, $old_score, $scoregain, $regat->getVar('regat_onsiterank'))) { return new GWF_Result(GWF_HTML::lang('ERR_DATABASE', array(__FILE__, __LINE__)), true); } require_once 'WC_SiteMaster.php'; if ($solved >= 1.0) { WC_SiteMaster::markSiteMaster($user->getID(), $this->getID()); } elseif ($old_solved >= 1.0) { WC_SiteMaster::unmarkSiteMaster($user->getID(), $this->getID(), $solved); } return new GWF_Result(GWF_HTML::lang('You') . ' ' . GWF_HTML::display($comment), false); }