function wordpatValidatePattern($pattern) { if ($pattern == "") { return false; } $pattern = trim(strtoupper($pattern)); if (0 === preg_match("/^[A-P0-9]{2,20}\$/D", $pattern)) { return htmlDisplayError("Invalid character set"); } $found = array(); $highest = 1; $len = strlen($pattern); for ($i = 0; $i < $len; $i++) { $val = wordpatDigitToDec($pattern[$i]); if ($val > $i + 1) { return htmlDisplayError("Higher numbers than strlen"); } if ($val > $highest) { $highest = $val; } } if ($pattern == "" || $len < $highest) { return htmlDisplayError("Higher numbers than strlen"); } for ($i = 1; $i < $highest; $i++) { $char1 = wordpatDecToDigit($i); $char2 = wordpatDecToDigit($i + 1); if (strpos($pattern, "{$char2}") < strpos($pattern, "{$char1}")) { return htmlDisplayError("Wrong order. try 123 instead of 321"); } } return $pattern; }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $result = str_replace("", '', $result); # BOM $result = trim($result); $stats = explode(":", $result); if (count($stats) !== 7) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $i = 0; $username = $stats[$i++]; $rank = intval($stats[$i++]); $onsitescore = intval($stats[$i++]); $onsitescore = Common::clamp($onsitescore, 0); $maxscore = intval($stats[$i++]); $challssolved = intval($stats[$i++]); $challcount = intval($stats[$i++]); $usercount = intval($stats[$i++]); if ($maxscore === 0 || $challcount === 0 || $usercount === 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $stats = explode(':', $result); if (count($stats) !== 7) { // if ($result === '0') { // return array(0, 0); // } return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } # username:rank:score:maxscore:challssolved:challcount:usercount $uname = $stats[0]; $rank = intval($stats[1]); $onsitescore = intval($stats[2]); $maxscore = intval($stats[3]); $challssolved = intval($stats[4]); $challcount = intval($stats[5]); $usercount = intval($stats[6]); if ($maxscore === 0 || $challcount === 0 || $usercount === 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($onsitescore, $rank, $challssolved, $maxscore, $usercount, $challcount); }
public function parseStats($url) { $result2 = GWF_HTTP::getFromURL($url, false); $result = explode(':', $result2); if (count($result) !== 6) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result2), $this->displayName()))); } list($rank, $score, $maxscore, $challsolved, $challcount, $usercount) = $result; return array(intval($score), (int) $rank, $challsolved, $maxscore, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $data = explode(':', $result); if (count($data) !== 5) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } list($rank, $score, $maxscore, $usercount, $challcount) = $data; if ($rank == 0 || $maxscore == 0 || $usercount == 0 || $challcount == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array(round($score), $rank, -1, $maxscore, $usercount, $challcount); }
public function parseStats($url) { $result = GWF_HTTP::getFromURL($url, false); if ($result === false) { return false; } if ($result === "Unknown User") { return htmlDisplayError(WC_HTML::lang('err_onsitename', array($this->displayName()))); } $data = explode(":", $result); if (count($data) !== 5 || $data[3] < 0 || $data[3] > $data[4] || $data[2] == 0 || $data[4] == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($data[3], Common::clamp($data[1], 0), $data[3], $data[4], $data[2], $data[4]); }
public static function checkDuplicates($wordlistPath) { $file = file($wordlistPath); $checked = array(); $back = true; foreach ($file as $word) { if (in_array($word, $checked)) { htmlDisplayError("Warning: Duplicate entry '{$word}' in {$wordlistPath}"); $back = false; } else { $checked[] = $word; } } return $back; }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $stats = explode(':', $result); if (count($stats) !== 3) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } list($onsitescore, $challcount, $usercount) = $stats; if ($challcount == 0 || $usercount == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($onsitescore, -1, -1, $challcount, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $result = explode(":", $result); if (count($result) !== 4) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } list($rank, $score, $challcount, $usercount) = $result; if ($rank < 1 || $challcount == 0 || $usercount == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($score, $rank, $score, $challcount, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $stats = explode(":", $result); if (count($stats) !== 4) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } if ($stats[0] < 0 || $stats[0] > $stats[1] || $stats[3] == 0 || $stats[2] == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $score = round($stats[0] / $stats[1] * 10000); return array($score, -1, -1, 10000, $stats[3], $stats[2]); }
function checkSolution(WC_Challenge $chall) { if (false === ($correct = GWF_Session::getOrDefault('cyrm_solution'))) { return htmlDisplayError($chall->lang('err_no_request')); } $timediff = microtime(true) - GWF_Session::get('cyrm_timeout'); $taken = sprintf('%.03fs', $timediff); if ($correct !== ($answer = Common::getGetString('solution', ''))) { return htmlDisplayError($chall->lang('err_wrong', array(htmlspecialchars($answer, ENT_QUOTES), $correct, $taken))); } $maxtime = 2.5; if ($timediff >= $maxtime) { return htmlDisplayError($chall->lang('err_slow', array($maxtime . 's', $taken))); } return htmlDisplayMessage($chall->lang('msg_correct', array($taken))); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $data = explode(":", $result); if (count($data) !== 7) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $challcount = isset($data[5]) ? intval($data[5]) : $this->getVar('challcount'); $usercount = isset($data[6]) ? intval($data[6]) : $this->getVar('usercount'); if ($data[1] < 0 || $data[1] > $data[2] || $challcount == 0 || $usercount == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($data[1], $data[4], -1, $data[2], $usercount, $challcount); }
function checkSolution(WC_Challenge $chall) { if (false === ($correct = GWF_Session::getOrDefault('lg_solution'))) { return htmlDisplayError($chall->lang('err_no_req')); } $maxtime = LETTERGRID_MAX_TIME; $timediff = microtime(true) - GWF_Session::getOrDefault('lg_timeout', 0); if ($correct !== Common::getGet('solution')) { GWF_Session::remove('lg_timeout'); GWF_Session::remove('lg_solution'); return htmlDisplayError($chall->lang('err_wrong', array(htmlspecialchars(Common::getGet('solution'), ENT_QUOTES), $correct, $timediff, $maxtime))); } if ($timediff >= $maxtime) { return htmlDisplayError($chall->lang('err_slow', array($maxtime, $timediff))); } return htmlDisplayMessage($chall->lang('msg_correct', array($timediff))); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $stats = explode(':', $result); if (count($stats) < 2) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $onsitescore = intval($stats[0]); $maxscore = intval($stats[1]); $challcount = $maxscore; $usercount = intval($stats[2]); if ($onsitescore === 0 || $maxscore === 0 || $challcount === 0 || $usercount === 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($onsitescore, -1, $onsitescore, $maxscore, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $data = explode(':', $result); $percent = $data[0]; if (!is_numeric($percent) || $percent < 0 || $percent > 1) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $usercount = isset($data[1]) ? $data[1] : $this->getUsercount(); if ($usercount == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $maxscore = $this->getOnsiteScore(); $challcount = $this->getChallcount(); return array(round($percent * $maxscore), -1, -1, $maxscore, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $stats = explode(":", $result); if (count($stats) < 3) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $challs = $stats[1]; $done = $stats[0]; #$usercount = $stats[2]; if ($challs == 0) { # || $usercount == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($done, -1, $done, $challs, 0, $challs); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $data = explode(":", $result); if (count($data) !== 5) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $rank = (int) $data[0]; $score = (int) ($data[1] * 100); $maxscore = (int) ($data[2] * 100); $users = (int) $data[3]; $challs = (int) $data[4]; if ($score > $maxscore || $score < 0 || $maxscore == 0 || $challs == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($score, $rank, -1, $maxscore, $users, $challs); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $stats = explode(":", $result); if (count($stats) < 3) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $onsitescore = intval($stats[0]); $onsitescore = Common::clamp($onsitescore, 0); $maxscore = intval($stats[1]); $usercount = intval($stats[2]); $onsiterank = isset($stats[3]) ? intval($stats[3]) : -1; $challcount = $maxscore; if ($maxscore === 0 || $challcount === 0 || $usercount === 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($onsitescore, $onsiterank, $onsitescore, $maxscore, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $stats = explode(":", $result); if (count($stats) !== 4) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $onsitescore = intval($stats[2]); $score = intval($stats[1]); $rankname = $stats[0]; $usercount = 39500; $challcount = 102; #intval($stats[3]); if ($score > $onsitescore * 2 || $challcount <= 2 || $onsitescore < 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($score, -1, -1, $onsitescore, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $data = explode(':', $result); if (count($data) !== 6) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $rank = (int) $data[0]; $score = (int) $data[1]; $maxscore = (int) $data[2]; // on site max score $usercount = (int) $data[3]; $challcount = (int) ($data[4] = (int) $maxscore); $onsitename = (int) $data[5]; if ($score > $maxscore || $score < 0 || $challcount == 0 || $usercount == 0 || $maxscore == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($score, $rank, -1, $maxscore, $usercount, $challcount); }
public function parseStats($url) { if (false === ($page = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($page), $this->displayName()))); } $result = explode(':', trim($page)); if (count($result) !== 6) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($page), $this->displayName()))); } $i = 0; $username = $result[$i++]; $rank = -1; $score = $result[$i++]; $maxscore = $result[$i++]; $challssolved = $result[$i++]; $challcount = $result[$i++]; $usercount = $result[$i++]; if ($maxscore === 0 || $challcount === 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($score, $rank, $challssolved, $maxscore, $usercount, $challcount); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $file = explode('<br>', $result); if (count($file) !== 5) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } // $ranking = $file[1]; list($ranking, $usercount) = explode('/', trim(Common::substrFrom($file[1], ':'))); // $usercount = Common::substrFrom($ranking, "/"); $challstats = $file[3]; $challcount = Common::substrFrom($challstats, "/"); $points = $file[2]; $back = array(); preg_match('#(\\d*)\\/(\\d*)#', $points, $back); if (count($back) !== 3 || $back[1] < 0 || $back[1] > $back[2] || $usercount == 0 || $challcount == 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($back[1], $ranking, -1, $back[2], $usercount, $challcount); }
function checkSolution(WC_Challenge $chall) { // if (!User::isLoggedIn()) { // return htmlDisplayError("You need to login to submit a solution."); // } if (false === ($correct = GWF_Session::getOrDefault('lw_solution'))) { return htmlDisplayError($chall->lang('err_no_req')); } $answer = Common::getGet('solution'); $maxtime = 4.5; $timediff = microtime(true) - GWF_Session::getOrDefault('lw_timeout', 0); if ($answer !== $correct) { GWF_Session::remove('lw_timeout'); GWF_Session::remove('lw_solution'); $danswer = htmlspecialchars($answer, ENT_QUOTES); return htmlDisplayError($chall->lang('err_wrong', array($danswer, $correct, $timediff, $maxtime))); } if ($timediff >= $maxtime) { return htmlDisplayError($chall->lang('err_slow', array($maxtime, $timediff))); } return htmlDisplayMessage($chall->lang('msg_correct', array($timediff))); }
public function parseStats($url) { if (false === ($result = GWF_HTTP::getFromURL($url, false))) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } $stats = explode(':', $result); if (count($stats) != 7) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } # username:rank:score:maxscore:challssolved:challcount:usercount $i = 0; $username = $stats[$i++]; $onsitesrank = (int) $stats[$i++]; $onsitescore = (int) $stats[$i++]; $maxscore = (int) $stats[$i++]; $challssolved = (int) $stats[$i++]; $challcount = (int) $stats[$i++]; $usercount = (int) $stats[$i++]; if ($maxscore === 0 || $challcount === 0 || $usercount === 0) { return htmlDisplayError(WC_HTML::lang('err_response', array(GWF_HTML::display($result), $this->displayName()))); } return array($onsitescore, $onsitesrank, $challssolved, $maxscore, $usercount, $challcount); }
<?php chdir("../../"); require_once "challenge/html_head.php"; if (!GWF_User::isAdminS()) { echo GWF_HTML::err('ERR_NO_PERMISSION'); return; } $title = "Can you read me"; $solution = false; $score = 5; $url = "challenge/can_you_readme/index.php"; $creators = "Gizmore"; $tags = 'Coding,Image'; htmlDisplayError(WC_Challenge::installChallenge($title, $solution, $score, $url, $creators, $tags, true)); require_once "challenge/html_foot.php";
<?php chdir("../../"); require_once "challenge/html_head.php"; if (!GWF_User::isAdminS()) { return htmlDisplayError("You need to be admin"); } $title = "Lettergrid"; $solution = false; $score = 6; $url = "challenge/lettergrid/index.php"; $creators = "Gizmore"; $tags = "Coding"; WC_Challenge::installChallenge($title, $solution, $score, $url, $creators, $tags, true); require_once "challenge/html_foot.php";
/** * Retrieve uploaded file from url and call thx. * @param string $url * @return NULL */ function upload_please_by_url($url) { if (1 === preg_match('#^[a-z]{3,5}://#', $url)) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); if (false === ($file_data = curl_exec($ch))) { htmlDisplayError('cURL failed.'); } else { // Thanks upload_please_thx($file_data); } } else { htmlDisplayError('Your URL looks errorneous.'); } }
require_once 'challenge/html_head.php'; if (false === ($chall = WC_Challenge::getByTitle("Training: Programming 1"))) { $chall = WC_Challenge::dummyChallenge("[Training: Programming 1]"); } if (true === defined('NO_HEADER_PLEASE')) { prog2NextQuestion($chall); } $solved = false; if (false !== ($answer = Common::getGet('answer'))) { $solved = prog2CheckResult($chall); } $chall->showHeader(); if ($solved === true) { $chall->onChallengeSolved(GWF_Session::getUserID()); } elseif (is_string($solved)) { htmlDisplayError($solved, false); } ?> <?php $sol_url = Common::getAbsoluteURL($chall->getVar('chall_url')) . '?answer=the_message'; echo GWF_Box::box($chall->lang('info', array('index.php?action=request', $sol_url, TIMELIMIT))); ?> <?php function prog2NextQuestion(WC_Challenge $chall) { if (false === ($user = GWF_Session::getUser())) { die($chall->lang('err_login')); } $solution = GWF_Random::randomKey(rand(9, 12));
function zreloadGetShellConfig($shellid) { global $zshellz; if (!isset($zshellz[$shellid])) { htmlDisplayError('Unknown Shell ID in ' . __FILE__ . ' Line ' . __LINE__); return array('ERR', 'ERR'); } return $zshellz[$shellid]; }
<?php chdir("../../"); require_once "challenge/html_head.php"; html_head("Install Sidology"); if (!GWF_User::isAdminS()) { return htmlSendToLogin("Better be admin !"); } $title = "Sidology"; $solution = false; $score = 5; $url = "challenge/sidology/index.php"; $creators = "Gizmore"; htmlDisplayError(ChallengeTable::addChallenge($title, $solution, $score, $url, $creators)); require_once "challenge/html_foot.php";