<% Option Explicit %>
<!--#include file="../../Inc/Cls_DB.asp" -->
<!--#include file="../../Inc/Const.asp" -->
<%
	Dim DBC,Conn
	On Error Resume Next
	Set DBC = New DataBaseClass
	Set Conn = DBC.OpenConnection()
	Set DBC = Nothing
%>
<!--#include file="../../Inc/Session.asp" -->
<!--#include file="../../Inc/CheckPopedom.asp" -->
<%
if Not JudgePopedomTF(Session("Name"),"P0301") then Call ReturnError()
Dim Path,Result,FileName
FileName = Request.Form("FileName")
Path = Request("Path")
Result = Request.Form("Result")
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建模板文件</title>
</head>
<link href="../Inc/ModeWindow.css" rel="stylesheet">
<body topmargin="10">
<div align="center">
  <table width="98%" border="0" cellspacing="0" cellpadding="0">
    <form name="NewTempletForm" action="" method="post">
      <tr>
        <td height="20">&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr> 
        <td width="20%"> <div align="center">文件名</div></td>
        <td> <div align="left"> 
            <input style="width:100%;" value="Untitled.htm" type="text" name="FileName">
          </div></td>
      </tr>
      <tr> 
        <td height="50" colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
              <td><div align="center"> 
                  <input type="submit" name="Submit" value=" 确 定 ">
                  <input name="Result" type="hidden" id="Result" value="Submit">
                </div></td>
              <td><div align="center"> 
                  <input type="button" onClick="dialogArguments.location.reload();window.close();" name="Submit2" value=" 取 消 ">
                </div></td>
            </tr>
          </table></td>
      </tr>
    </form>
  </table>
</div>
</body>
</html>
<%
if Result = "Submit" then
	Dim FsoObj,PhysicalPath,FileObj,WriteStr
	WriteStr = WriteStr & "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"">" & Chr(13) & Chr(10) & "<html>" & Chr(13) & Chr(10)
	WriteStr = WriteStr & "<head>" & Chr(13) & Chr(10) & "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">" & Chr(13) & Chr(10)
	WriteStr = WriteStr & "<title>无标题文档</title>" & Chr(13) & Chr(10) & "</head>" & Chr(13) & Chr(10) & "<body>" & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "</body>" & Chr(13) & Chr(10) & "</html>"
	Set FsoObj = Server.CreateObject("Scripting.FileSystemObject")
	if Path <> "" then
		PhysicalPath = Server.MapPath(Path)
		if FileName <> "" then
			PhysicalPath = Server.MapPath(Path) & "\" & FileName
			if FsoObj.FileExists(PhysicalPath) = False then
				Set FileObj = FsoObj.CreateTextFile(PhysicalPath)
				FileObj.WriteLine(WriteStr)
			else
%>
<script language="JavaScript">
	alert('文件已经存在，新建失败');
	dialogArguments.location.reload();
	close();
</script>
<%
			end if
		else
%>
<script language="JavaScript">
	alert('参数传递错误，请重试');
	dialogArguments.location.reload();
	close();
</script>
<%
		end if
	else
%>
<script language="JavaScript">
	alert('参数传递错误，请重试');
	dialogArguments.location.reload();
	close();
</script>
<%
	end if
	if Err.Number = 0 then
%>
<script language="JavaScript">
	dialogArguments.location.reload();
	close();
</script>
<%
	else
%>
<script language="JavaScript">
	alert('新建失败');
	dialogArguments.location.reload();
	close();
</script>
<%
	end if
	Set FsoObj = Nothing
end if
%>
<script language="JavaScript">
document.NewTempletForm.FileName.select();
</script>