<!--#include file="user_top.asp"-->
<!--#include file="inc/class_blog.asp"-->

<%
Dim action
action = Trim(request("action"))
%>
</head>
<body scroll="no" style="overflow:auto!important;overflow:hidden;background:#fff;">
<%
Dim  sGuide
Dim rs, sql,mainid
Dim id, cmd
cmd = Trim(request("cmd"))
id = request("id")
If cmd = "" Then
    cmd = 0
Else
    cmd = Int(cmd)
End If
G_P_FileName = "user_tb.asp?cmd=" & cmd

If  action = "del" Then
    Call deltb
Else
    Call main
End If
%>

</body>
</html>
<%

Sub main()
    Dim  ssql,i,lPage,lAll,lPages,iPage
	ssql="a.id,a.tbuser,a.addtime,a.topic,a.ip,a.logid"
    Select Case cmd
        Case 0
            sql="select "&ssql&" from oblog_trackback a,oblog_log b where b.userid="&oblog.l_uid&" and a.logid=b.logid order by a.ID desc"
            sGuide = sGuide & "所有引用通告"
    End Select
    Set rs = server.CreateObject("Adodb.RecordSet")
    rs.Open sql, conn, 1, 3
    lAll=INT(rs.recordcount)
    If lAll=0 Then    	
    	rs.Close
    	Set rs=Nothing
    	%>
    	<div id="user_page_content">
		   <div id="content_li">
		   	<ul class="content_li_conten">
		   		<li class="t1"></li>
		   		<li class="t3">&nbsp;</li>
		   	</ul>
		   	<ul class="content_li_conten">
		   		<li class="t1"></li>
		   		<li class="t3"><%=sGuide & " 没有相关纪录" %></li></ul>
		  	</div>
		  </div>
    	<%
    	Exit Sub
    End If
    i=0
    iPage=12
	'分页
	If Request("page") = "" Or Request("page") ="0" then
		lPage = 1
	Else
		lPage = Int(Request("page"))
	End If
	
	'设置缓存大小 = 每页需显示的记录数目
	rs.CacheSize = iPage
	rs.PageSize = iPage
	rs.movefirst		
	lPages = rs.PageCount
	If lPage>lPages Then lPage=lPages
	rs.AbsolutePage = lPage
	i=0
	%>
  <form name="form1" method="post">
	<ul id="user_page_top">
		<li id="p7"><a href="#" onclick="chk_idAll(myform,1)">全部选择</a></li>
		<li id="p8"><a href="#" onclick="chk_idAll(myform,0)">全部取消</a></li>
		<li id="p4"><a href="#" onclick="if (chk_idBatch(myform,'删除选中的引用吗?')==true) {document.myform.action.value='del'; document.myform.submit();}">删除引用</a></li>
	</ul>
	<div id="showpage">
	  <%=MakeMiniPageBar(lAll,iPage,lPage,G_P_FileName)%>
	</div>
<style type="text/css">
<!--
	.content_li_top .tt1{ width:50px;text-align:center}
	.content_li_top .tt2 {width:40%;}
	.content_li_top .tt3 {width:160px;}
	.content_li_top .tt4 {width:120px;}
	.content_li_top .tt5 {width:100px;}
	#content_li .content_li_conten .tt1 {width:50px;text-align:center}
	#content_li .content_li_conten .tt2 {width:40%;}
	#content_li .content_li_conten .tt3 {width:160px;color:#888;}
	#content_li .content_li_conten .tt4 {width:120px;}
	#content_li .content_li_conten .tt5 a {color:#069;}
	#content_li .content_li_conten .tt5 a:hover {color:#06c;}
	#content_li .content_li_conten .tt5 {width:100px;}
-->
</style>
	<div id="user_page_content">
		<ul class="content_li_top">
			<li class="tt1">选中</li>
			<li class="tt2">标题</li>
			<li class="tt3">引用时间</li>
			<li class="tt4">IP</li>
			<li class="tt5">操作</li>
			
		</ul>
   		<div id="content_li">
			<form name="myform" method="Post" action="user_tb.asp?action=del" onSubmit="return confirm('确定要执行选定的操作吗？');">
          <%
          Do while not rs.EOF
          	i = i + 1%>
		   <ul class="content_li_conten" id="u<%=rs("ID")%>" onclick="chk_iddiv('<%=rs("id")%>')">
			<li class="tt1" title="点击选中"><input name='id' type='checkbox' id="c<%=rs("ID")%>" value='<%=rs("ID")%>' onclick="chk_iddiv('<%=rs("ID")%>')" /></li>
			<li class="tt2" ><a href=showtb.asp?id=<%=rs("logid")%> target="_blank"><%=oblog.filt_html(rs("topic"))%></a></li>
			<li class="tt3"><%=rs("addtime")%></li>
			<li class="tt4"><%=rs("ip")%></li>
			<li class="tt5"><a href="user_tb.asp?action=del&id=<%=rs("ID")%>" onclick="return confirm ('确认删除此引用通告？');">删除</a></li>
			
    	</ul>
<%
    	If i>iPage Then Exit Do
	    rs.movenext
	Loop
    rs.Close
    Set rs = Nothing
    %>
     </form>
    </div>
	</div>
    <%
End Sub

Sub deltb()
    Dim blog, rstComment
    If id = "" Then
        oblog.adderrstr ("错误：请指定要删除的引用！")
        oblog.showusererr
        Exit Sub
    End If
    If InStr(id, ",") > 0 Then
        id = FilterIDs(id)
        Dim n, i
        n = Split(id, ",")
        For i = 0 To UBound(n)
            delonetb (n(i))
        Next
    Else
        delonetb (id)
    End If
    oblog.showok "删除引用成功!", ""
End Sub

Sub delonetb(id)
    Dim  logid
    id = Int(id)
    Dim uid, mainid
    sql = "select a.logid from oblog_trackback a,oblog_log b where a.ID=" & Int(id) & " and b.userid=" & oblog.l_uId&" and a.logid=b.logid"
    Set rs = server.CreateObject("adodb.recordset")
    rs.Open sql, conn, 1, 3
    If Not rs.EOF Then
        logid = rs(0)
        rs.Delete
        rs.Close
        '重新计算引用数目
        oblog.Execute ("update [oblog_log] set trackbacknum=trackbacknum-1 where logid=" & logid)
    Else
        rs.Close
        Set rs = Nothing
        oblog.adderrstr ("错误：无删除权限！")
        oblog.showusererr
        Exit Sub
    End If
End Sub

Function FilterUbb(byval strHTML)
	Dim objRegExp, strOutput
	Set objRegExp = New Regexp	  
	strOutput=strHTML	
	objRegExp.IgnoreCase = True
	objRegExp.Global = True
	objRegExp.Pattern="(\[EMOT\])(.[^\[]*)(\[\/EMOT\])"
	strOutput = objRegExp.Replace(strOutput, "")	
	objRegExp.Pattern =  "\[[^\]]*\]"
	strOutput = objRegExp.Replace(strOutput, " ")	
	FilterUbb = strOutput   
	Set objRegExp = Nothing
End Function
%>