dolibarr  16.0.5
security_other.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30 
31 // Load translation files required by the page
32 $langs->loadLangs(array("users", "admin", "other"));
33 
34 if (!$user->admin) {
36 }
37 
38 $action = GETPOST('action', 'aZ09');
39 
40 
41 
42 /*
43  * Actions
44  */
45 
46 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
47  $code = $reg[1];
48  $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1);
49  if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
50  Header("Location: ".$_SERVER["PHP_SELF"]);
51  exit;
52  } else {
53  dol_print_error($db);
54  }
55 } elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
56  $code = $reg[1];
57  if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
58  Header("Location: ".$_SERVER["PHP_SELF"]);
59  exit;
60  } else {
61  dol_print_error($db);
62  }
63 } elseif ($action == 'updateform') {
64  $res1 = 1; $res2 = 1;
65  if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) {
66  $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
67  }
68  if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) {
69  $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
70  }
71  if ($res1 && $res2) {
72  setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
73  }
74 }
75 
76 
77 
78 /*
79  * View
80  */
81 
82 $form = new Form($db);
83 
84 $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
85 llxHeader('', $langs->trans("Miscellaneous"), $wikihelp);
86 
87 print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup');
88 
89 print '<span class="opacitymedium">'.$langs->trans("MiscellaneousDesc")."</span><br>\n";
90 print "<br>\n";
91 
92 
93 
94 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
95 print '<input type="hidden" name="token" value="'.newToken().'">';
96 print '<input type="hidden" name="action" value="updateform">';
97 
98 $head = security_prepare_head();
99 
100 print dol_get_fiche_head($head, 'misc', '', -1);
101 
102 print '<br>';
103 
104 // Other Options
105 print '<table class="noborder centpercent">';
106 print '<tr class="liste_titre">';
107 print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
108 print '<td class="right" width="100">'.$langs->trans("Status").'</td>';
109 print '</tr>';
110 
111 // Enable Captcha code
112 print '<tr class="oddeven">';
113 print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
114 print '<td class="right">';
115 if (function_exists("imagecreatefrompng")) {
116  if (!empty($conf->use_javascript_ajax)) {
117  print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
118  } else {
119  if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) {
120  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
121  } else {
122  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
123  }
124  }
125 } else {
126  $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning');
127  print $desc;
128 }
129 print '</td></tr>';
130 
131 // Enable advanced perms
132 print '<tr class="oddeven">';
133 print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
134 print '<td class="right">';
135 if (!empty($conf->use_javascript_ajax)) {
136  print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
137 } else {
138  if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
139  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
140  } else {
141  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
142  }
143 }
144 print "</td></tr>";
145 
146 print '</table>';
147 
148 
149 print '<br>';
150 
151 
152 // Timeout
153 print '<table width="100%" class="noborder">';
154 print '<tr class="liste_titre">';
155 print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
156 print '<td>'.$langs->trans("Value").'</td>';
157 print "</tr>\n";
158 
159 
160 $sessiontimeout = ini_get("session.gc_maxlifetime");
161 if (empty($conf->global->MAIN_SESSION_TIMEOUT)) {
162  $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout;
163 }
164 print '<tr class="oddeven">';
165 print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">';
166 if (ini_get("session.gc_probability") == 0) {
167  print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime")));
168 } else {
169  print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime")));
170 }
171 print '</td>';
172 print '<td class="nowrap">';
173 print '<input class="flat right width50" name="MAIN_SESSION_TIMEOUT" type="text" value="'.dol_escape_htmltag($conf->global->MAIN_SESSION_TIMEOUT).'"> '.strtolower($langs->trans("Seconds"));
174 print '</td>';
175 print '</tr>';
176 
177 /*
178 if (empty($conf->global->MAIN_APPLICATION_TITLE)) {
179  $conf->global->MAIN_APPLICATION_TITLE = "";
180 }
181 print '<tr class="oddeven">';
182 print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">';
183 print '</td>';
184 print '<td class="nowrap">';
185 print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.dol_escape_htmltag($conf->global->MAIN_APPLICATION_TITLE).'"> ';
186 print '</td>';
187 print '</tr>';
188 */
189 
190 print '</table>';
191 
192 print dol_get_fiche_end();
193 
194 print $form->buttonsSaveCancel("Modify", '');
195 
196 print '</form>';
197 
198 // End of page
199 llxFooter();
200 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
security_prepare_head
security_prepare_head()
Prepare array with list of tabs.
Definition: admin.lib.php:772
dolibarr_del_const
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
Definition: admin.lib.php:552
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
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
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
$wikihelp
if($actionsave) if(!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $wikihelp
View.
Definition: agenda_xcal.php:72
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:573
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dol_get_fiche_end
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition: functions.lib.php:2018
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
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59