photoxml.asp

来自「是个不错的文件代码,希望大家好好用,」· ASP 代码 · 共 186 行

ASP
186
字号
<!--#include file="conn.asp"-->
<!--#include file="inc/class_sys.asp"-->
<!--#include file="inc/md5.asp"-->
<%
dim oblog,action,userid
set oblog=new class_sys
oblog.autoupdate=false
oblog.start
Response.contentType="application/xml"
Response.Expires=0
Response.Write("<?xml version=""1.0"" encoding=""UTF-8""?>")
action=trim(request("action"))
userid=clng(request("userid"))
select case action
	case "menu"
		call menu()
	case "photo"
		call photo()
	case "sysclass"
		call sysclass()
	case "subject"
		call subject()
	case "chklogin"
		call chklogin()
	case "islogin"
		call islogin()
	case "delfile"
		call delfile()
end select

sub menu()
	dim rs,menustr,i
	set rs=oblog.execute("select subjectname,subjectid from oblog_subject where userid=" & userid & " And SubjectType=1 order by ordernum")
	while not rs.eof
		menustr=menustr&"<menu label="""&rs("subjectname")&""" subjectid="""&rs("subjectid")&""" />"
		rs.movenext
	wend
%>
<menu>
	<menu label="所有图片" subjectid="0" />
	<%=menustr%>
	<menu label="大头贴" subjectid="-1" />
</menu>
<%
	set rs=nothing
end sub

sub photo()
	dim rs,ssql,subjectid,pstr
	subjectid=clng(request("subjectid"))
	if subjectid>0 then ssql=" and userClassId="&subjectid
	if subjectid=-1 then ssql=" and isBigHead=1"
	set rs=oblog.execute("select file_name,file_path,fileid from oblog_upfile where userid="&userid&ssql&" and isphoto=1 order by fileid desc")
	while not rs.eof 
		pstr=pstr&"<p _name="""&rs("file_name")&""" _url="""&rs("file_path")&""" _fileid="""&rs("fileid")&"""/>"
		rs.movenext
	wend
	response.Write "<photo>"&pstr&"</photo>" 
	set rs=nothing
end sub

sub sysclass()
	dim rs,pstr
	set rs=oblog.execute("select id,classname from oblog_logclass where idType=1 order by RootID,OrderID")
	while not rs.eof
		pstr=pstr&"<c _name="""&rs("classname")&""" _id="""&rs("id")&"""/>"
		rs.movenext
	wend
	response.Write "<sysclass>"&pstr&"</sysclass>" 
	set rs=nothing
end sub

sub subject()
	dim rs,pstr
	set rs=oblog.execute("select subjectid,subjectname from oblog_subject where subjectType=1 and userid="&userid&" order by Ordernum")
	while not rs.eof
		pstr=pstr&"<s _name="""&rs("subjectname")&""" _id="""&rs("subjectid")&"""/>"
		rs.movenext
	wend
	response.Write "<subject>"&pstr&"</subject>" 
	set rs=nothing
end sub

sub chklogin()
	
end sub

sub islogin()
	dim xmlstr
	if not oblog.checkuserlogined() then
		xmlstr="<m msg=""未登录"" login=""0"" />"
	else
		if oblog.l_ulevel=6 then
			xmlstr="<m msg=""您的账号未通过审核"" login=""0"" />"
		elseif oblog.l_uid<>userid then
			xmlstr="<m msg=""您不是当前用户,无权限上传"" login=""0"" />"
		else
			'xmlstr="<m msg=""已登录"" login=""1"" />"
			xmlstr="<m msg=""已登录"" login=""1"" maxsize="""&int(oblog.l_Group(24,0)-oblog.l_uUpUsed/1024)&""" onesize="""&oblog.l_Group(23,0)&""" />"
		end if
	end if
	response.Write "<islogin>"&xmlstr&"</islogin>" 
end sub

sub chklogin()
	dim username,password,xmlstr
	username=oblog.filt_badstr(trim(request("username")))
	password=md5(request("password"))
	oblog.ob_chklogin username,password,0
	if oblog.errstr<>"" then
		xmlstr="<m msg="""&oblog.errstr&""" login=""0"" />"
	else
		xmlstr="<m msg=""登录成功"" login=""1"" />"
	end if
	response.Write "<chklogin>"&xmlstr&"</chklogin>" 
end sub

sub delfile()
	dim fileid,xmlstr
	fileid=trim(request("fileid"))
	if not oblog.checkuserlogined() then
		response.Write("<delfile><m msg=""请登录后执行删除操作"" isdel=""0"" /></delfile>")
		exit sub
	end if
	 If InStr(fileid, ",") > 0 Then
        Dim n, i
        fileid = FilterIDs(fileid)
        n = Split(fileid, ",")
        For i = 0 To UBound(n)
            if delonefile (n(i)) then
				xmlstr="<m msg=""删除成功"" isdel=""1"" />"
			else
				xmlstr="<m msg=""删除失败"" isdel=""0"" />"
			end if
        Next
    Else
        if delonefile (fileid) then
			xmlstr="<m msg=""删除成功"" isdel=""1"" />"
		else
			xmlstr="<m msg=""删除失败"" isdel=""0"" />"
		end if
    End If
	response.Write "<delfile>"&xmlstr&"</delfile>" 
end sub


function delonefile(fileid)
	fileid=clng(fileid)
	dim userid,filesize,filepath,fso,photofile,isphoto,imgsrc,sql,rs	
	sql="select * from [oblog_upfile] where fileid=" & fileid&" and userid="&oblog.l_uid
	set rs=server.createobject("adodb.recordset")
	link_database
	rs.open sql,conn,1,3
	if not rs.eof then
		userid=rs("userid")
		filesize=Int(rs("file_size"))
		filepath=rs("file_path")
		photofile=rs("photofile")
		isphoto=rs("isphoto")
		rs.delete
		rs.update
		rs.close
		oblog.execute("update [oblog_user] set user_upfiles_size=user_upfiles_size-"&filesize&" where userid="&userid)
		if filepath<>"" then
			imgsrc=filepath
			Set fso = server.CreateObject("Scripting.FileSystemObject")
			if instr("jpg,bmp,gif,png,pcx",right(imgsrc,3))>0 then
				imgsrc=replace(imgsrc,right(imgsrc,3),"jpg")
				imgsrc=replace(imgsrc,right(imgsrc,len(imgsrc)-InstrRev(imgsrc,"/")),"pre"&right(imgsrc,len(imgsrc)-InstrRev(imgsrc,"/")))
				if  fso.FileExists(Server.MapPath(imgsrc)) then
					fso.DeleteFile Server.MapPath(imgsrc)
				end if
			end if
			if fso.FileExists(Server.MapPath(filepath)) then 
				fso.DeleteFile Server.MapPath(filepath)
			end if
			set fso=nothing
		end if
		delonefile=true
	else
		delonefile=false
		rs.close
		set rs=nothing
	End If
end function
%>

⌨️ 快捷键说明

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