<!--#include file="const.asp" -->
<!--#include file="conn.asp" -->
<!--#include file="common/function.asp" -->
<!--#include file="common/library.asp" -->
<!--#include file="common/cache.asp" -->
<!--#include file="common/checkUser.asp" -->
<!--#include file="class/cls_logAction.asp" -->
<!--#include file="common/ubbcode.asp" -->
<%
  getInfo(1)
  
'==================================
'  引用通告处理页面
'    更新时间: 2006-1-22
'==================================

IF IsInteger(Request.QueryString("tbID")) Then
	Dim tbID,tbTitle,tbURL,tbExcerpt,tbBlog
	tbID = CheckStr(Request.QueryString("tbID"))
	If Trim(Request.QueryString("tbmode"))="rss" Then
		Set tbBlog=Conn.Execute("SELECT tb_Title,tb_URL,tb_Intro,tb_PostTime FROM blog_Trackback WHERE blog_ID="&tbID)
		SQLQueryNums=SQLQueryNums+1
		If Not (tbBlog.BOF and tbBlog.EOF) Then
			Response.contentType="text/xml"
			Response.write "<?xml version=""1.0"" encoding=""UTF-8""?><response><error>0</error>"
%>
				<rss version="0.91">
					<channel>
						<title><![CDATA[<%=SiteName%>]]></title>
						<link><![CDATA[<%=SiteURL%>]]></link>
						<description><![CDATA[<%=SiteName%>]]></description>
						<language>utf-8</language>
					 	<% do while not tbBlog.eof %>
									<item>
										<title><![CDATA[<%=tbBlog(0)%>]]></title>
										<link><![CDATA[<%=tbBlog(1)%>]]></link>
										<description><![CDATA[<%=tbBlog(2)%>]]></description>
								     	<pubDate><%=DateToStr(tbBlog("tb_PostTime"),"w,d m y H:I:S")%></pubDate>
									</item>
						<% 
							tbBlog.MoveNext
							loop
						%>
					</channel>
				</rss>
			</response>
			<%
		 Else
			tbResponseXML 1,"无效参数，日志不存在或日志没有被引用！"
		End If
		Set tbBlog=Nothing
	Else
		'Trackback entry mode
		If Request.QueryString("url")<>Empty Then
			tbURL = ClearHTML(checkURL(CheckStr(Request.Form("url"))))
			tbTitle = ClearHTML(CheckStr(Request.Form("title")))
			tbExcerpt = ClearHTML(HTMLEncode(CheckStr(Request.Form("excerpt"))))
			tbBlog = ClearHTML(CheckStr(Request.Form("blog_name")))
		ElseIf Request.Form("url")<>Empty Then
			tbURL = ClearHTML(checkURL(CheckStr(Request.Form("url"))))
			tbTitle = ClearHTML(CheckStr(Request.Form("title")))
			tbExcerpt = ClearHTML(HTMLEncode(CheckStr(Request.Form("excerpt"))))
			tbBlog = ClearHTML(CheckStr(Request.Form("blog_name")))
		Else
			tbResponseXML 1,"无效参数，URL地址不存在！"
		End If
		tbURL=CutStr(tbURL,100)
		if tbTitle="" Then
			tbTitle=tbURL
		Else
			tbTitle=CutStr(tbTitle,100)
		End If
		tbExcerpt=CutStr(tbExcerpt,252)
		tbBlog=CutStr(tbBlog,100)

		'Check if allow trackback
		If Conn.Execute("SELECT count(log_ID) FROM blog_Content WHERE log_IsShow=True And log_DisComment=False AND log_ID="&tbID)(0)>0 AND Conn.Execute("SELECT count(tb_ID) FROM blog_Trackback WHERE blog_ID="&tbID&" AND tb_URL='"&tbURL&"' AND tb_Title='"&tbTitle&"' AND tb_Intro='"&tbExcerpt&"' AND tb_Site='"&tbBlog&"'")(0)<1 Then
			Conn.Execute("INSERT INTO blog_TrackBack (blog_ID, tb_URL, tb_Title, tb_Intro, tb_Site, tb_PostTime) VALUES ("&tbID&",'"&tbURL&"','"&tbTitle&"','"&tbExcerpt&"','"&tbBlog&"',Now())")
			Conn.Execute("UPDATE blog_Content SET log_QuoteNums=log_QuoteNums+1 WHERE log_ID="&tbID)
			Conn.Execute("UPDATE blog_Info Set blog_tbNums=blog_tbNums+1")
			Smilies(1)
			Keywords(1)
			getInfo(2)
			PostArticle tbID
			SQLQueryNums=SQLQueryNums+3
			tbResponseXML 0,"Trackback成功"
		Else
			tbResponseXML 1,"此日志是隐藏日志不允许引用，或者此引用通告已发送！"
		End If
	End If
Else

					Dim ReInfo
					 ReInfo=Array("Trackback 错误信息","非法操作<br/><a href=""javascript:history.go(-1);"">单击返回</a>","MessageIcon")
					If Request.QueryString("action")="deltb" Then
						If Not (IsInteger(Request.QueryString("tID")) AND IsInteger(Request.QueryString("logID"))) Then
				 		   ReInfo(0)="Trackback错误信息"
	                       ReInfo(1)="<b>无效参数</b><br/><a href=""javascript:history.go(-1);"">单击返回</a>"
                           ReInfo(2)="ErrorIcon"
						   showmsg "Trackback 错误信息","<b>无效参数</b><br/><a href=""javascript:history.go(-1);"">单击返回</a>","ErrorIcon",""
						Else
						    '验证用户登陆信息
						    checkCookies
  
					  	    '读取用户权限
						    UserRight(1)
							Dim dele_tb,logID
							logID=CheckStr(Request.QueryString("logID"))
							Set dele_tb=Conn.ExeCute("SELECT * FROM blog_TrackBack WHERE blog_ID="&logID&" AND tb_ID="&CheckStr(Request.QueryString("tID")))
							SQLQueryNums=SQLQueryNums+1
							IF dele_tb.EOF AND dele_tb.BOF Then
						 		     ReInfo(0)="Trackback 错误信息"
			                         ReInfo(1)="<b>引用通告不存在</b><br/><a href=""javascript:history.go(-1);"">单击返回</a>"
		                             ReInfo(2)="WarningIcon"
	                                 Conn.close
	                                 set Conn=nothing
									 showmsg "Trackback 错误信息","<b>引用通告不存在</b><br/><a href=""javascript:history.go(-1);"">单击返回</a>","WarningIcon",""
                          		Else
								If stat_Admin Then
									Conn.ExeCute("UPDATE blog_Content SET log_QuoteNums=log_QuoteNums-1 WHERE log_ID="&dele_tb("blog_ID"))
									Conn.Execute("DELETE * FROM blog_TrackBack WHERE blog_ID="&logID&" AND tb_ID="&CheckStr(Request.QueryString("tID")))
									Conn.Execute("UPDATE blog_Info Set blog_tbNums=blog_tbNums-1")
									SQLQueryNums=SQLQueryNums+2
				 		            ReInfo(0)="提示信息"
	                                ReInfo(1)="<b>引用通告删除成功！</b><br/><a href=""default.asp?id="&logID&""">单击返回</a>"
                                    ReInfo(2)="MessageIcon"
									Smilies(1)
									Keywords(1)
                                    PostArticle logID
                                    getInfo(2)
                                    Conn.close
                                    set Conn=nothing
								    showmsg "提示信息","<b>引用通告删除成功！</b><br/><a href=""default.asp?id="&logID&""">单击返回</a>","MessageIcon",""
								Else
				 		            ReInfo(0)="Trackback 错误信息"
	                                ReInfo(1)="<b>你没有权限删除引用通告~</b><br/><a href=""default.asp?id="&logID&""">单击返回</a>"
                                    ReInfo(2)="WarningIcon"
                                    Conn.close
                                    set Conn=nothing
								    showmsg "Trackback 错误信息","<b>你没有权限删除引用通告~</b><br/><a href=""default.asp?id="&logID&""">单击返回</a>","ErrorIcon",""
								End If
							End IF
							
						End If
					End If
					%>
	<!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" lang="UTF-8">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="Content-Language" content="UTF-8" />
	<meta name="robots" content="all" />
	<meta name="author" content="apple@xoofeng.com,apple" />
	<meta name="Copyright" content="apple's Blog 2 CopyRight 2006" />
	<meta name="keywords" content="PuterJam,Blog,ASP,designing,with,web,standards,xhtml,css,graphic,design,layout,usability,ccessibility,w3c,w3,w3cn" />
	<meta name="description" content="Apple's BLOG" />
	<title><%=siteName%> - <%=blog_Title%></title>
	</head>
	<body>
	<div style="text-align:center;font-size:12px">
	   <div style="text-align:center;width:300px;border:1px solid #004080;background:#bfdfff">
	    <div>
	      <div style="padding:3px;background:#97cbff;border-bottom:1px dotted #004080"><b><%=ReInfo(0)%></b></div>
	      <div style="padding:6px">
	          <%=ReInfo(1)%>
			</div>
		  </div>
		</div>
	 </div>
	</body>
	</html>
 <%
End If

'Trackback response function
Function tbResponseXML(intFlag, strMessage)
	Response.contentType="text/xml"
	Response.write "<?xml version=""1.0"" encoding=""UTF-8""?><response><error>"&intFlag&"</error>"
	If intFlag=1 Then Response.write "<message>"&strMessage&"</message>"
	Response.write "</response>"
	Conn.close
	set Conn=nothing
	Response.End
End Function

%>