<!--#include file="conn.asp"-->
<!--#include file="nosql.asp"-->
<!--#include file="config.asp"-->
<!--#include file="md5.asp"-->
<!-- #include File="upfile.asp" -->
<%if session("user")="" or session("id")="" then%>
<script language="javascript">
 window.alert("警告：非法操作！");
 window.close();
</script>
<%response.end
end if%>
	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
	<title>文件上传</title>
	<link href="/css.css" rel="stylesheet" type="text/css" />
	<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #efefef;
}
-->
</style></head>
	<body>

<%
dim freesize,onesize,maxsize,enupload,upfiletype,formName1,EditName1,infoname1



	enupload=up2
	upfiletype=1
	onesize=up12 '上传文件最大
	maxsize=3000

if enupload=999 then
	response.Write("当前系统设置不允许上传文件")
	response.End()
end if
freesize=int(maxsize-1/1024)
if freesize<=0 then
	response.Write("<ul style='margin:0px;text-align: left;width:100%;'> 上传空间已满，不允许上传文件,请整理上传文档</ul></body></html>")
	response.End()
end if
t=Request("t")
form_Name=Request("form_Name")			'回传到上页面编辑框所在Form的Name
Edit_Name=Request("Edit_Name")			'回传到上页面编辑框的Name
info_name=Request("info_name")				'回传到上页面编辑框的Name
If Request("t")="1" Then
	Upfile_Main()
Else
	Main()
End If

Sub Main()
	Dim PostRanNum
	Randomize
	PostRanNum = Int(900*rnd)+1000
	Session("UploadCode") = Cstr(PostRanNum)
%><br><br>
	<ul style="margin:0px;text-align: left;width:100%;"> 
      <form name="myform" method="post" action="upload.asp?t=1&Edit_Name=<%=Request("EditName")%>&form_Name=<%=Request("formName")%>&info_name=<%=Request("infoname")%>" enctype="multipart/form-data">
	    <div align="center">
	  <INPUT TYPE="hidden" NAME="UploadCode" value="<%=PostRanNum%>">
	  <input type="hidden" name="act" value="upload">
	  <input type="hidden" name="Edit_Name" value="<%=Request("EditName")%>">
      <input type="hidden" name="form_Name" value="<%=Request("formName")%>">
	  <input type="hidden" name="info_name" value="<%=Request("infoname")%>">
&nbsp;上传文件：
  <input type="file" name="uploadfile">
	  <input type="hidden" name="fname">
	  <input type="submit" name="Ok" value="上传" >
	  <br><br>
	&nbsp;单个文件最大上传限制：<%=onesize%>KB 
        </div>
      </form>
	</ul>
</body>
</html>
<%
End Sub

Sub Upfile_Main()
%>
<ul style="margin:0px;text-align: left;width:100%;"> 
<%
UploadFile
%>
</ul>
</body>
</html>
<%
End Sub

Sub UploadFile()

	Server.ScriptTimeOut=9999999
'	'-----------------------------------------------------------------------------
	Dim Upload,FilePath,FormName,File,F_FileName,F_Viewname
	dim DrawInfo
	upfiletype=replace(""&up1&"","|",",")
	if freesize<=onesize then onesize=freesize
	if onesize<0 then onesize=0 
if info_Name="home" then
FilePath=uppic3
 sql="select * from snsn_user where username='"&session("user")&"' and id="&session("id")&""
 Set rs= Server.CreateObject("ADODB.Recordset") 
 rs.open sql,conn,1,1
 if rs.eof or rs.bof then
  response.write "<script language=javascript>alert('没有此用户,请确认后或联系管理员再访问本页！');window.close();window.opener.location.reload();</script>"
  response.end
 else
  if rs("h_photo")=0 then
  conn.execute("update [snsn_user] set jifen=jifen+80 where id="&session("id")&"")
  conn.execute("update [snsn_user] set h_photo=1 where id="&session("id")&"")
  end if
  session("jifen")=rs("jifen")
 end if
elseif info_Name="love" then
FilePath=uppic4
elseif info_Name="music" then
FilePath=uppic1
else
FilePath=uppic2
end if
		DrawInfo = up13
	If DrawInfo = "0" Then
		DrawInfo = ""
	End If
	Set Upload = New UpFile_Cls
		Upload.UploadType			= enupload			'设置上传组件类型（0=无组件上传类，1=Aspupload3.0 ,2=SA-FileUp 4.0 ,3=DvFile.Upload V1.0）
		Upload.UploadPath			= FilePath								'设置上传路径
		Upload.MaxSize				= Int(onesize)							'单位 KB
		Upload.InceptMaxFile		= 1										'每次上传文件个数上限
		Upload.InceptFileType		= upfiletype							'设置上传文件限制
		Upload.RName				= ""
		Upload.ChkSessionName		= "UploadCode"
		
		Upload.PreviewType			= up3		'设置预览图片组件类型 组件(0=CreatePreviewImage组件，1=AspJpegV1.2 ,2=SoftArtisans ImgWriter V1.21)
		Upload.PreviewImageWidth	= up10										'设置预览图片宽度
		Upload.PreviewImageHeight	= up11										'设置预览图片高度
		Upload.DrawImageWidth		= up6					'设置水印图片或文字区域宽度
		Upload.DrawImageHeight		= up7					'设置水印图片或文字区域高度
		Upload.DrawGraph			= up16					'设置水印透明度 如60%请填写0.6
		Upload.DrawFontColor		= up14					'设置水印文字颜色
		Upload.DrawFontFamily		= up15					'设置水印文字字体格式
		Upload.DrawFontSize			= up4						'设置水印文字字体大小
		Upload.DrawFontBold			= up5						'设置水印文字是否粗体 0否1粗
		Upload.DrawInfo				= DrawInfo								'设置水印文字信息或图片信息
		Upload.DrawType				= up3						'0=不加载水印 ，1=加载水印文字，2=加载水印图片
		Upload.DrawXYType			= up8					'"0" =左上，"1"=左下,"2"=居中,"3"=右上,"4"=右下
		Upload.DrawSizeType			= up9										'"0"=固定缩小，"1"=等比例缩小
		Upload.TransitionColor	    = up17			'透明度颜色设置 保留为空则水印图片不去除底色

		'执行上传
		Upload.SaveUpFile
		If Upload.ErrCodes<>0 Then
			Response.write "错误："& Upload.Description & "[ <a href='upload.asp?infoname="&info_name&"&EditName="&Edit_Name&"&FormName="&Form_Name&"'>重新上传</a> ]"
			Exit Sub
		End If



		If Upload.Count > 0 Then
			For Each FormName In Upload.UploadFiles
				Set File = Upload.UploadFiles(FormName)
				F_FileName = FilePath & File.FileName
				'创建预览及水印图片
				If Upload.PreviewType<>999 and File.FileType=1 then
						F_Viewname =  FilePath&"pre" & Replace(File.FileName,File.FileExt,"") & "jpg"
						'创建预览图片:Call CreateView(原始文件的路径,预览文件名及路径,原文件后缀)
						Upload.CreateView F_FileName,F_Viewname,File.FileExt
				End If
			
					if instr("jpg,gif,bmp,pcx,png,psd",File.FileExt)=0 then isphoto=0
					
				    if Edit_Name="" then
					    Response.Write "文件："& F_FileName &"上传成功! [ <a href=upload.asp?EditName="&Edit_Name&"&FormName="&Form_Name&"&infoName="&info_Name&">再次上传</a> ]"
				    else
					 response.write "<script>window.opener.document."&Form_Name&"."&Edit_Name&".value='"&F_FileName&"'</script>"%>
			         <script language="javascript">
				     window.alert("文件上传成功!请不要修改生成的链接地址！");
				     window.close();
			         </script>
			         <%end if
				Set File = Nothing
			Next
		Else
			Response.write "请正确选择要上传的文件。[ <a href='upload.asp?infoname="&info_name&"&EditName="&Edit_Name&"&FormName="&Form_Name&"'>重新上传</a> ]"
			Exit Sub
		End If
	Set Upload = Nothing
End Sub
%>