Php prohibits access from an ip address or ip address segment. Php: how to disable access from an ip address or ip address segment. This section describes how to disable access from an ip address or ip address segment in php. The specific analysis is as follows: because php also prohibits access from an ip address or ip address segment, phpip
This article describes how php disables access from an ip address or ip address segment and shares it with you for your reference. The specific analysis is as follows:
Because I have not studied Apache and nginx in depth, I used PHP to write a small program that can disable the address.
You only need:
<?php include("banIP.php");?>
You can.
Disable a single ip address as follows:
<? Php // disable ip address $ ip = $ _ SERVER ["REMOTE_ADDR"]; $ ban = file_get_contents ("ban. dat "); if (stripos ($ ban, $ ip) {die (" Your IP Address is: $ ip, you're forbiden to view this page! ");} Echo" Your IP Address is: $ ip, hello! ";?>
The ban. dat file is as follows:
BEGIN: 119.184.251.245 127.0.0.1 192.168.1.100
The disabled ip segment is as follows:
<? Php // disable ip address $ ip = $ _ SERVER ["REMOTE_ADDR"]; while ($ ip [count ($ IP-1)]! = '. ') $ Ip = substr ($ ip, 1,-1); // sort out the ip segment $ ban = file_get_contents ("ban. dat "); if (stripos ($ ban, $ ip) {die (" U'RE forbiden to view this page! ");} Echo" Hello! ";?>
I hope this article will help you with php programming.
Examples in this article describe how php disables access from an ip address or ip address segment. The specific analysis is as follows...