* Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/security_other.php * \ingroup core * \brief Security options setup */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); $langs->load("users"); $langs->load("admin"); $langs->load("other"); if (!$user->admin) accessforbidden(); $upload_dir=$conf->admin->dir_temp; /* * Actions */ if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); dol_add_file_process($upload_dir,0,0); } if ($_GET["action"] == 'activate_captcha') { dolibarr_set_const($db, "MAIN_SECURITY_ENABLECAPTCHA", '1','chaine',0,'',$conf->entity); Header("Location: security_other.php"); exit; } else if ($_GET["action"] == 'disable_captcha') { dolibarr_del_const($db, "MAIN_SECURITY_ENABLECAPTCHA",$conf->entity); Header("Location: security_other.php"); exit; } if ($_GET["action"] == 'activate_advancedperms') { dolibarr_set_const($db, "MAIN_USE_ADVANCED_PERMS", '1','chaine',0,'',$conf->entity); Header("Location: security_other.php"); exit; } else if ($_GET["action"] == 'disable_advancedperms') { dolibarr_del_const($db, "MAIN_USE_ADVANCED_PERMS",$conf->entity); Header("Location: security_other.php"); exit; } if ($_GET["action"] == 'MAIN_SESSION_TIMEOUT') { if (! dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", $_POST["MAIN_SESSION_TIMEOUT"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } if ($_GET["action"] == 'MAIN_UPLOAD_DOC') { if (! dolibarr_set_const($db, 'MAIN_UPLOAD_DOC',$_POST["MAIN_UPLOAD_DOC"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } if ($_GET["action"] == 'MAIN_UMASK') { if (! dolibarr_set_const($db, "MAIN_UMASK", $_POST["MAIN_UMASK"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } if ($_GET["action"] == 'MAIN_ANTIVIRUS_COMMAND') { if (! dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", $_POST["MAIN_ANTIVIRUS_COMMAND"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } if ($_GET["action"] == 'MAIN_ANTIVIRUS_PARAM') { if (! dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", $_POST["MAIN_ANTIVIRUS_PARAM"],'chaine',0,'',$conf->entity)) dol_print_error($db); else $mesg=$langs->trans("RecordModifiedSuccessfully"); } /* * View */ $form = new Form($db); llxHeader('',$langs->trans("Miscellanous")); print_fiche_titre($langs->trans("SecuritySetup"),'','setup'); print $langs->trans("MiscellanousDesc")."
\n"; print "
\n"; $head=security_prepare_head(); dol_fiche_head($head, 'misc', $langs->trans("Security")); // Timeout $var=true; print ''; print ''; print ''; print ''; print ''; print "\n"; $var=!$var; if (empty($conf->global->MAIN_SESSION_TIMEOUT)) $conf->global->MAIN_SESSION_TIMEOUT=ini_get("session.gc_maxlifetime"); print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameters").''.$langs->trans("Value").' 
'.$langs->trans("SessionTimeOut").''; print $form->textwithpicto('',$langs->trans("SessionExplanation",ini_get("session.gc_probability"),ini_get("session.gc_divisor"))); print ''; print ' '.strtolower($langs->trans("Seconds")); print ''; print ''; print '
'; print '
'; // Other Options $var=true; print ''; print ''; print ''; print ''; print ''; // Enable Captcha code $var=!$var; print ""; print ''; print '"; print ""; print ''; // Enable advanced perms $var=!$var; print ""; print ''; print '"; print ""; print ''; print '
'.$langs->trans("Parameters").''.$langs->trans("Status").'
'.$langs->trans("UseCaptchaCode").''; if (function_exists("imagecreatefrompng")) { if ($conf->global->MAIN_SECURITY_ENABLECAPTCHA == 0) { print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } if($conf->global->MAIN_SECURITY_ENABLECAPTCHA == 1) { print ''.img_picto($langs->trans("Enabled"),'switch_on').''; } } else { $form = new Form($db); $desc = $form->textwithpicto('',$langs->transnoentities("EnableGDLibraryDesc"),1,'warning'); print $desc; } print "
'.$langs->trans("UseAdvancedPerms").''; if ($conf->global->MAIN_USE_ADVANCED_PERMS == 0) { print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } if($conf->global->MAIN_USE_ADVANCED_PERMS == 1) { print ''.img_picto($langs->trans("Enabled"),'switch_on').''; } print "
'; print '
'; // Upload options $var=false; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $var=!$var; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Use anti virus $var=!$var; print ''; print ''; print ""; print ''; print '"; print ''; print ''; print ''; // Use anti virus $var=!$var; print ''; print ''; print ""; print ''; print '"; print ''; print ''; print ''; print '
'.$langs->trans("Parameters").''.$langs->trans("Value").' 
'.$langs->trans("MaxSizeForUploadedFiles").'.'; $max=@ini_get('upload_max_filesize'); if ($max) print ' '.$langs->trans("MustBeLowerThanPHPLimit",$max*1024,$langs->trans("Kb")).'.'; else print ' '.$langs->trans("NoMaxSizeByPHPLimit").'.'; print ''; print ' '.$langs->trans("Kb"); print ''; print ''; print '
'.$langs->trans("UMask").''; print $form->textwithpicto('',$langs->trans("UMaskExplanation")); print ''; print ''; print ''; print ''; print '
'.$langs->trans("AntiVirusCommand").'
'; print $langs->trans("AntiVirusCommandExample"); // Check command in inside safe_mode print '
'; if (ini_get('safe_mode') && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { $langs->load("errors"); $basedir=preg_replace('/"/','',dirname($conf->global->MAIN_ANTIVIRUS_COMMAND)); $listdir=explode(';',ini_get('safe_mode_exec_dir')); if (! in_array($basedir,$listdir)) { print img_warning($langs->trans('WarningSafeModeOnCheckExecDir')); dol_syslog("safe_mode is on, basedir is ".$basedir.", safe_mode_exec_dir is ".ini_get('safe_mode_exec_dir'), LOG_WARNING); } } print ''; print "'; print ''; print '
'.$langs->trans("AntiVirusParam").'
'; print $langs->trans("AntiVirusParamExample"); print '
'; print ''; print "'; print ''; print '
'; print ''; // Form to test upload dol_htmloutput_mesg($mesg); // Affiche formulaire upload print '
'; $formfile=new FormFile($db); $formfile->form_attach_new_file(DOL_URL_ROOT.'/admin/security_other.php',$langs->trans("FormToTestFileUploadForm"),0,0,1); llxFooter(); $db->close(); ?>