fix webroot when using symlinks

This commit is contained in:
Robin Appelman 2010-06-27 18:09:59 +02:00
parent a0088cfea6
commit 0ba0f22627
1 changed files with 3 additions and 2 deletions

View File

@ -33,11 +33,12 @@ session_start();
// calculate the documentroot // calculate the documentroot
$SERVERROOT=substr(__FILE__,0,-17); $SERVERROOT=substr(__FILE__,0,-17);
$DOCUMENTROOT=$_SERVER['DOCUMENT_ROOT']; $DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']);
$SERVERROOT=str_replace("\\",'/',$SERVERROOT); $SERVERROOT=str_replace("\\",'/',$SERVERROOT);
$SUBURI=substr($_SERVER["SCRIPT_FILENAME"],strlen($SERVERROOT)); $SUBURI=substr(realpath($_SERVER["SCRIPT_FILENAME"]),strlen($SERVERROOT));
$WEBROOT=substr($_SERVER["SCRIPT_NAME"],0,strlen($_SERVER["SCRIPT_NAME"])-strlen($SUBURI)); $WEBROOT=substr($_SERVER["SCRIPT_NAME"],0,strlen($_SERVER["SCRIPT_NAME"])-strlen($SUBURI));
if($WEBROOT!='' and $WEBROOT[0]!=='/'){ if($WEBROOT!='' and $WEBROOT[0]!=='/'){
$WEBROOT='/'.$WEBROOT; $WEBROOT='/'.$WEBROOT;
} }