diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index c310c352690..f1022d01ba2 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -247,6 +247,18 @@ class FormTicket
$doleditor->Create();
print '';
+ if ($conf->global->MAIN_SECURITY_ENABLECAPTCHA) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
+ print '
| ';
+ print '';
+ print '';
+ print '';
+ print '';
+ print ' ';
+ print ''.img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"').'';
+ print '';
+ print ' |
';
+ }
// Attached files
if (!empty($this->withfile)) {
diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php
index 1c81faca1ad..06984316cef 100644
--- a/htdocs/public/ticket/create_ticket.php
+++ b/htdocs/public/ticket/create_ticket.php
@@ -142,6 +142,17 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('add', 'alpha')) {
array_push($object->errors, $langs->trans("ErrorBadEmailAddress", $langs->transnoentities("email")));
$action = '';
}
+
+ // Check Captcha code if is enabled
+ if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
+ $sessionkey = 'dol_antispam_value';
+ $ok = (array_key_exists($sessionkey, $_SESSION) === true && (strtolower($_SESSION[$sessionkey]) == strtolower($_POST['code'])));
+ if (!$ok) {
+ $error++;
+ array_push($object->errors, $langs->trans("ErrorBadValueForCode"));
+ $action = '';
+ }
+ }
if (!$error) {
$object->db->begin();