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;
using BLL;
/// <summary>
/// pageCount 的摘要说明
/// </summary>
public abstract class pageCount
{
public static void pageCountDo(Page page)
{
BpageCount bpage = new BpageCount();
string cookieid = "0";
if (page.Request.Cookies["countid"] != null)
{
cookieid = page.Request.Cookies["countid"].Value.ToString();
}
if (page.Request.Cookies["hSerialNo"] == null)
{
string _dt = DateTime.Now.ToString("yyyyMMdd");
Random rnd = new Random(31104000);
string str_rnd = _dt + "9" + DateTime.Now.ToString("hhm") + rnd.Next(10000, 99999).ToString();
str_rnd = str_rnd.Substring(0, 16);
page.Response.Cookies["hSerialNo"].Value = str_rnd;
page.Response.Cookies["hSerialNo"].Expires.AddMinutes(30.00);
}
string cururl = page.Request.Url.ToString();
string relurl = "";
if (page.Request.UrlReferrer != null)
{
relurl = page.Request.UrlReferrer.ToString();
page.Response.Cookies["frmurl"].Value = relurl.ToString();
page.Response.Cookies["frmurl"].Expires.AddMinutes(20.00);
}
string ip = page.Request.UserHostAddress;
string browser = page.Request.Browser.Type;
//string os = page.Request.Browser.Platform;
string os = "";
string agent = page.Request.UserAgent;
if (agent.Contains("NT 5.2"))
{
os = "Windows 2003";
}
else if (agent.Contains("NT 5.1"))
{
os = "Windows XP";
}
else if (agent.Contains("NT 5"))
{
os = "Windows 2000";
}
else if (agent.Contains("NT 4.9"))
{
os = "Windows ME";
}
else if (agent.Contains("NT 4"))
{
os = "Windows NT4";
}
else if (agent.Contains("NT 98"))
{
os = "Windows 98";
}
else if (agent.Contains("NT 95"))
{
os = "Windows 95";
}
else if (os.ToLower().Contains("Mac"))
{
os = "Mac";
}
else if (os.ToLower().Contains("unix"))
{
os = "UNIX";
}
else if (os.ToLower().Contains("linux"))
{
os = "Linux";
}
else if (os.Contains("SunOS"))
{
os = "SunOS";
}
string language = page.Request.UserLanguages[0];
string ipaddress;
IPinfo objScan = new IPinfo();
objScan.DataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/QQWry.Dat");
objScan.IP = Convert.ToString(ip);
string addre = objScan.IPtoAdrress(Convert.ToString(ip));
string err = objScan.ErrMsg;
ipaddress = addre + err;
page.Response.Cookies["countid"].Value = bpage.pageInfoAdd(cookieid, cururl, relurl, ip, browser, os, language,ipaddress);
page.Response.Cookies["countid"].Expires.AddHours(8.0);
}
}