Home Backend Development PHP Tutorial PHP中如何防止外部恶意提交调用ajax接口_php实例

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();
}
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 Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to Prevent DDoS Attacks: Protect Your Linux Server How to Prevent DDoS Attacks: Protect Your Linux Server Sep 09, 2023 pm 02:15 PM

How to Prevent DDoS Attacks: Protect Your Linux Server

Preventing path traversal attacks in Java Preventing path traversal attacks in Java Aug 09, 2023 pm 06:36 PM

Preventing path traversal attacks in Java

How to use PHP to prevent registration attacks? How to use PHP to prevent registration attacks? Aug 19, 2023 pm 10:08 PM

How to use PHP to prevent registration attacks?

How to prevent null pointer exceptions in C++ development How to prevent null pointer exceptions in C++ development Aug 22, 2023 pm 12:40 PM

How to prevent null pointer exceptions in C++ development

PHP implementation skills to prevent SQL injection PHP implementation skills to prevent SQL injection Jun 23, 2023 pm 12:02 PM

PHP implementation skills to prevent SQL injection

How to prevent file inclusion attacks using PHP How to prevent file inclusion attacks using PHP Jun 24, 2023 pm 04:22 PM

How to prevent file inclusion attacks using PHP

How to prevent words in HTML table from breaking into lines? How to prevent words in HTML table from breaking into lines? Sep 16, 2023 pm 10:45 PM

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

What are the techniques for using closures to prevent memory leaks? What are the techniques for using closures to prevent memory leaks? Jan 13, 2024 pm 01:01 PM

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

See all articles