From 133c2dbbb90c489c95b1e7b50823e9e0cfe9c71f Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Thu, 14 Feb 2013 04:11:33 -0800 Subject: Mute-User and Lockdown for chat. :). --- ajax/chat.ajax.php | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'ajax') diff --git a/ajax/chat.ajax.php b/ajax/chat.ajax.php index 3ca15c6..239cc1c 100644 --- a/ajax/chat.ajax.php +++ b/ajax/chat.ajax.php @@ -4,23 +4,44 @@ session_write_close(); //Just doing this as evidence that $_SESSION as read-only is still available. $userID = $_SESSION['userID']; +$chatLockDown = false; +// STOP CHAT? +//$chatLockDown = true; + require('../includes/chats.php'); $sent = false; if ($_REQUEST['messages']) { + $date = isMuted($userID); + if ($date !== false) { + $r[0]['error'] = 'Muted'; + $r[0]['serverMessage'] = 'true'; + $r[0]['message'] = 'You have been muted; You are muted until '.$date." (The current time is: ".date("Y-m-d H:i:s").")"; + $r[0]['secondsSince'] = 0; + $r[0]['displayName'] = 'SERVER'; + echo json_encode($r); + exit; + } + if ($chatLockDown == true AND $_SESSION['isAdmin'] !== true) { + $r[0]['error'] = 'Lockdown'; + $r[0]['serverMessage'] = 'true'; + $r[0]['message'] = 'Chat Lockdown has been activated. Messages are not being accepted'; + $r[0]['secondsSince'] = 0; + $r[0]['displayName'] = 'SERVER'; + echo json_encode($r); + exit; + } + $messages = $_REQUEST['messages']; $messages = explode("|:|", $messages); foreach ($messages as $message) { $message = chatFilter(stripslashes($message)); $insertID = addchat($userID, $message); } - $sent = true; - //echo "IID:$insertID:"; } - if ($_REQUEST['getChatFromID']) { $getChatID = $_REQUEST['getChatFromID']; if ($sent) { @@ -40,11 +61,11 @@ if ($_REQUEST['getChatFromID']) { usleep(100000); } } - //echo "reachedEnd"; $json = prepareChatData(getChat($getChatID)); echo $json; - exit; } +exit; + function prepareChatData($data) { if ($data) { @@ -58,7 +79,6 @@ function prepareChatData($data) { } - function chatFilter($chat) { //cuss words $chat = str_replace("fuck you", "i am moron", $chat); -- cgit v1.2.3