<?php
include '5yuns.class.php';
if (@$_GET['pw'] != $pass){
header("Content-type:text/html;charset=utf-8");
echo '<title>后台管理_温馨留言</title>';
echo '<h3>后台登陆</h3><form method="get" action="admin.php">';
echo '密码:<input type="password" name="pw">
<input type="submit" value="提交">';
echo '</form>';
exit;
}

$yuns5 = new yuns5();
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台管理_温馨留言</title>
<link rel="stylesheet" href="style/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="container">
 <div class="panel panel-primary">
  <div class="panel-heading"><h3 class="panel-title">设置区</h3></div>
   <div class="panel-body">
    <div class="alert alert-dismissable alert-info">
    <p>坚持收录那些温馨的话语吧！</p>
    </div>
	<form method="post" action="admin.php?pw=<?php echo $pass; ?>">
	<div class="input-group">
		<span class="input-group-addon">站点名称</span>
		<?php echo '<input type="text" class="form-control" name="site" value="'.$site.'">'; ?>
	</div>
	<div class="input-group">
		<span class="input-group-addon">管理密码</span>
		<?php echo '<input type="text" class="form-control" name="pass" value="'.$pass.'">'; ?>
	</div>
	<div class="input-group">
		<span class="input-group-addon">类型设置</span>
		<span align="center">
		<p><input type="radio" name="module" value="note" <?php if($module == 'note') echo 'checked=""'; ?>>【日记本】 - 发表区会设置上密码(密码为管理员密码)</p>
		<p><input type="radio" name="module" value="message" <?php if($module == 'message') echo 'checked=""'; ?>>【留言板】 - 任意用户均可在发表区留言(无密码设置)</p>
		</span>
	</div>
	<input type="submit" class="btn btn-default btn-block" name="set" value="提交">
	</form>
<?php
if(isset($_POST['set'])){
$txt="<?
\$site = \"$_POST[site]\"; //网站名称
\$pass = \"$_POST[pass]\"; //管理密码
\$module = \"$_POST[module]\"; //网站类型
?>";
$fp=fopen('config.php','w');
flock($fp,LOCK_EX);
$write=fputs($fp,$txt);
flock($fp,LOCK_UN);
fclose($fp);
if($write){
header("location: admin.php?pw=$pass");
}else{
echo '<center><p>保存配置失败，请开启0777权限！</p></center>';
}}
?>
  </div>
 </div>
<div class="panel panel-success">
<div class="panel-heading"><h3 class="panel-title"管理留言</h3></div>
<div class="panel-body">
<div class="alert alert-dismissable alert-info">
<p>注意，文本数据是安【年 月 日 时 分】载入的</p>
</div>
<?php
$list = $yuns5->getMessageList();
foreach ($list as $value){
echo '<p>'.$value.'<a href="admin.php?pw='.$pass.'&del='.$value.'">【删除】</a></p>';
}
unset($value);
if (isset($_GET['del'])){
unlink($yuns5->messageDir."/".$_GET['del']);
header("location: admin.php?pw=$pass");
}
?>
</div>
</div>
<footer>
<p>
<center>格子QQ:412476456</center>
<br> <a href="index.html" rel="nofollow">返回首页</a>
</p>
</footer>
</div>
</body>
</html>