<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p15")
'''''''''''''''''''''''''''''''''''''''''''''''
dim templet_file,TempCont,act,TempletContent,Template_head,Template_Cnt,Template_root,filetype,modtype
templet_file=request("file")
act=request.QueryString("act")
filetype=request.QueryString("filetype")
modtype=request.QueryString("modtype")
if(act="modok") then
	Set fs=Server.CreateObject("Scripting.FileSystemObject")
	Set file_w = fs.CreateTextFile(templet_file,true)
	if(modtype="view") then
		TempletContent=request.Form("template_head")&Chr(13)&request.Form("content")&Chr(13)&request.Form("template_root")
	else
		TempletContent=request.Form("content")
	end if
	file_w.WriteLine(TempletContent)
	file_w.close
	set file_w=nothing
	set fs=nothing
	response.Write("文件"&templet_file&"修改成功!")
	response.Write("<a href=""#"" onClick=""javascript:history.go(-2)"">返回</a>")
	response.End()
end if
%>
<HTML>
<HEAD>
<TITLE>修改模板</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style>
body,td,input,textarea {font-size:9pt}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
</style>
</HEAD>
<BODY>
<%
		Set fs=Server.CreateObject("Scripting.FileSystemObject")
		set file_r = fs.opentextfile(templet_file,1,True)'读取模板文件
		TempCont= file_r.ReadAll
		file_r.close()
		set file_r=nothing	
		set fs=nothing
		dim bodyStartPos,bodyEndpos
		if(filetype="html") then
		if(InStr(TempCont,"<body")=0) then
			
		else
			bodyStartPos=InStr(TempCont,"<body>")+len("<body>")
		end if
		if(InStr(TempCont,"</body>")=0) then
			
		else
			bodyEndpos=InStr(TempCont,"</body>")-1
		end if
		Template_head=left(TempCont,bodyStartPos)
		Template_Cnt=mid(TempCont,bodyStartPos,bodyEndpos-bodyStartPos)
		Template_root="</body></html>"
		end if
%>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
if(modtype="text") then
%>
<FORM method="POST" name="form1" action="file_mod.asp?act=modok&modtype=<%=modtype%>&filetype=<%=filetype%>" style="margin:0 0 0 0; ">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#F5F5F5">
  <TD height="24" colspan="2"><div align="center">修改模板<%=templet_file%>&nbsp;&nbsp;<a href="?modtype=view&file=<%=templet_file%>&filetype=<%=filetype%>">视图模式</a></div></TD>
  </TR>  
<TR bgcolor="#F5F5F5">	
	<TD width="8%">模板内容：</TD>
	<TD width="92%">
	  	<textarea name="content" style=" width:99%; height:300px;"><%=replace(replace(TempCont,"<","&lt;"),">","&gt;")%></textarea>
	  </TD>	  
</TR>
<TR bgcolor="#F5F5F5">
	<TD colspan=2 align=right>
	  <div align="center">	  
	  <input type="hidden" name="file" value="<%=templet_file%>">
	  <INPUT type=submit name=b1 value="提交"> 
	  <INPUT type=reset name=b2 value="重填"> 
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
else
%>
<FORM method="POST" name="form1" action="file_mod.asp?act=modok&modtype=view&filetype=<%=filetype%>" style="margin:0 0 0 0; " onSubmit="document.form1.content.value=doc_html.Composition.document.body.innerHTML">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#F5F5F5">
  <TD height="24" colspan="2"><div align="center">修改模板<%=templet_file%>&nbsp;&nbsp;<a href="?modtype=text&file=<%=templet_file%>&filetype=<%=filetype%>">文本模式</a></div></TD>
  </TR>
  <tr bgcolor="#F5F5F5">
  <TD width="8%">模板头：</TD>
	<TD width="92%"><textarea rows="12" name="template_head" style="width:100%; display:blok;"><%=replace(replace(Template_head,"<","&lt;"),">","&gt;")%></textarea></td>
  </tr>
<TR bgcolor="#F5F5F5">	
	<TD width="8%">模板内容：</TD>
	<TD width="92%">
		<!--<INPUT type="hidden" name="content1" value="">-->		
		<textarea rows="12" name="content" cols="70" style="display:none; "></textarea>
	  	<textarea name="tempcontent" style="display:none; "><%=replace(replace(Template_Cnt,"<","&lt;"),">","&gt;")%></textarea>
		<iframe src="editor/editorfile.htm" id="doc_html" name="doc_html" width="100%" height="325"></iframe>
		
	  </TD>	  
</TR>
<tr bgcolor="#F5F5F5">
<TD width="8%">模板尾：</TD>
	<TD width="92%"><textarea rows="12" name="template_root" style="width:100%; display:blok;"><%=replace(replace(Template_root,"<","&lt;"),">","&gt;")%></textarea></td>
</tr>
<TR bgcolor="#F5F5F5">
	<TD colspan=2 align=right>
	  <div align="center">	  
	  <input type="hidden" name="file" value="<%=templet_file%>">
	  <INPUT type=submit name=b1 value="提交"> 
	  <INPUT type=reset name=b2 value="重填"> 
	  <INPUT type=button name=b3 value="查看源文件" onClick="location.replace('view-source:'+location)">	
	    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end if
%>
</BODY>
</HTML>
<%
call connclose()
%>