📄 upload.asp
字号:
<!-- #include file="include/skin.asp" -->
<!-- #include file="include/upload_config.asp" -->
<!-- #include file="include/upload_watermark.asp" -->
<!-- #include file="include/jk_convert.asp" -->
<!-- #include file="include/jk_enurl.asp" -->
<!-- #include file="include/jk_msort.asp" -->
<!-- #include file="include/jk_val_code.asp" -->
<%
dim wmobj,dim_upload,is_admin,upload,up_text,up_path,uptemp,up_name,up_temp,upfile,upfilename,upfile_name,upfile_name2,upfilesize,upid,today_num,st,upcount,noload_type
dim formname,upload_path,upload_type,upload_size,upload_mn,upload_mode,up_sort,up_valcode
dim session_for
dim ReFilSize,ReFilType
ReFilSize=500 '远程图片大小限制 KB
ReFilType="gif|jpg|jpeg|bmp"
session_for=joekoe_cms.web_cookies&"_admin_"
upcount=1
today_num=0
tit="文件上传"
is_refur_true=false
is_admin=false
noload_type="asp,asa,aspx,php,cgi"
'--------------------------------------------------------------------------
server.scripttimeout=5000
'--------------------------------------------------------------------------
dim uptype,uppath,upname,uptext,upbg
uptype=trim(request.querystring("uptype"))
uppath=trim(request.querystring("uppath"))
upname=trim(request.querystring("upname"))
uptext=trim(request.querystring("uptext"))
upbg=trim(request.querystring("upbg"))
if action<>"upload" and action<>"upfile" then
call web_head_title()
call upload_frame(0)
response.write vbcrlf&"<input type=button value='点击进行文件上传' onclick=""javascript:location.href='?uptype="&uptype&"&uppath="&uppath&"&upname="&upname&"&uptext="&uptext&"&upbg="&upbg&"&action=upload';""><input type=hidden name=chk value='yes'>"
call upload_frame(1)
call web_clears(1)
end if
call web_head(0,1,4,0,0)
if session(session_for&"admin")="joekoe_admin" then
is_admin=true
login_username=session(session_for&"admines")
end if
call msort_start(0)
response.write vbcrlf&"<script language=javascript>" & _
vbcrlf&"if (top.location==self.location) { top.location=""./""; }" & _
vbcrlf&"</script>"
'----------------------------中间 开始----------------------------
call upload_frame(0)
if var_null(login_username)="" and is_admin=false then
response.write web_nologin
else
call upload_load()
end if
call upload_frame(1)
'----------------------------中间 结束----------------------------
call msort_end()
call web_end(0,4)
sub noload_load()
dim noi,nodim,uptmp
nodim=split(noload_type,",")
for noi=0 to ubound(nodim)
if instr(","&upload_type&",",","&nodim(noi)&",")>1 then
uptmp=","&upload_type&","
uptmp=replace(uptmp,","&nodim(noi)&",",",")
upload_type=left(uptmp,len(uptmp)-1)
upload_type=right(upload_type,len(upload_type)-1)
end if
next
end sub
sub upload_load()
set wmobj=new cms_watermark
if session(session_for&"admin")="joekoe_admin" then
is_admin=true
end if
dim_upload=split(web_dim(14),"|")
upload_path=web_dim(13)
select case lcase(uptype)
case "pic","pics"
upload_type=lcase(dim_upload(17))
case "swf","swfs"
upload_type="swf"
case "file","files"
upload_type=lcase(dim_upload(18))
case else
upload_type=lcase(dim_upload(0))
end select
call noload_load()
upload_size=dim_upload(1)
upload_mn=dim_upload(2)
upload_mode=dim_upload(3)
wmobj.con_mode=int(dim_upload(7))
wmobj.con_text=var_null(dim_upload(14))
wmobj.con_color=dim_upload(8)
wmobj.con_ycolor=dim_upload(22)
wmobj.con_setx=int(dim_upload(5))
wmobj.con_sety=int(dim_upload(6))
wmobj.con_place=int(dim_upload(9))
wmobj.con_watermark=dim_upload(10)
wmobj.wm_width=int(dim_upload(11))
wmobj.wm_height=int(dim_upload(12))
wmobj.con_opacity=int(dim_upload(13))
wmobj.base_width=int(dim_upload(15))
wmobj.base_height=int(dim_upload(16))
erase dim_upload
if not(isnumeric(upload_size)) then upload_size=0
if not(isnumeric(upload_mn)) then upload_mn=1
if is_admin=false then
call convert_load(login_mode)
upload_mn=format_convert(upload_mn,"+")
end if
if not isnumeric(upload_mode) then upload_mode=0
if upload_nums()=false then
response.write "<font class=re>注意</font>:您今天已上传<font class=red>"&today_num&"</font>个文件,每天只能上传<font class=red>"&upload_mn&"</font>个文件。"
exit sub
end if
select case action
case "upfile"
if joekoe_cms.post_chk()=false then
response.write web_nopost
else
call upload_way()
response.write uptemp
end if
'//* 新增 *//
case "remote"
call upload_remote()
'//* 结束 *//
case else
call upload_main()
end select
set wmobj=nothing
end sub
sub upload_0() '无组件上传
up_name=trim(upload.form("up_name"))
up_text=trim(upload.form("up_text"))
up_path=trim(upload.form("up_path"))
up_temp=trim(upload.form("up_temp"))
up_valcode=trim(upload.form("valcode"))
call upload_val_par()
if not up_val_chk(uppath) then
call upload_msg(6)
set upfile=nothing
exit sub
end if
set upfile=upload.file("file_name1")
upfilesize=upfile.filesize
if upfilesize<=0 then
call upload_msg(1)
set upfile=nothing
exit sub
end if
upfilename=upfile.filename
if upfilesize>(upload_size*1024) then
call upload_msg(2)
set upfile=nothing
exit sub
end if
upfile_name=right(upfilename,(len(upfilename)-instr(upfilename,".")))
upfile_name=lcase(upfile_name)
if instr(","&upload_type&",",","&upfile_name&",")<=0 then
call upload_msg(3)
set upfile=nothing
exit sub
end if
upfile_name2=upfile_name
upfile_name=up_name&"."&upfile_name
upfile.saveas up_path&upfile_name
call upload_data()
call upload_msg(4)
set upfile=nothing
end sub
sub upload_1() 'lyfupload
up_name=trim(upload.request("up_name"))
up_text=trim(upload.request("up_text"))
up_path=trim(upload.request("up_path"))
up_temp=trim(upload.request("up_temp"))
up_valcode=trim(upload.request("valcode"))
if var_null(up_temp)="" then
call upload_msg(1)
exit sub
end if
upload.maxsize=upload_size*1024
upload.extname=upload_type
call upload_val_par()
if not up_val_chk(uppath) then
call upload_msg(6)
set upfile=nothing
exit sub
end if
upfile_name=apart_filename(up_temp,2,"\")
upfile_name=lcase(upfile_name)
if instr(","&upload_type&",",","&upfile_name&",")>0 then
upfile_name2=upfile_name
upfile_name=up_name&"."&upfile_name
end if
if right(up_path,1)="/" then up_path=left(up_path,len(up_path)-1)
if right(up_path,1)<>"\" then up_path=up_path&"\"
st=upload.savefile("file_name1",up_path,true,upfile_name)
select case cstr(st)
case "0"
call upload_msg(2)
exit sub
case "1"
call upload_msg(3)
exit sub
case "3"
if is_admin=false then
call upload_msg(0)
exit sub
end if
upfilesize=upload.filesize
case ""
call upload_msg(5)
exit sub
case else
upfilesize=upload.filesize
end select
call upload_data()
call upload_msg(4)
end sub
sub upload_2() 'aspupload
on error resume next
if is_admin=true or session(session_for&"uploadtype")="s" then
upload.overwritefiles=true '能复盖
else
upload.overwritefiles=false '不能复盖
end if
upload.ignorenopost=true
upload.setmaxsize upload_size*1024,true '限制大小
upcount=upload.save
if err.number=8 then
err.clear
call upload_msg(2)
exit sub
end if
if err<>0 then 'err.description
call upload_msg(5)
exit sub
end if
up_name=trim(upload.form("up_name"))
up_text=trim(upload.form("up_text"))
up_path=trim(upload.form("up_path"))
up_temp=trim(upload.form("up_temp"))
up_valcode=trim(upload.form("valcode"))
call upload_val_par()
if not up_val_chk(uppath) then
call upload_msg(6)
set upfile=nothing
exit sub
end if
set upfile=upload.files("file_name1")
if upcount<>1 then
call upload_msg(1)
set upfile=nothing
exit sub
end if
upfilename=upfile.filename
upfilesize=upfile.size
upfile_name=apart_filename(upfilename,2,".")
upfile_name=lcase(upfile_name)
if instr(","&upload_type&",",","&upfile_name&",")<=0 then
call upload_msg(3)
set upfile=nothing
exit sub
end if
upfile_name2=upfile_name
upfile_name=up_name&"."&upfile_name
upfile.saveas up_path&upfile_name
call upload_data()
call upload_msg(4)
set upfile=nothing
end sub
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(upload_path,up_path) '验证文件夹是否存在
up_path=server.mappath(upload_path&up_path)
if right(up_path,1)<>"/" then up_path=up_path&"/"
end sub
sub upload_data()
dim uiid,unsort,utypes
session("mode")=upfile_name2
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()
dim ta
ta="#"
if joekoe_cms.web_vt=1 then ta="'"
upload_nums=true
if is_admin=true then
exit function
end if
sql="select count(*) from upload where username='"&login_username&"' and tim>="&ta&formatdatetime(formatdatetime(joekoe_cms.now_time,2))&ta
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
end if
end function
sub upload_msg(mn)
dim tmpjs
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -