-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
131 lines (127 loc) · 5.22 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
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
<?php
session_start();
include('header.php');
?>
<title>FChat | Alex | Timo</title>
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.2/css/font-awesome.min.css'>
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet" id="bootstrap-css">
<script src="js/chat.js"></script>
<script src="js/jquery-3.4.1.min.js"></script>
<style>
.modal-dialog {
width: 400px;
margin: 30px auto;
}
#dialog{
display: none;
}
</style>
<?php include('container.php');?>
<div class="container">
<?php if(isset($_SESSION['userID']) && $_SESSION['userID']) { ?>
<div class="chat">
<div id="frame">
<div id="sidepanel">
<div id="profile">
<?php
include ('Chat.php');
$chat = new Chat();
$loggedUser = $chat->getUserDetails($_SESSION['userID']);
echo '<div class="wrap">';
$currentSession = '';
foreach ($loggedUser as $user) {
$currentSession = $user['current_session'];
echo '<img id="profile-img" src="userpics/'.$user['profilePic'].'" class="online" alt="" />';
echo '<p>'.$user['username'].'</p>';
//echo '<i class="fa fa-chevron-down expand-button" aria-hidden="true"></i>';
echo '<div id="status-options">';
echo '<ul>';
echo '<li style="float: right" id="status-online" class="active"><span class="status-circle"></span> <p>Online  </p></li>';
echo '<li style="float: right" id="status-away"><span class="status-circle"></span> <p>Away  </p></li>';
echo '<li style="float: right" id="status-busy"><span class="status-circle"></span> <p>Busy  </p></li>';
echo '<li style="float: right" id="status-offline"><span class="status-circle"></span> <p>Offline  </p></li>';
echo '</ul>';
echo '</div>';
/*
echo '<div id="expanded">';
echo '<input type="text">userpics/'.$user['profilePic'].'</input>';
echo '<a href="logout.php">Logout</a>';
echo '</div>';
*/
}
echo '</div>';
?>
</div>
<div id="search">
<label for=""><i class="fa fa-search" aria-hidden="true"></i></label>
<input type="text" id="mySearch" onkeyup="searchUser()" placeholder="Search contacts..." />
</div>
<div id="contacts">
<?php
echo '<ul id="myUL">';
$chatUsers = $chat->chatUsers($_SESSION['userID']);
foreach ($chatUsers as $user) {
$status = 'offline';
if($user['status']) {
$status = 'online';
}
$activeUser = '';
if($user['userID'] == $currentSession) {
$activeUser = "active";
}
echo '<li id="'.$user['userID'].'" class="contact '.$activeUser.'" data-touserID="'.$user['userID'].'" data-tousername="'.$user['username'].'">';
echo '<div class="wrap">';
echo '<span id="status_'.$user['userID'].'" class="contact-status '.$status.'"></span>';
echo '<img src="userpics/'.$user['profilePic'].'" alt="" />';
echo '<div class="meta">';
echo '<p class="name">'.$user['username'].'<span id="unread_'.$user['userID'].'" class="unread">'.$chat->getUnreadMessageCount($user['userID'], $_SESSION['userID']).'</span></p>';
echo '<p class="preview"><span id="isTyping_'.$user['userID'].'" class="isTyping"></span></p>';
echo '</div>';
echo '</div>';
echo '</li>';
}
echo '</ul>';
?>
</div>
<div id="bottom-bar">
<button onclick="location.href='logout.php'" type="button"><i class="fa fa-sign-out fa-fw"></i>Logout</button>
<button id="settings"><i class="fa fa-cog fa-fw" aria-hidden="true"></i> <span>Settings</span></button>
</div>
</div>
<div class="content" id="content">
<div class="contact-profile" id="userSection">
<?php
$userDetails = $chat->getUserDetails($currentSession);
foreach ($userDetails as $user) {
echo '<img src="userpics/'.$user['profilePic'].'" alt="" />';
echo '<p>'.$user['username'].'</p>';
}
?>
</div>
<div class="messages" id="conversation">
<?php
echo $chat->getUserChat($_SESSION['userID'], $currentSession);
?>
</div>
<div class="message-input" id="replySection">
<div class="message-input" id="replyContainer">
<div class="wrap">
<input type="text" class="chatMessage" id="chatMessage<?php echo $currentSession; ?>" placeholder="Write your message..." />
<button class="submit chatButton" id="chatButton<?php echo $currentSession; ?>" style="padding-top: 5px;padding-bottom: 12px;"><i class="fa fa-paper-plane" aria-hidden="true"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
<?php } else { ?>
<br>
<br>
<strong><a href="login.php"><h3>Login To Access Chat System</h3></a></strong>
<strong><a href="register.php"><h3>Register To Chat System</h3></a></strong>
<?php } ?>
<br>
<br>
</div>
<?php include('footer.php');?>