예제 #1
0
 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()));
 }
예제 #2
0
파일: Freeze.php 프로젝트: sinfocol/gwf3
 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()));
 }
예제 #3
0
파일: WC_Site.php 프로젝트: sinfocol/gwf3
 /**
  * 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);
 }