>>  Site Map >>  Forums >>  PHP+MySql

Forum module - topics in forum:



PHP+MySql - Coding mã nguồn mở rât thông dụng để làm web, và hệ thống cơ sỏ dữ liệu rất mạnh duợc ưa chuộng



Denied arange IP by PHP ( some part of web not alow viewed by some IP ) goog

Denied arange IP by PHP ( some part of web not alow viewed by some IP ) goog

Đây là đoạn mã nhỏ một số bạn có hỏi mình làm sao đẻ ngăn các IP việt nam không thấy đuọc google ads
đẻ ngăn các IP vào wweb các bạn có thể dùng htaccess nhưng không tiện lợi chút nào.. vì một số phần của web vấn muốn cho mọi nguỏi xem

Code: :

<?
/*
58.186.0
125.212.128
125.214.0
125.234.0
202.6.2
202.6.96
202.60.96
202.78.224
202.151.160
203.113.128
203.119.8
203.119.36
203.160.0
203.160.96
203.161.0
203.162.0
203.190.160
203.210.128
210.245.0
218.100.10
218.100.14
221.132.0
221.133.0
222.252.0
*/
$ip_Strip = array('192.168.1' => 1, "125.214.0" => 2, "58.186.0" => 3);
$ip = userIP();
if (array_key_exists($ip, $ip_Strip)){
   echo "other ads will be here";
}
else {
echo ' the google ads will here ';
}
function userIP()
      {
       //This returns the True IP of the client calling the requested page
       // Checks to see if HTTP_X_FORWARDED_FOR
       // has a value then the client is operating via a proxy
       $userIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
       if($userIP == "")
        {
           $userIP = $_SERVER['REMOTE_ADDR'];
        }
        // return the IP we've figured out:
      //$endDotPos = end(explode(".", $userIP));
      $endDotPos = strrpos($userIP, ".");
      $userIP = substr($userIP, 0, $endDotPos);
       
       echo $userIP;

        return $userIP;
 }
?>


mình cũng cung cấp sẵn các ip việt nam đẻ các bạn dùng.. muốn tham khảo them kiếm googe ip2contries nhé




Search from ALEXA


put your ads here