diff --git a/reply_ticket.php b/reply_ticket.php index 7bcec0da..166c98fb 100644 --- a/reply_ticket.php +++ b/reply_ticket.php @@ -1,12 +1,12 @@ NOW() LIMIT 1"); +if (hesk_dbNumRows($res) == 1) +{ + if (hesk_dbResult($res) >= $hesk_settings['attempt_limit']) + { + unset($_SESSION); + hesk_error( sprintf($hesklang['yhbb'],$hesk_settings['attempt_banmin']) , 0); + } +} + /* Get details about the original ticket */ $res = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` WHERE `trackid`='{$trackingID}' LIMIT 1"); if (hesk_dbNumRows($res) != 1) @@ -154,6 +165,22 @@ if ($ticket['locked']) exit(); } +// Prevent flooding ticket replies +$res = hesk_dbQuery("SELECT `staffid` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."replies` WHERE `replyto`='{$ticket['id']}' AND `dt` > DATE_SUB(NOW(), INTERVAL 10 MINUTE) ORDER BY `id` ASC"); +if (hesk_dbNumRows($res) > 0) +{ + $sequential_customer_replies = 0; + while ($tmp = hesk_dbFetchAssoc($res)) + { + $sequential_customer_replies = $tmp['staffid'] ? 0 : $sequential_customer_replies + 1; + } + if ($sequential_customer_replies > 10) + { + hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."logins` (`ip`, `number`) VALUES ('".hesk_dbEscape($_SERVER['REMOTE_ADDR'])."', ".intval($hesk_settings['attempt_limit'] + 1).")"); + hesk_error( sprintf($hesklang['yhbr'],$hesk_settings['attempt_banmin']) , 0); + } +} + /* Insert attachments */ if ($hesk_settings['attachments']['use'] && !empty($attachments)) {