-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
83 lines (71 loc) · 3.2 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>首页 - SdustBlog</title>
<!-- meta -->
<meta charset="UTF-8">
<meta http-equiv="content-language" content="zh-CN" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="msvalidate.01" content="26321DE756A81E2A83BB30B252FB5A80" />
<meta name="description" content="首页 - SdustBlog - Linux - 信息安全 - 计算机网络 - 计算机 ">
<link rel="shortcut icon" href="./images/favicon.ico">
<!-- css -->
<link rel="stylesheet" href="http://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link rel="stylesheet" href="./css/bootstrap.min.css">
<link rel="stylesheet" href="./css/pace.css">
<link rel="stylesheet" href="./css/custom.css">
<link rel="stylesheet" href="./css/pagination.css">
<!-- js -->
<script src="./js/jquery-2.1.3.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/pace.min.js"></script>
<script src="./js/modernizr.custom.js"></script>
</head>
<body>
<?php require './includes/header.php'; ?>
<div class="content-body">
<div class="container">
<div class="row">
<main class="col-md-8">
<?php
# 如果是访客的话需要重新连接数据库
if(!(isset($mysqli) && $mysqli -> connect_errno)){
require './includes/connect.php';
}
# 数据库查询文章列表
$query = "SELECT user_id, user_name, article_id, article_title, article_post_datetime, article_category_id, category_name, article_excerpt, article_click FROM users, articles, categories WHERE article_user_id=user_id AND article_category_id=category_id ORDER BY article_post_datetime DESC";
$result = $mysqli -> prepare($query);
$result -> execute();
$result -> bind_result($userid, $username, $articleid, $articletitle, $articlepostdatetime, $articlecategoryid, $categoryname, $articleexcerpt, $articleclick);
while($result -> fetch()){
$flag = 1; # 判断是否有文章,后续如果添加分页功能的话可去掉
require './includes/articleheader.php';
$articleexcerpt = strip_tags($articleexcerpt);
print<<<EOT
<div class="entry-content clearfix">
<p> $articleexcerpt  ...</p>
<div class="read-more cl-effect-14">
<a href="./detail.php?articleid=$articleid" class="more-link"> 继续阅读 <span class="meta-nav">→</span></a>
</div>
</div>
</article>
EOT;
}
$result -> close();
if(!isset($flag)){
echo '<div class="no-post">暂时还没有发布的文章!</div>';
}
?>
</main>
<!-- 页脚添加在这里-->
<?php require './includes/pageright.php'; ?>
</div>
</div>
</div>
<?php require './includes/mobile.php'; ?>
<script src="./js/script.js"></script>
</body>
</html>