Пример #1
0
function prog2CheckResult(WC_Challenge $chall)
{
    if (false === ($user = GWF_Session::getUser())) {
        die($chall->lang('err_login'));
    }
    if (false === ($answer = Common::getGet('answer'))) {
        die($chall->lang('err_no_answer'));
    }
    $solution = GWF_Session::getOrDefault('prog2_solution', false);
    $startTime = GWF_Session::getOrDefault('prog2_timeout', false);
    if ($solution === false || $startTime === false) {
        die($chall->lang('err_no_request'));
    }
    $back = "";
    if (trim($answer) !== $solution) {
        $back .= $chall->lang('err_wrong', array(htmlspecialchars($answer, ENT_QUOTES), $solution));
    } else {
        $back .= $chall->lang('msg_correct');
    }
    $timeNeeded = microtime(true) - $startTime;
    if ($timeNeeded > TIMELIMIT) {
        return $back . $chall->lang('err_timeout', array(sprintf('%.02f', $timeNeeded), TIMELIMIT));
    }
    return trim($answer) === $solution ? true : $back;
}
Пример #2
0
 private function welcome($first_time)
 {
     if (false === ($user = GWF_Session::getUser())) {
         return GWF_HTML::err('ERR_LOGIN_REQUIRED');
     }
     require_once GWF_CORE_PATH . 'module/Login/GWF_LoginHistory.php';
     GWF_Hook::call(GWF_Hook::LOGIN_AFTER, $user, array(GWF_Session::getOrDefault('GWF_LOGIN_BACK', GWF_WEB_ROOT)));
     $fails = GWF_Session::getOrDefault('GWF_LOGIN_FAILS', 0);
     GWF_Session::remove('GWF_LOGIN_FAILS');
     if ($fails > 0) {
         $fails = $this->module->lang('err_failures', array($fails));
     } else {
         $fails = '';
     }
     $href_hist = $this->module->getMethodURL('History');
     $username = $user->display('user_name');
     if (false !== ($ll = GWF_LoginHistory::getLastLogin($user->getID()))) {
         $last_login = $this->module->lang('msg_last_login', array($ll->displayDate(), $ll->displayIP(), $ll->displayHostname(), $href_hist));
         $welcome = $this->module->lang('welcome_back', array($username, $ll->displayDate(), $ll->displayIP()));
     } else {
         $last_login = '';
         $welcome = $this->module->lang('welcome', array($username));
     }
     $tVars = array('welcome' => $welcome, 'fails' => $fails, 'last_login' => $last_login, 'href_history' => $href_hist);
     return $this->module->template('welcome.tpl', $tVars);
 }
Пример #3
0
 private static function validateCaptcha($context, GWF_Form $form, $validator, $key)
 {
     if (GWF_Session::getOrDefault('php_captcha', false) !== strtoupper($form->getVar($key))) {
         $form->onNewCaptcha();
         return GWF_HTML::lang('ERR_WRONG_CAPTCHA');
     }
     //		GWF_Session::remove('php_captcha');
     $form->onSolvedCaptcha();
     return false;
 }
Пример #4
0
 private function onNewPubmsg($timestamp)
 {
     if (false === ($cut = GWF_Session::getOrDefault(self::$SESS_AJAX_PUB, time()))) {
         return;
     }
     $msgs = new GWF_ChatMsg(false);
     $channel = '';
     $new = $msgs->selectAll('*', "chatmsg_to='{$channel}' AND chatmsg_time>{$cut}", 'chatmsg_time ASC');
     foreach ($new as $msg) {
         $this->echoMessage($msg);
     }
     GWF_Session::set(self::$SESS_AJAX_PUB, time());
 }
Пример #5
0
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)));
}
Пример #6
0
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)));
}
Пример #7
0
 public function onAddOption($add_new = true)
 {
     $options = GWF_Session::getOrDefault(self::SESS_OPTIONS, array());
     $posted = Common::getPostArray('opt', array());
     $i = 0;
     foreach ($options as $i => $option) {
         //			$i = $i+1;
         $options[$i] = isset($posted[$i]) ? $posted[$i] : '';
     }
     if ($add_new === true) {
         $i++;
         # = (string)($i+1);
         $options[$i] = '';
     }
     GWF_Session::set(self::SESS_OPTIONS, $options);
     return '';
 }
Пример #8
0
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)));
}
Пример #9
0
 private function profile(GWF_User $user)
 {
     if (false === ($profile = GWF_Profile::getProfile($user->getID()))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     $watcher = GWF_User::getStaticOrGuest();
     if ($profile->isRobotHidden() && $watcher->isWebspider()) {
         return $this->module->error('err_no_spiders');
     }
     if (false === ($prof_view = GWF_Session::getOrDefault('prof_view', false))) {
         $prof_view = array();
     }
     $uid = $user->getID();
     if (!in_array($uid, $prof_view, true)) {
         $prof_view[] = $uid;
         if (false === $profile->increase('prof_views', 1)) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     GWF_Session::set('prof_view', $prof_view);
     $tVars = array('user' => $user, 'profile' => $profile, 'jquery' => Common::getGet('ajax') !== false);
     return $this->module->templatePHP('profile.php', $tVars);
 }
Пример #10
0
function crackcha_answer(WC_Challenge $chall)
{
    if ('' === ($answer = Common::getGetString('answer', ''))) {
        echo $chall->lang('err_no_answer');
        return;
    }
    if (false === ($solution = GWF_Session::getOrDefault('WCC_CRACKCHA_CHARS', false))) {
        echo $chall->lang('err_no_problem');
        return;
    }
    if ($answer === $solution) {
        crackcha_increase_solved();
        echo $chall->lang('msg_success', array(GWF_Session::getOrDefault('WCC_CRACKCHA_SOLVED', 0), WCC_CRACKCHA_NEED));
        if (crackcha_solved()) {
            GWF_Module::loadModuleDB('Forum', true, true);
            Module_WeChall::includeForums();
            $chall->onChallengeSolved(GWF_Session::getUserID());
        }
    } else {
        echo $chall->lang('msg_failed', array($answer, $solution));
    }
    GWF_Session::remove('WCC_CRACKCHA_CHARS');
}
Пример #11
0
    echo GWF_HTML::message(GWF_PAGE_TITLE, $chall->lang('msg_reset'));
} elseif (isset($_POST['mybutton'])) {
    blightInit();
    $answer = Common::getPostString('thehash');
    $solution = blightGetHash();
    $attemp = blightAttemp();
    if (!strcasecmp($answer, $solution)) {
        if ($attemp > BLIGHT2_ATTEMPS + 1) {
            echo GWF_HTML::error(GWF_PAGE_TITLE, $chall->lang('err_attemps', array($attemp, BLIGHT2_ATTEMPS + 1)));
        } elseif (blightTimeout()) {
            echo GWF_HTML::error(GWF_PAGE_TITLE, $chall->lang('err_too_slow'));
        } else {
            if (blightSolved()) {
                $chall->onChallengeSolved(GWF_Session::getUserID());
            } else {
                $have = GWF_Session::getOrDefault('BLIGHT2_CONSECUTIVE', '1');
                $need = BLIGHT2_CONSEC - $have;
                echo GWF_HTML::message(GWF_PAGE_TITLE, $chall->lang('msg_consec_success', array($need)));
            }
            blightReset(false);
        }
    } else {
        echo GWF_HTML::error(GWF_PAGE_TITLE, $chall->lang('err_wrong', array($attemp)));
    }
} elseif (isset($_POST['inject'])) {
    blightInit();
    $password = Common::getPostString('injection');
    $success = blightVuln($password);
    $attemp = blightAttemp() + 1;
    if ($success) {
        echo GWF_HTML::message(GWF_PAGE_TITLE, $chall->lang('msg_logged_in', array($attemp)));
Пример #12
0
<?php

chdir('../../../');
define('GWF_PAGE_TITLE', 'Training: Regex');
require_once 'challenge/html_head.php';
require_once GWF_CORE_PATH . 'module/WeChall/solutionbox.php';
if (false === ($chall = WC_Challenge::getByTitle('Training: Regex'))) {
    $chall = WC_Challenge::dummyChallenge('Training: Regex', 2, '/challenge/training/regex/index.php', false);
}
$chall->showHeader();
$level = GWF_Session::getOrDefault('WCC_T_REGEX', 1);
if (false !== ($answer = Common::getPost('answer'))) {
    $function = 'train_regex_level_' . $level;
    # Users can cause errors... don`t die :) (thx busyr
    GWF_Debug::setMailOnError(false);
    GWF_Debug::setDieOnError(false);
    $solved = call_user_func($function, $chall, $answer);
    GWF_Debug::setMailOnError(true);
    GWF_Debug::setDieOnError(true);
    if ($solved === true) {
        $level++;
        $next_func = 'train_regex_level_' . $level;
        if (!function_exists($next_func)) {
            echo GWF_HTML::message('WeChall', $chall->lang('msg_solved'), false);
            $chall->onChallengeSolved(GWF_Session::getUserID());
            $level = 1;
        } else {
            echo GWF_HTML::message('WeChall', $chall->lang('msg_next_level'), false);
        }
        GWF_Session::set('WCC_T_REGEX', $level);
    } else {
Пример #13
0
 private function getAjaxTimes()
 {
     return GWF_Session::getOrDefault(self::$SESS_LAGGY_AJAX, array(time(), time(), time(), time()));
 }
Пример #14
0
<?php

chdir('../../../../');
define('WCC_IP6_SESS', 'WCC_IP6_SESS');
define('GWF_PAGE_TITLE', 'Training: IPv6');
require_once 'challenge/html_head.php';
require_once GWF_CORE_PATH . 'module/WeChall/solutionbox.php';
if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) {
    $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 1, 'challenge/training/www/ip6/index.php');
}
$chall->showHeader();
$wechall = Module_WeChall::instance();
$level = GWF_Session::getOrDefault(WCC_IP6_SESS, 1);
if (isset($_POST['answer']) && is_string($_POST['answer'])) {
    if (true === wcc_ip6_check_answer($chall, $_POST['answer'], $level)) {
        $_POST['answer'] = '';
        GWF_Session::set(WCC_IP6_SESS, ++$level);
        echo GWF_HTML::message('WCIPv6', $chall->lang('msg_correct', array($level)));
    } else {
        echo $wechall->error('err_wrong');
    }
}
echo GWF_Box::box($chall->lang('info_' . $level), $chall->lang('title', array($level)));
formSolutionbox($chall);
echo $chall->copyrightFooter();
require_once 'challenge/html_foot.php';
function wcc_ip6_check_answer(WC_Challenge $chall, $answer, $level)
{
    require_once 'solutions.php';
    if ($level === count($solutions)) {
        $ip = $_SERVER['REMOTE_ADDR'];
Пример #15
0
 public static function getSolution()
 {
     if (false === ($solution = GWF_Session::getOrDefault('LIV_SMI_SOL'))) {
         return self::genSolution();
     }
     return $solution;
 }
Пример #16
0
/**
 * Check if you were too slow.
 * @return true|false
 */
function blightTimeout()
{
    if (false === ($start = GWF_Session::getOrDefault('BLIGHT3_TIME_START', false))) {
        return true;
    } else {
        return time() - $start > BLIGHT3_TIME;
    }
}
Пример #17
0
<?php

chdir('../../../');
define('GWF_PAGE_TITLE', 'The Last Hope');
require_once 'challenge/html_head.php';
require GWF_CORE_PATH . 'module/WeChall/solutionbox.php';
if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) {
    $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 4, 'challenge/bsdhell/thelasthope/index.php', false);
}
$chall->showHeader();
if (strcasecmp(Common::getPost('answer'), 'username_password') === 0) {
    $count = GWF_Counter::getCount('WC_BSD_LH_DOLT');
    if (false === GWF_Session::getOrDefault('WC_BSD_LH_DOLT', false)) {
        $count++;
        GWF_Counter::saveCounter('WC_BSD_LH_DOLT', $count);
        GWF_Session::set('WC_BSD_LH_DOLT', '1');
    }
    echo GWF_HTML::message('The Last Hope', $chall->lang('msg_literal'), false);
    echo GWF_HTML::error('The Last Hope', $chall->lang('err_literal', array($count)), false);
} else {
    $chall->onCheckSolution();
}
htmlTitleBox($chall->lang('title'), $chall->lang('info', array('bsd_thelasthope.elf')));
formSolutionbox($chall);
echo $chall->copyrightFooter();
require_once 'challenge/html_foot.php';
Пример #18
0
 /**
  * Get the users nickname. Guests can choose their nick once per session.
  * Returns false if no nick has been set yet.
  * @return string or false
  */
 public function getNickname()
 {
     if (false !== ($user = GWF_Session::getUser())) {
         return $user->getVar('user_name');
     }
     return GWF_Session::getOrDefault(self::$SESS_NICKNAME, false);
 }
Пример #19
0
 /**
  * Get temp order from session or false.
  * @return GWF_Orderable
  */
 public static function getTempOrder()
 {
     if (false === ($object = GWF_Session::getOrDefault(self::SESS_ORDER, false))) {
         return false;
     }
     return unserialize($object);
 }
Пример #20
0
 public function isSuperuser()
 {
     return GWF_Session::getOrDefault(self::SUPERHASH_SESS, 0) > time();
 }
Пример #21
0
 public static function wantRightPanel()
 {
     return GWF_Session::getOrDefault('WC_RIGHT_PANEL', self::$RIGHT_PANEL) === true;
 }
Пример #22
0
 private function getFile()
 {
     return GWF_Session::getOrDefault(self::SESS_FILE, false);
 }
Пример #23
0
function salesman_check_answer_B(WC_Challenge $chall, $answer)
{
    // 	if ($answer === 'cheat')
    // 	{
    // 		return true;
    // 	}
    if (0 === preg_match_all('/((\\d+)([A-Z]+))/i', $answer, $matches)) {
        echo $chall->lang('err_format') . PHP_EOL;
        return false;
    }
    GWF_Session::remove('WCC_TR_CU_LEVEL_HAS_PB');
    $list = GWF_Session::get('WCC_TR_CU_LIST');
    $amounts = $matches[2];
    $names = $matches[3];
    $len = count($names);
    $price = 0;
    $amount = 0;
    $stock = GWF_Session::getOrDefault('WCC_TR_CU_STOCK', 1);
    $stocks = array();
    for ($i = 0; $i < $len; $i++) {
        $name = $names[$i];
        $amt = $amounts[$i];
        if (!is_numeric($amt)) {
            echo $chall->lang('err_item_num', array($name)) . PHP_EOL;
            continue;
        }
        $amt = (int) $amt;
        if ($amt < 0) {
            echo $chall->lang('err_item_num', array($name)) . PHP_EOL;
            continue;
        }
        if (isset($stocks[$name])) {
            $stocks[$name] += $amt;
        } else {
            $stocks[$name] = $amt;
        }
        if ($stocks[$name] > $stock) {
            echo $chall->lang('err_item_stock', array($stocks[$name], $name, $stock)) . PHP_EOL;
            continue;
        }
        $amount += $amt;
        if (!array_key_exists($name, $list)) {
            echo $chall->lang('err_item', array($name)) . PHP_EOL;
            continue;
        }
        $p = $list[$name];
        $price += $amt * $p;
    }
    $correct = true;
    $correct_amt = salesman_itemcount();
    if ($amount !== $correct_amt) {
        echo $chall->lang('err_item_count', array($amount, $correct_amt)) . PHP_EOL;
        $correct = false;
    }
    $correct_price = GWF_Session::get('WCC_TR_CU_PRICE');
    if ($price !== $correct_price) {
        echo $chall->lang('err_price', array($price, $correct_price)) . PHP_EOL;
        $correct = false;
    }
    $now = microtime(true);
    $start = GWF_Session::get('WCC_TR_CU_TIME');
    $needed = $now - $start;
    if ($needed > WCC_TR_CU_TIMEOUT) {
        echo $chall->lang('err_timeout', array(sprintf('%.02f', $needed), WCC_TR_CU_TIMEOUT)) . PHP_EOL;
        $correct = false;
    }
    return $correct;
}
Пример #24
0
 public static function getSavedPreview()
 {
     if (false === ($news = GWF_Session::getOrDefault(self::SESS_NEWSLETTER, false))) {
         return false;
     }
     return unserialize($news);
 }