2005-05-23 17:27:01 +02:00
|
|
|
<?php
|
2024-11-12 13:46:13 +01:00
|
|
|
/* Copyright (C) 2004-2022 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
|
|
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@inodbox.com>
|
|
|
|
|
* Copyright (C) 2013-2015 Juanjo Menent <jmenent@2byte.es>
|
|
|
|
|
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
2024-11-04 23:53:20 +01:00
|
|
|
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
2005-05-23 17:27:01 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-05-23 17:27:01 +02:00
|
|
|
* (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
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2005-05-23 17:27:01 +02:00
|
|
|
*/
|
|
|
|
|
|
2005-06-11 13:42:18 +02:00
|
|
|
/**
|
2008-08-13 15:39:30 +02:00
|
|
|
* \file htdocs/admin/security.php
|
|
|
|
|
* \ingroup setup
|
2023-12-21 13:01:09 +01:00
|
|
|
* \brief Page of setup of security
|
2008-08-13 15:39:30 +02:00
|
|
|
*/
|
2005-05-23 17:27:01 +02:00
|
|
|
|
2022-09-07 20:08:59 +02:00
|
|
|
// Load Dolibarr environment
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
2005-05-23 17:27:01 +02:00
|
|
|
|
2019-11-13 19:35:02 +01:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
2012-02-19 19:14:17 +01:00
|
|
|
|
2024-11-04 23:53:20 +01:00
|
|
|
/**
|
|
|
|
|
* @var Conf $conf
|
|
|
|
|
* @var DoliDB $db
|
|
|
|
|
* @var HookManager $hookmanager
|
|
|
|
|
* @var Translate $langs
|
|
|
|
|
* @var User $user
|
2024-11-06 19:39:46 +01:00
|
|
|
*
|
|
|
|
|
* @var string $dolibarr_main_db_pass
|
2024-11-04 23:53:20 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-05-26 18:52:14 +02:00
|
|
|
// Load translation files required by the page
|
2019-11-13 19:35:02 +01:00
|
|
|
$langs->loadLangs(array("users", "admin", "other"));
|
2005-05-23 17:27:01 +02:00
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if (!$user->admin) {
|
|
|
|
|
accessforbidden();
|
|
|
|
|
}
|
2005-05-23 17:27:01 +02:00
|
|
|
|
2024-01-11 10:07:06 +01:00
|
|
|
// Allow/Disallow change to clear passwords once passwords are encrypted
|
2024-05-15 17:55:16 +02:00
|
|
|
$allow_disable_encryption = false;
|
2007-03-01 20:18:19 +01:00
|
|
|
|
2021-06-15 01:18:17 +02:00
|
|
|
|
2006-03-11 19:45:10 +01:00
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2021-06-15 01:18:17 +02:00
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'setgeneraterule') {
|
2022-11-18 01:01:59 +01:00
|
|
|
if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', GETPOST("value", "alphanohtml"), 'chaine', 0, '', $conf->entity)) {
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_print_error($db);
|
2006-03-12 14:15:29 +01:00
|
|
|
}
|
2005-05-23 17:27:01 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'activate_encrypt') {
|
2020-10-31 14:32:18 +01:00
|
|
|
$error = 0;
|
2010-11-16 22:43:37 +01:00
|
|
|
|
2007-03-01 20:18:19 +01:00
|
|
|
$db->begin();
|
2009-04-05 21:01:43 +02:00
|
|
|
|
2022-12-28 02:47:37 +01:00
|
|
|
// On old version, a bug created the constant into user entity, so we delete it to be sure such entry won't exists. We want it in entity 0 or nowhere.
|
|
|
|
|
dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity);
|
2022-11-17 18:09:54 +01:00
|
|
|
// We set entity=0 (all) because DATABASE_PWD_ENCRYPTED is a setup into conf file, so always shared for everybody
|
|
|
|
|
$entityforall = 0;
|
|
|
|
|
dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $entityforall);
|
2020-10-31 14:32:18 +01:00
|
|
|
|
|
|
|
|
$sql = "SELECT u.rowid, u.pass, u.pass_crypted";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
|
|
|
|
$sql .= " WHERE u.pass IS NOT NULL AND LENGTH(u.pass) < 32"; // Not a MD5 value
|
|
|
|
|
|
|
|
|
|
$resql = $db->query($sql);
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($resql) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$numrows = $db->num_rows($resql);
|
|
|
|
|
$i = 0;
|
2021-02-26 22:04:03 +01:00
|
|
|
while ($i < $numrows) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$obj = $db->fetch_object($resql);
|
2021-02-26 22:04:03 +01:00
|
|
|
if (dol_hash($obj->pass)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$sql = "UPDATE ".MAIN_DB_PREFIX."user";
|
|
|
|
|
$sql .= " SET pass_crypted = '".dol_hash($obj->pass)."', pass = NULL";
|
2021-04-24 20:18:11 +02:00
|
|
|
$sql .= " WHERE rowid=".((int) $obj->rowid);
|
2020-10-31 14:32:18 +01:00
|
|
|
//print $sql;
|
|
|
|
|
|
|
|
|
|
$resql2 = $db->query($sql);
|
2021-02-26 22:04:03 +01:00
|
|
|
if (!$resql2) {
|
2020-10-31 14:32:18 +01:00
|
|
|
dol_print_error($db);
|
|
|
|
|
$error++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-26 22:04:03 +01:00
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
2007-03-01 20:18:19 +01:00
|
|
|
|
2010-11-16 22:43:37 +01:00
|
|
|
//print $error." ".$sql;
|
2020-10-31 14:32:18 +01:00
|
|
|
//exit;
|
2021-02-26 22:04:03 +01:00
|
|
|
if (!$error) {
|
2007-03-01 20:18:19 +01:00
|
|
|
$db->commit();
|
2020-05-21 09:35:30 +02:00
|
|
|
} else {
|
2008-11-19 19:19:51 +01:00
|
|
|
$db->rollback();
|
2019-01-27 11:55:16 +01:00
|
|
|
dol_print_error($db, '');
|
2007-03-01 20:18:19 +01:00
|
|
|
}
|
2021-02-26 22:04:03 +01:00
|
|
|
} elseif ($action == 'disable_encrypt') {
|
2024-05-15 17:55:16 +02:00
|
|
|
// By default, $allow_disable_encryption is false we do not allow to disable encryption because passwords can't be decoded once encrypted.
|
2024-11-12 13:46:13 +01:00
|
|
|
// We set entity=0 (all) because DATABASE_PWD_ENCRYPTED is a setup into conf file, so always shared for everybody
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($allow_disable_encryption) {
|
2019-01-27 11:55:16 +01:00
|
|
|
dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity);
|
2024-11-12 13:46:13 +01:00
|
|
|
dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", 0);
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
2006-10-17 00:38:56 +02:00
|
|
|
}
|
2005-05-23 17:27:01 +02:00
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'activate_encryptdbpassconf') {
|
2007-04-25 13:45:01 +02:00
|
|
|
$result = encodedecode_dbpassconf(1);
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($result > 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait.
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
// database value not required
|
2024-11-12 13:46:13 +01:00
|
|
|
// dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1");
|
2012-08-31 05:58:38 +02:00
|
|
|
header("Location: security.php");
|
2007-04-25 14:41:35 +02:00
|
|
|
exit;
|
2020-05-21 09:35:30 +02:00
|
|
|
} else {
|
2019-01-27 11:55:16 +01:00
|
|
|
setEventMessages($langs->trans('InstrucToEncodePass', dol_encode($dolibarr_main_db_pass)), null, 'warnings');
|
2007-04-25 14:41:35 +02:00
|
|
|
}
|
2021-02-26 22:04:03 +01:00
|
|
|
} elseif ($action == 'disable_encryptdbpassconf') {
|
2007-04-25 13:45:01 +02:00
|
|
|
$result = encodedecode_dbpassconf(0);
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($result > 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait.
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2008-08-13 15:39:30 +02:00
|
|
|
// database value not required
|
2024-11-12 13:46:13 +01:00
|
|
|
// dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity);
|
2012-08-31 05:58:38 +02:00
|
|
|
header("Location: security.php");
|
2007-04-25 14:41:35 +02:00
|
|
|
exit;
|
2020-05-21 09:35:30 +02:00
|
|
|
} else {
|
2024-11-12 13:46:13 +01:00
|
|
|
// setEventMessages($langs->trans('InstrucToClearPass', $dolibarr_main_db_pass), null, 'warnings');
|
2023-08-10 01:36:31 +02:00
|
|
|
setEventMessages($langs->trans('InstrucToClearPass', $langs->transnoentitiesnoconv("DatabasePassword")), null, 'warnings');
|
2007-04-25 14:41:35 +02:00
|
|
|
}
|
2007-04-25 13:45:01 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'activate_MAIN_SECURITY_DISABLEFORGETPASSLINK') {
|
2019-01-27 11:55:16 +01:00
|
|
|
dolibarr_set_const($db, "MAIN_SECURITY_DISABLEFORGETPASSLINK", '1', 'chaine', 0, '', $conf->entity);
|
2021-02-26 22:04:03 +01:00
|
|
|
} elseif ($action == 'disable_MAIN_SECURITY_DISABLEFORGETPASSLINK') {
|
2019-01-27 11:55:16 +01:00
|
|
|
dolibarr_del_const($db, "MAIN_SECURITY_DISABLEFORGETPASSLINK", $conf->entity);
|
2007-06-02 03:53:54 +02:00
|
|
|
}
|
|
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($action == 'updatepattern') {
|
2020-10-31 14:32:18 +01:00
|
|
|
$pattern = GETPOST("pattern", "alpha");
|
2024-03-21 21:31:57 +01:00
|
|
|
$explodePattern = explode(';', $pattern); // List of ints separated with ';' containing counts
|
2020-10-31 14:32:18 +01:00
|
|
|
|
|
|
|
|
$patternInError = false;
|
2024-03-21 21:31:57 +01:00
|
|
|
if ((int) $explodePattern[0] < 1 || (int) $explodePattern[4] < 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$patternInError = true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-21 21:31:57 +01:00
|
|
|
if ((int) $explodePattern[0] < (int) $explodePattern[1] + (int) $explodePattern[2] + (int) $explodePattern[3]) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$patternInError = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$patternInError) {
|
|
|
|
|
dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity);
|
|
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
|
|
|
|
header("Location: security.php");
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2014-11-03 17:57:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-03-12 14:15:29 +01:00
|
|
|
/*
|
2009-08-21 21:09:20 +02:00
|
|
|
* View
|
2006-03-12 14:15:29 +01:00
|
|
|
*/
|
2019-12-09 09:43:38 +01:00
|
|
|
|
2011-11-08 10:18:45 +01:00
|
|
|
$form = new Form($db);
|
2006-03-11 19:45:10 +01:00
|
|
|
|
2019-11-13 19:35:02 +01:00
|
|
|
$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
|
2024-06-08 17:03:08 +02:00
|
|
|
llxHeader('', $langs->trans("Passwords"), $wikihelp, '', 0, 0, '', '', '', 'mod-admin page-security');
|
2005-05-23 17:27:01 +02:00
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
|
2006-08-12 17:32:57 +02:00
|
|
|
|
2019-12-09 09:43:38 +01:00
|
|
|
print '<span class="opacitymedium">'.$langs->trans("GeneratedPasswordDesc")."</span><br>\n";
|
2006-08-12 19:53:18 +02:00
|
|
|
print "<br>\n";
|
|
|
|
|
|
2006-03-11 19:45:10 +01:00
|
|
|
|
2019-11-13 19:35:02 +01:00
|
|
|
$head = security_prepare_head();
|
2006-11-13 23:31:26 +01:00
|
|
|
|
2020-10-22 22:50:03 +02:00
|
|
|
print dol_get_fiche_head($head, 'passwords', '', -1);
|
2006-03-11 19:45:10 +01:00
|
|
|
|
2021-10-19 16:26:43 +02:00
|
|
|
print '<br>';
|
2006-03-11 19:45:10 +01:00
|
|
|
|
2021-10-19 16:26:43 +02:00
|
|
|
// Select manager to generate passwords
|
2006-03-12 14:15:29 +01:00
|
|
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
2019-12-18 23:12:31 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2005-05-23 17:27:01 +02:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
|
|
|
|
print '<input type="hidden" name="constname" value="USER_PASSWORD_GENERATED">';
|
|
|
|
|
print '<input type="hidden" name="consttype" value="yesno">';
|
|
|
|
|
|
2024-09-27 18:55:19 +02:00
|
|
|
// Load array with all password generation modules
|
2011-10-24 14:11:49 +02:00
|
|
|
$dir = "../core/modules/security/generate";
|
2006-04-01 14:03:31 +02:00
|
|
|
clearstatcache();
|
2019-11-13 19:35:02 +01:00
|
|
|
$handle = opendir($dir);
|
|
|
|
|
$i = 1;
|
2024-03-09 02:43:57 +01:00
|
|
|
$arrayhandler = array();
|
2021-02-26 22:04:03 +01:00
|
|
|
if (is_resource($handle)) {
|
|
|
|
|
while (($file = readdir($handle)) !== false) {
|
2024-09-27 18:55:19 +02:00
|
|
|
$reg = array();
|
2021-02-26 22:04:03 +01:00
|
|
|
if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
// Charging the numbering class
|
|
|
|
|
$classname = $reg[1];
|
|
|
|
|
require_once $dir.'/'.$file;
|
|
|
|
|
|
|
|
|
|
$obj = new $classname($db, $conf, $langs, $user);
|
2024-03-24 21:36:30 +01:00
|
|
|
'@phan-var-force ModeleGenPassword $obj';
|
2020-10-31 14:32:18 +01:00
|
|
|
$arrayhandler[$obj->id] = $obj;
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
closedir($handle);
|
2006-03-12 14:15:29 +01:00
|
|
|
}
|
2018-05-01 20:52:25 +02:00
|
|
|
asort($arrayhandler);
|
2006-04-01 14:03:31 +02:00
|
|
|
|
2021-06-15 01:18:17 +02:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2006-04-01 14:03:31 +02:00
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td colspan="2">'.$langs->trans("RuleForGeneratedPasswords").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Example").'</td>';
|
2019-12-12 10:31:08 +01:00
|
|
|
print '<td class="center">'.$langs->trans("Activated").'</td>';
|
2006-04-01 14:03:31 +02:00
|
|
|
print '</tr>';
|
|
|
|
|
|
2022-09-11 12:18:43 +02:00
|
|
|
$tabConf = explode(";", getDolGlobalString('USER_PASSWORD_PATTERN'));
|
|
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
foreach ($arrayhandler as $key => $module) {
|
2008-09-05 01:44:36 +02:00
|
|
|
// Show modules according to features level
|
2023-11-27 12:24:18 +01:00
|
|
|
if (!empty($module->version) && $module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
|
2021-02-26 22:04:03 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
2023-11-27 12:24:18 +01:00
|
|
|
if (!empty($module->version) && $module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
|
2021-02-26 22:04:03 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
2008-09-05 01:44:36 +02:00
|
|
|
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($module->isEnabled()) {
|
2022-09-11 12:18:43 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2024-05-15 22:12:59 +02:00
|
|
|
print img_picto('', $module->picto, 'class="width25 size15x marginrightonly"').' ';
|
2020-10-31 14:32:18 +01:00
|
|
|
print ucfirst($key);
|
|
|
|
|
print "</td><td>\n";
|
|
|
|
|
print $module->getDescription().'<br>';
|
2022-09-11 12:18:43 +02:00
|
|
|
print $langs->trans("MinLength").': <span class="opacitymedium">'.$module->length.'</span>';
|
2020-10-31 14:32:18 +01:00
|
|
|
print '</td>';
|
|
|
|
|
|
|
|
|
|
// Show example of numbering module
|
2022-09-11 12:18:43 +02:00
|
|
|
print '<td class="nowraponall">';
|
2020-10-31 14:32:18 +01:00
|
|
|
$tmp = $module->getExample();
|
2020-11-28 02:09:27 +01:00
|
|
|
if (preg_match('/^Error/', $tmp)) {
|
|
|
|
|
$langs->load("errors");
|
|
|
|
|
print '<div class="error">'.$langs->trans($tmp).'</div>';
|
2021-02-26 22:04:03 +01:00
|
|
|
} elseif ($tmp == 'NotConfigured') {
|
2021-09-05 02:25:32 +02:00
|
|
|
print '<span class="opacitymedium">'.$langs->trans($tmp).'</span>';
|
2021-02-26 22:04:03 +01:00
|
|
|
} else {
|
2021-07-04 19:23:04 +02:00
|
|
|
print '<span class="opacitymedium">'.$tmp.'</span>';
|
2021-02-26 22:04:03 +01:00
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
print '</td>'."\n";
|
|
|
|
|
|
2022-09-11 12:18:43 +02:00
|
|
|
print '<td class="center">';
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($conf->global->USER_PASSWORD_GENERATED == $key) {
|
2021-04-17 03:11:58 +02:00
|
|
|
//print img_picto('', 'tick');
|
|
|
|
|
print img_picto($langs->trans("Enabled"), 'switch_on');
|
2020-10-31 14:32:18 +01:00
|
|
|
} else {
|
2021-09-19 18:03:38 +02:00
|
|
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setgeneraterule&token='.newToken().'&value='.$key.'">';
|
2021-04-17 03:11:58 +02:00
|
|
|
//print $langs->trans("Activate");
|
|
|
|
|
print img_picto($langs->trans("Disabled"), 'switch_off');
|
|
|
|
|
print '</a>';
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
|
|
|
|
print "</td></tr>\n";
|
2008-09-05 01:44:36 +02:00
|
|
|
}
|
2006-04-01 14:03:31 +02:00
|
|
|
}
|
|
|
|
|
print '</table>';
|
2021-06-15 01:18:17 +02:00
|
|
|
print '</div>';
|
|
|
|
|
|
2006-10-17 00:38:56 +02:00
|
|
|
print '</form>';
|
2007-04-23 00:55:32 +02:00
|
|
|
|
2022-12-12 10:25:03 +01:00
|
|
|
|
|
|
|
|
// Pattern for Password Perso
|
2023-10-08 23:19:49 +02:00
|
|
|
if (getDolGlobalString('USER_PASSWORD_GENERATED') == "Perso") {
|
2015-10-29 06:47:42 +01:00
|
|
|
print '<br>';
|
2021-06-15 01:18:17 +02:00
|
|
|
|
|
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2014-11-03 17:57:55 +01:00
|
|
|
print '<tr class="liste_titre">';
|
2021-06-15 01:18:17 +02:00
|
|
|
print '<td colspan="2"> '.$langs->trans("PasswordPatternDesc").'</td>';
|
2014-11-03 17:57:55 +01:00
|
|
|
print '</tr>';
|
|
|
|
|
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<td>'.$langs->trans("MinLength")."</td>";
|
2024-04-26 23:45:39 +02:00
|
|
|
print '<td><input type="number" class="width50 right" value="'.$tabConf[0].'" id="minlength" min="1"></td>';
|
2014-11-03 17:57:55 +01:00
|
|
|
print '</tr>';
|
|
|
|
|
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<td>'.$langs->trans("NbMajMin")."</td>";
|
2024-04-26 23:45:39 +02:00
|
|
|
print '<td><input type="number" class="width50 right" value="'.$tabConf[1].'" id="NbMajMin" min="0"></td>';
|
2014-11-03 17:57:55 +01:00
|
|
|
print '</tr>';
|
|
|
|
|
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<td>'.$langs->trans("NbNumMin")."</td>";
|
2024-04-26 23:45:39 +02:00
|
|
|
print '<td><input type="number" class="width50 right" value="'.$tabConf[2].'" id="NbNumMin" min="0"></td>';
|
2014-11-03 17:57:55 +01:00
|
|
|
print '</tr>';
|
|
|
|
|
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<td>'.$langs->trans("NbSpeMin")."</td>";
|
2024-04-26 23:45:39 +02:00
|
|
|
print '<td><input type="number" class="width50 right" value="'.$tabConf[3].'" id="NbSpeMin" min="0"></td>';
|
2014-11-03 17:57:55 +01:00
|
|
|
print '</tr>';
|
|
|
|
|
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<td>'.$langs->trans("NbIteConsecutive")."</td>";
|
2024-04-26 23:45:39 +02:00
|
|
|
print '<td><input type="number" class="width50 right" value="'.$tabConf[4].'" id="NbIteConsecutive" min="0"></td>';
|
2014-11-03 17:57:55 +01:00
|
|
|
print '</tr>';
|
|
|
|
|
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2019-11-13 19:35:02 +01:00
|
|
|
print '<td>'.$langs->trans("NoAmbiCaracAutoGeneration")."</td>";
|
2022-01-03 16:09:08 +01:00
|
|
|
print '<td><input type="checkbox" id="NoAmbiCaracAutoGeneration" '.($tabConf[5] ? "checked" : "").' min="0"> <label for="NoAmbiCaracAutoGeneration" id="textcheckbox">'.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'</label></td>';
|
2014-11-03 17:57:55 +01:00
|
|
|
print '</tr>';
|
2018-05-01 20:52:25 +02:00
|
|
|
|
2015-10-29 06:47:42 +01:00
|
|
|
print '</table>';
|
2014-11-03 17:57:55 +01:00
|
|
|
|
2020-05-19 04:21:38 +02:00
|
|
|
print '<div class="center">';
|
2020-11-19 20:23:38 +01:00
|
|
|
print '<a class="button button-save" id="linkChangePattern">'.$langs->trans("Save").'</a>';
|
2020-05-19 04:21:38 +02:00
|
|
|
print '</div>';
|
2022-12-12 10:25:03 +01:00
|
|
|
|
2015-10-29 06:47:42 +01:00
|
|
|
print '<br><br>';
|
2014-11-03 17:57:55 +01:00
|
|
|
|
|
|
|
|
print '<script type="text/javascript">';
|
|
|
|
|
print ' function getStringArg(){';
|
|
|
|
|
print ' var pattern = "";';
|
2024-11-06 19:18:24 +01:00
|
|
|
print ' pattern += $("#minlength").val() + ";";';
|
2014-11-03 17:57:55 +01:00
|
|
|
print ' pattern += $("#NbMajMin").val() + ";";';
|
|
|
|
|
print ' pattern += $("#NbNumMin").val() + ";";';
|
|
|
|
|
print ' pattern += $("#NbSpeMin").val() + ";";';
|
|
|
|
|
print ' pattern += $("#NbIteConsecutive").val() + ";";';
|
|
|
|
|
print ' pattern += $("#NoAmbiCaracAutoGeneration")[0].checked ? "1" : "0";';
|
|
|
|
|
print ' return pattern;';
|
|
|
|
|
print ' }';
|
|
|
|
|
|
|
|
|
|
print ' function valuePossible(){';
|
2024-11-06 19:18:24 +01:00
|
|
|
print ' var fields = ["#minlength", "#NbMajMin", "#NbNumMin", "#NbSpeMin", "#NbIteConsecutive"];';
|
2019-10-04 18:13:00 +02:00
|
|
|
print ' for(var i = 0 ; i < fields.length ; i++){';
|
|
|
|
|
print ' if($(fields[i]).val() < $(fields[i]).attr("min")){';
|
|
|
|
|
print ' return false;';
|
|
|
|
|
print ' }';
|
|
|
|
|
print ' }';
|
|
|
|
|
print ' ';
|
2024-11-06 19:18:24 +01:00
|
|
|
print ' var length = parseInt($("#minlength").val());';
|
2014-11-03 17:57:55 +01:00
|
|
|
print ' var length_mini = parseInt($("#NbMajMin").val()) + parseInt($("#NbNumMin").val()) + parseInt($("#NbSpeMin").val());';
|
|
|
|
|
print ' return length >= length_mini;';
|
|
|
|
|
print ' }';
|
|
|
|
|
|
|
|
|
|
print ' function generatelink(){';
|
2022-09-11 12:18:43 +02:00
|
|
|
print ' return "security.php?action=updatepattern&token='.newToken().'&pattern="+getStringArg();';
|
2014-11-03 17:57:55 +01:00
|
|
|
print ' }';
|
|
|
|
|
|
|
|
|
|
print ' function valuePatternChange(){';
|
2020-05-19 04:21:38 +02:00
|
|
|
print ' console.log("valuePatternChange");';
|
2014-11-03 17:57:55 +01:00
|
|
|
print ' var lang_save = "'.$langs->trans("Save").'";';
|
|
|
|
|
print ' var lang_error = "'.$langs->trans("Error").'";';
|
2014-11-04 11:38:16 +01:00
|
|
|
print ' var lang_Disabled = "'.$langs->trans("Disabled").'";';
|
|
|
|
|
print ' var lang_Activated = "'.$langs->trans("Activated").'";';
|
|
|
|
|
print ' $("#textcheckbox").html($("#NoAmbiCaracAutoGeneration")[0].checked ? unescape(lang_Activated) : unescape(lang_Disabled));';
|
2014-11-03 17:57:55 +01:00
|
|
|
print ' if(valuePossible()){';
|
|
|
|
|
print ' $("#linkChangePattern").attr("href",generatelink()).text(lang_save);';
|
|
|
|
|
print ' }';
|
|
|
|
|
print ' else{';
|
|
|
|
|
print ' $("#linkChangePattern").attr("href", null).text(lang_error);';
|
|
|
|
|
print ' }';
|
|
|
|
|
print ' }';
|
|
|
|
|
|
2024-11-06 19:18:24 +01:00
|
|
|
print ' $("#minlength").change(function(){valuePatternChange();});';
|
2014-11-03 17:57:55 +01:00
|
|
|
print ' $("#NbMajMin").change(function(){valuePatternChange();});';
|
|
|
|
|
print ' $("#NbNumMin").change(function(){valuePatternChange();});';
|
|
|
|
|
print ' $("#NbSpeMin").change(function(){valuePatternChange();});';
|
|
|
|
|
print ' $("#NbIteConsecutive").change(function(){valuePatternChange();});';
|
|
|
|
|
print ' $("#NoAmbiCaracAutoGeneration").change(function(){valuePatternChange();});';
|
|
|
|
|
|
|
|
|
|
print '</script>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-11-17 18:09:54 +01:00
|
|
|
// Crypt passwords in database
|
|
|
|
|
|
2006-10-17 00:38:56 +02:00
|
|
|
print '<br>';
|
2022-08-25 19:33:04 +02:00
|
|
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
|
2019-12-18 23:12:31 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2022-08-25 19:33:04 +02:00
|
|
|
print '<input type="hidden" name="action" value="encrypt">';
|
2007-03-01 20:18:19 +01:00
|
|
|
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2006-10-17 00:38:56 +02:00
|
|
|
print '<tr class="liste_titre">';
|
2007-06-02 03:53:54 +02:00
|
|
|
print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
|
2019-12-12 10:31:08 +01:00
|
|
|
print '<td class="center">'.$langs->trans("Activated").'</td>';
|
2022-12-12 10:25:03 +01:00
|
|
|
print '<td class="center"></td>';
|
2006-10-17 00:38:56 +02:00
|
|
|
print '</tr>';
|
2007-03-01 20:18:19 +01:00
|
|
|
|
2007-06-02 03:53:54 +02:00
|
|
|
// Disable clear password in database
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2007-04-25 15:50:40 +02:00
|
|
|
print '<td colspan="3">'.$langs->trans("DoNotStoreClearPassword").'</td>';
|
2022-11-17 18:09:54 +01:00
|
|
|
print '<td class="center" width="60">';
|
2021-04-21 18:59:25 +02:00
|
|
|
if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
|
2019-01-27 11:55:16 +01:00
|
|
|
print img_picto($langs->trans("Active"), 'tick');
|
2006-10-17 00:38:56 +02:00
|
|
|
}
|
|
|
|
|
print '</td>';
|
2021-04-21 18:59:25 +02:00
|
|
|
if (!getDolGlobalString('DATABASE_PWD_ENCRYPTED')) {
|
2022-11-17 18:09:54 +01:00
|
|
|
print '<td class="center" width="100">';
|
2022-11-18 01:08:56 +01:00
|
|
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=activate_encrypt&token='.newToken().'">'.$langs->trans("Activate").'</a>';
|
2007-03-01 20:18:19 +01:00
|
|
|
print "</td>";
|
2024-05-15 17:55:16 +02:00
|
|
|
} else {
|
2022-11-17 18:09:54 +01:00
|
|
|
print '<td class="center" width="100">';
|
2021-02-26 22:04:03 +01:00
|
|
|
if ($allow_disable_encryption) {
|
2009-12-16 11:36:18 +01:00
|
|
|
//On n'autorise pas l'annulation de l'encryption car les mots de passe ne peuvent pas etre decodes
|
2021-02-26 22:04:03 +01:00
|
|
|
//Do not allow "disable encryption" as passwords cannot be decrypted
|
2022-08-25 19:33:04 +02:00
|
|
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=disable_encrypt&token='.newToken().'">'.$langs->trans("Disable").'</a>';
|
2020-05-21 09:35:30 +02:00
|
|
|
} else {
|
2024-05-15 17:55:16 +02:00
|
|
|
print '<span class="opacitymedium">'.$langs->trans("Always").'</span>';
|
2007-04-25 15:31:45 +02:00
|
|
|
}
|
2007-04-25 15:50:40 +02:00
|
|
|
print "</td>";
|
2007-04-25 15:20:39 +02:00
|
|
|
}
|
2007-06-02 03:53:54 +02:00
|
|
|
print "</td>";
|
|
|
|
|
print '</tr>';
|
2007-04-25 15:50:40 +02:00
|
|
|
|
2022-11-17 18:09:54 +01:00
|
|
|
|
|
|
|
|
// Crypt password into config file conf.php
|
2017-04-14 11:22:48 +02:00
|
|
|
|
|
|
|
|
print '<tr class="oddeven">';
|
2007-04-25 15:10:48 +02:00
|
|
|
print '<td colspan="3">'.$langs->trans("MainDbPasswordFileConfEncrypted").'</td>';
|
2007-04-27 00:01:10 +02:00
|
|
|
print '<td align="center" width="60">';
|
2021-02-26 22:04:03 +01:00
|
|
|
if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_db_encrypted_pass)) {
|
2019-01-27 11:55:16 +01:00
|
|
|
print img_picto($langs->trans("Active"), 'tick');
|
2007-04-25 13:45:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
2022-11-17 18:09:54 +01:00
|
|
|
print '<td class="center" width="100">';
|
2021-02-26 22:04:03 +01:00
|
|
|
if (empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) {
|
2008-10-13 20:41:52 +02:00
|
|
|
$langs->load("errors");
|
2008-08-13 15:39:30 +02:00
|
|
|
print img_warning($langs->trans("WarningPassIsEmpty"));
|
2020-05-21 09:35:30 +02:00
|
|
|
} else {
|
2021-02-26 22:04:03 +01:00
|
|
|
if (empty($dolibarr_main_db_encrypted_pass)) {
|
2022-08-25 19:33:04 +02:00
|
|
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=activate_encryptdbpassconf&token='.newToken().'">'.$langs->trans("Activate").'</a>';
|
2008-08-13 15:39:30 +02:00
|
|
|
}
|
2021-02-26 22:04:03 +01:00
|
|
|
if (!empty($dolibarr_main_db_encrypted_pass)) {
|
2022-08-25 19:33:04 +02:00
|
|
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=disable_encryptdbpassconf&token='.newToken().'">'.$langs->trans("Disable").'</a>';
|
2008-08-13 15:39:30 +02:00
|
|
|
}
|
2007-04-25 13:45:01 +02:00
|
|
|
}
|
2008-08-13 15:39:30 +02:00
|
|
|
print "</td>";
|
2007-04-25 13:45:01 +02:00
|
|
|
|
|
|
|
|
print "</td>";
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
2009-08-21 21:09:20 +02:00
|
|
|
|
|
|
|
|
// Disable link "Forget password" on logon
|
2017-04-14 11:22:48 +02:00
|
|
|
|
|
|
|
|
print '<tr class="oddeven">';
|
2009-08-21 21:09:20 +02:00
|
|
|
print '<td colspan="3">'.$langs->trans("DisableForgetPasswordLinkOnLogonPage").'</td>';
|
2022-11-17 18:09:54 +01:00
|
|
|
print '<td class="center" width="60">';
|
2021-04-21 18:59:25 +02:00
|
|
|
if (getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) {
|
2019-01-27 11:55:16 +01:00
|
|
|
print img_picto($langs->trans("Active"), 'tick');
|
2009-08-21 21:09:20 +02:00
|
|
|
}
|
|
|
|
|
print '</td>';
|
2021-04-21 18:59:25 +02:00
|
|
|
if (!getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) {
|
2022-11-17 18:09:54 +01:00
|
|
|
print '<td class="center" width="100">';
|
2022-08-25 19:33:04 +02:00
|
|
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=activate_MAIN_SECURITY_DISABLEFORGETPASSLINK&token='.newToken().'">'.$langs->trans("Activate").'</a>';
|
2009-08-21 21:09:20 +02:00
|
|
|
print "</td>";
|
|
|
|
|
}
|
2021-04-21 18:59:25 +02:00
|
|
|
if (getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) {
|
2022-11-18 01:08:56 +01:00
|
|
|
print '<td center="center" width="100">';
|
2022-08-25 19:33:04 +02:00
|
|
|
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=disable_MAIN_SECURITY_DISABLEFORGETPASSLINK&token='.newToken().'">'.$langs->trans("Disable").'</a>';
|
2009-08-21 21:09:20 +02:00
|
|
|
print "</td>";
|
|
|
|
|
}
|
|
|
|
|
print "</td>";
|
|
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
|
2006-10-17 00:38:56 +02:00
|
|
|
print '</table>';
|
2022-09-11 12:18:43 +02:00
|
|
|
|
2006-04-01 14:03:31 +02:00
|
|
|
print '</form>';
|
2022-09-11 12:18:43 +02:00
|
|
|
|
2019-03-04 20:36:05 +01:00
|
|
|
print '<br>';
|
2005-05-23 17:27:01 +02:00
|
|
|
|
2024-01-23 23:25:15 +01:00
|
|
|
if (GETPOSTINT('info') > 0) {
|
2021-02-26 22:04:03 +01:00
|
|
|
if (function_exists('password_hash')) {
|
2020-10-31 14:32:18 +01:00
|
|
|
print $langs->trans("Note: The function password_hash exists on your PHP")."<br>\n";
|
|
|
|
|
} else {
|
2024-01-23 23:25:15 +01:00
|
|
|
print $langs->trans("Note: The function password_hash does not exist on your PHP")."<br>\n";
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
2021-04-21 18:59:25 +02:00
|
|
|
print 'MAIN_SECURITY_HASH_ALGO = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO')."<br>\n";
|
|
|
|
|
print 'MAIN_SECURITY_SALT = '.getDolGlobalString('MAIN_SECURITY_SALT')."<br>\n";
|
2019-03-04 20:36:05 +01:00
|
|
|
}
|
2006-10-17 00:38:56 +02:00
|
|
|
|
2006-03-11 19:45:10 +01:00
|
|
|
print '</div>';
|
2005-05-23 17:27:01 +02:00
|
|
|
|
2018-07-28 18:03:14 +02:00
|
|
|
// End of page
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2012-01-07 23:42:36 +01:00
|
|
|
$db->close();
|