From b0be1ddadb9a39ea998164a6cb22c339a681f231 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 10 Sep 2018 23:20:31 +0200 Subject: [PATCH] Fix files generated --- htdocs/core/lib/website.lib.php | 6 ++---- htdocs/website/class/website.class.php | 7 ++++++- htdocs/website/index.php | 14 +++----------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 8faed7b6560..85d3f1967e9 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -542,9 +542,7 @@ function dolSaveMasterFile($filemaster) if (! empty($conf->global->MAIN_UMASK)) @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); - if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); - - return ($result?true:false); + return $result; } /** @@ -618,7 +616,7 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= '/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/'.$object->ref.'/htmlheader.html")); ?>'."\n"; + $tplcontent.= '/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n"; $tplcontent.= ''."\n"; $tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n"; $tplcontent.= ''."\n"; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 68cf5e8c293..b4b761a7e0b 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -974,6 +974,11 @@ class Website extends CommonObject // Now generate the master.inc.php page $filemaster=$conf->website->dir_output.'/'.$object->ref.'/master.inc.php'; dolSaveMasterFile($filemaster); + if (! $result) + { + $this->errors[]='Failed to write file '.$filemaster; + $error++; + } dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists @@ -999,7 +1004,7 @@ class Website extends CommonObject $runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1); if ($runsql <= 0) { - $this->errors[]='Failed to load sql file '.$sqlfile.'.'; + $this->errors[]='Failed to load sql file '.$sqlfile; $error++; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 6641620ba84..e9d68e03034 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1134,7 +1134,8 @@ if ($action == 'updatemeta') // Now generate the master.inc.php page - dolSaveMasterFile($filemaster); + $result = dolSaveMasterFile($filemaster); + if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); // Now delete the alias.php page if (! empty($fileoldalias)) @@ -1321,16 +1322,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf // Now generate the master.inc.php page - dol_syslog("We regenerate the master file"); - dol_delete_file($filemaster); - - $mastercontent = ''."\n"; - $result = file_put_contents($filemaster, $mastercontent); - if (! empty($conf->global->MAIN_UMASK)) - @chmod($filemaster, octdec($conf->global->MAIN_UMASK)); + $result = dolSaveMasterFile($filemaster); if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');