From 895690e7e54079851d534bea2b35a25840434ac7 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Mon, 18 Feb 2013 23:29:31 -0800 Subject: More chat fixes --- ajax/chat.ajax.php | 2 +- includes/chats.php | 12 +++++++++++- pages/admin.php | 19 ++++--------------- pages/chat.php | 2 +- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/ajax/chat.ajax.php b/ajax/chat.ajax.php index 55f7718..1cbd6be 100644 --- a/ajax/chat.ajax.php +++ b/ajax/chat.ajax.php @@ -20,7 +20,7 @@ if ($_REQUEST['messages']) { $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'; - $r[0]['ID'] = -1; + $r[0]['userID'] = -1; echo json_encode($r); exit; } diff --git a/includes/chats.php b/includes/chats.php index a399d86..dcd46c9 100644 --- a/includes/chats.php +++ b/includes/chats.php @@ -12,7 +12,7 @@ function isMuted($userID) { $sql = "SELECT `dateChatGaggedUntil` FROM `users` WHERE `ID` = ? - AND `dateChatGaggedUntil` > CURDATE()"; + AND `dateChatGaggedUntil` > NOW()"; $stmt = $mysqli->prepare($sql); $stmt->bind_param("i", $userID); $stmt->execute(); @@ -22,6 +22,16 @@ function isMuted($userID) { else return false; } +function muteUser($userID, $numMinutes) { + global $mysqli; + $stmt = $mysqli->prepare("UPDATE `users` + SET `dateChatGaggedUntil` = ADDDATE(NOW(), INTERVAL ? MINUTE) + WHERE `ID` = ?"); + $stmt->bind_param('ii', $numMinutes, $userID); + $stmt->execute(); + return; +} + function addChat($userID, $message) { global $mysqli; if ($message == '') return; diff --git a/pages/admin.php b/pages/admin.php index d86d042..24feda4 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -11,6 +11,7 @@ include_once('./includes/maps.php'); include_once('./includes/mapoftheday.php'); include_once('./includes/sqli.php'); include_once('./includes/playerStats.php'); +include_once('./includes/chats.php'); if ($_GET['applyall'] == 'true') { echo "Apply-All command heard. Executing..."; @@ -43,22 +44,10 @@ else if ($_GET['deleteErrors'] == 'true') { } else if ($_POST['muteUser'] == 'true') { - muteUser($_POST['muteUserID'], $_POST['muteHours']); - echo "User ID ".$_POST['muteUserID']." muted for ".$_POST['muteHours']." hours"; + muteUser($_POST['muteUserID'], $_POST['muteMinutes']); + echo "User ID ".$_POST['muteUserID']." muted for ".$_POST['muteMinutes']." minutes"; } -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); @@ -79,7 +68,7 @@ $result = mysql_query($sql); USERID: - LENGTH IN HOURS: + LENGTH IN MINUTES: diff --git a/pages/chat.php b/pages/chat.php index 8aec336..ba99694 100644 --- a/pages/chat.php +++ b/pages/chat.php @@ -87,7 +87,7 @@ function getChatDone(data) { p = p+ "
"; if (user.userID == '-1') { - p = p+ ""; + p = p+ ""; } else { p = p+ ""; } -- cgit v1.2.3