dolibarr  17.0.4
constantonoff.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2011-2015 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2021 Laurent Destailleur <eldy@users.sourceforge.net>
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 
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 if (!defined('CSRFCHECK_WITH_TOKEN')) {
43  define('CSRFCHECK_WITH_TOKEN', '1'); // Token is required even in GET mode
44 }
45 
46 // Load Dolibarr environment
47 require '../../main.inc.php';
48 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
49 
50 $action = GETPOST('action', 'aZ09'); // set or del
51 $name = GETPOST('name', 'alpha');
52 $entity = GETPOST('entity', 'int');
53 $value = (GETPOST('value', 'aZ09') != '' ? GETPOST('value', 'aZ09') : 1);
54 
55 
56 /*
57  * View
58  */
59 
60 // Ajout directives pour resoudre bug IE
61 //header('Cache-Control: Public, must-revalidate');
62 //header('Pragma: public');
63 
64 //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
65 top_httphead();
66 
67 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
68 
69 // Registering the new value of constant
70 if (!empty($action) && !empty($name)) {
71  if ($user->admin) {
72  if ($action == 'set') {
73  dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity);
74  } elseif ($action == 'del') {
75  dolibarr_del_const($db, $name, $entity);
76  }
77  }
78 } else {
79  http_response_code(403);
80 }
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:632
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:556
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:1440