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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

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)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1252
24
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 DDoS attacks are a common cybersecurity threat that can make a server overloaded or unavailable. In this article, we will introduce several ways to protect your Linux server from DDoS attacks, including optimizing network configuration, using firewalls, and installing DDoS protection software. Optimize network configuration Optimization of network configuration is the first step in ensuring that your server can withstand large amounts of traffic. The following are several key configuration optimization suggestions: Increase the bandwidth of the server: Make sure

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? With the development of the Internet, the registration function has become one of the necessary functions for almost all websites. However, bad elements also took this opportunity to carry out registration attacks and maliciously registered a large number of fake accounts, causing many problems to the website. In order to prevent registration brush attacks, we can use some effective technical means. This article will introduce a method to prevent registration attacks using the PHP programming language and provide corresponding code examples. 1. IP address restriction registration attacks usually come from the same IP address, so

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 With the rapid development of the Internet, network security issues have become more and more important. Path traversal attacks are a common security vulnerability in which attackers obtain system information, read sensitive files, or execute malicious code by manipulating file paths. In Java development, we need to take appropriate methods to prevent path traversal attacks. The principle of path traversal attacks is caused by incorrect processing of file paths entered by users. Here is a simple example code to demonstrate how a path traversal attack works: impo

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 Summary: This article mainly introduces how to prevent null pointer exceptions in C++ development, including rational use of pointers, avoiding dangling pointers, using smart pointers, etc. Keywords: C++ development, null pointer exception, pointer, dangling pointer, smart pointer Introduction: In C++ development, null pointer exception is a common and troublesome problem. Null pointer exceptions occur when we do not handle pointers correctly in our code or use dangling pointers. This article will introduce some ways to prevent null pointer exceptions

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

How to use closures to prevent memory leaks? A memory leak means that when a program is running, due to some reasons, the memory that is no longer used cannot be recycled and released in time, which ultimately leads to excessive memory usage and affects the performance and stability of the program. In JavaScript, closures are a common problem that causes memory leaks. This article will introduce what closures are, how closures can cause memory leaks, and provide some considerations and sample code when using closures. What is a closure? Closure refers to the function inside the function, which can access the external function

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

SQL injection is a common attack method that bypasses an application's security verification by injecting malicious input into an attacker's SQL query. This type of attack is commonly seen in web applications, where PHP is a widely used programming language. In PHP, application programmers can use the following techniques to prevent SQL injection. Using Prepared Statements PHP provides a technology called prepared statements, which is a safe way to prevent SQL injection. A prepared statement is a way of converting query words into a SQL query before executing it.

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

When you need to break a line, you can use the word-break property in CSS to change the line break. Text line breaks usually appear only in specific positions, such as after a space or hyphen. Following is the syntax for word-break:normal|break-all|keep-all|break-word|initial|inherit; Let us read this article in depth to get a better understanding of how to prevent word breaks in HTML tables. Before that, let's take a quick look at HTML tables. HTML tables Web designers can use HTML tables to organize information such as text, images, links, and other tables into rows and columns of cells. <tabl

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

With the rapid development of the Internet, security issues have become an important issue that cannot be ignored. File inclusion attacks are a very common and dangerous attack method. The key is that attackers can use this vulnerability to obtain sensitive information on the server. Therefore, how to use PHP to prevent file inclusion attacks has become a problem that many developers must solve. 1. Understand file inclusion attacks File inclusion attacks are a common web attack and are listed as one of the top ten web security vulnerabilities of OWASP (Open Web Application Security Project). it can

See all articles