private function templateLevels() { $bid = $this->box->getID(); $_GET['sid'] = $this->box->getSiteID(); $_GET['bid'] = $bid; $tVars = array('site_quickjump' => $this->module->templateSiteQuickjump('boxdetail'), 'data' => $this->getData(), 'box' => $this->box, 'site' => $this->box->getSite(), 'method' => $this, 'sort_url' => GWF_WEB_ROOT . 'index.php?mo=WeChall&me=WarboxDetails&boxid=' . $bid . '&by=%BY%&dir=%DIR%'); return $this->module->templatePHP('warbox_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!'; } }
private function templatePlayers() { $bid = $this->box->getID(); $_GET['sid'] = $this->box->getSiteID(); $_GET['bid'] = $bid; $table = GDO::table('WC_Warflags'); $where = "wf_wbid={$bid} AND wf_solved_at IS NOT NULL"; $orderby = 'score DESC, solvedate ASC'; $joins = array('flag', 'flagbox', 'solvers'); $ipp = 50; $nItems = $table->countRows($where, $joins, 'user_name'); $nPages = GWF_PageMenu::getPagecount($ipp, $nItems); $page = Common::clamp(Common::getGetInt('page', 1), 1, $nPages); $from = GWF_PageMenu::getFrom($page, $ipp); $tVars = array('site_quickjump' => $this->module->templateSiteQuickjump('boxranking'), 'data' => $table->selectAll("user_name, user_countryid country, COUNT(*) solved, SUM(wf_score) score, SUM(wf_score)/{$this->box->getVar('wb_totalscore')}*100 percent, MAX(wf_solved_at) solvedate", $where, $orderby, $joins, $ipp, $from, GDO::ARRAY_A, 'user_name'), 'box' => $this->box, 'playercount' => $nItems, 'rank' => $from + 1, 'pagemenu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . 'index.php?mo=WeChall&me=WarboxPlayers&boxid=' . $bid . '&page=%PAGE%')); return $this->module->templatePHP('warbox_players.php', $tVars); }
private function createFromCSV(array $row) { $flag = new WC_Warflag(array('wf_id' => '0', 'wf_wbid' => $this->warbox->getID(), 'wf_order' => $row[0], 'wf_cat' => $row[1], 'wf_score' => $row[2], 'wf_solvers' => '0', 'wf_title' => $row[3], 'wf_url' => $row[4], 'wf_authors' => $row[5], 'wf_status' => $row[6], 'wf_login' => $row[7], 'wf_flag_enc' => WC_Warflag::hashPassword($row[8]), 'wf_created_at' => GWF_Time::getDate(), 'wf_last_solved_at' => NULL, 'wf_last_solved_by' => NULL, 'wf_options' => $this->bitFromType($row))); if (!$flag->insert()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return ''; }
private function onRecalcEverything() { require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php'; $wc = Module_WeChall::instance(); $wc->includeClass('WC_Warflag'); $wc->includeClass('WC_Warflags'); foreach (WC_Warbox::getAllBoxes() as $box) { $box instanceof WC_Warbox; $box->recalcPlayersAndScore(); $box->recalcChallcounts(); } WC_Site::recalcAllSites(); WC_RegAt::calcTotalscores(); return $this->templateAdmin(); }
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); }
public static function getPlayercount(WC_Warbox $box) { return self::table(__CLASS__)->selectVar('COUNT(DISTINCT(wf_uid))', "wf_wbid={$box->getID()} AND wf_solved_at IS NOT NULL", '', array('flag', 'flagbox')); }
//echo '</div>'; #- 1st row echo sprintf('<form action="%s" method="post">', GWF_HTML::display($tVars['form_action'])); echo '<div>'; foreach ($langs as $langid => $sites) { $text = $sites[0]->getLang()->displayName(); wcSiteQJSel($text, $sites, $tVars['mode'], $nqj++); } echo '</div>'; #- 3rd Row (and more) echo '<div>'; foreach ($cats as $cat => $sites) { wcSiteQJSel($cat, $sites, $tVars['mode'], $nqj++); } #- 4th Row (boxes) $boxes = WC_Warbox::getBoxes($SITE, 'wb_name ASC'); if (count($boxes) > 0) { $data = array(array('0', 'Warboxes')); foreach ($boxes as $box) { $box instanceof WC_Warbox; $data[] = array($box->getID(), $box->displayName()); } // var_dump($data); echo GWF_Select::display('wc_boxes_quickjump', $data, Common::getGetString('bid'), "wcSiteQuickqump(this, '{$tVars['mode']}', 2)"); } # - Button echo '<noscript><div class="i"><input type="submit" name="quickjump" value="' . $tLang->lang('btn_quickjump') . '" /></div></noscript>'; echo '</div>'; echo '</form>'; echo '</div>' . PHP_EOL; # - Tabs
<?php $site = $tVars['site']; $site instanceof WC_Site; $is_ranked = $site->isScored(); $siteid = $site->getID(); $boxes = WC_Warbox::getBoxes($site); echo '<div class="gwf_buttons_outer"><div class="gwf_buttons">' . PHP_EOL; $onclick = "wcjsHideJQuery('#wc_profile_slide'); wcjs_last_site = undefined; return false;"; echo GWF_Button::delete('#', $tLang->lang('btn_close'), '', $onclick); echo GWF_Button::forward($site->getURL(), $site->getSitename()); echo '</div></div>' . PHP_EOL; echo '<div class="gwf_buttons_outer"><div class="gwf_buttons">' . PHP_EOL; echo WC_HTML::button('btn_site_details', $site->hrefDetail()); if (count($boxes) > 0) { echo WC_HTML::button('btn_warboxes', $site->hrefWarboxes()); } echo WC_HTML::button('btn_ranking', $site->hrefRanking(true)); echo WC_HTML::button('btn_site_history', $site->hrefHistory()); echo '</div></div>' . PHP_EOL; ?> <?php if (false === ($user = GWF_User::getByName(Common::getGet('username', '')))) { } if ($user !== false) { $userid = $user->getID(); if (false !== ($regat = WC_RegAt::getRegatRow($userid, $siteid))) { $max = $site->getOnsiteScore(); echo GWF_Box::box($tLang->lang('site_detail_uinfo', array($user->displayUsername(), $regat->getOnsiteScore(), $max, $site->displayName(), round($regat->getPercent($max), 2), WC_RegAt::calcExactSiteRank($user, $siteid), $site->calcScore($regat)))); }
public static function getWarchall(WC_Warbox $box, $level) { $boxid = $box->getID(); $elevel = self::escape($level); if (false !== ($chall = self::table(__CLASS__)->selectFirstObject('*', "wf_wbid={$boxid} AND wf_title='{$elevel}'", '', '', NULL))) { return $chall; } $chall = new self(array('wf_id' => '0', 'wf_wbid' => $boxid, 'wf_order' => self::getNextOrder($box), 'wf_cat' => 'exploit', 'wf_score' => '1', 'wf_solvers' => '0', 'wf_title' => $level, 'wf_url' => '', 'wf_authors' => '', 'wf_status' => 'up', 'wf_login' => '', 'wf_flag_enc' => NULL, 'wf_created_at' => GWF_Time::getDate(), 'wf_last_solved_at' => NULL, 'wf_last_solved_by' => NULL, 'wf_options' => self::WARCHALL)); if (!$chall->replace()) { return false; } return $chall; }
function warscore_has_level(WC_Warbox $box, $level) { if ($box->isBlacklisted($level)) { return false; } return $box->isWhitelisted($level); }
private function formEdit(WC_Warbox $box) { $data = array('name' => array(GWF_Form::STRING, $box->getVar('wb_name'), $this->l('th_wb_name')), 'url' => array(GWF_Form::STRING, $box->getVar('wb_weburl'), $this->l('th_wb_url')), 'host' => array(GWF_Form::STRING, $box->getVar('wb_host'), $this->l('th_wb_host')), 'port' => array(GWF_Form::INT, $box->getVar('wb_port'), $this->l('th_wb_port')), 'user' => array(GWF_Form::STRING, $box->getVar('wb_user'), $this->l('th_wb_user')), 'pass' => array(GWF_Form::STRING, $box->getVar('wb_pass'), $this->l('th_wb_pass')), 'wlist' => array(GWF_Form::STRING, $box->getVar('wb_whitelist'), $this->l('th_wb_wlist')), 'blist' => array(GWF_Form::STRING, $box->getVar('wb_blacklist'), $this->l('th_wb_blist')), 'launch' => array(GWF_Form::DATE, $box->getVar('wb_launched_at'), $this->l('th_wb_launch'), '', 8), 'status' => array(GWF_Form::ENUM, $box->getVar('wb_status'), $this->l('th_wb_status'), '', $this->statusValues()), 'warbox' => array(GWF_Form::CHECKBOX, $box->isWarbox(), $this->l('th_warbox')), 'multi' => array(GWF_Form::CHECKBOX, $box->isMultisolve(), $this->l('th_multisolve')), 'buttons' => array(GWF_Form::SUBMITS, array('edit' => $this->l('btn_edit_warbox'), 'flags' => $this->l('btn_edit_warflags')))); return new GWF_Form($this, $data); }
/** * Update new scoring shemes. Warboxes and Warflags. * @param GWF_User $user * @param array $stats */ public function onUpdateUserWarboxWarflag(GWF_User $user, array &$stats) { Module_WeChall::instance()->includeClass('WC_Warbox'); $boxes = WC_Warbox::getBoxes($this); if (count($boxes) > 0) { // $this->parseMultiStats($user, $stats); Module_WeChall::instance()->includeClass('WC_Warflag'); Module_WeChall::instance()->includeClass('WC_Warflags'); Module_WeChall::instance()->includeClass('sites/warbox/WCSite_WARBOX'); foreach ($boxes as $box) { $box instanceof WC_Warbox; if ($box->isUp()) { $box->parseFlagStats($user, $stats); // $box->parseWarboxStats($user, $stats); } } } }
public static function getForBoxAndUser(WC_Warbox $box, GWF_User $user, $orderby = '') { $where = "wc_boxid={$box->getID()}"; $joins = array(array('WC_Warchalls', 'wc_id', 'wc_wcid', 'wc_uid', $user->getID())); return self::table(__CLASS__)->selectAll('*', $where, $orderby, $joins, -1, -1, GDO::ARRAY_O); }