Common/IpSearch.cs
(开头部分) 13KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//该源码下载自www.51aspx.com(51aspx.com)
//引入的命名空间
using System.IO;
/// <summary>
/// 判断IP归属地类
/// </summary>
public class IpSearch
{
private static object lockHelper = new object();
static PHCZIP pcz = new PHCZIP();
static string filePath = "";
static bool fileIsExsit = true;
static IpSearch()
{
filePath = HttpContext.Current.Server.MapPath("~/ipdata.config");
pcz.SetDbFilePath(filePath);
}
public static string GetIp()
{
string result = String.Empty;
result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(result) || result == "")
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (string.IsNullOrEmpty(result) || result == "")
{
result = HttpContext.Current.Request.UserHostAddress;
}
if (string.IsNullOrEmpty(result))
{
return "127.0.0.1";
}
return result;
}
/// <summary>
/// 返回IP查找结果
/// </summary>
/// <param name="IPValue">要查找的IP地址</param>
/// <returns></returns>
public static string GetAddressWithIP(string IPValue)
{
lock (lockHelper)
{
string result = pcz.GetAddressWithIP(IPValue.Trim());
后面还有 342 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。