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