diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 5538e0ad952..5ea581296af 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -80,8 +80,18 @@ if ($action == 'updateform') { } if (!$error) { + $tmpumask = GETPOST('MAIN_UMASK', 'alpha'); + $tmpumask = (octdec($tmpumask) & 0666); + $tmpumask = decoct($tmpumask); + if (!preg_match('/^0/', $tmpumask)) { + $tmpumask = '0'.$tmpumask; + } + if (empty($tmpumask) || $tmpumask === '0') { + $tmpumask = '0664'; + } + $res3 = dolibarr_set_const($db, 'MAIN_UPLOAD_DOC', GETPOST('MAIN_UPLOAD_DOC', 'alpha'), 'chaine', 0, '', $conf->entity); - $res4 = dolibarr_set_const($db, "MAIN_UMASK", GETPOST('MAIN_UMASK', 'alpha'), 'chaine', 0, '', $conf->entity); + $res4 = dolibarr_set_const($db, "MAIN_UMASK", $tmpumask, 'chaine', 0, '', $conf->entity); $res5 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_COMMAND", trim($antivircommand), 'chaine', 0, '', $conf->entity); $res6 = dolibarr_set_const($db, "MAIN_ANTIVIRUS_PARAM", trim($antivirparam), 'chaine', 0, '', $conf->entity); if ($res3 && $res4 && $res5 && $res6) { diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 8dae305a989..846e9272fb6 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -746,7 +746,7 @@ class Documents extends DolibarrApi if ($fhandle) { $nbofbyteswrote = fwrite($fhandle, $newfilecontent); fclose($fhandle); - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($destfiletmp); } else { throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 11cb4f98dbd..9999f63b624 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -2278,7 +2278,7 @@ class ActionComm extends CommonObject // Create temp file $outputfiletmp = tempnam($conf->agenda->dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file if ($format == 'vcal') { diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index b9d1fd7c54a..266ddd3b79f 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1700,9 +1700,7 @@ class BonPrelevement extends CommonObject } fclose($this->file); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($this->filename, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($this->filename); return $result; } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 55d7ec6fdcf..b6513951f22 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -820,9 +820,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto // check if pdftk is installed if (file_exists($file)) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); @@ -888,9 +886,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $now = dol_now(); $file = $diroutputmassaction.'/'.$filename.'_'.dol_print_date($now, 'dayhourlog').'.pdf'; $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $langs->load("exports"); setEventMessages($langs->trans('FileSuccessfullyBuilt', $filename.'_'.dol_print_date($now, 'dayhourlog')), null, 'mesgs'); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 42e936e5cba..9e8593e6d1b 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1213,9 +1213,7 @@ class CMailFile } fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } @@ -1797,7 +1795,7 @@ class CMailFile if ($fhandle) { $nbofbyteswrote = fwrite($fhandle, base64_decode($filecontent)); fclose($fhandle); - @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($destfiletmp); } else { $this->errors[] = "Failed to open file '".$destfiletmp."' for write"; return -1; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 3f082ba6d53..a8dc4bfff9a 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -231,9 +231,7 @@ class CSMSFile fputs($fp, "Message:\n".$this->message); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } @@ -257,9 +255,7 @@ class CSMSFile fputs($fp, "\nResult id=".$result); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } } diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 8b3c9177d3e..b2b5e2c6e93 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -743,9 +743,7 @@ class Ldap if ($fp) { fputs($fp, $content); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); return 1; } else { return -1; diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index da3257b09c9..d70876c5709 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -295,10 +295,7 @@ class RssParser if ($fp) { fwrite($fp, $str); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); $this->_lastfetchdate = $nowgmt; } else { diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 60cdc5d5226..1ef45097594 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -119,10 +119,7 @@ abstract class Stats $fp = fopen($newpathofdestfile, 'w'); fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } @@ -222,10 +219,7 @@ abstract class Stats if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); } else { dol_syslog("Failed to write cache file", LOG_ERR); } @@ -332,10 +326,7 @@ abstract class Stats if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); } $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 3e310ade5bc..be91b49765b 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -494,9 +494,7 @@ class Utils } } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } else { $langs->load("errors"); dol_syslog("Failed to open file ".$outputfile, LOG_ERR); @@ -739,9 +737,7 @@ class Utils pclose($handlein); fclose($handle); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } // Update with result @@ -1051,7 +1047,7 @@ class Utils fclose($sourcehandle); gzclose($gzfilehandle); - @chmod($logpath.'/'.$logname.'.1.gz', octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); + dolChmod($logpath.'/'.$logname.'.1.gz'); } dol_delete_file($logpath.'/'.$logname, 0, 0, 0, null, false, 0); @@ -1061,7 +1057,7 @@ class Utils fclose($newlog); //var_dump($logpath.'/'.$logname." - ".octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK)); - @chmod($logpath.'/'.$logname, octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); + dolChmod($logpath.'/'.$logname); } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 93863254a03..e74bd537fb2 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -678,7 +678,7 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask } file_put_contents($newpathoftmpdestfile, $content); - @chmod($newpathoftmpdestfile, octdec($newmask)); + dolChmod($newpathoftmpdestfile, $newmask); // Rename $result = dol_move($newpathoftmpdestfile, $newpathofdestfile, $newmask, (($destfile == $srcfile) ? 1 : 0), 0, $indexdatabase); @@ -694,7 +694,7 @@ function dolReplaceInFile($srcfile, $arrayreplacement, $destfile = '', $newmask $newmask = '0664'; } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile, $newmask); return 1; } @@ -752,7 +752,7 @@ function dol_copy($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1) $newmask = '0664'; } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile, $newmask); return 1; } @@ -900,6 +900,18 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te } } + global $dolibarr_main_restrict_os_commands; + if (!empty($dolibarr_main_restrict_os_commands)) { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); + if (in_array(basename($destfile), $arrayofallowedcommand)) { + //$langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + //setEventMessages($langs->trans("ErrorFilenameReserved", basename($destfile)), null, 'errors'); + dol_syslog("files.lib.php::dol_move canceled because target filename ".basename($destfile)." is using a reserved command name. we ignore the move request.", LOG_WARNING); + return false; + } + } + $result = @rename($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ if (!$result) { if ($destexists) { @@ -975,11 +987,11 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te if (empty($newmask)) { $newmask = empty($conf->global->MAIN_UMASK) ? '0755' : $conf->global->MAIN_UMASK; } - $newmaskdec = octdec($newmask); + // Currently method is restricted to files (dol_delete_files previously used is for files, and mask usage if for files too) // to allow mask usage for dir, we shoul introduce a new param "isdir" to 1 to complete newmask like this // if ($isdir) $newmaskdec |= octdec('0111'); // Set x bit required for directories - @chmod($newpathofdestfile, $newmaskdec); + dolChmod($newpathofdestfile, $newmask); } return $result; @@ -1219,9 +1231,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable // Move file $return = move_uploaded_file($src_file_osencoded, $file_name_osencoded); if ($return) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file_name_osencoded); dol_syslog("Files.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); return $successcode; // Success } else { @@ -1303,7 +1313,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, // If it fails and it is because of the missing write permission on parent dir if (!$ok && file_exists(dirname($filename)) && !(fileperms(dirname($filename)) & 0200)) { dol_syslog("Error in deletion, but parent directory exists with no permission to write, we try to change permission on parent directory and retry...", LOG_DEBUG); - @chmod(dirname($filename), fileperms(dirname($filename)) | 0200); + dolChmod(dirname($filename), decoct(fileperms(dirname($filename)) | 0200)); // Now we retry deletion if ($nophperrors) { $ok = @unlink($filename); @@ -1592,11 +1602,10 @@ function dol_meta_create($object) $fp = fopen($file, "w"); fputs($fp, $meta); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - return 1; + dolChmod($file); + + return 1; } else { dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING); } @@ -1713,6 +1722,17 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess $destfile = dol_string_nohtmltag($destfile); $destfull = dol_string_nohtmltag($destfull); + global $dolibarr_main_restrict_os_commands; + if (!empty($dolibarr_main_restrict_os_commands)) { + $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); + $arrayofallowedcommand = array_map('trim', $arrayofallowedcommand); + if (in_array(basename($destfull), $arrayofallowedcommand)) { + $langs->load("errors"); // key must be loaded because we can't rely on loading during output, we need var substitution to be done now. + setEventMessages($langs->trans("ErrorFilenameReserved", basename($destfull)), null, 'errors'); + return -1; + } + } + // Move file from temp directory to final directory. A .noexe may also be appended on file name. $resupload = dol_move_uploaded_file($TFile['tmp_name'][$i], $destfull, $allowoverwrite, 0, $TFile['error'][$i], 0, $varfiles, $upload_dir); @@ -2388,7 +2408,7 @@ function dol_compress_dir($inputdir, $outputfile, $mode = "zip", $excludefiles = $newmask = '0664'; } - @chmod($outputfile, octdec($newmask)); + dolChmod($outputfile, $newmask); return 1; } @@ -3215,7 +3235,7 @@ function dol_filecache($directory, $filename, $object) } $cachefile = $directory.$filename; file_put_contents($cachefile, serialize($object), LOCK_EX); - @chmod($cachefile, 0644); + dolChmod($cachefile, '0644'); } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c138ccb743c..125ac7b36c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6864,13 +6864,16 @@ function dol_mkdir($dir, $dataroot = '', $newmask = '') * Change mod of a file * * @param string $filepath Full file path + * @param string $newmask Force new mask. For example '0644' * @return void */ -function dolChmod($filepath) +function dolChmod($filepath, $newmask = '') { global $conf; - if (!empty($conf->global->MAIN_UMASK)) { + if (!empty($newmask)) { + @chmod($filepath, octdec($newmask)); + } elseif (!empty($conf->global->MAIN_UMASK)) { @chmod($filepath, octdec($conf->global->MAIN_UMASK)); } } diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 37cc70760eb..b10b000b8e7 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -362,9 +362,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Set permissions on file - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($imgTargetName, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($imgTargetName); // Free memory. This does not delete image. imagedestroy($img); @@ -761,9 +759,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Set permissions on file - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($imgThumbName); // Free memory. This does not delete image. imagedestroy($img); diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index da01d93fc62..3a9712ba58f 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -277,9 +277,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte if (!$error && $pagecount) { $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); } if ($usestdout) { diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 163c90aa8a9..a60e9a3a78a 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -227,7 +227,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = $result = file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass); if ($result) { - @chmod($pathoffiletoedittarget, octdec($newmask)); + dolChmod($pathoffiletoedittarget, $newmask); } else { $error++; } @@ -369,7 +369,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $result = file_put_contents($pathoffiletoedittarget, $contentsql); if ($result) { - @chmod($pathoffiletoedittarget, octdec($newmask)); + dolChmod($pathoffiletoedittarget, $newmask); } else { $error++; setEventMessages($langs->trans("ErrorFailToCreateFile", $pathoffiletoedittarget), null, 'errors'); @@ -408,7 +408,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $result2 = file_put_contents($pathoffiletoedittarget, $contentsql); if ($result2) { - @chmod($pathoffiletoedittarget, octdec($newmask)); + dolChmod($pathoffiletoedittarget, $newmask); } else { $error++; setEventMessages($langs->trans("ErrorFailToCreateFile", $pathoffiletoedittarget), null, 'errors'); diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 93da106aebd..e0bf4a683f0 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -457,7 +457,7 @@ function encodedecode_dbpassconf($level = 0) // It's config file, so we set read permission for creator only. // Should set permission to web user and groups for users used by batch - //@chmod($file, octdec('0600')); + //dolChmod($file, '0600'); return 1; } else { diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 61a894b2c96..156e0fc1022 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -1210,9 +1210,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $fp = fopen($filetosave, "w"); fputs($fp, $tmpgeturl['content']); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filetosave); } } } @@ -1281,9 +1279,7 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $fp = fopen($filetosave, "w"); fputs($fp, $tmpgeturl['content']); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filetosave, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filetosave); } } } diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 744ca519f90..679f6e3fb42 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -45,9 +45,7 @@ function dolSaveMasterFile($filemaster) $mastercontent .= "}\n"; $mastercontent .= '?>'."\n"; $result = file_put_contents($filemaster, $mastercontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filemaster); return $result; } @@ -79,9 +77,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) if ($result === false) { dol_syslog("Failed to write file ".$filealias, LOG_WARNING); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filealias, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filealias); // Save also alias into language subdirectory if it is not a main language if ($objectpage->lang && in_array($objectpage->lang, explode(',', $object->otherlang))) { @@ -99,9 +95,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) if ($result === false) { dol_syslog("Failed to write file ".$filealiassub, LOG_WARNING); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filealiassub, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filealiassub); } elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) { // Save also alias into all language subdirectories if it is a main language if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR) && !empty($object->otherlang)) { @@ -122,9 +116,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) if ($result === false) { dol_syslog("Failed to write file ".$filealiassub, LOG_WARNING); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filealiassub, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filealiassub); } } } @@ -276,9 +268,8 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage, //var_dump($filetpl);exit; $result = file_put_contents($filetpl, $tplcontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); - } + + dolChmod($filetpl); return $result; } @@ -318,9 +309,8 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $o $indexcontent .= '// END PHP ?>'."\n"; $result1 = file_put_contents($fileindex, $indexcontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); - } + + dolChmod($fileindex); if (is_object($object) && $object->fk_default_home > 0) { $objectpage = new WebsitePage($db); @@ -352,9 +342,7 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $o if ($result === false) { dol_syslog("Failed to write file ".$fileindexsub, LOG_WARNING); } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($fileindexsub, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($fileindexsub); } } } @@ -368,9 +356,7 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper, $o $wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.php'); $result2 = file_put_contents($filewrapper, $wrappercontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filewrapper); } else { $result2 = true; } @@ -394,9 +380,7 @@ function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent) dol_mkdir($pathofwebsite); $result = file_put_contents($filehtmlheader, $htmlheadercontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filehtmlheader); return $result; } @@ -416,9 +400,7 @@ function dolSaveCssFile($filecss, $csscontent) dol_mkdir($pathofwebsite); $result = file_put_contents($filecss, $csscontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filecss, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filecss); return $result; } @@ -438,9 +420,7 @@ function dolSaveJsFile($filejs, $jscontent) dol_mkdir($pathofwebsite); $result = file_put_contents($filejs, $jscontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filejs, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filejs); return $result; } @@ -460,9 +440,7 @@ function dolSaveRobotFile($filerobot, $robotcontent) dol_mkdir($pathofwebsite); $result = file_put_contents($filerobot, $robotcontent); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filerobot, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filerobot); return $result; } @@ -482,9 +460,7 @@ function dolSaveHtaccessFile($filehtaccess, $htaccess) dol_mkdir($pathofwebsite); $result = file_put_contents($filehtaccess, $htaccess); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filehtaccess); return $result; } @@ -504,9 +480,7 @@ function dolSaveManifestJson($file, $content) dol_mkdir($pathofwebsite); $result = file_put_contents($file, $content); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); return $result; } @@ -526,9 +500,7 @@ function dolSaveReadme($file, $content) dol_mkdir($pathofwebsite); $result = file_put_contents($file, $content); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); return $result; } @@ -548,9 +520,7 @@ function dolSaveLicense($file, $content) dol_mkdir($pathofwebsite); $result = file_put_contents($file, $content); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); return $result; } diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index 6b5c92881c5..45c7bf17793 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -284,10 +284,7 @@ function build_calfile($format, $title, $desc, $events_array, $outputfile) fwrite($calfileh, "END:VCALENDAR"); fclose($calfileh); - - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } else { dol_syslog("xcal.lib.php::build_calfile Failed to open file ".$outputfile." for writing"); return -2; @@ -429,10 +426,7 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt fwrite($fichier, ""); fclose($fichier); - - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($outputfile); } } diff --git a/htdocs/core/modules/action/rapport.class.php b/htdocs/core/modules/action/rapport.class.php index d91b748d7d5..d4805143e59 100644 --- a/htdocs/core/modules/action/rapport.class.php +++ b/htdocs/core/modules/action/rapport.class.php @@ -209,9 +209,7 @@ class CommActionRapport $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index ba4f39919bf..a68b8fd2354 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -480,9 +480,7 @@ class doc_generic_asset_odt extends ModelePDFAsset $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index b20f60fe084..92af12427b2 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -815,13 +815,11 @@ class pdf_standard_asset extends ModelePDFAsset $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index ddc65b1ff8c..2af920da42e 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -250,9 +250,7 @@ class pdf_ban extends ModeleBankAccountDoc $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index ecf7a2a6ad9..00d57161e10 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -429,9 +429,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index ea877432c17..d34844f14f2 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -498,9 +498,7 @@ class doc_generic_bom_odt extends ModelePDFBom $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 43db9a615e6..6d257de6306 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -203,9 +203,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index bbace838183..9172115903b 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -496,9 +496,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 6fe07506958..533619ed055 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -676,9 +676,7 @@ class pdf_einstein extends ModelePDFCommandes $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 8614238c2c7..bae583ccf4c 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -900,9 +900,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 83e8f2551f7..aec1a96109a 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -492,9 +492,7 @@ class doc_generic_contract_odt extends ModelePDFContract $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 8921425a8ac..69b7f193a70 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -496,9 +496,7 @@ class pdf_strato extends ModelePDFContract $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index 3db75e6ca9b..7ae6356aabc 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -634,9 +634,7 @@ class pdf_storm extends ModelePDFDeliveryOrder $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 281dbf65026..af2fda0f7a8 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -619,9 +619,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 155d16842ec..e48e2e2c092 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -240,9 +240,7 @@ class html_cerfafr extends ModeleDon $handle = fopen($file, "w"); fwrite($handle, $form); fclose($handle); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index f8280aab301..bf264b45c94 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -559,9 +559,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index bb8eb9e9baf..34699a6e608 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -763,9 +763,7 @@ class pdf_espadon extends ModelePdfExpedition $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index db10c37e7e8..130608be433 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -425,9 +425,7 @@ class pdf_merou extends ModelePdfExpedition $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 87dd02096e8..f0d2fb847a1 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -669,9 +669,7 @@ class pdf_rouget extends ModelePdfExpedition $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 4363a7e90f1..5568cd28840 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -539,9 +539,7 @@ class pdf_standard extends ModeleExpenseReport $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index e8fc6325001..14f71fa4f99 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -520,9 +520,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 1c93f32a4d6..207514ca195 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -908,9 +908,7 @@ class pdf_crabe extends ModelePDFFactures $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 4ae1df8dae6..98c2e4552bc 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1058,9 +1058,7 @@ class pdf_sponge extends ModelePDFFactures $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 7616fba5c6b..f209dc67247 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -469,9 +469,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 2d125d2743a..f38f61e6d8a 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -412,9 +412,7 @@ class doc_generic_member_odt extends ModelePDFMember $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 5a038e67c6d..179645e1a97 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -455,10 +455,7 @@ class pdf_standard extends CommonStickerGenerator // Output to file $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index d42dbaa0666..a1c4ff54654 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -791,9 +791,7 @@ class pdf_standard extends ModelePDFMovement $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 90d1f2f8d6b..340530d8504 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -484,9 +484,7 @@ class doc_generic_mo_odt extends ModelePDFMo $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 492385a53a3..e625d685727 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -684,9 +684,7 @@ class pdf_vinci extends ModelePDFMo $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index 0e9eefa1e45..a3195290b21 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -337,9 +337,7 @@ class pdf_standardlabel extends CommonStickerGenerator // Output to file $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index 0d380ce1537..fe18c8cb467 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -360,10 +360,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator // Output to file $pdf->Output($file, 'F'); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } - + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 6fde0ce16c4..ba98d74fb3f 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -481,9 +481,7 @@ class doc_generic_product_odt extends ModelePDFProduct $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index c8190a362f5..b244f01e0fa 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -581,9 +581,7 @@ class pdf_standard extends ModelePDFProduct $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index c3a8cd796fc..635a627d0a1 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -1167,9 +1167,7 @@ class doc_generic_project_odt extends ModelePDFProjects $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index b5c3c6d215b..2bfd73757c9 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -521,9 +521,7 @@ class pdf_baleine extends ModelePDFProjects $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index e72198e5b22..c1365fde536 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -769,9 +769,7 @@ class pdf_beluga extends ModelePDFProjects $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 7af10dd170d..c5aa80d5748 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -524,9 +524,7 @@ class pdf_timespent extends ModelePDFProjects $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index a7f3eab4a30..49522a01d33 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -845,9 +845,7 @@ class doc_generic_task_odt extends ModelePDFTask $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index ac95786cdd2..d1a64bcf039 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -523,9 +523,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9ea524f2977..d3117e526f8 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -873,9 +873,7 @@ class pdf_azur extends ModelePDFPropales $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 8a41e680fc5..ddc4e60ad4c 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -990,9 +990,7 @@ class pdf_cyan extends ModelePDFPropales $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 5440c8e1201..67504bea2cd 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -343,9 +343,7 @@ class pdf_paiement $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 84d95a5036c..463a794faee 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -485,9 +485,7 @@ class doc_generic_reception_odt extends ModelePdfReception $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 127cc790e0c..b605ac68631 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -599,9 +599,7 @@ class pdf_squille extends ModelePdfReception $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); return 1; // No error } else { diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index d6804c3a397..e8d6c8317dc 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -433,9 +433,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 358369d1f43..4ce652dd55b 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -484,9 +484,7 @@ class doc_generic_stock_odt extends ModelePDFStock $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index ac0bf98b0f3..a5c1d87691d 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -595,9 +595,7 @@ class pdf_standard extends ModelePDFStock $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 35a52f35bd8..b6e38438a69 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -659,8 +659,7 @@ class pdf_eagle extends ModelePdfStockTransfer $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index ed8b46c7746..23feb4bfca6 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -796,8 +796,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index c9e18e7c4ab..c37eef06360 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -483,9 +483,7 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 802abd6a184..d1b8331ea5d 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -622,9 +622,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index ca7d1b3d61b..8a747775b3f 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -478,9 +478,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 2343885cb4d..43bfae86af3 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -840,9 +840,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 1de4acd1550..cecd9737cdf 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -722,9 +722,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 74f90f1d68e..18cb0796ed0 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -478,9 +478,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 8fca5110896..116b6daf9be 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -510,9 +510,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 2f264cfb928..0efa9cc63be 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -702,9 +702,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $this->result = array('fullpath'=>$file); diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 265741f35c6..73ebc0d1d90 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -180,7 +180,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface $message = dol_print_date(dol_now('gmt'), 'standard', 'gmt').$delay." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident > 0 ?str_pad('', $this->ident, ' ') : '').$content['message']; fwrite($filefd, $message."\n"); fclose($filefd); - @chmod($logfile, octdec(empty($conf->global->MAIN_UMASK) ? '0664' : $conf->global->MAIN_UMASK)); + dolChmod($logfile); } } } diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index e175115ac28..de316dbc4b1 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -405,9 +405,7 @@ class doc_generic_ticket_odt extends ModelePDFTicket $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 00edf04fac0..e8a15b8f09a 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -433,9 +433,7 @@ class doc_generic_user_odt extends ModelePDFUser $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index a5447260a2f..5700870444f 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -491,9 +491,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index e6c1aac1372..b73748ecf23 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -287,9 +287,7 @@ if ($action == 'download') { if ($result) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($localfile, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($localfile); // Define mime type $type = 'application/octet-stream'; diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 0bba0e59345..47226a60829 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -880,7 +880,7 @@ IMG; pclose($handlein); fclose($handle); } - if (! empty($conf->global->MAIN_UMASK)) @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfile); } if ($retval == 0) { diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-corporate/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-noimg/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php index 4f1c281ee93..648b0e3ef6a 100644 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php +++ b/htdocs/install/doctemplates/websites/website_template-stellar/containers/wrapper.php @@ -137,7 +137,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l); diff --git a/htdocs/install/step5.php b/htdocs/install/step5.php index 6598843b882..40e1c1b799e 100644 --- a/htdocs/install/step5.php +++ b/htdocs/install/step5.php @@ -443,11 +443,12 @@ if ($action == "set") { $fp = @fopen($lockfile, "w"); if ($fp) { if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) { - $force_install_lockinstall = 444; // For backward compatibility + $force_install_lockinstall = '444'; // For backward compatibility } fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); - @chmod($lockfile, octdec($force_install_lockinstall)); + dolChmod($lockfile, $force_install_lockinstall); + $createlock = 1; } } @@ -490,11 +491,12 @@ if ($action == "set") { $fp = @fopen($lockfile, "w"); if ($fp) { if (empty($force_install_lockinstall) || $force_install_lockinstall == 1) { - $force_install_lockinstall = 444; // For backward compatibility + $force_install_lockinstall = '444'; // For backward compatibility } fwrite($fp, "This is a lock file to prevent use of install or upgrade pages (set with permission ".$force_install_lockinstall.")"); fclose($fp); - @chmod($lockfile, octdec($force_install_lockinstall)); + dolChmod($lockfile, $force_install_lockinstall); + $createlock = 1; } } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9f370340a01..24922a912dc 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -374,7 +374,7 @@ DoTestSendHTML=Test sending HTML ErrorCantUseRazIfNoYearInMask=Error, can't use option @ to reset counter each year if sequence {yy} or {yyyy} is not in mask. ErrorCantUseRazInStartedYearIfNoYearMonthInMask=Error, can't use option @ if sequence {yy}{mm} or {yyyy}{mm} is not in mask. UMask=UMask parameter for new files on Unix/Linux/BSD/Mac file system. -UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
It must be the octal value (for example, 0666 means read and write for everyone).
This parameter is useless on a Windows server. +UMaskExplanation=This parameter allow you to define permissions set by default on files created by Dolibarr on server (during upload for example).
It must be the octal value (for example, 0666 means read and write for everyone.). Recommended value is 0660
This parameter is useless on a Windows server. SeeWikiForAllTeam=Take a look at the Wiki page for a list of contributors and their organization UseACacheDelay= Delay for caching export response in seconds (0 or empty for no cache) DisableLinkToHelpCenter=Hide the link "Need help or support" on the login page diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 164bfc3911c..6e60f238911 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -262,6 +262,7 @@ ErrorParameterMustBeEnabledToAllwoThisFeature=Error, parameter %s must be ErrorLoginDateValidity=Error, this login is outside the validity date range ErrorValueLength=Length of field '%s' must be higher than '%s' ErrorReservedKeyword=The word '%s' is a reserved keyword +ErrorFilenameReserved=The filename %s can't be used as it is a reserved and protected command. ErrorNotAvailableWithThisDistribution=Not available with this distribution ErrorPublicInterfaceNotEnabled=Public interface was not enabled ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must be defined if it is set as a translation of another page diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 299bae1d6ce..d2fc01ddead 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1246,20 +1246,20 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { } if ($objectname != $firstobjectname) { $rightToadd = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Read objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Read objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'read'; + \$this->rights[\$r][5] = 'read'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'write'; + \$this->rights[\$r][5] = 'write'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Delete objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Delete objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'delete'; + \$this->rights[\$r][5] = 'delete'; \$r++; "; dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER PERMISSIONS */' => '/*'.strtoupper($objectname).'*/'.$rightToadd."/*END ".strtoupper($objectname).'*/'."\n\t\t".'/* END MODULEBUILDER PERMISSIONS */')); @@ -1835,20 +1835,20 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { // regenerate permissions and delete them $rights = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Read objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Read objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'read'; + \$this->rights[\$r][5] = 'read'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Create/Update objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'write'; + \$this->rights[\$r][5] = 'write'; \$r++; - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = 'Delete objects of ".$module."'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = 'Delete objects of ".$module."'; \$this->rights[\$r][4] = '".strtolower($objectname)."'; - \$this->rights[\$r][5] = 'delete'; + \$this->rights[\$r][5] = 'delete'; \$r++; "; @@ -2050,10 +2050,10 @@ if ($dirins && $action == 'addright' && !empty($module) && empty($cancel)) { } //prepare stirng to add $rightToAdd = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$label'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$label'; \$this->rights[\$r][4] = '$objectForPerms'; - \$this->rights[\$r][5] = '$crud'; + \$this->rights[\$r][5] = '$crud'; \$r++; "; $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; @@ -2152,18 +2152,18 @@ if ($dirins && GETPOST('action') == 'update_right' && GETPOST('modifyright')&& e //prepare right want to delete $right = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$x1'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$x1'; \$this->rights[\$r][4] = '$x2'; - \$this->rights[\$r][5] = '$x3'; + \$this->rights[\$r][5] = '$x3'; \$r++; "; // right after editing $rightUpdated = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$label'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$label'; \$this->rights[\$r][4] = '$objectForPerms'; - \$this->rights[\$r][5] = '$crud'; + \$this->rights[\$r][5] = '$crud'; \$r++; "; if (!$error) { @@ -2209,10 +2209,10 @@ if ($dirins && $action == 'confirm_deleteright' && !empty($module) && GETPOST('p $x3 = $permissions[$key][5]; //prepare right want to delete $rightTodelete = " - \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); - \$this->rights[\$r][1] = '$x1'; + \$this->rights[\$r][0] = \$this->numero . sprintf('%02d', \$r + 1); + \$this->rights[\$r][1] = '$x1'; \$this->rights[\$r][4] = '$x2'; - \$this->rights[\$r][5] = '$x3'; + \$this->rights[\$r][5] = '$x3'; \$r++; "; @@ -2286,7 +2286,7 @@ if ($action == 'savefile' && empty($cancel)) { dol_delete_file($pathoffile); $result = file_put_contents($pathoffile, $content); if ($result) { - @chmod($pathoffile, octdec($newmask)); + dolChmod($pathoffile, $newmask); setEventMessages($langs->trans("FileSaved"), null); } else { @@ -2394,19 +2394,19 @@ if ($dirins && $action == 'confirm_deletemenu' && GETPOST('menukey', 'int')) { if ($menus[$key]['type'] == 'top') { $menuTop = " \$this->menu[\$r++] = array( - 'fk_menu'=>'".$menus[$key]['fk_menu']."', - 'type'=>'".$menus[$key]['type']."', + 'fk_menu'=>'".$menus[$key]['fk_menu']."', + 'type'=>'".$menus[$key]['type']."', 'titre'=>'".$menus[$key]['titre']."', 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'), 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu'=> '', 'url'=>'".$menus[$key]['url']."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$menus[$key]['perms']."', 'target'=>'".$menus[$key]['target']."', - 'user'=>".$menus[$key]['user'].", + 'user'=>".$menus[$key]['user'].", );"; $check = dolReplaceInFile($moduledescriptorfile, array($menuTop => '',"\t\t".'/*TOPMENU '.strtolower($menus[$key]['titre']).'*/'."\n" => '', '/*END TOPMENU '.strtolower($menus[$key]['titre']).'*/'."\n\t\t" => '')); } @@ -2579,19 +2579,19 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) { if ($type == 'top') { $menuTop = " \$this->menu[\$r++] = array( - 'fk_menu'=>'".$fk_menu."', - 'type'=>'".strtolower($type)."', + 'fk_menu'=>'".$fk_menu."', + 'type'=>'".strtolower($type)."', 'titre'=>'".ucfirst($titre)."', 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'), 'mainmenu'=>'".$mainmenu."', 'leftmenu'=> '".$leftmenu."', 'url'=>'".$url."', - 'langs'=>'".strtolower($module)."@".strtolower($module)."', + 'langs'=>'".strtolower($module)."@".strtolower($module)."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>".$user.", + 'user'=>".$user.", );"; $addTopMenu = dolReplaceInFile($moduledescriptorfile, array('/* END MODULEBUILDER TOPMENU */' => '/*TOPMENU '.strtolower($titre).'*/'.$menuTop."\n\t\t".'/*END TOPMENU '.strtolower($titre).'*/'."\n\t\t/* END MODULEBUILDER TOPMENU */")); } @@ -2605,7 +2605,7 @@ if ($dirins && $action == 'addmenu' && empty($cancel)) { 'mainmenu'=>'".strtolower($module)."', 'leftmenu'=>'".strtolower($leftmenu)."', 'url'=>'".$url."', - 'langs'=>'".strtolower($module)."@".strtolower($module)."', + 'langs'=>'".strtolower($module)."@".strtolower($module)."', 'position'=>1100+\$r, 'enabled'=>'\$conf->".strtolower($module)."->enabled', 'perms'=>'".$perms."', @@ -2662,12 +2662,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$menus[$key]['url']."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$menus[$key]['perms']."', 'target'=>'".$menus[$key]['target']."', - 'user'=>".$menus[$key]['user'].", + 'user'=>".$menus[$key]['user'].", );"; $fk_menu = GETPOST('fk_type', 'alpha'); @@ -2691,12 +2691,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$url."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'".$menus[$key]['enabled']."', + 'enabled'=>'".$menus[$key]['enabled']."', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>".$user.", + 'user'=>".$user.", );"; @@ -2716,12 +2716,12 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && empty(GE 'mainmenu'=>'".$menus[$key]['mainmenu']."', 'leftmenu' =>'".$menus[$key]['leftmenu']."', 'url' =>'".$url."', - 'langs'=>'".$menus[$key]['langs']."', + 'langs'=>'".$menus[$key]['langs']."', 'position'=>1000 + \$r, - 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', + 'enabled'=>'isModEnabled(\"".strtolower($module)."\")', 'perms' =>'".$perms."', 'target'=>'".$target."', - 'user'=>'".$user."', + 'user'=>'".$user."', );"; dolReplaceInFile($moduledescriptorfile, array($menuTomodify => $modifiedMenu)); diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index f89360e8774..bcd437ad21d 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -498,9 +498,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index b78a2a5f4d7..66d0ae14d58 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -783,13 +783,11 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index e2b6c5129ff..c32e789d429 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -366,10 +366,7 @@ class ProjectStats extends Stats if ($fp) { fwrite($fp, json_encode($data)); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; - } - @chmod($newpathofdestfile, octdec($newmask)); + dolChmod($newpathofdestfile); } else { dol_syslog("Failed to write cache file", LOG_ERR); } @@ -479,12 +476,11 @@ class ProjectStats extends Stats dol_mkdir($conf->user->dir_temp); } $fp = fopen($newpathofdestfile, 'w'); - fwrite($fp, json_encode($data)); - fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - $newmask = $conf->global->MAIN_UMASK; + if ($fp) { + fwrite($fp, json_encode($data)); + fclose($fp); + dolChmod($newpathofdestfile); } - @chmod($newpathofdestfile, octdec($newmask)); $this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt; } diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 147e8ec3519..a415cb5c940 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -482,9 +482,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); $odfHandler = null; // Destroy object diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 61c2eb3ff20..a0747f13f45 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -710,13 +710,11 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $this->errors = $hookmanager->errors; } - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($file, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($file); - $this->result = array('fullpath'=>$file); + $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 92a2b8f6b45..28eb11dde90 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1132,9 +1132,7 @@ class Website extends CommonObject fputs($fp, $line); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($filesql, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($filesql); // Build zip file $filedir = $conf->website->dir_temp.'/'.$website->ref.'/.'; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index adccc80e14c..83d675f4394 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -939,8 +939,7 @@ if ($action == 'addcontainer' && $usercanedit) { $fp = fopen($filetosave, "w"); fputs($fp, $tmpgeturl['content']); fclose($fp); - if (!empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + dolChmod($file); } */ @@ -1008,8 +1007,7 @@ if ($action == 'addcontainer' && $usercanedit) { //$fp = fopen($filetosave, "w"); //fputs($fp, $tmpgeturl['content']); //fclose($fp); - //if (!empty($conf->global->MAIN_UMASK)) - // @chmod($file, octdec($conf->global->MAIN_UMASK)); + //dolChmod($file); // $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; $pagecsscontent .= '/* Content of file '.$urltograbbis.' */'."\n"; @@ -2659,9 +2657,7 @@ if ($action == 'generatesitemaps' && $usercanedit) { } $domtree->appendChild($root); if ($domtree->save($tempdir.$xmlname)) { - if (!empty($conf->global->MAIN_UMASK)) { - @chmod($tempdir.$xmlname, octdec($conf->global->MAIN_UMASK)); - } + dolChmod($tempdir.$xmlname); setEventMessages($langs->trans("SitemapGenerated", $xmlname), null, 'mesgs'); } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -5022,8 +5018,7 @@ if ((empty($action) || $action == 'preview' || $action == 'createfromclone' || $ print $out; /*file_put_contents($filetpl, $out); - if (!empty($conf->global->MAIN_UMASK)) - @chmod($filetpl, octdec($conf->global->MAIN_UMASK)); + dolChmod($filetpl); // Output file on browser dol_syslog("index.php include $filetpl $filename content-type=$type"); diff --git a/htdocs/website/samples/wrapper.php b/htdocs/website/samples/wrapper.php index 26adb3ef220..9a8a8d5ab48 100644 --- a/htdocs/website/samples/wrapper.php +++ b/htdocs/website/samples/wrapper.php @@ -156,7 +156,7 @@ if ($rss) { // Create temp file $outputfiletmp = tempnam($dir_temp, 'tmp'); // Temporary file (allow call of function by different threads - @chmod($outputfiletmp, octdec($conf->global->MAIN_UMASK)); + dolChmod($outputfiletmp); // Write file $result = build_rssfile($format, $title, $desc, $eventarray, $outputfiletmp, '', $website->virtualhost.'/wrapper.php?rss=1'.($l ? '&l='.$l : ''), $l);