modulework/csrfwork 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

modulework/csrfwork

Composer 安装命令:

composer require modulework/csrfwork

包简介

A simple way of protecting forms regarding to CSRF

README 文档

README

A simple way of protecting forms regarding to CSRF

Installation:

  • Place the csrf.php file into your application folder
  • Include it include_once 'csrf.php';
  • and initate it: CSRF::init();

HowTo

There are 2 methods available for you to interact with your cache.

  • token()
  • check($token)

TOKEN

token()

This method will return the token for the current and next request.

Example usage:

<input type="hidden" value="<?php echo CSRF::token(); ?>" name="csrf_token" />

This will add a hidden input field to you form with the name csrf_token and the value is the token itself. How we can use we' ll see in the check() part.

CHECK

check($token)

This method will check if a string matches the token generated in the previous request.

  • $token: string: the string to check

Example usage:

if (CSRF::check($_POST['csrf_token'])) {   
    // Everything' s fine   
} else {   
    // The post request was not submited by the form on your site.   
    die('DIE STUPID ATTACKER'); //Take 'em down...   
}   

You can always have a look at the PHP doc for a brief explanation.

统计信息

  • 总下载量: 26
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache
  • 更新时间: 2013-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固