diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/chats.php | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/includes/chats.php b/includes/chats.php index 0e48ecf..c4a43dc 100644 --- a/includes/chats.php +++ b/includes/chats.php @@ -103,7 +103,7 @@ function enterChannel($userID, $channel = 1) { (`userID`, `channel`, `dateEntered`, `isHere`)
VALUES (?, ?, NOW(), true)
- ON DUPLICATE KEY UPDATE `isHere` = true
+ ON DUPLICATE KEY UPDATE `isHere` = true, dateLastActive = NOW()
");
$stmt->bind_param('ii', $userID, $channel);
$stmt->execute();
@@ -122,6 +122,23 @@ function exitChannel($userID, $channel = 1) { return;
}
+
+function channelListUpdated($timeStamp) {
+ global $mysqli;
+
+ $stmt = $mysqli->prepare("SELECT `value` FROM `settings`
+ WHERE `name` = 'Channel_Last_Update' AND
+ `value` < '?'"
+ );
+ $stmt->bind_param( "i", $timeStamp);
+ $stmt->execute();
+
+ $stmt->bind_result($value);
+
+ return $value;
+}
+
+
//Get a list of users in channel
function getChannelList($channel = 1) {
global $mysqli;
@@ -130,13 +147,15 @@ function getChannelList($channel = 1) { $res = $mysqli->query("
SELECT
- chatUsers.userID,
+ chatUsers.userID as 'ID',
chatUsers.dateEntered,
- chatUsers.dateLastActive,
+
+ TIME_TO_SEC(TIMEDIFF(NOW(), chatUsers.dateLastActive)) as dateLastActive,
+
chatUsers.isAdmin,
chatUsers.isMod,
- users.displayName,
+ users.displayName as 'display',
users.displayColor,
users.wallColor,
users.wallEmblem,
@@ -144,6 +163,7 @@ function getChannelList($channel = 1) { FROM `chatUsers`
LEFT JOIN `users`
ON chatUsers.userID = users.ID
+ WHERE chatUsers.dateLastActive > NOW() - INTERVAL 5 MINUTE
ORDER BY chatUsers.isMod DESC, chatUsers.dateEntered DESC
");
$array = array();
@@ -152,7 +172,7 @@ function getChannelList($channel = 1) { return false;
}
while ($response = $res->fetch_assoc()) {
- $array[] = $response;
+ $array['users'][] = $response;
}
$res->close();
$mysqli->close();
|