-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
137 lines (86 loc) · 3.45 KB
/
search.php
File metadata and controls
137 lines (86 loc) · 3.45 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
require_once 'include/db.inc.php';
require_once 'include/class_autoloader.inc.php';
require_once 'include/config.inc.php';
require_once 'include/vendor/plasticbrain/php-flash-messages/src/FlashMessages.php';
$msg = new \Plasticbrain\FlashMessages\FlashMessages();
$keyword = trim($_GET['keyword']);
if (!isset($keyword) || strlen($keyword) < 5) {
header('Location:index.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Home page |
<?php echo SITE_NAME; ?>
</title>
<?php require_once 'partials/__head.php'; ?>
</head>
<body>
<?php require_once 'partials/__nav.php' ?>
<?php require_once 'partials/__page_header.php' ?>
<!-- Main Content -->
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-10 mx-auto">
<?php
$blog = new Blog;
$user = new User;
$posts = $blog->searchBlog($keyword)['posts'];
foreach ($posts as $post) {
?>
<div class="post-preview">
<a href="post.php?slug=<?php echo $post['slug']; ?>#disqus_thread">
<h2 class="post-title">
<?php echo $post['title'] ?>
</h2>
<h3 class="post-subtitle">
<?php echo substr($post['excerpt'], 0, 200) ?>
</h3>
</a>
<p class="post-meta">Posted by
<a href="user.php?slug=<?= $user->getUserDetails($post['user_id'])[0]['slug'] ?>">
<?php echo $user->getUserDetails($post['user_id'])[0]['name'] ?>
</a>
on
<?php
$timeago = new get_timeago;
echo $timeago->timeago($post['created_at']);
?>
</p>
</div>
<?php
} // foreach
if (count($posts) > 0) {
$pages = $blog->searchBlog($keyword)['pages'];
?>
<nav aria-label="Page navigation example">
<ul class="pagination">
<?php
for ($x = 1; $x <= $pages; $x++) {
$perPage = $blog->searchBlog($keyword)['per-page'];
?>
<li class="page-item"><a class="page-link"
href="?keyword=<?php echo $keyword; ?>&page=<?php echo $x; ?>&per-page=<?php echo $perPage; ?>"><?php echo $x; ?></a></li>
<?php
} // for
?>
</ul>
</nav>
<?php
} // main if
?>
</div>
</div>
</div>
<hr>
<?php require_once 'partials/__footer.php' ?>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Custom scripts for this template -->
<script src="js/clean-blog.min.js"></script>
</body>
</html>