* 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 * \version $Id: security_other.php,v 1.41 2011/07/31 22:23:22 eldy Exp $ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/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 ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); $result=create_exdir($upload_dir); // Create dir if not exists if ($result >= 0) { $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],1,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { $mesg = '
'.$langs->trans("FileTransferComplete").'
'; include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); $formmail = new FormMail($db); $formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']); } else { $langs->load("errors"); if ($resupload < 0) // Unknown error { $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; } else if (preg_match('/ErrorFileIsInfectedWithAVirus.(.*)/',$resupload,$reg)) // Files infected by a virus { $mesg = '
'.$langs->trans("ErrorFileIsInfectedWithAVirus"); $mesg.= '
'.$langs->trans("Information").': '.$langs->trans($reg[1]); $mesg.= '
'; } else // Known error { $mesg = '
'.$langs->trans($resupload).'
'; } } } } 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 ' '.$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"),'off').''; } if($conf->global->MAIN_SECURITY_ENABLECAPTCHA == 1) { print ''.img_picto($langs->trans("Enabled"),'on').''; } } else { $html = new Form($db); $desc = $html->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"),'off').''; } if($conf->global->MAIN_USE_ADVANCED_PERMS == 1) { print ''.img_picto($langs->trans("Enabled"),'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); $db->close(); llxFooter('$Date: 2011/07/31 22:23:22 $ - $Revision: 1.41 $'); ?>