dolibarr 18.0.6
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
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}
39if (!defined('NOREQUIRETRAN')) {
40 define('NOREQUIRETRAN', '1');
41}
42if (!defined('CSRFCHECK_WITH_TOKEN')) {
43 define('CSRFCHECK_WITH_TOKEN', '1'); // Token is required even in GET mode
44}
45
46// Load Dolibarr environment
47require '../../main.inc.php';
48require_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// Security check
56if (empty($user->admin)) {
57 httponly_accessforbidden('This ajax component can be called by admin user only');
58}
59
60
61/*
62 * View
63 */
64
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
70if (!empty($action) && !empty($name)) {
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} else {
77 http_response_code(403);
78}
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).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
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.
httponly_accessforbidden($message=1, $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.