<!--#include file="conn.asp"-->
<!--#include file="inc/usercode.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="user_chkpass.asp"-->
<%
if CheckUserLogined()=False then
	response.Redirect "user_login.asp"
end if

dim rs,rstmp,sql,rsblogchk,badstr
dim temp,tbid
dim tbUrl,tbTopic,tbExcerpt,tbBlogname,url
dim topic,logtext,blog_password
dim blogteam,blogteamsubject
dim i
		
	url=trim(request("url"))'引用地址
	sql="select * from blog where username='"&username&"'"
	set rs=server.createobject("adodb.recordset")
	rs.open sql,conn,2,3
	rs.addnew
	rs("topic")=debadstr(trim(request("topic")))
	for i = 1 to Request.Form("logtext").Count 
  		logtext = logtext & Request.Form("logtext")(i)
	Next
	if logtext="" then
		logtext=trim(request.form("edit"))
	end if
	logtext=debadstr(logtext)
	blogteam=trim(request("blogteam"))
	blogteamsubject=clng(request("blogteamsubject"))
	rs("logtext")=logtext
	rs("face")=trim(request("face"))
	'rs("username")=username
	rs("addtime")=request("selecty")&"-"&request("selectm")&"-"&request("selectd")&" "&request("selecth")&":"&request("selectmi")&":"&request("selects")
	rs("upfiles")=request("upfiles")
	rs("classid")=clng(trim(request("classid")))
	if blogteamsubject<>0 then
		rs("subjectid")=blogteamsubject
	else
		rs("subjectid")=clng(trim(request("subjectid")))
	end if
	if request("showword")<>"" then
		rs("showword")=clng(trim(request("showword")))
	else
		rs("showword")=0
	end if
	set rstmp=conn.execute("select blog_password from [user] where username='"&blogteam&"'")
	blog_password=rstmp(0) '判断整个blog是否加密
	set rstmp=nothing
	if blog_password<>"" then
		rs("blog_password")=blog_password
	else
		rs("blog_password")=""
	end if
	rs("author")=username
	rs("username")=blogteam
	rs("ishide")=trim(request("ishide"))
	'rs("ishide")=trim(request("ishide"))
	if trim(request("ispassword"))<>"" then
		rs("ispassword")=md5(trim(request("ispassword")))
	end if
	rs("iis")=0
	rs("trackback")=0
	set rsblogchk=conn.execute("select blogcheck from bloginfo") '判断是否需要审核
	if rsblogchk("blogcheck")="true" then
		rs("passcheck")="false"
		set rsblogchk=nothing
	else
		if findbadstr(logtext) then '检查敏感字出现次数
			rs("passcheck")="false"
		else
			rs("passcheck")="true"
		end if		
	end if
	set rsblogchk=nothing
  	rs.update
	Set rs=Conn.Execute("SELECT max(id) from blog where username='"&username&"'")
	tbid=RS(0)
	rs.close
	set rs=nothing
	'增加用户日志数
	conn.execute("update [user] set logcount=logcount+1 where username='"&blogteam&"'")
	'增加系统分类日志数
	if clng(trim(request("classid")))<>0 then
		conn.execute("update [classname] set classlognum=classlognum+1 where id="&clng(trim(request("classid"))) )
	end if
	'增加专题日志数
	if clng(trim(request("subjectid")))<>0 then
		conn.execute("update [subject] set subjectlognum=subjectlognum+1 where id="&clng(trim(request("subjectid"))) )
	end if
	'增加系统日志数
	conn.execute("update [bloginfo] set logcount=logcount+1")
	'Application(cachename&"index_update")=true
	call PutApplicationValue()
	'以下为引用参数
	set rs=conn.execute("select siteurl from bloginfo")
	tbUrl=rs(0)&"more.asp?name="&username&"&id="&tbid
	tbTopic =trim(request("topic"))
	tbExcerpt = left(unhtml(logtext),100)
	tbBlogname = username	
	set rs=nothing

function unHtml(content)
	ON ERROR RESUME NEXT
	unHtml=content
	if content <> "" then
		unHtml=Server.HTMLEncode(unHtml)
		unHtml=replace(unHtml,vbcrlf,"<br>")
		unHtml=replace(unHtml,chr(9),"&nbsp;&nbsp;&nbsp;&nbsp;")
		unHtml=replace(unHtml," ","&nbsp;")
	end if
	if Err.Number <>0 then
		unHtml= "html转换中出错请联系管理员<br>"
		Err.Clear
	end if
end function
	
	
%>
<% if url<>"" then%>
<script language="JavaScript">
document.title="保存信息";
function chgInnerHtml()
{
	document.all.showMsg.innerHTML = "<br><br><br><br><br><div align=center>引用已经提交，<a href='user_index.asp'><font color=red>请点击返回</font></a></div>"
	//document.location ="user_index.asp"
}//chgInnerHtml
function loadFunc()
{
	parent.tbFrame.tbF.url.value = "<%=tbUrl%>";
	parent.tbFrame.tbF.topic.value = "<%=tbtopic%>";
	parent.tbFrame.tbF.excerpt.value = "<%=tbExcerpt%>";
	parent.tbFrame.tbF.blogname.value = "<%=tbBlogname%>";
	parent.tbFrame.tbF.action = "<%=Request.Form("url")%>";
	parent.tbFrame.tbF.submit();
	setTimeout("chgInnerHtml()",3000);
}
</script>

<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css">
<body onLoad="loadFunc()">
<span id="showMsg">
<br><br><br><br><br><div align="center">正在提交引用...</div>
</span>
<iframe id=tbFrame name=tbFrame style="width=0;height=0;top=0;left=0" frameborder=0 src=tb.asp?act=post></iframe>
</body>
<%
else
response.Redirect "user_index.asp"
end if
%>


