From 79d3c716e38084beab01d34a5f49a5aee7e72526 Mon Sep 17 00:00:00 2001 From: Snap Date: Sat, 25 Apr 2015 22:30:21 -0700 Subject: Some work on the Chat. Fixed bug where user could chat as "SERVER" --- includes/chats.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'includes') 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 "); -- cgit v1.2.3