<!--#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_root,filetype
templet_file=request("file")
act=request.QueryString("act")
filetype=request.QueryString("filetype")
if(act="modok") then
	Set fs=Server.CreateObject("Scripting.FileSystemObject")
	Set file_w = fs.CreateTextFile(templet_file,true)
	TempletContent=request.Form("template_head")&Chr(13)&request.Form("content1")&Chr(13)&request.Form("template_root")
	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
			
			'response.End()
		else
			bodyStartPos=InStr(TempCont,"<body>")+len("<body>")
		end if
		if(InStr(TempCont,"</body>")=0) then
			
			'response.End()
		else
			bodyEndpos=InStr(TempCont,"</body>")-1
		end if
		Template_head=left(TempCont,bodyStartPos)
		if(bodyStartPos>0 and bodyEndpos>bodyStartPos) then
			TempCont=mid(TempCont,bodyStartPos,bodyEndpos-bodyStartPos)
			Template_root="</body></html>"
		end if
		
		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>
<FORM method="POST" name="form1" action="?act=modok" 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%> <a href="file_mod.asp?file=<%=templet_file%>">文本编辑</a></div></TD>
  </TR>
  <tr bgcolor="#F5F5F5" style="display:none;">
  <TD width="8%">模板头：</TD>
	<TD width="92%"><textarea rows="8" name="template_head" style="width:100%; "><%=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="content1" style="display:none; "><%=replace(replace(TempCont,"<","&lt;"),">","&gt;")%></textarea>		
		<IFRAME ID="eWebEditor1" src="webedit/editor.html" frameborder="0" scrolling="no" width="98%" height="350"></IFRAME>
	  </TD>	  
</TR>
<tr bgcolor="#F5F5F5" style="display:none;">
<TD width="8%">模板尾：</TD>
	<TD width="92%"><textarea rows="6" name="template_root" style="width:100%; "><%=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>
</BODY>
</HTML>
<%
call connclose()
%>