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


PHP csrf_token_is_valid函数代码示例

本文整理汇总了PHP中csrf_token_is_valid函数的典型用法代码示例。如果您正苦于以下问题:PHP csrf_token_is_valid函数的具体用法?PHP csrf_token_is_valid怎么用?PHP csrf_token_is_valid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: ID

                if (!$user->save()) {
                    $session->message("Username" . $user->username . " " . "other info for ID (" . $user->id . ")");
                    $session->ok(true);
                    unset($_POST);
                    redirect_to("profile.php");
                } else {
                    unset($_POST);
                    $session->message("User: " . $user->username . " " . "edit failed");
                }
            }
        }
    }
}
if (request_is_post() && request_is_same_domain()) {
    //var_dump($_POST);
    if (!csrf_token_is_valid(3) || !csrf_token_is_recent(3)) {
        $message = "Sorry, request was not valid 3.";
    } else {
        if (isset($_POST['submit']) && $_POST['submit'] === "Update Photo") {
            $user = UpdateUserProfile::find_by_id($session->user_id);
            $valid = new formValidation();
            //    echo get_class_vars('User');
            //            $user->unset_required_fields("username","password",'nom','email',);
            //            $user->unset_required_fields("password",'nom','user_type_id');
            //            $user->unset_table_fields(array('username', 'hashed_password', 'nom','email','user_type','user_type_id','block_user','unread_message','unread_notification','first_name', 'last_name','reset_token','address','cp','city','country','phone','mobile'));
            $user->unset_table_fields(array('hashed_password'));
            if (empty($valid->errors)) {
                if (empty($_FILES['user_image'])) {
                    //                    $user->save();
                    redirect_to("profile.php");
                }
开发者ID:kamy333,项目名称:rajah,代码行数:31,代码来源:profile.php

示例2: redirect_to

<?php

require_once "../../includes/initialize.php";
// Rather than require setting up a real database,
// we can fake one instead.
$message = "";
$token = $_GET['token'];
// Confirm that the token sent is valid
$user = User::find_by_reset_token($token);
if (!isset($user) || !$user) {
    // Token wasn't sent or didn't match a user.
    $session->message("Did not find you try again");
    redirect_to('login_forgot_password_username.php');
}
if (request_is_post() && request_is_same_domain()) {
    if (!csrf_token_is_valid() || !csrf_token_is_recent()) {
        $message = "Sorry, request was not valid.";
    } else {
        // CSRF tests passed--form was created by us recently.
        // retrieve the values submitted via the form
        $password = trim($_POST['password']);
        $password_confirm = trim($_POST['password_confirm']);
        $valid = new FormValidation();
        $valid->validate_presences(array('password', 'password_confirm'));
        if ($password !== $password_confirm) {
            $valid->errors['password_confirmation'] = "Password confirmation does not match password.";
        }
        if (empty($valid->errors)) {
            $user->password = $password;
            $user->save();
            $user->delete_reset_token();
开发者ID:kamy333,项目名称:rajah,代码行数:31,代码来源:login_reset_password.php

示例3: die_on_csrf_token_failure

function die_on_csrf_token_failure($id = "")
{
    if (!csrf_token_is_valid($id)) {
        die("CSRF token validation failed.");
    }
}
开发者ID:kamy333,项目名称:rajah,代码行数:6,代码来源:security_csrf_token_functions.php


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