Example #1
0
 private function outputScore($username)
 {
     if (false === ($user = GWF_User::getByName($username))) {
         die('Unknown User');
     }
     if (false === ($site = WC_Site::getWeChall())) {
         die('Unknown Site');
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php';
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     $score = WC_Challenge::getScoreForUser($user);
     $maxscore = WC_Challenge::getMaxScore();
     $challs_solved = WC_ChallSolved::getChallsSolvedForUser($user);
     $challcount = WC_Challenge::getChallCount();
     $usercount = GDO::table('GWF_User')->countRows();
     $rank = WC_RegAt::calcExactRank($user);
     die(sprintf('%d:%s:%s:%s:%s:%s', $rank, $score, $maxscore, $challs_solved, $challcount, $usercount));
 }
Example #2
0
 private static function installSiteWeChall(Module_WeChall $module)
 {
     if (false !== ($site = WC_Site::getWeChall())) {
         return '';
     }
     $options = WC_Site::AUTO_UPDATE;
     $site = new WC_Site(array('site_id' => 1, 'site_status' => WC_Site::UP, 'site_name' => 'WeChall', 'site_classname' => 'WC', 'site_logo_v' => 0, 'site_country' => 0, 'site_language' => GWF_Language::getEnglish()->getID(), 'site_joindate' => '20080218000000', 'site_launchdate' => '20080218', 'site_authkey' => 'iusdgsdgsiog3!s', 'site_xauthkey' => 'rw98t693g!9sg', 'site_irc' => 'irc://irc.idlemonkeys.net#wechall', 'site_url' => 'http://' . GWF_DOMAIN . GWF_WEB_ROOT, 'site_url_mail' => 'index.php?mo=WeChall&me=CrossSite&link=%USERNAME%&email=%EMAIL%&no_session=yes', 'site_url_score' => 'index.php?mo=WeChall&me=CrossSite&score=%USERNAME%&no_session=yes', 'site_url_profile' => 'profile/%USERNAME%', 'site_score' => 0, 'site_basescore' => 10000, 'site_avg' => 0.0, 'site_dif' => 3.0, 'site_fun' => 3.0, 'site_vote_dif' => 0, 'site_vote_fun' => 0, 'site_maxscore' => 0, 'site_challcount' => 0, 'site_usercount' => 0, 'site_linkcount' => 0, 'site_visit_in' => 0, 'site_visit_out' => 0, 'site_options' => $options, 'site_tags' => 'Exploit,Programming,Stegano,Crypto', 'site_boardid' => 0, 'site_threadid' => 0, 'site_tagbits' => 0, 'site_color' => '0000FF'));
     if (false === $site->onCreateSite($module, $back)) {
         return $back;
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php';
     if (false === WC_SiteDescr::insertDescr($site->getID(), 1, 'Please edit me :)')) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '';
 }
Example #3
0
 public function hookRenameUser(GWF_User $user, array $args)
 {
     list($oldname, $newname) = $args;
     $newname = GDO::escape($newname);
     $uid = $user->getID();
     $sid = WC_Site::getWeChall()->getID();
     return GDO::table('WC_RegAt')->update("regat_onsitename='{$newname}'", "regat_uid={$uid} AND regat_sid={$sid}");
 }
Example #4
0
 private function onDelete(WC_Challenge $chall)
 {
     if (false === $chall->onDelete()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $wc = WC_Site::getWeChall();
     $wc->recalcSite();
     return $this->module->message('msg_chall_deleted');
 }
Example #5
0
 public static function displayMenuChallengesNSC(Module_WeChall $module)
 {
     $sel = $module->isMethodSelected('Sites') ? ' class="wc_menu_sel"' : '';
     $href = WC_Site::getWeChall()->hrefWarboxes();
     return '<li><a' . $sel . ' href="' . $href . '">' . $module->lang('menu_challs') . '</a></li>';
 }
Example #6
0
    echo gwfProfileRow($tLang->lang('th_user_avatar'), $u->displayAvatar());
}
if ($u->hasCountry()) {
    echo gwfProfileRow($tLang->lang('th_user_country'), $u->displayCountryFlag(true));
}
echo gwfProfileRow($tLang->lang('th_user_name'), $u->displayUsername());
if (isset($data['WC_HIDE_SCORE'])) {
    echo gwfProfileRow(WC_HTML::lang('th_score'), $wechall->lang('hidden'));
} else {
    echo gwfProfileRow(WC_HTML::lang('th_score'), GWF_HTML::anchor(WC_Site::getWeChall()->hrefRanking(), $u->getVar('user_level')));
}
if (isset($data['WC_HIDE_RANK'])) {
    echo gwfProfileRow(WC_HTML::lang('th_rank2'), $wechall->lang('hidden'));
} else {
    $rank = WC_RegAt::calcRank($u);
    echo gwfProfileRow(WC_HTML::lang('th_rank2'), GWF_HTML::anchor(WC_Site::getWeChall()->hrefRanking(), $rank));
}
// if ($u->getVar('user_countryid') !== '0') {
// 	if (isset($data['WC_HIDE_RANK'])) {
// 		echo gwfProfileRow(WC_HTML::lang('th_crank'), $wechall->lang('hidden'));
// 	} else {
// 		$cRank = WC_Regat::calcCountryRank($u);
// 		$href_crank = GWF_WEB_ROOT.'country_ranking/player/'.$u->urlencode2('user_name').'#rank_'.$cRank;
// 		echo gwfProfileRow(WC_HTML::lang('th_crank'), GWF_HTML::anchor($href_crank, $cRank));
// 	}
// }
echo gwfProfileRow($tLang->lang('th_registered'), GWF_Time::displayDate($u->getVar('user_regdate')));
if ($u->isOptionEnabled(GWF_User::HIDE_ONLINE)) {
    $lastactivity = GWF_HTML::lang('unknown');
} else {
    $lastactivity = GWF_Time::displayTimestamp($u->getVar('user_lastactivity'));
Example #7
0
 /**
  * Wechall internally bot response.
  * The advantage over the other method is accurate challcount.
  * @param string $input
  * @return string
  */
 public function wechallChalls($input)
 {
     if ($input === '') {
         return sprintf('Try wechallchalls.php?userame=blub');
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     $wechall = WC_Site::getWeChall();
     $siteid = $wechall->getID();
     if (false !== ($user = GWF_User::getByName($input))) {
         if ($user->isOptionEnabled(0x10000000)) {
             die('This user is not ranked!');
         }
         $rank = WC_RegAt::calcExactSiteRank($user, $siteid);
     } elseif (false !== ($user = WC_RegAt::getUserBySiteRank($siteid, $input))) {
         $rank = intval($input);
     } else {
         return sprintf('The user does not exist.');
     }
     //		if (false !== ($error = $this->module->isExcludedFromAPI($user))) {
     //			return $error;
     //		}
     $userid = $user->getID();
     $username = $user->displayUsername();
     $solvedCount = WC_ChallSolved::getSolvedCount($userid);
     $score = WC_Challenge::getScoreForUser($user);
     $challcount = WC_Challenge::getChallCount();
     $maxScore = WC_Challenge::getMaxScore();
     $percent = $score / $maxScore * 100;
     $out = sprintf('%s solved %d of %d Challenges with %d of %d possible points (%.02f%%).', $username, $solvedCount, $challcount, $score, $maxScore, $percent);
     if ($rank !== false) {
         $out .= sprintf(' Rank for the site WeChall: %d', $rank);
     }
     return $out;
 }
Example #8
0
<?php

$module = $tVars['module'];
echo '<nav id="gwf_foot_menu">' . PHP_EOL . '<a href="' . GWF_WEB_ROOT . 'news">' . $module->lang('menu_news') . '</a>' . PHP_EOL . '| <a href="' . GWF_WEB_ROOT . 'ranking">' . $module->lang('menu_ranking') . '</a>' . PHP_EOL . '| <a href="' . WC_Site::getWeChall()->hrefWarboxes() . '">' . $module->lang('menu_challs') . '</a>' . PHP_EOL . '| <a href="' . GWF_WEB_ROOT . 'contact">' . $module->lang('menu_contact') . '</a>' . PHP_EOL . '</nav>' . PHP_EOL;