获取访问用户所在国家,省份以及城市信息

php 代码

function id_getip(){
 if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) {
   $ip = getenv("HTTP_CLIENT_IP");
  } else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) {
   $ip = getenv("HTTP_X_FORWARDED_FOR");
  } else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) {
   $ip = getenv("REMOTE_ADDR");
  } else  if (isset ($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) {
   $ip = $_SERVER['REMOTE_ADDR'];
  } else {
   $ip = "unknown";
  }
 return $ip;
}
function id_getLocation($ip=''){
 empty($ip) && $ip = id_getip();
 if($ip=="127.0.0.1") return "本机地址";
 $api = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=$ip"; 
 $json = @file_get_contents($api);//调用新浪IP地址库 
 $arr = json_decode($json,true);//解析json
 $country = $arr['country']; //取得国家
 $province = $arr['province'];//获取省份 
 $city = $arr['city']; //取得城市
 if((string)$country == "中国"){
  if((string)($province) != (string)$city){
   $_location = $country." ".$province." ".$city;
  }else{
   $_location = $country.$city;      
  }
 }else{
  $_location = $country;
 }
 return $_location;
}

  翻  牌  子

JS - 禁止右键等代码

js 代码

function stop(){ 
        return false; 
    } 
    document.oncontextmenu = stop;//禁止右键
    document.oncopy = stop;//禁止复制
    document.onselectstart = stop;//禁止选取
    document.onkeydown = KeyPress;
    function  KeyPress(num){
        var keycode = event.keyCode;
        if(keycode == 8)//禁止退格健
        {
            event.keyCode = 0;
            return;
        }
        if(keycode >= 112 && keycode <= 123)//禁止f1-f12
        {
            event.keyCode = 0 ;
            event.returnValue = false;
            return;
        }
    }

  翻  牌  子