📄 admin.php
字号:
<?
ob_start();
session_start();
include("config.php");
include("include/function.php");
$data=$path.$data;
?>
<html>
<head>
<title><?=$title?></title>
<style>
body{
margin:10px;
background:#fff;
font:16px verdana;
color:#666;}
input{
width:100px;
font:16px verdana;
color:#666;}
a{
color:#666;}
a:hover{
color:blue;}
input{
width:160px;}
table.back{
border-collapse:collapse;
border:1px solid #333;}
table.back tr,td{
padding:3px;
border:1px dashed #666;}
table.back .putin{
font:12px verdana;
width:80px;}
</style>
<script type="text/javascript">
function putin(file){
question=confirm("是否真的要将备份"+file+"-data.txt覆盖原数据库?");
if(question==true){window.location.href="?action=putin&back="+file+"-data.txt";}
}
</script>
</head>
<body>
<?
if(isset($_GET["login"])){
if($_GET["login"]=="check"){//________进行验证
if($_POST['user']!=$administrator||$_POST['pass']!=$adminer)die("验证错误,<a href='#' onclick='javascript:history.go(-1)'>返回</a>");
$pass=$adminer;
session_register("pass");
echo "<script type='text/javascript'>window.location.href='admin.php'</script>";
}
}
if($_SESSION["pass"]!=$adminer){//________登陆表单输出
echo "<form action=?login=check method=post>\n";
echo "<p>user:<input type='text' name='user'></p>\n";
echo "<p>pass:<input type='password' name='pass'></p>\n";
echo "<input type='submit' value='提交' style='border:0px;'>\n";
echo "</form>";
echo "<br>\n<a href='index.php'>index.php</a>";
die(" ");
}
if(isset($_GET["del"])){//________进行删除
$del=$_GET["del"];
$file=file($data);
$file[$del]="";
write_file($data,join("",$file),"w");
echo "删除成功.<br>\n<a href='index.php'>index.php</a> <a href='admin.php'>admin.php</a>\n<br>\n<br>\n";
}
if(isset($_GET["promise"])){//________进行审批
$promise=$_GET["promise"];
$file=@file($data);
list($hidden,$name,$icon,$message,$ip,$time,$reply)=explode("||",$file[$promise]);
$hidden=1;
$file[$promise]=$hidden."||".$name."||".$icon."||".$message."||".$ip."||".$time."||".$reply;
write_file($data,join("",$file),"w");
echo "审批成功.<br>\n<a href='index.php'>index.php</a> <a href='admin.php'>admin.php</a>\n<br>\n<br>\n";
}
if(isset($_GET["re"])){//________回复表单输出开始
$re=$_GET["re"];
$file=@file($data);
list($hidden,$name,$icon,$message,$ip,$time,$reply)=explode("||",$file[$re]);
?>
<div id="msgbox">
<div class="msgitem">
<div class="msgname"><?=$name?></div>
<div class="msgimg">
<a href="#" onclick="javascript:alert('<?=$ip?> at <?=$time2?>');">
<img src="image/<?=$icon?>">
</a>
</div>
<div class="msgboxinbox">
<div class="msgcontent">
<?=$message?>
</div>
<div class="msgtime"><?=$time1?></div>
<form action="?action=reply" method="post"><textarea name="remsg" style="font:12px verdana;border:1px dashed #aaa;color:#666;width:320px;height:80px;"><?=$reply?></textarea>
<input type="hidden" value="<?=$re?>" name="number">
<input type="submit" value="submit" class="submit">
</form>
</div>
</div>
</div>
<?
}//________回复表单输出结束
if(isset($_GET["action"])){//________回复留言处理
$action=$_GET["action"];
if($action=="reply"){
$remsg=blackbox($_POST["remsg"]);
$remsg.="\n";
$file=file($data);
list($hidden,$name,$icon,$message,$ip,$time,$reply)=explode("||",$file[$number]);
$file[$number]=$hidden."||".$name."||".$icon."||".$message."||".$ip."||".$time."||".$remsg;
write_file($data,join("",$file),"w");
echo "回复成功!<br>\n<a href='index.php'>index.php</a> <a href='admin.php'>admin.php</a>\n<br>\n<br>\n";
}
if($action=="backup"){//________备份数据文件
$t=time();
$new=$path.$t."-data.txt";
copy($data,$new);
echo "备份完毕<br>";
echo "<a href=\"".$new." \" target=\"_blank\">".$new."</a><br><br>\n<a href='?action=showback'>备份管理</a> <a href='index.php'>index.php</a>\n<br><br>\n";
}
if($action=="delitems"){//________进行批量删除
$file=file($data);
for($i=0;$i<sizeof($_POST["items"]);$i++){
$delnum=$_POST["items"][$i]-1;
echo "删除第".$_POST["items"][$i]."条留言...<br>\n";
$file[$delnum]="";
}
write_file($data,join("",$file),"w");
echo "批量删除成功!<br>\n<a href='index.php'>index.php</a> <a href='admin.php'>admin.php</a>\n<br>\n<br>\n";
}
if($action=="date"){//________数据管理表单输出
echo "<form action='?action=save' method='post'>\n";
echo "<p style='color:red;'>此项功能用于直接对数据进行修改,要使用这项功能时请先备份数据</p>";
echo "<textarea name='data' style='color:#333;font:11px verdana;width:480px;height:220px;'>\n";
$file=file($data);
$content="";
for($i=0;$i<count($file);$i++)$content.=$file[$i];
echo $content;
echo "</textarea>\n";
echo "<br>\n<input type='submit' value='提交' style='background:#333;color:#fff;border:0px;'>\n";
echo "</form>\n";
}
if($action=="normal"){//________常规修改表单输出
$data=explode("/",$data);
$data=end($data);
echo "<form action='?action=modify' method='post' name='modify'>\n";
echo "<span style='width:160px;text-align:right;'>选择样式表:</span>\n";
echo "<select name='new_style' style='font:16px verdana;width:160px;color:#666;'>\n";
$handle=opendir("style");
while ($file = readdir($handle)) {
if(ereg(".css$",$file)){
$style_info=get_style_info("style/".$file);
echo "<option value='style/".$file."' ";
if("style/".$file==$style)echo "selected";
echo ">".$style_info[0]."</option>\n";
}
}
echo "</select><input type=\"button\" value=\"观看样式\" style=\"font:11px verdana;width:100px;\" onclick=\"window.open('index.php?style='+document.modify.new_style.options[document.modify.new_style.selectedIndex].value)\"><br>\n";
echo "<span style='width:160px;text-align:right;'>留言本标题:</span><input type='text' value='$title' name='new_title'><br>\n";
echo "<span style='width:160px;text-align:right;'>数据地址:</span><input type='text' value='$path' name='new_path'><br>\n";
echo "<span style='width:160px;text-align:right;'>数据文件名:</span><input type='text' value='$data' name='new_data'><br>\n";
echo "<span style='width:160px;text-align:right;'>每页留言数:</span><input type='text' value='$numperpage' name='new_numperpage'><br>\n";
echo "<span style='width:160px;text-align:right;'>最大留言数:</span><input type='text' value='$max' name='new_max'><br>\n";
echo "<span style='width:160px;text-align:right;'>防灌水时间间隔:</span><input type='text' value='$wait' name='new_wait'>秒<br>\n";
echo "<span style='width:160px;text-align:right;'>管理用户:</span><input type='text' value='$administrator' name='new_administrator'><br>\n";
echo "<span style='width:160px;text-align:right;'>管理密码:</span><input type='password' value='$adminer' name='new_adminer'><br>\n";
echo "<span style='width:160px;text-align:right;'>留言验证开关:</span><input type='tetx' value='$check' name='new_check'>0为关闭,1为开启<br>\n";
echo "<input type='submit' value='submit'>\n";
echo "</form>\n";
}
if($action=="save"){//________进行数据管理处理
$fp=@fopen($data,"w");
fwrite($fp,$_POST["data"]);
fclose($fp);
echo "修改成功!\n<br>\n";
}
if($action=="delback"){
if(isset($_GET["back"])&&ereg("-data.txt",$_GET["back"])){
if(@unlink($path.$_GET["back"])){
echo "删除成功<br><a href='?action=showback'>备份管理</a> <a href='admin.php'>admin.php</a>\n<br>\n<br>\n";}
else{echo "删除失败,可能是文件属性权限不够造成此原因.<br>";}
}
else{echo "不恰当的操作,要删除的备份未被指定或名称错误!<br>\n<br>\n";}
}
if($action=="putin"){
if(isset($_GET["back"])&&ereg("-data.txt",$_GET["back"])){
$file=file($path.$_GET[back]);
write_file($data,join($file),"w");
echo "导入成功<br><a href='?action=showback'>备份管理</a> <a href='index.php'>index.php</a>\n<br>\n<br>\n";}
else{echo "不恰当的操作,要导入的备份未被指定或名称错误!<br>\n<br>\n";}
}
if($action=="showback"){
echo "<table class='back'>\n<tr><td>名称</td><td>备份时间</td><td>删除</td><td>导入数据库</td></tr>\n";
$handle=opendir($path);
while ($file = readdir($handle)) {
if(ereg("-data.txt",$file)){
$time=explode("-",$file);
echo "<tr><td><a href='".$path.$file."' target='_blank'>".$file."</a></td><td>".date("y年m月d日 H点i分",$time[0])."</td><td><a href='?action=delback&back=$file'>删除</a></td><td><input type='button' class='putin' value='导入' onclick=\"putin($time[0])\"></td></tr>\n";}
}
closedir($handle);
echo "</table>\n";
echo "<p><input type='button' value='备份新的数据' onclick=\"javascript:window.location.href='?action=backup'\"></p>";
}
if($action=="modify"){//________进行常规设置处理
$input="<?\$title=\"".$_POST["new_title"]."\";\$style=\"".$_POST["new_style"]."\";\$path=\"".$_POST["new_path"]."\";\$data=\"".$_POST["new_data"]."\";\$numperpage=\"".$_POST["new_numperpage"]."\";\$max=\"".$_POST["new_max"]."\";\$wait=\"".$_POST["new_wait"]."\";\$administrator=\"".$_POST["new_administrator"]."\";\$adminer=\"".$_POST["new_adminer"]."\";\$check=\"".$_POST["new_check"]."\";?>";
write_file("config.php",$input,"w");
echo "修改成功!<br>\n<a href='index.php'>index.php</a> <a href='admin.php'>admin.php</a>\n<br>\n<br>\n";
}
if($action=="out"){//________注销退出
session_unregister("pass");
echo "注销完毕.<a href='index.php'>index.php</a> <a href='admin.php'>admin.php</a>\n";
}
}
if($_SESSION["pass"]==$adminer){//________输出管理项目
echo "<a href='?action=normal'>常规设置</a>\n";
echo "<a href='?action=showback'>备份管理</a>\n";
echo "<a href='?action=date'>数据管理</a>\n";
echo "<a href='index.php'>首页管理</a>\n";
echo "<a href='?action=out'>注销</a>\n";
}
?>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -