Fix: more compatible with alternative path

Fix: problem with dol_include_once and dol_require_once (blank page)
This commit is contained in:
Regis Houssin
2010-12-19 17:38:29 +00:00
parent 81342b1287
commit a9436e521b

View File

@@ -69,6 +69,7 @@ function GETPOST($paramname,$check='',$method=0)
*/
function dol_include_once($relpath)
{
$res=false;
$res=@include_once(DOL_DOCUMENT_ROOT.$relpath);
if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@include_once(DOL_DOCUMENT_ROOT_ALT.$relpath);
return $res;
@@ -81,8 +82,13 @@ function dol_include_once($relpath)
*/
function dol_require_once($relpath)
{
$res=@require_once(DOL_DOCUMENT_ROOT.$relpath);
if (! $res && defined('DOL_DOCUMENT_ROOT_ALT')) $res=@require_once(DOL_DOCUMENT_ROOT_ALT.$relpath);
$res=false;
// 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;
}
@@ -93,14 +99,13 @@ function dol_require_once($relpath)
*/
function dol_file_exists($path,$absolute=0)
{
$res='';
$res=false;
if ($absolute)
{
preg_match('/^([^<]+\.php)/i',$path,$regs);
$path = (! empty($regs[1]) ? $regs[1] : $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
{