<!--#include file="fsoconfig.asp"-->
<!--#include file="checklogin.asp"-->
<%
if request.form("act")="editfile" then
	fcontent=request.form("fcontent")
	if path="" or instr(path,":")>0 or instr(path,"\")>0 then
		response.write "<script language='javascript'>"&vbcrlf
		response.write "<!--"&vbcrlf
		response.write "alert('指定的文件名或路径中含有非法字符');"&vbcrlf
		response.write "window.close();"&vbcrlf
		response.write "//-->"&vbcrlf
		response.write "</script>"&vbcrlf
		response.end
	end if
	if len(path)>1 and right(path,1)="/" then
		path=left(path,len(path)-1)
	end if
	filepath=server.mappath(path)
	set obj_fso=server.createobject("scripting.filesystemobject")
	if obj_fso.fileexists(filepath) then
		set obj_file=obj_fso.opentextfile(filepath,2,false)
		obj_file.write fcontent
		obj_file.close
		set obj_file=nothing
		response.write "<script language='javascript'>"&vbcrlf
		response.write "<!--"&vbcrlf
		response.write "window.history.go(-1);"&vbcrlf
		response.write "//-->"&vbcrlf
		response.write "</script>"&vbcrlf
	else
		response.write "<script language='javascript'>"&vbcrlf
		response.write "<!--"&vbcrlf
		response.write "alert('找不到指定的文件，可能该文件已经被删除');"&vbcrlf
		response.write "window.close();"&vbcrlf
		response.write "//-->"&vbcrlf
		response.write "</script>"&vbcrlf
	end if
	response.end

end if
%>
<html>
<head>
<title><%=sysname%>--文件编辑</title>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta name="author" content="netasp;EMAIL:netasp@sohu.com">
<style type="text/css">
<!--
body,table,td{font-size:12px;color:#000090;}
body{margin:0;background:#ffffff url(fsoimg/bgbrick.gif);}
table{width:100%}
table table{width:100%;}
td{vertical-align:top;padding-left:12px;}
td td{padding-left:4px;vertical-align:middle;}
img{vertical-align:bottom}
form,p{margin:0;padding:0}
a{color:#000080;text-decoration:none;}
a:hover{color:#ff3333;text-decoration:underline}
.button{width:65px;height:20px;border:solid 1px;border-color:#ffffff #666666 #666666 #ffffff;margin:3px 0;}
//-->
</style>
<head>
<body>
<table align="center" cellspacing=0 style="border:solid 1px;border-color:#f6f6f6 #999999 #999999 #f6f6f6;background:#d6d3cc">
<tr>
<td style="padding-left:12px;vertical-align:middle;height:32px;"><%=sysname%></td>
</tr>
</table>
<table align="center" cellspacing=0 style="border:solid 1px;border-color:#f6f6f6 #999999 #999999 #f6f6f6;background:#d6d3cc">
<tr>
<td>
<form method="get" action="<%=selfname%>">
<span style="position:relative;top:-3px;">位置：</span><input type="text" name="path" style="margin:6px 6px 3px;width:95%;border:solid 1px #000099;" <%
path=trim(request.querystring("path"))
response.write "value='"&path&"'> "
response.write "<input type='submit' class='button' value='读文件'> "
response.write "</form>"&vbcrlf&"</td>"&vbcrlf&"</tr>"&vbcrlf&"<tr>"&vbcrlf&"<td>"&vbcrlf
if path="" or instr(path,":")>0 or instr(path,"\")>0 then
	response.write "　　　　<font color=#ff3333>你要编辑的文件名或路径错误！</font>"
	response.end
end if
filepath=server.mappath(path)
set obj_fso=server.createobject("scripting.filesystemobject")
if obj_fso.fileexists(filepath) then
	set obj_file=obj_fso.opentextfile(filepath,1,false)
	if not obj_file.atendofstream then
		s_content=replace(obj_file.readall(),"&","&amp;")
		s_content=replace(s_content,"<","&lt;")
		s_content=replace(s_content,">","&gt;")
	end if
	obj_file.close
	set obj_file=nothing
	response.write "<form action='"&selfname&"?path="&server.urlencode(path)&"' method=post>"&vbcrlf
	response.write "<input type='hidden' name='act' value='editfile'>"
	response.write "<input type='hidden' name='path' value='"&path&"'>"
	response.write "<textarea name='fcontent' style='border:solid 1px #000099;width:98%;' cols='102' rows='33'>"&s_content&"</textarea><br>"&vbcrlf
	response.write "<p style='text-align:right;padding-right:24px;'><input type='submit' class='button' value='保存编辑'>　<input type='reset' class='button' value='复原'></p>"&vbcrlf
	response.write "</form>"&vbcrlf
else
	response.write "　　　　<font color=#ff3333>你要编辑的文件不存在</font>"
end if
set obj_fso=nothing

%>
</td>
</tr>
</table>
</body>
</html>
<!--#include file="fsofoot.asp"-->
 

