ajaxserver.asp

来自「是个不错的文件代码,希望大家好好用,」· ASP 代码 · 共 637 行 · 第 1/2 页

ASP
637
字号
<!--#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>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='#' >"&rsSubject("subjectname")&"</a></li><ol id='ol_"&n&"'>"
		while not rs.eof
			if rs("subjectid")=rsSubject("subjectid") then
				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="&rs("title")&"&mainuserid="&rs("mainuserid")&"' onclick=""go_cmdurl('我的订阅',this)"" target='content3' title='查看'>"&rs("title")&"</a></li>"
			end if
			rs.movenext
		wend
		if not rs.eof then	
			rs.movefirst
		else
			str=str&"</ol>"
		end if
		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='#' >未分类</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="&rs("title")&"&mainuserid="&rs("mainuserid")&"' onclick=""go_cmdurl('我的订阅',this)"" target='content3' 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
	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")
	pmNumbers="("&rs(0)&")"
	set rs=nothing
	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
    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_uid
			rstLog("addtime")=Now
			rstLog("addip")=oblog.userip
			rstLog("desc")=oblog.l_uname & "(" & oblog.l_uid & ")" & " 于 " & Now() & " 自 " & oblog.userip & " 发布一篇文章包含以下禁止发表的关键字(文章被禁止发布):<br/><font color=red>日志标题:" & EncodeJP(log_topic) & "<br/>可疑关键字:" & Right (oblog.errstr,Len(oblog.errstr)-1) & "</font>"
			rstLog("itype")=2 '用户日志来源
			rstLog.Update
			rstLog.Close
			oblog.errstr = ""
			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
		Set rs  = oblog.execute ("SELECT * FROM oblog_blogteam WHERE otheruserid = " & oblog.l_uid)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?