ShuDudu's Home was started in 2011, but the web data is lost, so now begin again, I would like to make some friends, I hope you like ShuDudu's home.
Current position: ShuDudu > Life >

[PHP]Disable ip functions

Monday on August 1st, 2005Life

disable functions of ip

Code snippet:

 & lt;?Function check_ip ($range,$ip='') {If ($ip = =') $ip = getenv (& quot;REMOTE_ADDR")If ($ip = = & quot;127.0.0.1") return 1$result = 1If (ereg (& quot; ([0-9] +). ([0-9] +). ([0-9] +). ([0-9] +)/([0-9] +) & quot;,$range,$regs)) {$ipl = ip2long ($ip)$rangel = ip2long ($regs [1]. & quot;.". $regs [2]. & quot;.". $regs [3]. & quot;.". $regs [4])$maskl = 0For ($I = 0; $iTunlt; 31; $iTunes +) {If ($I & lt; $regs [5]-1) {$maskl = $maskl + pow (2, (30muri))}}If (($maskl & $rangel) = ($maskl & $ipl)) {Return 1} else {Return 0}} else {$maskocts = split (& quot;.",$range)$ipocts = split (& quot;.",$ip)For ($iTun0; $ifolltter4; $iposit +) {If (& quot; [([0-9] +)-([0-9] +)] & quot;,$maskocts [$I], $regs)) {If (($ipocts [$I] & gt; $regs [2]) | ($ipocts [$I] & lt; $regs [1])) {$result = 0}}Else{If ($maskocts [$I] & lt;> $ipocts [$I]) {$result = 0}}}}Return $result}Function auth_ip () {$result = 0$null_check = 1$path = & quot;ip.cf";//ip restriction profile, in the format of each line/*Xxx.xxx.xxx.xxx such as 127.0.0.2Xxx.xxx.xxx. [yyy-zzz] such as 1270.0.0. [2-23]Xxx.xxx.xxx.xxx/nn such as 127.0.0.0 Universe 24,/$fg=@fopen ($path,"r")While ($line=@fgets ($fg,1024)) {$line = trim ($line)$line=ereg_replace (& quot;#.*","",$line)If ($line! = & quot;") {$null_check = 0If (check_ip ($line)) {Fclose ($fg)Return 1}}}@ fclose ($fg)If ($null_check = = 1) return 1Return $result}? & gt

-
from: im286

Copyright Protection: ShuDudu from the original article, reproduced Please keep the link: https://www.shududu.com/life/PHP-Disable-ip-functions.htm