diff options
author | Robin Appelman <icewind1991@gmail.com> | 2010-06-07 04:18:21 +0400 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2010-06-07 04:18:21 +0400 |
commit | 56dfcce9b97084476b0637a70b468e4e0aa0f75d (patch) | |
tree | 71585fb0d838e63fed1530048d600d3b2d90a39a | |
parent | e4a5ef55fbf2e1e9a608d0c7bbcbe34185e536cc (diff) |
improved detection of WEBROOT
-rwxr-xr-x | inc/lib_base.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/inc/lib_base.php b/inc/lib_base.php index 666e0d6524c..cd622f1f5b6 100755 --- a/inc/lib_base.php +++ b/inc/lib_base.php @@ -35,8 +35,27 @@ session_start(); $SERVERROOT=substr(__FILE__,0,-17); $DOCUMENTROOT=$_SERVER['DOCUMENT_ROOT']; $SERVERROOT=str_replace("\\",'/',$SERVERROOT); -$count=strlen($DOCUMENTROOT); -$WEBROOT=substr($SERVERROOT,$count); +if(strpos($SERVERROOT,$DOCUMENTROOT)===0){ + //if the serverroot is a subdir of the documentroot we can use this + $count=strlen($DOCUMENTROOT); + $WEBROOT=substr($SERVERROOT,$count); +}else{ + //try some common patterns + $WEBROOT=''; + if(strpos($_SERVER['REQUEST_URI'],'/~')!==false){ + //owncloud is probable installed in a users home folder, extract the username from the uri and use it as base for the webroot + $part=substr($_SERVER['REQUEST_URI'],strpos($_SERVER['REQUEST_URI'],'/~')+1); + $part=substr($part,0,strpos($part,'/')); + $WEBROOT.='/'.$part; + } + if(strpos($SERVERROOT,'public_html')!==false){ + //a common used folder name for websevers to store their sites + if($WEBROOT{strlen($WEBROOT)-1}!=='/'){ + $WEBROOT.='/'; + } + $WEBROOT.=substr($SERVERROOT,strpos($SERVERROOT,'public_html')+strlen('public_html')); + } +} if($WEBROOT{0}!=='/' and $WEBROOT!=''){ $WEBROOT='/'.$WEBROOT; } |