Skip to content
Snippets Groups Projects
Commit a9436e52 authored by Regis Houssin's avatar Regis Houssin
Browse files

Fix: more compatible with alternative path

Fix: problem with dol_include_once and dol_require_once (blank page)
parent 81342b12
Branches
Tags
No related merge requests found
...@@ -69,6 +69,7 @@ function GETPOST($paramname,$check='',$method=0) ...@@ -69,6 +69,7 @@ function GETPOST($paramname,$check='',$method=0)
*/ */
function dol_include_once($relpath) function dol_include_once($relpath)
{ {
$res=false;
$res=@include_once(DOL_DOCUMENT_ROOT.$relpath); $res=@include_once(DOL_DOCUMENT_ROOT.$relpath);
if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@include_once(DOL_DOCUMENT_ROOT_ALT.$relpath); if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@include_once(DOL_DOCUMENT_ROOT_ALT.$relpath);
return $res; return $res;
...@@ -81,8 +82,13 @@ function dol_include_once($relpath) ...@@ -81,8 +82,13 @@ function dol_include_once($relpath)
*/ */
function dol_require_once($relpath) function dol_require_once($relpath)
{ {
$res=@require_once(DOL_DOCUMENT_ROOT.$relpath); $res=false;
if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@require_once(DOL_DOCUMENT_ROOT_ALT.$relpath);
// Forced to use file_exists otherwise there is a blank page
//$res=@require_once(DOL_DOCUMENT_ROOT.$relpath);
//if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@require_once(DOL_DOCUMENT_ROOT_ALT.$relpath);
$res=@require_once(dol_file_exists($relpath));
return $res; return $res;
} }
...@@ -93,14 +99,13 @@ function dol_require_once($relpath) ...@@ -93,14 +99,13 @@ function dol_require_once($relpath)
*/ */
function dol_file_exists($path,$absolute=0) function dol_file_exists($path,$absolute=0)
{ {
$res=''; $res=false;
if ($absolute) if ($absolute)
{ {
preg_match('/^([^<]+\.php)/i',$path,$regs); preg_match('/^([^<]+\.php)/i',$path,$regs);
$path = (! empty($regs[1]) ? $regs[1] : $path);
$res=DOL_URL_ROOT.$path; $res=DOL_URL_ROOT.$path;
if (defined('DOL_URL_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$path)) $url=DOL_URL_ROOT_ALT.$path; if (defined('DOL_URL_ROOT_ALT') && ! file_exists(DOL_DOCUMENT_ROOT.$regs[1])) $res=DOL_URL_ROOT_ALT.$path;
} }
else else
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment