From 640816989a99e069397ed18f3fa703d1ec12d596 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 15 Jan 2014 01:39:04 -0800 Subject: More work on channel list. --- ajax/chat.ajax.php | 13 ++++++-- css/chat.css | 4 +-- includes/chats.php | 30 ++++++++++++++--- pages/chat.php | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 125 insertions(+), 16 deletions(-) diff --git a/ajax/chat.ajax.php b/ajax/chat.ajax.php index 8302c33..91c5b95 100644 --- a/ajax/chat.ajax.php +++ b/ajax/chat.ajax.php @@ -7,10 +7,15 @@ session_start(); // } -ini_set('display_errors',1); -ini_set('display_startup_errors',1); -error_reporting(-1); +//ini_set('display_errors',1); +//ini_set('display_startup_errors',1); +//error_reporting(-1); +if (isset($_REQUEST['pollChannelList'])) { + require_once('../includes/chats.php'); + echo json_encode(getChannelList()); + exit; +} if (isset($_SESSION['chatLastReset'])) $chatLastReset = $_SESSION['chatLastReset']; else $chatLastReset = 0; @@ -50,7 +55,9 @@ $use_psuedo_longpoll = true; require_once('../includes/chats.php'); +//exit; +enterChannel($userID); $sent = false; if (isset($_REQUEST['messages'])) { diff --git a/css/chat.css b/css/chat.css index 5973b4d..d0bccab 100644 --- a/css/chat.css +++ b/css/chat.css @@ -89,7 +89,7 @@ font-family: 'Trebuchet MS1', 'Trebuchet MS', sans-serif; font-size: 16px; display: inline-block; - width: 525px; + width: 335px; padding: 5px 5px 5px 5px; white-space: pre-wrap; /* CSS3 */ white-space: -moz-pre-wrap; /* Firefox */ @@ -122,7 +122,7 @@ } .chatMessage { - width:780px; + width:590px; min-height:35px; margin:1px; display:block; 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(); diff --git a/pages/chat.php b/pages/chat.php index f55476f..992d600 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -20,10 +20,13 @@ if (!$accepted) {

Pathery Chat - BETA

-
-
+ +
Loading...
+ +
+ +
+
@@ -386,6 +466,8 @@ function setChatMute() {
+ +