实现的原理比较简单只要获取用户IP然后再在我们黑名单库中验证一下当前IP是不是存在即可进行过滤操作了,具体例子如下。
段代码是我在网上搜相关解决方法时搜到的,这个类的makePregIP函数逻辑有点问题,我修改了下可以使用了。这个类得功能是允许白名单中的IP地址访问,如果要实现限制黑名单中的IP地址访问,简单修改下checkIP函数中的代码逻辑就可以了。
使用方法
代码如下 | 复制代码 |
$allow_ip = array("192.168.1.1","210.10.2.1-20","222.34.4.*","127.0.0.1"); |
allowIP类文件
代码如下 | 复制代码 |
class allowIp { |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool