工具教程

LogHao工具教程 > 垃圾蜘蛛IP段屏蔽方法PHP版本

垃圾蜘蛛IP段屏蔽方法PHP版本

<?php
 
 
function heiget_real_ip(){
    $ip=false;
    if(!empty($_SERVER["HTTP_CLIENT_IP"])){
        $ip = $_SERVER["HTTP_CLIENT_IP"];
    }
    if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
        $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
        if($ip){ array_unshift($ips, $ip); $ip = FALSE;}
        for($i = 0; $i < count($ips); $i++){
            if(!preg_match ("^(10|172\.16|192\.168)\.", $ips[$i])){
                $ip = $ips[$i];
                break;
            }
        }
    }
    return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
 
$heiips = heiget_real_ip();$heiips = '#' . substr( $heiips , 0 , (strrpos($heiips , '.') + 1) ) . '#';
 
$heiipsarr = 'ip#192.243.55.#
#94.154.239.#
#163.172.65.#
#163.172.66.#
#193.111.140.#
#51.255.65.#
#85.14.244.#
#86.132.215.#
#192.243.55.#
#216.244.66.#
#164.132.161.#
#51.254.129.#
##
##
##
##
##
##ip';
 
 
if( strpos( $heiipsarr , $heiips ) ){header("location: http://www.semrush.com/bot.html");exit;}


四川快乐12最长遗漏