diff --git a/src/mibew/client.php b/src/mibew/client.php index 9451ea65..0d8d3c8d 100644 --- a/src/mibew/client.php +++ b/src/mibew/client.php @@ -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); diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index e086c448..2b9a4d83 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -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); } diff --git a/src/mibew/thread.php b/src/mibew/thread.php index d7e55043..3e8460e8 100644 --- a/src/mibew/thread.php +++ b/src/mibew/thread.php @@ -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);