📄 upload.asp
字号:
sub upload_val_par()
up_name=var_null(up_name)
if session(session_for&"admin")<>"joekoe_admin" and len(up_name)>2 and session(session_for&"uploadtype")<>"s" then up_name=""
if len(up_name)<3 then up_name=up_name&joekoe_cms.rand_file("")
if not upsort_path(up_path) then up_path="other"
if len(up_path)<3 then up_path="other"
uppath=up_path
if uppath="face" then
upload_type="gif"
up_name="face_"&login_id
end if
if right(upload_path,1)<>"/" then upload_path=upload_path&"/"
call upload_val_folder(joekoe_cms.web_dir&upload_path,up_path) '验证文件夹是否存在
up_path=server.mappath(joekoe_cms.web_dir&upload_path&up_path)
if right(up_path,1)<>"/" then up_path=up_path&"/"
end sub
sub upload_data()
dim uiid,unsort,utypes
uiid=0
unsort=""
utypes=0
sql="select id from upload where url='"&uppath&"/"&upfile_name&"'"
if session(session_for&"uploadtype")="s" then
uiid=int(login_id)
unsort="uface"
utypes=1
sql="select id from upload where iid="&uiid&" and nsort='"&unsort&"'"
end if
set rs=joekoe_cms.exec(sql,1)
if rs.eof then
rs.close
sql="insert into upload(iid,nsort,types,username,url,genre,sizes,tim) " & _
"values("&uiid&",'"&unsort&"',"&utypes&",'"&login_username&"','"&uppath&"/"&upfile_name&"','"&upfile_name2&"',"&upfilesize&",'"&joekoe_cms.now_time&"')"
call joekoe_cms.exec(sql,0)
sql="select top 1 id from upload order by id desc"
set rs=joekoe_cms.exec(sql,1)
upid=int(rs("id"))
else
call joekoe_cms.exec("update upload set username='"&login_username&"',sizes="&upfilesize&",tim='"&joekoe_cms.now_time&"',url='"&uppath&"/"&upfile_name&"' where id="&rs("id"),0)
end if
rs.close
session(session_for&"uploadtype")=""
end sub
function upload_nums()
upload_nums=true
if session(session_for&"admin")<>"joekoe_admin" then
sql="select count(*) from upload where username='"&login_username&"' and tim>="&time_mode&formatdatetime(formatdatetime(joekoe_cms.now_time,2))&time_mode
set rs=joekoe_cms.exec(sql,1)
today_num=rs(0)
rs.close
if not(isnumeric(today_num)) then today_num=0
if int(today_num)>=int(upload_mn) then
upload_nums=false
response.write "<font class=re>注意</font>:您今天已上传<font class=red>"&today_num&"</font>个文件,每天只能上传<font class=red>"&upload_mn&"</font>个文件。"
end if
end if
end function
sub upload_msg(mn)
dim tmpjs
select case mn
case 0
uptemp=vbcrlf&"<font class=red>上传失败</font>:参数出错!"&go_back
case 1
uptemp=vbcrlf&"<font class=red>上传失败</font>:您可能没有选择想要上传的文件!"&go_back
case 2
uptemp=vbcrlf&"<font class=red>上传失败</font>:文件太大!(不能超过<font class=red>"&int(upload_size)&"KB</font>) "&go_back
case 3
uptemp=vbcrlf&"<font class=red>上传失败</font>:文件类型只能为:<font class=blue>"&replace(upload_type,"|","、")&"</font> 等格式 "&go_back
case 4
uptemp=vbcrlf&"<font class=red>上传成功</font>:<a href='../"&upload_path&uppath&"/"&upfile_name&"' target=_blank>"&upfile_name&"</a> ("&upfilesize&"Byte)"
if instr(up_text,"pic")>0 then
if uppath="face" then
tmpjs=tmpjs&"parent.document.all."&up_text&".value='../"&upload_path&uppath&"/"&upfile_name&"';"
upid=0
else
tmpjs=tmpjs&"parent.document.all."&up_text&".value='"&uppath&"/"&upfile_name&"';"
end if
else
uptemp=uptemp&vbcrlf&" [ <a href='?uppath="&uppath&"&upname=&uptext="&up_text&"'>点击继续上传</a> ]"
tmpjs=tmpjs&"parent.document.all."&up_text&".value+='"
select case lcase(upfile_name2)
case "gif","jpg","bmp","png"
tmpjs=tmpjs&"[IMG]../"&upload_path&uppath&"/"&upfile_name&"[/IMG]"
case "swf"
tmpjs=tmpjs&"[FLASH=350,250]../"&upload_path&uppath&"/"&upfile_name&"[/FLASH]"
case else
tmpjs=tmpjs&"[DOWNLOAD]../"&upload_path&uppath&"/"&upfile_name&"[/DOWNLOAD]"
end select
tmpjs=tmpjs&"\n';"
end if
if int(upid)>0 then tmpjs=tmpjs&"parent.document.all.upid.value+=',"&upid&"';"
if tmpjs<>"" then
uptemp=uptemp&vbcrlf&"<script language=javascript>"&vbcrlf&tmpjs&vbcrlf&"</script>"
end if
call val_chk_end("up_"&uppath)
case 5
uptemp=vbcrlf&"<font class=red>上传失败</font>:未知错误!"&go_back
case 6
uptemp=vbcrlf&"<font class=red>上传失败</font>: <font class=red>验证码</font> 为空或有错误!"&go_back
end select
end sub
sub upload_way()
on error resume next
dim up_way
select case upload_mode
case 0
up_way="无"
set upload=new upload_classes
case 1
up_way="LyfUpload"
set upload=server.createobject("lyfupload.uploadfile")
case 2
up_way="AspUpload"
set upload = server.createobject("persits.upload")
end select
if err then
set upload=nothing
err.clear
response.write "空间不支持 <font class=red>"&up_way&" 组件</font> 上传!请后台配置后再进行上传功能。"
exit sub
end if
select case upload_mode
case 1
call upload_1()
case 2
call upload_2()
case else
call upload_0()
end select
set upload=nothing
if err then err.clear
end sub
sub upload_val_folder(uf_upload,uf_uppath)
dim myfso,myfile,up_path
set myfso=createobject("scripting.filesystemobject")
if uf_uppath<>"" then
myfile=server.mappath(uf_upload&uf_uppath)
if not myfso.folderexists(myfile) then
set up_path=myfso.createfolder(myfile)
end if
end if
set myfso=nothing
end sub
sub upload_main()
dim upname,uptext,cid
session(session_for&"uploadtype")=""
uppath=trim(request.querystring("uppath"))
upname=trim(request.querystring("upname"))
uptext=trim(request.querystring("uptext"))
if session(session_for&"admin")<>"joekoe_admin" then
if len(upname)>2 then upname=""
end if
if not upsort_path(uppath) then
response.write "参数(1)出错!"
exit sub
end if
if uppath="face" then
session(session_for&"uploadtype")="s"
if int(login_id)<1 then
response.write "参数(2)出错!"
exit sub
end if
upname="face_"&login_id
end if
if len(uppath)<1 or len(uptext)<1 then
response.write "参数(3)出错!"
exit sub
end if
%>
<script language=javascript>
function frm_submit(theform)
{
if (document.all||document.getElementById)
{
for (i=0;i<theform.length;i++)
{
var tempobj=theform.elements[i];
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
tempobj.disabled=true;
}
}
}
</script>
<table border=0 cellspacing=0 cellpadding=2>
<form name=form1 action='?action=upfile' method=post enctype='multipart/form-data'<%if cstr(upload_mode)<>"0" then response.write " onsubmit=""javascript:frm_submit(this);"""%>>
<input type=hidden name=up_path value='<%response.write uppath%>'>
<input type=hidden name=up_name value='<% response.write upname %>'>
<input type=hidden name=up_text value='<% response.write uptext %>'>
<input type=hidden name=up_temp value=''>
<%response.write val_code_num("up_"&uppath,1)%>
<tr>
<td><input type=file name=file_name1 value='' size=10></td>
<td align=center height=30><%
if uppath="face" then
response.write "<input type=submit name=submit onclick=""up_temp.value=file_name1.value"" value='上 传'> <font class=blue>GIF</font> 格式,小于<font class=red>"&upload_size&"</font>KB"
else
response.write "<input type=submit name=submit onclick=""up_temp.value=file_name1.value"" value='点击上传'> (今天上传<font class=red>"&today_num&"</font>个,每天<font class=red>"&upload_mn&"</font>个,每个<font class=red>"&upload_size&"</font>KB)"
end if
%></td>
</tr>
</form>
</table>
<%
end sub
function up_val_chk(vsort)
if not val_is_true then
up_val_chk=true
exit function
end if
dim valcode,valc
up_val_chk=false
valcode="jk"&up_valcode
valc=trim(request.cookies(joekoe_cms.web_cookies)("vc_up_"&vsort))
if valcode<>"" and valcode<>"jk" and cstr(valcode)=cstr(valc) then
up_val_chk=true
end if
end function
'****************************************************
' Web: http://www.aouoo.com , http://www.aouoo.net
' Copyright (C) 2007 Aouoo.com All Rights Reserved.
'****************************************************
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -