diff --git a/htdocs/admin/security_captcha.php b/htdocs/admin/security_captcha.php
index f30e8267ffb8a..e710915f8fc2a 100644
--- a/htdocs/admin/security_captcha.php
+++ b/htdocs/admin/security_captcha.php
@@ -46,7 +46,7 @@
}
$action = GETPOST('action', 'aZ09');
-
+$handler = GETPOST('handler', 'aZ09');
/*
@@ -70,34 +70,13 @@
} else {
dol_print_error($db);
}
-} elseif ($action == 'updateform') {
- $res1 = 1;
- $res2 = 1;
- $res3 = 1;
- $res4 = 1;
- $res5 = 1;
- if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) {
- $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
- }
- if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
- $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
- }
- if (GETPOSTISSET('MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT')) {
- $res3 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", GETPOST("MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT", 'alphanohtml'), 'int', 0, '', $conf->entity);
- }
- if (GETPOSTISSET('MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS')) {
- $res4 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", GETPOST("MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 'alphanohtml'), 'int', 0, '', $conf->entity);
- }
- if (GETPOSTISSET('MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS')) {
- $res5 = dolibarr_set_const($db, "MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", GETPOST("MAIN_SECURITY_MAX_ATTACHMENT_ON_FORMS", 'alphanohtml'), 'int', 0, '', $conf->entity);
- }
- if ($res1 && $res2 && $res3 && $res4 && $res5) {
- setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
+} elseif ($action == 'setcaptchahandler') {
+ if (!dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA_HANDLER', GETPOST("value", "aZ09"), 'chaine', 0, '', $conf->entity)) {
+ dol_print_error($db);
}
}
-
/*
* View
*/
@@ -112,28 +91,37 @@
print ''.$langs->trans("CaptchaDesc")."
\n";
print "
\n";
+$dirModCaptcha = array_merge(array('/core/modules/security/captcha'), is_array($conf->modules_parts['captcha']) ? $conf->modules_parts['captcha'] : array());
+foreach ($conf->modules_parts['captcha'] as $mo) {
+ //Add more models
+ $dirModCaptcha[] = $mo.'core/modules/security/captcha';
+}
// Load array with all captcha generation modules
-$dir = DOL_DOCUMENT_ROOT."/core/modules/security/captcha";
-clearstatcache();
-$handle = opendir($dir);
-$i = 1;
$arrayhandler = array();
-if (is_resource($handle)) {
- while (($file = readdir($handle)) !== false) {
- $reg = array();
- if (preg_match('/(modCaptcha[a-z]+)\.class\.php$/i', $file, $reg)) {
- // Charging the numbering class
- $classname = $reg[1];
- require_once $dir.'/'.$file;
-
- $obj = new $classname($db, $conf, $langs, $user);
- '@phan-var-force ModeleCaptcha $obj';
- $arrayhandler[$obj->id] = $obj;
- $i++;
+
+foreach ($dirModCaptcha as $dirroot) {
+ $dir = dol_buildpath($dirroot, 0);
+
+ $handle = @opendir($dir);
+
+ $i = 1;
+ if (is_resource($handle)) {
+ while (($file = readdir($handle)) !== false) {
+ $reg = array();
+ if (preg_match('/(modCaptcha[a-z]+)\.class\.php$/i', $file, $reg)) {
+ // Charging the numbering class
+ $classname = $reg[1];
+ require_once $dir.'/'.$file;
+
+ $obj = new $classname($db, $conf, $langs, $user);
+ '@phan-var-force ModeleCaptcha $obj';
+ $arrayhandler[$obj->id] = $obj;
+ $i++;
+ }
}
+ closedir($handle);
}
- closedir($handle);
}
asort($arrayhandler);
@@ -215,13 +203,11 @@
if (function_exists("imagecreatefrompng")) {
if ($key != $selectedcaptcha) {
- print '';
+ print '';
+ print img_picto($langs->trans("Disabled"), 'switch_off');
+ print '';
} else {
- print '';
+ print img_picto($langs->trans("Enabled"), 'switch_on');
}
} else {
$desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning');
diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php
index d5df6d50bd7b9..52a61d81c5760 100644
--- a/htdocs/admin/ticket_public.php
+++ b/htdocs/admin/ticket_public.php
@@ -506,11 +506,16 @@
print '
';
- print load_fiche_titre($langs->trans("Emails"));
+ //print load_fiche_titre($langs->trans("Emails"));
print '
'.$langs->trans("Emails").' | '; + print ''; + print ' | '; + print '
'; print $form->textwithpicto($langs->trans("TicketsDisableCustomerEmail"), $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index c020fdc3b2ac8..cb5a97f8c7bd5 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -556,6 +556,8 @@ public function setValues($db) $newvalue = '/'.$modulename.'/core/'.$partname.'/'; } elseif (in_array($partname, array('models', 'theme', 'websitetemplates'))) { $newvalue = '/'.$modulename.'/'; + } elseif (in_array($partname, array('captcha'))) { + $newvalue = '/'.$modulename.'/core/modules/security/'.$partname.'/'; } elseif ($value == 1) { $newvalue = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe } else { // $partname can be any other value like 'sms', ... diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 5f07cc83a50ad..de9d367f75ba8 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -569,40 +569,6 @@ function groupticketchange() { $doleditor->Create(); print ' | |
'; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $captcha = getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_HANDLER', 'standard'); - - $classfile = DOL_DOCUMENT_ROOT."/core/modules/security/captcha/modCaptcha".ucfirst($captcha).'.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $captchaobj = null; - if (dol_is_file($classfile)) { - // Charging the numbering class - $classname = "modCaptcha".ucfirst($captcha); - require_once $classfile; - - $captchaobj = new $classname($this->db, $conf, $langs, $user); - } - - if (is_object($captchaobj) && method_exists($captchaobj, 'getCaptchaCodeForForm')) { - // TODO: get this code using a method of captcha - } else { - print ' | '; - print ''; - print ''; - print ''.img_picto($langs->trans("Refresh"), 'refresh', 'id="captcha_refresh_img"').''; - print ''; - } - - print ' | '; - print '
'; + + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $captcha = getDolGlobalString('MAIN_SECURITY_ENABLECAPTCHA_HANDLER', 'standard'); + + $classfile = DOL_DOCUMENT_ROOT."/core/modules/security/captcha/modCaptcha".ucfirst($captcha).'.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $captchaobj = null; + if (dol_is_file($classfile)) { + // Charging the numbering class + $classname = "modCaptcha".ucfirst($captcha); + require_once $classfile; + + $captchaobj = new $classname($this->db, $conf, $langs, $user); + } + + if (is_object($captchaobj) && method_exists($captchaobj, 'getCaptchaCodeForForm')) { + print $captchaobj->getCaptchaCodeForForm(); + } else { + print 'Error, the captcha handler '.get_class($captchaobj).' does not have any method getCaptchaCodeForForm()'; + } + + print ' |