<!--#include file="../conn.asp"-->
<!--#include file="../inc/function.asp"-->
<!--#include file="../inc/config.asp"-->
<!--#include file="../../include/Lebi_config.asp"-->
<!-- #include File="class_upfile.asp" -->
<html>
<head>
<style>
body{margin:0;padding:0;font-size:12px;}
td{font-size:12px;}
a:link {font-size: 12px;font-family: 宋体;color: #646245;text-decoration: none;}
a:visited {font-size: 12px;font-family: 宋体;color: #646245;text-decoration: none;}
a:hover {font-size: 12px;font-family: 宋体;color: #ff6600;text-decoration: underline;}
a:active {font-size: 12px;font-family: 宋体;color: #646245;text-decoration: none; }
.form {
	BORDER-BOTTOM: #a7a6aa 1px solid; BORDER-LEFT: #a7a6aa 1px solid; PADDING-BOTTOM: 2px; PADDING-LEFT: 2px; PADDING-RIGHT: 0px; BACKGROUND: url(../images/input-bg.png) white no-repeat 0px 0px; COLOR: #333; BORDER-TOP: #a7a6aa 1px solid; BORDER-RIGHT: #a7a6aa 1px solid; PADDING-TOP: 2px
}
.button {
	COLOR: #756A4F; BORDER: 1px #CAC5BB solid; BACKGROUND: url(../images/btn_bg.gif); HEIGHT:22px; FONT-SIZE: 12px; CURSOR:pointer
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/swfobject.js"></script>
</head>
<BODY>
<%
'*****************************************
'* 软件名称 乐彼网上开店软件(56770 EShop)
'* 软件开发 http://www.56770.com
'* 版权所有 http://www.56770.com
'* 文件名称 upload.asp
'* 最后更新 2012-01-31 by 56770.kingdge
'*****************************************
response.charset="UTF-8"
session.codepage="65001"
u_type = checknum(request("u_type"),0)
filename = safereplace(request("filename"))
If filename = "" Then filename = "pic"
include "../lang/"& LangFilePath &"/lang_sys.inc"
include "../lang/"& LangFilePath &"/lang_product.inc"
if request.cookies(cookiesname)("admin_name")="" then
		response.write "<table width=100% border=0 cellspacing=1 cellpadding=2><tr><td height=20>"& Lang_sys(78) &"</td></tr></table>"
Else
        Select Case request("action")
               Case "ok" : Upfile_Main()
               Case else
	       main()
        End Select
End if
Sub Main()
	Dim PostRanNum
	Randomize
	PostRanNum = Int(900*rnd)+1000
	Session("UploadCode") = Cstr(PostRanNum)
%>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr><td height="25">
	   <%If u_type = 0 Then%>
         <form name="form" method="post" action="Upload.asp?action=ok" enctype="multipart/form-data">
		<INPUT TYPE="hidden" NAME="u_type" value="<%=u_type%>">
		<INPUT TYPE="hidden" NAME="filename" value="<%=filename%>">
	   <INPUT TYPE="hidden" NAME="UploadCode" value="<%=PostRanNum%>">
	   <input type="file" name="uploadfile" size="10" class="form">
	   <input type="submit" name="Ok" value="<%=Lang_sys(52)%>" class="button">
	   <%If filename = "pic" Then%>
	   <input type="checkbox" value="1" name="Ifbigpic"><%=Lang_Product(78)%>
	   <%End If%>
	</form>
	   <%Else%>
		<div id="sapload"></div>
		<script type="text/javascript">
		var so = new SWFObject("sapload.swf", "sapload", "280", "54", "9", "#ffffff");
		so.addVariable('types','jpg;gif;jpeg;png;swf');
		so.addVariable('args','action=ok;UploadCode=<%=PostRanNum%>');
		so.addVariable('upUrl','upload_b.asp');
		so.addVariable('fileName','uploadfile');
		so.addVariable('maxNum','10');
		so.addVariable('maxSize','5000'); //单位KB
		so.addVariable('etmsg','1');
		so.addVariable('ltmsg','1');
		so.write("sapload");           
		function sapLoadMsg(t){
		if(t.indexOf('@')<0) 
		{ 
			alert(t); 
			return false; 
		}else{
			parent.document.getElementById('cpic').value+=t;
		}
		}
		</script> 
	   <%End If%>
	 </td></tr>
       </table>
</body>
</html>
<%
End Sub

Sub Upfile_Main()
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td height="25">
<%
'Set Upload_56770 = New UpFile_Cls
'response.write
UploadFile()
%>
</td></tr>
</table>
</body>
</html>
<%
End Sub

Sub UploadFile()
	Server.ScriptTimeOut=9999999
'	'-----------------------------------------------------------------------------
	Dim Upload,FilePath,FormName,File,F_FileName,F_Viewname
	dim DrawInfo
	yy=year(Date()):mm=month(Date())
        if len(mm)=1 then mm="0"&mm
        folder_date=yy&mm
	upfiletype="gif,jpg,jpeg,png,swf"
	onesize="2048000" '200KB
	FilePath = "../../"& PicPath &"/"
	FilePath=CreatePath(FilePath)
	rem 读取水印内容
	If Upload_isDraw = "1" Then
		DrawInfo = Upload_Drawtext
	ElseIf Upload_isDraw = "2" Then
		DrawInfo = "../.."& Upload_Drawpic
	Else
		DrawInfo = ""
	End If
	If DrawInfo = "0" Then
		DrawInfo = ""
	End If
	Set Upload_lebi = New UpFile_Cls
		Upload_Lebi.UploadType		= Upload_type			'设置上传组件类型
		Upload_Lebi.UploadPath		= FilePath								'设置上传路径
		Upload_Lebi.MaxSize			= Int(onesize)							'单位 KB
		Upload_Lebi.InceptMaxFile		= 1										'每次上传文件个数上限
		Upload_Lebi.InceptFileType		= upfiletype							'设置上传文件限制
		Upload_Lebi.RName			= Upload_RName                                                          '文件名前缀
		Upload_Lebi.UploadSaveType		= Upload_SaveType
		Upload_Lebi.ChkSessionName		= "UploadCode"
		if clng(Upload_isDraw)=1 or clng(Upload_isDraw)=2 or clng(Upload_isDraw)=3 then
			Upload_Lebi.PreviewType			= 1								'设置预览图片组件类型
		else
			Upload_Lebi.PreviewType			= 999
		end if
		Upload_Lebi.PreviewImageWidth	= Upload_SPicWidth										'设置预览图片宽度
		Upload_Lebi.PreviewImageHeight	= Upload_SPicHeight										'设置预览图片高度
		Upload_Lebi.DrawImageWidth		= Upload_DrawWidth						'设置水印图片或文字区域宽度
		Upload_Lebi.DrawImageHeight		= Upload_DrawHight						'设置水印图片或文字区域高度
		Upload_Lebi.DrawGraph		= Upload_DrawGraph						'设置水印透明度
		Upload_Lebi.DrawFontColor		= Upload_Drawcolor						'设置水印文字颜色
		Upload_Lebi.DrawFontFamily		= Upload_Drawfont						'设置水印文字字体格式
		Upload_Lebi.DrawFontSize		= Upload_Drawfontsize						'设置水印文字字体大小
		Upload_Lebi.DrawFontBold		= Upload_DrawFontBold						'设置水印文字是否粗体
		Upload_Lebi.DrawInfo			= DrawInfo					'设置水印文字信息或图片信息
		Upload_Lebi.DrawType			= Upload_isDraw						'0=不加载水印 ，1=加载水印文字，2=加载水印图片
		Upload_Lebi.DrawXYType		= Upload_DrawXYType						'"0" =左上，"1"=左下,"2"=居中,"3"=右上,"4"=右下
		Upload_Lebi.DrawSizeType		= 1						'"0"=固定缩小，"1"=等比例缩小
		If Upload_Drawpiccolor<>"" or Upload_Drawpiccolor<>"0" Then
			Upload_Lebi.TransitionColor	= Upload_Drawpiccolor			'透明度颜色设置
		End If
		'执行上传
		Upload_Lebi.SaveUpFile
		If Upload_Lebi.ErrCodes<>0 Then
			Write_Lebi_Eshop("ERROR："& Upload_Lebi.Description & "[ <a href='Upload.asp?u_type="&u_type&"&filename="& Upload_Lebi.UploadForms("filename") &"'>"& Lang_sys(79) &"</a> ]")
			Exit Sub
		End If
		If Upload_Lebi.Count > 0 Then
			For Each FormName In Upload_Lebi.UploadFiles
				Set File = Upload_Lebi.UploadFiles(FormName)
				F_FileName = FilePath & File.FileName
				If Upload_Dir = "1" Then folder_date = "product"
				'创建预览及水印图片
				If Upload_Lebi.PreviewType<>999 And File.FileType=1 Then 
				        If Upload_Lebi.UploadForms("Ifbigpic") = "1" Then 
								F_Viewname =  "../../"& PicPath &"/"& folder_date &"/s_" & Replace(File.FileName,File.FileExt,"") & File.FileExt
						ElseIf Upload_Lebi.UploadForms("filename") <> "pic" Then 
								F_Viewname = "0"
						Else 
								F_Viewname = "0"
								Upload_Lebi.DrawType = 0
						End If
						'创建预览图片:Call CreateView(原始文件的路径,预览文件名及路径,原文件后缀)
						Upload_Lebi.CreateView F_FileName,F_Viewname,File.FileExt
				End If
				If U_type = 0 then
				    If Upload_isDraw = 0 Then
					        Write_Lebi_Eshop("<script>parent.document.getElementById('"& Upload_Lebi.UploadForms("filename") &"').value='"&folder_date&"/"&file.filename&"'</script>")
					Else
					        If Upload_Lebi.UploadForms("Ifbigpic") = "1" And CDbl(File.Filewidth) > CDbl(Upload_SPicWidth) And CDbl(File.Fileheight) > CDbl(Upload_SPicHeight) Then Issmllpic_left = "s_"
						    Write_Lebi_Eshop("<script>parent.document.getElementById('"& Upload_Lebi.UploadForms("filename") &"').value='"&folder_date&"/"& Issmllpic_left & file.filename&"'</script>")
					End If
'					str_showpicsize=showpicsize(File.Filewidth,File.Fileheight,Upload_SPicWidth,Upload_SPicHeight)
'					Write_Lebi_Eshop("<script>parent.document.getElementById('Pic_size').value='"&str_showpicsize&"'</script>")
				End If
				If Upload_Lebi.UploadForms("Ifbigpic") = "1" Or U_type = 1 Then
				        Write_Lebi_Eshop("<script>parent.document.getElementById('cpic').value+='@@"&folder_date&"/"&file.filename&"'</script>")
				End If
				Write_Lebi_Eshop(Lang_sys(81) &"[ <a href='Upload.asp?u_type="&u_type&"&filename="& Upload_Lebi.UploadForms("filename") &"'>"& Lang_sys(82) &"</a> ]")
				Set File = Nothing
			Next
		Else
			Write_Lebi_Eshop(Lang_sys(80) &"[ <a href='Upload.asp?u_type="&u_type&"&filename="& Upload_Lebi.UploadForms("filename") &"'>"& Lang_sys(79) &"</a> ]")
			Exit Sub
		End If
	Set Upload_56770 = Nothing
End Sub
'检查上传目录，若无目录则自动建立
Function CreatePath(PathValue)
	Dim objFSO,Fsofolder,uploadpath
	Select Case Upload_Dir 
	Case "0" 
		yy=year(Date()):mm=month(Date())
        if len(mm)=1 then mm="0"&mm
		uploadpath = yy&mm
	Case "1"
		uploadpath = "product"
	End Select 
	If Right(PathValue,1)<>"/" Then PathValue = PathValue&"/"
	On Error Resume Next
	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
		If objFSO.FolderExists(Server.MapPath(PathValue & uploadpath))=False Then
			objFSO.CreateFolder Server.MapPath(PathValue & uploadpath)
		End If
		If Err.Number = 0 Then
			CreatePath = PathValue & uploadpath & "/"
		End If
	Set objFSO = Nothing
End Function
Sub Write_Lebi_Eshop(value)
	Response.Write(value)
End Sub
Function Delfile(str)
        on error resume next
		Dim ObjFSO
		Set ObjFSO = Server.CreateObject("Scripting.FileSystemObject")
		ObjFSO.DeleteFile(Server.MapPath("../"& PicPath &""& str &""))
		If Err.Number<>"0" Then
					Write_Lebi_Eshop(Err.Description)
		Else
					Write_Lebi_Eshop(Lang_Product(79))
		End If
		Set ObjFSO = Nothing
End Function
%>