PHP中如何防止外部恶意提交调用ajax接口_php实例
Jun 07, 2016 pm 05:08 PM
prevent
我们自己网站写好的ajax接口,如果给自己用,那就限定一下来路域名,判断一下来路即可。
注意:将www.php.net替换成你自己的域名。
复制代码 代码如下:
//判断来路
if(!isset($_SERVER['HTTP_REFERER']) || !stripos($_SERVER['HTTP_REFERER'],'www.php.net')) {
echo 'cann`t access';
exit();
}
if(!isset($_SERVER['HTTP_REFERER']) || !stripos($_SERVER['HTTP_REFERER'],'www.php.net')) {
echo 'cann`t access';
exit();
}
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD

Hot tools Tags

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to Prevent DDoS Attacks: Protect Your Linux Server

Preventing path traversal attacks in Java

How to use PHP to prevent registration attacks?

How to prevent null pointer exceptions in C++ development

PHP implementation skills to prevent SQL injection

How to prevent file inclusion attacks using PHP

How to prevent words in HTML table from breaking into lines?

What are the techniques for using closures to prevent memory leaks?
