“博客迷”(BlogMi)源码阅读[4]

后台管理部分.index.php

1.检查COKKIES,判断是否已经登录.已登录由跳转到post.php

2.检查提交信息,判断帐户和密码是否正确.正确则跳转到post.php

3.一些页面布局和用户名和密码输入框还有提交按钮.

 1 <?php
 2 require_once dirname(dirname(__FILE__)).'/files/conf.php';
 3 if (isset($_COOKIE['mc_token'])) {//检查COOKIES确定是否已登录
 4   $token = $_COOKIE['mc_token'];
 5   if ($token == md5($mc_config['user_name'].'_'.$mc_config['user_pass'])) {
 6     Header("Location:post.php");
 7   }
 8 }
 9 if (isset($_POST['login'])) {//检查是否点击了提交按钮
10   if ($_POST['user'] == $mc_config['user_name'] 
11   && $_POST['pass'] == $mc_config['user_pass']) {
12     setcookie('mc_token', md5($mc_config['user_name'].'_'.$mc_config['user_pass']));
13     Header("Location:post.php");
14   }
15 }
16 ?>
17 <!DOCTYPE html>
18 <html>
19 <head>
20 <meta charset="UTF-8" />
21 <title>后台管理</title>
22 <style type="text/css">
23 * { font-family:"Microsoft YaHei",Arial; }
24 body { background:#f9f9f9; font-size:14px; }
25 #login_title { text-align:center; width:360px; margin:120px auto; margin-bottom:0px; font-size:32px; color:#333;  text-shadow: 0 2px 0 #FFFFFF;}
26 #login_form { width:360px; margin:0 auto; margin-top:20px; border:solid 1px #e0e0e0; background:#fff; border-radius:3px 3px 3px 3px;}
27 #login_form_box { padding:16px; }
28 #login_form .label { font-weight:bold; padding-bottom:6px; color:#333; }
29 #login_form .textbox input { border:none; padding:0; font-size:24px; width:312px; color:#333; }
30 #login_form .textbox { border:1px solid #e0e0e0; padding:6px; margin-bottom:20px; border-radius:3px 3px 3px 3px; }
31 #login_form .bottom { text-align:right; }
32 #login_form .button { padding:8px 16px; font-size:14px; }
33 </style>
34 </head>
35 <body>
36 <form action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
37   <div id="login_title">登录后台</div>
38   <div id="login_form">
39     <div id="login_form_box">
40       <div class="label">帐号</div>
41       <div class="textbox"><input name="user" type="text" /></div>
42       <div class="label">密码</div>
43       <div class="textbox"><input name="pass" type="password" /></div>
44       <div class="bottom"><input name="login" type="submit" value="登录" class="button" /></div>
45     </div>
46   </div>
47 </form>
48 </body>
49 </html>

 

posted @ 2016-04-16 18:03  夜梦多离殇  阅读(375)  评论(0编辑  收藏  举报