public static function insertEntry(GWF_User $user, WC_Site $site, $onsitescore, $comment) { $user = GWF_User::getByID($user->getID()); $max = $site->getOnsiteScore(); $perc = $max <= 0 ? 0 : round($onsitescore / $max * 10000); $entry = new self(array('userhist_uid' => $user->getVar('user_id'), 'userhist_date' => time(), 'userhist_sid' => $site->getVar('site_id'), 'userhist_percent' => $perc, 'userhist_onsitescore' => $onsitescore, 'userhist_rank' => WC_RegAt::calcRank($user), 'userhist_totalscore' => $user->getVar('user_level'), 'userhist_comment' => $comment)); if (WECHALL_DEBUG_SCORING) { echo WC_HTML::message('Inserting User History entry...'); } return $entry->insert(); }
public static function insertFirstLink(GWF_User $user, WC_Site $site, $onsitename, $onsitescore) { $table = self::table(__CLASS__); $siteid = $site->getVar('site_id'); if (false !== $table->getRow($onsitename, $siteid)) { return true; } $entry = new self(array('fili_onsitename' => $onsitename, 'fili_sid' => $siteid, 'fili_date' => GWF_Time::getDate(GWF_Date::LEN_DAY), 'fili_uid' => $user->getVar('user_id'), 'fili_username' => $user->getVar('user_name'), 'fili_sitename' => $site->getVar('site_name'), 'fili_percent' => $site->getPercent($onsitescore))); // echo GWF_HTML::message('DEBUG', 'Insert First Link...'); return $entry->insert(); }
private function templateBoxes() { $this->module->includeClass('WC_Warbox'); $this->module->includeClass('WC_Warflag'); $this->module->includeClass('WC_SiteDescr'); $sid = $this->site->getID(); $_GET['sid'] = $sid; $_GET['bid'] = 0; $table = GDO::table('WC_Warbox'); $by = Common::getGetString('by'); $dir = Common::getGetString('dir'); $orderby = $table->getMultiOrderby($by, $dir); $tVars = array('site_quickjump' => $this->module->templateSiteQuickjump('boxdetails'), 'boxes' => WC_Warbox::getBoxes($this->site, $orderby), 'site' => $this->site, 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=WarboxesDetails&by=%BY%&dir=%DIR%&siteid=' . $sid); return $this->module->templatePHP('warboxes_details.php', $tVars); }
private function onSolved(WC_Warflag $flag) { if ($this->box->isMultisolve()) { if (false !== ($err = $this->onMultiSolved($flag))) { return $err; } } else { if (false !== ($err = $this->onSingleSolved($flag))) { return $err; } } if (!$this->box->recalcPlayersAndScore()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === ($this->flags = WC_Warflag::getForBoxAndUser($this->box, $this->user, 'wf_order ASC'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $this->module->includeClass('WC_RegAt'); if ($this->site->isUserLinked($this->user->getID())) { $result = $this->site->onUpdateUser($this->user); return $result->display($this->site->displayName()); } else { return '_YOU_ARE_NOT_LINKED_TO_THE_SITE,_BUT_WELL_DONE!'; } }
public static function fixCatBits() { self::table(__CLASS__)->truncate(); require_once 'WC_RegAt.php'; $sites = WC_Site::getSites(); $tag_c = array(); foreach ($sites as $site) { $site instanceof WC_Site; $tags = $site->getTagArray(); $curr = array(); foreach ($tags as $tag) { $tag = trim($tag); if ($tag === '') { continue; } $curr[] = $tag; if (!isset($tag_c[$tag])) { $tag_c[$tag] = 1; } else { $tag_c[$tag]++; } self::addToCat($site->getID(), $tag); } $site->saveVars(array('site_tagbits' => self::calcTagBits($tags, $tag_c), 'site_tags' => implode(',', $curr))); WC_RegAt::fixTagBits($site, $site->getTagBits()); } self::adjustBits($tag_c); }
public function templateOutput($date, $amt) { $this->module->includeClass('WC_Warbox'); $this->module->includeClass('WC_Warflag'); $this->module->includeClass('WC_Warflags'); $table = GDO::table('WC_Warflags'); $joins = array('flag', 'solvers', 'flagsite', 'flagbox'); if (false === ($result = $table->selectAll('user_id, wf_id, wf_solved_at, wf_solved_at, wf_attempts, 0, 0, wf_attempts, user_name, wf_title, wf_solvers, IFNULL(wf_url, wb_weburl)', "wb_sid={$this->site->getID()} AND wf_solved_at>='{$date}'", 'wf_solved_at DESC', $joins, $amt, -1, GDO::ARRAY_N))) { return ''; } $back = ''; foreach ($result as $row) { $row = array_map(array(__CLASS__, 'escapeCSV'), $row); $back .= implode('::', $row) . PHP_EOL; } return $back; }
private function templateDDOS(WC_Site $site) { // require_once GWF_CORE_PATH.'module/WeChall/WC_RegAt.php'; $siteid = $site->getVar('site_id'); $regat = GWF_TABLE_PREFIX . 'wc_regat'; $users = GWF_TABLE_PREFIX . 'user'; $query = "SELECT u.* FROM {$regat} JOIN {$users} u ON regat_uid=user_id WHERE regat_sid={$siteid}"; $db = gdo_db(); if (false === ($result = $db->queryRead($query))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $user = new GWF_User(); while (false !== ($row = $db->fetchAssoc($result))) { $user->setGDOData($row); $site->onUpdateUser($user, false); } $db->free($result); $site->recalcSite(); }
private function sanitize() { if (false === ($this->site = WC_Site::getByID(Common::getGetInt('siteid', 0)))) { return array($this->module->lang('err_site')); } require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteAdmin.php'; if (!WC_SiteAdmin::isSiteAdmin(GWF_Session::getUserID(), $this->site->getID()) && !GWF_User::isAdminS()) { return array(GWF_HTML::lang('ERR_NO_PERMISSION')); } return false; }
private function displaySites() { $sites = array_reverse(WC_Site::getActiveSites()); if (0 === ($count = count($sites))) { return ''; } $box = ''; foreach ($sites as $site) { $site instanceof WC_Site; $box .= '<div>' . $site->displayLink() . '</div>' . PHP_EOL; } return $this->sidebox($this->module->lang('rp_sites', array($count)), $box); }
public function validate_site_classname(Module_WeChall $m, $arg) { if (false !== WC_Site::getByClassName($arg)) { return $m->lang('err_classname_dup'); } $max = $m->cfgMaxSitenameLen(); if (1 !== preg_match('/^[a-z][a-z0-9_]+$/iD', $arg)) { return $m->lang('err_site_classname', array(1, $max)); } $len = GWF_String::strlen($arg); if ($len < 1 || $len > $max) { return $m->lang('err_site_classname', array(1, $max)); } return false; }
private function templateRanking(GWF_Language $lang, $user) { $db = gdo_db(); $ipp = 50; $iso = $lang->getISO(); $langid = $lang->getID(); $users = GWF_TABLE_PREFIX . 'user'; $regat = GWF_TABLE_PREFIX . 'wc_regat'; # Count number of users playing this language. $query = "SELECT COUNT(DISTINCT regat_uid) AS c FROM {$regat} WHERE regat_langid={$langid} AND regat_options&4=0"; if (false === ($result = $db->queryFirst($query))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } # Page Menu $nItems = intval($result['c']); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); list($page, $hl_rank) = $this->getPageRank($langid, $ipp, $user); GWF_Website::setPageTitle($this->module->lang('pt_langrank', array($lang->displayName(), $page, $nPages))); GWF_Website::setMetaTags($this->module->lang('mt_ranking_lang', array($lang->displayName()))); GWF_Website::setMetaDescr($this->module->lang('md_ranking_lang', array($lang->displayName(), $page, $nPages))); // echo 'PAGE:'; // var_dump($page); // // echo 'RANK:'; // var_dump($hl_rank); // $page = Common::clamp($page, 1, $nPages); $from = GWF_PageMenu::getFrom($page, $ipp); # Query Data $query = "SELECT r1.regat_uid AS user_id, user_name, user_level, user_countryid, r1.regat_sid, r1.regat_solved AS solved, r2.sum AS sum " . "FROM {$regat} AS r1 " . "JOIN (SELECT regat_uid,SUM(regat_score) AS sum FROM {$regat} WHERE regat_langid={$langid} GROUP BY regat_uid ORDER BY SUM(regat_score) DESC LIMIT {$from},{$ipp}) AS r2 ON r1.regat_uid=r2.regat_uid " . "JOIN {$users} AS u ON u.user_id=r1.regat_uid " . "WHERE regat_options&4=0 " . "ORDER BY sum DESC "; if (false === ($result = $db->queryRead($query))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // var_dump($query); $data = array(); while (false !== ($row = $db->fetchAssoc($result))) { $uid = intval($row['user_id']); if (!isset($data[$uid])) { $data[$uid] = new GWF_User($row); } $sid = $row['regat_sid']; $data[$uid]->setVar('ss_' . $sid, (double) $row['solved']); } $db->free($result); # Show template $tVars = array('rank' => $from + 1, 'hlrank' => $hl_rank, 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'lang_ranking/' . $iso . '/page-%PAGE%'), 'langname' => $lang->displayName(), 'users' => $data, 'sites' => WC_Site::getSitesLang($langid), 'form_action' => $this->getMethodHref(), 'iso' => $lang->getISO()); return $this->module->templatePHP('ranking_lang.php', $tVars); }
private function rightPanelSites() { $sites = WC_Site::getActiveSites(); // $sites = GDO::table('WC_Site')->select("site_status='up' OR site_status='down'"); if (count($sites) === 0) { return ''; } $back = sprintf('<div>%s</div>', $this->module->lang('rp_sites', array(count($sites)))) . PHP_EOL; $back .= '<ol>' . PHP_EOL; foreach ($sites as $site) { $site instanceof WC_Site; $back .= sprintf('<li>%s</li>', $site->getLink()) . PHP_EOL; } $back .= '</ol>' . PHP_EOL; return $back; }
private function sanitize() { if (false === Common::getGet('no_session')) { return 'The mandatory parameter \'no_session\' is not set. Try \'&no_session=1\'.'; } # Validate Date if (false !== ($date = Common::getGet('datestamp'))) { if (GWF_Time::isValidDate($date, false, GWF_Date::LEN_SECOND)) { $this->time = GWF_Time::getTimestamp($date); } } # Validate username if (false !== ($username = Common::getGet('username'))) { if (false === ($this->user = GWF_User::getByName($username))) { return GWF_HTML::err('ERR_UNKNOWN_USER'); } if (false !== ($error = $this->module->isExcludedFromAPI($this->user, Common::getGet('password')))) { return $error; } } # Validate sitename if (false !== ($sitename = Common::getGet('sitename'))) { if (false === ($this->site = WC_Site::getByName($sitename)) && false === ($this->site = WC_Site::getByClassName($sitename))) { return $this->module->error('err_site'); } } # Validate Limit if (in_array(Common::getGet('masterkey'), self::$masterKeys)) { $max_limit = PHP_INT_MAX; } elseif ($this->user === false && $this->site === false) { $max_limit = self::MAX_LIMIT_ALL; } else { $max_limit = self::MAX_LIMIT_SINGLE; } $this->limit = Common::clamp(Common::getGet('limit', self::DEFAULT_LIMIT), 1, $max_limit); // if (!isset($no_block)) // { // require_once 'core/module/WeChall/WC_API_Block.php'; // if (WC_API_Block::isBlocked()) // { // return $this->module->error('err_api_block'); // } // } return false; }
public function execute() { if (!($site = WC_Site::getByClassName(Common::getGetString('site')))) { $this->module->ajaxErr('err_site'); } require_once GWF_CORE_PATH . 'module/WeChall/WC_HistoryUser2.php'; $table = GDO::table('WC_HistoryUser2'); $orderby = 'userhist_date DESC'; $siteid = $site->getVar('site_id'); $conditions = "userhist_sid={$siteid}"; $items = $table->selectObjects('*', $conditions, $orderby, 15); $feed = new GWF_RSS(); $feed->setTitle($this->l('siterss_title', array($site->displayName()))); $feed->setItems($items); $feed->setFeedURL($_SERVER['REQUEST_URI']); $feed->setWebURL(Common::getAbsoluteURL('site/history/' . $site->displayName())); die($feed->export()); }
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)); }
private function onQuickJump() { $jumps = Common::getPost('quickjumps'); if (!is_array($jumps)) { return $this->module->error('err_site') . '1'; } foreach ($jumps as $key => $value) { if ($value === '0') { continue; } if (false === ($site = WC_Site::getByID($value))) { return $this->module->error('err_site') . '2'; } $sid = $site->getVar('site_id'); GWF_Website::redirect(GWF_WEB_ROOT . 'site/details/' . $sid . '/' . $site->urlencodeSEO('site_name')); return ''; } return $this->module->error('err_site') . '3'; }
public function execute() { $syntax = 'syntax: ' . Common::getAbsoluteURL('remoteupdate.php') . '?sitename=FOO&username=BAR'; $server = htmlspecialchars($_SERVER['SERVER_NAME'], ENT_QUOTES); $unknownsite = 'Join us: ' . Common::getAbsoluteURL('join_us'); # "Join us: http://$server/join.php"; $unknownuser = '******' . Common::getAbsoluteURL('register') . ' for global ranking. Please note that the username is case sensitive for remoteupdates.'; // flag for images. 0=normal text, 1=default image, we can assign different image styles to higher numbers $img = (int) Common::getGet('img', 0); if ($img === 1) { header("Content-Type: image/png"); } if (false === ($sitename = Common::getRequest('sitename'))) { $this->outDie($syntax); } if (false === ($onsitename = Common::getRequest('username'))) { $this->outDie($syntax); } if ($sitename === 'FOO' && $onsitename === 'BAR') { $this->outDie('Doh! Not literally!'); } if (false === ($site = WC_Site::getByName($sitename)) && false === ($site = WC_Site::getByClassName($sitename))) { $this->outExit($unknownsite); } $this->module->includeClass('WC_RegAt'); if (false === ($user = WC_RegAt::getUserByOnsiteName($onsitename, $site->getID()))) { $this->outExit($unknownuser); } # Update him $result = $site->onUpdateUser($user); $site->saveOption(WC_Site::AUTO_UPDATE, true); # Output result switch ($img) { case 0: $this->outResult($result); break; case 1: $this->imgDisplayText($result->getMessage()); break; } }
private function templateHistory(GWF_User $user) { require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteDescr.php'; require_once GWF_CORE_PATH . 'module/WeChall/WC_HistoryUser2.php'; $uid = $user->getID(); $ipp = 50; $history = GDO::table('WC_HistoryUser2'); $nItems = $history->countRows("userhist_uid={$uid}"); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); $page = Common::clamp(Common::getGet('page', 1), 1, $nPages); $from = GWF_PageMenu::getFrom($page, $ipp); $by = Common::getGet('by', ''); $dir = Common::getGet('dir', ''); $orderby = $history->getMultiOrderby($by, $dir); $uuname = $user->urlencode2('user_name'); $duname = $user->displayUsername(); GWF_Website::setPageTitle($this->module->lang('pt_texthis', array($duname))); GWF_Website::setMetaDescr($this->module->lang('md_texthis', array($duname))); GWF_Website::setMetaTags($this->module->lang('mt_texthis', array($duname))); $tVars = array('user' => $user, 'duname' => $duname, 'sites' => WC_Site::getSites('site_id'), 'data' => $history->selectObjects('*', "userhist_uid={$uid}", $orderby, $ipp, $from), 'sort_url' => GWF_WEB_ROOT . 'history/for/' . $uuname . '/by/%BY%/%DIR%/page-1', 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'history/for/' . $uuname . '/by/' . urlencode($by) . '/' . urlencode($dir) . '/page-%PAGE%')); return $this->module->templatePHP('text_history.php', $tVars); }
private function templateRanking() { require_once GWF_CORE_PATH . 'module/WeChall/WC_SiteCats.php'; $tag = Common::getGet('tag', self::DEFAULT_TAG); if (0 === ($bit = WC_SiteCats::getBitForCat($tag))) { $bit = 1; $tag = $_GET['tag'] = WC_SiteCats::getCatForBit($bit); } $ipp = 50; $nItems = $this->countItems($bit); list($page, $hlrank) = $this->getPageNum($ipp, $bit); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); $page = Common::clamp($page, 1, $nPages); $from = GWF_PageMenu::getFrom($page, $ipp); $rank = ($page - 1) * $ipp + 1; $data = $bit === 0 ? array() : $this->selectPage($bit, $from, $ipp); $dtag = GWF_HTML::display($tag); GWF_Website::setPageTitle($this->module->lang('pt_tagrank', array($dtag))); GWF_Website::setMetaTags($this->module->lang('mt_tagrank', array($dtag, $dtag))); GWF_Website::setMetaDescr($this->module->lang('md_tagrank', array($dtag, $page, $nPages))); $tVars = array('rank' => $rank, 'hlrank' => $hlrank, 'sites' => WC_Site::getSimilarSitesS($bit, true), 'data' => $data, 'tag' => $dtag, 'form_action' => GWF_WEB_ROOT . 'category_ranking', 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('category_ranking/%s/page-%%PAGE%%', urlencode($tag))), 'select' => $this->getTagSelect()); return $this->module->templatePHP('ranking_tag.php', $tVars); }
private function templateRanking($user) { require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php'; $users = GDO::table('GWF_User'); $ipp = $this->module->cfgItemsPerPage(); $nItems = $users->countRows("user_level>0"); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); if (false === ($page = Common::getGet('page'))) { list($page, $rank) = $this->getPageForSession($ipp, $user); } else { $page = Common::clamp(intval($page), 1, $nPages); $rank = $user === false || $user->isOptionEnabled(0x10000000) ? 1 : WC_RegAt::calcExactRank($user); } // var_dump($page); // var_dump($rank); $from = GWF_PageMenu::getFrom($page, $ipp); $href = GWF_WEB_ROOT . 'ranking/page-%PAGE%'; GWF_Website::setPageTitle($this->module->lang('pt_ranking', array($page))); GWF_Website::setMetaTags($this->module->lang('mt_ranking')); $userdata = $this->selectUsers($ipp, $from); $tVars = array('rank' => $from + 1, 'highlight_rank' => $rank, 'langs' => WC_Site::getLangs(), 'userdata' => $userdata, 'pagemenu' => GWF_PageMenu::display($page, $nPages, $href)); return $this->module->templatePHP('ranking.php', $tVars); }
function Upgrade_WeChall_1_04(Module_WeChall $module) { $db = gdo_db(); $sites = GWF_TABLE_PREFIX . 'wc_site'; $query = "ALTER TABLE {$sites} ADD COLUMN site_descr_lid INT(11) UNSIGNED NOT NULL DEFAULT 1"; if (false === $db->queryWrite($query)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } require_once 'core/module/WeChall/WC_SiteDescr.php'; if (false === GDO::table('WC_SiteDescr')->createTable(true)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $patches = array(13 => 5, 43 => 3, 17 => 5); foreach (WC_Site::getSites('site_id ASC') as $site) { $site instanceof WC_Site; $siteid = $site->getID(); $desc = $site->getVar('site_description'); if (isset($patches[$siteid])) { $langid = $patches[$siteid]; } else { $langid = 1; } if (false === WC_SiteDescr::insertDescr($siteid, $langid, $desc)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $site->saveVar('site_descr_lid', $langid)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } $query = "ALTER TABLE `{$sites}` DROP `site_description`"; if (false === $db->queryWrite($query)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } GWF_HTML::message('WC', '[+] Multi Lang Descriptions', true, true); return ''; }
<?php $SITE = WC_Site::getByID(Common::getGetString('sid')); if ($SITE === false) { # fallback $SITE = GDO::table('WC_Site')->selectRandom('*', "site_status='up'", 1, NULL, GDO::ARRAY_O); $SITE = $SITE[0]; } # Put in cats. //$types = array(); # Row types $langs = array(); # Row languages $cats = array(); # Row cats //$types['all'] = array(); //$types['active'] = array(); foreach ($tVars['sites'] as $site) { $site instanceof WC_Site; // var_dump($site->getGDOData()); if ($site->isScored()) { $langid = $site->getLangID(); if (!isset($langs[$langid])) { $langs[$langid] = array(); } $langs[$langid][] = $site; // $types['active'][] = $site; } // else // { // $type = $site->getTypeID(); // if (!isset($types[$type])) {
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(); }
private static function installSiteColors(Module_WeChall $module) { $classnames = array('WC' => 'c6d0da', 'HQ' => '00ffff', 'Rankk' => 'a50000', 'TBS' => 'f8b128', 'Elec' => 'ffff00', 'Asp' => 'cdcdcd', 'HS' => '48633b', 'NC' => '5d5d5d', 'DYM' => 'fec752', 'Lost' => 'bbbbbb', 'Yash' => 'aaaaaa', 'Mirmo' => '232323', 'BQ' => 'dbdbdc', 'NF' => '93836e', 'Hispa' => '8ddc42', 'HTS' => '409fff', 'TIL' => '688ade', 'ElH' => 'e2e9ee', 'TT1' => '2370aa', 'TDH' => 'ffec62', 'MiB' => '42d153', 'Ma' => '008000', 'PHM' => '000000', 'BBox' => '', 'Euler' => 'c7e1f8', '0ID' => 'ed8c0f', 'HDE' => '', 'Hax' => '00b000', 'HBH' => 'bec8c5', 'Hacker' => 'd0f4df', 'Bl0' => '', 'SA' => '11141d', 'osix' => '2e506b', 'RCode' => 'f60101', 'CSTC' => '8883b8', 'LB' => '4d8ac7', 'Asta' => '000000', 'WoW' => 'ffffff', 'THC' => '804b69', 'HBBS' => 'd0d0d0', 'CLIB' => 'ffffff', 'ST' => '202020', 'Root' => '000000', 'SPOJ' => '07077e'); foreach ($classnames as $classname => $color) { if ($color !== '') { if (false !== ($site = WC_Site::getByClassName($classname))) { $site->saveVar('site_color', $color); } } } }
public static function displayIcons(GWF_User $user) { $back = ''; $db = gdo_db(); $uid = $user->getInt('user_id'); $regats = GWF_TABLE_PREFIX . 'wc_regat'; $query = "SELECT regat_sid, regat_solved FROM {$regats} WHERE regat_uid={$uid}"; if (false === ($result = $db->queryRead($query))) { return ''; } $i = 0; while (false !== ($row = $db->fetchRow($result))) { if (0.05 > ($solved = floatval($row[1]))) { continue; } if (++$i % 5 === 0) { $back .= '<br/>' . PHP_EOL; } $siteid = (int) $row[0]; $site = WC_Site::getByID($siteid); $back .= $site->displayLogoUN($user->getVar('user_name'), $solved, 6, 28, true) . PHP_EOL; } $db->free($result); return $back; }
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'); }
private function getSiteSelect() { $data = array(); foreach (WC_Site::getSites('site_name ASC') as $site) { $data[] = array($site->getID(), $site->getVar('site_name')); } return GWF_Select::display('site', $data, Common::getPostString('site', '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())); }
public static function getPlayercountForSite(WC_Site $site) { return self::table(__CLASS__)->selectVar('COUNT(DISTINCT(wf_uid))', "wb_sid={$site->getID()} AND wf_solved_at IS NOT NULL", '', array('flag', 'flagbox', 'flagsite')); }
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>'; }