diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | ajax/chat.ajax.php | 14 | ||||
-rw-r--r-- | includes/chats.php | 14 | ||||
-rw-r--r-- | pages/chat.php | 18 |
4 files changed, 43 insertions, 6 deletions
@@ -2,7 +2,8 @@ /nbproject/private/
/favicon.ico
/emailLockFile
+/GitEyePathery
/.dropbox
/desktop.ini
-/.project +/.project
diff --git a/ajax/chat.ajax.php b/ajax/chat.ajax.php index 1574bde..576ab39 100644 --- a/ajax/chat.ajax.php +++ b/ajax/chat.ajax.php @@ -52,6 +52,9 @@ if (isset($_REQUEST['messages'])) { }
}
//Don't lockout requests by holding the session file open!
+
+$isLoggedIn = ($_SESSION['accepted'] == 1);
+
session_write_close();
$userID = $_SESSION['userID'];
@@ -74,8 +77,19 @@ require_once('../includes/chats.php'); enterChannel($userID);
$sent = false;
+//User is sending a message
if (isset($_REQUEST['messages'])) {
$date = isMuted($userID);
+ if ($isLoggedIn !== true) {
+ $r[0]['error'] = 'Logged out';
+ $r[0]['serverMessage'] = 'true';
+ $r[0]['message'] = "Whoops, your session has timed out. Please sign in again.";
+ $r[0]['secondsSince'] = 0;
+ $r[0]['displayName'] = 'SERVER';
+ $r[0]['userID'] = null;
+ echo json_encode($r);
+ exit;
+ }
if ($date !== false) {
$r[0]['error'] = 'Muted';
$r[0]['serverMessage'] = 'true';
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
");
diff --git a/pages/chat.php b/pages/chat.php index a1870a6..4f10a1c 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -22,6 +22,7 @@ if (!$accepted) { var lastID = 1;
//Internet Explorer doesn't support "const"
//CONSTANTS: ...
+var channelTimerDelay = 30000;
var chatTimerDelayUpper = 9000;
var chatTimerDelayLower = 2000;
var chatTimerDelayDefault = 5000;
@@ -45,6 +46,13 @@ function getChatTimer() { //addChatMessage("Debug", "Chat timer called!");
}
+pollChannelListTimer();
+function pollChannelListTimer() {
+ setTimeout("pollChannelListTimer()", channelTimerDelay);
+
+ pollChannelList();
+}
+
var firstGetChat = true;
function getChatDone(data) {
var newChats = false;
@@ -288,7 +296,7 @@ function pollChannelListDone(data) { function channelListShow(JO) {
console.log("Formating channelList");
- var p = "<table class='membersList score' style='max-height:400px; width:220px; background-color:transparent; '>";
+ var p = "<table class='membersList score' style='border-style:none; max-height:400px; width:220px; background-color:transparent; '>";
console.log('beginloop');
@@ -303,9 +311,11 @@ function channelListShow(JO) { styleClass = 'border-top: 6px solid #777799;';
}
}
-
+
+ // u.secFromLastActive could be used in here someplace..
+
if (u.wallEmblem == undefined) u.wallEmblem = 'blank.png';
- p = p+ "<tr style='"+styleClass+" background-color: "+u.background+"; color:"+u.displayColor+";' title='Last Active: "+u.dateLastActive+"'>";
+ p = p+ "<tr style='"+styleClass+" background-color: "+u.background+"; color:"+u.displayColor+";' title=''>";
p = p+ "<td style='vertical-align: middle;width:100px;'>";
p = p+ " <div class='grid_td' style='float:left; width:35px; height:35px; background:"+u.wallColor+" url("+linkEmblem(u.wallEmblem, u.wallOrientation)+");'>";
@@ -408,7 +418,7 @@ $(function() { function onChatWindowShown()
{
chatTimerDelay = chatTimerDelayDefault;
- getChatTimer();
+ getChat();
}
function onChatWindowHidden()
|