当前位置: 首页>>代码示例>>PHP>>正文


PHP GWF_Session::getOrDefault方法代码示例

本文整理汇总了PHP中GWF_Session::getOrDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP GWF_Session::getOrDefault方法的具体用法?PHP GWF_Session::getOrDefault怎么用?PHP GWF_Session::getOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GWF_Session的用法示例。


在下文中一共展示了GWF_Session::getOrDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prog2CheckResult

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;
}
开发者ID:sinfocol,项目名称:gwf3,代码行数:25,代码来源:index.php

示例2: welcome

 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);
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:26,代码来源:Welcome.php

示例3: validateCaptcha

 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;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:10,代码来源:GWF_FormValidator.php

示例4: onNewPubmsg

 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());
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:13,代码来源:Ajax_OLD.php

示例5: checkSolution

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)));
}
开发者ID:sinfocol,项目名称:gwf3,代码行数:16,代码来源:index.php

示例6: onAddOption

 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 '';
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:17,代码来源:AddPoll.php

示例7: profile

 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);
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:23,代码来源:Profile.php

示例8: crackcha_answer

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');
}
开发者ID:sinfocol,项目名称:gwf3,代码行数:23,代码来源:crackcha.php

示例9: elseif

    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)));
开发者ID:sinfocol,项目名称:gwf3,代码行数:31,代码来源:index.php

示例10: chdir

<?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 {
开发者ID:sinfocol,项目名称:gwf3,代码行数:31,代码来源:index.php

示例11: getAjaxTimes

 private function getAjaxTimes()
 {
     return GWF_Session::getOrDefault(self::$SESS_LAGGY_AJAX, array(time(), time(), time(), time()));
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:4,代码来源:Ajax.php

示例12: chdir

<?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'];
开发者ID:sinfocol,项目名称:gwf3,代码行数:31,代码来源:index.php

示例13: getSolution

 public static function getSolution()
 {
     if (false === ($solution = GWF_Session::getOrDefault('LIV_SMI_SOL'))) {
         return self::genSolution();
     }
     return $solution;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:7,代码来源:LIVIN_Smile.php

示例14: blightTimeout

/**
 * 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;
    }
}
开发者ID:sinfocol,项目名称:gwf3,代码行数:12,代码来源:vuln.php

示例15: chdir

<?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';
开发者ID:sinfocol,项目名称:gwf3,代码行数:26,代码来源:index.php


注:本文中的GWF_Session::getOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。