diff --git a/CHANGELOG b/CHANGELOG index fa27d68..5574a97 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Don't display empty option for system messages in delete messages by name Don't show a kick button on your own session in the list of active sessions Allow ignoring incognito chatters +Prevent posting the same message twice, if no other message was posted in-between Version 1.20.6 - Jul. 23, 2016 Simplify ignore logic + disallow ignoring chatters with higher status diff --git a/chat.php b/chat.php index bc33406..2bbb7b7 100644 --- a/chat.php +++ b/chat.php @@ -2911,11 +2911,11 @@ function create_hotlinks(){ } function add_message(){ - global $U; + global $U, $db; if(empty($U['message'])){ return false; } - $newmessage=array( + $message=array( 'postdate' =>time(), 'poststatus' =>$U['poststatus'], 'poster' =>$U['nickname'], @@ -2923,7 +2923,13 @@ function add_message(){ 'text' =>"$U[displaysend]".style_this($U['message'], $U['style']).'', 'delstatus' =>$U['status'] ); - write_message($newmessage); + //prevent posting the same message twice, if no other message was posted in-between. + $stmt=$db->prepare('SELECT id FROM ' . PREFIX . 'messages WHERE poststatus=? AND poster=? AND recipient=? AND text=? AND id IN (SELECT * FROM (SELECT id FROM ' . PREFIX . 'messages ORDER BY id DESC LIMIT 1) AS t);'); + $stmt->execute([$message['poststatus'], $message['poster'], $message['recipient'], $message['text']]); + if($stmt->fetch(PDO::FETCH_NUM)){ + return false; + } + write_message($message); return true; }