Exemplo n.º 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));
 }
Exemplo n.º 2
0
    echo wcProfileGraphScore($u);
    echo '</section>';
} else {
    echo '<div class="cb"></div>' . PHP_EOL;
}
# Links
//if ( (false !== ($mod_links = GWF_Module::getModule('Links'))) && (false !== ($mod_votes = GWF_Module::getModule('Votes'))) )
if (false !== ($mod_links = GWF_Module::loadModuleDB('Links', true, true)) && false !== ($mod_votes = GWF_Module::loadModuleDB('Votes', true))) {
    //	$mod_votes->onInclude();
    //	$mod_links->onInclude();
    //	$mod_links->onLoadLanguage();
    echo wcProfileFavLinks($u, $mod_links);
    echo wcProfileOwnLinks($u, $mod_links);
}
# Challs
if (WC_Challenge::getScoreForUser($u) > 0) {
    Module_WeChall::includeForums();
    //	GWF_Module::getModule('Forum')->onInclude();
    # Profile Challs
    $method = $wechall->getMethod('ChallsProfile');
    $method instanceof WeChall_ChallsProfile;
    echo $method->templateChalls($u);
    # Created By
    if ($u->getID() !== '1') {
        $method = $wechall->getMethod('Challs');
        $method instanceof WeChall_Challs;
        echo $method->templateChalls(false, $u->getID(), '', '', '', false, false);
    }
}
# Guestbook
echo wcProfileGuestbook($u);
Exemplo n.º 3
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;
 }