zoukankan      html  css  js  c++  java
  • ip地址查询城市

    public bool IsExitCityByIP(string ip,out string city)
             {            
                    string[] ips = ip.Split('.');
                     double ipNum = Convert.ToDouble(ips[0]) * 16777216 + Convert.ToDouble(ips[1]) * 65536 + Convert.ToDouble(ips[2]) * 256 + Convert.ToDouble(ips[3]);
     
                    string[] cityName = { "Shenzhen", "Shanghai", "Guangzhou", "Hong Kong" };
                     IPGroupCity c = GetAddressByIPNum(ipNum);
                     city = c.City.ToString();
                     if (city != null)计算
                     {
                         for (int i = 0; i < cityName.Length; i++)
                         {
                             if (cityName[i].Equals(city))
                             {
                                 lblAddress.Text = "您查询的IP:" + txtIP.Text + "<br>IP地址位置:" + c.Country_name + "--" + city;
                                 return true;
                             }
                             else if (cityName[i].Equals(c.Country_name))
                             {
                                 lblAddress.Text = "您查询的IP:" + txtIP.Text + "<br>IP地址位置:" + c.Country_name + "--" + city;
                                 return true;
                             }
                         }
                         lblAddress.Text = "您查询的IP:" + txtIP.Text + "<br>IP地址位置:" + c.Country_name + "--" + city + "!   您没有在OpenRice所涉足的五个城市内 ";
                         return false;
                     }
                     else
                     {
                         ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('您输入的IP没有相关记录')", true);  
                         return false;
                     }
                      
            }
  • 相关阅读:
    jQuery
    jQuery
    jQuery Callback 函数
    怎样提高团队管理能力4
    poj 3461 Oulipo(KMP模板题)
    每日一小练——按字典顺序列出全部排列
    Java数据结构与算法之排序
    China Vis 2015 会议小结
    网络基础知识小小说
    NS3网络仿真(7): Wifi节点
  • 原文地址:https://www.cnblogs.com/johnwang/p/3225164.html
Copyright © 2011-2022 走看看