<%
sub CheckFileExt()
if FileSize < 1 then error2("当前文件为空文件")
if FileSize > UpMaxFileSize then error2("文件大小不得超过 "&CheckSize(UpMaxFileSize)&"\n当前的文件大小为 "&CheckSize(FileSize)&"")
if FileExt="asa" or FileExt="asp" or FileExt="cdx" or FileExt="cer" then error2("对不起，管理员设定本论坛不允许上传 "&FileExt&" 格式的文件")

if UpClass="Photo" or UpClass="Face" then
if split(FileMIME,"/")(0)<>"image" then error2("相册只允许上传图像格式的文件")
else
if instr("|"&UpFileTypes&"|","|"&FileExt&"|") <= 0 then error2("对不起，管理员设定本论坛不允许上传 "&FileExt&" 格式的文件")
end if

end sub


TotalUserPostAttachments=conn.execute("Select sum(ContentSize) from [BBSXP_UpFiles] where UserName='"&CookieUserName&"'")(0)
<!-----附件分组设置----->
if SiteSettings("Maxup")<>1 then
updatamax=SiteSettings("MaxPostAttachmentsSize")
else
updatamax=conn.execute("select Maxup from BBSXP_Roles where id="&UserRoleID)(0)
end if
if TotalUserPostAttachments+FileSize>updatamax then error2("您的上传空间已满！")
<!-----附件分组设置----->
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if ""&SiteSettings("UpFileOption")&""="" then
error2("对不起，管理员关闭文件上传功能")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif SiteSettings("UpFileOption")="ADODB.Stream" then
set upfile=new upfile_class				'建立上传对象
upfile.GetData ()					'取得上传数据
FileName=upfile.file("file").FileName			'文件名
FileExt=LCase(upfile.file("file").FileExt)		'小写后缀名
FileMIME=upfile.file("file").FileMIME			'文件类型
FileSize=upfile.file("file").FileSize			'文件大小
SaveFile=""&UpFolder&"."&FileExt&""			'保存文件路径
CheckFileExt()
upfile.SaveToFile "file",Server.mappath(""&SaveFile&"")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif SiteSettings("UpFileOption")="SoftArtisans.FileUp" then
Set FileUP = Server.CreateObject("SoftArtisans.FileUp")
FileName=FileUP.ShortFilename				'文件名
FileExt=LCase(mid(FileName,InStrRev(FileName, ".")+1))	'小写后缀名
FileMIME=FileUP.ContentType				'文件类型
FileSize=FileUP.TotalBytes				'文件大小
SaveFile=""&UpFolder&"."&FileExt&""			'保存文件路径
CheckFileExt()
FileUP.SaveAs Server.mappath(""&SaveFile&"")
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if Sitesettings("WatermarkOption")="Persits.Jpeg" and FileMIME="image/pjpeg" then
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Jpeg.Open Server.MapPath(""&SaveFile&"")
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if sitesettings("WatermarkType")=0 then
'Jpeg.Canvas.Font.Color = &H000000	'颜色
'Jpeg.Canvas.Font.Family = "黑体"  	'字体
'Jpeg.Canvas.Font.size = "15"		'大小
'Jpeg.Canvas.Font.Bold = True		'是否加粗
Jpeg.Canvas.Print 10, 10, ""&SiteSettings("WatermarkText")&""
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
elseif sitesettings("WatermarkType")=1 then
Set Jpeg2 = Server.CreateObject("Persits.Jpeg")
Jpeg2.Open Server.MapPath(sitesettings("WatermarkImage"))
select case sitesettings("WatermarkPosition")
case "0"
ImageWidth=10
ImageHeight=10
case "1"
ImageWidth=10
ImageHeight=Jpeg.OriginalHeight-Jpeg2.OriginalHeight-10
case "2"
ImageWidth=(Jpeg.OriginalWidth-Jpeg2.OriginalWidth)/2
ImageHeight=(Jpeg.OriginalHeight-Jpeg2.OriginalHeight)/2
case "3"
ImageWidth=Jpeg.OriginalWidth-Jpeg2.OriginalWidth-10
ImageHeight=10
case "4"
ImageWidth=Jpeg.OriginalWidth-Jpeg2.OriginalWidth-10
ImageHeight=Jpeg.OriginalHeight-Jpeg2.OriginalHeight-10
end select
Jpeg.Canvas.DrawImage ImageWidth, ImageHeight, Jpeg2, 0.5, &HFFFFFF	'0.5透明度, 透明颜色FFFFFF
end if
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Jpeg.Save Server.MapPath(""&SaveFile&"")
Set Jpeg = Nothing
end if

Rs.Open "[BBSXP_UpFiles]",conn,1,3 
Rs.addnew 
Rs("UserName")=CookieUserName
Rs("FileName")=FileName
Rs("ContentType")=FileMIME
Rs("ContentSize")=FileSize
Rs("FilePath")=SaveFile
Rs("Class")=UpClass
Rs("Category")=""
Rs.update
AttachmentID=Rs("id")
Rs.close
%>