diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-02-14 04:11:33 -0800 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-02-14 04:11:33 -0800 |
commit | 133c2dbbb90c489c95b1e7b50823e9e0cfe9c71f (patch) | |
tree | ea7409af6605eb1a5eeb19e15a1baae7fd1787c4 | |
parent | c7c8e39f9fd438a8b6279cc7410a9ce1289a6418 (diff) | |
download | pathery-133c2dbbb90c489c95b1e7b50823e9e0cfe9c71f.tar.xz |
Mute-User and Lockdown for chat. :).
-rw-r--r-- | ajax/chat.ajax.php | 32 | ||||
-rw-r--r-- | css/chat.css | 3 | ||||
-rw-r--r-- | includes/chats.php | 15 | ||||
-rw-r--r-- | pages/admin.php | 34 | ||||
-rw-r--r-- | pages/chat.php | 4 |
5 files changed, 77 insertions, 11 deletions
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);
diff --git a/css/chat.css b/css/chat.css index 1af7c4d..6dcf629 100644 --- a/css/chat.css +++ b/css/chat.css @@ -86,6 +86,9 @@ .chatMessage.self { background-color: #444; } +.chatMessage.server { + background-color: #844; +} .chatContainer2 { background-color: #222; diff --git a/includes/chats.php b/includes/chats.php index 6a36fe3..ee222c9 100644 --- a/includes/chats.php +++ b/includes/chats.php @@ -7,6 +7,21 @@ include_once('sqli.php'); define('CHAT_ROWS_TO_KEEP', 50);
+function isMuted($userID) {
+ global $mysqli;
+
+ $sql = "SELECT `dateChatGaggedUntil` FROM `users`
+ WHERE `ID` = ?
+ AND `dateChatGaggedUntil` > CURDATE()";
+ $stmt = $mysqli->prepare($sql);
+ $stmt->bind_param("i", $userID);
+ $stmt->execute();
+ $stmt->bind_result($date);
+ $stmt->fetch();
+ if ($date) return $date;
+ else return false;
+}
+
function addChat($userID, $message) {
global $mysqli;
if ($message == '')
diff --git a/pages/admin.php b/pages/admin.php index bda527d..2109f7c 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -9,7 +9,7 @@ topbar($Links); include_once('./includes/datas.php');
include_once('./includes/maps.php');
include_once('./includes/mapoftheday.php');
-include_once('./includes/sqlEmbedded.php');
+include_once('./includes/sqli.php');
include_once('./includes/playerStats.php');
if ($_GET['applyall'] == 'true') {
@@ -41,12 +41,30 @@ else if ($_GET['deleteErrors'] == 'true') { echo "Log restarted!";
}
+else if ($_POST['muteUser'] == 'true') {
+
+ muteUser($_POST['muteUserID'], $_POST['muteHours']);
+ echo "User ID ".$_POST['muteUserID']." muted for ".$_POST['muteHours']." hours";
+}
+
+function muteUser($userID, $numHours) {
+ global $mysqli;
+ $stmt = $mysqli->prepare("UPDATE `users`
+ SET `dateChatGaggedUntil` = ADDDATE(CURDATE(), INTERVAL ? HOUR)
+ WHERE `ID` = ?");
+ $stmt->bind_param('ii', $numHours, $userID);
+ $stmt->execute();
+ return;
+}
+
+
$sql = "SELECT `ID`, `displayName`, `dateJoined`, `dateLogin`, `email`, `isAdmin` FROM `users`";
$result = mysql_query($sql);
-echo '
+?>
+
<center>
<h3>Administrators Page</h3>
<p>News:</p>
@@ -57,13 +75,21 @@ echo ' </p>
<p>Links: <a href="errorlogs">View Errorlog.txt</a></p>
-<p>Hello admins, this is our current userlist.</p>
+ <form action="admin" method="post" id='muteOptions'>
+ <input type="hidden" name="muteUser" value="true">
+ <input type="submit" value='MUTE USER'>
+ USERID:<input type="text" name="muteUserID" id="muteUserID" value="" maxlength="20" autocomplete="off" >
+ LENGTH IN HOURS:<input type="text" name="muteHours" id="muteHours" value="" maxlength="20" autocomplete="off" >
+ </form>
+
</center>
<table style="padding-left:20px;">
<tr>
<th>ID</th><th>Display name:</th><th>Joined On:</th><th>Last Logon</th><th>Email</th><th>Administrator</th>
</tr>
-';
+
+
+<?
while (list($CUID, $CUsername, $Joined, $LastLogon, $email, $isAdmin) = mysql_fetch_row($result)) {
diff --git a/pages/chat.php b/pages/chat.php index a29cf36..cdf9b01 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -90,9 +90,11 @@ function getChatDone(data) { lastID = user.ID;
var strClass = '';
- console.log('cpm', user.userID, userObj.ID);
if (user.userID == userObj.ID) {
strClass += ' self';
+ }
+ if (user.serverMessage == 'true') {
+ strClass += ' server';
}
items.unshift('<div class="chatMessage'+strClass+'" id="' + key + '">' + p + '</div>');
|