dolibarr  16.0.5
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 require '../../main.inc.php';
47 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
48 
49 $action = GETPOST('action', 'aZ09'); // set or del
50 $name = GETPOST('name', 'alpha');
51 $entity = GETPOST('entity', 'int');
52 $value = ((GETPOST('value', 'int') || GETPOST('value', 'int') == '0') ? GETPOST('value', 'int') : 1);
53 
54 
55 /*
56  * View
57  */
58 
59 // Ajout directives pour resoudre bug IE
60 //header('Cache-Control: Public, must-revalidate');
61 //header('Pragma: public');
62 
63 //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
64 top_httphead();
65 
66 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
67 
68 // Registering the new value of constant
69 if (!empty($action) && !empty($name)) {
70  if ($user->admin) {
71  if ($action == 'set') {
72  dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity);
73  } elseif ($action == 'del') {
74  dolibarr_del_const($db, $name, $entity);
75  }
76  }
77 } else {
78  http_response_code(403);
79 }
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
top_httphead
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1407
dolibarr_set_const
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:627