核心函数代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
function check_ip(){
$ALLOWED_IP = array ( '192.168.2.*' , '127.0.0.1' , '192.168.2.49' );
$IP =getIP();
$check_ip_arr = explode ( '.' , $IP );
#限制IP
if (!in_array( $IP , $ALLOWED_IP )) {
foreach ( $ALLOWED_IP as $val ){
if ( strpos ( $val , '*' )!==false){
$arr = array ();
$arr = explode ( '.' , $val );
$bl =true;
for ( $i =0; $i
|
在需要检测的地方 加上调用 check_ip(); 即可; 本函数提供只允许指定的IP访问文件,并提供IP中*号通配符 匹配多IP