<!--#include file="conn.asp"-->
<%dim find,webtype,webtypename,pl,ob
dim rs,sql,trs
dim condition,linkstr
find=hx.checkstr(trim(request("find")),50)
webtype=request("webtype")



condition = " where isverify="&strTrue

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

ob = request("ob")
if ob<>"asc" then ob="desc"

if webtype="" or not isnumeric(webtype) then
	webtype=0 
else
	'查询是否有此分类，取出类别名称
	set trs = hx.execute("select name from tt_WebType where id="&webtype)
	if trs.eof then
		webtype=0
	else
		webtypename="类别："&trs(0)&" - "
	end if
	set trs = nothing
end if

if webtype>0 then
	condition = condition & " and webtype="&webtype
	linkstr = linkstr & "&webtype="&webtype
end if

if find<>"" then
	condition = condition & " and (ttname like '%"&find&"%' or ttinfo like '%"&find&"%' or tturl like '%"&find&"%')"
	linkstr = linkstr & "&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

dim rowcount
rowcount = PageNo*MaxPageSize

'普通sql语句
sql="select top "&rowcount&" * from tt_Link" & condition &" ORDER BY top desc,"&pl&" "&ob
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=webtypename%>链接网站列表_<%=WebName & ChannelName%> - Powered By ttdv</title>
<link rel="stylesheet" href="style.css">
</head>
<BODY background="images/back.gif"> 
<!--#include file="top.asp"-->

<div class="bt<%=skin%>" >
您的位置:<a href="<%=WebUrl%>">首页</a> -> <a href="index.asp"><%=ChannelName%></a> -> <a href="morelink.asp" >链接网站列表</a>
</div>
<%if find="" then%>
<div class="mainbar_b<%=skin%>">
<table align="center" cellpadding="2" cellspacing="0" border="0" width="100%">
  <tr> 
    <td width="25%" valign="top">
    <div class="f_tit<%=skin%>">今日点入排行</div>
    <div class="f_main<%=skin%>"><%call showtop(1,1)%></div>
		</td>
    <td width="25%" valign="top">
    <div class="f_tit<%=skin%>">总计点入排行</div>
    <div class="f_main<%=skin%>"><%call showtop(1,2)%></div>    
		</td>
    <td width="25%" valign="top">
    <div class="f_tit<%=skin%>">今日点出排行</div>
    <div class="f_main<%=skin%>"><%call showtop(2,1)%></div>    
		</td>
    <td width="25%" valign="top">
    <div class="f_tit<%=skin%>">总计点出排行</div>
    <div class="f_main<%=skin%>"><%call showtop(2,2)%></div>        
    </td>
  </tr>
</table>
</div>
<%end if%>

<div class="mainbar_b<%=skin%>" >
<div style="text-align:center;" >
<table width="100%">
<tr class="bt<%=skin%>" >
<div style="text-align:center;" >
		<form method="Get" action="">
		关键字： 
                <input name="find" type="text" value="<%=find%>" size="15" maxlength="20">
                网站分类： 
                <select name="webtype" size="1">
                  <option value="">全部类别</option>
                  <%call hx.listwebtype(webtype,0)%>
                </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>
                <select name="ob" size="1">
                	<option value="asc"<%if ob="asc" then response.write " selected"%>>顺序</option>
                	<option value="desc"<%if ob="desc" then response.write " selected"%>>倒序</option>
                </select>                
                <input name="submit" type="submit" value="查 询">
            </form>
<div class="typelist"><ul><li><a href="morelink.asp"<%if webtype=0 then response.write " class=""sel"""%>>全部类别</a></li><%call hx.listwebtype(webtype,1)%></ul></div>

</tr>
</table>
</div>

<table border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#000000" width="100%">
 <%
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,1,1
  if not rs.eof then
	rs.move (PageNo-1)*MaxPageSize
	dim i
	i=0   
	%>
  <tr align="center" class="main_title<%=skin%>"> 
    <td width="100">网站名称</td>
    <td width="92">链接图标</td>
    <td width="92">网站类别</td>
    <td width="120">网站登记时间</td>
    <td width="120">开始统计时间</td>
    <td width="120">最后点入时间</td>
    <td width="120">最后点出时间</td>
  </tr>
<%Do While Not rs.EOF and i<MaxPageSize%>
  <tr align="center" class="tr<%=skin%>"> 
    <td><a href="http://<%=hx.BaseUrl%>ttout.asp?username=<%=rs("username")%>" target="_blank"><%=rs("ttname")%></a></td>
    <td><a href="http://<%=hx.BaseUrl%>ttout.asp?username=<%=rs("username")%>" target="_blank"><img src="<%=hx.htmlencode2(rs("ttlogo"))%>" width="88" height="31" alt="网址:<%=hx.htmlencode2(rs("tturl"))%>" 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 class="tr<%=skin%>"> 
    <td align="center">贡献统计</td>
    <td colspan="3" align="center">点入贡献:总计点入 <%=rs("inc")%> 今天点入 <%=rs("inj")%> 平均点入 <font color="#00009F"><%=formatnumber(rs("inp"),2,-1)%></font></td>
   <td colspan="3" align="center">点出贡献:总计点出 <%=rs("outc")%> 今天点出 <%=rs("outj")%> 平均点出 <font color="#00009F"><%=formatnumber(rs("outp"),2,-1)%></font>
    </td>
  </tr>
  <tr> 
    <td align="center" class="tr<%=skin%>">简　介</td>
    <td colspan="6" class="tr<%=skin%>"><%=hx.htmlencode2(rs("ttinfo"))%></td>
  </tr>  
  <tr class="jg<%=skin%>"> 
    <td height="5" colspan=7></td>
  </tr>
  <%  
i=i+1  
rs.MoveNext  
Loop  
else
%>
  <tr class="tr<%=skin%>"> 
    <td height="80" colspan="7"> <div align="center"><B>没有找到你所查询的网站</B></div></td>
  </tr>
  <%
end if  
rs.close
set rs=nothing
%>
</table><div class="cutpage"> 
<%response.flush
hx.showPageInfo "tt_Link","username",condition,PageNo,MaxPageSize,linkstr%></div>
</div>
<!--#include file="under.asp"-->
<%set hx=nothing%>
<%
	
	Function ShowTop(x,y)
		Dim OutStr,constr
		Dim rs,sql,i
		constr = " where isverify="&strTrue&" and "
		if webtype>0 then 
		constr = constr & "webtype="&webtype&" and "
		end if
		if y=2 then
			if x=1 then 
				constr=constr&" inc>0 order by inc desc"
			else
				constr=constr&" outc>0 order by outc desc"			
			end if
		sql="select top 5 ttname,inc,outc,id,tturl from tt_Link "&constr
		else
			if x=1 then 
				constr=constr&" inj>0 order by inj desc"
			else
				constr=constr&" outj>0 order by outj desc"			
			end if		
		sql="select top 5 ttname,inj,outj,id,tturl from tt_Link "&constr
		end if
		OutStr = "<ul>"
		set rs=hx.Execute(sql)
		if rs.eof then
			OutStr= OutStr & "<li>暂时还没有数据</li>"		
		else
		do while not rs.eof and i<5
			OutStr= OutStr & "<li>"
			OutStr= OutStr & "<sup>"		
			if x=1 then
			OutStr= OutStr & " 点入:"&rs(1)
			else
			OutStr= OutStr & " 点出:"&rs(2)
			end if				
			OutStr= OutStr & "</sup>"
			OutStr= OutStr & " <a href="""&rs(4)&""" onclick='return ourl("&rs(3)&");'"
			OutStr= OutStr & ">"&rs(0)&"</a>"
			OutStr= OutStr & "</li>"			
			i=i+1
			rs.movenext
		loop
		end if
		OutStr= OutStr & "</ul>"
		Response.Write OutStr
	End Function
%>
<script type="text/javascript">
function ourl(id){
	linkform.id.value=id;
	linkform.comeurl.value=document.location;
	linkform.submit();
	setTimeout("window.location.reload()",1000);
	return false;
}   
</script>
<form id="linkform" action="ttout.asp" method="post" target="_blank">
	<input name="comeurl" type="hidden">
	<input name="id" type="hidden">
</form>
</body>
</html>
