<!-- #INCLUDE FILE = "conn.asp" -->
<!-- #INCLUDE FILE = "date.asp" -->
<!-- #INCLUDE FILE = "function.asp" -->
<!-- #INCLUDE FILE = "session.asp" -->
<%
dim Rs,sql,bydate,pagenum,totalnum,pagesizes,currentpage,nextpage,prepage,i,rowsdata,iti,BeginTime
BeginTime=Timer
pagesizes=20
if(request.QueryString("bydate")<>"") then
	bydate=trim(request.QueryString("bydate"))
else
	bydate=iYear&"-"&iMonth&"-"&iDay
end if
if(request.QueryString("page")<>"") then
	currentpage=Cint(request.QueryString("page"))
else
	currentpage=1
end if
If databaseType = 1 Then
	sql="select count(*) from t_ip WHERE f_date=#"&bydate&"#"
Else
	sql="SELECT count(*) from t_ip WHERE datediff(d,f_date,'"&bydate&"')=0"
	sql="SELECT count(*) from t_ip WHERE f_date='"&bydate&"'"
end if
totalnum=conn.execute(sql)(0)
pagenum=Cint((totalnum+pagesizes-1)/pagesizes)
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
<link href="style/css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
	color: #FFFFFF;
	font-weight: bold;
}
.style2 {
	color: #cc3300;
	font-weight: bold;
}
.style3 {
	color: #006699;
	font-weight: bold;
}
.style4 {
	color: #000000;
	font-weight: bold;
}
-->
</style>
<script language="javascript">
function goto(frm)
{
	var gourl ="?bydate=<%=bydate%>&";
	gourl += "page=" + (frm.page.value);
     var hid=parseInt(frm.hid.value);
	 if(parseInt(frm.page.value)>hid||frm.page.value<=0){
	 alert("错误！请确定你输入的数字在1-"+hid+"之间");
	 return false;
	 }
	window.location.href(gourl);
}</script>
<LINK media=screen href="js/dhtmlgoodies_calendar.css" rel=stylesheet></LINK>
<SCRIPT src="js/dhtmlgoodies_calendar.js" type=text/javascript></SCRIPT>
</head>
<body>
<p><br />
  &nbsp;&nbsp;<span class="style3">来路统计<%=bydate%>：</span> <span class="style2"><%=totalnum%></span></p>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <tr>
    <td height="20" bgcolor="#006699"><div align="center" class="style1">来路访问统计</div></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
      <tr>
        <td width="28%" height="20" valign="bottom" bgcolor="#F5F5F5">      <div align="center">来源IP</div>
        <td width="29%" valign="bottom" bgcolor="#F5F5F5">      <div align="center">时间</div>
        <td width="27%" valign="bottom" bgcolor="#F5F5F5"><div align="center">所在地</div></td>
        <td width="16%" valign="bottom" bgcolor="#F5F5F5"><div align="center">点击</div></td>
      </tr>
      
	  <%	
		Set Rs=Server.CreateObject("ADODB.Recordset")
		If databaseType = 1 Then
			sql="select f_ip,f_date,f_hits,f_address from t_ip WHERE f_date=#"&bydate&"# order by f_hits desc,id desc"
		Else
			if(currentpage=1) then
				sql = "SELECT top "&pagesizes&" f_ip,f_date,f_hits,f_address from t_ip WHERE datediff(d,f_date,'"&bydate&"')=0 order by f_hits desc"
			else
				sql = "SELECT top "&pagesizes&" f_ip,f_date,f_hits,f_address from t_ip WHERE id not in (select top "&(pagesizes*(currentpage-1))&" id from t_ip where datediff(d,f_date,'"&bydate&"')=0 order by f_hits desc) and  datediff(d,f_date,'"&bydate&"')=0 order by f_hits desc"
			end if
		end if
		dim startIndex
		if(databaseType=1) then
			startIndex=pagesizes*(currentpage-1)
		else
			startIndex=0
		end if
		Rs.open sql,conn,3,1
		if not rs.eof then
			rowsdata=rs.GetRows()
			rs.close
			set rs=nothing			
			for iti=startIndex to startIndex+pagesizes-1				
				if(iti>ubound(rowsdata,2)) then
					exit for
				end if
	  %>
	  <tr>
        <td height="20" valign="bottom" bgcolor="#FFFFFF"><div align="left"><%=iti+1%>:<%=rowsdata(0,iti)%></div>
        <td valign="bottom" bgcolor="#FFFFFF"><div align="center"><%=rowsdata(1,iti)%></div>
        <td valign="bottom" bgcolor="#FFFFFF"><div align="center"><%=rowsdata(3,iti)%></div></td>
        <td valign="bottom" bgcolor="#FFFFFF"><div align="center"><%=rowsdata(2,iti)%></div></td>
	   </tr>
	   <%
	   		next
	 	else
			response.Write("no data")
			rs.close
			set rs=nothing
		end if
	  %>
    </table></td>
  </tr>
</table>
<br />
<%
dim preY,nextY,preM,nextM,preD,nextD
preY=iYear-1
nextY=iYear+1
preM=getPreMonth(iMonth)
nextM=getNextMonth(iMonth)
preD=getPreDay(iDay)
nextD=getNextDay(iDay)
%>
<table width="98%" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
	<div align="center">
	<a href="?y=<%=preY%>&m=<%=iMonth%>&d=<%=iDay%>">&lt;&lt;</a> <%=iYear%>年
	<a href="?y=<%=nextY%>&m=<%=iMonth%>&d=<%=iDay%>">&gt;&gt;</a>
	<a href="?m=<%=preM%>&y=<%=iYear%>&d=<%=iDay%>">&lt;&lt;</a><%=iMonth%>月
	<a href="?m=<%=nextM%>&y=<%=iYear%>&d=<%=iDay%>">&gt;&gt;</a>
	<a href="?d=<%=preD%>&m=<%=iMonth%>&y=<%=iYear%>">&lt;&lt;</a><%=iDay%>日
	<a href="?d=<%=nextD%>&m=<%=iMonth%>&y=<%=iYear%>">&gt;&gt;</a> 
	<form id="form1" name="form1" method="get" action="">
	  按天查看：
	  <input name="bydate" type="text" id="bydate" size="15" />
        <input name="button" type="button" onclick="displayCalendar(document.forms[0].bydate,'yyyy-mm-dd',this)" value="选择" />
        <input type="submit" value="查 看" />
	</form>
	</div>
	<div align="center">
	<%
	nextpage=currentpage+1
	prepage=currentpage-1
	if prepage>0then
		response.write("["&"<a href='?page="&cstr(prepage)&"&y="&iYear&"&m="&iMonth&"&d="&iDay&"'>上一页</a>]&nbsp;&nbsp;&nbsp;")
	else
		response.write("上一页&nbsp;&nbsp;&nbsp;")
	end if 
	if (nextpage-1)*pagesizes>=totalnum then 
		response.write("下一页" )
	else
		response.Write("["&"<a href='?page="&cstr(nextpage)&"&y="&iYear&"&m="&iMonth&"&d="&iDay&"'>下一页</a>]")
	end if
	response.write("&nbsp;共"&totalnum&"条&nbsp;")
	response.Write("&nbsp;共"&pagenum&"页&nbsp;")
	response.Write("&nbsp;第"&currentpage&"页&nbsp;")
	response.Write("&nbsp;执行时间"&CStr(FormatNumber((Timer-BeginTime),2))& "秒")
	%>
</div></td>
  </tr>
</table>
</body>
</html>
<%
call connclose()
%>