-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.php
241 lines (204 loc) · 6.4 KB
/
home.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php
function time_stamp($session_time)
{
$time_difference = time() - $session_time ;
$seconds = $time_difference ;
$minutes = round($time_difference / 60 );
$hours = round($time_difference / 3600 );
$days = round($time_difference / 86400 );
$weeks = round($time_difference / 604800 );
$months = round($time_difference / 2419200 );
$years = round($time_difference / 29030400 );
if($seconds <= 60)
{
echo"$seconds seconds ago";
}
else if($minutes <=60)
{
if($minutes==1)
{
echo"one minute ago";
}
else
{
echo"$minutes minutes ago";
}
}
else if($hours <=24)
{
if($hours==1)
{
echo"one hour ago";
}
else
{
echo"$hours hours ago";
}
}
else if($days <=7)
{
if($days==1)
{
echo"one day ago";
}
else
{
echo"$days days ago";
}
}
else if($weeks <=4)
{
if($weeks==1)
{
echo"one week ago";
}
else
{
echo"$weeks weeks ago";
}
}
else if($months <=12)
{
if($months==1)
{
echo"one month ago";
}
else
{
echo"$months months ago";
}
}
else
{
if($years==1)
{
echo"one year ago";
}
else
{
echo"$years years ago";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Zink - Home</title>
<!-- <link rel="icon" type="image/svg+xml" href="ICONS/shot.svg"> -->
<link rel="icon" type="image/svg+xml" href="ICONS/logo.png">
<link rel="stylesheet" type="text/css" href="css/homecss.css">
</head>
<body>
<?php include ('session.php');?>
<div id="header" style="z-index: 1;">
<div class="head-view">
<ul>
<!--<li><img src="ICONS/shots.png"></li>-->
<li ><img src="ICONS/logo2.png" alt="logo" style=" height: 45px; left: 3px; top: 6px; position: relative; border: 1px solid #555; border-radius: 5px;"></li>
<li ><a href="home.php" title="Home" ><b id='zinkfont'>Zink</b></a></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li><a href="timeline.php" title="<?php echo $username ?>"><label><?php echo $username ?></label></a></li>
<li><a href="home.php" title="Home"><img src="ICONS/home.png"></a></li>
<li><a href="profile.php" title="Profile"><img src="ICONS/profile.png"></a></li>
<li><a href="photos.php" title="Zink"><img src="ICONS/shots.png"></a></li>
<li><a href="index1.php" title="Chitchat"><img src="ICONS/chats.png"></a></li>
<li><a href="logout.php" onclick='return confirm("Are you sure want to Zink Out <?php echo $username ?> ?");'><button class="btn-sign-in" value="Log out">Zink out!</button></a></li>
</ul>
</div>
</div>
<div id="container">
<div id="right-nav">
<div class="top">
<div class="clip1">
<a href="updatephoto.php" title="Change Profile Picture"> <img src="<?php $profile = $row['profile_picture'];
if (empty($profile)) $profile = "images/profile.jfif";
echo $profile ?>">
</a>
</div>
<h1>Zink It! <?php echo $username ?></h1>
</div>
<div>
<form method="post" action="post.php" enctype="multipart/form-data">
<textarea placeholder="Whats on your zink?" name="content" class="post-text" required></textarea>
<input type="file" name="image">
<button class="btn-share" name="Submit" value="Log out">Share</button>
</form>
</div>
</div>
<?php
include("includes/database.php");
$query=mySQLi_query($con,"SELECT * from post LEFT JOIN user on user.user_id = post.user_id order by post_id DESC");
while($row=mySQLi_fetch_array($query)){
$posted_by = $row['firstname']." ".$row['lastname'];
$location = $row['post_image'];
$content=$row['content'];
$post_id = $row['post_id'];
$time=$row['created'];
$profile = $row['profile_picture'];
if (empty($profile)) $profile = "images/profile.jfif";
?>
<div id="right-nav1">
<div class="profile-pics">
<img style="left: 15px; top: 15px; position: relative;" src="<?php echo $profile ?>">
<b style="left: 3px; bottom : 20px; position: relative;"><?php echo $posted_by ?></b>
<strong style="left: 3px; bottom : 20px; position: relative;"><?php echo $time = time_stamp($time); ?></strong>
</div>
<br />
<div class="post-content">
<p><?php echo $row['content']; ?></p>
<center>
<img src="<?php echo $location ?>">
</center>
</div>
<?php
include("includes/database.php");
$comment=mySQLi_query($con,"SELECT * from comments INNER JOIN user on user.user_id = comments.user_id where post_id='$post_id' order by post_id DESC");
while($row=mySQLi_fetch_array($comment)){
$comment_id=$row['comment_id'];
$content_comment=$row['content_comment'];
$time=$row['created'];
$post_id=$row['post_id'];
$user=$_SESSION['id'];
$profile = $row['profile_picture'];
if (empty($profile)) $profile = "images/profile.jfif";
?>
<div class="comment-display"<?php echo $comment_id ?>>
<div class="delete-post">
<a href="delete_comment.php<?php echo '?id='.$comment_id; ?>" onclick='return confirm("Are you sure want to delete comment?");' title="Delete your comment"><button class="btn-delete">X</button></a>
</div>
<div class="user-comment-name"><img src="<?php echo $profile; ?>"> <?php echo $row['name']; ?><b class="time-comment"><?php echo $time = time_stamp($time); ?></b></div>
<div class="comment"><?php echo $row['content_comment']; ?></div>
</div>
<br />
<?php
}
?>
<form method="POST" action="comment.php">
<div class="comment-area" style="width: 94%">
<?php $image=mysqli_query($con,"select * from user where user_id='$id'");
while($row=mysqli_fetch_array($image)){
?>
<img src="<?php $profile = $row['profile_picture'];
if (empty($profile)) $profile = "images/profile.jfif";
echo $profile ?>"width="50" height="50">
<?php } ?>
<input type="text" name="content_comment" placeholder="Write your comment here" class="comment-text">
<input type="hidden" name="post_id" value="<?php echo $post_id ?>">
<input type="hidden" name="user_id" value="<?php echo $firstname . ' ' . $lastname ?>">
<input type="hidden" name="image" value="<?php echo $profile ?>">
<input type="submit" name="post_comment" value="Enter" class="btn-comment">
</div>
</form>
</div>
<?php
}
?>
</div>
</body>
</html>