Php functions that prohibit ip access
| Provide a function to prohibit IP access, including a function that trusts IP access. For more information, see.
The complete code is as follows.
$ Regs [2]) | ($ ipocts [$ I] <$ regs [1]) {$ result = 0 ;}} else {if ($ maskocts [$ I] <> $ ipocts [$ I]) {$ result = 0 ;}}} return $ result;} function auth_ip () {$ result = 0; $ null_check = 1; $ path = "ip. cf "; // ip address restriction configuration file. the format of each line is/* xxx. xxx. xxx. xxx for example 127.0.0.2xxx.xxx.xxx. [yyy-zzz] for example, 255.0.0.0. [2-23] xxx. xxx. xxx. xxx/nn such as 127.0.0.0/24 */$ fg = @ fopen ($ path, "r"); while ($ line = @ fgets ($ fg, 1024 )) {$ line = trim ($ line); $ line = ereg _ Replace ("#. *", "", $ line); if ($ line! = "") {$ Null_check = 0; if (check_ip ($ line) {fclose ($ fg); return 1 ;}}@ fclose ($ fg ); if ($ null_check = 1) return 1; return $ result ;}?>Articles you may be interested in: PHP disables IP address access to the website. php disables access from a single IP address or IP address segment. |