Merge pull request #16347 from andreubisquerra/master
NEW Can use captcha on public page to create ticket
This commit is contained in:
commit
069cf46f16
@ -247,6 +247,18 @@ class FormTicket
|
||||
$doleditor->Create();
|
||||
print '</td></tr>';
|
||||
|
||||
if (!empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
print '<tr><td class="titlefield"><label for="email"><span class="fieldrequired">'.$langs->trans("SecurityCode").'</span></label></td><td>';
|
||||
print '<span class="span-icon-security inline-block">';
|
||||
print '<input id="securitycode" placeholder="'.$langs->trans("SecurityCode").'" class="flat input-icon-security width150" type="text" maxlength="5" name="code" tabindex="3" />';
|
||||
print '</span>';
|
||||
print '<span class="nowrap inline-block">';
|
||||
print '<img class="inline-block valignmiddle" src="'.DOL_URL_ROOT.'/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />';
|
||||
print '<a class="inline-block valignmiddle" href="'.$php_self.'" tabindex="4" data-role="button">'.img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"').'</a>';
|
||||
print '</span>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Attached files
|
||||
if (!empty($this->withfile)) {
|
||||
|
||||
@ -143,6 +143,17 @@ if (empty($reshook) && $action == 'create_ticket' && GETPOST('add', 'alpha')) {
|
||||
$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();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user