-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
86 lines (73 loc) · 4.23 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
84
85
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<?php
include "config.php";
$stylePath = "/assets/css/";
// SELECT
$stmt = $con->prepare("SELECT * FROM stylesheets");
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo "<link rel='stylesheet' href='" . $stylePath . $row['fileName'] . "' data-theme='" . $row['title'] . "'>";
}
$stmt->close();
?>
<script src="scripts/loadStylesheet.js"></script>
<script src="scripts/script.js"></script>
</head>
<body>
<?php
session_start();
include 'navigate.php'
?>
<main class="container">
<h1>Yesterweb Blog</h1>
<p>A collaborative blog about the past, present and future of the internet. </p>
<p>You can subscribe via RSS <a href="feed.php">here</a>.</p>
<div class="flex">
<div class="wrapper">
<?php
date_default_timezone_set("US/Eastern");
$stmt = $con->prepare("SELECT * FROM blogs WHERE approved = 1 ORDER BY id DESC");
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$id = $row['id'];
$name = $row['owner_name'];
$link = $row['owner_link'];
$dateposted = $row['dateposted'];
$title = $row['title'];
$entry = $row['entry'];
$formattedDate = date("l, F j, Y", strtotime($dateposted));
echo '<article class="blog">';
echo '<header class="title"><h2><a href="view.php?entry=' . $id . '">' . $title . '</a></h2></header>';
echo '<div class="whoWhen">Posted on <span class="date">' . $formattedDate . '</span>';
echo '<span class="author"> by <a href="' . $link . '">' . $name . '</a></span></div>';
echo '<div class="post">' . $entry . '</div>';
$sql = "SELECT COUNT(*) FROM comments WHERE blogid = " . $id;
$qry = mysqli_query($con, $sql);
$totalCount = mysqli_fetch_assoc($qry)['COUNT(*)'];
echo '<section class="links">';
if ($totalCount == 1) {
echo '<a href="view.php?entry=' . $id . '" id="View"" id="addComment">' . $totalCount . ' Comment</a><a href="view.php?entry=' . $id . '" id="View">View Entry</a>';
} else if ($totalCount == 0) {
echo '<a href="view.php?entry=' . $id . '" id="View"" id="addComment">Add Comment</a><a href="view.php?entry=' . $id . '" id="View">View Entry</a>';
} else {
echo '<a href="view.php?entry=' . $id . '" id="View"" id="addComment">' . $totalCount . ' Comments</a><a href="view.php?entry=' . $id . '" id="View">View Entry</a></section>';
}
echo '</section></article>';
}
$stmt->close();
?>
</div>
<aside class="sidebar">
<? include "sidebar.php" ?>
</aside>
</div>
</main>
</body>
</html>