PHP Limits IP Address range method, PHP limit IP range
This article explains how PHP restricts the range of IP addresses. Share to everyone for your reference. Specific as follows:
Only IP addresses within a limited scope can be accessed
function get_real_ipaddress () {if (!empty ($_server[' http_client_ip ')) { return $_server[' http_client_ip '];} ElseIf (!empty ($_server[' http_x_forwarded_for ')) { return $_server[' http_x_forwarded_for '];} return $_server[' Remote_addr '];} function In_ip_range ($ip, $ip _one, $ip _two = False) {if (! $ip _two) { return $ip _one = = = $ip;} return Ip2long ($ip _one) *-1 >= ip2long ($IP) *-1 && ip2long ($ip _two) *-1 <= ip2long ($IP) *-1;} function Validate_ip () {$ip = explode (': ', get_real_ipaddress ()); $ip = $ip [0]; if (In_ip_range ($ip, ' 212.76.229.115 ', ' 21 2.76.229.120 ') { return true;} else if (In_ip_range ($ip, ' 194.78.4.66 ', ' 194.78.4.79 ')) { return true;} else if ( In_ip_range ($ip, ' 194.8.4.78 ', ' 194.8.4.78 ')) { return true;} else if (In_ip_range ($ip, ' 0 ', ' 1 ')) {//local Retu RN true; } header (' location:http://www.bkjia.com ');}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/976691.html www.bkjia.com true http://www.bkjia.com/PHPjc/976691.html techarticle PHP Limits IP address range methods, PHP restricted IP range This article describes how PHP restricts the range of IP addresses. Share to everyone for your reference. Specific as follows: Only within limits ...