mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-07 00:14:40 +03:00
Prevent empty messages from being posted (related to Issue #9)
This commit is contained in:
parent
6eef9e8762
commit
2ff3e8c4f0
@ -142,7 +142,9 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
|
||||
}
|
||||
if($firstmessage) {
|
||||
$postedid = post_message_($thread['threadid'],$kind_user,$firstmessage,$link,$visitor['name']);
|
||||
commit_thread( $thread['threadid'], array('shownmessageid' => intval($postedid)), $link);
|
||||
if ($postedid) {
|
||||
commit_thread( $thread['threadid'], array('shownmessageid' => intval($postedid)), $link);
|
||||
}
|
||||
}
|
||||
notify_operators($thread, $firstmessage, $link);
|
||||
mysql_close($link);
|
||||
|
@ -61,6 +61,9 @@ function next_revision($link)
|
||||
function post_message_($threadid, $kind, $message, $link, $from = null, $utime = null, $opid = null)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
if (!isset($message) || preg_match('/^\s*$/', $message)) {
|
||||
return 0;
|
||||
}
|
||||
$query = sprintf(
|
||||
"insert into ${mysqlprefix}chatmessage (threadid,ikind,tmessage,tname,agentId,dtmcreated) values (%s,%s,'%s',%s,%s,%s)",
|
||||
intval($threadid),
|
||||
@ -69,7 +72,6 @@ function post_message_($threadid, $kind, $message, $link, $from = null, $utime =
|
||||
$from ? "'" . mysql_real_escape_string($from, $link) . "'" : "null",
|
||||
$opid ? intval($opid) : "0",
|
||||
$utime ? "FROM_UNIXTIME(" . intval($utime) . ")" : "CURRENT_TIMESTAMP");
|
||||
|
||||
perform_query($query, $link);
|
||||
return mysql_insert_id($link);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ if( $act == "refresh" ) {
|
||||
|
||||
$link = connect();
|
||||
$postedid = post_message_($threadid,$kind,$message,$link,$from,null,$isuser ? null : $operator['operatorid'] );
|
||||
if($isuser && $thread["shownmessageid"] == 0) {
|
||||
if($isuser && $postedid && $thread["shownmessageid"] == 0) {
|
||||
commit_thread( $thread['threadid'], array('shownmessageid' => intval($postedid)), $link);
|
||||
}
|
||||
mysql_close($link);
|
||||
|
Loading…
Reference in New Issue
Block a user