-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewpost.php
70 lines (66 loc) · 3.44 KB
/
viewpost.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
<?php
session_start();
if (!isset($_GET['postid']) || !isset($_GET['userid'])) {
header('location: error.php');
}
else {
$postid = $_GET['postid'];
$userid = $_GET['userid'];
}
if (isset($_GET['delete'])) {
$delete = 'true';
}
else {
$delete = 'false';
}
require_once('scripts/php/classes.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>SN!</title>
<link rel="stylesheet" href="scripts/style.css" type="text/css" />
<link rel="stylesheet" href="scripts/jquery/ui/jquery-ui.css">
</head>
<body>
<?php include('headers/header.php'); ?>
<div id="content">
<div class="wrapper">
<!-- Confirmation dialog for post deletion -->
<div id="dialog" title="Confirm Deletion">
<p><span class="ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>This post will be deleted. This cannot be undone. Are you sure?</p>
</div>
<center>
<div class="panel middle">
<?php
$post = Post::getPost($postid, $delete);
$following = User::fetchFollowing();
echo '<div class="postWrapper post_' . $post->postid . '">
<a href="user.php?userid=' . $post->userid . '"><img class="avatar" src="' . $post->avatar . '"></a>
<span class="name"><a href="user.php?userid=' . $post->userid . '">' . $post->username . '</a></span><span class="time"><a href="viewpost.php?userid=' . $post->userid . '&postid=' . $post->postid . '">' . $post->time . '</a></span>';
echo '<p>' . $post->body . '</p>';
// if post belongs to the user logged in, add a delete link
if ($_SESSION['id'] == $post->userid) {
echo '<div class="deleteLink" style="clear: both; text-align: right;"><input type="submit" value="delete" class="btnDelete" id="' . $post->postid .'"></div>';
}
if (in_array($post->userid, $following)) {
echo '<div class="unfollow' . $post->userid . '" style="clear: both; text-align: right;"><input type="submit" value="Unfollow" class="btnUnfollow" id="' . $post->userid . '"></div><div class="follow' . $post->userid . '" style="clear: both; text-align: right; display: none;"><input type="submit" value="Follow" class="btnFollow" id="' . $post->userid . '"></div>';
}
else {
if ($post->userid != $_SESSION['id']) {
echo '<div class="follow' . $post->userid . '" style="clear: both; text-align: right;"><input type="submit" value="Follow" class="btnFollow" id="' . $post->userid . '"></div><div class="unfollow' . $post->userid . '" style="clear: both; text-align: right; display: none;"><input type="submit" value="Unfollow" class="btnUnfollow" id="' . $post->userid . '"></div>';
}
}
echo '</div>';
?>
</div>
</center>
</div>
</div>
<?php include_once('headers/footer.php'); ?>
<script src="scripts/jquery/jquery.js"></script>
<script src="scripts/jquery/ui/jquery-ui.js"></script>
<script src="scripts/js/click.js"></script>
</body>
</html>