diff --git a/htdocs/facturxutil/class/actions_facturx.class.php b/htdocs/facturxutil/class/actions_facturx.class.php index 1ded7350f..900152fb2 100644 --- a/htdocs/facturxutil/class/actions_facturx.class.php +++ b/htdocs/facturxutil/class/actions_facturx.class.php @@ -102,16 +102,18 @@ public function doActions($parameters, &$object, &$action, $hookmanager) if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' // Do what you want here... // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. - } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; + if (!$error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } } + + return 0; } @@ -135,16 +137,18 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager) foreach ($parameters['toselect'] as $objectid) { // Do action on each object id } - } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; + if (!$error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } } + + return 0; } diff --git a/htdocs/google/class/actions_google.class.php b/htdocs/google/class/actions_google.class.php index c05a9d75d..d3687356a 100755 --- a/htdocs/google/class/actions_google.class.php +++ b/htdocs/google/class/actions_google.class.php @@ -68,7 +68,7 @@ function setContentSecurityPolicy($parameters, &$object, &$action, &$hookmanager { $tmp = ($hookmanager->resPrint ? $hookmanager->resPrint : $parameters['contentsecuritypolicy']); - // Add google to policies + // Add google to Content-Security-Policy $tmp = preg_replace('/script-src \'self\'/', 'script-src \'self\' *.googleapis.com *.google.com *.google-analytics.com', $tmp); $tmp = preg_replace('/font-src \'self\'/', 'font-src \'self\' *.google.com', $tmp); $tmp = preg_replace('/connect-src \'self\'/', 'connect-src \'self\' *.google.com', $tmp); diff --git a/htdocs/google/core/modules/modGoogle.class.php b/htdocs/google/core/modules/modGoogle.class.php index 6369e9cb3..0c3621d8c 100644 --- a/htdocs/google/core/modules/modGoogle.class.php +++ b/htdocs/google/core/modules/modGoogle.class.php @@ -57,7 +57,9 @@ function __construct($db) // Defined if the directory /mymodule/inc/triggers/ contains triggers or not $this->module_parts = array( 'triggers' => 1, - 'hooks' => array('main','agenda','agendalist') + 'hooks' => array('main','agenda','agendalist'), + // Set this to 1 if the module provides a captcha driver + 'captcha' => 1 ); // Data directories to create when module is enabled diff --git a/htdocs/google/core/modules/security/captcha/modCaptchaGoogle.class.php b/htdocs/google/core/modules/security/captcha/modCaptchaGoogle.class.php new file mode 100644 index 000000000..31ca31bc9 --- /dev/null +++ b/htdocs/google/core/modules/security/captcha/modCaptchaGoogle.class.php @@ -0,0 +1,93 @@ + + * Copyright (C) 2024 Frédéric France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/security/captcha/modCaptchaStandard.class.php + * \ingroup core + * \brief File to manage captcha generation according to dolibarr native code + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/security/captcha/modules_captcha.php'; + + +/** + * Class to generate a password according to a dolibarr standard rule (12 random chars) + */ +class modCaptchaGoogle extends ModeleCaptcha +{ + /** + * @var string ID + */ + public $id; + + public $picto = 'fa-shield-alt'; + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param Conf $conf Handler de conf + * @param Translate $langs Handler de langue + * @param User $user Handler du user connected + */ + public function __construct($db, $conf, $langs, $user) + { + $this->id = strtolower(preg_replace('/^modCaptcha/i', '', get_class())); + + //$this->picto = 'fab-google'; + + $this->db = $db; + $this->conf = $conf; + $this->langs = $langs; + $this->user = $user; + } + + /** + * Return description of module + * + * @return string Description of module + */ + public function getDescription() + { + global $langs; + return $langs->trans("GoogleCaptchaV3"); + } + + /** + * Return an example of password generated by this module + * + * @return string Example of password + */ + public function getExample() + { + return ''; + } + + + /** + * Validate a captcha + * This function is called after a log to validate a captcha, before validating a password. + * + * @return int 0 if KO, >0 if OK + */ + public function validateCodeAfterLoginSubmit() + { + return 1; + } +} diff --git a/htdocs/helloasso/class/actions_helloasso.class.php b/htdocs/helloasso/class/actions_helloasso.class.php index 9253dd7f7..f942e7ba5 100644 --- a/htdocs/helloasso/class/actions_helloasso.class.php +++ b/htdocs/helloasso/class/actions_helloasso.class.php @@ -112,16 +112,18 @@ public function doActions($parameters, &$object, &$action, $hookmanager) foreach ($parameters['toselect'] as $objectid) { // Do action on each object id } - } - if (!$error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; + if (!$error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } } + + return 0; } @@ -145,16 +147,18 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager) foreach ($parameters['toselect'] as $objectid) { // Do action on each object id } - } - if (!$error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; + if (!$error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } } + + return 0; } /** diff --git a/htdocs/prestashopget/class/actions_prestashopget.class.php b/htdocs/prestashopget/class/actions_prestashopget.class.php index 5e5db4c2d..1b2892b99 100644 --- a/htdocs/prestashopget/class/actions_prestashopget.class.php +++ b/htdocs/prestashopget/class/actions_prestashopget.class.php @@ -102,16 +102,18 @@ public function doActions($parameters, &$object, &$action, $hookmanager) if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2' // Do what you want here... // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. - } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } } + + return 0; } @@ -135,16 +137,18 @@ public function doMassActions($parameters, &$object, &$action, $hookmanager) foreach ($parameters['toselect'] as $objectid) { // Do action on each object id } - } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } } + + return 0; } diff --git a/htdocs/tawkto/class/actions_tawkto.class.php b/htdocs/tawkto/class/actions_tawkto.class.php index 0d73fd370..4856cb5da 100644 --- a/htdocs/tawkto/class/actions_tawkto.class.php +++ b/htdocs/tawkto/class/actions_tawkto.class.php @@ -11,8 +11,6 @@ class ActionsTawkto */ function setContentSecurityPolicy($parameters, &$object, &$action, &$hookmanager) { - global $conf,$user,$langs; - $tmp = ($hookmanager->resPrint ? $hookmanager->resPrint : $parameters['contentsecuritypolicy']); $tmp = preg_replace('/script-src \'self\'/', 'script-src \'self\' *.tawk.to *.jsdelivr.net', $tmp);