29require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
44$langs->loadLangs(array(
'users',
'admin',
'other'));
46$action =
GETPOST(
'action',
'aZ09');
47$sortfield =
GETPOST(
'sortfield',
'aZ09');
48$sortorder =
GETPOST(
'sortorder',
'aZ09');
49if (empty($sortfield)) {
52if (empty($sortorder)) {
56$upload_dir =
$conf->admin->dir_temp;
70 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
75if ($action ==
'updateform') {
76 $antivircommand =
GETPOST(
'MAIN_ANTIVIRUS_COMMAND',
'restricthtml');
77 $antivirparam =
GETPOST(
'MAIN_ANTIVIRUS_PARAM',
'restricthtml');
78 $antivircommand =
dol_string_nospecial($antivircommand,
'', array(
"|",
";",
"<",
">",
"&",
"+"));
81 if ($antivircommand && !empty($dolibarr_main_restrict_os_commands)) {
82 $arrayofallowedcommand = explode(
',', $dolibarr_main_restrict_os_commands);
83 $arrayofallowedcommand = array_map(
'trim', $arrayofallowedcommand);
84 dol_syslog(
"Command are restricted to ".$dolibarr_main_restrict_os_commands.
". We check that one of this command is inside ".$antivircommand);
85 $basenamecmddump = basename(str_replace(
'\\',
'/', $antivircommand));
86 if (!in_array($basenamecmddump, $arrayofallowedcommand)) {
87 $errormsg = $langs->trans(
'CommandIsNotInsideAllowedCommands');
94 $tmpumask =
GETPOST(
'MAIN_UMASK',
'alpha');
95 $tmpumask = (octdec($tmpumask) & 0666);
96 $tmpumask = decoct($tmpumask);
97 if (!preg_match(
'/^0/', $tmpumask)) {
98 $tmpumask =
'0'.$tmpumask;
100 if (empty($tmpumask)) {
108 $res7 =
dolibarr_set_const(
$db,
"MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION",
GETPOST(
'MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION',
'alpha'),
'chaine', 0,
'',
$conf->entity);
110 $res8 =
dolibarr_set_const(
$db,
"MAIN_SECURITY_MAXFILESIZE_DOWNLOADED",
GETPOST(
'MAIN_SECURITY_MAXFILESIZE_DOWNLOADED',
'alpha'),
'chaine', 0,
'',
$conf->entity);
112 if ($res3 && $res4 && $res5 && $res6 && $res7 && $res8) {
113 setEventMessages($langs->trans(
"RecordModifiedSuccessfully"),
null,
'mesgs');
116} elseif ($action ==
'deletefile') {
118 $langs->load(
"other");
119 $file =
$conf->admin->dir_temp.
'/'.
GETPOST(
'urlfile',
'alpha');
135$wikihelp =
'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad';
136llxHeader(
'', $langs->trans(
"Files"), $wikihelp,
'', 0, 0,
'',
'',
'',
'mod-admin page-security_file');
140print
'<span class="opacitymedium">'.$langs->trans(
"SecurityFilesDesc").
"</span><br>\n";
144print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
145print
'<input type="hidden" name="token" value="'.newToken().
'">';
146print
'<input type="hidden" name="action" value="updateform">';
156print
'<div class="div-table-responsive-no-min">';
157print
'<table class="noborder centpercent nomarginbottom">';
158print
'<tr class="liste_titre">';
159print
'<td>'.img_picto(
'',
'download',
'class="pictofixedwidth"').$langs->trans(
"Download").
'</td>';
163print
'<tr class="oddeven">';
164print
'<td>'.$langs->trans(
"MAIN_SECURITY_MAXFILESIZE_DOWNLOADED").
'<br>';
168print
'<input type="text" name="MAIN_SECURITY_MAXFILESIZE_DOWNLOADED" class="width100 right" spellcheck="false" value="'.getDolGlobalString(
'MAIN_SECURITY_MAXFILESIZE_DOWNLOADED').
'"> '.$langs->trans(
"Kb");
182print
'<div class="div-table-responsive-no-min">';
183print
'<table class="noborder centpercent nomarginbottom">';
184print
'<tr class="liste_titre">';
185print
'<td>'.img_picto(
'',
'upload',
'class="pictofixedwidth"').$langs->trans(
"UploadName").
'</td>';
189print
'<tr class="oddeven">';
190print
'<td>'.$langs->trans(
"MaxSizeForUploadedFiles").
'.';
191$max = @ini_get(
'upload_max_filesize');
193 print
'<br><span class="opacitymedium">'.$langs->trans(
"MustBeLowerThanPHPLimit", ((
int) $max) * 1024, $langs->trans(
"Kb")).
'.</span>';
195 print
' '.$langs->trans(
"NoMaxSizeByPHPLimit").
'.';
198print
'<td class="nowrap">';
199print
'<input class="flat width75 right" name="MAIN_UPLOAD_DOC" type="text" spellcheck="false" value="'.dol_escape_htmltag(
getDolGlobalString(
'MAIN_UPLOAD_DOC')).
'"> '.$langs->trans(
"Kb");
203print
'<tr class="oddeven">';
205print $form->textwithpicto($langs->trans(
"UMask"), $langs->trans(
"UMaskExplanation"));
207print
'<td class="nowrap">';
208print
'<input class="flat width75 right" name="MAIN_UMASK" type="text" spellcheck="false" value="'.dol_escape_htmltag(
getDolGlobalString(
'MAIN_UMASK')).
'">';
212print
'<tr class="oddeven">';
213print
'<td>'.$langs->trans(
"UploadExtensionRestriction").
'<br>';
214print
'<span class="opacitymedium">'.$langs->trans(
"UploadExtensionRestrictionExemple").
'</span>';
217print
'<input type="text" name="MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION" class="minwidth500imp" spellcheck="false" value="'.getDolGlobalString(
'MAIN_FILE_EXTENSION_UPLOAD_RESTRICTION', implode(
',',
getExecutableContent())).
'">';
226print
'<tr class="oddeven">';
227print
'<td>'.$langs->trans(
"UseAntivirusOnUploadedFile").
'</td>';
228print
'<td class="">';
229if (defined(
'MAIN_ANTIVIRUS_UPLOAD_ON') && constant(
'MAIN_ANTIVIRUS_UPLOAD_ON')) {
230 print
img_picto($langs->trans(
"Enabled").
" - Can't be disabled (PHP constant MAIN_ANTIVIRUS_UPLOAD_ON is set)",
'switch_on',
'', 0, 0, 0,
'',
'opacitymedium');
232 if (!empty(
$conf->use_javascript_ajax)) {
233 print ajax_constantonoff(
'MAIN_ANTIVIRUS_UPLOAD_ON', array(),
null, 0, 0, 1);
236 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=set_MAIN_ANTIVIRUS_UPLOAD_ON&token='.
newToken().
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
238 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=del_MAIN_ANTIVIRUS_UPLOAD_ON&token='.
newToken().
'">'.
img_picto($langs->trans(
"Enabled"),
'on').
'</a>';
245 print
'<tr class="oddeven">';
246 print
'<td><span class="fieldrequired">'.$langs->trans(
"AntiVirusCommand").
'</span><br>';
247 print
'<span class="opacitymedium">'.$langs->trans(
"AntiVirusCommandExample").
'</span>';
252 $langs->load(
"errors");
253 $basedir = preg_replace(
'/"/',
'', dirname(
$conf->global->MAIN_ANTIVIRUS_COMMAND));
254 $listdir = explode(
';', ini_get(
'safe_mode_exec_dir'));
255 if (!in_array($basedir, $listdir)) {
256 print
img_warning($langs->trans(
'WarningSafeModeOnCheckExecDir'));
257 dol_syslog(
"safe_mode is on, basedir is ".$basedir.
", safe_mode_exec_dir is ".ini_get(
'safe_mode_exec_dir'), LOG_WARNING);
260 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')).
'">';
261 if (defined(
'MAIN_ANTIVIRUS_COMMAND') && !defined(
'MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) {
262 print
'<br><span class="opacitymedium">'.$langs->trans(
"ValueIsForcedBySystem").
'</span>';
268 print
'<tr class="oddeven">';
269 print
'<td>'.$langs->trans(
"AntiVirusParam").
'<br>';
270 print
'<span class="opacitymedium">'.$langs->trans(
"AntiVirusParamExample").
'</span>';
273 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')) :
'').
'">';
274 if (defined(
'MAIN_ANTIVIRUS_PARAM')) {
275 print
'<br><span class="opacitymedium">'.$langs->trans(
"ValueIsForcedBySystem").
'</span>';
287print $form->buttonsSaveCancel(
"Modify",
'');
295$formfile->form_attach_new_file($_SERVER[
'PHP_SELF'], $langs->trans(
"FormToTestFileUploadForm"), 0, 0, 1, 50,
null,
'', 1,
'', 0);
298$filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'', $sortfield, $sortorder ==
'desc' ? SORT_DESC : SORT_ASC, 1);
299if (count($filearray) > 0) {
300 $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.
getExecutableContent()
Return array of extension for executable files of text files that can contains executable code.
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.