dolibarr 21.0.0-beta
security.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011-2015 Regis Houssin <regis.houssin@inodbox.com>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
25if (!defined('NOTOKENRENEWAL')) {
26 define('NOTOKENRENEWAL', '1'); // Disables token renewal
27}
28if (!defined('NOREQUIREMENU')) {
29 define('NOREQUIREMENU', '1');
30}
31if (!defined('NOREQUIREHTML')) {
32 define('NOREQUIREHTML', '1');
33}
34if (!defined('NOREQUIREAJAX')) {
35 define('NOREQUIREAJAX', '1');
36}
37if (!defined('NOREQUIRESOC')) {
38 define('NOREQUIRESOC', '1');
39}
40// We need langs because the getRandomPassword may use the user language to define some rules of pass generation
41/*if (!defined('NOREQUIRETRAN')) {
42 define('NOREQUIRETRAN', '1');
43}*/
44
45// Load Dolibarr environment and check user is logged.
46require '../../main.inc.php';
55$action = GETPOST('action');
56
57// Security check
58// None. This is public component with no access and effect on data.
59
60
61/*
62 * Action
63 */
64
65// None
66
67
68/*
69 * View
70 */
71
73
74//print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
75
76// Return a new generated password
77if ($action) {
78 if ($action == 'getrandompassword') { // Test on permission not required here. Endpoint can be called by anu logged user.
79 require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
80 $generic = GETPOST('generic') ? true : false;
81 echo getRandomPassword($generic);
82 }
83} else {
84 if (GETPOST('errorcode') == 'InvalidToken') {
85 http_response_code(401);
86 }
87}
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.