-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser_home_page.php
262 lines (251 loc) · 8.55 KB
/
user_home_page.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<html>
<head>
<link rel="shortcut icon" type="image/x-icon" href="site_logo.png"/>
<link rel="stylesheet" type="text/css" href="user_home_page_css.css"/>
<title>Mingle in Jingle</title>
<script>
var fetch = setInterval(function(){online()},1000);
function online()
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("dis").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "online.php", true);
xmlhttp.send();
}
function search(str)
{
if(str.length == 0)
{
document.getElementById("sea").innerHTML = "";
}
else
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("sea").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "search.php?q="+str, true);
xmlhttp.send();
}
}
function likes(str,str2)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("span").innerHTML = xmlhttp.responseText;
}
}
if(str2 == 0)
{
xmlhttp.open("GET", "likes.php?q="+str, true);
}
if(str2 == 1)
{
xmlhttp.open("GET", "unlikes.php?q="+str, true);
}
xmlhttp.send();
}
</script>
</head>
<body>
<span id="span"></span>
<div class="header">
<div id="wrapper">
<div class="logo">
<a href="user_home_page.php"><img src="mingle.png" alt="image not displayed"/></a>
</div>
<div id="search">
<input type="text" id="search_bar" placeholder="Search" onkeyup="search(this.value)">
</div>
<div id="menu">
<a href="timeline.php?u=<?php session_start(); if($_SESSION['email'] != null)
{
$email = $_SESSION['email'];
}
else
{
$email = $_SESSION['email'];
}
echo $email;
?>">
<?php
require 'database_open.inc.php';
if($_SESSION['email'] != null)
{
$email = $_SESSION['email'];
}
else
{
$email = $_SESSION['email'];
}
$query1 = "SELECT `First Name`,`image` FROM `users` WHERE `email`='$email'";
$query_run1 = mysql_query($query1);
$query_data = mysql_fetch_assoc($query_run1);
$image = $query_data['image'];
echo '<img src="Pictures/'.$image.'" style="width:29px;height:29px;margin-top:-5px;position:absolute;margin-left:-35px;">'.$query_data['First Name'].'';
?></a>
<a href="messages.php">Messages</a>
<a href="group.php">Group</a>
<a href="change_settings_page.php">Settings</a>
<a href="logout.php">Logout</a>
</div>
</div>
</div>
<div id="sea" style="margin-top:60px;margin-left:360px;width:490px;position:fixed;border:1px solid rgb(233,234,237);z-index:2;padding:4px;background-color:rgb(233,234,237)"></div>
<div style="margin-left:360px;margin-top:90px;position:absolute">
<form action="post.php" method="POST">
<textarea name='SU' id="textarea" placeholder="Share what's new" required></textarea><br><br>
<input type='submit' value='Post'>
</form>
</div>
<div style="margin-top:436px;margin-left:940px;position:fixed;height:230px;width:360px;border:1px solid rgb(70,120,180);padding:0px">
<div style="background-color:rgb(70,120,180);color:white;height:20px;padding:5px;font-family:Catull;">
Start a new Chat
</div><br>
<div style="margin-left:10px">
<form action="chat_confirmation.php" method="POST" autocomplete="on">
<pre>
<input type="email" name="E" placeholder="Email" required><br>
<textarea name='M' id="textarea1" placeholder="Message..." required></textarea><br>
<input type="submit" value="Send">
</pre>
</form>
</div>
</div>
<div style="margin-top:90px;position:fixed;margin-left:940px;background-color:rgb(70,120,180);color:white;height:20px;width:350px;padding:5px;font-family:Catull;">
<pre><img src="online_image.jpg" width="20px" height="10px">Online <a href="#" onclick="online()" style="color:white;text-decoration:none">Refresh</a></pre>
<div id="dis" style="color:black;border:1px solid rgb(70,120,180);margin-left:-5px;margin-top:5px;width:348px;padding:5px;height:200px;overflow:auto"></div>
</div>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="fade.js"></script>
<script type="text/javascript" src="search_bar.js"></script>
</body>
</html>
<?php
require 'database_open.inc.php';
$_SESSION['grp'] = "";
if((isset($_SESSION['email']) && !empty($_SESSION['email'])))
{
$email = $_SESSION['email'];
$query1 = "SELECT `First Name`,`Last Name` FROM `users` WHERE email='$email'";
$query_run1 = mysql_query($query1);
$query_data1 = mysql_fetch_assoc($query_run1);
echo '<div style="
margin-top:355px;
margin-left:0px;
position:fixed;
height:50px;
width:180px;
z-index:1;">
<pre style="color:rgb(70,120,180);font-size:35px;margin-left:40px;margin-top:5px">'
.$query_data1['First Name'].' '.$query_data1['Last Name'].'</pre>
</div>';
$query3 = "SELECT `Id`,`image` FROM `users` WHERE email='$email'";
$query_run3 = mysql_query($query3);
$query_data3 = mysql_fetch_assoc($query_run3);
$image = $query_data3['image'];
echo "<div style='
margin-top:90px;
margin-left:40px;
position:fixed;
min-width:120px;
z-index:1;'>
<img width='250' height='250' src='Pictures/".$image."' alt='Default Profile Pic'>
</div>";
$id4 = $query_data3['Id'];
$query2 = "SELECT `Status`,`fromUser`,`time`,`likes`,`Id`,`people` FROM `status` ORDER BY ID DESC";
$query_run2 = mysql_query($query2);
while($query_data2 = mysql_fetch_assoc($query_run2))
{
$from = $query_data2['fromUser'];
$query17 = "SELECT `Id`,`follow` FROM `users` WHERE `email`='$from'";
$query_run17 = mysql_query($query17);
$query_data17 = mysql_fetch_assoc($query_run17);
$flag45 = false;
$len2 = strlen($query_data17['follow']);
for($x = 0; $x < $len2; $x++)
{
if($id4 == substr($query_data17['follow'],$x,1))
{
$flag45 = true;
break;
}
}
if($query_data17['Id'] == $id4)
{
$flag45 = true;
}
if($flag45 == true)
{
$post = $query_data2['Status'];
$time = $query_data2['time'];
$like = $query_data2['likes'];
$id = $query_data2['Id'];
$people = $query_data2['people'];
$query10 = "SELECT `Id` FROM `users` WHERE `email`='$email'";
$query_run10 = mysql_query($query10);
$query_data10 = mysql_fetch_assoc($query_run10);
$len = strlen((string)$query_data2['people']);
$flag10 = false;
for($i = 0;$i<$len;$i++)
{
if($query_data10['Id'] == substr($query_data2['people'],$i,1))
{
$flag10 = true;
break;
}
}
if($flag10 == true)
{
$lg = "Unlike";
$lgi = 1;
}
else
{
$lg = "Like";
$lgi = 0;
}
$query3 = "SELECT `First Name`,`Last Name`,`image` FROM `users` WHERE email='$from'";
$query_run3 = mysql_query($query3);
$query_data3 = mysql_fetch_assoc($query_run3);
$name1 = $query_data3['First Name'];
$name2 = $query_data3['Last Name'];
$image = $query_data3['image'];
echo ' <div style="margin-top:240px;margin-left:360px;position:absolute;height:125px;width:500px;overflow:auto;border:1px solid rgb(70,120,180);background-color:white">
<div style="">
<img width="55" height="55" src="Pictures/'.$image.'" alt="Default Profile Pic" style="padding-top:10px;padding-left:10px;">
</div>
<div style="padding-top:5px;padding-left:5px;margin-top:-55px;margin-left:70px;position:absolute">
'.$name1.' '.$name2.' updated his status.
</div>
<div style="padding-top:5px;padding-left:5px;margin-top:-35px;margin-left:70px;position:absolute;font-size:13px">
'.$time.'
</div>
<div style="padding-top:5px;padding-left:5px;margin-top:-18px;margin-left:70px;position:absolute;font-size:13px">
<a href="#" id="l" onclick="likes('.$id.','.$lgi.')" style="color:rgb(70,120,180);text-decoration:none;">'.$lg.'</a> '.$like.' people likes this.
</div>
<br><hr>
<div style="padding-top:5px;padding-left:5px;">
<pre style="color:rgb(70,120,180);font-size:15px;margin-top:0px;margin-left:10px;position:absolute;padding-bottom:5px;">'.htmlspecialchars($post).'</pre>
</div>
</div><br><br><br><br><br><br><br><br><br>';
}
}
}
else{
header('Location: please_log_in.html');
}
?>