Home  >  Article  >  Backend Development  >  How to ban access to a certain IP or IP address range in PHP

How to ban access to a certain IP or IP address range in PHP

墨辰丷
墨辰丷Original
2018-06-13 09:59:312344browse

This article mainly introduces the method of prohibiting access to a certain IP or IP address range in PHP, involving the operation skills of server variables $_SERVER, files and strings. It has certain reference value. Friends in need can refer to it

The example in this article describes how PHP prohibits access to a certain IP or IP address range. The specific analysis is as follows:

Because I have not studied Apache and nginx in depth, I wrote a small program in PHP that can disable addresses
When using, just:

Disable a single ip as follows:

ban.dat file is as follows:

BEGIN: 
119.184.251.245 
127.0.0.1 
192.168.1.100

Disable ip segment As follows:

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

Brief introduction to the method of implementing httpRequest in PHP

##PHP framework laravel installation and configuration instructions

How to operate directories and files in php

The above is the detailed content of How to ban access to a certain IP or IP address range in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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