-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-back.php
69 lines (59 loc) · 1.84 KB
/
index-back.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
<?php
//Include the main page
include("rec/main.php");
//Set the timezone
date_default_timezone_set ("America/New York");
//Set the page title
$title = "Ligerbots Home Page";
//Load the header
include("rec/header.php");
//If the user is an editor, add a new post button
if($loggedin) {
if($user['editor']) {
echo('<div class="posteditbar"><a href="post.php">New Post</a></div>');
}
}
//Load the last 5 blog posts
//Post array
$posts = array();
//Formulate the query
$query = "SELECT * FROM " . $post_table;
//Execute the query
$result = mysqli_query($connection, $query);
//Additional posts to show
$apos = 0;
//Check if a start is specified
if(isSet($_GET['posts'])) {
$apos = intval($_GET['posts']);
}
//Iterate through the result, getting post names
for($i = 0; $i < ($apos + 5); $i++) {
if($row = mysqli_fetch_array($result)) {
$posts[$i] = $row;
}
}
//Invert the posts array
$posts = array_reverse($posts);
//Iterate through the posts and post them
foreach($posts as $post) {
//Parse the time
$date = date("l\, F jS\, Y \a\\t h:i A", $post['time']);
echo('<div class="post"><ptitle>' . $post['title'] . "</ptitle><br><pinfo>Posted on " . $date . " by " . $post['author'] . '</pinfo><br><div class="content">');
include("rec/data/blog/" . $post['time'] . ".html");
echo('</div>');
//If the user is an editor, give them editor options
if($loggedin) {
if($user['editor']) {
echo('<div class="posteditbar"><a href="epost.php?post=' . $post['time'] . '">Edit post</a> <a href="epost.php?post=' . $post['time'] . '&action=del">Delete</a> </div>');
}
}
//Finish off the post
echo('</div>');
}
//Add the next/previous buttons
echo('<a href="/?posts=' . ($apos + 5) . '">Show more posts</a>');
?>
<?php
//Include the footer
include("rec/footer.php");
?></p>