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, '192. 76.229.115 ', '192. 76.229.120 ')){ Return true; } Else if (in_ip_range ($ ip, '192. 78.4.66 ', '192. 78.4.79 ')){ Return true; } Else if (in_ip_range ($ ip, '192. 8.4.78 ', '192. 8.4.78 ')){ Return true; } Else if (in_ip_range ($ ip, '0', '1') {// local Return true; } Header ('location: http://www.bkjia.net '); } |