當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CSRF::ValidateToken方法代碼示例

本文整理匯總了PHP中CSRF::ValidateToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP CSRF::ValidateToken方法的具體用法?PHP CSRF::ValidateToken怎麽用?PHP CSRF::ValidateToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CSRF的用法示例。


在下文中一共展示了CSRF::ValidateToken方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doCheckLogin

function doCheckLogin()
{
    global $config;
    if (!isset($_POST[LOGIN_FORM_USERNAME]) || !isset($_POST[LOGIN_FORM_PASSWORD])) {
        return;
    }
    $username = trim(stripslashes(@$_POST[LOGIN_FORM_USERNAME]));
    $password = stripslashes(@$_POST[LOGIN_FORM_PASSWORD]);
    session_init();
    if (CSRF::isEnabled() && !isset($_SESSION[CSRF::SESSION_KEY])) {
        echo '<p style="color: red;">PHP Session seems to have failed!</p>';
        CSRF::ValidateToken();
        exit;
    }
    CSRF::ValidateToken();
    $password = md5($password);
    $config['user']->doLogin($username, $password);
    if ($config['user']->isOk() && getVar('error') == '') {
        // success
        $lastpage = getLastPage();
        if (strpos($lastpage, 'login') !== FALSE) {
            $lastpage = './';
        }
        ForwardTo($lastpage);
        exit;
    }
    unset($username, $password);
}
開發者ID:Furt,項目名稱:WebAuctionPlus,代碼行數:28,代碼來源:login.php

示例2: doChangePassword

function doChangePassword()
{
    global $config;
    if (!isset($_POST[CHANGEPASS_FORM_PASSWORD]) || !isset($_POST[CHANGEPASS_FORM_CONFIRM])) {
        return NULL;
    }
    $password = trim(stripslashes(@$_POST[CHANGEPASS_FORM_PASSWORD]));
    $confirm = trim(stripslashes(@$_POST[CHANGEPASS_FORM_CONFIRM]));
    unset($_POST[CHANGEPASS_FORM_PASSWORD]);
    unset($_POST[CHANGEPASS_FORM_CONFIRM]);
    session_init();
    if (CSRF::isEnabled() && !isset($_SESSION[CSRF::SESSION_KEY])) {
        echo '<p style="color: red;">PHP Session seems to have failed!</p>';
        CSRF::ValidateToken();
        exit;
    }
    CSRF::ValidateToken();
    // check passwords match
    if ($password !== $confirm) {
        $_SESSION['error'][] = 'Passwords don\'t match. Please try again.';
        return FALSE;
    }
    // check password length
    if (strlen($password) < 6) {
        $_SESSION['error'][] = 'Password is to short, must be at least 6 characters long.';
        return FALSE;
    }
    // update password in database
    $result = $config['user']->ChangePassword(md5($password));
    // successful change
    if ($result !== FALSE) {
        // password has been changed
        $_SESSION['Temp Pass'] = FALSE;
        $lastpage = getLastPage();
        if (strpos($lastpage, 'login') !== FALSE || strpos($lastpage, 'changepass') !== FALSE) {
            $lastpage = './';
        }
        ForwardTo($lastpage);
        exit;
    }
    return FALSE;
}
開發者ID:GRANTSWIM4,項目名稱:WebAuctionPlus-1.2,代碼行數:42,代碼來源:changepass.php

示例3: doCheckLogin

function doCheckLogin()
{
    global $config;
    if (!isset($_POST[LOGIN_FORM_USERNAME]) || !isset($_POST[LOGIN_FORM_PASSWORD])) {
        return NULL;
    }
    $username = trim(stripslashes(@$_POST[LOGIN_FORM_USERNAME]));
    $password = trim(stripslashes(@$_POST[LOGIN_FORM_PASSWORD]));
    unset($_POST[LOGIN_FORM_PASSWORD]);
    session_init();
    if (CSRF::isEnabled() && !isset($_SESSION[CSRF::SESSION_KEY])) {
        echo '<p style="color: red;">PHP Session seems to have failed!</p>';
        CSRF::ValidateToken();
        exit;
    }
    CSRF::ValidateToken();
    // check hashed password
    $result = $config['user']->doLogin($username, md5($password));
    // try temporary password
    if ($result !== TRUE && strlen($password) < 32) {
        //    unset($_GET['error']);
        $result = $config['user']->doLogin($username, $password);
        if ($result === TRUE && $config['user']->isOk() && getVar('error') == '') {
            $_SESSION['Temp Pass'] = TRUE;
            unset($_SESSION['error']);
        }
    }
    // successful login
    if ($result !== FALSE && $config['user']->isOk() && getVar('error') == '') {
        $lastpage = getLastPage();
        if (strpos($lastpage, 'login') !== FALSE) {
            $lastpage = './';
        }
        ForwardTo($lastpage);
        exit;
    }
    unset($username, $password);
    return TRUE;
}
開發者ID:GRANTSWIM4,項目名稱:WebAuctionPlus-1.2,代碼行數:39,代碼來源:login.php

示例4: getLastPage

    if ($config['user']->isLocked()) {
        echo '<center><h2>Your inventory is currently locked.<br />Please close your in game inventory and try again.</h2><br /><a href="' . getLastPage() . '">Back to last page</a></center>';
        ForwardTo(getLastPage(), 4);
        exit;
    }
    // buy auction
    if (AuctionFuncs::BuyAuction(getVar('auctionid', 'int', 'post'), getVar('qty', 'int', 'post'))) {
        echo '<center><h2>Auction purchased successfully!</h2><br /><a href="' . getLastPage() . '">Back to last page</a></center>';
        ForwardTo(getLastPage(), 2);
        exit;
    }
    echo $config['error'];
    exit;
}
if ($config['action'] == 'cancel') {
    CSRF::ValidateToken();
    // inventory is locked
    if ($config['user']->isLocked()) {
        echo '<center><h2>Your inventory is currently locked.<br />Please close your in game inventory and try again.</h2><br /><a href="' . getLastPage() . '">Back to last page</a></center>';
        ForwardTo(getLastPage(), 4);
        exit;
    }
    // cancel auction
    if (AuctionFuncs::CancelAuction(getVar('auctionid', 'int', 'post'))) {
        echo '<center><h2>Auction canceled!</h2><br /><a href="' . getLastPage() . '">Back to last page</a></center>';
        ForwardTo(getLastPage(), 2);
        exit;
    }
    echo $config['error'];
    exit;
}
開發者ID:Furt,項目名稱:WebAuctionPlus,代碼行數:31,代碼來源:auctions.php


注:本文中的CSRF::ValidateToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。