<!--#include file="conn.asp" -->
<% adm_power_page="7" %>
<!--#include file="admin_dn.asp" -->
<%
 On Error Resume Next
  dim err_msg,iis_id,Computer,w3svc
   iis_id=Trim(Request("iis_id"))
   Computer="localhost"
   if iis_id="" or iis_id=empty then
   Response.Write ("<script>alert('IIS序号出错');javascript:history.back(1)</script>")
   response.end
   end if
   
   Function charv(chartxt,classname1)
    if chartxt="" then
	 charv="参数"&classname1&"不能为空"
	end if
  End Function
   
   '修改iis
  if Trim(Request.QueryString("w"))="save" then
  
	 ServerComment=Trim(Request.Form("ServerComment"))'站点名字
	 MaxConnections=Trim(Request.Form("MaxConnections")) 'IIS链接数
	 LogFileDirectory=Trim(Request.Form("LogFileDirectory"))'日志文件地址
	 CPULimitLogEvent=Trim(Request.Form("CPULimitLogEvent"))'CPU使用
	 MaxBandwidth=Trim(Request.Form("MaxBandwidth"))'宽带限制
	 DefaultDoc=Trim(Request.Form("DefaultDoc"))'默认文档
	 path=Trim(Request.Form("path"))'路径
	 err_msg=charv(ServerComment,"站点名字")
	 err_msg=err_msg&charv(MaxConnections,"IIS链接数")
	 err_msg=err_msg&charv(LogFileDirectory,"日志文件地址")
	 err_msg=err_msg&charv(CPULimitLogEvent,"CPU使用")
	 err_msg=err_msg&charv(maxbandwidth,"宽带限制")
	 err_msg=err_msg&charv(DefaultDoc,"默认文档")
	 err_msg=err_msg&charv(path,"路径")
	 if err_msg<>"" then
	    Response.Write ("<script>alert('数据为空');javascript:history.back(1)</script>")
		response.end
	 end if
	 Err.Clear
	 Set w3svc = GetObject("IIS://" & Computer & "/w3svc")
	  If Err.Number <> 0 Then
	    Response.Write ("<script>alert('无法打开IIS对像');javascript:history.back(1)</script>")
		response.end
	  End If
	 Err.Clear
	 set serverobj=w3svc.getobject("iiswebserver",iis_id)
	 If Err.Number <> 0 Then
	    Response.Write ("<script>alert('无法打开IIS站点');javascript:history.back(1)</script>")
		response.end
	  End If
	  '修改数据
	  Err.Clear
	 serverobj.ServerComment=ServerComment
	 serverobj.MaxConnections=MaxConnections
	 serverobj.CPULimitLogEvent=CPULimitLogEvent
	 serverobj.maxbandwidth=maxbandwidth
	 serverobj.DefaultDoc=DefaultDoc
	 serverobj.LogFileDirectory=LogFileDirectory
	 serverobj.setinfo
	 If Err.Number <> 0 Then
	    Response.Write ("<script>alert('修改iis:iiswebserver时出错');javascript:history.back(1)</script>")
		response.end
	  End If
	  Err.Clear
       Set NewWebServer =serverobj.getobject("iisWebVirtualDir","root")
       If Err.Number <> 0 Then
	      Response.Write ("<script>alert('打开IIS:iisWebVirtualDir对像时出错');javascript:history.back(1)</script>")
		  response.end
	    End If
	   Err.Clear
	    NewWebServer.AppCreate true
	    NewWebServer.put("path"),path	
	    NewWebServer.setinfo
	   If Err.Number <> 0 Then
	    Response.Write ("<script>alert('修改iis:iiswebserver时出错');javascript:history.back(1)</script>")
		response.end
	   End If
	  SET NewWebServer=nothing
	  SET w3svc=nothing
	    Response.Write ("<script>alert('IIS更改成功');</script>")
		
    end if


  '读取IIS数据
 Err.Clear
  Set w3svc = GetObject("IIS://" & Computer & "/w3svc")
  If Err.Number <> 0 Then
   WScript.Echo "无法打开: "&"IIS://" & Computer & "/w3svc" & VbCrlf & "程序将退出."
   WScript.Quit (1)
  End If
 Err.Clear
 Set NewWebServer =w3svc.getobject("iiswebserver",iis_id)
 If Err.Number <> 0 Then
  Response.Write("打开站点出错")
  response.end
 end if
 ServerComment=NewWebServer.ServerComment'站点名字
 MaxConnections=NewWebServer.MaxConnections 'IIS链接数
 LogFileDirectory=NewWebServer.LogFileDirectory '日志文件地址
 CPULimitLogEvent=NewWebServer.CPULimitLogEvent 'CPU使用
 MaxBandwidth=NewWebServer.MaxBandwidth '宽带限制
 DefaultDoc=NewWebServer.DefaultDoc  '默认文档
 'AnonymousUserName=NewWebServer.AnonymousUserName '站点匿名访问的用户名
 'AnonymousUserPass=NewWebServer.AnonymousUserPass '站点匿名访问的密码
 
 'Set NewDir = NewWebServer.getobject("IIsWebVirtualDir", "ROOT")
 set NewDir= GetObject("IIS://" & Computer & "/w3svc/" & iis_id&"/root")
  path=newdir.path
 %>
 
<!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><font color="#990000"><strong>在线IIS维护</strong></font></p>
<form name="form1" method="post" action="edit_iis.asp?w=save">
  <table width="62%" height="221" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC" bordercolorlight="" bordercolordark="ffffff">
    <tr bgcolor="#F5F5F5"> 
      <td colspan="2"><font color="#666666">IIS在线维护</font></td>
    </tr>
    <tr> 
      <td width="20%" height="22" bgcolor="#F5F5F5">IISID:</td>
      <td width="80%"><%= iis_id %>&nbsp; <input name="iis_id" type="hidden" id="iis_id" value="<%=iis_id%>"></td>
    </tr>
    <tr> 
      <td height="24" bgcolor="#F5F5F5">站点名称:</td>
      <td> <input name="ServerComment" type="text" id="ServerComment" value="<%=ServerComment%>"></td>
    </tr>
    <tr> 
      <td height="20" bgcolor="#F5F5F5">IIS链接数:</td>
      <td> <input name="MaxConnections" type="text" id="MaxConnections" value="<%=MaxConnections%>" size="10"></td>
    </tr>
    <tr> 
      <td bgcolor="#F5F5F5">日志文件:</td>
      <td> <input name="LogFileDirectory" type="text" id="LogFileDirectory" value="<%=LogFileDirectory%>" size="30"></td>
    </tr>
    <tr> 
      <td bgcolor="#F5F5F5">主目录:</td>
      <td> <input name="path" type="text" id="path" value="<%=Path%>" size="20">
        路径</td>
    </tr>
    <tr> 
      <td bgcolor="#F5F5F5">CPU使用:</td>
      <td><input name="CPULimitLogEvent" type="text" id="CPULimitLogEvent" value="<%=CPULimitLogEvent%>" size="10">
        这里是以 1/10000 做为单位 <font color="#FF0000">如:1000 表示 1%</font></td>
    </tr>
    <tr> 
      <td bgcolor="#F5F5F5">带宽限制:</td>
      <td><input name="maxbandwidth" type="text" id="maxbandwidth" value="<%=MaxBandwidth%>" size="10">
        字节 /S 1KB/S =1024字节/S <font color="#FF0000">0</font>为不限制</td>
    </tr>
    <tr> 
      <td bgcolor="#F5F5F5">默认文档:</td>
      <td><input name="DefaultDoc" type="text" id="DefaultDoc" value="<%=DefaultDoc%>" size="40"></td>
    </tr>
    <tr> 
      <td bgcolor="#F5F5F5">&nbsp;</td>
      <td bgcolor="#F5F5F5"><input type="submit" name="Submit" value="确定"></td>
    </tr>
  </table>
</form>
<p>&nbsp; </p>
</body>
</html>
