-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
146 lines (98 loc) · 3.58 KB
/
search.php
File metadata and controls
146 lines (98 loc) · 3.58 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
138
139
140
141
142
143
144
145
146
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-db-connection.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-functions.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-header.php");
?>
<main>
<?php
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$max = (int)getValue("homepage_pagination");
$from = ($page * $max) - $max;
$posts = DB::getInstance()->select("
SELECT *
FROM `posts`
WHERE `post_title` LIKE '%{$_GET['s']}%'
ORDER BY `post_date` DESC
LIMIT :from, :max_results",
[
'from' => [
'type' => PDO::PARAM_INT,
'value' => $from
],
'max_results' => [
'type' => PDO::PARAM_INT,
'value' => $max
]
]);
$total = DB::getInstance()->selectValue("SELECT count(*) FROM `posts` WHERE `post_title` LIKE '%{$_GET['s']}%'");
if (!count($posts)) {
stderr('Sorry, there are <strong>no</strong> results for that keyword.');
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
die();
} else {
stdmsg("Found you <strong>{$total}</strong> post(s) for the search <strong>{$_GET['s']}</strong>.");
}
?>
<?php
if (isset($_GET['s'])) {
$params = [];
$pagination = [];
$params['s'] = $_GET['s'];
$pagination['s'] = $_GET['s'];
}
?>
<div class="row">
<!-- posts -->
<div class="col-md-<?= getValue("hide_all_sidebars") == 0 ? "12" : "9"; ?>">
<?php
$count = 0;
foreach($posts as $post) {
?>
<div class="card" style="box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">
<div class="card-header" style="font-family: 'Helvetica Neue', sans-serif; font-size: 16px; text-transform: uppercase; text-align: center; background-color: transparent; padding: 1rem;">
<small><i class="fas fa-pencil-alt"></i> Posted on <strong><?= date("F j, Y", strtotime($post['post_date'])); ?></strong> by <strong><span class="text-success"><?= getPostersUsername($post['post_member_id']); ?></span></strong>.</small>
</div>
<div class="card-body">
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-post-structure.php"); ?>
</div>
<div class="card-footer mt-3" style="font-size: 14px; background-color: transparent;"><?= ($count == $max) ? pagination($page, $total, $max) : "<small><span class=\"float-end\"><i class=\"fas fa-eye\"></i> {$post['post_views']}</span></small>"; ?></div>
</div>
<?php } ?>
</div>
<?php if (getValue("hide_all_sidebars") != 0) { ?>
<!-- categories / sidebars -->
<div class="col-md-3">
<?php
if (!empty(getValue("about_us_header")) && !empty(getValue("about_us_text"))) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-about-us.php");
}
?>
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sidebar-recent-posts.php");
?>
<?php
if (getValue("homepage_show_categories")) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sidebar-categories.php");
}
?>
<?php
if (!empty(getValue("sidebar_cta_1_header")) && !empty(getValue("sidebar_cta_1_text"))) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sidebar-cta-1.php");
}
?>
<?php
if (!empty(getValue("sidebar_cta_2_header")) && !empty(getValue("sidebar_cta_2_text"))) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-sidebar-cta-2.php");
}
?>
</div>
<?php } ?>
</div>
</main>
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
?>