Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 private function getSinglePageRank($cid, $ipp, $user)
 {
     # Guest or not your country
     if ($user === false || $user->getCountryID() !== $cid) {
         return array(Common::getGet('page', 1), 1);
     }
     # Requested a page, so use it
     if (false !== ($page = Common::getGet('page'))) {
         return array($page, 1);
     }
     # Oh, auto-page detection for the user!
     $rank = WC_RegAt::calcExactCountryRank($user);
     $page = GWF_PageMenu::getPageForPos($rank, $ipp);
     return array($page, $rank);
 }
Exemplo n.º 3
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);
 }