<!--#include file="inc/inc_syssite.asp"-->
<!--#include file="inc/class_blog.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/class_trackback.asp"-->
<%
Response.expires = 0
Response.expiresabsolute = now() - 1
Response.addHeader "pragma","no-cache"
Response.addHeader "cache-control","private"
Response.cachecontrol = "no-cache"
'Oblog4.0 AJAX Server

Dim Action,tName
action=LCase(Request("action"))
tName="日志"
Select Case action
	Case "get_draft"
		Call get_draft()
	Case "savelog"
		Call savelog()
	Case "getfeedlist"
		Call getfeedlist()
	Case "getpm"
		Call getpm()
	Case "vote"
		Call SaveVote
End Select

Sub SaveVote()
	Dim sValue,logid,rs,Scores,targetUserid
	sValue=Request("v")
	logid=Int(Request("logid"))
	If sValue<>"1" Then sValue=0
	'-------------------------------
	'1.进行登录检测
	'-------------------------------
	If Not oblog.checkuserlogined() Then
		Response.Write "必须登录后才能进行此操作"
		Response.End
	Else
		If oblog.l_ulevel=6 then
			Response.Write "您的帐号还没有通过审核，不能进行此操作"
			Response.End
		End If
	End If
	'-------------------------------
	'2.检测用户积分是否足够
	'-------------------------------
	'If oblog.CheckScore(oblog.CacheScores(20)) Then
	'	Response.Write "该操作需要 " & oblog.CacheScores(20) & " 积分，您的积分不足"
	'	Response.End
	'End If
	'-------------------------------
	'3.检测目标文章
	'-------------------------------
	'积分平衡维护
	'在反对状态下，不是一味的减少，而是只减少到将该日志所有积分扣除完为止
	Set rs=Server.CreateObject("Adodb.Recordset")
	rs.Open "Select scores,userid From oblog_log Where logid=" & logid ,conn,1,3
	If rs.Eof Then
		rs.Close
		Set rs=Nothing
		Response.Write "目标文章不存在"
		Response.End	
	End If
	targetUserid=rs(1)
	Scores=OB_IIF(rs(0),0)
	If targetUserid=oblog.l_uid Then
		rs.Close
		Set rs=Nothing
		Response.Write "您自己不能给对自己的文章进行此操作"
		Response.End	
	End If
	rs.Close
	'-------------------------------
	'4.检测是否已表态过,如果没有则进行记录
	'-------------------------------
	rs.Open "Select * From oblog_logvotes Where logid=" & logid & " And userid=" & oblog.l_uid,conn,1,3
	If Not rs.Eof Then
		Response.Write "你之前已经表态为 "
		If rs("vote")=1 Then
			Response.Write C_Vote_Action1
		Else
			Response.Write C_Vote_Action2
		End If
		rs.Close
		Set rs=Nothing
		Response.End
	End If
	rs.AddNew
	rs("logid")=logid
	rs("userid")=oblog.l_uid
	rs("vote")=sValue
	rs("addtime")=Now
	rs("addip")=oblog.userIp
	rs.Update
	rs.Close
	'-------------------------------
	'5.进行积分操作
	'目标用户积分+/-
	'-------------------------------
	'如果当前积分>待扣除积分，则更改值/仅用于减少时
	If oblog.CacheScores(20)<>"" Then
		If Scores>Int(oblog.CacheScores(20)) Then
			Scores=oblog.CacheScores(20)
		End If
		If sValue="1" Then
			oblog.execute("Update oblog_log Set vote1=vote1+1,scores=scores+" & oblog.CacheScores(20)&" Where logid=" & logid)
			oblog.execute("Update oblog_user Set scores=scores+" & oblog.CacheScores(20)&" Where userid=" & targetUserid)
		Else
			oblog.execute("Update oblog_log Set vote0=vote0+1,scores=scores-" & Scores &"  Where logid=" & logid)
			oblog.execute("Update oblog_user Set scores=scores-" & oblog.CacheScores(20)&" Where userid=" & targetUserid)
		End If
		'-------------------------------
		'6.扣除来源用户积分
		'-------------------------------
		oblog.execute("Update oblog_user Set scores=scores-" & oblog.CacheScores(20)&" Where userid=" & oblog.l_uid)
	End If
	Response.Write "操作完成"
	Dim blog
	set blog=new class_blog
	blog.userid=targetUserid
	Server.ScriptTimeOut=99999	
	blog.update_log logid,3
	'Call blog.CreateFunctionPage
	set blog=nothing
End Sub


'读取feed列表
sub getfeedlist()
	if not oblog.checkuserlogined() then
		exit sub
	end if
	dim rsSubject,rs,str,t,m,ostr,isupdate,ajax,n
	Set rsSubject = oblog.Execute("select subjectid,subjectname from oblog_subject where userid=" & oblog.l_uId & " And subjecttype=3 order by ordernum")
	set rs=oblog.execute("select * from oblog_myurl where subjectid>0 and userid="&oblog.l_uid&" order by subjectid desc")
	n=0
	while not rsSubject.eof
		'if m=1 then ostr="</ol>" else ostr=""
		str=str&ostr&"<li id='su_"&n&"' class='open' onClick=""if(ol_"&n&".style.display == 'none'){ol_"&n&".style.display = '';}else{ol_"&n&".style.display = 'none';};su_click(document.getElementById('su_"&n&"'));""><a href='#' title="""&rsSubject("subjectname")&""" >"&rsSubject("subjectname")&"</a></li><ol id='ol_"&n&"'>"
		rs.Filter = "subjectid = " &rsSubject("subjectid")
		while not rs.eof
			if rs("isupdate")=1 then isupdate="class='isupdate'" else isupdate="class=noupdate"
			str=str&"<li id='now701' "&isupdate&" onclick=""this.className='noupdate'""><a  href='user_url.asp?action=read&feedurl="&rs("url")&"&encodeing="&rs("encodeing")&"&title="&Server.UrlEncode(rs("title"))&"&mainuserid="&rs("mainuserid")&"' onclick=""go_cmdurl('我的订阅',this)"" target='content3' title="""&rs("title")&""">"&rs("title")&"</a></li>"
			rs.movenext
		Wend
		str=str&"</ol>"
		rsSubject.movenext
		n=n+1
	wend 
	set rs=oblog.execute("select * from oblog_myurl where subjectid=0 and userid="&oblog.l_uid)
	if  not rs.eof then
		str=str&ostr&"<li id='su_999' class='open' onClick=""if(ol_no.style.display == 'none'){ol_no.style.display = '';}else{ol_no.style.display = 'none';}su_click(document.getElementById('su_999'));""><a href='#' title=""未分类"">未分类</a></li><ol id='ol_no'>"
		while not rs.eof
			if rs("isupdate")=1 then isupdate="class='isupdate'" else isupdate="class=noupdate"
			str=str&"<li id='now701' "&isupdate&"><a href='user_url.asp?action=read&feedurl="&rs("url")&"&encodeing="&rs("encodeing")&"&title="&Server.UrlEncode(rs("title"))&"&mainuserid="&rs("mainuserid")&"' onclick=""go_cmdurl('我的订阅',this)"" target='content3' title="""&rs("title")&""">"&rs("title")&"</a></li>"
			rs.movenext
		wend
	end if
	set rs=nothing
	set rsSubject=nothing
	'response.Write(str)
	'if str="" then str="<span style='margin:20px;'>暂无订阅(<a href='user_url.asp' target='content3'>管理</a>)</span>"
	str="<ol class=""option""><li class=""t1""><a id='active701' href='user_url.asp?action=add' onclick=""go_cmdurl('增加订阅',this)"" target='content3' title='增加订阅'>增加</a></li><li class=""t1""><a id='active702' href='user_url.asp' onclick=""go_cmdurl('订阅管理',this);"" target='content3' title='订阅管理'>管理</a></li><li class=""t1""><a id='active703' href='user_subject.asp?t=3' onclick=""go_cmdurl('订阅分类',this)"" target='content3' title='订阅分类'>分类</a></li></ol>"&str
	set ajax=new AjaxXml
	ajax.re(split(str&"$$$","$$$"))
end sub

'读取短消息状态
sub getpm()
	Dim rs,pmNumbers,ajax,username
	If not oblog.checkuserlogined() then
		pmNumbers=0
	Else
		username=request("username")
		'Set rs=oblog.execute("select count(id) from oblog_pm where incept='"&oblog.filt_badstr(username)&"' and isreaded=0 and delR=0")
		Set rs=oblog.execute("select count(id) from oblog_pm where incept='"&oblog.l_uname&"' and isreaded=0 and delR=0")
		pmNumbers="("&rs(0)&")"
		set rs=nothing
	End If
	set ajax=new AjaxXml
	ajax.re(split(pmNumbers&"$$$","$$$"))
end sub



Sub savelog()
	if not oblog.checkuserlogined() then
		exit sub
	end if
    Dim blog, logtext, i, rs, logid, isdraft, p, tid, log_tags, filename, log_pics, log_Abstract
    Dim log_topic, log_text, log_face, log_time, log_classid, log_showword, log_blogteam, log_subjectid, log_password, log_ishide, log_istop, log_isencomment, log_isdraft, log_modiid, log_tb, log_filename, todraft, log_str, log_oldtb,log_teamsubject
    Dim isblog, teamid,log_specialid,log_isTrouble
	dim restr,ajax
	set ajax=new AjaxXml
	isdraft = Int(request("isdraft"))
    If oblog.l_Group(31,0) = 1 and isdraft<>1 Then
		If Not oblog.codepass Then 
			oblog.adderrstr ("验证码错误，请刷新后重新输入！")
			restr=split(oblog.errstr&"$$$0","$$$")
			ajax.re(restr)
			response.End
		End if
    End If
    log_isTrouble=0
    logid=request("logid")
    If logid<>"" Then logid=Int(logid)
    log_oldtb = ""
    If logid=""  Then
    	Dim sPostAccess
    	sPostAccess=oblog.CheckPostAccess
    	If sPostAccess<>"" Then    	
    		oblog.AddErrstr sPostAccess
      	oblog.ShowUserErr
      End If
    End If
    
    log_topic = Replace_Plus(unescape(trim(request("topic"))))
    log_face = request("face")
    If log_text = "" Then log_text = Replace_Plus(unescape(Trim(request("edit"))))
    log_time = request("selecty") & "-" & request("selectm") & "-" & request("selectd") & " " & request("selecth") & ":" & request("selectmi") & ":00"
    log_classid = Trim(request("classid"))
    log_showword = Trim(request("showword"))
    log_specialid= Trim(request("specialid"))
	log_blogteam=clng(trim(request("blogteam")))
	log_teamsubject=trim(request("blogteamsubject"))
    log_subjectid = Trim(request("subjectid"))
    log_password = Trim(request("ispassword"))
    log_ishide = Trim(request("ishide"))
    log_isencomment = Trim(request("isencomment"))
    log_istop = Trim(request("istop"))
    log_tb = Trim(request("tb"))
    log_filename = Trim(request("filename"))
    log_isdraft = isdraft
    log_pics = Trim(request("log_pics"))
	log_Abstract=trim(Request("abstract"))
    If logid <>"" Then
        log_modiid = logid
    End If
	log_topic = Trim (log_topic)
	log_text = Trim (log_text)
    If (log_topic = "" Or oblog.strLength(log_topic) > 50) and isdraft<>1 Then oblog.adderrstr ("日志标题不能为空(不能大于50)！")
	if isdraft=1 and log_topic = "" then log_topic="无题"
    If Trim(log_filename) = "自动编号" Then log_filename = ""
    If (oblog.chkdomain(log_filename) = False And log_filename <> "") and isdraft<>1 Then oblog.adderrstr ("文件名称不合规范，只能使用小写字母及数字！")
    If log_text = "" Or oblog.strLength(log_text) > Int(oblog.Cacheconfig(34)) Then oblog.adderrstr (tName & "内容不能为空且不能大于" & oblog.Cacheconfig(34) & "字符！")
    Dim iChk1,iChk2,iChk3
	if isdraft<>1 then
		iChk1=oblog.chk_badword(log_topic)
		iChk2=oblog.chk_badword(log_abstract)
		iChk3=oblog.chk_badword(log_text)
		If iChk1=0.1 Or iChk2=0.1 Or iChk3=0.1 Then
			'记录
			oblog.execute("Update oblog_user Set isTrouble=isTrouble+1 Where userid=" & oblog.l_uid)
			'写系统日志
			Dim rstLog
			Set rstLog=Server.CreateObject("Adodb.Recordset")
			rstLog.Open "Select * From oblog_syslog Where 1=0",conn,1,3
			rstLog.AddNew
			rstLog("username")=oblog.l_uname
			rstLog("addtime")=Now
			rstLog("addip")=oblog.userip
			rstLog("desc")="用户名："&oblog.l_uname & "(ID：" & oblog.l_uid & ")" & " 于 " & Now() & " 自 " & oblog.userip & " 发布一篇文章包含以下禁止发表的关键字（文章被禁止发布）:<br/><font color=red>日志标题：" & EncodeJP(log_topic) & "<br/>可疑关键字：" & oblog.ShowBadWord & "</font>"
			rstLog("itype")=2 '用户日志来源
			rstLog.Update
			rstLog.Close
			oblog.adderrstr ("内容中存在绝对禁止的关键字,请注意您的言论!")
			
			'判断是否需要封禁
			If oblog.CacheConfig(13)<>"0" And  Trim(oblog.CacheConfig(13))<>"" Then
				Dim isRedirect
				rstLog.Open "Select istrouble,lockuser From oblog_user Where userid=" & oblog.l_uid,conn,1,3	
				If rstLog(0)>CInt(oblog.CacheConfig(13)) Then
					rstLog("lockuser")=1
					rstLog.Update
					rstLog.Close
					isRedirect = 1
					oblog.errstr= ""
					oblog.adderrstr ("您发布的敏感字过多，已经被封禁！")
				End If
			End If
			Set rstLog=Nothing
			If oblog.errstr <> "" Then 
				If isRedirect = 1 Then 
					restr=split(replace(oblog.errstr,"_","<br />")&"$$$3$$$index.asp","$$$")
				Else 
					restr=split(replace(oblog.errstr,"_","<br />")&"$$$0","$$$")
				End If 
				ajax.re(restr)
				response.End
			End If
		Elseif iChk1 >=1 Or iChk2>=1 Or iChk3>=1 Then
			log_isTrouble=1
		End If
	end if
    If Not IsDate(log_time) Then oblog.adderrstr (tName & "时间格式错误！")
	if log_teamsubject="" then log_teamsubject=0
    If log_showword = "" Then log_showword = 0
    If Not IsNumeric(log_showword) Then oblog.adderrstr (tName & "部分显示字数必须为数字！")
    If log_subjectid = "" Then log_subjectid = 0
    If log_classid = "" Then log_classid = 0
    If log_istop = "" Then log_istop = 0
    If log_isencomment = "" Then log_isencomment = 0
    If log_ishide = "" Then log_ishide = 0
    If log_isdraft = "" Then log_isdraft = 0
    If Int(request("oldisdraft")) = 0 And log_isdraft = 1 And log_modiid > 0 Then todraft = 1
    If Int(request("oldisdraft")) = 1 And log_isdraft = 0 And log_modiid > 0 Then todraft = -1
    log_tags = Replace_Plus(unescape(Trim(request.Form("logtags"))))
    If log_tags <> "" and isdraft<>1 Then
    	log_tags = Replace(log_tags, "'", "")
        If Len(log_tags) > 255 Then
                oblog.adderrstr ("TAG总长度不能大于255个字符")
            End If
            If UBound(Split(log_tags, P_TAGS_SPLIT)) > (P_TAGS_MAX - 1) Then
                oblog.adderrstr ("每篇文章最多支持" & P_TAGS_MAX & "个TAG")
            End If
    End If
	If log_blogteam<>oblog.l_uId Then
		If CheckBlogTeam(log_blogteam) = False Then 
			log_blogteam = oblog.l_uId
		End If
	End if

	set rs=Nothing
 	
	If oblog.errstr <> "" Then 
		restr=split(replace(oblog.errstr,"_","<br />")&"$$$0","$$$")
		ajax.re(restr)
		response.end
	end if
'    log_Abstract=oblog.filt_html_b(log_Abstract)
'    If log_Abstract = "" Then
'        log_Abstract = trimlog(log_text, Int(Trim(log_showword)))
'        If request("isubb") = "1" Then
'            log_Abstract = UBBCode(log_Abstract, 1)
'            log_Abstract = Replace(log_Abstract, Chr(10), "<br /> ")
'        End If
'        log_Abstract = Replace(log_Abstract, "#isubb#", "")
'        log_Abstract = filtimg(log_Abstract)
'        If oblog.cacheConfig(45) = 1 Then log_Abstract = profilthtm(log_Abstract)
'    End If
    '更新摘要
    Set blog = New class_blog
    Set rs = Server.CreateObject("adodb.recordset")
    If log_modiid > 0 Then
        rs.open "select * from oblog_log where logid=" & log_modiid, conn, 2, 2
    Else
        rs.open "select top 1 * from oblog_log Where 1=0 ", conn, 2, 2
        rs.addnew
        '分布时增加积分
        'If log_isdraft = 0 Or todraft = -1 Then
	        Call oblog.GiveScore("",oblog.cacheScores(3),"")        
	        '日志积分增加
	        rs("scores")=oblog.cacheScores(3)
	    'End if
    End If
    '开始写入操作
    rs("topic") = EncodeJP(oblog.filt_astr(log_topic, 50))
    log_text = Replace(log_text, "#isubb#", "")
    If request("isubb") = "1" Then
        log_text = "#isubb#" & log_text
        rs("EditorType") = 1
    Else
        rs("EditorType") = 0
    End If
    log_text = EncodeJP(oblog.filtpath(oblog.filt_badword(log_text)))
    '进行脚本控制
    If oblog.l_Group(12,0)=0 Then log_text=FilterJS(log_text)
    '进一步处理编辑器造成的<DIV>&nbsp;</DIV>问题,不使用-1参数
	log_text=Replace(log_text,"<DIV>&nbsp;</DIV>","<br/>") 
	log_text=Replace(log_text,"<div>&nbsp;</div>","<br/>")
    rs("logtext") = log_text
    rs("face") = log_face
    rs("addtime") = log_time
    rs("classid") = log_classid
'	log_blogteam = oblog.l_uId
	if log_teamsubject>0 then log_subjectid=clng(log_teamsubject)
    If rs("subjectid") <> Int(log_subjectid) And log_modiid > 0 Then
        oblog.Execute ("update oblog_subject set subjectlognum=subjectlognum+1 where subjectid=" & Int(log_subjectid))
        oblog.Execute ("update oblog_subject set subjectlognum=subjectlognum-1 where subjectid=" & Int(rs("subjectid")))
    End If
    rs("subjectid") = Int(log_subjectid)
    rs("showword") = Int(Trim(log_showword))
    If log_modiid = 0 Then
        rs("authorid") = oblog.l_uId
        rs("author") = EncodeJP(oblog.l_uName)
    End If
    rs("userid") = log_blogteam
    'rs("state")=isblog '是否在blog显示
    rs("ishide") = log_ishide
    rs("istop") = log_istop
    If log_modiid > 0 Then log_oldtb = rs("tburl")
    rs("tburl") = log_tb
    rs("logpics") = log_pics
    rs("logtype") = 0
    rs("isencomment") = log_isencomment
    rs("Abstract") = log_Abstract
    If rs("ispassword") = log_password Then
    Else
        If log_password <> "" Then
        	If log_password<>"已设密码，若不修改请不要操作" Then rs("ispassword") = md5(Trim(log_password))
        Else
            log_password = ""
            rs("ispassword") = ""
        End If
    End If
    If oblog.l_Group(11,0) = 1 Then
        rs("passcheck") = 0
        log_Abstract = "此日志需要管理员审核后才可见。"
    Else
		If logid = "" Then 
			rs("passcheck") = 1
		End if
    End If
    rs("isdraft") = log_isdraft
    rs("filename") = log_filename
    If log_specialid="" Then log_specialid=0
    rs("specialid") = log_specialid
    If log_modiid = 0 Then
        rs("iis") = 0
        rs("commentnum") = 0
        rs("trackbacknum") = 0
        rs("blog_password") = 0
        rs("truetime") = Now()
    End If
    rs("addip")=oblog.userip
    rs("istrouble")=log_isTrouble
    rs.Update
    rs.Close

    '---------------------------------------------------------------
    If (log_modiid = 0 And log_isdraft = 0) Or todraft = -1 Then
        oblog.Execute ("update [oblog_user] set log_count=log_count+1 where userid=" & log_blogteam)
        If log_classid > 0 Then
            oblog.Execute ("update [oblog_logclass] set classlognum=classlognum+1 where id=" & log_classid)
        End If
        If log_subjectid > 0 Then
            oblog.Execute ("update [oblog_subject] set subjectlognum=subjectlognum+1 where subjectid=" & log_subjectid)
        End If
        oblog.Execute ("update [oblog_setup] set log_count=log_count+1")
		oblog.Execute ("update [oblog_myurl] set isupdate=1 where mainuserid="&oblog.l_uid)
    End If
    If log_modiid = 0 Then
        Set rs = oblog.Execute("select max(logid) from oblog_log where userid=" & log_blogteam)
        tid = rs(0)
		rs.Close
    Else
        tid = log_modiid
    End If
    'Tag处理
    Call Tags_UserAdd(log_tags, oblog.l_uId, tid)
    If isdraft = 0 Then
    	'非审核状态下允许专题和群组处理
    	If oblog.l_Group(11,0) = 0 or 1=1 Then
	    	'---------------------------------------------------------------
		    '专题处理
			if log_specialid >0 Then
				log_specialid=Int(log_specialid)	
				rs.Open "Select * From oblog_SpecialList Where logid=" & tid & " And specialid=" & log_specialid,conn,1,3
				If rs.Eof Then
					rs.Addnew
					oblog.Execute("Update oblog_Special Set s_count=s_count+1 Where specialid=" & log_specialid)
				End If
				rs("specialid")=log_specialid
				rs("userid")=oblog.l_uid
				rs("logid")=tid
				rs("author")=oblog.l_uname
				rs("topic")=log_topic
				rs("abstract")=log_abstract
				rs("addtime")=ServerDate(Now)
				rs("ispass")=0
				rs("istop")=0
				rs.Update
				rs.Close
				
			End If
			
			'群组处理
			teamid=FilterIds(Request.Form("teamid"))
			If teamId<>"" Then
				teamId=Split(teamid,",")
				For i=0 To Ubound(teamId)
					rs.Open "Select * From oblog_teampost Where logid=" & tid & " And teamid=" & teamid(i),conn,1,3
					If rs.Eof Then
						rs.Addnew
						oblog.Execute "Update oblog_team Set icount1=icount1+1 Where teamId=" & teamid(i)
						rs("istop")=0
						rs("isbest")=0
						rs("ispass")=1
						rs("addtime")=log_time
						rs("addip")=oblog.userip
						rs("views")=0
						rs("replys")=0
						rs("scores")=1
						Call oblog.GiveScore("",oblog.cacheScores(13),"")
					End If
					rs("userid")=oblog.l_uid
					rs("author")=oblog.l_uname
					rs("teamid")=teamid(i)
					rs("logid")=tid
					rs("topic")=log_topic
					rs("content")=log_text				
					rs("lastupdate")=ServerDate(Now)
					rs.Update
					rs.close
				Next
			End If
		End If
			'---------------------------------------------------------------
	    '生成日志静态页面
		blog.userid = log_blogteam
'		blog.isMulti=0
		blog.CreateFunctionPage
		blog.Update_log tid, 0
		'如果非共同撰写需要生成上一篇日志的连接
		If log_blogteam = oblog.l_uid Then
			If log_modiid = 0 Then
				set rs=oblog.execute("select top 1 logid from oblog_log where logid<"&tid&" and userid="&log_blogteam&" and logtype=0 order by logid desc")
				If Not rs.EOF Then blog.Update_log rs(0), 0
			End If
		End if
		blog.Update_calendar (tid)
		blog.Update_newblog (log_blogteam)
		blog.Update_Subject (log_blogteam)
		blog.Update_index 0
		blog.Update_info log_blogteam
		'如果是共同撰写，则更新用户首页
		If log_blogteam <> oblog.l_uid Then
			blog.userid =  oblog.l_uid 
			blog.CreateFunctionPage
			blog.Update_calendar (tid)
			blog.Update_newblog  oblog.l_uid
			blog.Update_Subject  oblog.l_uid
			blog.Update_index 0
			blog.Update_info  oblog.l_uid
		End If
	    '向目标链接发送Ping指令
	    If log_tb <> "" And log_tb <> log_oldtb Then
	        Dim objTrackBack
	        Set objTrackBack = New Class_TrackBack
	        objTrackBack.logid = tid
	        objTrackBack.Blog_Name = blog.BlogName
	        objTrackBack.title = log_topic
	        objTrackBack.url = oblog.cacheConfig(3) & "go.asp?logid=" & tid
	        objTrackBack.Excerpt = log_topic & "<br />oBlog Created"
	        Call objTrackBack.ProcessMultiPing(log_tb)
	        Set objTrackBack = Nothing
	        'response.Write("<script src="""&log_tb&"&url="&trim(oblog.cacheConfig(3))&blog.gourl&"&topic="&oblog.filt_astr(unHtml(log_topic),250)&"&tbuser="&oblog.l_uname&"""><script>")
	    End If
		'发布日志后重新载入Session
		Session ("CheckUserLogined") = ""
		restr="提交完成!$$$1"
    Else
        If todraft = 1 Then
            logtodraft (tid)
        End If
		restr="已在"&Hour(now())&":"&Minute(now())&"保存到草稿箱。$$$2$$$"&tid
       ' response.Write("<li><a href=""user_post.asp?logid="&tid&""">已经保存到草稿箱，点击继续修改日志</a></li>")
    End If
    '发布或修改日志后重新生成功能页面
    Set rs = Nothing
    Set blog = Nothing
	'response.Write(restr)
	ajax.re(split(restr,"$$$"))
	response.End()
End Sub

Sub logtodraft(logid)
    logid = Int(logid)
    Dim uid, delname, subjectfile, sdate, edate, fso, sid, rs, readme
    Set rs = Server.CreateObject("adodb.recordset")
    rs.open "select userid,logfile,issave,subjectfile,subjectid,isdraft from oblog_log where logid=" & logid, conn, 1, 3
    If Not rs.EOF Then
        uid = rs(0)
        delname = Trim(rs(1))
        subjectfile = rs(3)
        sid = rs(4)
        If delname <> "" Then
			If true_domain = 1 Then
				If InStr(delname, "archives") Then
					delname = Right(delname, Len(delname) - InStrRev(delname, "archives") + 1)
				Else
					delname = Right(delname, Len(delname) - InStrRev(delname, "/"))
				End If	
				delname=oblog.l_udir&"/"&oblog.l_ufolder&"/"&delname
			End If
            Set fso = Server.CreateObject(oblog.CacheCompont(1))
            If fso.FileExists(Server.MapPath(delname)) Then fso.deleteFile Server.MapPath(delname)
        End If
        rs("logfile") = ""
        rs("isdraft") = 1
        rs.Update
        rs.Close
        'oblog.Execute ("update oblog_user set log_count=log_count-1 where userid=" & uid)
        'oblog.Execute ("update oblog_subject set subjectlognum=subjectlognum-1 where subjectid=" & Int(sid))
        Dim blog
        Set blog = New class_blog
        blog.userid = uid
        'blog.update_index_subject 0,0,0,""
        blog.Update_index 0
        blog.Update_newblog (uid)
        Set blog = Nothing
        Set fso = Nothing
        Set rs = Nothing
    Else
        rs.Close
        Set rs = Nothing
        Exit Sub
    End If
End Sub

sub get_draft()
	dim rs,userid,draft_num,del_num,ajax
	userid=clng(request("userid"))
	set rs=oblog.execute("select count(logid) from oblog_log where isdraft=1 and isdel=0 and userid="&userid)
	draft_num=rs(0)
	if draft_num>0 then draft_num="("&draft_num&")" else draft_num=""
	set rs=oblog.execute("select count(logid) from oblog_log where isdel=1 and userid="&userid)
	del_num=rs(0)
	if del_num>0 then del_num="("&del_num&")" else del_num=""
	set rs=nothing
	set ajax=new AjaxXml
	ajax.re(split(draft_num&"$$$"&del_num,"$$$"))
end Sub
'替换发布日志中的"+"
Function Replace_Plus(str)
	Dim strTemp
	If str = "" Or IsNull(str) Then 
		Replace_Plus= ""
		Exit Function 
	End if
	strTemp=Replace (str,Chr(25),"+")
	Replace_Plus=strTemp
End Function
'检测团队博客发布日志的合法性
Private Function CheckBlogTeam(tid)
	CheckBlogTeam = False
	Dim trs
	Set trs = oblog.Execute ("SELECT id From oblog_blogteam WHERE otheruserid = " & oblog.l_uId & " AND mainuserid = " &tid)
	If Not trs.EOF Then CheckBlogTeam = True
	trs.close
	Set trs = Nothing
End Function
%>