<!--#Include File="ChkFileExt.asp"-->

<SCRIPT LANGUAGE="JavaScript">
<!--
function retProductPicSmall(str)
{	
//将产品图片返回给父文件

	if (!opener) return true;
	opener.document.HtmlEditForm.Ppic_.src = str;
	opener.document.HtmlEditForm.Ppic.value = str;
	self.close();
	return false;
}


function retProductPicBig(str)
{	
//将产品图片返回给父文件

	if (!opener) return true;
	opener.document.HtmlEditForm.PpicBig_.src = str;
	opener.document.HtmlEditForm.PpicBig.value = str;
	self.close();
	return false;
}

//-->
</SCRIPT>

<%


	sub CheckFileName( NeedCHKName )
		Letters = "+=:;,[]<>\|/*?"
		if len( NeedCHKName ) >20 then
			PrintMsg "文件或文件夹名太长，已经超过 20 个字符！"
		end if
		for i = 1 to len( NeedCHKName )
			c = mid( NeedCHKName,i,1 )
			if inStr( Letters,c )<>0 then
				PrintMsg "文件或文件夹名含有非法字符！"
			end if
		next
	end sub





	function IsValidVDir( str )
		Dim Letters,i,c,L
		Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_-/"
		L=len(str)
		for i=1 to L
			c = mid( str,i,1 )
			if inStr( Letters,c )=0 then
				IsValidVDir = false
				exit function
			end if
		next
		IsValidVDir = true
	end function




'打印HTML头及上传界面函数
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub interface()
	ServName = "http://" & Request.ServerVariables( "SERVER_NAME" )	'服务器地址
	'URL = "http://" & Cook_UserName & "." & HOST & VDir
	URL = "网站资源:/" & VDir
%>


<script language="JavaScript">
<!--
function submitchecken() {

	if (document.CreateNewFolder.CreateFolder.value == "") {
		alert("错误信息：请输入您要新建的文件夹名。");
		document.CreateNewFolder.CreateFolder.focus();
		return false;
	}

	return true;
}
function InputFileName(OldFileName) {
	var tishi = "重新命名文件 " + OldFileName + " ，请输入新的文件名："
	NewFileName = prompt(tishi,OldFileName);
	if(NewFileName!=null) {
		this.location = "?dir=<%=VDir%>&OldFileName=" + OldFileName + "&NewFileName=" + NewFileName;
	}
}
function InputFolderName(OldFolderName) {
	var tishi = "重新命名文件夹 " + OldFolderName + " ，请输入新的文件夹名："
	NewFolderName = prompt(tishi,OldFolderName);
	if(NewFolderName!=null) {
	this.location = "?dir=<%=VDir%>&OldFolderName=" + OldFolderName + "&NewFolderName=" + NewFolderName;
	}
}

function DelFolder( dir, folder ) {
	var isDelFolder = confirm("真的要删除文件夹 “" + folder + "” 吗？删除后无法恢复！");
	if( isDelFolder ) {
		this.location = "?dir=" + dir + "&DelFolder=" + folder;
	}
}

function DelFile( dir, file ) {
	var isDelFile = confirm("真的要删除文件 “" + file + "” 吗？删除后无法恢复！");
	if( isDelFile ) {
		this.location = "?dir=" + dir + "&DelFile=" + file;
	}
}

//////////////////////////////////////////////////////////////////////////////////////////

function SaveSizeToCookies( swfw, swfh, isOK ) {
	var expdate = new Date();

	if( !isOK ) {
		alert("可能是您的 LASH 文件出现问题，系统未能正确读出其宽度或高度，现在定义其宽高为默认值(100X100)。");
		swfw=100;
		swfh=100;
	}
	//set Xinger Cookies exist 5 minutes
	expdate.setTime(expdate.getTime()+(5*60*1000));

	SetCookie( "swfw", swfw, expdate, "/", null, false );	//save swf width
	SetCookie( "swfh", swfh, expdate, "/", null, false );	//save swf height
}

function SetCookie( name, value ) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (2<argc) ? argv[2] : null;
	var path = (3<argc) ? argv[3] : null;
	var domain = (4<argc) ? argv[4] : null;
	var secure = (5<argc) ? argv[5] : false;

	var CookStr = name + "=" + escape(value);
	CookStr += ((expires==null)?"":("; expires="+expires.toGMTString()));
	CookStr += ((path==null)?"":("; path="+path));
	CookStr += ((domain==null)?"":("; domain="+domain));
	CookStr += ((secure==true)?"; secure":"");
	document.cookie = CookStr;
}

//////////////////////////////////////////////////////////////////////////////////////////


function sub_up()
{
	if (UpForm.FileFrom.value != "")
	{
		saving.style.visibility = "visible";
		UpForm.submit();
	}else{
		alert("错误信息：请选择您要上传的文件。");
		document.UpForm.FileFrom.focus();
		return false;
	}
}

// -->
</script>


<table width="752" align="center" bgcolor="#FFFFFF">
  <tbody>
<form name="UpForm" method="post" enctype="multipart/form-data" action="upsave1.asp" onsubmit="return sub_up();">
  <tr>
    <td><b>当前目录</b> <input type="text" size="111" value="<%=URL%>" class=INPUT_Line style="width:80%">
    </td>
  </tr>
  <tr>
    <td><input type="hidden" name="filepath" size="95" style="color:#888888" value="<%=VDir%>" class=INPUT_Line>
        <input name="currdir" type="hidden" class=INPUT_Line id="currdir" style="color:#888888" value="<%=request.QueryString("dir")%>" size="95">
		 <input name="action" type="hidden" id="action" value="<%=request.QueryString("action")%>"> 
      </td>
  </tr>
  <tr>
    <td><b>文件来自</b> <input type="file" name="FileFrom" size="80" class=INPUT_Line style="width:80%">
	<input type="submit" name="Submit" value="上 传" style="background-color: buttonface"> 
    </td>
  </tr>

  <tr>
    <td height=30>

    </td>
  </tr>

</form>
</tbody>
</table>


<div id="saving" style="position:absolute; top:200; z-index:10; visibility:hidden" align=center>
<TABLE WIDTH=750 BORDER=0 CELLSPACING=0 CELLPADDING=0>
  <TR>
    <td width="30%"></td>
    <TD width="40%" bgcolor="<%=Trbgcolor(6)%>">
      <TABLE WIDTH=100% height=70 BORDER=0 CELLSPACING=1 CELLPADDING=0>
	<TR>
	  <td bgcolor="<%=Trbgcolor(1)%>" align=center>文件正在上传，请稍候...</td>
	</tr>
      </table>
    </td>
    <td width="30%"></td>
  </tr>
</table>
</div>

<%
end sub







'#############################################################################
'文件上传函数
'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub up()

	'Response.AddHeader "pragma","no-cache"
	dim uplaod
	dim isSuccess
	dim CurrError
	dim VformPath, VformPathTmp, FileFrom, FileExt

	isSuccess = true
	Set upload = Server.CreateObject("Xinger.Upload")
	upload.Maxsize = 1048576		'限制文件大小（单位是字节） 1MB
	upload.TempPath = Server.MapPath("/UPTemp/")	'用户设置临时文件夹
	upload.GetInfo				'获取表单数据信息


	'验证文件的合法性，用户可以在这里限制要上传的文件类型
	'------------------------------------------------------------
	FileFrom = upload.FileName("FileFrom")
	if FileFrom = "" then
		Set upload = Nothing
		PrintMsg "请选择您要上传的文件！"
	end if

	FileExt = upload.FileExt("FileFrom")	'获取文件扩展名
	if not ChkFileExt( FileExt ) then
		Set upload = Nothing
		PrintMsg "文件格式不正确，只允许上传扩展名为 """ & PermitedExt & """ 文件！"
	end if


	'处理要上传到服务器的目录
	'------------------------------------------------------------
	VformPath = upload.request("filepath")
	if inStr( VformPath, "../" ) <> 0 then
		Set upload = Nothing
		PrintMsg "上传路径非法！"
	end if
	VformPathTmp = VformPath
	if left( VformPath,1 ) <> "/" then
		VformPath = "/" & VformPath
	end if
	if right( VformPath,1 ) <> "/" then
		VformPath = VformPath & "/"
	end if
	'VformPath = "home/" & strUserName & VformPath
        VformPath = "home/" & strUserName & "/UpFile/"
        'VformPath = cookies_path & "/home/" & strUserName & "/UpFile/"
       
	if right( VformPath,1 )<>"/" then
		VformPath = VformPath & "UpFile/"
                'VformPath = VformPath & VDir
	end if
	'VformPath = Server.MapPath(VformPath)
	'VformPath = Server.MapPath(VformPath & "UpFile/")
	
	'设置上传到服务器的目录
	'------------------------------------------------------------
	upload.UpTo = Server.MapPath(VformPath)

	'开始上传
	'------------------------------------------------------------
	isSuccess = upload.Save("FileFrom",true)


	if not isSuccess then
		CurrError = upload.CurrError
		Set upload = Nothing
		PrintMsg CurrError
	end if


	'上传完毕，销毁对象
	'------------------------------------------------------------
	Set upload = Nothing

	response.redirect ThisPage & "?dir=" & VformPathTmp
end sub







	'处理向上
	'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	sub GoUpFolder()
		dim GetFolder, Arr, UpFolder

		GetFolder = VDir
		Arr = split(GetFolder,"/")
		n = Ubound( Arr )
		UpFolder = "/"
		for i=1 to n-2
			UpFolder = UpFolder & Arr(i) & "/"
		next


		response.write "<tr onmouseover=javascript:this.bgColor='#F9F9F9' onmouseout=javascript:this.bgColor='#FFFFFF' bgcolor=#FFFFFF height=22>" &_
			"<td width=30 align=left>" &_
			"<a href=""?dir=" & UpFolder & ActionDo

		response.write """><font color=#000000>▲</font></a>" &_
			"</td>" &_
			"<td width=1><a href=""?dir=" & UpFolder & ActionDo

		response.write """><IMG src=images/Ext/Folder.gif border=0></a>" &_
			"</td>" &_
			"<td width=220><a href=""?dir=" & UpFolder & ActionDo

		response.write """>向上...</a></td>" &_
			"<td width=80 align=left></td>" &_
			"<td width=160 align=left> </td>" &_
			"<td width=150> </td>" &_
			"<td width=40> </td>" &_
			"</tr>" &_
			"<tr><TD colspan=7 bgcolor=" & TrBgcolor(4) & " height=1></tD></tr>"
	end sub







	'防止最后一位是 "."，即 100<fsize<100(B/K/M/G) 时
	'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	sub fsizeLeft()
		if fsize>100 then
			fsize = left( fsize,5 )
		else
			fsize = left( fsize,4 )
		end if
	end sub





	'处理文件大小
	'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Sub Pfsize()
		if fsize>1000 then
			fsize = fsize/1024
			if fsize>1000 then
				fsize = fsize/1024
				if fsize>1000 then
					fsize = fsize/1024
					call fsizeLeft()  '防止最后一位是 "."，即 100<fsize<100 时
					fsize = fsize & "G"
				else
					fsizeLeft()
					fsize = fsize & "M"
				end if
			else
				fsizeLeft()
				fsize = fsize & "K"
			end if
		else
			fsize = left( fsize,4 ) & " Byte"
		end if
	End sub






	'打印文件夹列表
	'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Sub ShowFolderList(folderspec)
		Dim fs, f, f1, fc, s, ThisDir
		Set fs = CreateObject( Const_ScriptFileSystem )
		Set f = fs.GetFolder(folderspec)
		Set fc = f.SubFolders
		NumFolder=0
		On Error Resume Next
		For Each f1 in fc
			s = ""
			NumFolder=NumFolder+1
			fsize = f1.size
			TotalSize = TotalSize + fsize
			call Pfsize()
			ThisDir = VDir & f1.name
			response.write "<tr onmouseover=""javascript:this.bgColor='#F9F9F9';"" onmouseout=""javascript:this.bgColor='#FFFFFF';"" bgcolor=""#FFFFFF"">" &_
				"<td>" &_
				"<a href=""javascript:DelFolder('"& VDir & "','"& f1.name &"');"" " &_
				"title=""删除文件夹 " & f1.name & "，删除后无法恢复！"">" &_
				"<font color=#000000  face=""Webdings"">r</font>" &_
				"</a>" &_
				" <a href=""javascript:newfoldername='" & f1.name & "';InputFolderName(newfoldername);""" &_
				" title=""重命名文件夹 " & f1.name & """>" &_
				"<font color=#000080 face=""Webdings"">2</font>" &_
				"</a>" &_
				"</td>" &_
				"<td width=1>" &_
				"<a href=""?dir=" & ThisDir & ActionDo

			response.write """ title=""打开文件夹 " & f1.name & """>" &_
				"<IMG src=""images/Ext/folder.gif"" border=0>" &_
				"</a>" &_
				"</td>" &_
				"<td>" &_
				"<a href=""?dir=" & ThisDir & ActionDo

			response.write """ title=""打开文件夹 " & f1.name & """>" &_
				"<font color=#555555>" & isELetter(f1.name) & "</font></a>" &_
				"</td>" &_
				"<td><font color=#888888>" & isELetter(fsize) & "</font></td>" &_
				"<td><font color=#888888>文件夹</font></td>" &_
				"<td> </td>" &_
				"<td> </td>" &_
				"</tr>" &_
				"<tr><TD colspan=7 bgcolor=" & TrBgcolor(4) & " height=1></tD></tr>"
		Next

	End Sub







	'打印文件列表
	'- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Sub ShowFileList(folderspec)
		Dim fs, f, f1, fc, s , ThisFile , ThisExt

		Set fs = CreateObject( Const_ScriptFileSystem )
		Set f = fs.GetFolder(folderspec)
		Set fc = f.Files
		NumFile=0
		On Error Resume Next
		For Each f1 in fc
			s = ""
			NumFile = NumFile + 1
			ThisExt = fs.GetExtensionName(f1.name)	'获得文件的扩展名
			if ThisExt<>"" then
				ThisExt = Lcase(ThisExt)
			end if

			fsize = f1.size
			TotalSize = TotalSize + fsize
			call Pfsize()	'处理文件大小
			ThisFile = VNowFolder & f1.name
			ThisFileTmp = ThisFile

			response.write "<tr onmouseover=""javascript:this.bgColor='#F9F9F9';"" onmouseout=""javascript:this.bgColor='#FFFFFF';"" bgcolor=""#FFFFFF"">" &_
				"<td>" &_
				"<a href=""javascript:DelFile('" & VDir & "','" & f1.name & "');""" &_
				" title=""删除文件 " & f1.name & "，删除后无法恢复！"">" &_
				"<font color=""#000000"" face=""Webdings"">r</font></a> " &_
				"<a href=""javascript:newfilename='" & f1.name & "'; InputFileName(newfilename);""" &_
				" title=""重命名文件 " & f1.name & """>" &_
				"<font color=""#000080"" face=""Webdings"">2</font></a>" &_
				"</td>" &_
				"<td width=1>" &_
				"<img src=""images/Ext/" & ThisExt & ".gif"" border=""0"" " &_
				"onerror=""this.src='images/Ext/Unknown.gif';"">" &_
				"</td>"

			response.write "<td>" &_
				" <a href=""" & ThisFile & """ target=""_blank""" &_
				" title=""浏览文件 :: " & f1.name & """>" &_
				"<font color=""#555555"">" & isELetter(f1.name) & "</font></a>" &_
				"</td>" &_
				"<td>" &_
				"<font color=""#888888"">" & isELetter(fsize) & "</font></td>" &_
				"<td width=""170"" align=""left"">" &_
				"<font color=""#888888"">" & isELetter(f1.Type) & "</font></td>" &_
				"<td>" &_
				"<font color=""#888888"">" & isELetter(f1.DateLastModified) & "</font>" &_
				"</td>" &_
				"<td>"
			if request("action")="select" then
				if ThisExt = "swf" then
				    response.write "" &_
					"<a href=""javascript:"" " &_
					"onclick=""swfclick('" & ThisFile & "');return false;"">插入</a>"
				else
				    response.write "" &_
					"<a href=""javascript:"" " &_
					"onclick=""imgclick('" & ThisFile & "');return false;"">插入</a>"
				end if
			elseif action = "SelProductPicSmall" then
				response.write "<a href=""javascript:"" onclick=""return retProductPicSmall('" & ThisFile &_
					"');"">选我</a>"
			elseif action = "SelProductPicBig" then
				response.write "<a href=""javascript:"" onclick=""return retProductPicBig('" & ThisFile &_
					"');"">选我</a>"
			end if


'------------------------编辑
			if request("action")="editauto" then

				    

%><%if ThisExt="exe" or ThisExt="com" or ThisExt="mp3" or ThisExt="bmp" or ThisExt="swf" or ThisExt="jpg" or ThisExt="gif" or ThisExt="zip" or ThisExt="hlp" or ThisExt="cab" then%><%else%>
<INPUT type="button" 
				onmouseover="this.style.backgroundColor='#FF0000';" 
				onmouseout="this.style.backgroundColor='#5F8AC5';" 
				onclick="javascript:window.open('Admin_Editauto.asp?FileID=<%=f1.name%>&dir=<%=Vdir%>','','');" 
				value="编辑" 
				style="background-color:#5F8AC5; color:#FFFFFF; cursor:hand; height:30;"
			>




   
<%end if%>
<%
			
			end if
'--------------------------------------------------
			response.write "</td>" &_
				"</tr>" &_
				"<tr><TD colspan=7 bgcolor=" & TrBgcolor(4) & " height=1></tD></tr>"
			on error resume next
		Next
	End Sub









Sub CopyRight()
%>

版权所有 2001-2002 <a href="http://www.jndiy.com" target="_blank">企业自助站</a> | 作者：九天 写于 2002年3月 | 本程序永远免费提供给个人使用

<%
end sub



function GetSwfSize( iPath )
	dim qswh
	dim Ext
	dim arr
	dim GetSwfSizeValue

	iPath = Lcase(iPath)
	GetSwfSize = ""
	GetSwfSizeValue = "100,100,false"
	set qswh=new qswhImg

		if len(iPath) > 4 then
			iPath = Server.MapPath( iPath )
			Ext = right(iPath,4)
			if Lcase(Ext) = ".swf" then
				arr = qswh.getImageSize( iPath )
				if arr(1)<>"" and arr(2)<>"" then	'width=arr(1), height=arr(2)
					GetSwfSizeValue = cstr( arr(1) & "," & arr(2) & ",true" )
				end if
			end if
		end if

	Set qswh=nothing

	GetSwfSize = GetSwfSizeValue
end function
%>