<!--#include file="conn.asp"-->
<%
'-------------------------------------
'功能：管理员管理网站首页
'更新：2004-12-27 11:57
'作者：未知-部落忍者
'演示：http://www.0cc.cn/link/
'-------------------------------------

if session("cutelink_admin")<>"OK" then
    response.redirect("admin_login.asp")
end if
dim action
action=request.QueryString("action")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="style.css" rel="stylesheet" type="text/css">
<title>管理网站信息_<%=WebName&ChannelName%></title>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<table border="0" align="center" cellpadding="0" cellspacing="0" class="main_title1">
  <tr> 
    <td align="center"><a href="admin_manage.asp">管理首页</a> | <a href="?action=ListSite">列出所有网站</a> | <a href="?action=ShowLog"><font color="#0000FF">查看点击记录</font></a> |  
      修改网站信息 | <a href="?action=BatchDelform">批量删除数据</a> | <a href="admin_login.asp?action=exit">退出管理</a></td>
  </tr>
</table>
<table border="0" align="center" cellpadding="3" cellspacing="0" class="main_tdbg">
  <tr> 
    <td height="30">您的位置:<a href="<%=WebUrl%>">首页</a> 
      -- <a href="admin_manage.asp">管理首页</a> -- 管理网站信息</td>
  </tr>
</table>
<table border="0" align="center" cellpadding="0" cellspacing="0" class="main_tdbg">
  <tr> 
    <td> <%
select case action
case "del"
	call dellink
case "init"
	call init
case "BatchDelform"
	call BatchDelform
case "BatchDelWeb"
	call BatchDelWeb
case "BatchDelLog"
	call BatchDelLog
case "ShowLog"
	call ShowLog
case "ListSite"
	call ListSite
case "CompactDB"
	call Compact
case "ClearCache"
	call ClearCache
case "Summary"
	call Summary
case else
	call main
end select
sub main
%>
      <table width="700" border="0" align="center" cellpadding="3" cellspacing="0">
        <tr> 
          <td width="110"><img src="images/common.gif" width="9" height="15"> 
            <a href="?action=ListSite"><font color="#0000FF">列出所有网站</font></a></td>
          <td width="590">10种排序方式显示各个网站的信息，您可以修改、初始化、删除其站点并查看点入点出记录。</td>
        </tr>
        <tr> 
          <td width="110"><img src="images/common.gif" width="9" height="15"> 
            <a href="?action=Summary"><font color="#0000FF">查看统计记录</font></a></td>
          <td width="590">查看总网站数，总点入点出次数等系统总体概况数据。</td>
        </tr>		
        <tr> 
          <td><img src="images/common.gif" width="9" height="15"> <a href="?action=ShowLog"><font color="#0000FF">查看点击记录</font></a></td>
          <td>查看所有用户的点入点出记录，也可单独查看点入或点出的记录，也可单独查看某一用户的点入点出记录。</td>
        </tr>
        <tr> 
          <td><img src="images/common.gif" width="9" height="15"> <a href="?action=BatchDelform"><font color="#0000FF">批量删除数据</font></a></td>
          <td>可选择删除初始化后指定天数内总点击进入数小于指定数量的站点; 删除指定天数前的点击记录(用户3天内的点入点出记录不会被删除)。 
          </td>
        </tr>
        <tr> 
          <td><img src="images/common.gif" width="9" height="15"> <a href="admin_type.asp"><font color="#0000FF">管理网站分类</font></a></td>
          <td>添加、修改、删除网站分类。 
          </td>
        </tr>
        <tr> 
          <td><img src="images/common.gif" width="9" height="15"> <a href="?action=init" onClick="return confirm('初始化后，所有数据将清零，你确认要继续吗？')"><font color="#0000FF">初始化所有数据</font></a></td>
          <td>初始化后，所有网站的数据都将清零，请谨慎操作！</td>
        </tr>
        <tr> 
          <td><img src="images/common.gif" width="9" height="15"> <a href="?action=ClearCache" onClick="return confirm('此功能将删除本系统上的缓存，你确认要继续吗？')"><font color="#0000FF">删除本系统缓存</font></a></td>
          <td>执行后，link.asp和js.asp将立刻显示最新的数据。</td>
        </tr>
        <tr> 
          <td><img src="images/common.gif" width="9" height="15"> <a href="aspcheck.asp" target="_blank"><font color="#0000FF">服务器环境检测</font></a></td>
          <td>可检测服务器有关参数 | 服务器组件情况 | 服务器运算能力 | 服务器磁盘信息 | 服务器连接速度，此为零星部落ASP探针V1.2版</td>
        </tr>
        <tr> 
          <td><img src="images/common.gif" width="9" height="15"> <a href="?action=CompactDB" onClick="return confirm('你确定要压缩吗？')"><font color="#0000FF">压缩数据库</font></a></td>
          <td>建议每隔一段时间，对数据库进行压缩操作。如果您的服务器不支持FSO，请将数据库下载到本地，用Access2000压缩数据库。</td>
        </tr>
        <tr> 
          <td><img src="images/common.gif" width="9" height="15"> <a href="admin_login.asp?action=exit"><font color="#0000FF">退出管理</font></a></td>
          <td>防止他人非法更改资料哦！管理完毕，请一定要退出，尤其是在公用的电脑上。</td>
        </tr>
      </table> 
      <%
end sub
sub ListSite
dim find,webtype,pl
dim rs,sql
dim condition,linkstr
find=hx.checkstr(request("find"),20)
webtype=request("webtype")

sql="select * from CL_Link"
condition = " where 1=1 " 

pl=request("pl")
if pl="" then
pl="inp"
end if
linkstr = "pl=" & pl

if webtype="" or not isnumeric(webtype) then
webtype=0 
elseif webtype>0 then
condition = condition & " and webtype="&webtype
end if
linkstr = linkstr & "&action=ListSite&webtype="&webtype


if find<>"" then
condition = condition & " and (sitename like '%"&find&"%' or siteintro like '%"&find&"%' or siteurl like '%"&find&"%')"
linkstr = linkstr & "&action=ListSite&find="&find
end if

'分页信息
dim PageNo
PageNo=Request.QueryString("PageNo")
if PageNo="" or not isnumeric(PageNo) then
PageNo=1
else
PageNo=int(PageNo)
end if

'普通sql语句
sql=sql & condition &" ORDER BY "&pl&" DESC"

%> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <form method="post" action="?action=ListSite">
          <tr> 
            <td height="30" align="center" valign="middle"> <p>关键字： 
                <input name="find" type="text" id="find" value="<%=find%>" size="15" maxlength="20">
                网站分类： 
                <select name="webtype" size="1">
                  <option value="">全部类别</option>
                  <%hx.listwebtype(webtype)%>
                </select>
                排序： 
                <select name="pl" size="1">
                  <option value="inc"<%if pl="inc" then%> selected<%end if%>>总计点入</option>
                  <option value="inj"<%if pl="inj" then%> selected<%end if%>>今天点入</option>
                  <option value="inp"<%if pl="inp" then%> selected<%end if%>>平均点入</option>
                  <option value="outc"<%if pl="outc" then%> selected<%end if%>>总计点出</option>
                  <option value="outj"<%if pl="outj" then%> selected<%end if%>>今天点出</option>
                  <option value="outp"<%if pl="outp" then%> selected<%end if%>>平均点出</option>
                  <option value="indate"<%if pl="indate" then%> selected<%end if%>>点入时间</option>
                  <option value="outdate"<%if pl="outdate" then%> selected<%end if%>>点出时间</option>
                  <option value="fromdate"<%if pl="fromdate" then%> selected<%end if%>>统计时间</option>
                  <option value="dateandtime"<%if pl="dateandtime" then%> selected<%end if%>>加入时间</option>
                </select>
                <input name="submit" type="submit" value="查 询">
                &nbsp; 
            </td>
          </tr></form>
          <tr> 
            <td height="30" align="center"><%hx.showPageInfo "CL_link","username",condition,PageNo,MaxPageSize,linkstr%>
</td>
          </tr>
      </table>
    </td>
  </tr>
</table>
<%
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1

if not rs.eof then
	rs.PageSize = MaxPageSize
	rs.AbsolutePage = PageNo 
	dim i
	i=0   
%>
<table border="1" align="center" cellpadding="3" cellspacing="0" bordercolorlight=#000000 bordercolordark=#FFFFFF class="main_tdbg">
  <tr align="center" class="main_title1"> 
    <td width="100">网站名称</td>
    <td width="100">链接图标</td>
    <td width="100">网站类别</td>
    <td width="100">网站登记时间</td>
    <td width="100">开始统计时间</td>
    <td width="100">最后点入时间</td>
    <td width="100">最后点出时间</td>
  </tr>
  <%Do While Not rs.EOF and i<MaxPageSize%>
  <tr align="center"> 
    <td><a href="http://<%=hx.BaseUrl%>out.asp?username=<%=rs("username")%>" target="_blank"><%=rs("sitename")%></a></td>
    <td><a href="http://<%=hx.BaseUrl%>out.asp?username=<%=rs("username")%>" target="_blank"><img src=<%=hx.htmlencode2(rs("sitelogo"))%> width=88 height=31 alt="网址:<%=hx.htmlencode2(rs("siteurl"))%>" border="0"></a></td>
    <td><%=hx.showwebtype(rs("webtype"))%></td>
    <td><%=rs("dateandtime")%></td>
    <td><%=rs("fromdate")%></td>
    <td><%=rs("indate")%></td>
    <td><%=rs("outdate")%></td>
  </tr>
  <tr> 
    <td align="center">网　址</td>
    <td colspan="3"><a href="out.asp?username=<%=rs("username")%>" target="_blank"><%=hx.htmlencode2(rs("siteurl"))%></a></td>
    <td align="center">邮　箱</td>
    <td colspan="2"><a href="mailto:<%=rs("email")%>"><%=rs("email") %></a></td>
  </tr>
  <tr> 
    <td align="center">简　介</td>
    <td colspan="6"><%=hx.htmlencode2(rs("siteintro"))%></td>
  </tr>
  <tr> 
    <td align="center">贡献统计</td>
    <td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="50%">[你站]对[我站]:总计 <%=rs("inc")%> 今天 <%=rs("inj")%> 平均 <font color=#00009F><%=formatnumber(rs("inp"),2,-1)%></font></td>
          <td width="50%">[我站]对[你站]:总计 <%=rs("outc")%> 今天 <%=rs("outj")%> 平均 <font color=#00009F><%=formatnumber(rs("outp"),2,-1)%></font></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td bgcolor="#FDF0F9"><div align="center">管理选项</div></td>
    <td colspan=6 bgcolor="#FDF0F9"><a href="admin_editlink.asp?username=<%=rs("username")%>">修 
      改</a> <a href="?Action=del&username=<%=rs("username")%>" onClick="return confirm('确定要删除吗？')">删 
      除</a> <a href="?action=init&username=<%=rs("username")%>" onClick="return confirm('初始化后，此网站数据将清零，你确认要继续吗？')">初始化统计</a> 
      <a href="?action=ShowLog&username=<%=rs("username")%>&inout=0">查看点入记录</a> 
      <a href="?action=ShowLog&username=<%=rs("username")%>&inout=1">查看点出记录</a></td>
  </tr>
  <tr> 
    <td height="5" colspan=7 bgcolor="#8cc3de"></td>
  </tr>
  <%  
i=i+1  
rs.MoveNext  
Loop  
else
%>
  <tr> 
    <td height=80 colspan=7> <div align="center"><B>没有找到你所查询的网站</B></div></td>
  </tr>
  <%
end if  
rs.close
set rs=nothing

%>
</table>
<%end sub%>
<%sub BatchDelform%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td><form name="form1" method="post" action="?action=BatchDelWeb">
        删除初始化后 
        <input name="daynum" type="text" value="30" size="3" maxlength="4">
        天内总点击进入数小于 
        <input name="hitsnum" type="text" id="hitsnum" value="1" size="3" maxlength="4">
        的站点 
        <input type="submit" name="Submit" value="删除">
      </form></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td><form name="form1" method="post" action="?action=BatchDelLog">
        删除 
        <input name="daynum" type="text" value="15" size="3" maxlength="4">
        天前的点击记录(用户3天内的点入点出记录不会被删除) 
        <input type="submit" name="Submit" value="删除">
      </form></td>
  </tr>
</table>
<%
Call GoBack
end sub

sub dellink
	dim username
	username=hx.checkstr(request("username"),12)
	hx.execute("delete from CL_Link where username='"&username&"'")
	response.write "<p align=center>用户名为"& username & "的网站删除成功</p>"
	Call GoBack
end sub

sub init
	dim username
	username=hx.checkstr(request("username"),12)
	if username="" then
		hx.execute("update CL_Link set inc=0,inj=0,inp=0,outc=0,outj=0,outp=0,fromdate=date(),indate=date(),outdate=date()")
		response.write "<p align=center>初始化完毕！所有数据已清零，从今天起开始重新统计！</p>"
	else
		hx.execute("update CL_Link set inc=0,inj=0,inp=0,outc=0,outj=0,outp=0,fromdate=date(),indate=date(),outdate=date() where username='"&username&"'")
		response.write "<p align=center>"&username&"的站点初始化完毕！所有数据已清零，从今天起开始重新统计！</p>"	
	end if
	Call GoBack
end sub

sub BatchDelWeb
	dim rs,daynum,hitsnum,TotalCount
	daynum=request.form("daynum")
	hitsnum=request.form("hitsnum")
	'容错判断
	if daynum="" or not isnumeric(daynum) then daynum=30
	if hitsnum="" or not isnumeric(hitsnum) then hitsnum=1
	'开始删除	
	set rs=hx.execute("select count(*) from CL_Link where fromdate<"&SqlNowString&"-"&daynum&" and inc<"&hitsnum)
	TotalCount=rs(0)
	set rs=nothing
	if TotalCount>0 then
		hx.execute("delete from CL_Link where fromdate<"&SqlNowString&"-"&daynum&" and inc<"&hitsnum)	
		response.write "成功删除了" & TotalCount &"个站点"
	else
		response.write "暂时没有符合删除条件的站点"
	end if
	Call GoBack
end sub

sub BatchDelLog
	dim rs,daynum,TotalCount
	daynum=request.form("daynum")
	'容错判断
	if daynum="" or not isnumeric(daynum) then daynum=15
	if daynum<=3 then daynum=15	
	'开始删除	
	set rs=hx.execute("select count(*) from CL_Log where dateandtime<"&SqlNowString&"-"&daynum)
	TotalCount=rs(0)
	set rs=nothing
	if TotalCount>0 then
		hx.execute("delete from CL_Log where dateandtime<"&SqlNowString&"-"&daynum)	
		response.write "成功删除了" & TotalCount &"条记录"	
	else
		response.write "暂时没有符合删除条件的记录"
	end if
	Call GoBack
end sub

sub ShowLog
	dim rs,sql
	dim inout
	dim username
	dim strtitle
	username=hx.checkstr(request.QueryString("username"),12)
	inout=request.QueryString("inout")
	if inout="0" then
		strtitle="点入记录（你站对我站的贡献）"
	elseif inout="1" then
		strtitle="点出记录（我站对你站的贡献）"
	else
		strtitle="点入点出记录"		
	end if
	
	dim PageNo
	PageNo=Request.QueryString("PageNo")
	if PageNo="" or not isnumeric(PageNo) then
		PageNo=1
	else
		PageNo=int(PageNo)
	end if
	dim condition,linkstr
	if username="" then
		if inout="" then
			condition=""
			linkstr="action=ShowLog"
		else
			condition="where inout="&inout
			linkstr="action=ShowLog&inout="&inout
		end if		
	else
		strtitle= "<a href=admin_editlink.asp?username="&username&" title='查看"&username&"的网站资料'>"&username&"</a>的网站的" & strtitle
		if inout="" then
			condition="where username='"&username&"'"
			linkstr="action=ShowLog&username="&username
		else		
			condition="where inout="&inout &" and username='"&username&"'"
			linkstr="action=ShowLog&inout="&inout &"&username="&username
		end if	
	end if
	if inout<>"" then
		
	end if
%>
<table width="95%" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr> 
    <td><div align="center"><%=strtitle%></div></td>
  </tr>
</table>
<%
if username="" and inout="" then
set rs = hx.execute("select count(inout) from CL_Log where Datediff('d',dateandtime,date())=0 and inout=0")
response.write "<div align=center>今天总点入：" & rs(0)
set rs = nothing
set rs = hx.execute("select count(inout) from CL_Log where Datediff('d',dateandtime,date())=0 and inout=1")
response.write " 今天总点出：" & rs(0) & "</div>"
set rs = nothing
end if%>
<table width="95%" border="1" align="center" cellpadding="3" cellspacing="0" bordercolorlight="#000000" bordercolordark="#FFFFFF">
  <tr align="center"> 
  <%if username="" then response.write "<td width=100>用户名</td>"
if inout="" then response.write "<td width=30 align=center>状态</td>"
  %>
    <td width="120">时间</td>
    <td width="100">IP地址</td>
    <td>来源页面</td>
  </tr>
  <%
	set rs=server.createobject("adodb.recordset")
	sql="select * from CL_Log "&condition&" order by id desc"
	rs.open sql,conn,1,1
	if rs.eof then
		Response.write "<tr><td colspan=3 align=center>暂时还没有记录</td></tr>"
	else
		rs.PageSize = MaxPageSize
		rs.AbsolutePage = PageNo 
		dim i
		i=0   
		do while not rs.eof and i<MaxPageSize
	%>
  <tr style="word-break:break-all;Width:fixed">
<%if username="" then response.write "<td><a href=?action=ShowLog&username="&rs("username")&">"&rs("username")&"</a></td>"
if inout="" then
response.write "<td width=30 align=center>"
		response.write "<a href=?action=ShowLog&username="&username&"&inout="&rs("inout")&"><font color=#000000>"
	if rs("inout")=0 then
		response.write "点入"
	else
		response.write "点出"
	end if
		response.write "</font></a>"
response.write "</td>"
end if
 %>
    <td><%=rs("dateandtime")%></td>
    <td><%="<a href='http://www.0cc.cn/ip/ipinfo.asp?ip="&rs("ip")&"' title='查询此IP地址所在区域' target='_blank'>"&rs("ip")&"</a>"%></td>
    <td><%if trim(rs("come"))="" then
		  	response.write "无"
		  else
		  	response.write "<a href="&rs("come")&" target=_blank>"&rs("come")&"</a>"
		  end if%> </td>
  </tr>
  <%
		i=i+1
		rs.movenext
		loop
	end if
	set rs=nothing%>
</table>
<p align=center>
  <%hx.showPageInfo "CL_Log","id",condition,PageNo,MaxPageSize,linkstr%>
</p>

<%
Call GoBack
end sub%>
<%
Sub Compact
		Response.Write CompactDB(Server.Mappath(db),false)
		Response.write "<p align=center><< <a href=javascript:history.go(-1)>返回上一页</a></p>"	
End Sub
'=====================压缩参数=========================
Function CompactDB(dbPath, boolIs97)
	On Error Resume Next
	Dim fso, Engine, strDBPath,JET_3X
	strDBPath = left(dbPath,instrrev(DBPath,"\"))
	Set fso = CreateObject("Scripting.FileSystemObject")
	If Err Then
		Err.Clear
		CompactDB = "您当前操作的目录不支持FSO，请手动进行压缩数据库操作!" & vbCrLf
		Exit Function
	End If
	If fso.FileExists(dbPath) Then
		fso.CopyFile dbpath,strDBPath & "temp.mdb"
		Set Engine = CreateObject("JRO.JetEngine")

		If boolIs97 = "True" Then
			Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
			"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb;" _
			& "Jet OLEDB:Engine Type=" & JET_3X
		Else
			Engine.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp.mdb", _
			"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & "temp1.mdb"
		End If

		fso.CopyFile strDBPath & "temp1.mdb",dbpath
		fso.DeleteFile(strDBPath & "temp.mdb")
		fso.DeleteFile(strDBPath & "temp1.mdb")
		Set fso = Nothing
		Set Engine = Nothing
		CompactDB = "你的数据库, " & dbpath & ", 已经压缩成功!" & vbCrLf
	Else
		CompactDB = "数据库名称或路径不正确. 请重试!" & vbCrLf
	End If
End Function

Sub ClearCache
	response.write "<p align=center>删除本系统缓存成功</p>"
	hxcache.DelCahe("js")
	Call GoBack
End Sub

Sub Summary
	dim rs
	dim TotalSite,TotalSite1,Totalinc,Totaloutc,Totalinj,Totaloutj
	TotalSite = hx.execute("select count(0) from CL_Link")(0)
	TotalSite1 = hx.execute("select count(0) from CL_Link where inc > 0")(0)
	set rs = hx.execute("select sum(inc),sum(outc) from CL_Link")
	Totalinc = rs(0)
	Totaloutc = rs(1)
	set rs =  nothing
	set rs = hx.execute("select sum(inj),sum(outj) from CL_Link")
	Totalinj = rs(0)
	Totaloutj = rs(1)
	set rs =  nothing
	response.write "<p>总有网站："&TotalSite
	response.write "<br>有效网站："&TotalSite1 & "(有产生过点入次数的网站)"
	response.write "<br>总计点入："&Totalinc
	response.write "<br>总计点出："&Totaloutc
	response.write "<br>今天点入："&Totalinj
	response.write "<br>今天点出："&Totaloutj			
	Call GoBack
End Sub

Sub GoBack
	Response.Write "<p align=center><< <a href='javascript:history.go(-1)'>返回上一页</a></p>"	
End Sub
%>
</td>
</tr>
</table> 
<%CloseDatabase%>
<!--#include file="under.asp"-->
