-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
77 lines (66 loc) · 2.64 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
<?php
include ('./classes/DB.php');
include ('./classes/Login.php');
include ('./classes/Post.php');
include ('./classes/Comment.php');
include ('./classes/Notify.php');
$showTimeLine = false;
if (Login::isLoggedIn()) {
echo 'Logged In as ID:' . Login::isLoggedIn() . "<br>";
$userid = Login::isLoggedIn();
$showTimeLine = true;
header("Location: /SushiNetwork/index.html"); // new page for signed in users
} else {
header("Location: /SushiNetwork/create-account.html"); // new page sign up
die( 'Not logged in <br>' );
}
if (isset($_GET['postid']) && !isset($_POST['comment'])) {
Post::likePost($_GET['postid'], $userid);
}
if (isset($_POST['comment'])) {
Comment::createComment($_POST['commentbody'], $_GET['postid'], $userid);
}
if (isset($_POST['searchbox'])) {
echo "NOT Developed Yet Vid29";
//$users=DB::query('SELECT users.username FROM users WHERE user.username LIKE :username',array(':username'=>'%'.$_POST['searchbox'].'%'));
}
?>
<form action="index.php" method="post">
<input type="search" name="searchbox">
<input type="submit" name="search" value="Search">
</form>
<?php
$followingposts = DB::query('SELECT posts.id, posts.body, posts.likes, users.username FROM users, posts, followers
WHERE posts.user_id=followers.user_id
AND users.id=posts.user_id
AND follower_id=:userid
ORDER BY posts.posted_at DESC',array(':userid'=>$userid));
foreach ($followingposts as $post) {
echo htmlspecialchars($post['body']) . " ~ " . $post['likes'] . " Likes BY " . $post['username'] . "<br>";
echo "<form action='index.php?postid=" . $post['id'] . "' method='post'>";
if (!DB::query('SELECT post_id FROM post_likes WHERE post_id=:post_id AND user_id=:user_id', array(':post_id' => $post['id'], ':user_id' => $userid))) {
echo "<input type='submit' name='like' value='Like'>";
} else {
echo "<input type='submit' name='unlike' value='unLike'>";
}
echo "<span>" . $post['likes'] . " Likes</span>
</form>
<form action='index.php?postid=".$post['id']."' method='post'>
<textarea name='commentbody' rows='3' cols='55'></textarea>
<input type='submit' name='comment' value='Comment'>
</form>";
Comment::displayComments($post['id']);
echo"
<hr><br>
";
}
?>
<html>
<head>
<title>SSN: TimeLine</title>
<meta charset="utf-8">
</head>
<body>
<h1>INDEX PAGE</h1>
</body>
</html>