<!-- #include file=../inc/BBSsetup.asp -->
<!-- #include file=../inc/Board_Popfun.asp -->
<!-- #include file=../inc/Upload_Fun.asp -->
<script language=javascript>
<!--

	function addcontent(tmpstr)
	{
		parent.document.LeadBBSFm.Form_Content.value = parent.document.LeadBBSFm.Form_Content.value + tmpstr;
	}

//-->
</script>
<%
DEF_BBS_HomeUrl = "../"
GBL_UploadFlag = 1
Rem 缩小图像模式,0-缩小到预定宽或高,1,如果大于预定宽或高则成倍缩小
Const DEF_ResizeMode = 1

If DEF_FSOString = "" Then Response.End
If DEF_EnableDotNetUpload <> 1 Then Response.End
SiteHead("   ")
%>
<body bgcolor=<%=DEF_BBS_LightestColor%> leftmargin="0" topmargin="0" class=TBBGbody>
<%

initDatabase
MakeImg
CloseDatabase

Response.Write "<p>文件上传成功,要<a href=uploadFile.aspx?BoardID=" & Request.Form("BoardID") & "&cssfile=" & GBL_Board_BoardStyle & ">继续上传请点这里</a></body></html>"

function movefiles(tempsource,tempend)

    'on error resume next
    Dim fs
    Set fs=Server.CreateObject(DEF_FSOString)

    if fs.FileExists(tempend) then
       movefiles = 0
       set fs=nothing
       Exit Function
    end if
    
    if fs.FileExists(tempsource) then
    else
       movefiles = 0
       set fs=nothing
       Exit Function
    end if
    fs.moveFile tempsource,tempend
    movefiles = 1
    Set fs=nothing
         
end function

Function MakeImg

	'on error resume next
	Dim LoadFile,LoadFileNoUnder
	LoadFile = Request("LoadFile")
	If LoadFile = "" Then Exit Function
	If Right(LoadFile,1) <> "_" Then Exit Function

	Dim fs
	Set fs = CreateObject(DEF_FSOString)
	If Not fs.FileExists(LoadFile) Then
		Set Fs = Nothing
		Exit Function
	End if

	Dim SaveFile
	SaveFile = Left(LoadFile,len(LoadFile)-1)
	LoadFileNoUnder = SaveFile
	
	SaveFile = Replace(SaveFile,"/","\")

	Dim pic_name,pic_name1,UploadPhotoUrl2,UploadPhotoUrl,Old_pic_name,HeadStr

	If inStrRev(SaveFile,"\")>0 Then
		pic_name = Mid(SaveFile,inStrRev(SaveFile,"\") + 1)
	Else
		pic_name = SaveFile
	End if

	If inStrRev(SaveFile,".")>0 Then
		SaveFile = Left(SaveFile,inStrRev(SaveFile,".")-1) & "s" & Mid(SaveFile,inStrRev(SaveFile,"."))
	Else
		SaveFile = SaveFile
	End if

	pic_name1 = pic_name

	UploadPhotoUrl2 = Trim(Request("UploadPhotoUrl2"))
	UploadPhotoUrl = Trim(Request("UploadPhotoUrl"))
	
	Old_pic_name = pic_name
	If inStrRev(pic_name,".")>0 Then pic_name = Mid(pic_name,inStrRev(pic_name,".")+1)
	
	HeadStr = "\n[img]../images/fileType/"  & Replace(pic_name,".","") & ".gif[/img]"
	
	%>
	<script language=javascript>
	<!--
	<%
	Dim Temp
	Temp = 0
	If DEF_EnableGFL = 1 Then
		If DEF_EnableImagesUBB = 1 and inStr(":jpg:gif:jpeg:jpe:png:bmp:psd:tif:sgi:tga:iff:pcx:dcx:pbm:pgm:ppm:pnm:miff:xbm:xpm:ico:icl:emf:hru:jif:prc:wrl:wbmp:",pic_name) > 0 Then
			Temp = SaveSmallPic(LoadFile,SaveFile,570,5700)
			If Temp = 4 Then
				If inStrRev(UploadPhotoUrl2,".")>0 Then
					UploadPhotoUrl2 = Left(UploadPhotoUrl2,inStrRev(UploadPhotoUrl2,".")) & "jpg"
				Else
					UploadPhotoUrl2 = UploadPhotoUrl2 & "jpg"
				End if
			ElseIf Temp = 3 Then
				If inStrRev(UploadPhotoUrl2,".")>0 Then
					UploadPhotoUrl2 = Left(UploadPhotoUrl2,inStrRev(UploadPhotoUrl2,".")) & "gif"
				Else
					UploadPhotoUrl2 = UploadPhotoUrl2 & "gif"
				End if
			Else
				If Temp = 1 Then
					If inStrRev(UploadPhotoUrl2,".")>0 Then
						UploadPhotoUrl2 = Left(UploadPhotoUrl2,inStrRev(UploadPhotoUrl2,".")) & "jpg"
					Else
						UploadPhotoUrl2 = UploadPhotoUrl2 & "jpg"
					End if
				End If
			End If
			If Temp = 1 or Temp = 3 or Temp = 4 Then
				Response.Write "addcontent(""" & HeadStr & "此主题相关图片\n[url=" & htmlencode(UploadPhotoUrl) & "][img]" & htmlencode(UploadPhotoUrl2) & "[/img][/url]\n"");"
			Else
				If Temp = 2 Then
					Response.Write "addcontent(""" & HeadStr & "此主题相关图片\n[imga]" & htmlencode(UploadPhotoUrl) & "[/imga]\n"");"
				Else
					Response.Write "addcontent(""" & HeadStr & "此主题相关文件 [url=" & htmlencode(UploadPhotoUrl) & "]" & pic_name1 & "[/url]\n"");"
				End If
			End If
		ElseIf pic_name="swf" and DEF_EnableFlashUBB =  1 Then
			Response.Write "addcontent(""[flash]" & htmlencode(UploadPhotoUrl) & "[/flash]\n"");"
		ElseIf (pic_name="mp3" or pic_name="mid" or pic_name="asf" or pic_name="wma" or pic_name="wav") and DEF_EnableFlashUBB =  1 Then
			Response.Write "addcontent(""[mp=320,240]" & htmlencode(UploadPhotoUrl) & "[/mp]\n"");"
		ElseIf (pic_name="ra" or pic_name="ram" or pic_name="rm") and DEF_EnableFlashUBB =  1 Then
			Response.Write "addcontent(""[rm=320,240]" & htmlencode(UploadPhotoUrl) & "[/rm]\n"");"
		Else
			Response.Write "addcontent(""" & HeadStr & "此主题相关文件 [url=" & htmlencode(UploadPhotoUrl) & "]" & pic_name1 & "[/url]\n"");"
		End If
	Else
		If (pic_name = "gif" or pic_name = "jpg" or pic_name = "jpeg" or pic_name = "jpe" or pic_name = "bmp" or pic_name = "png") and DEF_EnableImagesUBB = 1 Then
			Response.Write "addcontent(""" & HeadStr & "此主题相关图片\n[imga]" & htmlencode(UploadPhotoUrl) & "[/imga]\n"");"
		ElseIf pic_name="swf" and DEF_EnableFlashUBB =  1 Then
			Response.Write "addcontent(""[flash]" & htmlencode(UploadPhotoUrl) & "[/flash]\n"");"
		ElseIf (pic_name="mp3" or pic_name="mid" or pic_name="asf" or pic_name="wma" or pic_name="wav") and DEF_EnableFlashUBB =  1 Then
			Response.Write "addcontent(""[mp=320,240]" & htmlencode(UploadPhotoUrl) & "[/mp]\n"");"
		ElseIf (pic_name="ra" or pic_name="ram" or pic_name="rm") and DEF_EnableFlashUBB =  1 Then
			Response.Write "addcontent(""[rm=320,240]" & htmlencode(UploadPhotoUrl) & "[/rm]\n"");"
		Else
			Response.Write "addcontent(""" & HeadStr & "此主题相关文件 [url=" & htmlencode(UploadPhotoUrl) & "]" & pic_name1 & "[/url]\n"");"
		End If
	End If
	
	movefiles LoadFile,LoadFileNoUnder
	If Temp = 1 or Temp = 3 Then
		CheckUploadDatabase UploadPhotoUrl,UploadPhotoUrl2
	Else
		CheckUploadDatabase UploadPhotoUrl,""
	End if%>

	//-->
	</script>
	<%

End Function
%>