<?php
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
if (!defined('MOD')) die("access die");
$show_debug_info = false;
$filename_pattern = "#[\\x00-\\x19\\\/\?\'\|\*:<>]#i";
$filename = ($_GET[file].$_GET['ext']) ? $_GET[file].$_GET['ext'] : $_POST['filename'];
if($_POST['filename'])
{
	$retval = qbase::writetofile( "$currdir/$_POST[filename]" ,stripslashes($_POST['filecontent']) );
	$content = ($retval)
				? "<p><b>成功</b> ：<br> &nbsp; &nbsp;文件修改成功，文件已经被保存。</p><p>请单击“完成”按钮。"
				: "<p><b>失败</b> ：<br> &nbsp; &nbsp;文件修改不成功！文件未被保存。</p><p>请单击“完成”按钮。";
	$button  = '<script type="text/javascript">parent.qmeCms.dialogView.setSubmit(true, " 完成 ", function(){
			parent.qmeCms.dialogView.setSubmit(false, " 完成 ");
			parent.qmeCms.dialogView.close();
		});</script>';
}
else
{
	$edit_file = "{$currdir}/{$_GET[file]}{$_GET[ext]}";
	if($_GET[file] && file_exists($edit_file))
	{
		$content = qbase::readfromfile($edit_file);
		$content = htmlspecialchars($content);
		$content = "<div style=\"position:relative;\">
								<textarea  class=\"text-data\"  name=filecontent id='filecontent-data' style=\"width:725px;height:350px;\" wrap=\"off\" oncontextmenu=\"return false\">$content</textarea>
								<textarea id=\"filecontent-index\" style=\"width:35px;height:350px;\" readonly=\"true\" class=\"text-index\"></textarea>
								<div style=\"width:42px;height:350px;\"class=\"text-index-parent\"></div>
							</div>";
		$button  = '<script type="text/javascript">
								new qmeCms.areaIndex("filecontent");
								parent.qmeCms.dialogView.setSubmit(true, " 保存 ", function(){
									parent.qmeCms.dialogView.setSubmit(false, " 保存 ");
									document.forms["ajaxForm"].submit();
								});
							</script>';
	}
	else
	{
		$content = '<p><b>错误</b>：<br> &nbsp; &nbsp;文件未指定，或者不存在！</p><p>请返回重试。';
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base target="_self">
<meta http-equiv='Content-Type' content='text/html; charset=<?php echo $_SET['def_charset']; ?>'>
<link rel='stylesheet' type='text/css' href='<?php echo AW_P; ?>images/main.css'>
<script language="javaScript" src="<?php echo WW_P; ?>images/js/qmecms.js"></script>
<script language="javaScript" src="<?php echo AW_P; ?>images/js/admin.js"></script>
<style type="text/css">
body{background-color:#F5F5F5}
</style>
</head>
<body>
<form method="POST" name="ajaxForm" id="ajaxForm" action="system.php?sys=explorer&action=editor&channelid=<?=$channelid?>&path=<?=$urlpath?>">
	<table border=0 cellspacing=0 width=100%>
		<tr>
			<td>
				<input type=hidden name=filename value="<?=$filename?>">路径 ： <?=$urlpath?>
			</td>
		</tr>
		<tr>
			<td>文件 ： <?=$filename?> </td>
		</tr>
		<tr>
			<td  style="HEIGHT:100%;"><?=$content?></td>
		</tr>
		<tr>
			<td align=right><?=$button?></td>
		</tr>
	</table>
</form>
<script type="text/javascript">
	setInterval(function(){
		parent.qmeCms.dialogView.iframeOnload();
	},500);
</script>
</body>
</html>
<?php
exit();
?>

