<form action="main.asp" name="tongji" method=post>
<input type=hidden name="del" value="ok">
<!--#include file="menu.asp"-->
<%
	action = request.form("del")
	if action="ok" then
		Set rs=Server.CreateObject("ADODB.Recordset")
		sql="select * from count_total"
		rs.open sql,conn,1,3
		rs("total")=0		'总访问量置0
		rs("yesterday")=0	'昨天访问量置0
		rs("today")=0		'今天访问量置0
		rs.update
		conn.execute "delete from count_shop"
		rs.close
		set rs=nothing
		
		response.write "<script language='javascript'>"
		response.write "alert('统计数据已被清除，系统将从现在开始重新统计。');"
		response.write "</script>"
	end if
	
	conn.execute("delete from count_online where datediff('h',time,now())>1")
	
	Set rs=Server.CreateObject("ADODB.Recordset")
	sql="select * from count_total"
	rs.open sql,conn,1,3
	total=rs("total")		'总访问量
	yesterday=rs("yesterday")	'昨天访问量
	today=rs("today")		'今天访问量
	
	set rs = server.createobject("adodb.recordset")
	sql = "select * from count_online"
	rs.open sql,conn,1,3 
	if not (rs.eof and rs.bof) then
		online=rs.RecordCount		'在线人数
	else 
		online=1
	end if
	
	set rs = server.createobject("adodb.recordset")
	sql = "select * from count_shop order by day asc"
	rs.open sql,conn,1,3 
	if not (rs.eof and rs.bof) then
		total_ip=rs.RecordCount		'总IP访问量
		firstday=rs("day")		'firstday：开始计算的日期
	else 
		total_ip=0
		firstday=date()
	end if
	per_ip=int(total_ip/(date()-firstday+1))	'平均每天IP访问量
	if per_ip<1 then per_ip=0	
	per=int(total/(date()-firstday+1))	'平均每天访问量
	if per<1 then per=0
	
	set rs = server.createobject("adodb.recordset")
	sql = "select * from count_shop where day=#"&date()&"#"
	rs.open sql,conn,1,3 
	if not (rs.eof and rs.bof) then
		today_ip=rs.RecordCount		'今天总IP访问量
	else 
		today_ip=0
	end if
	set rs=nothing
		
	set rs = server.createobject("adodb.recordset")
	sql = "select * from count_shop where day=#"&date()-1&"#"
	rs.open sql,conn,1,3 
	if not (rs.eof and rs.bof) then
		yesterday_ip=rs.RecordCount		'昨天总IP访问量
	else 
		yesterday_ip=0
	end if
	rs.close
	set rs=nothing
	conn.close
	set conn=nothing
%>
<table width="100%" border="1" cellPadding=3 cellSpacing=0 bordercolor="#E7EFFF" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" bgcolor="#E7EFFF">
  <tr>
    <td height="30" colspan="4" align="left" bgcolor="#E7EFFF">网站访问统计基本数据</td>
  </tr>
  <tr>
    <td width="12%" align="right" bgcolor="#E7EFFF">统计起始日期：</td>
    <td width="34%" bgcolor="#FFFFFF"><%=firstday%></td>
    <td width="14%" align="right" bgcolor="#E7EFFF">统计截止日期：</td>
    <td width="40%" bgcolor="#FFFFFF"><%=date()%>（共<%=date()-firstday+1%>天）</td>
  </tr>
  <tr>
    <td align="right" bgcolor="#E7EFFF">总访问量：</td>
    <td bgcolor="#FFFFFF"><%=total%></td>
    <td align="right" bgcolor="#E7EFFF">平均每日访问量：</td>
    <td bgcolor="#FFFFFF"><%=per%></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#E7EFFF">总IP访问量：</td>
    <td bgcolor="#FFFFFF"><%=total_ip%></td>
    <td align="right" bgcolor="#E7EFFF">平均每日IP访问量：</td>
    <td bgcolor="#FFFFFF"><%=per_ip%></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#E7EFFF">昨天访问量：</td>
    <td bgcolor="#FFFFFF"><%=yesterday%></td>
    <td align="right" bgcolor="#E7EFFF">昨天IP访问量：</td>
    <td bgcolor="#FFFFFF"><%=yesterday_ip%> &nbsp; <a href=more.asp?day=<%=date()-1%>>查看明细</a></td>
  </tr>
  <tr>
    <td align="right" bgcolor="#E7EFFF">今天访问量：</td>
    <td bgcolor="#FFFFFF"><%=today%></td>
    <td align="right" bgcolor="#E7EFFF">今天IP访问量：</td>
    <td bgcolor="#FFFFFF"><%=today_ip%> &nbsp; <a href=more.asp?day=<%=date()%>>查看明细</a></td>
  </tr>
  <tr>
    <td height="29" align="right" bgcolor="#E7EFFF">当前在线人数：</td>
    <td bgcolor="#FFFFFF"><%=online%> 人</td>
    <td align="right" bgcolor="#E7EFFF">统计数据置零：</td>
    <td bgcolor="#FFFFFF">
<input type="submit" name="action" value="清零" onClick="{if(confirm('清除全部统计数据，重新开始统计。此操作无法恢复，您确定要继续吗？')){this.document.tongji.submit();return true;}return false;}"></td>
</tr>
</table>
</form>
</body>
</html>
