public static void SaveIP()
{
string ip = string.Empty;
string ip2 = string.Empty;
string ip3 = string.Empty;
string ip4 = string.Empty;
string ip5 = string.Empty;
string ip6 = string.Empty;
string ip7 = string.Empty;
try
{
if (!string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"]))
ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
if (string.IsNullOrEmpty(ip))
ip = Convert.ToString(System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]);
}
catch (Exception)
{
throw;
}
try
{
ip2 = GetIpHelper.GetRealIP();
ip3 = GetIpHelper.GetBrowser();
ip4 = GetIpHelper.GetIP();
ip5 = GetIpHelper.GetIPAddress;
ip6 = GetIpHelper.GetNetIP();
ip7 = GetIpHelper.GetOSVersion();
}
catch (Exception)
{
}
try
{
ip = ip == null ? string.Empty : ip;
ip2 = ip2 == null ? string.Empty : ip2;
SqlHelper.ExecuteNonQuery(@"insert into grk.fangwen(ip,ip2,ip3,ip4,ip5,ip6,ip7,time)
values(@ip,@ip2,@ip3,@ip4,@ip5,@ip6,@ip7,@time)",
new MySqlParameter[]{
new MySqlParameter("@ip",ip),
new MySqlParameter("@ip2",ip2),
new MySqlParameter("@ip3",ip3),
new MySqlParameter("@ip4",ip4),
new MySqlParameter("@ip5",ip5),
new MySqlParameter("@ip6",ip6),
new MySqlParameter("@ip7",ip7),
new MySqlParameter("@time",DateTime.Now)
});
}
catch (Exception)
{
}
}