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 ***** diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 7bc968457f9..f7242ee43bc 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -50,6 +50,7 @@ $error=0; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admincompany','globaladmin')); + /* * Actions */ @@ -397,7 +398,7 @@ if ($action == 'edit' || $action == 'updateedit') print ''.img_delete($langs->trans("Delete")).''; if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { print '   '; - print ''; + print ''; } } else { print ''; @@ -791,7 +792,7 @@ else } else if ($mysoc->logo_mini && is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { - print ''; + print ''; } else { diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 4cb5a907927..1f2fdd26e5f 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -413,7 +413,7 @@ if ($action == 'edit') // Edit print ''.img_delete($langs->trans("Delete")).''; if (file_exists($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) { print '   '; - print ''; + print ''; } } else { print ''; @@ -561,7 +561,7 @@ else // Show print $conf->global->MAIN_LOGIN_BACKGROUND; if ($conf->global->MAIN_LOGIN_BACKGROUND && is_file($conf->mycompany->dir_output.'/logos/'.$conf->global->MAIN_LOGIN_BACKGROUND)) { - print ''; + print ''; } else { diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 24b94562915..de0324a97fe 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -63,7 +63,7 @@ top_htmlhead('','',0,0,'',$arrayofcss); logo_small)) { - print 'Logo company'; + print 'Logo company'; } else { diff --git a/htdocs/cashdesk/tpl/ticket.tpl.php b/htdocs/cashdesk/tpl/ticket.tpl.php index 3937c9dbde3..0d4a484b66e 100644 --- a/htdocs/cashdesk/tpl/ticket.tpl.php +++ b/htdocs/cashdesk/tpl/ticket.tpl.php @@ -47,7 +47,7 @@ $object->fetch($facid);

name; ?>
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 472ecbb40e5..432c857850b 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2161,10 +2161,10 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file=$dirins.'/'.$original_file; } // Wrapping for some images - elseif (($modulepart == 'mycompany' || $modulepart == 'companylogo') && !empty($conf->mycompany->dir_output)) + elseif ($modulepart == 'mycompany' && !empty($conf->mycompany->dir_output)) { $accessallowed=1; - $original_file=$conf->mycompany->dir_output.'/logos/'.$original_file; + $original_file=$conf->mycompany->dir_output.'/'.$original_file; } // Wrapping for users photos elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output)) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 73bb51d464a..235421a598e 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -662,6 +662,7 @@ function accessforbidden($message='',$printheader=1,$printfooter=1,$showonlymess { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; $langs=new Translate('',$conf); + $langs->setDefaultLang(); } $langs->load("errors"); diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index a23661f2f02..8c8bb3cbb10 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -228,11 +228,11 @@ if (! function_exists('dol_loginfunction')) if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('thumbs/'.$mysoc->logo_small); + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_small); } elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($mysoc->logo); + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/'.$mysoc->logo); $width=128; } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png')) diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 19e8cb3002f..e6ce5c1bddd 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -160,9 +160,9 @@ function llxHeaderTicket($title, $head = "", $disablejs = 0, $disablehead = 0, $ $urllogo = DOL_URL_ROOT . '/theme/login_logo.png'; if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) { - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('thumbs/' . $mysoc->logo_small); + $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/thumbs/'.$mysoc->logo_small); } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) { - $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode($mysoc->logo); + $urllogo = DOL_URL_ROOT . '/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file=' . urlencode('logos/'.$mysoc->logo); $width = 128; } elseif (is_readable(DOL_DOCUMENT_ROOT . '/theme/dolibarr_logo.png')) { $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png'; diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index e59ac551eb3..1957f2c820d 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); } } @@ -516,6 +520,31 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify +/** + * Save content of a page on disk + * + * @param string $filemaster Full path of filename master.inc.php for website to generate + * @return boolean True if OK + */ +function dolSaveMasterFile($filemaster) +{ + global $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)); + + return $result; +} + /** * Save content of a page on disk * @@ -541,7 +570,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) if (! empty($conf->global->MAIN_UMASK)) @chmod($filealias, octdec($conf->global->MAIN_UMASK)); - return ($result?true:false); + return ($result?true:false); } @@ -585,9 +614,9 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $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"; @@ -612,22 +641,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/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index fee6ae6c595..9878d8a2ca8 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -273,7 +273,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('thumbs/'.$mysoc->logo_mini); + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); } else { @@ -517,7 +517,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM $tmp=explode('?',$menu_array[$i]['url'],2); $url = $shorturl = $tmp[0]; $param = (isset($tmp[1])?$tmp[1]:''); // params in url of the menu link - + // Complete param to force leftmenu to '' to close open menu when we click on a link with no leftmenu defined. if ((! preg_match('/mainmenu/i',$param)) && (! preg_match('/leftmenu/i',$param)) && ! empty($menu_array[$i]['mainmenu'])) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0186b90cc16..4c42d22280e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -469,7 +469,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('thumbs/'.$mysoc->logo_mini); + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); } else { diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 9fa50850ffc..d53012191af 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -67,7 +67,7 @@ $colorbackhmenu1=join(',',colorStringToArray($colorbackhmenu1)); // Normalize ?> -global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> +global->MAIN_LOGIN_BACKGROUND)?'':' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file='.urlencode('logos/'.$conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>> dol_use_jmobile)) { ?> -