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 20/** 21 * \file htdocs/admin/security_other.php 22 * \ingroup core 23 * \brief Security options setup 24 */ 25 26require '../main.inc.php'; 27require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; 28require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 29require_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 34if (!$user->admin) 35 accessforbidden(); 36 37$action = GETPOST('action', 'aZ09'); 38 39 40 41/* 42 * Actions 43 */ 44 45if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) 46{ 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 { 51 Header("Location: ".$_SERVER["PHP_SELF"]); 52 exit; 53 } else { 54 dol_print_error($db); 55 } 56} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { 57 $code = $reg[1]; 58 if (dolibarr_del_const($db, $code, $conf->entity) > 0) 59 { 60 Header("Location: ".$_SERVER["PHP_SELF"]); 61 exit; 62 } else { 63 dol_print_error($db); 64 } 65} elseif ($action == 'updateform') 66{ 67 $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); 68 $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity); 69 if ($res1 && $res2) setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); 70} 71 72 73 74/* 75 * View 76 */ 77 78$form = new Form($db); 79 80$wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; 81llxHeader('', $langs->trans("Miscellaneous"), $wikihelp); 82 83print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); 84 85print '<span class="opacitymedium">'.$langs->trans("MiscellaneousDesc")."</span><br>\n"; 86print "<br>\n"; 87 88 89 90print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; 91print '<input type="hidden" name="token" value="'.newToken().'">'; 92print '<input type="hidden" name="action" value="updateform">'; 93 94$head = security_prepare_head(); 95 96print dol_get_fiche_head($head, 'misc', '', -1); 97 98 99// Other Options 100print '<table class="noborder centpercent">'; 101print '<tr class="liste_titre">'; 102print '<td colspan="3">'.$langs->trans("Parameters").'</td>'; 103print '<td class="right" width="100">'.$langs->trans("Status").'</td>'; 104print '</tr>'; 105 106// Enable Captcha code 107print '<tr class="oddeven">'; 108print '<td colspan="3">'.$langs->trans("UseCaptchaCode").'</td>'; 109print '<td class="right">'; 110if (function_exists("imagecreatefrompng")) 111{ 112 if (!empty($conf->use_javascript_ajax)) 113 { 114 print ajax_constantonoff('MAIN_SECURITY_ENABLECAPTCHA'); 115 } else { 116 if (empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) 117 { 118 print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; 119 } else { 120 print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_MAIN_SECURITY_ENABLECAPTCHA&token='.newToken().'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; 121 } 122 } 123} else { 124 $desc = $form->textwithpicto('', $langs->transnoentities("EnableGDLibraryDesc"), 1, 'warning'); 125 print $desc; 126} 127print '</td></tr>'; 128 129// Enable advanced perms 130print '<tr class="oddeven">'; 131print '<td colspan="3">'.$langs->trans("UseAdvancedPerms").'</td>'; 132print '<td class="right">'; 133if (!empty($conf->use_javascript_ajax)) 134{ 135 print ajax_constantonoff('MAIN_USE_ADVANCED_PERMS'); 136} else { 137 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) 138 { 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} 144print "</td></tr>"; 145 146print '</table>'; 147 148 149print '<br>'; 150 151 152// Timeout 153print '<table width="100%" class="noborder">'; 154print '<tr class="liste_titre">'; 155print '<td colspan="2">'.$langs->trans("Parameters").'</td>'; 156print '<td>'.$langs->trans("Value").'</td>'; 157print "</tr>\n"; 158 159 160$sessiontimeout = ini_get("session.gc_maxlifetime"); 161if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT = $sessiontimeout; 162print '<tr class="oddeven">'; 163print '<td>'.$langs->trans("SessionTimeOut").'</td><td class="right">'; 164if (ini_get("session.gc_probability") == 0) { 165 print $form->textwithpicto('', $langs->trans("SessionsPurgedByExternalSystem", ini_get("session.gc_maxlifetime"))); 166} else { 167 print $form->textwithpicto('', $langs->trans("SessionExplanation", ini_get("session.gc_probability"), ini_get("session.gc_divisor"), ini_get("session.gc_maxlifetime"))); 168} 169print '</td>'; 170print '<td class="nowrap">'; 171print '<input class="flat" name="MAIN_SESSION_TIMEOUT" type="text" size="6" value="'.htmlentities($conf->global->MAIN_SESSION_TIMEOUT).'"> '.strtolower($langs->trans("Seconds")); 172print '</td>'; 173print '</tr>'; 174 175 176if (empty($conf->global->MAIN_APPLICATION_TITLE)) $conf->global->MAIN_APPLICATION_TITLE = ""; 177print '<tr class="oddeven">'; 178print '<td>'.$langs->trans("MAIN_APPLICATION_TITLE").'</td><td class="right">'; 179print '</td>'; 180print '<td class="nowrap">'; 181print '<input class="flat" name="MAIN_APPLICATION_TITLE" type="text" size="20" value="'.htmlentities($conf->global->MAIN_APPLICATION_TITLE).'"> '; 182print '</td>'; 183print '</tr>'; 184 185print '</table>'; 186 187print dol_get_fiche_end(); 188 189print '<div class="center"><input type="submit" class="button" name="button" value="'.$langs->trans("Modify").'"></div>'; 190 191print '</form>'; 192 193// End of page 194llxFooter(); 195$db->close(); 196