GerHobbelt / mootools-filemanager

A filemanager for the web based on MooTools that allows you to (pre)view, upload and modify files and folders via the browser.
http://cpojer.net/blog/MooTools_based_FileManager
Other
4 stars 1 forks source link

Suggestion about documentRootPath & directory ... #23

Open partikule opened 13 years ago

partikule commented 13 years ago

Let's take concreet example to illustrate the problem :

Case 1 : Web site's URL : http://www.mydomain.com Web site's root dir : /Users/mydomain/ MTFM File's root dir : /Users/mydomain/files/

Filemanager option array : 'documentRootPath' => null, 'directory' => 'files'

Result : Everything's fine : documentRootPath and directory is well calculated by the Filemanager

Case 2 : Web site's URL : http://mysubdomain.mydomain.com Web site's root dir : /Users/mydomain/mysubdomain/ MTFM File's root dir : /Users/mydomain/mysubdomain/files/

Filemanager option array : 'documentRootPath' => null, 'directory' => 'files'

Result Not good : documentRootPath : /Users/mydomain/files/

Case 3 (should be the default behavior) : Web site's URL : http://www.mydomain.com Web site's root dir : /Users/mydomain/ MTFM File's root dir : /Users/mydomain/files/

Filemanager option array : 'documentRootPath' => '/Users/mydomain/', 'directory' => 'files'

Result Not good : documentRootPath : /Users/mydomain/Users/mydomain/files/

Suggestion : In the current behavior, the Filemanager lib calculates too much the root path and the base URL of files. Only 1 base URL and 1 basepath should be send to the FM at initialization, so the FM work with them and doesn't need to try to found the base URL / PATH :

Example : $param = array( basePath => '/Users/mydomain/', baseURL => 'http://www.mydomain.com/', directory => 'files/' );

Simple and efficient.

GerHobbelt commented 13 years ago

On Tue, May 3, 2011 at 7:25 PM, partikule < reply@reply.github.com>wrote:

Let's take concreet example to illustrate the problem :

Case 1 : Web site's URL : http://www.mydomain.com Web site's root dir : /Users/mydomain/ MTFM File's root dir : /Users/mydomain/files/

Filemanager option array : 'documentRootPath' => null, 'directory' => 'files'

Result : Everything's fine : documentRootPath and directory is well calculated by the Filemanager

Case 2 : Web site's URL : http://mysubdomain.mydomain.com Web site's root dir : /Users/mydomain/mysubdomain/ MTFM File's root dir : /Users/mydomain/mysubdomain/files/

Filemanager option array : 'documentRootPath' => null, 'directory' => 'files'

Result Not good : documentRootPath : /Users/mydomain/files/

Whoa. That reads as if you're either having a bulk vhost_alias-ing rig or something else where DocumentRoot and hence SERVER['DOCUMENT_ROOT'] are incorrectly pointing at /Users/mydomain/files/ instead of /Users/mydomain/mysubdomain/

Remember that PHP doesn't have access to vhost_alias and mod_rewrite rules, so any file mapping happening through those have to be 'mimicked'. That's a general PHP issue; FM4Alias.php's FileManagerWithAliasSupport class is specifically written for scenarios like that.

Case 3 (should be the default behavior) : Web site's URL : http://www.mydomain.com Web site's root dir : /Users/mydomain/ MTFM File's root dir : /Users/mydomain/files/

Filemanager option array : 'documentRootPath' => '/Users/mydomain/', 'directory' => 'files'

Result Not good : documentRootPath : /Users/mydomain/Users/mydomain/files/

That one sounds like a bug. Either in config setup (and thus documentation) or in the FM code.

Suggestion : In the current behavior, the Filemanager lib calculates too much the root path and the base URL of files. Only 1 base URL and 1 basepath should be send to the FM at initialization, so the FM work with them and doesn't need to try to found the base URL / PATH :

Example : $param = array( basePath => '/Users/mydomain/', baseURL => 'http://www.mydomain.com/', directory => 'files/' );

Hm. It's a bit early in the morning and I'm working to get a few things done in a hurry before I have to attend other matters, but I fear there's an issue with that approach, haven't got the proof ready though.

Anyway, FM has to work in any environment; the alias-mimicked support class is there for vhost_alias, alias, mod_rewrite and other trickery and if that class isn't good enough for mapping URLs to paths, then one will need a derived class which does (particularly when you have abundant/fancy regex-replacing mod_rewrite rules). Currently, FM doesn't bother with domain names, so baseURL would then be '/'; anyway, got to think this through most thoroughly, because I've had a couple of burns in that departments already with other rigs, where FM currently works and I'd hate to fix one to have me implicitly b0rk the other.

Met vriendelijke groeten / Best regards,

Ger Hobbelt


web: http://www.hobbelt.com/ http://www.hebbut.net/ mail: ger@hobbelt.com

mobile: +31-6-11 120 978

GerHobbelt commented 13 years ago

couple of tweaks and renamed the backend/frontend options to hint at their fill type: file system path or URI path (meant in the sense of RFC3986, section 3.3): see the branch 'partikule_path_issues' and particularly commit @a6c7f63acef5b62edcee2b503de1fe8eda5eff69

Doesn't mean your trouble is gone, but we should be getting there in a saner and more proper way this time :-)