Пример #1
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);
 }
Пример #2
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)));
}
Пример #3
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)));
}
Пример #4
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');
}
Пример #5
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;
}
Пример #6
0
/**
 * You successfully hacked it one time.
 * But return false if you need a few more consecutive hacks to solve the chall.
 * @return true|false
 */
function blightSolved()
{
    $solvecount = GWF_Session::getOrDefault('BLIGHT3_CONSECUTIVE', 0);
    $solvecount++;
    blightReset(false);
    if ($solvecount >= BLIGHT3_CONSEC) {
        GWF_Session::remove('BLIGHT3_CONSECUTIVE');
        return true;
    }
    GWF_Session::set('BLIGHT3_CONSECUTIVE', $solvecount);
    return false;
}
Пример #7
0
 private function clearFile()
 {
     GWF_Session::remove(self::SESS_FILE);
 }
Пример #8
0
 private function onAddPoll()
 {
     $form = $this->getForm();
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors . $this->templateAddPoll();
     }
     $opts = Common::getPostArray('opt', array());
     if (count($opts) === 0) {
         return $this->module->error('err_no_options') . $this->templateAddPoll();
     }
     $user = GWF_Session::getUser();
     $name = GWF_VoteMulti::createPollName(GWF_Session::getUser());
     $title = $form->getVar('title');
     $gid = $form->getVar('gid');
     $level = $form->getVar('level');
     $reverse = isset($_POST['reverse']);
     $is_multi = isset($_POST['multi']);
     $guest_votes = isset($_POST['guests']);
     $is_public = isset($_POST['public']);
     $result = (int) $form->getVar('view');
     if ($is_public && !$this->module->mayAddGlobalPoll($user)) {
         return $this->module->error('err_global_poll') . $this->templateAddPoll();
     }
     GWF_Session::remove(self::SESS_OPTIONS);
     return Module_Votes::installPollTable($user, $name, $title, $opts, $gid, $level, $is_multi, $guest_votes, $is_public, $result, $reverse);
 }
Пример #9
0
 public static function dropTempOrder()
 {
     GWF_Session::remove(self::SESS_ORDER);
 }
Пример #10
0
 public static function Validate($sUserCode, $bCaseInsensitive = true)
 {
     if ($bCaseInsensitive) {
         $sUserCode = strtoupper($sUserCode);
     }
     if ($sUserCode === GWF_Session::get(CAPTCHA_SESSION_ID)) {
         // clear to prevent re-use
         GWF_Session::remove(CAPTCHA_SESSION_ID);
         return true;
     }
     return false;
 }
Пример #11
0
 public static function cleanupPreview()
 {
     GWF_Session::remove(self::SESS_NEWSLETTER);
 }