29require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
42$langs->loadLangs(array(
'users',
'admin',
'other'));
44$action =
GETPOST(
'action',
'aZ09');
45$sortfield =
GETPOST(
'sortfield',
'aZ09');
46$sortorder =
GETPOST(
'sortorder',
'aZ09');
47if (empty($sortfield)) {
50if (empty($sortorder)) {
54$upload_dir =
$conf->admin->dir_temp;
68 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
73if ($action ==
'updateform') {
74 $antivircommand =
GETPOST(
'MAIN_ANTIVIRUS_COMMAND',
'restricthtml');
75 $antivirparam =
GETPOST(
'MAIN_ANTIVIRUS_PARAM',
'restricthtml');
76 $antivircommand =
dol_string_nospecial($antivircommand,
'', array(
"|",
";",
"<",
">",
"&",
"+"));
79 if ($antivircommand && !empty($dolibarr_main_restrict_os_commands)) {
80 $arrayofallowedcommand = explode(
',', $dolibarr_main_restrict_os_commands);
81 $arrayofallowedcommand = array_map(
'trim', $arrayofallowedcommand);
82 dol_syslog(
"Command are restricted to ".$dolibarr_main_restrict_os_commands.
". We check that one of this command is inside ".$antivircommand);
83 $basenamecmddump = basename(str_replace(
'\\',
'/', $antivircommand));
84 if (!in_array($basenamecmddump, $arrayofallowedcommand)) {
85 $errormsg = $langs->trans(
'CommandIsNotInsideAllowedCommands');
92 $tmpumask =
GETPOST(
'MAIN_UMASK',
'alpha');
93 $tmpumask = (octdec($tmpumask) & 0666);
94 $tmpumask = decoct($tmpumask);
95 if (!preg_match(
'/^0/', $tmpumask)) {
96 $tmpumask =
'0'.$tmpumask;
98 if (empty($tmpumask)) {
106 $res7 =
dolibarr_set_const(
$db,
"MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION",
GETPOST(
'MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION',
'alpha'),
'chaine', 0,
'',
$conf->entity);
108 $res8 =
dolibarr_set_const(
$db,
"MAIN_SECURITY_MAXFILESIZE_DOWNLOADED",
GETPOST(
'MAIN_SECURITY_MAXFILESIZE_DOWNLOADED',
'alpha'),
'chaine', 0,
'',
$conf->entity);
110 if ($res3 && $res4 && $res5 && $res6 && $res7 && $res8) {
111 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
114} elseif ($action ==
'deletefile') {
116 $langs->load(
"other");
117 $file =
$conf->admin->dir_temp.
'/'.
GETPOST(
'urlfile',
'alpha');
133$wikihelp =
'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
134llxHeader(
'', $langs->trans(
"Files"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-security_file');
138print
'<span class="opacitymedium">'.$langs->trans(
"SecurityFilesDesc").
"</span><br>\n";
142print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
143print
'<input type="hidden" name="token" value="'.newToken().
'">';
144print
'<input type="hidden" name="action" value="updateform">';
154print
'<div class="div-table-responsive-no-min">';
155print
'<table class="noborder centpercent nomarginbottom">';
156print
'<tr class="liste_titre">';
157print
'<td>'.img_picto(
'',
'download',
'class="pictofixedwidth"').$langs->trans(
"Download").
'</td>';
161print
'<tr class="oddeven">';
162print
'<td>'.$langs->trans(
"MAIN_SECURITY_MAXFILESIZE_DOWNLOADED").
'<br>';
166print
'<input type="text" name="MAIN_SECURITY_MAXFILESIZE_DOWNLOADED" class="width100 right" spellcheck="false" value="'.getDolGlobalString(
'MAIN_SECURITY_MAXFILESIZE_DOWNLOADED').
'"> '.$langs->trans(
"Kb");
180print
'<div class="div-table-responsive-no-min">';
181print
'<table class="noborder centpercent nomarginbottom">';
182print
'<tr class="liste_titre">';
183print
'<td>'.img_picto(
'',
'upload',
'class="pictofixedwidth"').$langs->trans(
"UploadName").
'</td>';
187print
'<tr class="oddeven">';
188print
'<td>'.$langs->trans(
"MaxSizeForUploadedFiles").
'.';
189$max = @ini_get(
'upload_max_filesize');
191 print
'<br><span class="opacitymedium">'.$langs->trans(
"MustBeLowerThanPHPLimit", ((
int) $max) * 1024, $langs->trans(
"Kb")).
'.</span>';
193 print
' '.$langs->trans(
"NoMaxSizeByPHPLimit").
'.';
196print
'<td class="nowrap">';
197print
'<input class="flat width75 right" name="MAIN_UPLOAD_DOC" type="text" spellcheck="false" value="'.dol_escape_htmltag(
getDolGlobalString(
'MAIN_UPLOAD_DOC')).
'"> '.$langs->trans(
"Kb");
201print
'<tr class="oddeven">';
203print $form->textwithpicto($langs->trans(
"UMask"), $langs->trans(
"UMaskExplanation"));
205print
'<td class="nowrap">';
206print
'<input class="flat width75 right" name="MAIN_UMASK" type="text" spellcheck="false" value="'.dol_escape_htmltag(
getDolGlobalString(
'MAIN_UMASK')).
'">';
210print
'<tr class="oddeven">';
211print
'<td>'.$langs->trans(
"UploadExtensionRestriction").
'<br>';
212print
'<span class="opacitymedium">'.$langs->trans(
"UploadExtensionRestrictionExemple").
'</span>';
215print
'<input type="text" name="MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION" class="minwidth500imp" spellcheck="false" value="'.getDolGlobalString(
'MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION', implode(
',', getExecutableContent())).
'">';
224print
'<tr class="oddeven">';
225print
'<td>'.$langs->trans(
"UseAntivirusOnUploadedFile").
'</td>';
226print
'<td class="">';
227if (defined(
'MAIN_ANTIVIRUS_UPLOAD_ON') && constant(
'MAIN_ANTIVIRUS_UPLOAD_ON')) {
228 print
img_picto($langs->trans(
"Enabled").
" - Can't be disabled (PHP constant MAIN_ANTIVIRUS_UPLOAD_ON is set)",
'switch_on',
'', 0, 0, 0,
'',
'opacitymedium');
230 if (!empty(
$conf->use_javascript_ajax)) {
231 print ajax_constantonoff(
'MAIN_ANTIVIRUS_UPLOAD_ON', array(),
null, 0, 0, 1);
234 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_MAIN_ANTIVIRUS_UPLOAD_ON&token='.newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
236 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=del_MAIN_ANTIVIRUS_UPLOAD_ON&token='.newToken().
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
243 print
'<tr class="oddeven">';
244 print
'<td><span class="fieldrequired">'.$langs->trans(
"AntiVirusCommand").
'</span><br>';
245 print
'<span class="opacitymedium">'.$langs->trans(
"AntiVirusCommandExample").
'</span>';
250 $langs->load(
"errors");
251 $basedir = preg_replace(
'/"/',
'', dirname(
$conf->global->MAIN_ANTIVIRUS_COMMAND));
252 $listdir = explode(
';', ini_get(
'safe_mode_exec_dir'));
253 if (!in_array($basedir, $listdir)) {
254 print
img_warning($langs->trans(
'WarningSafeModeOnCheckExecDir'));
255 dol_syslog(
"safe_mode is on, basedir is ".$basedir.
", safe_mode_exec_dir is ".ini_get(
'safe_mode_exec_dir'), LOG_WARNING);
258 print
'<input type="text" '.((defined(
'MAIN_ANTIVIRUS_COMMAND') && !defined(
'MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) ?
'disabled ' :
'').
'name="MAIN_ANTIVIRUS_COMMAND" class="minwidth500imp" spellcheck="false" value="'.
dol_escape_htmltag(GETPOSTISSET(
'MAIN_ANTIVIRUS_COMMAND') ?
GETPOST(
'MAIN_ANTIVIRUS_COMMAND') :
getDolGlobalString(
'MAIN_ANTIVIRUS_COMMAND')).
'">';
259 if (defined(
'MAIN_ANTIVIRUS_COMMAND') && !defined(
'MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
260 print
'<br><span class="opacitymedium">'.$langs->trans(
"ValueIsForcedBySystem").
'</span>';
266 print
'<tr class="oddeven">';
267 print
'<td>'.$langs->trans(
"AntiVirusParam").
'<br>';
268 print
'<span class="opacitymedium">'.$langs->trans(
"AntiVirusParamExample").
'</span>';
271 print
'<input type="text" '.(defined(
'MAIN_ANTIVIRUS_PARAM') ?
'disabled ' :
'').
'name="MAIN_ANTIVIRUS_PARAM" class="minwidth500imp" spellcheck="false" value="'.(
getDolGlobalString(
'MAIN_ANTIVIRUS_PARAM') ?
dol_escape_htmltag(
getDolGlobalString(
'MAIN_ANTIVIRUS_PARAM')) :
'').
'">';
272 if (defined(
'MAIN_ANTIVIRUS_PARAM')) {
273 print
'<br><span class="opacitymedium">'.$langs->trans(
"ValueIsForcedBySystem").
'</span>';
285print $form->buttonsSaveCancel(
"Modify",
'');
293$formfile->form_attach_new_file($_SERVER[
'PHP_SELF'], $langs->trans(
"FormToTestFileUploadForm"), 0, 0, 1, 50,
null,
'', 1,
'', 0);
296$filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'', $sortfield, $sortorder ==
'desc' ? SORT_DESC : SORT_ASC, 1);
297if (count($filearray) > 0) {
298 $formfile->list_of_documents($filearray,
null,
'admin_temp',
'');
security_prepare_head()
Prepare array with list of tabs.
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).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $keyforsourcefile='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null, $forceFullTextIndexation='', $mode=0)
Get and save an upload file (for example after submitting a new file in a mail form).
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.