From 6b47b63e611cb9371326fc3163b0ecb476879283 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Sep 2018 13:23:41 +0200 Subject: [PATCH 1/3] Code comment --- htdocs/societe/paymentmodes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index a98d81aae19..b269e4b39b5 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1023,8 +1023,10 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print ''; print $langs->trans("Remote"); + //if ($src->cvc_check == 'fail') print ' - CVC check fail'; print ''; print ''; + //var_dump($src); print ''; print ''; print ''; From d86ebad0060273b37fd91f508cccfc0378505550 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Sep 2018 13:28:24 +0200 Subject: [PATCH 2/3] Update doc --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index a834ef3e56a..da1efec9138 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,13 @@ For developers: * Code changes to be more compatible with PSR2 * Removed trigger USER_LOGOUT, USER_LOGIN, USER_LOGIN_FAILED (Some hooks are already dedicated for that) +WARNING: + +Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: +* If you use some links like viewimages.php?modulepart=mycompany&file=... in you external modules, you must + relace them with links like viewimages.php?modulepart=mycompany&file=logos/... (note that link change only for + modulepart=mycompany that now works like others). + ***** ChangeLog for 8.0.1 compared to 8.0.0 ***** From 5719a38ea79208ded5ea4b46be8c774f8fdcbae1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 9 Sep 2018 14:05:23 +0200 Subject: [PATCH 3/3] Work on website module. Support now links to company logos. --- htdocs/core/lib/website.lib.php | 40 ++++++++++++++++++++++++--------- htdocs/website/index.php | 5 +++-- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index e59ac551eb3..38a35d98088 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -150,11 +150,13 @@ function dolWebsiteOutput($content) $nbrep=0; if (! $symlinktomediaexists) { - $content=preg_replace('/(]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\document.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); + $content=preg_replace('/(]*src=")[^\"]*document\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); - $content=preg_replace('/(]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); - $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); - $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1/viewimage.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); + $content=preg_replace('/(]*href=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); + $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=medias([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); + $content=preg_replace('/(url\(["\']?)[^\)]*viewimage\.php([^\)]*)modulepart=medias([^\)]*)file=([^\)]*)(["\']?\))/', '\1/wrapper.php\2modulepart=medias\3file=\4\5', $content, -1, $nbrep); + + $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); } else { @@ -163,6 +165,8 @@ function dolWebsiteOutput($content) $content=preg_replace('/(]*href=")[^\"]*viewimage\.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); + + $content=preg_replace('/(]*src=")[^\"]*viewimage\.php([^\"]*)modulepart=mycompany([^\"]*)file=([^\"]*)("[^>]*>)/', '\1/wrapper.php\2modulepart=mycompany\3file=\4\5', $content, -1, $nbrep); } } @@ -612,22 +616,24 @@ function dolSavePageContent($filetpl, $object, $objectpage) /** - * Save content of the index.php page + * Save content of the index.php and wrapper.php page * * @param string $pathofwebsite Path of website root * @param string $fileindex Full path of file index.php * @param string $filetpl File tpl to index.php page redirect to + * @param string $fileindex Full path of file wrapper.php * @return boolean True if OK */ -function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl) +function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper) { global $conf; - $result=0; + $result1=false; + $result2=false; dol_mkdir($pathofwebsite); - dol_delete_file($fileindex); + dol_delete_file($fileindex); $indexcontent = ''."\n"; - $result = file_put_contents($fileindex, $indexcontent); + $result1 = file_put_contents($fileindex, $indexcontent); if (! empty($conf->global->MAIN_UMASK)) @chmod($fileindex, octdec($conf->global->MAIN_UMASK)); - return $result; + dol_delete_file($filewrapper); + $wrappercontent = 'mycompany->dir_output."/".$original_file));'."\n"; + $wrappercontent.= "else print 'Bad value for modulepart or file';\n"; + $wrappercontent.= 'if (is_object($db)) $db->close();'."\n"; + $wrappercontent.= '// END PHP ?>'."\n"; + $result2 = file_put_contents($filewrapper, $wrappercontent); + if (! empty($conf->global->MAIN_UMASK)) + @chmod($filewrapper, octdec($conf->global->MAIN_UMASK)); + + return ($result1 && $result2); } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 812ad8a891e..354de8807f5 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2016-2018 Laurent Destailleur * * 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 @@ -140,6 +140,7 @@ $filerobot=$pathofwebsite.'/robots.txt'; $filehtaccess=$pathofwebsite.'/.htaccess'; $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; +$filewrapper=$pathofwebsite.'/wrapper.php'; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); @@ -981,7 +982,7 @@ if ($action == 'setashome') // Generate the index.php page to be the home page //------------------------------------------------- - $result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl); + $result = dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper); if ($result) setEventMessages($langs->trans("Saved"), null, 'mesgs'); else setEventMessages('Failed to write file '.$fileindex, null, 'errors');