|
文件:admin.php
数据库:info.txt管理密码:admin
- <?php
- ob_start();
- error_reporting(0);
- session_start();
- /*页面设置*/
- $fuwu_title = "管理中心";
- $fuwu_footer = "版权所有:弘毅网络科技";
- /*顶部菜单设置*/
- $menu_head = "<a href='?'>所有</a> | <a href='admin.php?tj=add'>添加</a> | <a href='admin.php?tj=login'>管理</a>"; //顶部菜单
- $menu_admin = " | <a href='admin.php?tj=logout'>退出</a><br><a href='admin.php?tj=xiugai'>修改记录</a>" ;
- ?>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <meta name="format-detection" content="telephone=no" />
- <meta name="Copyright" content="" />
- <title><?php echo $fuwu_title;?></title>
- <style type="text/css">
- body {font-family: 宋体;font-size: 9pt;background: #00cd00;}
- a:link{color: #222;text-decoration: none;}
- a:visited{text-decoration: none;/*color: #222;*/}
- a:hover{text-decoration: underline;color: #FF0000;}
- a:active{text-decoration: none;/*color: #999999;*/}
- </style>
- <script>
- function del(id){
- if(confirm("确定要删除吗?")){
- window.location='?act=del&id='+id;
- }
- }
- </script>
- <script language=javascript>
- function CheckPost()
- {
- if (myform.title.value.length<2)
- {
- alert("标题不能少于2个字符");
- myform.title.focus();
- return false;
- }
- if (myform.name.value=="")
- {
- alert("昵称不能为空");
- myform.name.focus();
- return false;
- }
- if (myform.content.value.length<10)
- {
- alert("内容不能少于10个字符");
- myform.content.focus();
- return false;
- }
- }
- </script>
- <?php
- if($_POST['submit5']){
- if($_POST['pwd']=="admin"){
- $_SESSION['pwd']=$_POST['pwd'];
- echo "<script language=javascript>alert('登陆成功!');window.location='admin.php'</script>";
- }
- }
- ?>
- <?php
- if($_GET['tj'] == 'logout'){
- session_start(); //开启session
- session_destroy(); //注销session
- header("location:admin.php"); //跳转到首页
- }
- ?>
- <?php
- if($_GET["id"]<>'' && $_GET["act"]=="del"){
- $id = $_GET["id"];
- $info = file_get_contents("info.txt");
- $column = explode("@@@",$info); unset($column[$id]);
- $noinfo = implode("@@@",$column);
- file_put_contents("info.txt",$noinfo);
- echo "<script language=javascript>alert('删除成功!');window.location='admin.php'</script>";
- }
- ?>
- </head>
- <body>
- <form name="myform" method="post" onSubmit="return CheckPost()" action="" style="margin-bottom:5px;">
- <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#B3B3B3">
- <tr>
- <td align="center" onclick="javascript:window.history.go(-1);" width="80"> << </td>
- <td height="25" align="center" bgcolor="#EBEBEB"><?php echo $menu_head ;?><?php if($_SESSION['pwd']<>''){ echo "$menu_admin"; }?></td>
- </tr>
- </table>
- <a name='add'> </a>
- <?php
- if($_GET["tj"] == add){
- ?>
- <?php
- if($_POST[submit]){
- $title = $_POST["title"];
- $wangzhi = $_POST["wangzhi"];
- $content = file_get_contents("info.txt");
- if(!$content){$insert = "{$title}%%{$wangzhi}@@@";}else{$insert = "\r\n{$title}%%{$wangzhi}@@@";}
- file_put_contents("info.txt",$content.$insert);
- echo "<script language=javascript>alert('登记成功!');window.location='admin.php'</script>";
- }
- ?>
- <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#B3B3B3" brder="1">
- <tr>
- <td width="62" align="center" bgcolor="#FFFFFF">站名:</td>
- <td width="200" bgcolor="#FFFFFF"><input type="text" name="title" style="width:80%;"/>
- *</td>
- </tr>
- <tr>
- <td width="62" align="center" bgcolor="#FFFFFF">链接:</td>
- <td width="200" bgcolor="#FFFFFF"><input type="text" name="wangzhi" style="width:80%;"/>
- *</td>
- </tr>
- <tr>
- <td colspan="2" align="center" bgcolor="#FFFFFF">
- <input name="submit" type="submit"value="提交" />
- <input name="reset" type="reset" value="重填"/> </td>
- </tr>
- </table>
- </form>
- <?php
- }
- ?>
- <a name='add'> </a>
- <?php
- if($_GET["id"]<>'' && $_GET["tj"] == edit){
- //读取数据
- $info = file_get_contents("info.txt");
- $info = rtrim($info,"@");
- if(strlen($info)>10){
- $column = explode("@@@",$info);
- foreach($column as $keys=>$values){
- $message = explode("%%",$values);
- if($_GET["id"]==$keys){
- //修改文件操作
- if($_POST[submit] && $_GET["id"]<>''){
- $title = $_POST["title"];
- $wangzhi = $_POST["wangzhi"];
- $content = file_get_contents("info.txt");
- $str1 = str_replace($message[0],$title,$content);//将数据0替换为提交1
- file_put_contents("info.txt",$str1);//将数据0替换为提交1写入
- $content = file_get_contents("info.txt");
- $str2 = str_replace($message[1],$wangzhi,$content);//将数据1替换为提交2
- file_put_contents("info.txt",$str2);//将数据1替换为提交2写入
- echo "<script language=javascript>alert('修改成功!');window.location='admin.php?tj=edit&id={$_GET["id"]}'</script>";
- }
- ?>
- <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#B3B3B3" brder="1">
- <tr>
- <td width="62" align="center" bgcolor="#FFFFFF">站名:</td>
- <td width="200" bgcolor="#FFFFFF"><input type="text" name="title" value="<?php echo $message[0];?>" style="width:80%;"/>
- *</td>
- </tr>
- <tr>
- <td width="62" align="center" bgcolor="#FFFFFF">链接:</td>
- <td width="200" bgcolor="#FFFFFF"><input type="text" name="wangzhi" value="<?php echo $message[1];?>" style="width:80%;"/>
- *</td>
- </tr>
- <tr>
- <td colspan="2" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit"value="提交" /></td>
- </tr>
- </table>
- </form>
- <?php
- }
- }}}
- ?>
- <?php
- if($_GET["tj"] == xiugai){
- ?>
- <?php
- if(isset($_POST['content'])){
- file_put_contents('info.txt', $_POST['content']);
- echo "<p color="red">保存成功</p>";
- }
- $string=file('info.txt');
- ?>
- <form action="" method="POST">
- <textarea name="content" id="content" rows="20" cols="" style="width:100%;" >
- <?php
- for ($i=0;$i<count($string);$i++){
- echo $string[$i]."";
- }
- ?>
- </textarea>
- <input type="submit" name="Submit" value="提交" />
- </form>
- <?php
- }
- ?>
- <a name='login'> </a>
- <?php if($_GET['tj'] == 'login'){ ?>
- <form name="form" method="post" action="" style=" margin-top:5px;">
- <table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#B3B3B3">
- <tr>
- <td colspan="3" align="center" bgcolor="#EBEBEB" class="font">后台管理页</td>
- </tr>
- <tr>
- <td width="89" align="center" bgcolor="#FFFFFF" class="font">管理密码:</td>
- <td colspan="2" bgcolor="#FFFFFF" class="font">
- <input name="pwd" type="text" id="pwd" size="16"/></td>
- </tr>
- <tr>
- <td colspan="3" align="center" valign="top" bgcolor="#FFFFFF" class="font">
- <input type="submit" name="submit5" value="登录" />
-
- <input type="submit" name="reset" value="重置" /></td>
- </tr>
- </table>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td height="5"></td>
- </tr>
- </table>
- </form>
- <?php } ?>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td height="5"></td>
- </tr>
- </table>
- <?php if($_SESSION['pwd']<>''){
- echo "<table width='100%' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#B3B3B3'>
- <tr>
- <td align='center' bgcolor='#EBEBEB' class='font'>删除记录</td>
- </tr>
- </table>
- ";
- }?>
- <table width="100%" border="1" align="center" cellpadding="5" cellspacing="1" bgcolor="#B3B3B3">
- <?php
- $info = file_get_contents("info.txt");
- $info = rtrim($info,"@");
- if(strlen($info)>10){
- $column = explode("@@@",$info);
- foreach($column as $keys=>$values){
- $message = explode("%%",$values);
- ?>
- <tr>
- <?php if($_SESSION['pwd']<>''){
- echo "<td width=150><a href='javascript:del({$keys})'>[ 删除 ]</a><a href='?tj=edit&id={$keys}'>[ 修改 ]</a><!--a href='javascript:edit({$keys})'>[ 修改 ]</a--></td>";
- }?>
- <td width='130' align='right'><a href='<?php echo $message[1];?>' target='_blank'><?php echo $message[0];?></a></td>
- <td><a href='<?php echo $message[1];?>' target='_blank'><?php echo $message[1];?></a></td>
- </tr>
- <?php
- }
- }
- ?>
- </table>
- <table width="100%" height="" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC">
- <tr>
- <td align="center" bgcolor="#FFFFFF"><?php echo $fuwu_footer;?></td>
- </tr>
- </table>
- </body>
- </html>
复制代码
|
|