<!-- #Include File="../Include/Skin.asp" -->
<%
'=======================================================
' 欢迎使用《阿赛大型门户网站系统V3.0》，简称“AsaiMHV3”
' 技术支持、商业版咨询、官方唯一指定联系QQ“4941172”
' 官方网站：http://77ya.com      程序负责人：阿赛
'=======================================================

Dim ID
ID=trim(request.querystring("ID"))
ID=Decrypt(ID)
If not(isnumeric(ID)) Then ID=0
Call Upload_Imgaes()
Response.End

Function Decrypt(Thenumber)
	On Error Resume Next
	Dim e, n, sign, t, HiN, LoN, NewN, i
	e = Thenumber
	If Left(e, 1) = "R" Then sign = -1 Else sign = 1
	e = MID(e, 2)
	NewN = ""
	For i = 1 To Len(e) step 2
	t = MID(e, i, 2)
	If Asc(t) >= Asc("0") And Asc(t) <= Asc("9") Then
		NewN = NewN & t
		Exit For
	End If
	HiN = MID(t, 1, 1)
	LoN = MID(t, 2, 1)
	HiN = (Asc(HiN) - Asc("M")) * 16
	LoN = Asc(LoN) - Asc("C")
	t = CStr(HiN Or LoN)
	If Len(t) = 1 Then t = "0" & t
		NewN = NewN & t
	Next
	e = CDbl(NewN) * sign
	Decrypt = CLng((7 + sqr(49 - 4 * (-450 - e))) / 2 - 1570)
End Function

Sub Upload_Imgaes()
	Dim Serv_Url,SeID,Stream,Filetype,TrueFileName,Url
	SeID=trim(Cls.Cookies_Get("WebResources"))
	Serv_Url = Cstr(Request.ServerVariables("SERVER_NAME"))
	If int(Format_Mid_Num(46)) <> 0 Then
		If SeID <> ""&Web_Resources&"" Then					'Cookies防盗
			Response.Clear
			Response.Redirect ""&Cls.Web_Dir&"Images/No_Rob.jpg"
			Exit Sub
		End If
		If int(Format_Mid_Num(48)) = 1 Then
			If mid(Cls.WebBrowseUrl,8,len(Serv_Url)) <> Serv_Url Then	'外部链接防盗
				Response.Clear
				Response.Redirect ""&Cls.Web_Dir&"Images/No_Rob.jpg"
				Exit Sub
			End If
		End If
	End If
	sql="Select top 1 UpFileUrl from AsaiMHUpload Where ID="&ID
	Set Rs=Cls.Exec(SQL,1)
	If rs.eof Then
		rs.close
		Exit Sub
	End If
	Url=rs(0)								'获取文件地址
	Url=Replace(Replace(Url,"{$upload_dir}",""),"{$download_dir}","")	'转换文件地址去除相关内容
	rs.close
	Response.Buffer = True
	Response.Clear
	Filetype=LCase(Right(Url,3))	'检查文件类型
	Filetype=Replace(Filetype,".","")
	Select Case Filetype
	Case "gIf"
		Response.ContentType = "image/gIf"
	Case "jpg" , "jpeg"
		Response.ContentType = "image/jpeg"
	Case "bmp"
		Response.ContentType = "image/bmp"
	Case "png"
		Response.ContentType = "image/png"
	Case "swf" , "flv"
		Response.ContentType = "application/x-shockwave-flash" 
	Case "rm" , "rmvb" 
		Response.ContentType = "application/vnd.rn-realmedia" 
	Case "mp2" , "mpga"
		Response.ContentType = "audio/mpeg"
	Case "mp3" 
		Response.ContentType = "audio/mp3"
	Case "wma" 
		Response.ContentType = "audio/x-ms-wma" 
	Case "wmv" 
		Response.ContentType = "video/x-ms-wmv" 
	Case "smi" , "smil"
		Response.ContentType = "application/smil" 
	Case "xls" 
		Response.ContentType = "application/vnd.ms-excel" 
	Case "ppt" 
		Response.ContentType = "application/vnd.ms-powerpoint" 
	Case "mid" , "kar" , "midi"
		Response.ContentType = "audio/midi"
	Case "ASP", "ASA", "ASPX", "ASAX", "MDB"
		Exit Sub
	Case else
		Response.ContentType = "application/ms-download"
	End Select
	Response.AddHeader "content-disposition", "inline; FileName="&"AsaiMHUpFlie_"&Cls.Rand_File(9)&"."&Filetype	'生成随机文件名
	Set Stream = server.CreateObject("ADODB.Stream")
	Stream.Type = 1
	Stream.Open
	TrueFileName = Cls.Web_Dir&Cls.Web_Upload&Url					'载入文件
	Stream.LoadFromFile Server.MapPath(TrueFileName)
	While Not Stream.EOS
	Response.BinaryWrite Stream.Read(1024 * 64)
	WEnd
	Stream.Close
	Set Stream = Nothing
	Response.Flush
End Sub
%>
