<!--#include file="conn.asp" -->
<% adm_power_page="7" %>
<!--#include file="admin_dn.asp" -->
<!--#include file="../inc/hostconfig.asp" -->
<% 

 OpenFileName=seuv_filepath
 FtpName=Trim(Request("FtpName"))
 Function sdat(ftp_Expire)
  num=ftp_Expire-1064937600
  if num<0 then 
   sdat=""
  else
  num=num/86400
  sdat=cdate("2003-10-1")+num
  end if
  end function
  
 Function Ftp_Data(FtpUser_name)
    dim fso,file,temp,FunUser_1,FunUser_2
	FunUser_1=false
	FunUser_2=false
  Set fso =server.CreateObject("Scripting.FileSystemObject")
  Set File = fso.OpenTextFile(OpenFileName,1)
   do until file.Atendofstream
    Temp=trim(File.readline)
	if FunUser_1 and mid(temp,1,6)="[USER=" then
	 FunUser_1=false
	end if
		
	if Temp="[USER="&FtpUser_name&"|"&ftp_id&"]" then
	 FunUser_1=true
	end if
	
	if FunUser_1 and mid(temp,1,6)<>"[USER=" then 
	   	 Ftp_Data=Ftp_Data&Temp&"#"
	end if
   loop
  set File=nothing
  set fso=nothing
  End Function
 
  function Expire1(ftp_Expire_1)
   'ftp_Expire_1
   da=cdate(ftp_Expire_1)-cdate("2003-10-1")
   Response.Write(da)
   Expire1=da*86400+1064937600
  end function
 
 Set fso =server.CreateObject("Scripting.FileSystemObject")
 Set File = fso.OpenTextFile(OpenFileName,1)
  temp=file.readall
  if instr(temp,"[USER="&FtpName&"|"&ftp_id&"]")=0 then
   Response.Write("对不起ftp:"&FtpName&"不存在")
   response.end
  end if
 set file=nothing
 
 '更新内容
  if Trim(Request.QueryString("w"))="edit" then
   ftp_password=Trim(Request.Form("ftp_password"))
   ftp_HomeDir=Trim(Request.Form("ftp_HomeDir"))
   ftp_Expire=Trim(Request.Form("ftp_Expire"))
   ftp_DiskQuota=Trim(Request.Form("ftp_DiskQuota"))
   if ftp_password="" or ftp_HomeDir="" or ftp_Expire="" or ftp_DiskQuota="" then
   Response.Write ("<script>alert('带*的为必填项');javascript:history.back(1)</script>")
   response.end
   end if
   if ftp_Expire<>"0" then
    ftp_Expire=Expire1(ftp_Expire)
   end if
   Set File = fso.OpenTextFile(OpenFileName,1)
   Temp_serv_ini=""
   Temp_domain_user=false
   do until file.Atendofstream
    TempFile=trim(file.readline)
  if TempFile<>"" then 
	file_edit=true
	 if TempFile="[Domain"&ftp_id&"]" then
	  Temp_domain_user=true
	  Temp_domain_date=false
	 end if
	 if temp_domain_user and mid(TempFile,1,4)="User" then 
	   if split(split(TempFile,"=")(1),"|")(0)=FtpName then
	    Temp_serv_ini=Temp_serv_ini&split(TempFile,"=")(0)&"="&FtpName&"|"&ftp_id&"|"&ftp_Expire &vbCrLf
		file_edit=false
	   end if
	   
	   end if
	 if mid(TempFile,1,5)="[USER" then
	 Temp_domain_user=false
	 end if
	 if Temp_domain_date then
	   if mid(TempFile,1,5)<>"[USER" then
	    temp_ftp_date=TempFile	
		select case  split(temp_ftp_date,"=")(0)
		  case "Password"
		   TempFile="Password="&ftp_password
		  case "HomeDir"
		   TempFile="HomeDir="&ftp_HomeDir
		  case "Expire"
		   TempFile="Expire="&ftp_Expire
		  case "Access1"
		   TempFile="Access1="&ftp_HomeDir&"|"&split(split(temp_ftp_date,"=")(1),"|")(1)
		  case "DiskQuota"
		   TempFile="DiskQuota="&split(split(temp_ftp_date,"=")(1),"|")(0)&"|"&ftp_DiskQuota&"|"&split(split(temp_ftp_date,"=")(1),"|")(2)
		  case else
		   TempFile=temp_ftp_date
		  end select  
		 else
		Temp_domain_date=false
	   end if
	 end if 
	  if TempFile="[USER="&FtpName&"|"&ftp_id&"]" then
	  Temp_domain_date=true
	  end if
	 if file_edit then
	 Temp_serv_ini=Temp_serv_ini&TempFile&vbCrLf
	 end if
  end if
 loop  
   Temp_serv_ini = Replace(temp_serv_ini  , "[GLOBAL]" , "[GLOBAL]" & vbCrLf & "ReloadSettings=1") '强制刷新代码
   set file=nothing
  application lock
  set myfile=fso.opentextfile(OpenFileName,2,true)
     myfile.writeline Temp_serv_ini
  application unlock
  end if
     Ftp_Detailed=Ftp_Data(FtpName)
	 Ftp_Detailed=split(Ftp_Detailed,"#")
	 for i= 0 to ubound(Ftp_Detailed)-1
	 if Ftp_Detailed(i)<>"" then
	  if split(Ftp_Detailed(i),"=")(0)="Password" then ftp_password=split(Ftp_Detailed(i),"=")(1)
	  if split(Ftp_Detailed(i),"=")(0)="HomeDir" then ftp_HomeDir=split(Ftp_Detailed(i),"=")(1)
	  if split(Ftp_Detailed(i),"=")(0)="DiskQuota" then ftp_DiskQuota=split(Ftp_Detailed(i),"=")(1)
	  if split(Ftp_Detailed(i),"=")(0)="Expire" then ftp_Expire=split(Ftp_Detailed(i),"=")(1)
	  if ftp_DiskQuota="" then ftp_DiskQuota=0
	 end if
    next
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>:::管理页面:::</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>

<body leftmargin="4" topmargin="4">
<p>FTP维护</p>
<p>&nbsp;</p>
<form name="form1" method="post" action="edit_ftp.asp?w=edit">
  <table width="491" height="172" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" bordercolorlight="" bordercolordark="ffffff">
    <tr bgcolor="#F7F7F7"> 
      <td height="26" colspan="2">FTP在线维护</td>
    </tr>
    <tr> 
      <td width="95" height="20">FTP用户名:</td>
      <td width="386"><% =FtpName %>
        &nbsp;
        <input name="FtpName" type="hidden" id="FtpName" value="<%=FtpName%>"></td>
    </tr>
    <tr> 
      <td>FTP密码:</td>
      <td><input name="ftp_password" type="text" id="ftp_password" value="<%=ftp_password%>" size="10">
        <font color="#FF0000">*</font></td>
    </tr>
    <tr> 
      <td>所在目录:</td>
      <td><input name="ftp_HomeDir" type="text" id="ftp_HomeDir" value="<%=ftp_HomeDir%>" size="15">
        <font color="#FF0000">*</font></td>
    </tr>
    <tr> 
      <td>过期时间:</td>
      <td><input name="ftp_Expire" type="text" id="ftp_Expire" value="<% if sdat(ftp_Expire)="" then 
	  Response.Write("0")
	  else
	  Response.Write sdat(ftp_Expire)
	  end if  %>" size="11">
        <font color="#FF0000">*过期时间如果不限制请用 0 代替 格试用:2003-12-3 </font></td>
    </tr>
    <tr> 
      <td height="27">空间大小:</td>
      <td><input name="ftp_DiskQuota" type="text" id="ftp_DiskQuota" value="<%=split(ftp_DiskQuota,"|")(1)%>" size="20">
        <font color="#FF0000">*如果不限制请用 0 代替</font></td>
    </tr>
    <tr bgcolor="#F7F7F7"> 
      <td>&nbsp;</td>
      <td><input type="submit" name="Submit" value="确定"></td>
    </tr>
  </table>
</form>
<p>&nbsp; </p>
</body>
</html>
