Exemple #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;
 }
Exemple #2
0
    if (GWF_Session::isLoggedIn()) {
        $buttons .= GWF_Button::generic($tLang->lang('btn_pm'), $u->getPMHref());
    }
    if ($buttons !== '') {
        echo GWF_Table::rowStart();
        echo "<td colspan=\"2\" class=\"ce\">{$buttons}</td>" . PHP_EOL;
        echo GWF_Table::rowEnd();
    }
}
# Fav Sites
echo wcProfileFavSites($u->getID());
echo wcProfileFavCats($u->getID());
echo '</table>' . PHP_EOL;
echo '</div>' . PHP_EOL;
# Regats
$regats = WC_RegAt::getRegats($u->getID(), $orderby);
if (count($regats) > 0) {
    echo '<div class="oa fl">' . PHP_EOL;
    wcProfileRegats($regats, GWF_WEB_ROOT . 'index.php?mo=Profile&me=Profile&username='******'user_name') . '&by=%BY%&dir=%DIR%', $priv, isset($data['WC_HIDE_SCORE']));
    echo '</div>' . PHP_EOL;
}
# Break on jquery
if ($tVars['jquery']) {
    echo '<div class="cb"></div>' . PHP_EOL;
    return;
}
require_once GWF_CORE_PATH . 'module/WeChall/WC_HistoryUser2.php';
# Graphs and Activity
if ($u->getLevel() > 0) {
    echo wcProfileLastActivity($u, 10, $priv);
    // 	echo '<div class="cb"></div>'.PHP_EOL;
Exemple #3
0
 private function getSites()
 {
     $sitesLow = $sitesMed = $sitesHigh = $sitesNull = $sitesVersus = $sitesHave = array();
     if ($this->user1 !== false) {
         if (false === ($regats1 = WC_RegAt::getRegats($this->user1->getID()))) {
             return false;
         }
         foreach ($regats1 as $r) {
             $r instanceof WC_RegAt;
             $solved = $r->getFloat('regat_solved') * 100;
             $site = $r->getSite();
             $siteid = $site->getID();
             //Var('site_id');
             if (isset($this->sel[$siteid])) {
                 $site->setVar('sel', true);
             }
             if ($solved <= 0.0) {
                 $sitesNull[] = $site;
             } elseif ($solved < 33.3) {
                 $sitesLow[] = $site;
             } elseif ($solved < 66.59999999999999) {
                 $sitesMed[] = $site;
             } else {
                 $sitesHigh[] = $site;
             }
             $sitesHave[] = $siteid;
             ##->getVar('regat_sid');
         }
     }
     if ($this->user2 !== false) {
         if (false !== ($regats2 = WC_RegAt::getRegats($this->user2->getID()))) {
             foreach ($regats2 as $r) {
                 $siteid = $r->getVar('regat_sid');
                 $site = $r->getSite();
                 if (!in_array($siteid, $sitesHave, true)) {
                     $sitesVersus[] = $r->getSite();
                     $sitesHave[] = $siteid;
                 }
                 if (isset($this->sel[$siteid])) {
                     $site->setVar('sel', true);
                 }
             }
         }
     }
     return array('high' => $sitesHigh, 'med' => $sitesMed, 'low' => $sitesLow, 'null' => $sitesNull, 'vs' => $sitesVersus);
 }
Exemple #4
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 #5
0
 private function onUpdateAll()
 {
     $form = $this->getFormAll();
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     set_time_limit(600);
     $user = GWF_Session::getUser();
     $regats = WC_RegAt::getRegats(GWF_Session::getUserID());
     $back = '';
     foreach ($regats as $regat) {
         $site = $regat->getSite();
         $back .= $this->onUpdateB($site, $user);
     }
     return $back;
 }