<?
/*
	[SueamCMS] (C)2009-2010 ZMRNet Studio
	bbs_rep.php by 2009-10-16 zmrnet
*/
require_once(dirname(__FILE__).'/include/manage.php');

$bbs_act = trim($_POST['act']);

if($bbs_act=='rep'){
	$bbs_id = (int) trim($_POST['id']);
	$bbs_type = trim($_POST['type']);
	$bbs_reply = trim($_POST['reply']);
	$bbs_reply = htmlspecialchars_decode($bbs_reply);
	$bbs_rtime = date('Y-m-d H:i:s', time()+(time_zone*3600));

	$_LST = $vdb->opendir($bbs_type.'/list');
	$key = array_find($_LST, 'id', $bbs_id);
	$_LST[$key]['reply']	= $bbs_reply;
	$_LST[$key]['rtime']	= $bbs_rtime;
	$vdb->writedir($bbs_type.'/list', $_LST);
		
	$vdb->open('index');
	$vdb->write();

	unset($_LST);
		
	die(refresh('bbs_list.php?type='.$bbs_type).'<script>alert(\'留言回复成功！\')</script>');
}else{
	$bbs_id = (int) trim($_GET['id']);
	$bbs_type = trim($_GET['type']);
	if($bbs_id){
		$_LST = $vdb->opendir($bbs_type.'/list');
		$key = array_find($_LST, 'id', $bbs_id);
		$_BBS = $_LST[$key];
		$bbs_name	= $_BBS['name'];
		$bbs_post	= $_BBS['post'];
		$bbs_time	= $_BBS['time'];
		$bbs_reply	= $_BBS['reply'];
		$bbs_rtime	= $_BBS['rtime'];
		unset($_BBS);
		unset($_LST);
	}else{
		die('ID Error!');
	}
}

unset($_VDB);
unset($vdb);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><? echo $sys_title; ?></title>
<link href="images/sueam.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div style="margin:20px;">
	<div style="margin:10px;font-size:14px;color:green"><b>回复留言</b></div>
	<div class="sec_menu">
	<form action="bbs_rep.php" method="post" style="margin:auto;padding:25px;width:500px;text-align:left">
		<div style="text-align:left"><? echo $bbs_name; ?> ( <? echo $bbs_time; ?> )<br><? echo $bbs_post; ?></div>
		<br>回复内容：<br>
		<textarea name="reply" rows="3" class="input_txt2"><? echo $bbs_reply; ?></textarea><br><br>
		<input type="reset" value="还 原" class="input_btn">&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="submit" value="提 交" class="input_btn">
		<input type="hidden" name="type" value="<? echo $bbs_type; ?>">
		<input type="hidden" name="id" value="<? echo $bbs_id; ?>">
		<input type="hidden" name="act" value="rep">
	</form>
	</div><br>
</div>
</body>
</html>