-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
193 lines (132 loc) · 5.15 KB
/
index.php
File metadata and controls
193 lines (132 loc) · 5.15 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?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_status`='published'
AND `post_sticky`='0'
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`');
if (!count($posts)) {
stderr('There are <strong>no</strong> posts to show yet!');
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-footer.php");
exit;
}
?>
<div class="row">
<div class="col-md-12">
<?php
if (getValue("homepage_introduction_header")) {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-header-introduction.php");
}
?>
</div>
<!-- posts -->
<div class="col-md-<?= getValue("hide_all_sidebars") == 0 ? "12" : "9"; ?>">
<?php
$sticky = DB::getInstance()->select("SELECT * FROM `posts` WHERE `post_sticky`='1' LIMIT 1");
if (count($sticky) > 0) { ?>
<div class="card" style="box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);">
<div class="card-header bg-warning text-dark" style="font-family: 'Helvetica Neue', sans-serif; font-size: 16px; text-transform: uppercase; text-align: center; padding: 1rem;">
<small><i class="fas fa-pencil-alt"></i> Posted on <strong><?= date("F j, Y", strtotime($sticky[0]['post_date'])); ?></strong> by <strong><?= getPostersUsername($sticky[0]['post_member_id']); ?></strong>.</small>
<span class="float-end"><span class="badge bg-danger"><i class="fa-solid fa-note-sticky"></i></span></span>
</div>
<div class="card-body">
<?php
$postData = [
'post_title' => $sticky[0]['post_title'],
'post_id' => $sticky[0]['post_id'],
'post_image' => $sticky[0]['post_image'],
'post_image_alt_text' => $sticky[0]['post_image_alt_text'],
'post_body' => $sticky[0]['post_body']
];
?>
<div class="row">
<div class="col-md-4">
<?= createPostImage($postData); ?>
</div>
<div class="col-md-8">
<?= createPostTitle($postData); ?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?= createPostBody($postData); ?>
<?= createReadMoreButton($postData); ?>
</div>
</div>
</div>
<div class="card-footer mt-3 bg-warning text-dark" style="font-size: 14px;"><small><span class="float-end"><i class="fas fa-eye"></i> <?= $sticky[0]['post_views']; ?></span></small></div>
</div>
<?php } ?>
<?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");
?>