Sometimes we hope that the website of Changsha address IP can log in and other areas of IP login, the following I will write a PHP program this can be implemented to restrict the background of an IP segment can login OH.
| The code is as follows |
Copy Code |
Public Function login () { Set IP Segment Login if (getenv ("Http_client_ip")) { $onlineip = getenv (' http_client_ip '); } ElseIf (getenv (' http_x_forwarded_for ')) { $onlineip = getenv (' http_x_forwarded_for '); } ElseIf (getenv (' remote_addr ')) { $onlineip = getenv (' remote_addr '); } else{ $onlineip = $HTTP _server_vars[' remote_addr '); } Echo $onlineip; $adminip = $onlineip; $arrayip = Array (' 117.121.48.* ', ' 127.0.0.* ');//IP segment $ipregexp = implode (' | ', Str_replace (Array (' * ', '. '), Array (' d+ ', '. '), $arrayip)); $allow = Preg_match ("/^ (". $ipregexp. ") $/", $adminip);
if ($allow! = 1) { ShowMessage (' Your IP address is not in the allowed range! '), ' m=admin&c=index&a=login ', 6000); } |
Put the following code into your website login portal call, and then change the m=admin&c=index&a=login to your address on it.
http://www.bkjia.com/PHPjc/633159.html www.bkjia.com true http://www.bkjia.com/PHPjc/633159.html techarticle Sometimes we hope that the website of Changsha address IP can log in and other areas of IP login, the following I will write a PHP program this can be implemented to restrict the background of an IP segment can login Oh ...