dolibarr  x.y.z
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 
24 if (!defined('NOTOKENRENEWAL')) {
25  define('NOTOKENRENEWAL', '1'); // Disables token renewal
26 }
27 if (!defined('NOREQUIREMENU')) {
28  define('NOREQUIREMENU', '1');
29 }
30 if (!defined('NOREQUIREHTML')) {
31  define('NOREQUIREHTML', '1');
32 }
33 if (!defined('NOREQUIREAJAX')) {
34  define('NOREQUIREAJAX', '1');
35 }
36 if (!defined('NOREQUIRESOC')) {
37  define('NOREQUIRESOC', '1');
38 }
39 if (!defined('NOREQUIRETRAN')) {
40  define('NOREQUIRETRAN', '1');
41 }
42 
43 // Load Dolibarr environment
44 require '../../main.inc.php';
45 
46 $action = GETPOST('action');
47 
48 
49 /*
50  * View
51  */
52 
53 //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
54 top_httphead();
55 
56 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
57 
58 // Registering the location of boxes
59 if ($action) {
60  if ($action == 'getrandompassword' && ($user->admin || $user->rights->api->apikey->generate)) {
61  require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
62  $generic = GETPOST('generic') ? true : false;
63  echo getRandomPassword($generic);
64  }
65 }
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(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1436
getRandomPassword($generic=false, $replaceambiguouschars=null, $length=32)
Return a generated password using default module.