Пример #1
0
 private function onHardlink()
 {
     $form = $this->formHardlink();
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     $onsitename = Common::getPost('onsitename');
     $site = $this->site;
     $user = $this->user;
     require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php';
     require_once GWF_CORE_PATH . 'module/WeChall/WC_Freeze.php';
     if (false !== WC_RegAt::getRegatRow($user->getID(), $site->getID())) {
         return $this->module->error('err_already_linked', array($site->displayName()));
     }
     if (WC_Freeze::isUserFrozenOnSite($user->getID(), $site->getID())) {
         return $this->module->error('err_site_ban', array($site->displayName()));
     }
     if (false !== ($regat = WC_RegAt::getByOnsitename($site->getID(), $onsitename))) {
         if (false === ($user = $regat->getUser())) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         } else {
             return $this->module->error('err_onsitename_taken', array(htmlspecialchars($onsitename), $site->displayName(), $user->displayUsername()));
         }
     }
     $entry = new WC_RegAt(array('regat_uid' => $user->getID(), 'regat_sid' => $site->getID(), 'regat_onsitename' => $onsitename, 'regat_onsitescore' => 0, 'regat_challcount' => 0, 'regat_options' => 0, 'regat_lastdate' => '', 'regat_linkdate' => GWF_Time::getDate(GWF_Date::LEN_DAY), 'regat_solved' => 0.0, 'regat_score' => 0, 'regat_langid' => 0, 'regat_tagbits' => 0, 'regat_onsiterank' => 0, 'regat_challsolved' => 0));
     if (false === $entry->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (0 < ($percent = $form->getVar('percent'))) {
         $new_score = round($site->getOnsiteScore() * $percent / 100);
         $site->onUpdateUserB($user, $entry, $new_score, true, true);
     }
     return $this->module->message('msg_hardlinked', array($user->displayUsername(), $site->displayName(), GWF_HTML::display($onsitename)));
 }
Пример #2
0
echo '<div class="gwf_buttons_outer"><div class="gwf_buttons">' . PHP_EOL;
echo WC_HTML::button('btn_site_details', $site->hrefDetail());
if (count($boxes) > 0) {
    echo WC_HTML::button('btn_warboxes', $site->hrefWarboxes());
}
echo WC_HTML::button('btn_ranking', $site->hrefRanking(true));
echo WC_HTML::button('btn_site_history', $site->hrefHistory());
echo '</div></div>' . PHP_EOL;
?>

<?php 
if (false === ($user = GWF_User::getByName(Common::getGet('username', '')))) {
}
if ($user !== false) {
    $userid = $user->getID();
    if (false !== ($regat = WC_RegAt::getRegatRow($userid, $siteid))) {
        $max = $site->getOnsiteScore();
        echo GWF_Box::box($tLang->lang('site_detail_uinfo', array($user->displayUsername(), $regat->getOnsiteScore(), $max, $site->displayName(), round($regat->getPercent($max), 2), WC_RegAt::calcExactSiteRank($user, $siteid), $site->calcScore($regat))));
    }
}
?>

<div class="ib"><?php 
echo GWF_Box::box(GWF_Message::display($tVars['descr']));
?>
</div>

<table>
	<thead>
		<tr>
			<th colspan="2" id="wc_site_detail_head"><?php 
Пример #3
0
 private function onFreeze()
 {
     $form = $this->formFreeze();
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     $userid = $this->user->getID();
     $siteid = $this->site->getID();
     if (WC_Freeze::isUserFrozenOnSite($userid, $siteid)) {
         return $this->module->message('msg_frozen', array($this->user->displayUsername(), $this->site->displayName()));
     }
     $old_totalscore = $this->user->getVar('user_level');
     # Is linked?
     if (false !== ($row = WC_RegAt::getRegatRow($userid, $siteid))) {
         # Unlink
         if (false === WC_RegAt::unlink($userid, $siteid)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         $this->site->increase('site_linkcount', -1);
         WC_RegAt::calcTotalscores();
         #($this->user);
     }
     # Insert event.
     $rank = WC_RegAt::calcExactRank($this->user);
     $this->user = GWF_User::getByID($userid);
     $totalscore = $this->user->getVar('user_level');
     WC_HistoryUser2::insertEntry($this->user, $this->site, 'ban', 0, $row->getOnsiteScore(), $totalscore - $old_totalscore);
     # Insert Freeze
     if (false === WC_Freeze::freezeUser($userid, $siteid)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     # All done :)
     return $this->module->message('msg_frozen', array($this->user->displayUsername(), $this->site->displayName()));
 }
Пример #4
0
 private function showSite($input)
 {
     $sitename = Common::substrUntil(substr($input, 1), ' ');
     $username = Common::substrFrom($input, ' ');
     if (false !== ($site = WC_Site::getByName($sitename))) {
     } elseif (false !== ($site = WC_Site::getByClassName($sitename))) {
     } else {
         die($this->showUsageSites());
     }
     $siteid = $site->getID();
     if (false !== ($user = GWF_User::getByName($username))) {
         if ($user->isOptionEnabled(0x10000000)) {
             die('This user is not ranked!');
         }
         $rank = WC_RegAt::calcExactSiteRank($user, $siteid);
     } elseif (false !== ($user = WC_RegAt::getUserBySiteRank($siteid, $username))) {
         $rank = (int) $username;
     } else {
         die('User Not Found on https://www.wechall.net');
     }
     //		if (false !== ($error = $this->module->isExcludedFromAPI($user))) {
     //			die($error);
     //		}
     $sitename = $site->getVar('site_name');
     $siteurl = $site->getURL();
     $userid = $user->getID();
     $username = $user->getVar('user_name');
     if (false === ($regat = WC_RegAt::getRegatRow($userid, $siteid))) {
         die(sprintf('The User %s is not linked to %s at %s', $username, $sitename, $siteurl));
     }
     $onsitescore = $regat->getOnsiteScore();
     $onsiterank = $regat->getOnsiteRank();
     $maxonsitescore = $site->getOnsiteScore();
     $percent = $regat->getVar('regat_solved') * 100;
     $points = $regat->getVar('regat_score');
     # $site->calcScore($regat);
     if ($onsiterank < 1) {
         $out = sprintf('%s completed %%%.02f on %s (%d of %d points). ' . 'On %s , %s\'s rank is unknown. ' . 'Linked to WeChall he claims rank %s, scoring %d points.', $username, $percent, $sitename, $onsitescore, $maxonsitescore, $siteurl, $username, $rank, $points);
     } else {
         $out = sprintf('%s completed %%%.02f on %s (%d of %d points). ' . 'On %s %s is at rank %s. ' . 'Linked to WeChall he claims rank %s, scoring %d points.', $username, $percent, $sitename, $onsitescore, $maxonsitescore, $siteurl, $username, $onsiterank, $rank, $points);
     }
     die($out);
 }
Пример #5
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()));
 }
Пример #6
0
 public function isUserLinked($userid)
 {
     return WC_RegAt::getRegatRow($userid, $this->getID()) !== false;
 }