<!--#include file="../act_inc/ACT.User.asp"-->
<!--#include file="../ACT_inc/upfile_class.asp"-->
<!--#include file="../ACT_inc/ACT.SLT.asp"-->
<%
const upload_type=0
Dim Path,ModeID,DateDir,UpFileType,UpfilesSize,AddWaterFlag
ModeID = ACTCMS.ChkNumeric(ACTCMS.s("ModeID"))
If ModeID = 0 Then ModeID = 1
	

	Dim userhs
    Set UserHS = New ACT_User
	IF Cbool(UserHS.UserLoginChecked)=false then
	  Response.Write "<script>top.location.href ='login.asp' ;</script>"
	  Response.end
	End If
	Dim UserUpFilesTF
		Path=UserHS.G_Path&"/"&UserHS.UserID
		UpFileType=UserHS.G_UpFileType
		UpfilesSize=UserHS.G_UpfilesSize
DateDir = Year(Now()) & Right("0" & Month(Now()), 2) & "/"
Path =ACTCMS.ActSys& Path & "/" & DateDir
Call ACTCMS.CreateFolder(Path)
const ForbidFileType="asp,aspx,htm,html,js,shtml,zip,cer,cdx"
const EnableUploadFile="Yes"
dim upload,oFile,formName,SavePath,filename,fileExts,oFileSize
dim EnableUpload
dim arrUpFileType
dim ranNum
dim msg,FoundErr
msg=""
FoundErr=false
EnableUpload=False
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Images/css/css.css" rel="stylesheet" type="text/css">
<body leftMargin="0" topMargin="0" marginwidth="0" marginheight="0">


<script type="text/javascript">
// 文件上传成功接口操作
function doInterfaceUpload(strValue,instrname){
	if (strValue=="") return;
	var objLinkUpload = parent.document.getElementsByName(instrname)[0];
	if (objLinkUpload){
		if (objLinkUpload.value!=""){
			objLinkUpload.value = "";
		}
		objLinkUpload.value = objLinkUpload.value + strValue;
		objLinkUpload.fireEvent("onchange");
	}
}
</script>
</head>
<body leftmargin="2" topmargin="5" marginwidth="0" marginheight="0">
<%
call upload_0()  '使用化境无组件上传类
%>

<%
sub upload_0()    '使用化境无组件上传类
	set upload=new upfile_class ''建立上传对象
	upload.GetData(104857600)   '取得上传数据,限制最大上传100M
	AddWaterFlag= upload.Form("AddWaterFlag")
	If AddWaterFlag <> "1" Then	'生成是否要添加水印标记
		AddWaterFlag = "0"
	End if
	if upload.err > 0 then  '如果出错
		select case upload.err
			case 1
				response.write "请先选择你要上传的文件！"
			case 2
				response.write "你上传的文件总大小超出了最大限制（100M）"
		end select
		response.end
	end if
	SavePath = Path   '存放上传文件的目录
	if right(SavePath,1)<>"/" then SavePath=SavePath&"/" '在目录后加(/)
	for each formName in upload.file '列出所有上传了的文件
		set ofile=upload.file(formName)  '生成一个文件对象
		oFileSize=ofile.filesize
		if oFileSize<100 then
			msg="请先选择你要上传的文件！"
			FoundErr=True
		elseif oFileSize>(UpfilesSize*1024) then
 			msg="文件大小超过了限制，最大只能上传" & CStr(UpfilesSize) & "K的文件！"
			FoundErr=true
		end if

		fileExts=lcase(trim(ofile.fileExt))
		if(instr(ForbidFileType,fileExts)<>0) then
			response.Write("不允许上传的文件类型："&fileExts)
			EnableUpload=false
			response.End()
		end if
		arrUpFileType=split(UpFileType,"|")
		Dim i,strJS,file
		for i=0 to ubound(arrUpFileType)
			if fileExts=trim(arrUpFileType(i)) then
				EnableUpload=true
				exit for
			end if
		next
		if fileExts="exe" or fileExts="asa" or fileExts="aspx" then
			EnableUpload=false
		end if
		if EnableUpload=false then
			msg="这种文件类型不允许上传！\n\n只允许上传这几种文件类型：" & UpFileType
			FoundErr=true
		end if
		strJS="<SCRIPT language=javascript>" & vbcrlf
		if FoundErr<>true then
			randomize
			ranNum=int(900*rnd)+100
			filename=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&ranNum&"."&fileExts
			ofile.SaveToFile Server.mappath(SavePath&FileName)   '保存文件
		   If AddWaterFlag = "1" Then   '在保存好的图片上添加水印
				Dim W:Set W=New Watermark
				Call W.AddWaterMark(SavePath&FileName)
		   End if
		else
			strJS=strJS & "alert('" & msg & "');" & vbcrlf
		  	strJS=strJS & "history.go(-1);" & vbcrlf
		end if
		strJS=strJS & "</script>" & vbcrlf
		response.write strJS
		
		set file=nothing
	next
	set upload=nothing
end sub




Sub OutUploadScript(sType,strPath,instrct)
			sType = LCase(sType)
			Response.Write "function   insertHTMLToEditor(codeStr)" & vbCrLf
			Response.Write "	{" & vbCrLf
			Response.Write "	oEditor = FCKeditorAPI.GetInstance('"&instrct&"');" & vbCrLf
			Response.Write "	if(oEditor   &&   oEditor.EditorWindow){ "& vbCrLf
			Response.Write "		oEditor.InsertHtml(codeStr); "& vbCrLf
			Response.Write "	}" & vbCrLf
			Response.Write "}" & vbCrLf
	Select Case sType
		Case "gif","jpg","png","bmp","jpeg","tif","iff"
			Response.Write "parent.insertHTMLToEditor('<img src=""" & strPath & """ alt="""" />')" & vbCrLf
		Case "swf"
			Response.Write "parent.insertHTMLToEditor('<embed src=""" & strPath & """ scale=""ShowAll""  width=""450"" height=""70"" play=""true"" loop=""true"" menu=""true"" wmode=""Window"" quality=""1"" type=""application/x-shockwave-flash""></embed>')" & vbCrLf
		Case "mp3","wma"
			Response.Write "parent.insertHTMLToEditor('<object classid=""CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95""  id=""MediaPlayer"" width=""450"" height=""70""><param name=""howStatusBar"" value=""-1""><param name=""AutoStart"" value=""False""><param name=""Filename"" value=""" & strPath & """></object>')" & vbCrLf
		Case "rm","rmvb"
			Response.Write "parent.insertHTMLToEditor('<object classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" width=""400"" height=""300""><param name=""SRC"" value=""" & strPath & """ /><param name=""CONTROLS"" VALUE=""ImageWindow"" />"
			Response.Write "<param name=""CONSOLE"" value=""one"" /><param name=""AUTOSTART"" value=""true"" /><embed src=""" & strPath & """ nojava=""true"" controls=""ImageWindow"" console=""one"" width=""400"" height=""300""></object><br/>"
			Response.Write "<object classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" width=""400"" height=""32"" /><param name=""CONTROLS"" value=""StatusBar"" /><param name=""AUTOSTART"" value=""true"" /><param name=""CONSOLE"" value=""one"" />"
			Response.Write "<embed src=""" & strPath & """ nojava=""true"" controls=""StatusBar"" console=""one"" width=""400"" height=""24"" /></object><br/><object classid=""clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"" width=""400"" height=""32"" />"
			Response.Write "<param name=""CONTROLS"" value=""ControlPanel"" /><param name=""AUTOSTART"" value=""true"" /><param name=""CONSOLE"" value=""one"" /><embed src=""" & strPath & """ nojava=""true"" controls=""ControlPanel"" console=""one"" width=""400"" height=""24"" autostart=""true"" loop=""false"" /></object>')" & vbCrLf
		Case "ra"
			Response.Write "parent.insertHTMLToEditor('<object classid=""clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"" id=""RAOCX"" width=""450"" height=""60""><param name=""_ExtentX"" value=""6694""><param name=""_ExtentY"" value=""1588""><param name=""AUTOSTART"" value=""true""><param name=""SHUFFLE"" value=""0""><param name=""PREFETCH"" value=""0"">"
			Response.Write "<param name=""NOLABELS"" value=""0""><param name=""SRC"" value=""" & strPath & """><param name=""CONTROLS"" value=""StatusBar,ControlPanel""><param name=""LOOP"" value=""0""><param name=""NUMLOOP"" value=""0""><param name=""CENTER"" value=""0""><param name=""MAINTAINASPECT"" value=""0""><param name=""BACKGROUNDCOLOR"" value=""#000000""><embed src=""" & strPath & """ width=""450"" autostart=""true"" height=""60""></embed></object>')" & vbCrLf
		Case "asf","avi","wmv"
			Response.Write "parent.insertHTMLToEditor('<object classid=""clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"" codebase=""http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902"" type=""application/x-oleobject"" standby=""Loading..."" width=""400"" height=""300"">"
			Response.Write "<param name=""FileName"" VALUE=""" & strPath & """ /><param name=""ShowStatusBar"" value=""-1"" /><param name=""AutoStart"" value=""true"" /><embed type=""application/x-mplayer2"" pluginspage=""http://www.microsoft.com/Windows/MediaPlayer/"" src=""" & strPath & """ autostart=""true"" width=""400"" height=""300"" /></object>')" & vbCrLf
		Case Else
			Response.Write "parent.insertHTMLToEditor('<a href=""" & strPath & """><img src=""" & ACTCMS.ActSys& "ACT_inc/share/download.gif"" border=""0"" style=""margin:0px 2px -4px 0px""/>点击下载此文件</a>')" & vbCrLf
	End Select
End Sub




Dim strpath,instrct
instrct=Request.QueryString("instrct")
strpath=Path&filename
call adduploaditem(fileExts,strpath,instrct)
If Request.QueryString("instr") = "1" Then
Response.Write "<script type=""text/javascript"">" & vbCrLf
Response.Write "doInterfaceUpload('" & strpath & "','" & Request.QueryString("instrname") & "');" & vbCrLf
Response.Write "</script>" & vbCrLf
End If
Sub addUploadItem(fileExts,strpath,instrct)
If Request.QueryString("YNContent") = "1" Then
	Response.Write "<script type=""text/javascript"">" & vbCrLf
	Call OutUploadScript(fileExts,strpath,instrct)
	Response.Write "</script>" & vbCrLf
End IF
End Sub
%>
<table style="width: 100%; height: 100%" cellspacing="0" cellpadding="0" align="center" border="0">
    <tr valign="top">
        <td><%response.write "文件上传成功！文件大小为：" & cstr(round(oFileSize/1024)) & "K"%>
<input type="button" name="Submit4" onclick="javascript:history.go(-1)" value="继续上传文件"><br>
        </td>
    </tr>
</table>
</body>
</html>