Skip to content

Commit 9032d50

Browse files
Add files via upload
1 parent 1a12cd1 commit 9032d50

19 files changed

+2360
-0
lines changed

.htaccess

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ErrorDocument 404 /error404.php
2+
ErrorDocument 403 /index.php

blog.php

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
include "core.php";
3+
head();
4+
5+
$queryst = mysqli_query($connect, "SELECT date_format FROM `settings` LIMIT 1");
6+
$rowst = mysqli_fetch_assoc($queryst);
7+
?>
8+
<div class="col-md-8">
9+
10+
<div class="card">
11+
<div class="card-header"><i class="far fa-file-alt"></i> Articles</div>
12+
<div class="card-body">
13+
14+
<?php
15+
$postsperpage = 6;
16+
17+
$pageNum = 1;
18+
if (isset($_GET['page'])) {
19+
$pageNum = $_GET['page'];
20+
}
21+
if (!is_numeric($pageNum)) {
22+
echo '<meta http-equiv="refresh" content="0; url=blog.php">';
23+
exit();
24+
}
25+
$rows = ($pageNum - 1) * $postsperpage;
26+
27+
$run = mysqli_query($connect, "SELECT * FROM `posts` WHERE active='Yes' ORDER BY id DESC LIMIT $rows, $postsperpage");
28+
$count = mysqli_num_rows($run);
29+
if ($count <= 0) {
30+
echo '<div class="alert alert-info">There are no published posts</div>';
31+
} else {
32+
while ($row = mysqli_fetch_assoc($run)) {
33+
34+
$image = "";
35+
if($row['image'] != "") {
36+
$image = '<img src="' . $row['image'] . '" alt="' . $row['title'] . '" class="card-img-top" width="100%" height="225"">';
37+
} else {
38+
$image = '<svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false">
39+
<title>No Image</title><rect width="100%" height="100%" fill="#55595c"/>
40+
<text x="46%" y="50%" fill="#eceeef" dy=".3em">No Image</text></svg>';
41+
}
42+
43+
echo '
44+
<div class="card shadow-sm">
45+
<a href="post.php?id=' . $row['id'] . '">
46+
'. $image .'
47+
</a>
48+
<div class="card-body">
49+
<a href="post.php?id=' . $row['id'] . '">
50+
<h5 class="card-title">' . $row['title'] . '</h5>
51+
</a>
52+
<div class="d-flex justify-content-between align-items-center">
53+
<a href="category.php?id=' . $row['category_id'] . '">
54+
<span class="badge bg-primary">' . post_category($row['category_id']) . '</span>
55+
</a>
56+
<small><i class="fas fa-comments"></i> Comments:
57+
<a href="post.php?id=' . $row['id'] . '#comments" class="blog-comments"><b>' . post_commentscount($row['id']) . '</b></a>
58+
</small>
59+
</div>
60+
<p class="card-text">' . short_text(strip_tags(html_entity_decode($row['content'])), 400) . '</p>
61+
<div class="d-flex justify-content-between align-items-center">
62+
<b><i class="fas fa-user-edit"></i> ' . post_author($row['author_id']) . '</b>
63+
<small class="text-muted">
64+
<i class="far fa-calendar-alt"></i> ' . date($rowst['date_format'], strtotime($row['date'])) . ', ' . $row['time'] . '
65+
</small>
66+
</div>
67+
</div>
68+
</div><br />
69+
';
70+
}
71+
72+
$query = "SELECT COUNT(id) AS numrows FROM posts WHERE active='Yes'";
73+
$result = mysqli_query($connect, $query);
74+
$row = mysqli_fetch_array($result);
75+
$numrows = $row['numrows'];
76+
$maxPage = ceil($numrows / $postsperpage);
77+
78+
$pagenums = '';
79+
80+
echo '<center>';
81+
82+
for ($page = 1; $page <= $maxPage; $page++) {
83+
if ($page == $pageNum) {
84+
$pagenums .= "<a href='?page=$page' class='btn btn-primary'>$page</a> ";
85+
} else {
86+
$pagenums .= "<a href=\"?page=$page\" class='btn btn-default'>$page</a> ";
87+
}
88+
}
89+
90+
if ($pageNum > 1) {
91+
$page = $pageNum - 1;
92+
$previous = "<a href=\"?page=$page\" class='btn btn-default'><i class='fa fa-arrow-left'></i> Previous</a> ";
93+
94+
$first = "<a href=\"?page=1\" class='btn btn-default'><i class='fa fa-arrow-left'\></i> <i class='fa fa-arrow-left'></i> First</a> ";
95+
} else {
96+
$previous = ' ';
97+
$first = ' ';
98+
}
99+
100+
if ($pageNum < $maxPage) {
101+
$page = $pageNum + 1;
102+
$next = "<a href=\"?page=$page\" class='btn btn-default'><i class='fa fa-arrow-right'></i> Next</a> ";
103+
104+
$last = "<a href=\"?page=$maxPage\" class='btn btn-default'><i class='fa fa-arrow-right'></i> <i class='fa fa-arrow-r'></i> Last</a> ";
105+
} else {
106+
$next = ' ';
107+
$last = ' ';
108+
}
109+
110+
echo $first . $previous . $pagenums . $next . $last;
111+
112+
echo '</center>';
113+
}
114+
?>
115+
116+
</div>
117+
</div>
118+
119+
</div>
120+
<?php
121+
sidebar();
122+
footer();
123+
?>

category.php

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?php
2+
include "core.php";
3+
head();
4+
5+
$queryst = mysqli_query($connect, "SELECT date_format FROM `settings` LIMIT 1");
6+
$rowst = mysqli_fetch_assoc($queryst);
7+
8+
$category_id = (int) $_GET['id'];
9+
$runq = mysqli_query($connect, "SELECT * FROM `categories` WHERE id='$category_id'");
10+
$rw = mysqli_fetch_assoc($runq);
11+
12+
if (empty($category_id)) {
13+
echo '<meta http-equiv="refresh" content="0; url=blog.php">';
14+
exit();
15+
}
16+
17+
if (mysqli_num_rows($runq) == 0) {
18+
echo '<meta http-equiv="refresh" content="0; url=blog.php">';
19+
exit();
20+
}
21+
?>
22+
<div class="col-md-8">
23+
24+
<div class="card">
25+
<div class="card-header"><i class="far fa-file-alt"></i> Blog - <?php
26+
echo $rw['category'];
27+
?></div>
28+
<div class="card-body">
29+
30+
<?php
31+
$postsperpage = 6;
32+
33+
$pageNum = 1;
34+
if (isset($_GET['page'])) {
35+
$pageNum = $_GET['page'];
36+
}
37+
if (!is_numeric($pageNum)) {
38+
echo '<meta http-equiv="refresh" content="0; url=blog.php">';
39+
exit();
40+
}
41+
$rows = ($pageNum - 1) * $postsperpage;
42+
43+
$run = mysqli_query($connect, "SELECT * FROM `posts` WHERE category_id='$category_id' and active='Yes' ORDER BY id DESC LIMIT $rows, $postsperpage");
44+
$count = mysqli_num_rows($run);
45+
if ($count <= 0) {
46+
echo '<div class="alert alert-info">There are no published posts</div>';
47+
} else {
48+
while ($row = mysqli_fetch_assoc($run)) {
49+
50+
$image = "";
51+
if($row['image'] != "") {
52+
$image = '<img src="' . $row['image'] . '" alt="' . $row['title'] . '" class="card-img-top" width="100%" height="225"">';
53+
} else {
54+
$image = '<svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Thumbnail" preserveAspectRatio="xMidYMid slice" focusable="false">
55+
<title>No Image</title><rect width="100%" height="100%" fill="#55595c"/>
56+
<text x="46%" y="50%" fill="#eceeef" dy=".3em">No Image</text></svg>';
57+
}
58+
59+
echo '
60+
<div class="card shadow-sm">
61+
<a href="post.php?id=' . $row['id'] . '">
62+
'. $image .'
63+
</a>
64+
<div class="card-body">
65+
<a href="post.php?id=' . $row['id'] . '">
66+
<h5 class="card-title">' . $row['title'] . '</h5>
67+
</a>
68+
<div class="d-flex justify-content-between align-items-center">
69+
<a href="category.php?id=' . $row['category_id'] . '">
70+
<span class="badge bg-primary">' . post_category($row['category_id']) . '</span>
71+
</a>
72+
<small><i class="fas fa-comments"></i> Comments:
73+
<a href="post.php?id=' . $row['id'] . '#comments" class="blog-comments">
74+
<strong>' . post_commentscount($row['id']) . '</strong>
75+
</a>
76+
</small>
77+
</div>
78+
<p class="card-text">' . short_text(strip_tags(html_entity_decode($row['content'])), 400) . '</p>
79+
<div class="d-flex justify-content-between align-items-center">
80+
<b><i class="fas fa-user-edit"></i> ' . post_author($row['author_id']) . '</b>
81+
<small class="text-muted">
82+
<i class="far fa-calendar-alt"></i> ' . date($rowst['date_format'], strtotime($row['date'])) . ', ' . $row['time'] . '
83+
</small>
84+
</div>
85+
</div>
86+
</div><br />
87+
';
88+
}
89+
90+
$query = "SELECT COUNT(id) AS numrows FROM posts WHERE category_id='$category_id' and active='Yes'";
91+
$result = mysqli_query($connect, $query);
92+
$row = mysqli_fetch_array($result);
93+
$numrows = $row['numrows'];
94+
$maxPage = ceil($numrows / $postsperpage);
95+
96+
$pagenums = '';
97+
98+
echo '<center>';
99+
100+
for ($page = 1; $page <= $maxPage; $page++) {
101+
if ($page == $pageNum) {
102+
$pagenums .= "<a href='?id=$category_id&page=$page' class='btn btn-primary'>$page</a> ";
103+
} else {
104+
$pagenums .= "<a href=\"?id=$category_id&page=$page\" class='btn btn-default'>$page</a> ";
105+
}
106+
}
107+
108+
if ($pageNum > 1) {
109+
$page = $pageNum - 1;
110+
$previous = "<a href=\"?id=$category_id&page=$page\" class='btn btn-default'><i class='fa fa-arrow-left'></i> Previous</a> ";
111+
112+
$first = "<a href=\"?id=$category_id&page=1\" class='btn btn-default'><i class='fa fa-arrow-left'\></i> <i class='fa fa-arrow-left'></i> First</a> ";
113+
} else {
114+
$previous = ' ';
115+
$first = ' ';
116+
}
117+
118+
if ($pageNum < $maxPage) {
119+
$page = $pageNum + 1;
120+
$next = "<a href=\"?id=$category_id&page=$page\" class='btn btn-default'><i class='fa fa-arrow-right'></i> Next</a> ";
121+
122+
$last = "<a href=\"?id=$category_id&page=$maxPage\" class='btn btn-default'><i class='fa fa-arrow-right'></i> <i class='fa fa-arrow-r'></i> Last</a> ";
123+
} else {
124+
$next = ' ';
125+
$last = ' ';
126+
}
127+
128+
echo $first . $previous . $pagenums . $next . $last;
129+
130+
echo '</center>';
131+
}
132+
?>
133+
134+
</div>
135+
</div>
136+
137+
</div>
138+
<?php
139+
sidebar();
140+
footer();
141+
?>

contact.php

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?php
2+
include "core.php";
3+
head();
4+
?>
5+
<div class="col-md-8">
6+
<div class="card">
7+
<div class="card-header"><i class="fas fa-envelope"></i> Contact</div>
8+
<div class="card-body">
9+
10+
<h5>Social Profiles</h5>
11+
<div class="list-group">
12+
<?php
13+
$run = mysqli_query($connect, "SELECT * FROM `settings`");
14+
$site = mysqli_fetch_assoc($run);
15+
?>
16+
<a class="list-group-item list-group-item-action" href="mailto:<?php
17+
echo $site['email'];
18+
?>" target="_blank"><strong><i class="fa fa-envelope"></i><span>&nbsp; <?php
19+
echo $site['email'];
20+
?></span></strong></a>
21+
<?php
22+
if ($site['facebook'] != '') {
23+
?>
24+
<a class="list-group-item list-group-item-primary list-group-item-action" href="<?php
25+
echo $site['facebook'];
26+
?>" target="_blank"><strong><i class="fab fa-facebook-square"></i>&nbsp; Facebook</strong></a>
27+
<?php
28+
}
29+
if ($site['instagram'] != '') {
30+
?>
31+
<a class="list-group-item list-group-item-warning list-group-item-action" href="<?php
32+
echo $site['instagram'];
33+
?>" target="_blank"><strong><i class="fab fa-instagram"></i>&nbsp; Instagram</strong></a>
34+
<?php
35+
}
36+
if ($site['twitter'] != '') {
37+
?>
38+
<a class="list-group-item list-group-item-info list-group-item-action" href="<?php
39+
echo $site['twitter'];
40+
?>" target="_blank"><strong><i class="fab fa-twitter-square"></i>&nbsp; Twitter</strong></a>
41+
<?php
42+
}
43+
if ($site['youtube'] != '') {
44+
?>
45+
<a class="list-group-item list-group-item-danger list-group-item-action" href="<?php
46+
echo $site['youtube'];
47+
?>" target="_blank"><strong><i class="fab fa-youtube-square"></i>&nbsp; YouTube</strong></a>
48+
<?php
49+
}
50+
if ($site['linkedin'] != '') {
51+
?>
52+
<a class="list-group-item list-group-item-primary list-group-item-action" href="<?php
53+
echo $site['linkedin'];
54+
?>" target="_blank"><strong><i class="fab fa-linkedin"></i>&nbsp; LinkedIn</strong></a>
55+
<?php
56+
}
57+
?>
58+
</div>
59+
60+
<br /><hr>
61+
<h5>Leave Your Message</h5>
62+
<?php
63+
if (isset($_POST['send'])) {
64+
if ($logged == 'No') {
65+
$name = $_POST['name'];
66+
$email = $_POST['email'];
67+
} else {
68+
$name = $rowu['username'];
69+
$email = $rowu['email'];
70+
}
71+
$content = $_POST['text'];
72+
73+
$date = date('d F Y');
74+
$time = date('H:i');
75+
76+
$captcha = '';
77+
78+
if (isset($_POST['g-recaptcha-response'])) {
79+
$captcha = $_POST['g-recaptcha-response'];
80+
}
81+
if ($captcha) {
82+
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($row['gcaptcha_secretkey']) . '&response=' . urlencode($captcha);
83+
$response = file_get_contents($url);
84+
$responseKeys = json_decode($response, true);
85+
if ($responseKeys["success"]) {
86+
87+
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
88+
echo '<div class="alert alert-danger">The entered E-Mail Address is invalid.</div>';
89+
} else {
90+
$query = mysqli_query($connect, "INSERT INTO messages (name, email, content, date, time) VALUES('$name','$email','$content','$date','$time')");
91+
echo '<div class="alert alert-success">Your message has been sent successfully.</div>';
92+
}
93+
}
94+
}
95+
}
96+
?>
97+
<form method="post" action="">
98+
<?php
99+
if ($logged == 'No') {
100+
?>
101+
<label for="name"><i class="fa fa-user"></i> Your Name:</label>
102+
<input type="text" name="name" id="name" value="" class="form-control" required />
103+
<br />
104+
105+
<label for="email"><i class="fa fa-envelope"></i> Your E-Mail Address:</label>
106+
<input type="email" name="email" id="email" value="" class="form-control" required />
107+
<br />
108+
<?php
109+
}
110+
?>
111+
<label for="input-message"><i class="far fa-file-alt"></i> Your Message:</label>
112+
<textarea name="text" id="input-message" rows="8" class="form-control" required></textarea>
113+
114+
<br /><center><div class="g-recaptcha" data-sitekey="<?php
115+
echo $row['gcaptcha_sitekey'];
116+
?>"></div></center><br />
117+
118+
<input type="submit" name="send" class="btn btn-primary col-12" value="Send" />
119+
</form><br />
120+
</div>
121+
</div>
122+
</div>
123+
<?php
124+
sidebar();
125+
footer();
126+
?>

0 commit comments

Comments
 (0)