Autodetect url relative path
This commit is contained in:
parent
cadb0c66e0
commit
c4d7e87e2c
@ -128,34 +128,20 @@ if (1 == 1) // Use auto forge url.
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* print $dolibarr_main_document_root.'-'.$_SERVER["DOCUMENT_ROOT"].'<br>';
|
$real_dolibarr_main_document_root=str_replace('\\','/',realpath($dolibarr_main_document_root));
|
||||||
print realpath($dolibarr_main_document_root).'-'.realpath($_SERVER["DOCUMENT_ROOT"]).'<br>';
|
|
||||||
$tmp1=realpath($dolibarr_main_document_root);
|
|
||||||
$tmp2=realpath($_SERVER["DOCUMENT_ROOT"]);
|
|
||||||
$pos=strpos($tmp1,$tmp2);
|
|
||||||
if ($pos !== false && $pos == 0)
|
|
||||||
{
|
|
||||||
$tmp3=str_replace($tmp2,'',$tmp1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*/
|
|
||||||
$paths=explode('/',str_replace('\\','/',$_SERVER["SCRIPT_NAME"]));
|
$paths=explode('/',str_replace('\\','/',$_SERVER["SCRIPT_NAME"]));
|
||||||
$concatpath='';
|
$concatpath='';
|
||||||
foreach($paths as $path)
|
foreach($paths as $path)
|
||||||
{
|
{
|
||||||
//if (empty($path)) continue;
|
|
||||||
if ($path) $concatpath.='/'.$path;
|
if ($path) $concatpath.='/'.$path;
|
||||||
print realpath($dolibarr_main_document_root).'-'.realpath($_SERVER["DOCUMENT_ROOT"].$concatpath).'<br>';
|
//print $real_$dolibarr_main_document_root.'-'.realpath($_SERVER["DOCUMENT_ROOT"].$concatpath).'<br>';
|
||||||
$pos=strpos(realpath($dolibarr_main_document_root),realpath($_SERVER["DOCUMENT_ROOT"].$concatpath));
|
if ($real_dolibarr_main_document_root == realpath($_SERVER["DOCUMENT_ROOT"].$concatpath))
|
||||||
if ($pos !== false && $pos == 0) // We found relative url
|
|
||||||
{
|
{
|
||||||
$tmp3=$concatpath;
|
$tmp3=$concatpath;
|
||||||
print "Found relative url = ".$tmp3;
|
//print "Found relative url = ".$tmp3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
$tmp='http'.((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on')?'':'s').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]==80)?'':':'.$_SERVER["SERVER_PORT"]).($tmp3?(preg_match('/^\//',$tmp3)?'':'/').$tmp3:'');
|
$tmp='http'.((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on')?'':'s').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"])||$_SERVER["SERVER_PORT"]==80)?'':':'.$_SERVER["SERVER_PORT"]).($tmp3?(preg_match('/^\//',$tmp3)?'':'/').$tmp3:'');
|
||||||
//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp;
|
//print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user