<!--#include file = "../inc/dbconn.asp"-->
<!--#include file = "../inc/function.asp"-->
<% call dbconn %>
<%Response.Expires = 0
dim DH654CN,ipcheck,stime,ip,gocome,id
DH654CN="http://www1.itmop.com"
stime="3600"  

ip=Request.ServerVariables("Remote_Addr")

gocome = request.servervariables("HTTP_REFERER")
id=gqv("id")
if Request.Cookies(DH654CN)("now")="" then
   ipcheck=true
elseif DateDiff("s",Request.Cookies(DH654CN)("now"),now())<stime then
   ipcheck=false
else
   Response.Cookies(DH654CN)("now")=now()
   ipcheck=true
end if



if ipcheck=true then   '--------结束统计--------
'--------获取常规变量并写进数据库--------
  dim TJ_year,TJ_month,TJ_day,TJ_hour,TJ_week,TJ_weeknum
  TJ_year=year(now)'判断当前年份
  TJ_month=month(now)'判断当前月份
  TJ_day=day(now)'判断当前日期
  TJ_hour=hour(now)'判断当前小时
  TJ_week=weekday(now)'判断当前星期
  TJ_weeknum=Datepart("ww",now())'判断当前周数
  dim sql
  sql= "Update DH654_Setup Set TJ_year ='"&TJ_year&"', TJ_month ='"&TJ_month&"', TJ_week ='"&TJ_week&"', TJ_day ='"&TJ_day&"', TJ_hour ='"&TJ_hour&"', TJ_weeknum ='"&TJ_weeknum&"' Where id = 1"

  conn.execute(sql)
	'--------结束写进--------

	'--------判断日期分辨今天还是昨天并写进--------
   dim rs
   set rs=conn.execute("select Id,UrlID,TJ_year,TJ_month,TJ_week,TJ_day,TJ_hour,TJ_weeknum,fip,fcome from TJ654_COUNT")
      sql1="update TJ654_COUNT  set vtoday=vtoday+1,vtotal=vtotal+1"
'--------判断日期分辨今月还是上个月并写进--------
   if int(fmonth)<>int(rs("vmonth")) then
      sql1=sql1&",vpremonth="&rs("vnowmonth")&",vnowmonth=1,vmonth='"&fmonth&"'"
   else
      sql1=sql1&", vnowmonth=vnowmonth+1"
   end if
     '--------判断日期分辨今年还是去年并写进--------
   if int(fyear)<>int(rs("vyear")) then
      sql1=sql1&",vnowyear=1,vyear='"&fyear&"'"
   else
      sql1=sql1&", vnowyear=vnowyear+1"
   end if
   '--------判断日期分辨今周还是上周并写进--------
    if int(fweeknum)<>int(rs("vweeknum")) then
      sql1=sql1&",vweek=1,vweeknum='"&fweeknum&"'"
    else
      sql1=sql1&", vweek=vweek+1"
    end if
    '--------判断统计数据是否为0,如果为0那么重新开始写进开始统计日期--------
    if rs("vtotal")="0" then sql1=sql1&", vstarttime='"&now()&"'"
    '--------判断是否为同一ip--------
    if rs("vip")<>fip then
       sql1=sql1&", vip='"&fip&"',vtotal1=vtotal1+1"
    end if
    conn.execute(sql1)
	'--------结束判断--------
else
   Response.write("XXXXXXXXXXXXXXX")
   Response.end
end if

Response.Expires = 0  

%>
