forked from psai11/Social-Networking-File
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages.php
96 lines (74 loc) · 2.16 KB
/
messages.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
<?php
include("includes/header.php");
$message_obj = new Message($con, $userLoggedIn);
if(isset($_GET['u']))
$user_to = $_GET['u'];
else {
$user_to = $message_obj->getMostRecentUser();
if($user_to == false)
$user_to = 'new';
}
if($user_to != "new")
$user_to_obj = new user($con, $user_to);
if(isset($_POST['post_message'])) {
if(isset($_POST['message_body'])) {
$body = mysqli_real_escape_string($con, $_POST['message_body']);
$date = date("Y-m-d H:i:s");
$message_obj->sendMessage($user_to,$body,$date);
}
}
?>
<div class="user_details column">
<a href="<?php echo $userLoggedIn; ?>"> <img src="<?php echo $user['PROFILE_PIC']; ?>"> </a>
<div class="user_details_left_right">
<?php
echo $user['NAME'];
?>
<br>
<a href="<?php echo $userLoggedIn; ?>">
<?php echo "@".$user['USERNAME']."<br>"; ?>
</a>
</div>
</div>
<div class="main_column column" id="main_column">
<?php
if($user_to != "new") {
echo "<h4>You and <a href='$user_to'>" . $user_to_obj->getName() . "</a></h4><hr><br>";
echo "<div class='loaded_messages' id='scroll_messages'>";
echo $message_obj->getMessages($user_to);
echo "</div>";
}
else {
echo "<h4>New Message</h4>";
}
?>
<div class="message_post">
<form action="" method="POST">
<?php
if($user_to == "new") {
echo "Select the friend you'd like to chat with... <br><br>";
?>
To: <input type='text' onkeyup='getUsers(this.value, "<?php echo $userLoggedIn; ?>")' name='q' placeholder='Name' autocomplete='off' id='search_text_input'>
<?php
echo "<div class='results'></div>";
}
else {
echo "<textarea name='message_body' id='message_textarea' placeholder='Write your message here...'></textarea>";
echo "<input type='submit' name='post_message' class='info' id='message_submit' value='Send'>";
}
?>
</form>
</div>
<script>
var div = document.getElementById("scroll_messages");
div.scrollTop = div.scrollHeight;
</script>
</div>
<div class="user_details column" id="conversations">
<h4>Conversations</h4>
<div class="loaded_conversations">
<?php echo $message_obj->getConvos(); ?>
</div>
<br>
<a href="messages.php?u=new">New Message</a>
</div>