<%
if request.cookies("buyok")("admin")="" then response.write "<meta http-equiv='refresh' content='0;URL=../admin.asp'>"
%>
<!--#include file="../include/config.asp"-->

<script language=javascript src=../include/mouse.js></script>
 <%
sub checkmanage(str)
Set mrs = conn.Execute("select * from manage where username='"&request.cookies("buyok")("admin")&"'")
if not (mrs.bof and mrs.eof) then
manage=mrs("manage")
if instr(manage,str)<=0 then
response.write "<script language='javascript'>"
response.write "alert('警告：您没有此项操作的权限！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
else
session("buyok_admin_login")=0
end if
else 
response.write "<script language='javascript'>"
response.write "alert('没有登陆，不能执行此操作！');"
response.write "location.href='quit.asp';"
response.write "</script>"
response.end
end if
set mrs=nothing
end sub
%>
<%call checkmanage("03")%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../images/css.css" type=text/css rel=stylesheet>
<LINK href="../list/newhead.css" type=text/css rel=stylesheet>
</head>
<BODY bgcolor="#D9EAFC">
<%
if request("action")="del" then
conn.execute "delete from bkey"
response.write "<script language='javascript'>"
response.write "alert('统计数据已被清除，系统将从重新开始统计。');"
response.write "</script>"
end if
%>
<table height="5"><tr><td></td></tr></table>
<TABLE cellSpacing=0 cellPadding=0 width=95% border=0 style="BORDER-RIGHT: #b1bfee 1px solid; BORDER-TOP: #b1bfee 1px solid; BORDER-LEFT: #b1bfee 1px solid; BORDER-BOTTOM: #b1bfee 1px solid" 
>
  <TBODY>
    <TR>
      <TD width="90%" bgColor=#f4f5fd><font color="#000000">　<B><font color="#FF0000">&nbsp;搜索关键词统计</font></B></font></TD>
      <TD bgColor=#f4f5fd height=30><font color="#000000"></font></TD>
    </TR>
  </TBODY>
</TABLE>
		  <table height="5"><tr><td></td></tr></table>

<table width="95%"  border="0" cellpadding="0" cellspacing="1" bgcolor="#b1bfee">
  <tr align="center" bgcolor="#f4f5fd">
    <td width="33%" height="30">关键词</td>
    <td width="33%">最近搜索时间</td>
    <td width="33%">搜索次数  &nbsp;  &nbsp;  &nbsp; 
    <span style="cursor:hand" onClick="{if(confirm('该操作不可恢复！\n\n确认要删除全部统计数据吗？ ')){location.href='keywords.asp?action=del';}}"><font color=red><u>清除统计数据</u></font></span>
    </td>
  </tr>

<%
set rs=Server.CreateObject("ADODB.recordset")
sql="select * from bkey order by num desc"
rs.open sql,conn,1,3 
if rs.eof and rs.bof then
%>
<tr align="center" valign="middle" bgcolor="#FFFFFF">
<td height="30" colspan=3>暂时没有访问者搜索商品</td>
</tr>
<%
else
pages = 20			'每页记录数
rs.pageSize = pages
allPages = rs.pageCount		'计算一共能分多少页
page = Request("page")
'if语句属于基本的排错处理
if isEmpty(page) or clng(page) < 1 then
page = 1
elseif clng(page) >= allPages then
page = allPages 
end if
rs.AbsolutePage = page


do while not rs.eof and pages>0
%>

  <tr align="center" bgcolor="#FFFFFF">
    <td height="30"><span alt="用户曾在本站以“<font color=red><%=rs("keywords")%></font>”为关键字搜索商品"><%=rs("keywords")%></span></td><td><%=rs("keydate")%></td><td><%=rs("num")%></td>
  </tr>

<%
pages = pages - 1
rs.movenext
if rs.eof then exit do
loop

end if

rs.close
set rs=nothing
conn.close
set conn=nothing
%>

</table>
<%
call listpages()
%>
</body></html>


<%
'分页
sub listPages() 
if allpages <= 1 then exit sub 
if page = 1 then
response.write "<font color=darkgray>首页 前页</font>"
else
response.write "<a href="&request.ServerVariables("script_name")&"?page=1>首页</a> <a href="&request.ServerVariables("script_name")&"?page="&page-1&">前页</a>"
end if
if page = allpages then
response.write "<font color=darkgray> 下页 末页</font>"
else
response.write " <a href="&request.ServerVariables("script_name")&"?page="&page+1&">下页</a> <a href="&request.ServerVariables("script_name")&"?page="&allpages&">末页</a>"
end if
response.write " 第"&page&"页 共"&allpages&"页"
end sub
%>
