dolibarr  13.0.2
constantonoff.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 
23 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
24 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
25 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
26 if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
27 if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
28 if (!defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
29 if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Token is required even in GET mode
30 
31 require '../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
33 
34 $action = GETPOST('action', 'aZ09'); // set or del
35 $name = GETPOST('name', 'alpha');
36 
37 
38 /*
39  * View
40  */
41 
42 // Ajout directives pour resoudre bug IE
43 //header('Cache-Control: Public, must-revalidate');
44 //header('Pragma: public');
45 
46 //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
47 top_httphead();
48 
49 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
50 
51 // Registering the new value of constant
52 if (!empty($action) && !empty($name))
53 {
54  $entity = GETPOST('entity', 'int');
55  $value = (GETPOST('value') ?GETPOST('value') : 1);
56 
57  if ($user->admin)
58  {
59  if ($action == 'set')
60  {
61  dolibarr_set_const($db, $name, $value, 'chaine', 0, '', $entity);
62  } elseif ($action == 'del')
63  {
64  dolibarr_del_const($db, $name, $entity);
65  }
66  }
67 } else {
68  http_response_code(403);
69 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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:575
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype= 'text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1214
dolibarr_del_const($db, $name, $entity=1)
Effacement d&#39;une constante dans la base de donnees.
Definition: admin.lib.php:499