*
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/**
* \file htdocs/admin/security_other.php
* \ingroup core
* \brief Security options setup
* \version $Id$
*/
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"] == 'set_main_upload_doc')
{
if (! dolibarr_set_const($db, 'MAIN_UPLOAD_DOC',$_POST["MAIN_UPLOAD_DOC"],'chaine',0,'',$conf->entity))
{
dol_print_error($db);
}
else
{
Header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
}
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"] == 'MAIN_SESSION_TIMEOUT')
{
dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", $_POST["MAIN_SESSION_TIMEOUT"],'chaine',0,'',$conf->entity);
Header("Location: security_other.php");
exit;
}
if ($_GET["action"] == 'MAIN_UMASK')
{
dolibarr_set_const($db, "MAIN_UMASK", $_POST["MAIN_UMASK"],'chaine',0,'',$conf->entity);
Header("Location: security_other.php");
exit;
}
if ($_GET["action"] == 'MAIN_ANTIVIRUS_COMMAND')
{
dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", $_POST["MAIN_ANTIVIRUS_COMMAND"],'chaine',0,'',$conf->entity);
Header("Location: security_other.php");
exit;
}
if ($_GET["action"] == 'MAIN_ANTIVIRUS_PARAM')
{
dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", $_POST["MAIN_ANTIVIRUS_PARAM"],'chaine',0,'',$conf->entity);
Header("Location: security_other.php");
exit;
}
/*
* 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 '| '.$langs->trans("Parameters").' | ';
print ''.$langs->trans("Value").' | ';
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 '
';
// Other Options
$var=true;
print '';
print '';
print '| '.$langs->trans("Parameters").' | ';
print ''.$langs->trans("Status").' | ';
print '
';
// Enable Captcha code
$var=!$var;
print "";
print '| '.$langs->trans("UseCaptchaCode").' | ';
print '';
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 " | ";
print "";
print '
';
print '
';
print '
';
// Upload options
$var=false;
print '';
print '';
print '| '.$langs->trans("Parameters").' | ';
print ''.$langs->trans("Value").' | ';
print '
';
print '';
$var=!$var;
print '';
// Use anti virus
$var=!$var;
print '';
// Use anti virus
$var=!$var;
print '';
print '
';
print '';
// Form to test upload
if ($mesg) print $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$ - $Revision$');
?>