Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 private function onSolveB($flagid, $password)
 {
     if (false === ($flag = WC_Warflag::getByID($flagid))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if ($this->box->getID() !== $flag->getVar('wf_wbid')) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->onAnswer($flag, $password);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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 '';
 }
Ejemplo n.º 5
0
 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'));
 }
Ejemplo n.º 6
0
 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;
 }
Ejemplo n.º 7
0
 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);
 }