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;
/// <summary>
/// visit 的摘要说明
/// </summary>
public class visit :Page
{
public visit()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
#region 取获客户端IP地址
public string GetClientIPAddress(string http_via,string http_x_forwarded_for,string remote_addr) //获取客户端IP地址
{
if (http_via != null)
{
return http_x_forwarded_for.ToString();
}
else
{
return remote_addr.ToString();
}
}
#endregion
#region 获取客户端浏览器
public string GetClientBrowser(HttpBrowserCapabilities bc) //获取客户端浏览器类型跟版本
{
string browserAndVer = "其它";
if (bc.Browser.ToLower().ToString() == "ie")
{
browserAndVer= "Internet Explorer " + bc.Version;
}
else if (bc.Browser.ToLower().ToString() == "firefox" || bc.Browser.ToLower().ToString() == "mozilla")
{
browserAndVer = "Mozilla Firefox " + bc.Version;
}
else if (bc.Browser.ToLower().ToString() == "opera")
{
browserAndVer = "Opera " + bc.Version;
}
return browserAndVer;
}
#endregion
#region 获取客户端操作系统
public string GetClientSystem(string sysAgen) //获取客户端操作系统的版本
{
string strSysVersion = "其他";
string strAgentInfo=sysAgen;
if (strAgentInfo.Contains("NT 5.2"))
{
strSysVersion = "Windows Server 2003";
}
else if (strAgentInfo.Contains("NT 5.1"))
{
strSysVersion = "Windows XP";
}
else if (strAgentInfo.Contains("NT 5"))
{
strSysVersion = "Windows 2000";
}
else if (strAgentInfo.Contains("NT 4.9"))
{
strSysVersion = "Windows ME";
}
else if (strAgentInfo.Contains("NT 4"))
{
strSysVersion = "Windows NT4";
}
else if (strAgentInfo.Contains("NT 98"))
{
strSysVersion = "Windows 98";
}
else if (strAgentInfo.Contains("NT 95"))
{
strSysVersion = "Windows 95";
}
else if (strSysVersion.ToLower().Contains("Mac"))
{
strSysVersion = "Mac";
}
else if (strSysVersion.ToLower().Contains("unix"))
{
strSysVersion = "UNIX";
}
else if (strSysVersion.ToLower().Contains("linux"))
{
strSysVersion = "Linux";
}
else if (strSysVersion.Contains("SunOS"))
{
strSysVersion = "SunOS";
}
return strSysVersion;
}
#endregion
#region 获取访问者来源
public string GetVisitSource(string visitSource)
{
string URLSource = "直接输入网址";
if (visitSource != null)
{
return visitSource;
}
else
{
return URLSource;
}
}
#endregion
}