index.asp

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

ASP
555
字号

		GetGeneralCategories()
		
		For i = 1 to objRS.PageSize

			Set objArticle = New BlogArticle

			If objArticle.LoadInfoByID(objRS("logid")) Then
				s=strPost
				s=Replace(s,"$1",TransferHTML(objArticle.Topic,"[<][>][&][""]"))
				s=Replace(s,"$2",TransferHTML(objArticle.Log_Text,"[<][>][&][""]"))
				s=Replace(s,"$3",TransferHTML(ParseDateForRFC3339(objArticle.AddTime),"[<][>][&][""]"))
				For Each Cate in GeneralCategories
					If IsObject(Cate) Then
						If objArticle.SubjectId = Cate.Id Then
								strCate = Cate.Name
							Exit For
						End If
					End If
				Next
				s=Replace(s,"$4",TransferHTML(strCate,"[<][>][&][""]"))
				s=Replace(s,"$5",TransferHTML(objArticle.Id,"[<][>][&][""]"))
				s=Replace(s,"$6",TransferHTML(objArticle.AuthorId,"[<][>][&][""]"))
				s=Replace(s,"$7",TransferHTML(objArticle.trackbacknum,"[<][>][&][""]"))

				strRecentPosts=strRecentPosts & s
			End If

			objRS.MoveNext
			If objRS.eof Then Exit For

			Set objArticle=Nothing

		Next

	End If

	strXML=Replace(strXML,"$1",strRecentPosts)

	Response.Write strXML

End Function


Function EditPost(intPostID, structPost, bolPublish)

	On Error Resume Next

	Dim objXmlFile
	Set objXmlFile = Server.CreateObject("Microsoft.XMLDOM")

	objXmlFile.loadXML(structPost)

	Dim strXML

	strXML="<?xml version=""1.0"" encoding=""gb2312""?><methodResponse><params><param><value><boolean>$1</boolean></value></param></params></methodResponse>"

	Dim objArticle
	Set objArticle=New BlogArticle

	If Not(objArticle.VerifyId(intPostID)) Then
		Call ResponseError(ERROR_NOT_EXIST_ARTICLE)
	End If

	objArticle.Topic = objXmlFile.documentElement.selectSingleNode("member[name=""title""]/value/string").text

	If (bolPublish = True) Then
		objArticle.IsDraft = 0'发布
	Else
		objArticle.IsDraft = 1'草稿
	End If

	GetGeneralCategories()
	Dim strCate
	strCate = objXmlFile.documentElement.selectSingleNode("member[name=""categories""]/value/array/data/value[0]/string").text
	If strCate<>"" Then
		Dim Cate
		For Each Cate in GeneralCategories
			If IsObject(Cate) Then
				If strCate = Cate.Name Then
					objArticle.Subjectid = Cate.Id
					Exit For
				End If
			End If
		Next
	End If
	
	objArticle.Log_Text = objXmlFile.documentElement.selectSingleNode("member[name=""description""]/value/string").text

	objArticle.AuthorId = objUser.Id
	If objArticle.Modify() = True Then
		Call ReBuildBlog(objArticle.Id)

		Response.Clear

		strXML=Replace(strXML,"$1",1)
		Response.Write strXML
	Else
		Call ResponseError(ERROR_ACCESS_DATABASE_FAILED)
	End If

End Function


Function DeletePost(intPostID)

	Dim strXML

	strXML="<?xml version=""1.0"" encoding=""gb2312""?><methodResponse><params><param><value><boolean>$1</boolean></value></param></params></methodResponse>"

	Dim objArticle
	Set objArticle=New BlogArticle

	If Not (objArticle.VerifyId(intPostID)) Then
		Call RespondError(9,ZVA_ErrorMsg(9))
	End If

	If objArticle.Delete() Then
		Call ReBuildBlog(objArticle.Id)
		
		Response.Clear

		strXML=Replace(strXML,"$1",1)
		Response.Write strXML
	Else
		Call RespondseError(11)
	End If

End Function


Function NewMediaObject(strFileName,strFileType,strFileBits)
	'判断是否开启上传文件
	If Not UPLOADFILE_SIGN Then
		Call ResponseError(ERROR_SHUTDOWN_UPLOADFILE)
	End If
	
	Dim strXML
	strXML="<?xml version=""1.0"" encoding=""gb2312""?><methodResponse><params><param><value><struct><member><name>url</name><value><string>$1</string></value></member></struct></value></param></params></methodResponse>"

	Dim objUpLoadFile
	Set objUpLoadFile = New BlogUpLoadFile
	objUpLoadFile.AuthorID = objUser.Id
	objUpLoadFile.FileName = strFileName
	objUpLoadFile.UploadType="Stream"

	Dim xmlnode
	Set xmlnode = objXmlFile.createElement("file")
	xmlnode.datatype = "bin.base64"
	xmlnode.text = strFileBits

	Dim objStreamUp
	Set objStreamUp = Server.CreateObject("ADODB.Stream")

	With objStreamUp
		.Type = 1
		.Mode = 3
		.Open
		.Position = 0
		.Write xmlnode.nodeTypedvalue
		.Position = 0
		objUpLoadFile.Stream=.Read
		.Close
	End With

	If objUpLoadFile.UpLoad() Then
	
		strXML=Replace(strXML,"$1",TransferHTML(objUpLoadFile.BackUrl,"[<][>][&][""]"))
		Response.Write strXML

	End If

End Function
'/////////////////////////////////////////////////////////////////////////////////////////

Response.ContentType = "text/xml"
Session.CodePage = 936'!GB2312

Dim strXmlCall
Dim objXmlFile

strXmlCall=Request.BinaryRead(Request.TotalBytes)
Set objXmlFile = Server.CreateObject("Microsoft.XMLDOM")

objXmlFile.load(strXmlCall)

If objXmlFile.readyState=4 Then
	If objXmlFile.parseError.errorCode <> 0 Then
		Call ResponseError(ERROR_NOT_LEGAL_XMLREQUEST)
	Else

		Dim objRootNode
		Set objRootNode=objXmlFile.documentElement

		Dim strAction
		strAction=objRootNode.selectSingleNode("methodName").text

		Dim strUserName
		Dim strUserPassWord
		Dim intNumberOfPosts
		Dim strPost
		Dim intPostID
		Dim strFileName
		Dim strFileType
		Dim strFileBits
		Dim bolPublish

		Select Case strAction
			Case "blogger.getUsersBlogs":
				strUserName=objRootNode.selectSingleNode("params/param[1]/value/string").text
				strUserPassWord=objRootNode.selectSingleNode("params/param[2]/value/string").text
				
				If VerifyUser(strUserName,strUserPassWord) Then Call GetUsersBlogs()
				
			Case "metaWeblog.getCategories":
				strUserName		=	objRootNode.selectSingleNode("params/param[1]/value/string").text
				strUserPassWord	=	objRootNode.selectSingleNode("params/param[2]/value/string").text
				
				If VerifyUser(strUserName,strUserPassWord) Then Call GetCategories()
				
			Case "metaWeblog.getCategories2":'此方法为oblog扩展,获取系统分类
				strUserName		=	objRootNode.selectSingleNode("params/param[1]/value/string").text
				strUserPassWord	=	objRootNode.selectSingleNode("params/param[2]/value/string").text
				
				If VerifyUser(strUserName,strUserPassWord) Then Call GetCategories2()
				
			Case "metaWeblog.newPost":
				strUserName		=	objRootNode.selectSingleNode("params/param[1]/value/string").text
				strUserPassWord	=	objRootNode.selectSingleNode("params/param[2]/value/string").text
				strPost			=	objRootNode.selectSingleNode("params/param[3]/value/struct").xml
				bolPublish		=	CBool(objRootNode.selectSingleNode("params/param[4]/value/boolean").text)
				
				If VerifyUser(strUserName,strUserPassWord) Then Call NewPost(strPost,bolPublish)
				
			Case "metaWeblog.getRecentPosts":
				strUserName		=	objRootNode.selectSingleNode("params/param[1]/value/string").text
				strUserPassWord	=	objRootNode.selectSingleNode("params/param[2]/value/string").text
				intNumberOfPosts=	objRootNode.selectSingleNode("params/param[3]/value/int").text
				
				If VerifyUser(strUserName,strUserPassWord) Then Call GetRecentPosts(intNumberOfPosts)
				
			Case "metaWeblog.editPost":
				intPostID		=	objRootNode.selectSingleNode("params/param[0]/value/string").text
				strUserName		=	objRootNode.selectSingleNode("params/param[1]/value/string").text
				strUserPassWord	=	objRootNode.selectSingleNode("params/param[2]/value/string").text
				strPost			=	objRootNode.selectSingleNode("params/param[3]/value/struct").xml
				bolPublish		=	CBool(objRootNode.selectSingleNode("params/param[4]/value/boolean").text)
				
				If VerifyUser(strUserName,strUserPassWord) Then Call EditPost(intPostID,strPost,bolPublish)
				
			Case "blogger.deletePost":
				intPostID		=	objRootNode.selectSingleNode("params/param[1]/value/string").text
				strUserName		=	objRootNode.selectSingleNode("params/param[2]/value/string").text
				strUserPassWord	=	objRootNode.selectSingleNode("params/param[3]/value/string").text
				
				If VerifyUser(strUserName,strUserPassWord) Then Call DeletePost(intPostID)
				
			Case "metaWeblog.newMediaObject":
				strUserName=objRootNode.selectSingleNode("params/param[1]/value/string").text
				strUserPassWord=objRootNode.selectSingleNode("params/param[2]/value/string").text
				strFileName=objRootNode.selectSingleNode("params/param[3]/value/struct/member[name=""name""]/value/string").text
				strFileType=objRootNode.selectSingleNode("params/param[3]/value/struct/member[name=""type""]/value/string").text
				strFileBits=objRootNode.selectSingleNode("params/param[3]/value/struct/member[name=""bits""]/value/base64").text
				
				If VerifyUser(strUserName,strUserPassWord) Then Call NewMediaObject(strFileName,strFileType,strFileBits)

			Case Else
				Call ResponseError(ERROR_UNKNOW_BLOGAPIMETHOD)
		End Select 

	End If
End If


conn.Close
Set conn = Nothing
%>

⌨️ 快捷键说明

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