dolibarr  7.0.0-beta
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@capnetworks.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 <http://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 $langs->load("users");
32 $langs->load("admin");
33 $langs->load("other");
34 
35 if (! $user->admin)
37 
38 $action=GETPOST('action','alpha');
39 
40 
41 
42 /*
43  * Actions
44  */
45 
46 if (preg_match('/set_(.*)/',$action,$reg))
47 {
48  $code=$reg[1];
49  $value=(GETPOST($code) ? GETPOST($code) : 1);
50  if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
51  {
52  Header("Location: ".$_SERVER["PHP_SELF"]);
53  exit;
54  }
55  else
56  {
57  dol_print_error($db);
58  }
59 }
60 
61 else if (preg_match('/del_(.*)/',$action,$reg))
62 {
63  $code=$reg[1];
64  if (dolibarr_del_const($db, $code, $conf->entity) > 0)
65  {
66  Header("Location: ".$_SERVER["PHP_SELF"]);
67  exit;
68  }
69  else
70  {
71  dol_print_error($db);
72  }
73 }
74 
75 else if ($action == 'updateform')
76 {
77  $res1=dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", $_POST["MAIN_APPLICATION_TITLE"],'chaine',0,'',$conf->entity);
78  $res2=dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", $_POST["MAIN_SESSION_TIMEOUT"],'chaine',0,'',$conf->entity);
79  if ($res1 && $res2) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
80 }
81 
82 
83 
84 /*
85  * View
86  */
87 
88 $form = new Form($db);
89 
90 $wikihelp='EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
91 llxHeader('',$langs->trans("Miscellaneous"),$wikihelp);
92 
93 print load_fiche_titre($langs->trans("SecuritySetup"),'','title_setup');
94 
95 print $langs->trans("MiscellaneousDesc")."<br>\n";
96 print "<br>\n";
97 
98 
99 
100 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
101 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
102 print '<input type="hidden" name="action" value="updateform">';
103 
104 $head=security_prepare_head();
105 
106 dol_fiche_head($head, 'misc', $langs->trans("Security"), -1);
107 
108 
109 // Other Options
110 $var=true;
111 
112 print '<table class="noborder" width="100%">';
113 print '<tr class="liste_titre">';
114 print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
115 print '<td align="right" width="100">'.$langs->trans("Status").'</td>';
116 print '</tr>';
117 
118 // Enable Captcha code
119 
120 print '<tr class="oddeven">';
121 print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>';
122 print '<td align="right">';
123 if (function_exists("imagecreatefrompng"))
124 {
125  if (! empty($conf->use_javascript_ajax))
126  {
127  print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA');
128  }
129  else
130  {
131  if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA))
132  {
133  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA">'.img_picto($langs->trans("Disabled"),'off').'</a>';
134  }
135  else
136  {
137  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA">'.img_picto($langs->trans("Enabled"),'on').'</a>';
138  }
139  }
140 }
141 else
142 {
143  $desc = $form->textwithpicto('',$langs->transnoentities("EnableGDLibraryDesc"),1,'warning');
144  print $desc;
145 }
146 print '</td></tr>';
147 
148 // Enable advanced perms
149 
150 print '<tr class="oddeven">';
151 print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>';
152 print '<td align="right">';
153 if (! empty($conf->use_javascript_ajax))
154 {
155  print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS');
156 }
157 else
158 {
159  if (empty($conf->global->MAIN_USE_ADVANCED_PERMS))
160  {
161  print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_USE_ADVANCED_PERMS">'.img_picto($langs->trans("Disabled"),'off').'</a>';
162  }
163  else
164  {
165  print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_USE_ADVANCED_PERMS">'.img_picto($langs->trans("Enabled"),'on').'</a>';
166  }
167 }
168 print "</td></tr>";
169 
170 print '</table>';
171 
172 
173 print '<br>';
174 
175 
176 // Timeout
177 $var=true;
178 
179 print '<table width="100%" class="noborder">';
180 print '<tr class="liste_titre">';
181 print '<td colspan="2">'.$langs->trans("Parameters").'</td>';
182 print '<td>'.$langs->trans("Value").'</td>';
183 print "</tr>\n";
184 
185 
186 $sessiontimeout=ini_get("session.gc_maxlifetime");
187 if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT=$sessiontimeout;
188 print '<tr class="oddeven">';
189 print '<td>'.$langs->trans("SessionTimeOut").'</td><td align="right">';
190 print $form->textwithpicto('',$langs->trans("SessionExplanation",ini_get("session.gc_probability"),ini_get("session.gc_divisor")));
191 print '</td>';
192 print '<td class="nowrap">';
193 print '<input class="flat" name="MAIN_SESSION_TIMEOUT" type="text" size="6" value="'.htmlentities($conf->global->MAIN_SESSION_TIMEOUT).'"> '.strtolower($langs->trans("Seconds"));
194 print '</td>';
195 print '</tr>';
196 
197 
198 $sessiontimeout=ini_get("session.gc_maxlifetime");
199 if (empty($conf->global->MAIN_APPLICATION_TITLE)) $conf->global->MAIN_APPLICATION_TITLE="";
200 print '<tr class="oddeven">';
201 print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td align="right">';
202 print '</td>';
203 print '<td class="nowrap">';
204 print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.htmlentities($conf->global->MAIN_APPLICATION_TITLE).'"> ';
205 print '</td>';
206 print '</tr>';
207 
208 print '</table>';
209 
210 dol_fiche_end();
211 
212 print '<div class="center"><input type="submit" class="button" name="button" value="'.$langs->trans("Modify").'"></div>';
213 
214 print '</form>';
215 
216 
217 llxFooter();
218 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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:485
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
if(GETPOST('button_removefilter_x','alpha')||GETPOST('button_removefilter.x','alpha')||GETPOST('button_removefilter','alpha')) if($action=="save"&&empty($cancel)) if(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg) $wikihelp)
View.
Definition: agenda.php:143
dolibarr_del_const($db, $name, $entity=1)
Effacement d'une constante dans la base de donnees.
Definition: admin.lib.php:410
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
security_prepare_head()
Prepare array with list of tabs.
Definition: admin.lib.php:581
print
Draft customers invoices.
Definition: index.php:91
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0)
On/off button for constant.
Definition: ajax.lib.php:500