From ca14dd790b8e5e1cb0b41be27537c8875b8bb153 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Jan 2018 22:58:37 +0100 Subject: [PATCH] Fix module website --- htdocs/core/lib/website.lib.php | 3 +++ htdocs/document.php | 17 ++++++++++++++++- htdocs/public/website/index.php | 3 +-- htdocs/website/index.php | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 197e050f48a..bbe9a0fecad 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -93,6 +93,8 @@ function dolWebsiteOutput($content) // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart=" $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); + $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); + // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart=" $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); @@ -118,6 +120,7 @@ function dolWebsiteOutput($content) } else { + $content=preg_replace('/(]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep); $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^\/]*\/?>)/', '\1medias/\4\5', $content, -1, $nbrep); $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1medias/\4\5', $content, -1, $nbrep); } diff --git a/htdocs/document.php b/htdocs/document.php index db9f4bdb41e..1c722e4cb55 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -30,7 +30,16 @@ * document.php?modulepart=logs&hashp=sharekey */ -define('NOTOKENRENEWAL',1); // Disables token renewal +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +//if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks // For bittorent link, we don't need to load/check we are into a login session if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'bittorrent' && ! defined("NOLOGIN")) { @@ -43,6 +52,12 @@ if (isset($_GET["hashp"]) && ! defined("NOLOGIN")) define("NOLOGIN",1); define("NOCSRFCHECK",1); // We accept to go on this page from external web site. } +// Some value of modulepart can be used to get resources that are public so no login are required. +if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias') && ! defined("NOLOGIN")) +{ + define("NOLOGIN",1); + define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +} if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); diff --git a/htdocs/public/website/index.php b/htdocs/public/website/index.php index 0772965c5e6..0558268913d 100644 --- a/htdocs/public/website/index.php +++ b/htdocs/public/website/index.php @@ -191,8 +191,7 @@ if (! file_exists($original_file_osencoded)) // Output page content define('USEDOLIBARRSERVER', 1); print ''."\n"; -include_once $original_file_osencoded; - +include_once $original_file_osencoded; // Note: The pageXXX.tpl.php showed here contains a formatage with dolWebsiteOutput() at end of page. if (is_object($db)) $db->close(); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 509acd837f5..7d27badbc83 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -150,7 +150,7 @@ $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; - +$htmlheadercontentdefault.=''."\n"; /*