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

	function addcontent(tmpstr,GBL_Width,GBL_Height)
	{
		parent.document.form1.Form_FaceUrl.value = tmpstr;
		parent.document.form1.Form_FaceWidth.value = GBL_Width;
		parent.document.form1.Form_FaceHeight.value = GBL_Height;
		parent.document.faceimg.src=tmpstr;
		parent.document.faceimg.width=GBL_Width;
		parent.document.faceimg.height=GBL_Height;
	}

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

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 "<img src=" & DEF_BBS_HomeUrl & "images/null.gif height=8 width=3><br>要<a href=uploadFile.aspx>重新上传请点这里</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]" & DEF_BBS_HomeUrl & "images/fileType/"  & Replace(pic_name,".","") & ".gif[/img]"
	
	%>
	<script language=javascript>
	<!--
	<%
	Dim temp
	If DEF_EnableGFL = 1 Then
		If 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,DEF_AllFaceMaxWidth,DEF_AllFaceMaxWidth)
			If Temp = 4 Then
				If inStrRev(UploadPhotoUrl2,".")>0 Then
					UploadPhotoUrl2 = Left(UploadPhotoUrl2,inStrRev(UploadPhotoUrl2,".")) & "jpg"
				Else
					UploadPhotoUrl2 = UploadPhotoUrl2 & "jpg"
				End if
				If inStrRev(SaveFile,".")>0 Then
					SaveFile = Left(SaveFile,inStrRev(SaveFile,".")) & "jpg"
				Else
					SaveFile = SaveFile & "jpg"
				End if
			ElseIf Temp = 3 Then
				If inStrRev(UploadPhotoUrl2,".")>0 Then
					UploadPhotoUrl2 = Left(UploadPhotoUrl2,inStrRev(UploadPhotoUrl2,".")) & "gif"
				Else
					UploadPhotoUrl2 = UploadPhotoUrl2 & "gif"
				End if
				If inStrRev(SaveFile,".")>0 Then
					SaveFile = Left(SaveFile,inStrRev(SaveFile,".")) & "gif"
				Else
					SaveFile = SaveFile & "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
					If inStrRev(SaveFile,".")>0 Then
						SaveFile = Left(SaveFile,inStrRev(SaveFile,".")) & "jpg"
					Else
						SaveFile = SaveFile & "jpg"
					End if
				End If
			End If
			If Temp = 1 or Temp = 3 or Temp = 4 Then
				If GBL_Width < 20 or GBL_Height < 20 Then
					Response.Write "alert(""图像宽度或高度太小或比例不相称,最小要求20像素!"");"
					deletefiles SaveFile
				Else
					CheckUploadDatabase SaveFile,""
					Response.Write "addcontent(""" & UploadPhotoUrl2 & """," & GBL_Width & "," & GBL_Height & ");"
					'movefiles LoadFile,LoadFileNoUnder
				End If
				deletefiles LoadFile
			Else
				If Temp = 2 Then
					If GBL_Width < 20 or GBL_Height < 20 Then
						Response.Write "alert(""图像宽度或高度太小或比例不相称,最小要求20像素!"");"
						deletefiles LoadFile
					Else
						movefiles LoadFile,LoadFileNoUnder
						CheckUploadDatabase LoadFileNoUnder,""
						Response.Write "addcontent(""" & UploadPhotoUrl & """," & GBL_Width & "," & GBL_Height & ");"
					End If
				Else
					Response.Write "alert(""非图像文件,上传错误!"");"
					deletefiles LoadFile
				End If
			End If
		Else
			Response.Write "alert(""非图像文件,上传错误!"");"
			deletefiles LoadFile
		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" Then
			movefiles LoadFile,LoadFileNoUnder
			CheckUploadDatabase LoadFileNoUnder,""
			Response.Write "addcontent(""" & UploadPhotoUrl & """," & DEF_AllFaceMaxWidth & "," & DEF_AllFaceMaxWidth & ");"
		Else
			Response.Write "alert(""非图像文件,上传错误!"");"
			deletefiles LoadFile
		End If
	End If
	%>

	//-->
	</script>
	<%

End Function
%>