Exemple #1
0
 public function getPageForSession($ipp, $user)
 {
     if ($user === false || $user->isWebspider() || $user->isOptionEnabled(0x10000000)) {
         return array(1, 1);
     }
     $rank = WC_RegAt::calcExactRank($user);
     $page = GWF_PageMenu::getPageForPos($rank, $ipp);
     return array($page, WC_RegAt::calcRank($user));
 }
Exemple #2
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));
 }
Exemple #3
0
 private function showUser(GWF_User $user, $api_key)
 {
     if (false !== ($error = $this->module->isExcludedFromAPI($user, $api_key))) {
         return $error;
     }
     $private_mode = $this->module->isAPIKeyCorrect($user, $api_key);
     require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php';
     if (false === ($regats = WC_RegAt::getRegats($user->getID(), 'regat_solved ASC'))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     require_once GWF_CORE_PATH . 'module/Forum/GWF_ForumOptions.php';
     if (false === ($fopts = GWF_ForumOptions::getUserOptions($user, false))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $unknown = GWF_HTML::lang('unknown');
     if ('0' === ($countryid = $user->getVar('user_countryid'))) {
         $country = false;
         $cname = $unknown;
         $crank = $unknown;
     } else {
         $country = GWF_Country::getByID($countryid);
         $cname = $country->displayName();
         $crank = WC_RegAt::calcExactCountryRank($user);
     }
     $back = '';
     $back .= 'Username:'******'user_name') . PHP_EOL;
     $back .= 'Country:' . $cname . PHP_EOL;
     $back .= 'Totalscore:' . $user->getVar('user_level') . PHP_EOL;
     $back .= 'GlobalRank:' . WC_RegAt::calcExactRank($user) . PHP_EOL;
     $back .= 'CountryRank:' . $crank . PHP_EOL;
     $back .= $this->contactData($user);
     $back .= 'ForumPosts:' . $fopts->getVar('fopt_posts') . PHP_EOL;
     $back .= 'ForumThanks:' . $fopts->getVar('fopt_thanks') . PHP_EOL;
     $back .= 'ForumVoteUp:' . $fopts->getVar('fopt_upvotes') . PHP_EOL;
     $back .= 'ForumVoteDown:' . $fopts->getVar('fopt_downvotes') . PHP_EOL;
     $back .= $this->regatData($user, $regats);
     if ($private_mode === true) {
         $back .= $this->privateData($user);
     }
     return $back;
 }
Exemple #4
0
 public static function insertEntry(GWF_User $user, WC_Site $site, $type, $onsitescore_new = 0, $onsitescore_old = 0, $scoregain = 0, $onsiterank = 0)
 {
     $uid = $user->getID();
     $user = GWF_User::getByID($uid);
     $max = $site->getOnsiteScore();
     $perc_new = $max <= 0 ? 0 : round($onsitescore_new / $max * 10000);
     $perc_old = $max <= 0 ? 0 : round($onsitescore_old / $max * 10000);
     $perc_gain = $perc_new - $perc_old;
     $options = 0;
     $data = $user->getUserData();
     if (isset($data['WC_NO_XSS'])) {
         $options |= self::NO_XSS;
     }
     $entry = new self(array('userhist_uid' => $uid, 'userhist_date' => time(), 'userhist_sid' => $site->getID(), 'userhist_percent' => $perc_new, 'userhist_onsitescore' => $onsitescore_new, 'userhist_rank' => WC_RegAt::calcExactRank($user), 'userhist_totalscore' => $user->getVar('user_level'), 'userhist_gain_perc' => $perc_gain, 'userhist_gain_score' => $scoregain, 'userhist_type' => $type, 'userhist_onsiterank' => $onsiterank, 'userhist_options' => $options));
     if (WECHALL_DEBUG_SCORING) {
         echo WC_HTML::message('Inserting User History entry...');
     }
     return $entry->insert();
 }
Exemple #5
0
 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()));
 }
Exemple #6
0
 private function showSites($input)
 {
     $input = substr($input, 1);
     $sitename = trim(Common::substrUntil($input, ' '));
     $username = trim(Common::substrFrom($input, ' ', ''));
     if ($username === '') {
         die($this->showUsageSites());
     }
     if (false !== ($user = GWF_User::getByName($username))) {
         if ($user->isOptionEnabled(0x10000000)) {
             die('This user is not ranked!');
         }
         $rank = WC_RegAt::calcExactRank($user);
     } elseif (false !== ($user = WC_RegAt::getUserByGlobalRank($username))) {
         $rank = (int) $username;
     } else {
         die("The user doesnt exist at https://www.wechall.net");
     }
     //		if (false !== ($error = $this->module->isExcludedFromAPI($user))) {
     //			die($error);
     //		}
     $username = $user->displayUsername();
     $regats = WC_RegAt::getRegats($user->getID(), 'regat_solved DESC');
     $sitedata = array();
     $keepthrough = 5;
     foreach ($regats as $row) {
         $perc = $row->getVar('regat_solved') * 100;
         if ($perc < 10 && $keepthrough < 0) {
             continue;
         }
         $keepthrough--;
         $sitedata[] = sprintf('%s(%.02f%%)', $this->getClassnameFromID($row->getVar('regat_sid')), $perc);
     }
     $count = count($sitedata);
     $sitedata = implode(', ', $sitedata);
     $out = sprintf('%s plays %d sites, primary: %s.', $username, count($regats), $sitedata);
     die($out);
 }
Exemple #7
0
	<div class="gwf_post_uinfo gwf_tr_<?php 
echo $trd;
?>
">
		<?php 
echo GWF_HTML::div('<span>' . $user->displayCountryFlag() . $user->displayProfileLink() . '</span>');
?>
		<?php 
echo GWF_HTML::div($user->displayTitle(), $class);
/* don't htmlspecialchars */
?>
		<?php 
if (!$user->isOptionEnabled(0x10000000)) {
    ?>
		<?php 
    echo GWF_HTML::div(WC_HTML::lang('th_rank2') . ':&nbsp;' . WC_RegAt::calcExactRank($user));
    ?>
		<?php 
}
?>
		<?php 
if (!isset($data['WC_HIDE_SCORE'])) {
    ?>
		<?php 
    echo GWF_HTML::div(WC_HTML::lang('th_totalscore') . ':&nbsp;' . $user->getVar('user_level'));
    ?>
		<?php 
}
?>
		<?php 
echo GWF_HTML::div($tLang->lang('th_postcount') . ':&nbsp;' . $opts->getPostcount());
Exemple #8
0
 private function displayBanner(GWF_User $user, $format = self::FORMAT, $bg = self::BGCOLOR, $fg = self::FGCOLOR, $size, $spacingx = 1, $spacingy = 1, $mx, $my, $divider)
 {
     $this->box_logo = new GWF_GDRect();
     $this->box_stats = new GWF_GDRect(0, 0, self::WIDTH, self::HEIGHT);
     $this->box_avatar = new GWF_GDRect();
     // 		echo $this->box_stats->toString().PHP_EOL;
     # Image
     if (false === ($image = imagecreatetruecolor(self::WIDTH, self::HEIGHT))) {
         echo GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
         return false;
     }
     # Colors
     $bg = GWF_GDColor::fromHTML($image, $bg);
     $fg = GWF_GDColor::fromHTML($image, $fg);
     # BG
     imagefilledrectangle($image, 0, 0, self::WIDTH, self::HEIGHT, $bg);
     $format2 = '';
     for ($i = 0; $i < strlen($format); $i++) {
         $c = $format[$i];
         $pos = $this->parsePos($format, $i);
         switch ($c) {
             case 'L':
                 $this->copyLogo($image, $pos);
                 break;
             case 'A':
                 $this->copyAvatar($image, $user, $pos);
                 break;
             case 'S':
                 $this->copySites($image);
                 break;
             default:
                 $format2 .= $c;
                 break;
         }
     }
     // 		echo $this->box_stats->toString().PHP_EOL;
     $text = '';
     for ($i = 0; $i < strlen($format2); $i++) {
         $c = $format2[$i];
         switch ($c) {
             case 'U':
                 $text .= $divider . $user->getVar('user_name');
                 break;
             case 'R':
                 $text .= $divider . 'Registered: ' . GWF_Time::displayAge($user->getVar('user_regdate'));
                 break;
             case 'T':
                 $text .= $divider . $this->module->langUser($user, 'th_totalscore') . ': ' . $user->getVar('user_level');
                 break;
             case 'G':
                 $text .= $divider . $this->module->langUser($user, 'th_rank2') . ': ' . WC_RegAt::calcExactRank($user);
                 break;
             case 'C':
                 $text .= $divider . $this->module->langUser($user, 'th_crank') . ': ' . WC_RegAt::calcExactCountryRank($user);
                 break;
             case 'X':
                 $text .= $divider . $this->getSignature($user);
                 break;
         }
     }
     // 		die($this->getFontPath());
     $text = substr($text, strlen($divider));
     if (!GWF_GDText::write($image, $this->getFontPath(), $this->box_stats->x, $this->box_stats->y, $text, $fg, $this->box_stats->w, $size, $spacingx, $spacingy, $mx, $my)) {
         return false;
     }
     // 		die();
     # Output
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
 }