Debug v21

This commit is contained in:
Laurent Destailleur (aka Eldy) 2024-12-31 14:04:14 +01:00
parent ed1b28ad21
commit f67fad1105
3 changed files with 40 additions and 7 deletions

View file

@ -1672,7 +1672,12 @@ function dol_sanitizePathName($str, $newstr = '_', $unaccent = 1)
// Char '>' '<' '|' '$' and ';' are special chars for shells.
// Chars '--' can be used into filename to inject special parameters like --use-compress-program to make command with file as parameter making remote execution of command
$filesystem_forbidden_chars = array('<', '>', '?', '*', '|', '"', '°', '$', ';', '`');
$tmp = dol_string_nospecial($unaccent ? dol_string_unaccent($str) : $str, $newstr, $filesystem_forbidden_chars);
$tmp = $str;
if ($unaccent) {
$tmp = dol_string_unaccent($tmp);
}
$tmp = dol_string_nospecial($tmp, $newstr, $filesystem_forbidden_chars);
$tmp = preg_replace('/\-\-+/', '_', $tmp);
$tmp = preg_replace('/\s+\-([^\s])/', ' _$1', $tmp);
$tmp = preg_replace('/\s+\-$/', '', $tmp);
@ -7948,6 +7953,8 @@ function dol_mkdir($dir, $dataroot = '', $newmask = '')
dol_syslog("functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
$dir = dol_sanitizePathName($dir, '_', 0);
$dir_osencoded = dol_osencode($dir);
if (@is_dir($dir_osencoded)) {
return 0;

View file

@ -250,10 +250,25 @@ class Website extends CommonObject
}
}
// Create subdirectory for images and js
// Create subdirectory for images and js into documents/medias directory
dol_mkdir($conf->medias->multidir_output[$conf->entity].'/image/'.$this->ref, DOL_DATA_ROOT);
dol_mkdir($conf->medias->multidir_output[$conf->entity].'/js/'.$this->ref, DOL_DATA_ROOT);
$pathofwebsite = $conf->website->dir_output.'/'.$this->ref;
// Check symlink documents/website/mywebsite/medias to point to documents/medias and restore it if ko.
// Recreate also dir of website if not found.
$pathtomedias = DOL_DATA_ROOT.'/medias';
$pathtomediasinwebsite = $pathofwebsite.'/medias';
if (!is_link(dol_osencode($pathtomediasinwebsite))) {
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure that the directory for website exists
$result = symlink($pathtomedias, $pathtomediasinwebsite);
if (!$result) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors');
}
}
// Uncomment this and change WEBSITE to your own tag if you
// want this action to call a trigger.
// if (!$notrigger) {

View file

@ -1325,13 +1325,18 @@ if ($action == 'addcontainer' && $usercanedit) {
// To generate the CSS, robot and htmlheader file.
// Check symlink to medias and restore it if ko
// Check symlink documents/website/mywebsite/medias to point to documents/medias and restore it if ko.
// Recreate also dir of website if not found.
$pathtomedias = DOL_DATA_ROOT.'/medias';
$pathtomediasinwebsite = $pathofwebsite.'/medias';
if (!is_link(dol_osencode($pathtomediasinwebsite))) {
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure that the directory for website exists
$result = symlink($pathtomedias, $pathtomediasinwebsite);
if (!$result) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors');
}
}
// Now generate the master.inc.php page if it does not exists yet
@ -2296,13 +2301,18 @@ if ((($action == 'updatesource' || $action == 'updatecontent' || $action == 'con
$res = 0;
if (!$error) {
// Check symlink to medias and restore it if ko
// Check symlink documents/website/mywebsite/medias to point to documents/medias and restore it if ko.
// Recreate also dir of website if not found.
$pathtomedias = DOL_DATA_ROOT.'/medias';
$pathtomediasinwebsite = $pathofwebsite.'/medias';
if (!is_link(dol_osencode($pathtomediasinwebsite))) {
dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite);
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists
dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure that the directory for website exists
$result = symlink($pathtomedias, $pathtomediasinwebsite);
if (!$result) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFailedToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors');
}
}
/*if (GETPOST('savevirtualhost') && $object->virtualhost != GETPOST('previewsite'))
@ -2537,7 +2547,8 @@ if ($action == 'importsiteconfirm' && $usercanedit) {
$action = 'importsite';
} else {
if (!empty($_FILES) || GETPOSTISSET('templateuserfile')) {
// Check symlink to medias and restore it if ko. Recreate also dir of website if not found.
// Check symlink documents/website/mywebsite/medias to point to documents/medias and restore it if ko.
// Recreate also dir of website if not found.
$pathtomedias = DOL_DATA_ROOT.'/medias';
$pathtomediasinwebsite = $pathofwebsite.'/medias';
if (!is_link(dol_osencode($pathtomediasinwebsite))) {