数据库
数据库名:article
第一张表article
第二张表
comment
第三张表enroll
第四张表essay
第五张表:user
文件建立列表
入口文件 index.js
<?php ini_set('display_errors','on'); //错误信息 define('ROOT',__DIR__); defined('CACHE_PATH') or define('CACHE_PATH',__DIR__.'/cache'); session_start(); spl_autoload_register('autoLoad'); //自动加载 function autoLoad($className){ $className = str_replace('\\','/',$className); $fileName = $_SERVER['DOCUMENT_ROOT'].'/'.$className.'.php'; include $fileName; } $requestScript = $_SERVER['SCRIPT_NAME']; if($requestScript != '/article/index.php'){ exit(); } // 获取请求url $requsetURL = $_SERVER['PATH_INFO']; $requsetURL = trim($requsetURL,'/'); $requsetArr = explode('/',$requsetURL); if( count($requsetArr) % 2 != 0){ echo '404 not found'; exit(); } //获取控制器 和 方法 $class_ = $requsetArr[0]; $method = $requsetArr[1]; //默认 //路由解析 $params = []; if(count($requsetArr) > 2){ $index = 2; while(true){ $key = $requsetArr[$index++]; $value = $requsetArr[$index++]; $params[$key] = $value; if($index >= count($requsetArr)){ break; } } } $class_ = 'article\\controller\\'.$class_; $obj = new $class_; if(!empty($_REQUEST)) { $params = array_merge($params,$_REQUEST); } // \article\controller\Request::setRequest($parms); echo $obj->$method($params); config.js文件 <?php return [ '__ROOT__'=>'/article', '__COVERROOT_'=>'/article/img/' ];
model 文件夹中
DataBase.php文件
<?php namespace article\model; class Database{ //连接数据库 private $pdo; static public $db = null; //构造函数 public function __construct(){ $this->geterr(); } //初始化$pdo public function getPdo(){ return $this->pdo; } //初始化$db 静态变量采用self::赋值 static public function getdb(){ if (self::$db == null){ self::$db =new Database(); } return self::$db; } //连接数据库 输出错误信息 public function geterr(){ try{ $this->pdo = new \PDO('mysql:dbname=article;host=localhost','root',''); }catch (PDOException $e){ echo '数据库连接失败' . $e->getMessage(); } //防止乱码 $this->pdo->query('set names utf8'); } //数据库查询方法 预处理 public function database_query($sql,$valueArray){ $qul = $this->pdo->prepare($sql); $index = 1; foreach ($valueArray as $value){ $qul -> bindValue($index, $value); $index++; } $qul -> execute(); //fetchAll — 返回一个包含结果集中所有行的数组 $arr = $qul-> fetchAll(\PDO::FETCH_ASSOC); return $arr; } //数据库操作 public function database_excute($sql, $valueArray){ $qul = $this->pdo->prepare($sql); $index = 1; foreach ($valueArray as $value){ $qul -> bindValue($index,$value); $index++; } $end = $qul -> execute(); return $end; } }
ArticleModel.php文件
<?php namespace article\model; class ArticleModel{ private $db; public function __construct(){ $this->db = Database::getdb(); } //查询文章标题 public function allTitle(){ $result = $this->db->database_query("SELECT `id`,`title` FROM `article`",[]); return $result; } //查询文章作者 public function allAuthor(){ $result = $this->db->database_query("SELECT `author` FROM `article`",[]); return $result; } //查询文章 public function allArticle(){ $result = $this->db->database_query("SELECT * FROM `article`",[]); return $result; } //根据ID查询单个文章信息 public function searchArticleById($parms){ $result = $this->db->database_query("SELECT * FROM `article` WHERE `article`.`id` = ?",$parms); return $result; } //模糊查询 public function searchArticleLike($parms){ $result = $this->db->database_query("SELECT * FROM `article` WHERE `article`.`title` LIKE '%' ? '%' ",$parms); if(empty($result)){ $result = $this->db->database_query("SELECT * FROM `article` WHERE `article`.`id` = 1",$parms); return $result; } return $result; } //删除文章 public function deleteArticle($parms){ $result = $this->db->database_excute('DELETE FROM `article` WHERE `article`.`id` = ? ',$parms); return $result; } //添加文章 public function addArticle($parms){ $result = $this->db->database_excute('INSERT INTO `article` (`title`, `type`, `author`, `cover`, `summary` , `content`, `time`) VALUES (?, ?, ?, ?, ?, ?, ?)',$parms); return $result; } //更新(有封面) public function editEssay($parms){ $result = $this->db->database_excute("UPDATE `article` SET `title` = ?, `type` = ?, `author` = ?, `cover` = ?, `summary` = ?,`content` = ?,`time` = ? WHERE `essay`.`id` = ?",$parms); return $result; } //更新(无封面) public function editEssay2($parms){ $result = $this->db->database_excute("UPDATE `article` SET `title` = ?, `type` = ?, `author` = ?, `summary` = ?,`content` = ?,`time` = ? WHERE `article`.`id` = ?",$parms); return $result; } //添加文章 public function addEssay($parms){ $result = $this->db->database_excute("INSERT INTO `article` (`title`, `type`, `author`, `cover`, `summary` , `content`, `time`) VALUES (?, ?, ?, ?, ?, ?, ?)",$parms); return $result; } //添加用户文章(无封面) public function addArticles($parms){ $result = $this->db->database_excute("INSERT INTO `article` (`title`, `type`, `author`, `summary` , `content`, `time`) VALUES ( ?, ?, ?, ?, ?, ?)",$parms); return $result; } public function getPdo(){ if (empty($this->db)){ return null; } return $this->db->getPdo(); } } CommentModel.php文件 <?php namespace article\model; class CommentModel{ private $db; function __construct() { $this->db = Database::getdb(); } /** * 根据文章的id查评论 * @param $parms * @return mixed */ public function selectCommentById($parms){ $result = $this->db->database_query("SELECT * FROM `comment` WHERE `comment`.`articleId` = ? ",$parms); return $result; } /* * 查询所有评论 * */ public function selectAllComment(){ $result = $this->db->database_query('SELECT * FROM `comment`',[]); return $result; } /** * 添加评论 * @param $parms * @return mixed */ public function addComment($parms){ $result = $this->db->database_excute("INSERT INTO `comment` (`articleId`, `visitorname`, `content`, `date`) VALUES (?, ?, ?, ?)",$parms); return $result; } //评论 public function addComments($parms){ $result = $this->db->database_excute("INSERT INTO `comment` (`visitorname`, `content`, `date`) VALUES (?, ?, ?)",$parms); return $result; } /** * 删除评论 * @param $parms * @return mixed */ public function deleteComment($parms){ $result = $this->db->database_excute("DELETE FROM `comment` WHERE `comment`.`id` = ? ",$parms); return $result; } }
EssayModel.php文件
<?php namespace article\model; class EssayModel{ private $db; public function __construct(){ $this->db = Database::getdb(); } //查询用户个人资料 public function User($parms){ $result = $this->db->database_query("SELECT * FROM `enroll` WHERE `enroll`.`id` = ?",$parms); return $result; } //添加文章 public function addEssay($parms){ $result = $this->db->database_excute('INSERT INTO `essay` (`title`, `type`, `author`, `summary` , `content`, `date`, `userId`) VALUES (?, ?, ?, ?, ?, ? ,?)',$parms); return $result; } //查询所以文章 public function allEssay(){ $result = $this->db->database_query('SELECT * FROM `essay`',[]); return$result; } //查询单个文章 public function searchEssayById($parms){ $result = $this->db->database_query('SELECT * FROM `essay` WHERE `essay`.`id` = ?',$parms); return $result; } //删除文章 public function deleteEssay($parms){ $result = $this->db->database_excute('DELETE FROM `essay` WHERE `essay`.`id` = ? ',$parms); return $result; } }
ForgetModel.php文件
<?php namespace article\model; include "Database.php"; class ForgetModel{ private $db; function __construct() { $this->db = new Database(); } //查询用户的密保问题 public function selectQuestionByname($parms){ $towArrRes = $this->db->database_query('SELECT question FROM `user` WHERE `user`.`name` = ?',$parms); return $towArrRes; } //判断密保是否正确 //@param $parms // @return bool public function find($parms){ $towArrRes = $this->db->database_query('SELECT * FROM `user` WHERE `user`.`name` = ? and `user`.`answer` = ?',$parms); if (count($towArrRes) == 0) return false; return true; } //重置密码 // @param $parms // @return bool public function resetPassword($parms){ $result = $this->db->database_excute("UPDATE `user` SET `password` = ? WHERE `user`.`name` = ?",$parms); if (count($result) == 0) return false; return true; } }
HomeModel.php文件
<?php namespace article\model; include "Database.php"; class HomeModel{ private $db; public function __construct(){ $this->db = Database::getdb(); } //根据name判断用户是否登录成功 public function search($parms){ $towArrRes = $this->db->database_query('SELECT * FROM `enroll` WHERE `enroll`.`name` = ? and `enroll`.`password` = ?',$parms); if (count($towArrRes) == 0) return false; return true; } //根据用户名字查询id public function searchId($parms){ $result = $this->db->database_query('SELECT `id` FROM `enroll` WHERE `name` = ?',$parms); $result = $result[0]; return $result; } }
RegisterModel.php文件
<?php namespace article\model; class RegisterModel{ private $db; public function __construct(){ $this->db = Database::getdb(); } //判断是否存在该用户 public function isUser($parms){ $towArrRes = $this->db->database_query('SELECT name FROM `enroll` WHERE `enroll`.`name` = ?',$parms); if (count($towArrRes)){ return true; }else return false; } //添加用户 public function addUser($parms){ $towArrRes = $this->db->database_excute('INSERT INTO `enroll` (`name`, `password`) VALUES ( ?, ?)',$parms); if (count($towArrRes)){ return true; }else return false; } //删除用户 public function deleteRegister($parms){ $result = $this->db->database_excute('DELETE FROM `enroll` WHERE `enroll`.`id` = ? ',$parms); return $result; } //查询所有用户信息 public function allUser(){ $result = $this->db->database_query('SELECT * FROM `enroll`',[]); return $result; } } UserModel.php文件 <?php namespace article\model; include "Database.php"; class UserModel{ private $db; public function __construct(){ $this->db = Database::getdb(); } //根据名字查用户资料 public function searchUserDataByName($parms){ $qul = $this->db->database_query('SELECT * FROM `user` WHERE `user`.`name` = ?',$parms); return $qul; } //根据name判断用户是否登录成功 // @param $parms // @return bool public function find($parms){ $towArrRes = $this->db->database_query('SELECT * FROM `user` WHERE `user`.`name` = ? and `user`.`password` = ?',$parms); if (count($towArrRes) == 0) return false; return true; } //查询用户资料 public function searchUserData(){ $towArrRes = $this->db->database_query('SELECT * FROM `user`',[]); return $towArrRes; } //根据id查询用户资料 public function searchUserDataById($parms){ $towArrRes = $this->db->database_query('SELECT * FROM `user` WHERE `user`.`id` = ?',$parms); return $towArrRes; } //根据id设置用户资料 public function setUserData($parms){ $result = $this->db->database_excute("UPDATE `user` SET `name` = ?, `sex` = ?, `birthday` = ?, WHERE `user`.`id` = ".$_SESSION['myid'],$parms); return $result; } }
view文件夹中
Add.php文件
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>article</title> <link rel="stylesheet" href="__ROOT__/css/Add.css"> <link rel="stylesheet" href="__ROOT__/css/public.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/backstage.js"></script> <script src="__ROOT__/js/public.js"></script> </head> <body> <header> <img src="__ROOT__/img/logo1.png" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <div class="clear"></div> <nav> </nav> <div class="text"> <a href="/article/index/Admin/index">文章评论管理</a><br> <a href="/article/index/Article/allInformation">文章详细列表</a><br> <a href="#">添加文章</a><br> <a href="/article/index/Essay/examineEssay">审核文章</a><br> <a href="/article/index/Register/enterUser">管理用户</a><br> <a href="/article/index.php/Login/loginOut">退出</a><br> </div> <div class="clear"></div> <div class="content" id="parts"> <form id='addform' enctype='multipart/form-data' class="form"> <img src="__ROOT__/img/center.jpg" alt="图片无法加载"> <div class="top"> <div class='form-row'><label>标题:</label> <input type='text' name='title' id='title'> </div> <div class='form-row'><label>类型:</label> <input type='text' name='type' id='type'> </div> <div class='form-row'><label>作者:</label> <input type='text' name='author' id='author'> </div> </div> <div class='form-row1'><label>封面:</label> <input type='file' name='cover[]' id='cover' multiple> </div> <div class="clear"></div> <div class='summary'> <div class='title'>简介</div> <textarea name='summary' id='summary'></textarea> </div> <div class='Content'> <div class='title'>内容</div> <textarea name='content' id='content' class='clearboth'></textarea> </div> <div class="clear"></div> </form> <button class='sub' id='add' >添加</button> </div> </body> </html>
backstage.php文件
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>article</title> <link rel="stylesheet" href="__ROOT__/css/backstage.css"> <link rel="stylesheet" href="__ROOT__/css/public.css"> <link rel="stylesheet" href="__ROOT__/css/bootstrap.css"> <link rel="stylesheet" href="__ROOT__/css/bootstrap.min.css"> <link rel="stylesheet" href="__ROOT__/css/bootstrap-theme.css"> <link rel="stylesheet" href="__ROOT__/css/bootstrap-theme.min.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/backstage.js"></script> <script src="__ROOT__/js/public.js"></script> <script src="__ROOT__/js/bootstrap.js"></script> <script src="__ROOT__/js/bootstrap.min.js"></script> <script src="__ROOT__/js/npm.js"></script> </head> <body> <header> <img src="__ROOT__/img/logo1.png" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <nav> </nav> <div class="text"> <a href="#">文章评论管理</a><br> <a href="/article/index/Article/allInformation">文章详细列表</a><br> <a href="/article/index/Article/addEssay">添加文章</a><br> <a href="/article/index/Essay/examineEssay">审核文章</a><br> <a href="/article/index/Register/enterUser">管理用户</a><br> <a href="/article/index.php/Login/loginOut">退出</a><br> </div> <div class="clear"></div> <div class="content"> <div id="myCarousel" class="carousel slide"> <!-- 轮播(Carousel)指标 --> <ol class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"></li> <li data-target="#myCarousel" data-slide-to="1"></li> <li data-target="#myCarousel" data-slide-to="2"></li> </ol> <!-- 轮播(Carousel)项目 --> <div class="carousel-inner"> <div class="item active"> <img src="__ROOT__/img/tg-2.jpg" alt="First slide"> </div> <div class="item"> <img src="__ROOT__/img/1.jpg" alt="Second slide"> </div> <div class="item"> <img src="__ROOT__/img/tg-3.jpg" alt="Third slide"> </div> </div> <!-- 轮播(Carousel)导航 --> <a class="carousel-control left" href="#myCarousel" data-slide="prev">‹ </a> <a class="carousel-control right" href="#myCarousel" data-slide="next">› </a> </div> <div class="pic"> <img src="__ROOT__/img/red.jpg" alt="red rainbow"> </div> <div class="clear"></div> <div class="photos"> <img src="__ROOT__/img/red.jpg" alt="伞" class="img1"> <img src="__ROOT__/img/lu.jpg" alt="路" class="img1"> <img src="__ROOT__/img/yuan.jpg" alt="天梯" class="img2"> <img src="__ROOT__/img/yue.jpg" alt="月" class="img3"> <img src="__ROOT__/img/tg-1.jpg" alt="玫瑰" class="img4"> </div> <div class="clear"></div> <div class="load"> <form class="form"> <table> <tr> <td style="width: 153.6px;height: 50.4px">文章编号</td> <td style="width: 153.6px;height: 50.4px">用户名</td> <td style="width: 537.6px;height: 50.4px">评论内容</td> <td style="width: 153.6px;height: 50.4px">操作</td> </tr> </table> </form> <?php foreach ($this->data as $value){ ?> <form action="/article/index/Comment/deleteComment" class="form"> <table> <tr> <td style="width: 153.6px;height: 50.4px"><?php echo $value['articleId']; ?></td> <td style="width: 153.6px;height: 50.4px"> <?php echo $value['visitorname']; ?></td> <td style="width: 537.6px;height: 50.4px"> <?php echo $value['content']; ?></td> <td style="width: 153.6px;height: 50.4px"> <button><input type="hidden" name="id" value="<?php echo $value['id'];?>">删除</button></td> </tr> </table> </form> <?php }?> </div> </div> </body> </html>
conversation.php文件
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <link rel="stylesheet" href="__ROOT__/css/conversation.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/jquery.imgbox.pack.js"></script> <script src="__ROOT__/js/conversation.js"></script> </head> <body> <header> <img src="__ROOT__/img/logo1.png" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <nav> </nav> <div class="text"> <a href="#">话题社</a><br> </div> <div class="clear"></div> <div class="content"> <div class="test"> <div class="conver"> <?php foreach ($this->date as $key => $value) { if ($value['articleId'] == null){ if ($value['visitorname'] == $_SESSION['name']){ echo '<div class="tm"><h2>' . $value['visitorname'] . '</h2><p class="date">'.$value['date'] .'</p><div class="cont"><p>'.$value['content'].'</div></div><div class="clear"></p></div>'; }else{ echo '<div class="tg"><h2>' . $value['visitorname'] . '</h2><p class="date">'.$value['date'] .'</p><div class="cont"><p>'.$value['content'].'</p></div></div>'; } } } ?> <form class="form"> <input type="hidden" value="<?php echo $_SESSION['name']?>" id="visitorname"> <textarea type="text" placeholder="最多输入15个字哦" name="content" id="publish-content" maxlength="13" onkeydown="if(event.keyCode==13){com();}"></textarea><br> </form> <button class="button" id="com" onclick="com()">提交</button> <div class="clear"></div> </div> </div> </div> <script src="__ROOT__/js/backstage.js"></script> </body> </html>
Details.php文件
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="__ROOT__/css/public.css"> <link rel="stylesheet" href="__ROOT__/css/List.css"> <link rel="stylesheet" href="__ROOT__/css/Details.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/Details.js"></script> <script src="__ROOT__/js/jquery.imgbox.pack.js"></script> <title>Details</title> </head> <body> <header> <img src="__ROOT__/img/logo.jpg" alt="图片无法加载"> <form action="__ROOT__/controller/Article/SearchArticle" method="post"> <input type="text" placeholder="请输入关键字" class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <div class="name"> <ul> <li><a href="/article/index/Admin/index">首页</a></li> <li><a href="/article/index/Article/allInformation">文章</a></li> <li><a href="/article/index/Article/addEssay">添加</a></li> </ul> </div> <div class="clear"></div> <div class="content"> <div class="essay"> <div class="local">位置:美文网 >原创美文 >文章内容</div> <h1><?php foreach ($this->date as $value){ echo $value['title']; } ?> </h1> <h2>类型: <?php echo $value['type'];?> 作者: <?php echo $value['author']; ?> 时间: <?php echo $value['time'] ?> </h2> <p> 简介:<?php echo $value['summary']?> </p> <p> <?php echo $value['content']?> </p> </div> </div> </body> </html>
Edit.php文件
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <link rel="stylesheet" href="__ROOT__/css/public.css"> <link rel="stylesheet" href="__ROOT__/css/Edit.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/backstage.js"></script> <script src="__ROOT__/js/public.js"></script> </head> <body> <header> <img src="__ROOT__/img/logo1.png" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <nav> </nav> <div class="text"> <a href="/article/index/Admin/index">文章评论管理</a><br> <a href="/article/index/Article/allInformation">文章详细列表</a><br> <a href="/article/index/Article/addEssay">添加文章</a><br> <a href="/article/index/Essay/examineEssay">审核文章</a><br> <a href="/article/index/Register/enterUser">管理用户</a><br> <a href="/article/index.php/Login/loginOut">退出</a><br> </div> <div class="clear"></div> <div class="content" id="parts"> <form id='addform' class="form"> <img src="__ROOT__/img/center.jpg" alt="图片无法加载"> <div class="top"> <div class='form-row'><label>标题:</label> <input type='text' name='title' id='title' value="<?php foreach ($this->date as $value){echo $value['title'];} ?>"> </div> <div class='form-row'><label>类型:</label> <input type='text' name='type' id='type' value="<?php foreach ($this->date as $value){echo $value['type'];} ?>"> </div> <div class='form-row'><label>作者:</label> <input type='text' name='author' id='author' value="<?php foreach ($this->date as $value){echo $value['author'];} ?>"> </div> </div> <div class='form-row1'><label>封面:</label> <input type='file' name='cover[]' id='cover'> </div> <div class="clear"></div> <div class='summary'> <div class='title'>简介</div> <textarea name='summary' id='summary'><?php foreach ($this->date as $value){echo $value['summary'];} ?></textarea> </div> <div class='Content'> <div class='title'>内容</div> <textarea name='content' id='content'> <?php foreach ($this->date as $value){echo $value['content'];} ?> </textarea> </div> <div class="clear"></div> </form> <button class='sub' id='edit' >修改</button> </div> </body> </html>
examineEssay.php文件
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="__ROOT__/css/public.css"> <link rel="stylesheet" href="__ROOT__/css/examineEssay.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/examineEssay.js"></script> <title>examineEssay</title> </head> <body> <header> <img src="__ROOT__/img/logo1.png" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <nav> </nav> <div class="text"> <a href="/article/index/Admin/index">文章评论管理</a><br> <a href="/article/index/Article/allInformation">文章详细列表</a><br> <a href="/article/index/Article/addEssay">添加文章</a><br> <a href="#">审核文章</a><br> <a href="/article/index/Register/enterUser">管理用户</a><br> <a href="/article/index.php/Login/loginOut">退出</a><br> </div> <div class="clear"></div> <div class="content"> <div class="list" id="parts"> <h3>文章详细列表</h3> <table> <tr> <td style="width: 100px;height: 50px">编号</td> <td style="width: 200px;height: 50px">标题</td> <td style="width: 150px;height: 50px">类型</td> <td style="width: 200px;height: 50px">作者</td> <td style="width: 100px;height: 50px">作者id</td> <td style="width: 200px;height: 50px">操作</td> </tr> <?php foreach($this->date as $v) { echo "<tr> <td style='height: 50px'>{$v['id']}</td> <td>{$v['title']}</td> <td>{$v['type']}</td> <td>{$v['author']}</td> <td>{$v['userId']}</td> <td> <a href='/article/index/Essay/searchEssayById?id={$v['id']}' class='page-operate'>详情</a> <a href='javascript:deleteEssay({$v['id']});'>删除</a> <a href='javascript:addArticle({$v['id']});'>通过</a> </td> </tr>"; } ?> </table> </div> </body> </html>
ForgetPassward.php
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>forget password</title> <link rel="stylesheet" href="__ROOT__/css/forgetPassword.css"> <link rel="stylesheet" href="__ROOT__/css/public.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/forgetPassword.js"></script> </head> <body> <div class="dialog" id="dialog"> <div class="dialog-title"> 忘记密码 <a class="dialog-closebutton" href="/article/index.php/Login/login" style="background: url(../img/close_def.png) no-repeat;"></a> </div> <div class="dialog-content" id="dialog-content"> <input id="name" class="input" type="text" placeholder="用户名" style="background: url(../img/input_username.png) no-repeat 0px -1px;" /> <input type="submit" id="submit" class="submit" value="确认"> </div> </div> </body> </html>
homePage.php
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>homepage</title> <link rel="stylesheet" href="__ROOT__/css/public.css"> <link rel="stylesheet" href="__ROOT__/css/homePage.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/homePage.js"></script> <script src="__ROOT__/js/jquery.imgbox.pack.js"></script> </head> <body> <div class="content"> <header> <h1>美文网</h1> </header> <div class="dialog" id="dialog"> <div class="dialog-title"> 登录 <a class="dialog-closebutton" href="/article/index/HomeLogin/Login" style= "background: url(__ROOT__/img/close_def.png) no-repeat;"></a> </div> <div class="dialog-content"> <input id="login-name" class="input" type="text" placeholder="用户名" style= "background: url('__ROOT__/img/input_username.png') no-repeat 0px -1px;" /> <input id="login-password" class="input" type="password" placeholder="密码" style="background: url(__ROOT__/img/input_password.png) no-repeat 0px -1px; "/> <a class="register" href="/article/index/Register/showRegister">注册</a> <input type="submit" id="login-submit" class="submit" value="登录"> </div> </div> <div class="clear"></div> <div class="fly"> <img src="__ROOT__/img/fly.gif" alt="图片无法加载"> </div> </div> </body> </html>
List.php
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>List</title> <link rel="stylesheet" href="__ROOT__/css/public.css"> <link rel="stylesheet" href="__ROOT__/css/List.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/List.js"></script> <script src="__ROOT__/js/jquery.imgbox.pack.js"></script> </head> <body> <header> <img src="__ROOT__/img/logo.jpg" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchUserArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <div class="name"> <ul> <li><a href="#">首页</a></li> <li><a href="__ROOT__/index/Comment/selectComment" target="_blank">话题社</a></li> <li><a href="__ROOT__/index/Essay/enterSpace" target="_blank">个人空间</a></li> <li><a href="/article/index.php/HomeLogin/loginOut">退出</a></li> </ul> </div> <div class="clear"></div> <div class="content"> <div class="picture"> <p>惊扰了桃花,掠去了芳华</p> </div> <div class="text"> <h3>念在天涯,心在咫尺</h3> <p> <?php foreach ($this->date as $key => $value){ if ($key < 4){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } } ?> </p> <h3>别样心情,回首时光</h3> <p> <?php foreach ($this->date as $key => $value){ if ($key >= 4 && $key<=8){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } } ?> </p> </div> <div class="author"> <h3>作家排行榜</h3> <p> <?php foreach($this->data as $key => $value){ if ($key <=8){ echo $value['author'].'<br>'; } } ?> </p> </div> <div class="clear"></div> <div class="photo"> <ul> <li> <img src="__ROOT__/img/1.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<1){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/2.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<2 && $key>0){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/3.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<3 && $key>1){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/4.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<4 && $key>2){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/5.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<5 && $key>3){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/6.jpeg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<6 && $key>4){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/7.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<7 && $key>5){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/8.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<8 && $key>6){ echo '<a href="/article/index/Article/SearchIdArticle?id= '.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/9.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<9 && $key>7){ echo '<a href="/article/index/Article/SearchIdArticle?id='.($value['id']).'">' .$value['title'].'</a>'.'<br>'; } }?></p> </li> <li> <img src="__ROOT__/img/10.jpg" alt="图片无法加载"> <p><?php foreach ($this->date as $key => $value){ if ($key<10 && $key>8){ echo '<a href="/article/index/Article/SearchIdArticle? id='.($value['id']).'">'.$value['title'].'</a>'.'<br>'; } }?></p> </li> </ul> </div> <div class="ranking"> <h3>阅读排行</h3> <p> <?php foreach ($this->date as $key => $value){ if($key <6 ){ echo '<a target="_blank" href="/article/index/Article/SearchIdArticle?id='.($value['id']).'">'.$value['title'].'</a>'.'<br>';} } ?> </p> </div> <div class="clear"></div> <div class="new"> <h4 class="new-essay">最新文章</h4> <div id="new-essay"> <p><?php foreach ($this->date as $key => $value){ if($key <12 ){ echo '<a target="_blank" href="/article/index/Article/SearchIdArticle?id='.($value['id']).'">'.$value['title'].'</a>'.'<br>';} } ?></p> </div> </div> <div class="hot"> <h4 class="hot-essay">最热文章</h4> <div id="hot-essay"> <p> <?php foreach ($this->date as $key => $value){ if($key <6 ){ echo '<a target="_blank" href="/article/index/Article/SearchIdArticle?id='.($value['id']).'">'.$value['title'].'</a>'.'<br>';} } ?> </p> </div> </div> <div class="reader"> <h3>小编推荐</h3> <p> <?php foreach ($this->date as $key => $value){ if($key <6 ){ echo '<a target="_blank" href="/article/index/Article/SearchIdArticle?id='.($value['id']).'">'.$value['title'].'</a>'.'<br>';} } ?> </p> </div> <div class="clear"></div> </div> </body> </html>
Login.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>article</title> <link rel="stylesheet" href="__ROOT__/css/login.css"> <link rel="stylesheet" href="__ROOT__/css/public.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/login.js"></script> </head> <body> <div class="dialog" id="dialog"> <div class="dialog-title"> 登录 <a class="dialog-closebutton" href="/article/index.php/Login/login" style="background: url(__ROOT__/img/close_def.png) no-repeat;"></a> </div> <div class="dialog-content"> <input id="login-name" class="input" type="text" placeholder="用户名" style="background: url('__ROOT__/img/input_username.png') no-repeat 0px -1px;" /> <input id="login-password" class="input" type="password" placeholder="密码" style="background: url(__ROOT__/img/input_password.png) no-repeat 0px -1px; "/> <div class="code-div clearboth"> <input id="login-code" class="code" type="text" placeholder="验证码"/> <img id="code-img" class="code-img" src="/article/index.php/Login/code" alt="看不清楚,换一张" onclick="javascript:newgdcode(this,this.src);"> </div> <a class="forget" href="/article/index.php/ForgetPassword/showForgetPassword">忘记密码</a> <input type="submit" id="login-submit" class="submit" value="登录"> </div> </div> </body> </html>
register.php
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>register</title> <link rel="stylesheet" href="__ROOT__/css/homePage.css"> <link rel="stylesheet" href="__ROOT__/css/register.css"> <link rel="stylesheet" href="__ROOT__/css/public.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/register.js"></script> </head> <body> <div class="content"> <header> <h1>美文网</h1> </header> <div class="dialog" id="dialog"> <div class="dialog-title"> 注册 <a class="dialog-closebutton" href="/article/index/HomeLogin/Login" style="background: url(__ROOT__/img/close_def.png) no-repeat;"></a> </div> <div class="dialog-content"> <input id="name" class="input" type="text" placeholder="用户名" style="background: url('__ROOT__/img/input_username.png') no-repeat 0px -1px;" /> <input id="password" class="input" type="password" placeholder="密码" style="background: url(__ROOT__/img/input_password.png) no-repeat 0px -1px; "/> <div class="return"><a href="/article/index/HomeLogin/login">返回登录</a></div> <input type="submit" id="login-submit" class="submit" value="注册"> </div> </div> <div class="clear"></div> <div class="fly"> <img src="__ROOT__/img/fly.gif" alt="图片无法加载"> </div> </div> </body> </html>
selectQuestionByname.php
<div> <lable class='text'>姓名:<span id="name" style="display: inline-block"><?php echo $name; ?></span></lable> <p class='text' id='name'></p> </div> <div> <lable class='text'>密保问题:</lable> <p class='text'><?php echo $question; ?></p> </div> <input id='answer' class='input' type='text' placeholder='密保答案'/> <input id='new-password' class='input' type='password' placeholder='新密码'/> <input id='confirm-password' class='input' type='password' placeholder='确认密码'/> <input type='submit' id='submit2' class='submit' value='确认'> User.php <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="__ROOT__/css/User.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/User.js"></script> <title>user</title> </head> <body> <header> <img src="__ROOT__/img/logo1.png" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <nav> </nav> <div class="text"> <a href="/article/index/Admin/index">文章评论管理</a><br> <a href="/article/index/Article/allInformation">文章详细列表</a><br> <a href="/article/index/Article/addEssay">添加文章</a><br> <a href="/article/index/Essay/examineEssay">审核文章</a><br> <a href="/article/index/Register/enterUser">管理用户</a><br> <a href="/article/index.php/Login/loginOut">退出</a><br> </div> <div class="clear"></div> <div class="content"> <div class="list" id="parts"> <h3>文章详细列表</h3> <table> <tr> <td>编号</td> <td>用户名</td> <td>密码</td> <td>操作</td> </tr> <?php foreach($this->date as $v) { echo "<tr> <td>{$v['id']}</td> <td>{$v['name']}</td> <td>{$v['password']}</td> <td> <a href='javascript:deleteUser({$v['id']});'>删除</a> </td> </tr>"; } ?> </table> </div> </div> </body> </html>
UserDetails.php
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="__ROOT__/css/public.css"> <link rel="stylesheet" href="__ROOT__/css/List.css"> <link rel="stylesheet" href="__ROOT__/css/Details.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/jquery.imgbox.pack.js"></script> <title>Details</title> </head> <body> <header> <img src="__ROOT__/img/logo.jpg" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchUserArticle" method="post"> <input type="text" placeholder="请输入关键字" class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <div class="name"> <ul> <li>美文网</li> <li>美文</li> </ul> </div> <div class="clear"></div> <div class="content"> <div class="essay"> <div class="local">位置:美文网 >原创美文 >文章内容</div> <h1><?php foreach ($this->date as $key => $value){ echo $value['title'].'<br>'; } ?> </h1> <h2>类型: <?php echo $value['type'];?> 作者: <?php echo $value['author']; ?> 时间: <?php echo $value['time'] ?> </h2> <p> 简介:<?php echo $value['summary']?> </p> <p> <?php echo $value['content']?> </p> <div class="comment"> <div class="usercomment"> <p><?php foreach ($this->data as $v){ if ($v['articleId'] == $value['id']) echo '<p>昵称:'.$v['visitorname'].'</p><br> <p>评论内容:'.$v['content'].'</p><br><p>'.$v['date'].'</p><hr>'; } ?></p> </div> <p>评论:</p> <form > <input type="hidden" value="<?php echo $value['id']?>" id="id"> <input type="hidden" value="<?php echo $_SESSION['name']?>" id="visitorname"> <textarea type="text" placeholder="用心评论,文明发言" name="content" id="publish-content"></textarea><br> </form> <button class="button" id="com">提交</button> </div> </div> </div> <script src="__ROOT__/js/Details.js"></script> </body> </html>
userEssay.php
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="__ROOT__/css/userEssay.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/examineEssay.js"></script> <title>userEssay</title> </head> <body> <header> <img src="__ROOT__/img/logo1.png" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <nav> </nav> <div class="text"> <a href="/article/index/Admin/index">文章评论管理</a><br> <a href="/article/index/Article/allInformation">文章详细列表</a><br> <a href="/article/index/Article/addEssay">添加文章</a><br> <a href="/article/index/Essay/examineEssay">审核文章</a><br> <a href="/article/index/Register/enterUser">管理用户</a><br> <a href="/article/index.php/Login/loginOut">退出</a><br> </div> <div class="clear"></div> <div class="content"> <div class="test"> <h2><?php foreach ($this->date as $value){ echo $value['title']; } ?></h2> <p>作者:<?php echo $value['author']; ?></p> <p>类型:<?php echo $value['type']; ?></p> <p>简介:<?php echo $value['summary']; ?></p> <div class="con"> <p>内容:<?php echo $value['content']; ?></p> </div> </div> </div> </body> </html>
UserList.php
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>article</title> <link rel="stylesheet" href="__ROOT__/css/public.css"> <link rel="stylesheet" href="__ROOT__/css/UserList.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/backstage.js"></script> <script src="__ROOT__/js/public.js"></script> </head> <body> <header> <img src="__ROOT__/img/logo1.png" alt="图片无法加载"> <form action="__ROOT__/index/Article/SearchArticle" method="post"> <input type="text" placeholder=请输入关键字 class="sub" name="value"> <button class="submit">搜索</button> </form> </header> <nav> </nav> <div class="text"> <a href="/article/index/Admin/index">文章评论管理</a><br> <a href="#">文章详细列表</a><br> <a href="/article/index/Article/addEssay">添加文章</a><br> <a href="/article/index/Essay/examineEssay">审核文章</a><br> <a href="/article/index/Register/enterUser">管理用户</a><br> <a href="/article/index.php/Login/loginOut">退出</a><br> </div> <div class="clear"></div> <div class="content"> <div class="list" id="parts"> <h3>文章详细列表</h3> <table> <tr> <td style="width: 80px;height: 50px">编号</td> <td style="width: 195px;height: 50px">标题</td> <td style="width: 80px;height: 50px">类型</td> <td style="width: 120px;height: 50px">作者</td> <td>浏览</td> <td>修改时间</td> <td>操作</td> </tr> <?php foreach($this->date as $v) { echo "<tr> <td style=\"width: 80px;height: 50px\">{$v['id']}</td> <td>{$v['title']}</td> <td>{$v['type']}</td> <td>{$v['author']}</td> <td>{$v['browse']}</td> <td>{$v['time']}</td> <td> <a href='/article/index/Article/enterEditArticle?id={$v['id']}' class='page-operate'>编辑 </a> <a href='javascript:deleteArticle({$v['id']});'>删除</a> </td> </tr>"; } ?> </table> <a class="login" href="/article/index/Login/loginOut">退出</a><br> </div> </div> </body> </html>
UserSpace.php
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="__ROOT__/css/UserSpace.css"> <script src="__ROOT__/js/jquery-3.2.1.min.js"></script> <script src="__ROOT__/js/UserSpace.js"></script> <title>UserSpace</title> </head> <body> <header class="header" id="header"> <h1><?php foreach ($this->date as $value){ echo $value['name']; } ?>的空间</h1> <nav id="nav"> <h2>个人空间</h2> </nav> </header> <div class="content" id="content"> <div class="self" id="self"> <h4 id="h1">个人资料</h4> <p><button type="button" id="button_A">换肤</button></p> <img src="__ROOT__/img/red.jpg" alt="red rainbow" id="img_A"> <p>用户名:<?php echo $value['name']; ?></p> <p>发表文章</p> </div> <div class="add" id="parts"> <h4 id="h4">发表文章</h4> <form id='addform' enctype='multipart/form-data'> <div class="top"> <div class='form-row'><label>标题:</label> <input type='text' name='title' id='title'> </div> <div class='form-row'><label>类型:</label> <input type='text' name='type' id='type'> </div> </div> <div class="clear"></div> <div class='summary'> <div class='title'>简介</div> <textarea name='summary' id='summary'></textarea> </div> <div class='Content'> <div class='title'>内容</div> <textarea name='content' id='content'></textarea> </div> <div class="clear"></div> </form> <button class='sub' id='add' >添加</button> </div> </div> <script> function img() { var img = document.getElementById("img_A"); var i = 0; var imgArr = ["__ROOT__/img/yue.jpg","__ROOT__/img/yuan.jpg","__ROOT__/img/red.jpg"]; img.addEventListener("click", function () { img.src = imgArr[i]; i++; if (i == 3){ i = 0; } }) } img(); function logo() { var btn = document.getElementById("button_A"); var self = document.getElementById("self"); var parts = document.getElementById("parts"); var nav = document.getElementById("nav"); var h1 = document.getElementById("h1"); var h4 = document.getElementById("h4"); var i = 0; var imgArr = ["__ROOT__/img/xiao.jpg","__ROOT__/img/top2.jpg", "__ROOT__/img/top3.jpg","__ROOT__/img/top4.jpg","__ROOT__/img/top.jpg"]; var bacArr = ["#fff","#fff","#fff","#fff","#2d2d2d"]; var bgcArr = ["#1F2267","#A58C5C","#B16B6A","rgb(114, 33, 128)","#2d2d2d"]; var bgArr = ["#E4E5EE","#EEEBE2","#F7EDED","rgb(245, 211, 244)","#5f5959"]; btn.addEventListener("click", function () { document.body.style.backgroundImage = "url('"+imgArr[i]+"')"; self.style.background = bacArr[i]; parts.style.background = bacArr[i]; nav.style.background = bgcArr[i]; h1.style.background = bgArr[i]; h4.style.background = bgArr[i]; i++; if (i == 5) { i = 0; } }); } logo(); </script> </body> </html>
controller文件夹中
Admin.php
<?php namespace article\controller; class Admin extends Controller{ private $userModel = null; private $commentModel = null; function __construct(){ $this->userModel = new \article\model\UserModel(); $this->commentModel = new \article\model\CommentModel(); } //判断是否显示页面(首页) public function index(){ if (Login::isOnLine()){ $result = $this->userModel->searchUserData(); if (count($result) !== 0){ $this->date = $result[0]; $result1 = $this->commentModel->selectAllComment(); if (count($result1)){ $this->data = $result1; return $this->show('backstage'); }else{ return '查询失败'; } } }else{ return $this->show('Login'); } } //进入首页 //@return mixed|string public function homePage(){ if(!isset($_SESSION['id'])){ header('Location: /article/index.php/HomeLogin/login'); } $result = $this->userModel->searchUserData(); if (count($result) !== 0){ $this->date = $result[0]; return $this->show('homePage'); }else{ return '站点不存在!'; } } }
Article.php
<?php namespace article\controller; class Article extends Controller { private $ArticleModel; private $essayModel; private $commentModel; public function __construct(){ $this->ArticleModel = new \article\model\ArticleModel(); $this->essayModel = new \article\model\EssayModel(); $this->commentModel = new \article\model\CommentModel(); } //判断是否显示列表页 public function enterList(){ if(!isset($_SESSION['id'])){ header('Location: /article/index/HomeLogin/login'); } $result = $this->ArticleModel->allTitle(); if (count($result) !== 0){ $this->date = $result; $result1 = $this->ArticleModel->allAuthor(); if (count($result1) !== 0){ $this->data = $result1; return $this->show('List'); } }else{ return $this->badJson('站点不存在!'); } } //管理员查询文章 public function SearchArticle($parms){ if(!isset($_SESSION['myid'])){ header('Location: /article/index.php/Login/login'); } $total = $this->ArticleModel->searchArticleLike($parms); if (count($total)){ $this->date = $total; $content = $this->show('Details'); return $content; }else{ return $this->badJson('查询失败'); } } //用户查询文章 public function SearchUserArticle($parms){ if(!isset($_SESSION['id'])){ header('Location: /article/index.php/HomeLogin/login'); } $result = $this->commentModel->selectAllComment(); if (!empty($result)){ $this->data = $result; $total = $this->ArticleModel->searchArticleLike($parms); if (count($total)){ $this->date = $total; $content = $this->show('UserDetails'); return $content; }else{ return $this->badJson('查询失败'); } }else{ return $this->badJson('查询失败'); } } //用户点击查询文章 public function SearchIdArticle($parms){ if(!isset($_SESSION['id'])){ header('Location: /article/index.php/HomeLogin/login'); } $result = $this->commentModel->selectAllComment(); if (!empty($result)){ $this->data = $result; $total = $this->ArticleModel->searchArticleById($parms); if (count($total)){ $this->date = $total; $content = $this->show('UserDetails'); return $content; }else{ return $this->badJson('查询失败'); } }else{ return $this->badJson('查询失败'); } } //删除文章 public function deleteArticle($parms){ $id = $parms['id']; $rwes = $this->ArticleModel->searchArticleById([intval($id)]); if (count($rwes)){ $cover = $rwes[0]['cover']; $file_path = ROOT.'\img\\'.$cover; $lost = null; $pdo = $this->ArticleModel->getPdo(); $pdo->beginTransaction(); $result = $this->ArticleModel->deleteArticle([intval($id)]); if ($result){ if (file_exists($file_path) && is_file($file_path)){ $lost = unlink($file_path); } if($lost){ $pdo->rollBack(); return $this->goodJson(null,'删除成功'); }else{ $pdo->commit(); return $this->badJson('本地删除成功!'); } }else{ return $this->badJson('本地删除失败'); } }else{ return $this->badJson('文章不存在'.$parms['id']); } } //查询文章所有信息 public function allInformation(){ if(!isset($_SESSION['myid'])){ header('Location: /article/index.php/Login/login'); } $result = $this->ArticleModel->allArticle(); if (count($result)){ $this->date = $result; return $this->show('UserList'); }else{ return $this->badJson('查询失败!'); } } //进入编辑页 public function enterEditArticle($parms){ if(!isset($_SESSION['myid'])){ header('Location: /article/index.php/Login/login'); } $total = $this->ArticleModel->searchArticleById($parms); if (count($total)){ $_SESSION['essayid'] = $parms['id']; $this->date = $total; $content = $this->show('Edit'); return $content; }else{ return '编辑失败!'; } } //进入添加文章页面 public function addEssay(){ if(!isset($_SESSION['myid'])){ header('Location: /article/index.php/Login/login'); } $content = $this->show('Add'); return $content; } //添加文章 public function addArticle($parms){ $title = trim($parms['title']); $type = trim($parms['type']); if(empty($title)){ return $this->badJson('文章标题为空'); } else if(empty($type)){ return $this->badJson('文章类型为空'); } $author = trim($parms['author']); if(empty($author)){ return $this->badJson('文章作者为空'); } $summary = trim($parms['summary']); if(empty($summary)){ return $this->badJson('文章简介为空'); } $content = trim($parms['content']); if(empty($content)){ return $this->badJson('文章内容为空'); } $up = new \article\common\FileUpload(); $up->set('path','./img'); $uploadresult = $up->upload('cover'); if($uploadresult){ $fileName = $up->getFileName(); foreach ($fileName as $key => $value){ $time = date('Y-m-d H:i:s'); $resultOfAddEssay = $this->ArticleModel->addEssay([$title,$type,$author,$value,$summary,$content,$time]); if($resultOfAddEssay){ return $this->goodJson('',"文章添加成功"); }else{ return $this->badJson("文章添加失败".$time); } } }else{ $errors = $up->getErrorMsg(); return $this->badJson($errors); } } //添加用户文章 public function addArticles($parms){ $result1 = $this->essayModel->searchEssayById($parms); if (count($result1)){ $title = $result1[0]['title']; $type = $result1[0]['type']; $author = $result1[0]['author']; $summary = $result1[0]['summary']; $content = $result1[0]['content']; $time = date('Y-m-d H:i:s'); $result = $this->ArticleModel->addArticles([$title,$type,$author,$summary,$content,$time]); if ($result){ return $this->goodJson('','添加成功'); }else{ return $this->badJson('添加失败'); } } } /** *编辑文章 * @param $parms * @return string */ public function editArticles($parms){ $title = trim($parms['title']); if(empty($title)){ return $this->badJson('文章标题为空'); } $type = trim($parms['type']); if(empty($type)){ return $this->badJson('文章类型为空'); } $author = trim($parms['author']); if(empty($author)){ return $this->badJson('文章作者为空'); } $summary = trim($parms['summary']); if(empty($summary)){ return $this->badJson('文章简介为空'); } $content = trim($parms['content']); if(empty($content)){ return $this->badJson('文章内容为空'); } $up = new \article\common\FileUpload(); $up->set('path','./img'); $uploadresult = $up->upload('cover'); if($uploadresult){ $fileName = $up->getFileName(); foreach ($fileName as $key => $value){ $time = date('Y-m-d H:i:s'); $resultOfeditEssay = $this->ArticleModel->editEssay( [$title,$type,$author,$value,$summary,$content,$time,$_SESSION['essayid']]); if($resultOfeditEssay){ return $this->goodJson('','文章修改成功'); }else{ return $this->badJson('文章修改失败!'); } } }else{ $errors = $up->getErrorMsg(); $errorsarr = explode('/',$errors[0]); if($errorsarr[1] == '4'){ $time = date('Y-m-d H:i:s'); $resultOfeditEssay = $this->ArticleModel->editEssay2( [$title,$type,$author,$summary,$content,$time,$_SESSION['essayid']]); if($resultOfeditEssay){ return $this->goodJson('','文章修改成功'); }else{ return $this->badJson('文章修改失败'); } } return $this->badJson($errors); } } }
Comment.php
<?php namespace article\controller; use article\controller\Controller; class Comment extends Controller{ private $commentModel = null; public function __construct() { $this->commentModel = new \article\model\CommentModel(); } /** * 查询所有评论 * @param $parms * @return string */ public function selectComment(){ if(!isset($_SESSION['id'])){ header('Location: /article/index/HomeLogin/login'); } $result = $this->commentModel->selectAllComment(); if (count($result)){ $this->date = $result; $content = $this->show('conversation'); return $content; }else{ return '查询失败'; } } /** * 添加评论 * @param $parms * @return string */ public function addComment($parms){ if (empty($parms['id'])) return $this->badJson('参数无效'); if (empty($parms['visitorname'])) return $this->badJson('昵称不能为空'); if(empty($parms['content'])) return $this->badJson('评论不能为空!'); $content = $this->removeXSS($parms['content']); $time = date('Y-m-d H:i:s'); $result = $this->commentModel->addComment([$parms['id'],$parms['visitorname'],$content,$time]); if($result) return $this->goodJson('','评论成功'); else return $this->badJson('评论失败'); } //评论上墙 public function addComments($parms){ if (empty($parms['visitorname'])) return $this->badJson('昵称不能为空'); if(empty($parms['content'])) return $this->badJson('评论不能为空!'); $content = $this->removeXSS($parms['content']); $time = date('Y-m-d H:i:s'); $result = $this->commentModel->addComments([$parms['visitorname'],$content,$time]); if($result) return $this->goodJson('','评论成功'); else return $this->badJson('评论失败'); } /** * 删除评论 * @param $parms * @return string */ public function deleteComment($parms){ $result = $this->commentModel->deleteComment($parms); if ($result){ return '<script> window.location.replace("Javascript:window.history.go(-1)");alert("删除成功");</script>'; }else{ return '<script> alert("删除失败")</script>'; } } } <?php namespace article\controller; use article\controller\Controller; class Comment extends Controller{ private $commentModel = null; public function __construct() { $this->commentModel = new \article\model\CommentModel(); } /** * 查询所有评论 * @param $parms * @return string */ public function selectComment(){ if(!isset($_SESSION['id'])){ header('Location: /article/index/HomeLogin/login'); } $result = $this->commentModel->selectAllComment(); if (count($result)){ $this->date = $result; $content = $this->show('conversation'); return $content; }else{ return '查询失败'; } } /** * 添加评论 * @param $parms * @return string */ public function addComment($parms){ if (empty($parms['id'])) return $this->badJson('参数无效'); if (empty($parms['visitorname'])) return $this->badJson('昵称不能为空'); if(empty($parms['content'])) return $this->badJson('评论不能为空!'); $content = $this->removeXSS($parms['content']); $time = date('Y-m-d H:i:s'); $result = $this->commentModel->addComment([$parms['id'],$parms['visitorname'],$content,$time]); if($result) return $this->goodJson('','评论成功'); else return $this->badJson('评论失败'); } //评论上墙 public function addComments($parms){ if (empty($parms['visitorname'])) return $this->badJson('昵称不能为空'); if(empty($parms['content'])) return $this->badJson('评论不能为空!'); $content = $this->removeXSS($parms['content']); $time = date('Y-m-d H:i:s'); $result = $this->commentModel->addComments([$parms['visitorname'],$content,$time]); if($result) return $this->goodJson('','评论成功'); else return $this->badJson('评论失败'); } /** * 删除评论 * @param $parms * @return string */ public function deleteComment($parms){ $result = $this->commentModel->deleteComment($parms); if ($result){ return '<script> window.location.replace("Javascript:window.history.go(-1)");alert("删除成功");</script>'; }else{ return '<script> alert("删除失败")</script>'; } } }
Controller.php
<?php namespace article\controller; //它的作用是给一个外部引用起别名 这是命名空间的一个重要特性 use \article\Config; class Controller{ public $date = []; public $data = []; public function setDate($key,$value){ $this->date[$key] = $value; return $this; } //显示相应的页面 public function show($viewName){ //获取视图路径 $showPath = $_SERVER['DOCUMENT_ROOT'].'/article/view/'.$viewName.'.php'; //检测文件是否存在 if (file_exists($showPath) && is_file($showPath)){ //extract() 函数从数组中将变量导入到当前的符号表 extract($this->date); ob_start(); include $showPath; $content = ob_get_contents(); ob_end_clean(); $configArr = \article\config\Config::getInstance(); foreach ($configArr as $key => $value){ //将 $content 中的 $key 换成 $value $content = str_replace($key, $value, $content); } return $content; }else{ echo 'showPath is error! '; } } //返回json格式的数据 在异步应用程序中将字符串从 Web 客户机传递给服务器端程序 public function goodJson($content,$msg = null){ return json_encode([ 'code'=>1,//返回成功或失败 'msg'=>$msg,//返回的信息, 'data'=>$content,//返回的模块页面 ]); } public function badJson($msg){ return json_encode([ 'code'=>0, 'msg'=>$msg, 'data'=>[ ] ]); } //过滤XSS攻击 public function removeXSS($val) { // remove all non-printable characters. CR(0a) and LF(0b) and TAB(9) are allowed // this prevents some character re-spacing such as <java\0script> // note that you have to handle splits with \n, \r, and \t later since they *are* allowed in some inputs $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val); // straight replacements, the user should never need these since they're normal characters // this prevents like <IMG SRC=@avascript:alert('XSS')> $search = 'abcdefghijklmnopqrstuvwxyz'; $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $search .= '1234567890!@#$%^&*()'; $search .= '~`";:?+/={}[]-_|\'\\'; for ($i = 0; $i < strlen($search); $i++) { // ;? matches the ;, which is optional // 0{0,7} matches any padded zeros, which are optional and go up to 8 chars // @ @ search for the hex values $val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); // with a ; // @ @ 0{0,7} matches '0' zero to seven times $val = preg_replace('/(�{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ; } // now the only remaining whitespace attacks are \t, \n, and \r $ra1 = Array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); $ra2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload'); $ra = array_merge($ra1, $ra2); $found = true; // keep replacing as long as the previous round replaced something while ($found == true) { $val_before = $val; for ($i = 0; $i < sizeof($ra); $i++) { $pattern = '/'; for ($j = 0; $j < strlen($ra[$i]); $j++) { if ($j > 0) { $pattern .= '('; $pattern .= '(&#[xX]0{0,8}([9ab]);)'; $pattern .= '|'; $pattern .= '|(�{0,8}([9|10|13]);)'; $pattern .= ')*'; } $pattern .= $ra[$i][$j]; } $pattern .= '/i'; $replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2); // add in <> to nerf the tag $val = preg_replace($pattern, $replacement, $val); // filter out the hex tags if ($val_before == $val) { // no replacements were made, so exit the loop $found = false; } } } return $val; } }
Essay.php
<?php namespace article\controller; class Essay extends Controller{ private $essayModel; public function __construct(){ $this->essayModel = new \article\model\EssayModel(); } //进入个人空间页面 public function enterSpace(){ if(!isset($_SESSION['id'])){ header('Location: /article/index.php/HomeLogin/login'); } $parms = $_SESSION['id']; $result = $this->essayModel->User($parms); if (count($result)){ $this->date = $result; $content = $this->show('UserSpace'); return $content; }else{ return '查询失败'; } } //用户发表文章 public function addEssay($parms){ $id = $_SESSION['id']; $title = trim($parms['title']); if(empty($title)){ return $this->badJson('文章标题为空'); } $type = trim($parms['type']); if(empty($type)){ return $this->badJson('文章类型为空'); } $author = $_SESSION['name']; $summary = trim($parms['summary']); if(empty($summary)){ return $this->badJson('文章简介为空'); } $content = trim($parms['content']); if(empty($content)){ return $this->badJson('文章内容为空'); } $time = date('Y-m-d H:i:s'); $result = $this->essayModel->addEssay([$title,$type,$author,$summary,$content,$time,$id['id']]); if ($result){ return $this->goodJson('','发表成功,等待管理员审核'); }else{ return $this->badJson('发表失败'.$time); } } //管理员审核文章页面 public function examineEssay(){ if(!isset($_SESSION['myid'])){ header('Location: /article/index/Login/login'); } $result = $this->essayModel->allEssay(); if (count($result)){ $this->date = $result; $content = $this->show('examineEssay'); return $content; }else{ return '查询失败'; } } //根据id查询单个文章 public function searchEssayById($parms){ if(!isset($_SESSION['myid'])){ header('Location: /article/index/Login/login'); } $result = $this->essayModel->searchEssayById($parms); if (count($result)){ $this->date = $result; $content = $this->show('userEssay'); return $content; }else{ return '查询失败'; } } //删除文章 public function deleteEssay($parms){ $result = $this->essayModel->deleteEssay($parms); if ($result){ return $this->goodJson('','删除成功'); }else{ return $this->badJson('删除失败'); } } }
ForgetPassword.php
<?php namespace article\controller; class ForgetPassword extends Controller{ private $forgetModel = null; public function __construct(){ $this->forgetModel = new \article\model\ForgetModel(); } //显示忘记密码页面 public function showForgetPassword(){ return $this->show('forgetPassword'); } //根据姓名查询密保问题 //@param $parms //@return string public function selectQuestionByname($parms){ $result = $this->forgetModel->selectQuestionByname($parms); if($result){ $this->date = $result[0]; $this->setDate('name',$parms['name']); $content = $this->show('selectQuestionByname'); return $this->goodJson($content); }else{ return $this->badJson('用户不存在'); } } //重置密码 //@param $parms // @return string public function resetPassword($parms){ if (empty($parms['name'])){ return $this->badJson('用户名错误'); } if (empty($parms['answer'])){ return $this->badJson('密保答案为空'); } if (!empty($parms['newPassword'])){ $parms['newPassword'] = str_replace(' ', '',$parms['newPassword']); if($parms['newPassword'] == '') return $this->badJson('新密码为空'); }else return $this->badJson('新密码为空'); if (!empty($parms['confirmPassword'])){ $parms['confirmPassword'] = str_replace(' ', '',$parms['confirmPassword']); if($parms['confirmPassword'] == '') return $this->badJson('确认密码为空'); }else return $this->badJson('确认密码为空'); if($parms['newPassword'] !== $parms['confirmPassword']){ return $this->badJson('两次密码不一致'); } $result = $this->forgetModel->find([$parms['name'],$parms['answer']]); if($result){ $result2 = $this->forgetModel->resetPassword([$parms['newPassword'],$parms['name']]); if($result2){ return $this->goodJson('','修改成功'); }else{ return $this->badJson('修改失败'); } }else{ return $this->badJson('答案错误'.$parms['answer'].",".$parms['name']); } } }
HomeLogin.php
<?php namespace article\controller; class HomeLogin extends Controller { private $homeLogin = null; function __construct(){ $this->homeLogin = new \article\model\HomeModel(); } //登录 public function login(){ if ($this->isOnLine()){ $this->loginOut();//若在线则退出 }else{ return $this->show('homePage'); } } //判断是否登录成功 public function homeLine($parms = null){ if (!isset($_SESSION['name'])){ if (empty($parms['name'])){ return $this->badJson('用户名为空'); } if (!empty($parms['password'])){ $parms['password'] = str_replace(' ', '',$parms['password']); if($parms['password'] == '') return $this->badJson('密码为空'); }else return $this->badJson('密码为空'); $name = $parms['name']; $password = $parms['password']; $rlt = $this->homeLogin->search([$name,$password]); if ($rlt){ $id = $this->homeLogin->searchId([$name]); if (count($id)){ $_SESSION['id'] = $id; } $_SESSION['name'] = $name; return $this->goodJson('','登录成功'); }else{ return $this->badJson('用户名或密码错误'); } }else{ return $this->goodJson('','登录成功'); } } //用户没有退出,依旧在线 static public function isOnLine(){ if (isset($_SESSION['name'])){ return true; } return false; } //退出 public function loginOut(){ unset($_SESSION['id']); unset($_SESSION['name']); header('Location: /article/index.php/HomeLogin/login'); } }
Login.php
<?php namespace article\controller; class Login extends Controller{ private $userModel = null; //构造函数获取模型路径 public function __construct(){ $this->userModel = new \article\model\UserModel(); } //登录 public function login(){ if ($this->isOnLine()){ $this->loginOut();//若在线则退出 }else{ return $this->show('login'); } } //验证码 public function code($parms = null){ echo new \article\common\Vcode(154,41,4); } //判断用户是否登录成功 public function inLine($parms = null){ if (!isset($_SESSION['myname'])){ if (empty($parms['name'])){ return $this->badJson('用户名为空'); } if (!empty($parms['password'])){ $parms['password'] = str_replace(' ', '',$parms['password']); if($parms['password'] == '') return $this->badJson('密码为空'); }else return $this->badJson('密码为空'); if (empty($parms['code'])){ return $this->badJson('验证码为空'); } //strtoupper() 函数把字符串转换为大写 $code = strtoupper($parms['code']); if ($code != $_SESSION['code']){ return $this->badJson('验证码错误'); } $name = $parms['name']; $password = $parms['password']; $rlt = $this->userModel->find([$name,$password]); if ($rlt){ $_SESSION['myname'] = $name; $_SESSION['myid'] = $name; return $this->goodJson('','登录成功'); }else{ return $this->badJson('用户名或密码错误'); } }else{ return $this->goodJson('','登录成功'); } } //用户没有退出,依旧在线 static public function isOnLine(){ if (isset($_SESSION['myname'])){ return true; } return false; } //退出 public function loginOut(){ unset($_SESSION['myid']); unset($_SESSION['myname']); unset($_SESSION['essayid']); header('Location: /article/index.php/Login/login'); } }
Register.php
<?php namespace article\controller; class Register extends Controller { private $register = null; public function __construct(){ $this->register = new \article\model\RegisterModel(); } //显示登录界面 public function showRegister(){ return $this->show('register'); } //判断是否注册成功 public function resetRegister($parms){ if (!empty($parms['name'])){ if(!empty($parms['password'])){ $result = $this->register->isUser([$parms['name']]); if (!$result){ $result1 = $this->register->addUser($parms); if ($result1){ return $this->goodJson(''); }else{ return $this->badJson('注册失败!'); } }else{ return $this->badJson('用户名已存在!'); } }else{ return $this->badJson('密码为空!'); } }else{ return $this->badJson('用户名为空!'); } } //进入用户列表页 public function enterUser(){ if(!isset($_SESSION['myid'])){ header('Location: /article/index/Login/login'); } $result = $this->register->allUser(); if (count($result)){ $this->date = $result; $content = $this->show('User'); return $content; }else{ return '查询失败'; } } //删除用户 public function deleteRegister($parms){ $result = $this->register->deleteRegister($parms); if ($result){ return $this->goodJson('','删除成功'); }else{ return $this->badJson('删除失败'); } } }
config文件夹中
Config.php
<?php namespace article\config; //单例模式 class Config{ public $config = []; static public $instance = null; public function __construct(){ $this->config = include('./config.php'); } static public function getInstance(){ if (self::$instance == null) { self::$instance = new Config(); } return self::$instance->config; } }
js文件夹中
backstage.js
$(document).ready(function () { //添加文章 $("#parts").on("click","#add",function () { var formData = new FormData($("#addform")[0]); $.ajax({ type:"POST", url:"/article/index/Article/addArticle", data:formData, processData:false, contentType:false, dataType:"json", cache:false, success:function (data) { if(data.code == 1){ alert(data.msg); }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); $("#parts").on("click","#edit",function () { var formData = new FormData($("#addform")[0]); $.ajax({ type:"POST", url:"/article/index/Article/editArticles", data:formData, processData:false, contentType:false, dataType:"json", cache:false, success:function (data) { if(data.code == 1){ alert(data.msg); }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); }) //删除文章 function deleteArticle(id) { if(confirm('确定删除')){ //删除文章 $.ajax({ type:"POST", url:"/article/index/Article/deleteArticle", data:{ id :id, }, dataType:"json", success:function (data) { if(data.code == 1){ alert(data.msg); }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); } } /** * 模糊搜索文章 */ $("#parts").on("click","#SearchArticle",function () { $value = $("#SearchValue").val(); $.ajax({ type:"POST", url:"/article/Article/SearchArticle", data:{ search:$value, methodName :'SearchArticle', }, dataType:"json", success:function (data) { if(data.code == 1){ alert('查询成功!') window.location.href="/article/index.php/Admin/index"; }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); /** * 发表评论 */ function com() { //添加评论 var visitorname = $.trim($("#visitorname").val()); var content = $.trim($("#publish-content").val()); $.ajax({ type: "POST", url: "/article/index/Comment/addComments", data: { content: content, visitorname: visitorname, }, dataType: "json", success: function (data) { if (data.code == 1) { alert(data.msg); window.location.href="/article/index/Comment/selectComment"; } else { alert(data.msg); } }, error: function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }
引入bootstrap.js文件
Details.js
/** * 模糊搜索文章 */ $("#parts").on("click","#SearchArticle",function () { $value = $("#SearchValue").val(); $.ajax({ type:"POST", url:"/article/index/Article/SearchArticle", data:{ search:$value, methodName :'SearchArticle', }, dataType:"json", success:function (data) { if(data.code == 1){ alert('查询成功!') window.location.href="/article/index.php/Admin/index"; }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); /** * 发表评论 */ $("#com").click(function () { //添加评论 //使用 PHP trim() 函数去除用户输入数据中不必要的字符 (如:空格,tab,换行) var id = $.trim($("#id").val()); var visitorname = $.trim($("#visitorname").val()); var content = $.trim($("#publish-content").val()); $.ajax({ type: "POST", url: "/article/index/Comment/addComment", data: { id: id, content: content, visitorname: visitorname, }, dataType: "json", success: function (data) { if (data.code == 1) { alert(data.msg); } else { alert(data.msg); } }, error: function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); });
examineEssay.js
//删除文章 function deleteEssay(id) { if(confirm('确定删除')){ //删除文章 $.ajax({ type:"POST", url:"/article/index/Essay/deleteEssay", data:{ id :id, }, dataType:"json", success:function (data) { if(data.code == 1){ alert(data.msg); }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); } } //审核通过 function addArticle(id) { $.ajax({ type:"POST", url:"/article/index/Article/addArticles", data:{ id:id, }, dataType:"json", success:function (data) { if (data.code == 1){ alert(data.msg); }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }
forgetPassword.js
//忘记密码 $(document).ready(function () { $("#submit").click(function () { var name = $.trim($("#name").val()); $.ajax({ type:"POST", url:"/article/index/ForgetPassword/selectQuestionByname", data:{ name :name, }, dataType:"json", success:function (data) { if(data.code == 1){ $("#dialog-content").empty(); $("#dialog-content").append(data.data); }else { alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); //密保对照 $("#dialog-content").on("click","#submit2",function () { var name = $.trim($("#name").html()); var answer = $.trim($("#answer").val()); var newPassword = $.trim($("#new-password").val()); var confirmPassword = $.trim($("#confirm-password").val()); $.ajax({ type:"POST", url:"/article/index/ForgetPassword/resetPassword", data:{ name :name, answer :answer, newPassword :newPassword, confirmPassword :confirmPassword, }, dataType:"json", success:function (data) { if(data.code == 1){ alert(data.msg); window.location.href="/article/index/Login/login"; }else { alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); });
homePage.js
//用户登录 $(document).ready(function () { $("#login-submit").click(function () { var name = $.trim($("#login-name").val()); var password = $.trim($("#login-password").val()); $.ajax({ type:"POST", url:"/article/index.php/HomeLogin/homeLine", data:{ name :name, password :password, }, dataType:"json", success:function (data) { if(data.code == 1){ alert('登陆成功!') window.location.href="/article/index/Article/enterList"; }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); });
引入jquery.imgbox.pack.js文件
引入jquery-3.2.1.min.js文件
login.js
// 刷新验证码 // @param obj // @param url function newgdcode(obj,url){ obj.src = url+"?nowtime=" + new Date().getTime(); } $(document).ready(function () { $("#login-submit").click(function () { var name = $.trim($("#login-name").val()); var password = $.trim($("#login-password").val()); var code = $.trim($("#login-code").val()); $.ajax({ type:"POST", url:"/article/index.php/Login/inLine", data:{ name :name, password :password, code :code, }, dataType:"json", success:function (data) { if(data.code == 1){ alert('登陆成功!') window.location.href="/article/index.php/Admin/index"; }else { alert(data.msg); $('#code-img').click(); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); });
npm.js
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. require('../../js/transition.js') require('../../js/alert.js') require('../../js/button.js') require('../../js/carousel.js') require('../../js/collapse.js') require('../../js/dropdown.js') require('../../js/modal.js') require('../../js/tooltip.js') require('../../js/popover.js') require('../../js/scrollspy.js') require('../../js/tab.js') require('../../js/affix.js') register.js //用户注册 $(document).ready(function () { $("#login-submit").click(function () { var name = $.trim($("#name").val()); var password = $.trim($("#password").val()); $.ajax({ type:"POST", url:"/article/index.php/Register/resetRegister", data:{ name :name, password :password, }, dataType:"json", success:function (data) { if(data.code == 1){ alert('注册成功!'); window.location.href="/article/index.php/Admin/homePage"; }else { alert(data.msg); $('#code-img').click(); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); });
User.js
function deleteUser(id) { if(confirm('确定删除')){ //删除用户 $.ajax({ type:"POST", url:"/article/index/Register/deleteRegister", data:{ id :id, }, dataType:"json", success:function (data) { if(data.code == 1){ alert(data.msg); }else{ alert(data.msg); } }, error:function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); } }
UserSpace.js
$(document).ready(function () { //添加文章 $("#parts").on("click", "#add", function () { var formData = new FormData($("#addform")[0]); $.ajax({ type: "POST", url: "/article/index/Essay/addEssay", data: formData, processData: false, contentType: false, dataType: "json", cache: false, success: function (data) { if (data.code == 1) { alert(data.msg); } else { alert(data.msg); } }, error: function (jqXHR) { alert("发生错误:" + jqXHR.status); } }); }); })
common文件夹中
FileUpload.php
<?php namespace article\common; class FileUpload { private $path = "./img"; //上传文件保存的路径 private $allowtype = array('jpg','gif','png','jpeg','bmp'); //设置限制上传文件的类型 private $maxsize = 2000000; //限制文件上传的大小 private $israndname = true; //设置是否随机重命名文件 private $originName; //原文件名 private $tmpFileName; //临时文件名 private $fileType; //文件类型(后缀) private $fileSize; //文件大小 private $newFileName; //新文件名 private $errorNum = 0; //错误号 private $errorMess = ""; //错误报告消息 /** * 设置成员属性 * @param $sky * @param $value * @return $this */ function set($sky,$value){ $this->setOption($sky,$value); return $this; } /** * 上传文件 * @param $fileFiled * @return bool */ function upload($fileFiled){ $return = true; //检查文件路径是否合法 if(!$this->checkFilePath()){ $this->errorMess = $this->getError(); } //将文件信息去出付给变量 $name = $_FILES[$fileFiled]['name']; $tmp_name = $_FILES[$fileFiled]['tmp_name']; $size = $_FILES[$fileFiled]['size']; $error = $_FILES[$fileFiled]['error']; //如果有多个文件上传则会是一个数组 if(is_array($name)){ $errors = array(); //多个文件上传则循环处理。这个循环只有检查上传文件的功能,并未有真正上传 for($i = 0; $i < count($name); $i++) { //设置文件信息 if ($this->setFiles($name[$i], $tmp_name[$i], $size[$i], $error[$i])) { if ($this->checkFileSize() && $this->checkFileType() && $this->isImage()) { }else{ $errors[] = $this->getError(); $return = false; } } else { $errors[] = $this->getError(); $return = false; } //如果有问题,则初始化属性 if (!$return) { $this->setFiles(); } } if($return){ //存放所以上传后的文件名的数组 $fileNames = array(); //如果上传的文件都是合法的,则通过循环向服务器上传文件 for($i = 0; $i < count($name); $i++){ if($this->setFiles($name[$i],$tmp_name[$i],$size[$i],$error[$i])){ $this->setNewFileName(); if(!$this->copyFile()){ $errors[] = $this->getError(); $return = false; } $fileNames[] = $this->newFileName; } } $this->newFileName = $fileNames; } $this->errorMess = $errors; return $return; //上传单个文件的处理方法 }else{ if($this->setFiles($name,$tmp_name,$size,$error)){ if($this->checkFileSize() && $this->checkFileType() && $this->isImage()){ $this->setNewFileName(); //上传文件,返回0为成功 if($this->copyFile()){ return true; }else{ $return = false; } }else{ $return = false; } }else{ $return = false; } //如果$return为false.则出错,将错误信息保存在erroMess里 if (!$return){ $this->errorMess = $this->getError(); } return $return; } } //获取上传后文件的名称 public function getFileName(){ return $this->newFileName; } public function getFilePath(){ $path = rtrim($this->path,'/').'/'; $newFilePath = $this->newFileName; foreach ($newFilePath as $key => $value){ $newFilePath[$key] = $path.$value; } return $newFilePath; } //上传失败后,用此方法得到错误信息 public function getErrorMsg(){ return $this->errorMess; } //设置出错信息 private function getError(){ $str = "上传文件{$this->originName}时出错:"; switch ($this->errorNum){ case 4: $str .= "没有文件被上传/4"; break; case 3: $str .= "文件只有部分被上传/3"; break; case 2: $str .= "上传文件的大小超过了HTML表单MAX_FILE_SIZE选项指定的值/2"; break; case 1: $str .= "上传的文件超过了php.ini中upload_max_filesize选项限制的值/1"; break; case -1: $str .= "未允许类型/-1"; break; case -2: $str .= "文件过大,上传的文件不能超过{$this->maxsize}个字节/-2"; break; case -3: $str .= "上传失败/-3"; break; case -4: $str .= "建立存放上传文件的目录失败,请重新指定上传目录/-4"; break; case -5: $str .= "必须指定上传文件的路径/-5"; break; default: $str .= "未知错误/0"; } return $str; } //设置和$_FILES有关的内容 private function setFiles($name = '',$tmp_name = '',$size = 0,$error = 0){ $this->setOption('errorNum',$error); if($error) return false; $this->setOption('originName',$name); $this->setOption('tmpFileName',$tmp_name); $aryStr = explode('.',$name); $this->setOption('fileType',strtolower($aryStr[count($aryStr)-1])); $this->setOption('fileSize',$size); return true; } //为单个成员属性设置值 private function setOption($key,$value){ $this->$key = $value; } //设置上传后文件的名称 private function setNewFileName(){ if($this->israndname){ $this->setOption('newFileName',$this->proRandName()); }else{ $this->setOption('newFileName',$this->originName); } } //检查上传文件是否是合法的类型 private function checkFileType(){ if(in_array(strtolower($this->fileType),$this->allowtype)){ return true; }else{ $this->setOption('errorNum',-1); return false; } } //检查是否是图片格式 private function isImage(){ $alltype = '.gif|.jpeg|.png|.bmp|.jpg';//定义检查的图片类型 $result= getimagesize($this->tmpFileName); $ext = image_type_to_extension($result['2']); if(stripos($alltype,$ext)){ return true; }else{ $this->setOption('errorNum',-1); return false; } } //检查文件大小是否是允许的大小 private function checkFileSize(){ if($this->fileSize > $this->maxsize){ $this->setOption('errorNum',-2); return false; }else{ return true; } } //检查是否有存放上传文件的目录 private function checkFilePath(){ if(empty($this->path)){ $this->setOption('errorNum',-5); return false; } if(!file_exists($this->path) || !is_writable($this->path)){ if(!@mkdir($this->path,0755)){ $this->setOption('errorNum',-4); return false; } } return true; } //设置随机文件名 private function proRandName(){ $FileName = date('YmdHis')."_".rand(100,999); return $FileName.'.'.$this->fileType; } //复制文件到指定的位置 private function copyFile(){ if(!$this->errorNum){ $path = rtrim($this->path,'/').'/'; $path .= $this->newFileName; if(move_uploaded_file($this->tmpFileName,$path)){ return true; }else{ $this->setOption('errorNum',-3); return false; } }else{ return false; } } }
Vcode.php
<?php namespace article\common; //验证码 GD扩展 class Vcode{ private $width; //宽 private $height; //高 private $codeNum; //字符个数 private $disturbColorNum; //干扰元素个数 private $checkCode; //字符 private $image; //资源 //构造方法 function __construct($width = 100, $height = 30, $codeNum = 4){ $this->width = $width; $this->height = $height; $this->codeNum = $codeNum; $number = floor($width*$height/15); if ($number > 240-$codeNum) { $this->disturbColorNum = 240-$codeNum; } else { $this->disturbColorNum = $codeNum; } $this->checkCode = $this->createCheckCode(); } //用于输出验证码,同时将验证码保存在SESSION中 function __toString(){ $_SESSION["code"] = strtoupper(implode("",$this->checkCode)); $this->outImg(); return ""; } //内部私有方法,输出图像 public function outImg(){ $this->getCreateImage(); $this->setDisturbColor(); $this->outputText(); $this->outputImage(); } //创建图像资源,并初始化背景 private function getCreateImage(){ //创建一张底图imagecreatetruecolor() $this->image = imagecreatetruecolor($this->width, $this->height); $backColor = imagecolorallocate($this->image, rand(225,255), rand(225,255), rand(225,255)); //imagefill()区域填充 @imagefill($this->image, 0, 0, $backColor); //imagecolorallocate()为一幅图像分配颜色 $border = imagecolorallocate($this->image, 0, 0, 0); imagerectangle($this->image, 0, 0, $this->width-1, $this->height-1, $border); } //随机生成字符串,去除易混淆的oOLlz和012 private function createCheckCode(){ $code="3456789abcdefghijkmnpqrstuvwxyABCDEFGHIJKMNPQRSTUVWXY"; $ascii = []; for ($i=0; $i < $this->codeNum; $i++) { $char = $code[rand(0,strlen($code)-1)]; $ascii[$i] = $char; } return $ascii; } //设置干扰元素 private function setDisturbColor(){ //干扰点 for ($i=0; $i <= $this->disturbColorNum; $i++) { $color = imagecolorallocate($this->image, rand(0,255), rand(0,255), rand(0,255)); imagesetpixel($this->image, rand(1,$this->width-2), rand(1,$this->height-2), $color); } for($i=0; $i < 5; $i++){ $color = imagecolorallocate($this->image,rand(0,255),rand(0,255),rand(0,255)); imagearc($this->image,rand(-10,$this->width),rand(-10,$this->height),rand(30,300), rand(20,200),55,44,$color); } } //随机颜色,随机摆放,随机字符串向图像中输出 private function outputText(){ for ($i = 0; $i < $this->codeNum; $i++){ $fontcolor = imagecolorallocate($this->image, rand(0,128), rand(0,128), rand(0,128)); $fontSize = 10; $x = floor($this->width/$this->codeNum)*$i+3; $y = rand(0,$this->height - imagefontheight($fontSize)); imagechar($this->image, $fontSize, $x, $y,$this->checkCode[$i], $fontcolor); } } //验证码以图片格式输出 private function outputImage(){ if(imagetypes() & IMG_GIF){ header("Content-type:image/gif"); imagegif($this->image); }elseif(imagetypes() & IMG_JPG){ header("Content-type:image/jpeg"); imagejpeg($this->image, "", 0.5); }elseif(imagetypes() & IMG_PNG){ header("Content-type:image/png"); imagepng($this->image); }elseif(imagetypes() & IMG_WBMP){ header("Content-type:image/vnd.wap.wbmp"); imagewbmp($this->image); }else{ die("PHP不支持图像创建"); } } //析构方法 function __destruct(){ imagedestroy($this->image); } }
css文件夹中
Add.css
body{ margin: 0 auto; } header{ text-align: left; background: rgba(25,31,34,.9); height: 90px; } header img{ float: left; margin: 15px 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 26px 20px 0 0; } header input{ padding-left: 5px; margin: 0 0 5px 0; } header .submit{ width: 50px; height: 40px; } nav{ background: url("../img/qin.jpg"); background-size: cover; height: 300px; position: relative; } .text{ position: absolute; top: 200px; left: 17%; text-align: center; background-color: rgba(250,250,250,0.4); width: 1000px; height: 250px; color: #5e5e5e; border-radius: 10px; } .text a{ padding: 30px; float: left; line-height: 40px; color: #000; font-weight: 900; font-size: 20px; } .content{ background-color: #f0f0f0; margin: 0 auto; position: relative; } .form { background: #fcfcfc; margin: 0px 17%; height: 800px; width: 1000px; } .form img{ float: left; margin: 0 50px; } .form .top{ float: left; margin: 60px; } .form-row{ margin: 20px; } .form-row1{ float: left; margin: 120px 30px 150px 0; } .summary{ margin: 10px 50px 0 100px; } .summary textarea{ width: 800px; height: 150px; } .Content{ margin: 10px 50px 0 100px; } .Content textarea{ width: 800px; height: 150px; } .content button{ width: 50px; height: 40px; margin: 10px 12%; position: absolute; right: 14%; bottom: 60px; } backstage.css body{ margin: 0 auto; } header{ text-align: left; background: rgba(25,31,34,.9); height: 90px; } header img{ float: left; margin: 15px 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 26px 20px 0 0; } header input{ padding-left: 5px; margin: 0 0 5px 0; } header .submit{ width: 50px; height: 40px; }li a{ color: #fff; text-decoration: none; } li a:active{ color: #fff; } nav{ background: url("../img/hua.jpg"); background-size: cover; height: 300px; position: relative; } .text{ position: absolute; top: 200px; left: 17%; text-align: center; background-color: rgba(250,250,250,0.4); width: 1000px; height: 250px; color: #5e5e5e; border-radius: 10px; } .text a{ padding: 30px; float: left; line-height: 40px; color: #000; font-weight: 900; font-size: 20px; } .clear{ content: ""; clear: both; } .content{ background: #f0f0f0; margin: 0 auto; } .carousel{ margin: 10px 0 10px 17%; width: 660px; height: 300px; float: left; } .item img{ width: 750px; } .pic img{ width: 320px; height: 300px; float: left; margin: 10px 0 0 20px; } .photos{ margin: 10px 17%; float: left; } .photos img{ width: 183px; height: 183px; } .photos .img1,.img2,.img3{ margin: 0 16px 0 0; } .form{ margin: 0 17%; width: 1000px; background: #fff; text-align: center; } table{ margin: 0 50px; border: #000 1px solid; } table tr td{ margin: 10px 0; border: #000 1px solid; } 引入bootstrap.css文件 引入bootstrap-theme.css文件 conversation.css body{ margin: 0 auto; } header{ text-align: left; background: rgba(25,31,34,.9); height: 90px; } header img{ float: left; margin: 15px 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 26px 20px 0 0; } header input{ padding-left: 5px; margin: 0 0 5px 0; } header .submit{ width: 50px; height: 40px; } nav{ background: url("../img/hua.jpg"); background-size: cover; height: 300px; position: relative; } .text{ position: absolute; top: 200px; left: 17%; text-align: center; background-color: rgba(250,250,250,0.4); width: 1000px; height: 250px; color: #5e5e5e; border-radius: 10px; } .text a{ padding: 30px; float: left; line-height: 40px; color: #000; font-weight: 900; font-size: 20px; } .clear{ content: ""; clear: both; } .content{ background: #f0f0f0; margin: 0 auto; } .test{ margin: 0 17%; width: 1000px; } .conver{ background: #fff; padding: 30px; } .test .tm .cont{ background: url("../img/s.jpg"); background-size: cover; width: 258px; height: 59px; float: right; margin: 0 auto; } .test .tg .cont{ background: url("../img/s.jpg"); background-size: cover; width: 265px; height: 59px; } .tm .cont p{ padding: 5px 20px; } .tg .cont p{ padding: 20px 20px; } .test .tm h2{ margin: 0; text-align: right; color: green; font-size: 18px; } .test .tm .date{ color: #999; font-size: 13px; } .test .tm{ text-align: right; } .test .tg{ text-align: left; } .test .tg h2{ margin: 0; text-align: left; color: green; font-size: 18px; } .test .tg .date{ color: #999; font-size: 13px; } .tg{ text-align: left; } .form{ margin: 100px 0 0 0; } .form input{ margin: 10px 0; } .form textarea{ width: 930px; height: 80px; margin: 10px 0; } .button{ margin: 10px 0 50px 0; float: right; } Details.css .essay{ margin: 0 auto; width: 900px; background-color: #fff; height: 100%; } .submit{ float: right; margin: 30px 28% 0 0; } .essay .local{ text-align: left; font-size: 15px; color: #5e5e5e; padding: 10px; } .essay h1{ text-align: center; font-size: 25px; color: #000; line-height: 40px; } .essay h2{ font-size: 15px; line-height: 30px; color: #5e5e5e; background-color: #e8f5dc; margin: 10px; } .essay p{ text-align: left; line-height: 30px; margin:30px 60px; color: #5e5e5e; font-size: 13px; } .comment p{ margin:0 0 0 60px; font-size: 15px; } .comment textarea{ width: 700px; height: 80px; padding: 20px; } .comment .button{ width: 70px; height: 40px; margin: 0 0 0 75%; }
Edit.css
body{ margin: 0 auto; } header{ text-align: left; background: rgba(25,31,34,.9); height: 90px; } header img{ float: left; margin: 15px 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 26px 20px 0 0; } header input{ padding-left: 5px; margin: 0 0 5px 0; } header .submit{ width: 50px; height: 40px; } nav{ background: url("../img/de.jpg"); background-size: cover; height: 300px; position: relative; } .text{ position: absolute; top: 200px; left: 17%; text-align: center; background-color: rgba(250,250,250,0.4); width: 1000px; height: 250px; color: #5e5e5e; border-radius: 10px; } .text a{ padding: 30px; float: left; line-height: 40px; color: #000; font-weight: 900; font-size: 20px; } .content{ background-color: #f0f0f0; margin: 0 auto; position: relative; } .form { background: #fcfcfc; margin: 0px 17%; width: 1000px; height: 800px; } .form img{ float: left; margin: 0 50px; } .form .top{ float: left; margin: 60px; } .form-row{ margin: 20px; } .form-row1{ float: left; margin: 120px 30px 150px 0; } .summary{ margin: 10px 50px 0 100px; } .summary textarea{ width: 800px; height: 150px; } .Content{ margin: 10px 50px 0 100px; } .Content textarea{ width: 800px; height: 150px; } .content button{ width: 50px; height: 40px; margin: 10px 12%; position: absolute; right: 14%; bottom: 60px; }
examineEssay.css
body{ margin: 0 auto; } header{ text-align: left; background: rgba(25,31,34,.9); height: 90px; } header img{ float: left; margin: 15px 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 26px 20px 0 0; } header input{ padding-left: 5px; margin: 0 0 5px 0; } header .submit{ width: 50px; height: 40px; } nav{ background: url("../img/hu.jpg"); background-size: cover; height: 300px; position: relative; } .text{ position: absolute; top: 200px; left: 17%; text-align: center; background-color: rgba(250,250,250,0.4); width: 1000px; height: 250px; color: #5e5e5e; border-radius: 10px; } .text a{ padding: 30px; float: left; line-height: 40px; color: #000; font-weight: 900; font-size: 20px; } .content{ background-color: #f0f0f0; margin: 0 auto; position: relative; } .list{ margin: 0 17%; width: 1000px; background: #fff; } .list h3{ font-size: 18px; line-height: 50px; margin: 0; text-align: center; } table{ margin: 10px 20px; border: #000 1px solid; } table tr td{ text-align: center; margin: 10px 0; border: #000 1px solid; } forgetPassword.css body{ background: url("../img/bg.jpg"); background-size: cover; } .dialog{ width: 380px; margin: 200px auto 0; border: 1px solid #D5D5D5; background: #fff; } .dialog-title{ position: relative; height: 48px; line-height: 48px; padding:0px 20px; color: #535353; font-size: 16px; border-bottom: 1px solid #efefef; background: #f5f5f5; } .dialog-closebutton{ width: 16px; height: 16px; display: block; position: absolute; top: 12px; right: 20px; cursor: pointer; } .dialog-content{ padding: 15px 20px; } .input{ width: 100%; height: 40px; line-height: 40px; margin: 10px auto 20px; border: 1px solid #d5d5d5; font-size: 16px; color: #c1c1c1; text-indent: 25px; } .text{ font-size: 16px; display: inline-block; color: orange; } .submit{ width: 100%; height: 50px; background-color: orange; transition:0.4s; color: #fff; font-size: 16px; display: block; text-align: center; line-height: 50px; } .submit:hover{ background-color: darkorange; } homePage.css body{ background: url("../img/bg-1.jpg"); background-size: cover; width: 100%; height: 100%; overflow: hidden; } h1{ text-align: center; color: #000; font-size: 40px; margin: 10px 0 0 0; font-family: "华文隶书"; } a{ text-decoration: none; color: #000; } .dialog{ width: 380px; margin: 200px auto 0; border: 1px solid #D5D5D5; background: #fff; } .dialog-title{ position: relative; height: 48px; line-height: 48px; padding:0px 20px; color: #535353; font-size: 16px; border-bottom: 1px solid #efefef; background: #f5f5f5; } .dialog-closebutton{ width: 16px; height: 16px; display: block; position: absolute; top: 12px; right: 20px; cursor: pointer; } .dialog-content{ padding: 15px 20px; } .input{ width: 100%; height: 40px; line-height: 40px; margin: 10px auto 20px; border: 1px solid #d5d5d5; font-size: 16px; color: #c1c1c1; text-indent: 25px; } .submit{ width: 100%; height: 50px; background-color:#1c58a1; opacity: 0.9; transition:0.4s; color: #fff; font-size: 16px; display: block; text-align: center; line-height: 50px; } .submit:hover{ background-color: #02316d; opacity: 1; } .register{ color: #000; } .clear{ content:''; clear: both; } .clear{ content: ''; clear: both; } .fly{ margin: 0 20% 0 0; float: right; } a{ text-decoration: none; color: #fff; } List.css body{ margin: 0 auto; } a{ color: #fff; text-decoration: none; } a:hover{ color:#fcf8e3; } p a{ color: #5e5e5e; } p a:hover{ color: red; } header{ text-align: left; } header img{ float: left; margin: 0 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 30px 20px 0 0; } header input{ padding-left: 5px; } header .submit{ width: 50px; height: 40px; } .name{ width: 100%; height: 46px; background: #5b951b; margin: 30px 0 0 0; } .name ul{ margin: 0 20%; } .name ul li{ float: left; color: #fff; margin: 10px 30px; font-size: 20px; } .clear{ content: ""; clear: both; } .content{ background: #f0f0f0; margin: 0 auto; text-align: center; } .picture{ margin: 10px 0 0 15%; float: left; width: 300px; height: 340px; background: url("../img/b.jpg"); background-size: cover; } .picture p{ margin-top: 104%; color: #fff; background-color:#000; height: 29px; } .text{ float: left; margin: 10px; background: #fff; width: 420px; height: 300px; text-align: left; padding: 20px; } .text h3{ font-size: 21px; text-align: center; line-height: 40px; } .text p{ font-size: 15px; line-height: 25px; } .author{ width: 220px; height: 300px; float: left; background: #fff; margin: 10px 10% 0 0; padding: 20px; } .author h3{ text-align: left; font-size: 20px; line-height: 40px; } .author p{ text-align: left; line-height: 30px; font-size: 15px; color: #3a768f; } .photo{ width: 770px; height: 284px; float: left; margin: 10px 0 0 15%; background: #fff; } .photo li{ width: 130px; height: 114px; float: left; margin: 12px; } .photo li p{ font-size: 13px; } .photo li img{ width: 130px; height: 90px; } .ranking{ width: 240px; height: 264px; background: #fff; float: left; padding: 10px; margin: 10px 0 0 10px; } .ranking p{ text-align: left; line-height: 35px; } .new{ width: 375px; height: 328px; float: left; margin: 10px 0 0 15%; background: #fff; } .new p{ text-align: left; line-height: 30px; font-size: 15px; padding: 10px; } h4{ font-size: 20px; } .hot{ width: 385px; height: 328px; float: left; margin: 10px 0 0 10px; background: #fff; } .hot p{ text-align: left; line-height: 30px; font-size: 15px; padding: 10px; } .reader{ width: 240px; height: 308px; background: #fff; float: left; padding: 10px; margin: 10px 0 0 10px; } .reader p{ text-align: left; line-height: 30px; font-size: 15px; padding: 10px; }
login.css
body{ background: url("../img/bg.jpg"); background-size: cover; } .dialog{ width: 380px; margin: 200px auto 0; border: 1px solid #D5D5D5; background: #fff; } .dialog-title{ position: relative; height: 48px; line-height: 48px; padding:0px 20px; color: #535353; font-size: 16px; border-bottom: 1px solid #efefef; background: #f5f5f5; } .dialog-closebutton{ width: 16px; height: 16px; display: block; position: absolute; top: 12px; right: 20px; cursor: pointer; } .dialog-content{ padding: 15px 20px; } .input{ width: 100%; height: 40px; line-height: 40px; margin: 10px auto 20px; border: 1px solid #d5d5d5; font-size: 16px; color: #c1c1c1; text-indent: 25px; } .code{ width: 150px; height: 40px; float: left; border: 1px solid #d5d5d5; font-size: 16px; color: #c1c1c1; text-indent: 25px; } .submit{ width: 100%; height: 50px; background-color: orange; opacity: 0.9; transition:0.4s; color: #fff; font-size: 16px; display: block; text-align: center; line-height: 50px; } .submit:hover{ background-color: darkorange; opacity: 1; } .forget{ color: #9F9386; display: block; text-align: right; margin: -10px 0 10px; transition:0.4s; cursor:pointer; } .forget:hover{ color: #9999FF; } .code-div{ width: 100%; margin: 10px auto 20px; } .code-img{ float: right; cursor:pointer; }
public.css
*{ margin: 0; padding: 0; } a{ text-decoration: none; } li{ list-style:none; } p{ display: block; } input{ outline: none; } span{ display: block; } body,h1,h2,h3,h4,h5,h6,span,i{ font-weight: normal; } .clearboth:after{ content: " "; clear: both; display:block; } textarea{ resize:none; font-size: 20px; } register.css .dialog{ width: 380px; margin: 200px auto 0; border: 1px solid #D5D5D5; background: #fff; } .dialog-title{ position: relative; height: 48px; line-height: 48px; padding:0px 20px; color: #535353; font-size: 16px; border-bottom: 1px solid #efefef; background: #f5f5f5; } .dialog-closebutton{ width: 16px; height: 16px; display: block; position: absolute; top: 12px; right: 20px; cursor: pointer; } .dialog-content{ padding: 15px 20px; } .input{ width: 100%; height: 40px; line-height: 40px; margin: 10px auto 20px; border: 1px solid #d5d5d5; font-size: 16px; color: #c1c1c1; text-indent: 25px; } .text{ font-size: 16px; display: inline-block; color: #0088ff; } .submit{ width: 100%; height: 50px; background-color: #1c58a1; transition:0.4s; color: #fff; font-size: 16px; display: block; text-align: center; line-height: 50px; } .submit:hover{ background-color: #024378; } a{ color: #5e5e5e; } User.css body{ margin: 0 auto; } header{ text-align: left; background: rgba(25,31,34,.9); height: 90px; } header img{ float: left; margin: 15px 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 26px 20px 0 0; } header input{ padding-left: 5px; margin: 0 0 5px 0; } header .submit{ width: 50px; height: 40px; } a{ color: #5e5e5e; text-decoration: none; } a:active{ color: #fff; } nav{ background: url("../img/bai.jpg"); background-size: cover; height: 300px; position: relative; } .text{ position: absolute; top: 200px; left: 17%; text-align: center; background-color: rgba(250,250,250,0.4); width: 1000px; height: 250px; color: #5e5e5e; border-radius: 10px; } .text a{ padding: 30px; float: left; line-height: 40px; color: #000; font-weight: 900; font-size: 20px; } .content{ background-color: #f0f0f0; margin: 0 auto; } .list{ margin: 0 17%; width: 960px; padding: 20px 20px; color: #000; background-color: #fff; } .list h3{ font-size: 18px; line-height: 50px; margin: 0; text-align: center; } table{ margin: 10px 70px; border: #000 1px solid; } table tr td{ text-align: center; width: 200px; height: 50px; margin: 10px 0; border: #000 1px solid; } userEssay.css body{ margin: 0 auto; } header{ text-align: left; background: rgba(25,31,34,.9); height: 90px; } header img{ float: left; margin: 15px 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 26px 20px 0 0; } header input{ padding-left: 5px; margin: 0 0 5px 0; } header .submit{ width: 50px; height: 40px; } nav{ background: url("../img/cao.jpg"); background-size: cover; height: 300px; position: relative; } .text{ position: absolute; top: 200px; left: 17%; text-align: center; background-color: rgba(250,250,250,0.4); width: 1000px; height: 250px; color: #5e5e5e; border-radius: 10px; } .text a{ padding: 30px; float: left; line-height: 40px; color: #000; font-weight: 900; font-size: 20px; } .content{ background-color: #f0f0f0; margin: 0 auto; position: relative; } .test{ margin: 0 17%; width: 1000px; background: #fff; } .test h2{ text-align: center; font-size: 20px; margin: 0; line-height: 45px; color:#3a768f; } .test p{ font-size: 16px; text-align: left; color: #3a768f; margin: 0 25%; line-height: 40px; } .con p{ margin: 0 15%; text-align: left; font-size: 15px; color: #5e5e5e; line-height: 40px; }
UserList.css
body{ margin: 0 auto; } header{ text-align: left; background: rgba(25,31,34,.9); height: 90px; } header img{ float: left; margin: 15px 20px 0 25%; } header .sub{ width: 400px; height: 40px; border-width: 0.5px; border-radius: 3px; margin: 26px 20px 0 0; } header input{ padding-left: 5px; margin: 0 0 5px 0; } header .submit{ width: 50px; height: 40px; } a{ color: #5e5e5e; text-decoration: none; } a:active{ color: #fff; } nav{ background: url("../img/shu.jpg"); background-size: cover; height: 300px; position: relative; } .text{ position: absolute; top: 200px; left: 17%; text-align: center; background-color: rgba(250,250,250,0.4); width: 1000px; height: 250px; color: #5e5e5e; border-radius: 10px; } .text a{ padding: 30px; float: left; line-height: 40px; color: #000; font-weight: 900; font-size: 20px; } .content{ background-color: #f0f0f0; margin: 0 auto; } .list{ margin: 0 17%; width: 960px; padding: 20px 20px; color: #000; background-color: #fff; } .list h3{ font-size: 18px; line-height: 50px; margin: 0; text-align: center; } table{ margin: 10px 0; border: #000 1px solid; } table tr td{ text-align: center; margin: 10px 0; border: #000 1px solid; }
UserSpace.css
body{ margin: 0 auto; background: url("../img/top.jpg"); background-size: cover; } h1{ font-size: 35px; text-align: left; color: #fff; margin: 0 20%; padding: 50px 0; } header{ margin: 0; height: 400px; } nav{ margin: 170px 17% 0 17%; background: #2d2d2d; border-radius: 5px; } nav h2{ line-height: 40px; font-size: 20px; text-align: center; color: #fff; } .content{ margin: 0; height: 900px; } .self{ background: #2d2d2d; float: left; margin: -35px 0 0 17%; width: 300px; height: 400px; } .self h4{ background: #5f5959; line-height: 30px; text-align: center; font-size: 16px; color: #baab6f; margin: 0; } .self img{ width: 150px; height: 150px; padding: 20px 25%; background: #fcf8e3; } .self p{ margin: 0; color: #baab6f; font-size: 15px; text-align: center; line-height: 40px; } .add{ float: left; width: 690px; height: 700px; background: #2d2d2d; margin: -35px 0 0 10px; color: #baab6f; } .add h4{ background: #5f5959; line-height: 50px; text-align: center; font-size: 16px; margin: 0; } .add .top{ float: left; margin: 30px 60px; } .add .top .form-row{ margin: 15px 0; } .form-row1{ margin: 45px 20px; float: left; } .summary{ margin: 10px 60px; } .summary textarea{ width: 550px; height: 120px; } .Content{ margin: 10px 60px; } .Content textarea{ width: 550px; height: 120px; } .add button{ float: right; margin: 0 90px 0 0; } .clear{ content: ''; clear: both; }
最后img文件夹放图片