diff --git a/htdocs/public/websites/index.php b/htdocs/public/websites/index.php
index 4625bc1573a..8c83a1daebc 100644
--- a/htdocs/public/websites/index.php
+++ b/htdocs/public/websites/index.php
@@ -17,8 +17,8 @@
/**
* \file htdocs/public/websites/index.php
- * \ingroup core
- * \brief A redirect page to an error
+ * \ingroup website
+ * \brief Page to output pages
* \author Laurent Destailleur
*/
@@ -90,14 +90,14 @@ if (empty($pageid))
// Security: Delete string ../ into $original_file
global $dolibarr_main_data_root;
-if ($pageid == 'css')
+if ($pageid == 'css') // No more used ?
{
header('Content-type: text/css');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
//if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
//else
header('Cache-Control: no-cache');
- $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css';
+ $original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php';
}
else
{
@@ -142,7 +142,11 @@ if (! file_exists($original_file_osencoded))
exit;
}
+
+// Output page content
+print "\n".''."\n";
include_once $original_file_osencoded;
+
if (is_object($db)) $db->close();
diff --git a/htdocs/public/websites/styles.css.php b/htdocs/public/websites/styles.css.php
new file mode 100644
index 00000000000..5a736affc25
--- /dev/null
+++ b/htdocs/public/websites/styles.css.php
@@ -0,0 +1,139 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
';
+
+if (empty($pageid))
+{
+ require_once DOL_DOCUMENT_ROOT.'/websites/class/website.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/websites/class/websitepage.class.php';
+
+ $object=new Website($db);
+ $object->fetch(0, $website);
+
+ $objectpage=new WebsitePage($db);
+ $array=$objectpage->fetchAll($object->id);
+
+ if (count($array) > 0)
+ {
+ $firstrep=reset($array);
+ $pageid=$firstrep->id;
+ }
+}
+if (empty($pageid))
+{
+ $langs->load("website");
+ print $langs->trans("PreviewOfSiteNotYetAvailable");
+ exit;
+}
+
+// Security: Delete string ../ into $original_file
+global $dolibarr_main_data_root;
+
+$original_file=$dolibarr_main_data_root.'/websites/'.$website.'/styles.css.php';
+
+// Find the subdirectory name as the reference
+$refname=basename(dirname($original_file)."/");
+
+// Security:
+// Limite acces si droits non corrects
+if (! $accessallowed)
+{
+ accessforbidden();
+}
+
+// Security:
+// On interdit les remontees de repertoire ainsi que les pipe dans
+// les noms de fichiers.
+if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
+{
+ dol_syslog("Refused to deliver file ".$original_file);
+ $file=basename($original_file); // Do no show plain path of original_file in shown error message
+ dol_print_error(0,$langs->trans("ErrorFileNameInvalid",$file));
+ exit;
+}
+
+clearstatcache();
+
+$filename = basename($original_file);
+
+// Output file on browser
+dol_syslog("styles.css.php include $original_file $filename content-type=$type");
+$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
+
+// This test if file exists should be useless. We keep it to find bug more easily
+if (! file_exists($original_file_osencoded))
+{
+ $langs->load("website");
+ print $langs->trans("RequestedPageHasNoContentYet", $pageid);
+ //dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
+ exit;
+}
+
+
+// Output page content
+require_once $original_file_osencoded;
+
+
+if (is_object($db)) $db->close();
+
diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php
index 19f72486c3f..8fdd09c30ae 100644
--- a/htdocs/websites/index.php
+++ b/htdocs/websites/index.php
@@ -123,7 +123,7 @@ if ($pageid > 0 && $action != 'add')
global $dolibarr_main_data_root;
$pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website;
-$filecss=$pathofwebsite.'/styles.css';
+$filecss=$pathofwebsite.'/styles.css.php';
$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
// Define $urlwithroot
@@ -276,7 +276,10 @@ if ($action == 'updatecss')
$db->rollback();
}*/
- $csscontent = GETPOST('WEBSITE_CSS_INLINE');
+ $csscontent ='"."\n";
+ $csscontent .= GETPOST('WEBSITE_CSS_INLINE');
dol_mkdir($pathofwebsite);
file_put_contents($filecss, $csscontent);
@@ -379,15 +382,26 @@ if ($action == 'updatecontent')
if (! $error)
{
$db->commit();
- setEventMessages($langs->trans("Saved"), null, 'mesgs');
+ // Now create the .tpl file
dol_mkdir($pathofwebsite);
dol_delete_file($filetpl);
- file_put_contents($filetpl, $objectpage->content);
+
+ $tplcontent = ''."\n";
+ $tplcontent.= '