diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php index fdd2b19f79a..84436ae7409 100644 --- a/apps/bookmarks/templates/list.php +++ b/apps/bookmarks/templates/list.php @@ -20,7 +20,7 @@
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 8f6c029007f..5f00a884a04 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -12,7 +12,8 @@ diff --git a/lib/app.php b/lib/app.php index 13b6617b23e..5883a29bb02 100755 --- a/lib/app.php +++ b/lib/app.php @@ -328,11 +328,23 @@ class OC_App{ */ public static function getAppPath($appid) { foreach(OC::$APPSROOTS as $dir) { - if(file_exists($dir.'/'.$appid)) { - return $dir.'/'.$appid; + if(file_exists($dir['path'].'/'.$appid)) { + return $dir['path'].'/'.$appid; + } + } + return false; + } + + /** + * Get the path for the given app on the access + * If the app is defined in multiple directory, the first one is taken. (false if not found) + */ + public static function getAppWebPath($appid) { + foreach(OC::$APPSROOTS as $dir) { + if(file_exists($dir['path'].'/'.$appid)) { + return $dir['web'].'/'.$appid; } } -// OC_Log::write('core','Unable to find app "'.$appid.'"',OC_Log::ERROR); return false; } @@ -477,9 +489,9 @@ class OC_App{ public static function getAllApps(){ $apps=array(); foreach(OC::$APPSROOTS as $apps_dir) { - $dh=opendir($apps_dir); + $dh=opendir($apps_dir['path']); while($file=readdir($dh)){ - if(substr($file,0,1)!='.' and is_file($apps_dir.'/'.$file.'/appinfo/app.php')){ + if(substr($file,0,1)!='.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')){ $apps[]=$file; } } diff --git a/lib/base.php b/lib/base.php index b494bbcabc5..131485961ad 100644 --- a/lib/base.php +++ b/lib/base.php @@ -55,13 +55,9 @@ class OC{ */ public static $THIRDPARTYWEBROOT = ''; /** - * The installation path of the apps folder on the server (e.g. /srv/http/owncloud) + * The installation path array of the apps folder on the server (e.g. /srv/http/owncloud) 'real' and web path in 'web' */ public static $APPSROOTS = array(); - /** - * the root path of the apps folder for http requests (e.g. owncloud) - */ - public static $APPSWEBROOT = ''; /* * requested app */ @@ -168,27 +164,31 @@ class OC{ // search the apps folder if(OC_Config::getValue('appsroot', '')<>''){ - OC::$APPSROOTS=explode(':',OC_Config::getValue('appsroot', '')); - OC::$APPSWEBROOT=OC_Config::getValue('appsurl', ''); - }elseif(file_exists(OC::$SERVERROOT.'/apps')){ - OC::$APPSROOTS= array(OC::$SERVERROOT.'/apps'); - OC::$APPSWEBROOT=OC::$WEBROOT; - } - if(file_exists(OC::$SERVERROOT.'/../apps')){ - OC::$APPSROOTS[] = rtrim(realpath(OC::$SERVERROOT.'/../apps'), '/'); -// OC::$APPSWEBROOT=rtrim(dirname(OC::$WEBROOT), '/'); + $real_a = explode(':',OC_Config::getValue('appsroot', '')); + $web_a = explode(':',OC_Config::getValue('appsurl', '')); + foreach($real_a as $k => $path) { + if(!isset($web_a[$k])){ + echo("Apps root and appsurl not mathing. You need to have the same number of paths"); + exit; + } + OC::$APPSROOTS[] = array('path'=> $path, 'web' => $web_a[$k]); + } } + if(empty(OC::$APPSROOTS)){ echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file."); exit; } + $paths = array(); + foreach( OC::$APPSROOTS as $path) + $paths[] = $path['path']; // set the right include path set_include_path( OC::$SERVERROOT.'/lib'.PATH_SEPARATOR. OC::$SERVERROOT.'/config'.PATH_SEPARATOR. OC::$THIRDPARTYROOT.'/3rdparty'.PATH_SEPARATOR. - implode(OC::$APPSROOTS,PATH_SEPARATOR).PATH_SEPARATOR. + implode($paths,PATH_SEPARATOR).PATH_SEPARATOR. get_include_path().PATH_SEPARATOR. OC::$SERVERROOT ); @@ -292,6 +292,7 @@ class OC{ require_once(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE); } }else{ + die(); header('HTTP/1.0 404 Not Found'); exit; } diff --git a/lib/helper.php b/lib/helper.php index 72ae98222d9..550bf9771e4 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -48,7 +48,7 @@ class OC_Helper { $urlLinkTo = OC::$WEBROOT . '/?app=' . $app; $urlLinkTo .= ($file!='index.php')?'&getfile=' . urlencode($file):''; }else{ - $urlLinkTo = OC::$APPSWEBROOT . '/apps/' . $app . $file; + $urlLinkTo = OC_App::getAppWebPath($app) . $file; } } else{ @@ -151,7 +151,7 @@ class OC_Helper { if( file_exists( OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image" )){ return OC::$WEBROOT."/themes/$theme/apps/$app/img/$image"; }elseif( file_exists(OC_App::getAppPath($app)."/img/$image" )){ - return OC::$APPSWEBROOT."/apps/$app/img/$image"; + return OC_App::getAppWebPath($app)."/img/$image"; }elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/themes/$theme/$app/img/$image" )){ return OC::$WEBROOT."/themes/$theme/$app/img/$image"; }elseif( !empty( $app ) and file_exists( OC::$SERVERROOT."/$app/img/$image" )){ diff --git a/lib/template.php b/lib/template.php index a354d58a4b1..e6525ec6336 100644 --- a/lib/template.php +++ b/lib/template.php @@ -415,8 +415,8 @@ class OC_Template{ $append = false; foreach( OC::$APPSROOTS as $apps_dir) { - if($page->appendIfExist('jsfiles', $apps_dir, OC::$APPSWEBROOT.'/apps/', "$script$fext.js" , true)) { $append =true; break; } - elseif($page->appendIfExist('jsfiles', $apps_dir, OC::$APPSWEBROOT.'/apps/', "$script.js", true )) { $append =true; break; } + if($page->appendIfExist('jsfiles', $apps_dir['path'], $apps_dir['web'], "$script$fext.js" , true)) { $append =true; break; } + elseif($page->appendIfExist('jsfiles', $apps_dir['path'], $apps_dir['web'], "$script.js", true )) { $append =true; break; } } if(! $append) { echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); @@ -443,8 +443,8 @@ class OC_Template{ $append = false; foreach( OC::$APPSROOTS as $apps_dir) { - if($page->appendIfExist('cssfiles', $apps_dir, OC::$APPSWEBROOT, "$style$fext.css", true)) { $append =true; break; } - elseif($page->appendIfExist('cssfiles', $apps_dir, OC::$APPSWEBROOT, "$style.css", true )) { $append =true; break; } + if($page->appendIfExist('cssfiles', $apps_dir['path'], $apps_dir['web'], "$style$fext.css", true)) { $append =true; break; } + elseif($page->appendIfExist('cssfiles', $apps_dir['path'], $apps_dir['web'], "$style.css", true )) { $append =true; break; } } if(! $append) { echo('css file not found: style:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);