diff options
Diffstat (limited to 'includes/chats.php')
-rw-r--r-- | includes/chats.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/includes/chats.php b/includes/chats.php index 47ecd39..5bfd61f 100644 --- a/includes/chats.php +++ b/includes/chats.php @@ -108,6 +108,7 @@ function enterChannel($userID, $channel = 1) { $stmt->bind_param('ii', $userID, $channel);
$stmt->execute();
$stmt->close();
+ cleanupChannel();
return;
}
@@ -122,6 +123,14 @@ function exitChannel($userID, $channel = 1) { return;
}
+//User leaves the channel
+function cleanupChannel($channel = 1) {
+ global $mysqli;
+
+ $mysqli->query("DELETE FROM `chatUsers` WHERE TIME_TO_SEC(TIMEDIFF(NOW(), chatUsers.dateLastActive)) > 800");
+ return;
+}
+
function channelListUpdated($timeStamp) {
global $mysqli;
@@ -150,7 +159,8 @@ function getChannelList($channel = 1) { chatUsers.userID as 'ID',
chatUsers.dateEntered,
- TIME_TO_SEC(TIMEDIFF(NOW(), chatUsers.dateLastActive)) as dateLastActive,
+ TIME_TO_SEC(TIMEDIFF(NOW(), chatUsers.dateLastActive)) as secFromLastActive,
+ TIME_TO_SEC(TIMEDIFF(NOW(), users.dateChatGaggedUntil)) as secSinceGagged,
chatUsers.isAdmin,
chatUsers.isMod,
@@ -160,9 +170,11 @@ function getChannelList($channel = 1) { users.wallColor,
users.wallEmblem,
users.wallOrientation
+
FROM `chatUsers`
LEFT JOIN `users`
ON chatUsers.userID = users.ID
+ WHERE TIME_TO_SEC(TIMEDIFF(NOW(), chatUsers.dateLastActive)) < 300
ORDER BY chatUsers.isMod DESC, chatUsers.dateEntered ASC
");
|