diff --git a/public_html/admin/install/classes/installer.class.php b/public_html/admin/install/classes/installer.class.php index d9b3a4cfa..63f674498 100644 --- a/public_html/admin/install/classes/installer.class.php +++ b/public_html/admin/install/classes/installer.class.php @@ -522,7 +522,7 @@ private function checkPermissions() $paths['public_html/'] . 'images/articles/', $paths['public_html/'] . 'images/topics/', $paths['public_html/'] . 'images/userphotos', - $paths['public_html/'] . 'filemanager/scripts/filemanager.config.js', + $paths['public_html/'] . 'filemanager/scripts/filemanager.config.json', $paths['public_html/'] . 'images/library/File/', $paths['public_html/'] . 'images/library/Flash/', $paths['public_html/'] . 'images/library/Image/', diff --git a/public_html/filemanager/ReadMe.md b/public_html/filemanager/ReadMe.md new file mode 100644 index 000000000..b21c735a0 --- /dev/null +++ b/public_html/filemanager/ReadMe.md @@ -0,0 +1,502 @@ +Filemanager +======================== + +FM is an open-source file manager released under MIT license. It is an alternative to elfinder or CKFinder. + +**_IMPORTANT_**: Check [new repo](https://github.com/servocoder/RichFilemanager) with a number of [new features and improvements](https://github.com/servocoder/RichFilemanager/blob/master/changelog). + +Support +------- + +Filemanager is under free license. If you want to support the filemanager development or just thank its main maintainer by paying a beer, you can make a donation by clicking the following button : +[![Donate](https://www.paypal.com/en_US/i/btn/x-click-but21.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2M5GWH9NLNEZL) + + + +Main features +------------- + +* A Filemanager relying on jquery. +* Available in more than 20 languages. +* [Highly customizable](https://github.com/simogeo/Filemanager/wiki/Filemanager-configuration-file) +* Can work as standalone application +* Easy integration with RTE like CKEditor, TinyMCE and so on. +* Easy integration with [colorbox jquery plugin](https://github.com/simogeo/Filemanager/wiki/How-to-use-the-filemanager-with-colorbox) or [HTML simple textfield](https://github.com/simogeo/Filemanager/wiki/How-to-use-the-filemanager-from-a-simple-textfield) +* Several computer language connectors available. **PHP is up-to-date** +* Ability to upload, delete, modify, download and move files +* Ability to create folders +* Support user permissions - based on session +* Handle system permissions +* Ability to pass config user file in URL +* Multiple uploads support - based on [dropzonejs](http://www.dropzonejs.com) +* Online text / code edition - based on [codeMirror](http://codemirror.net/) +* Online documents viewer - based on [viewerJS](http://viewerjs.org/) +* [Opening a given folder](https://github.com/simogeo/Filemanager/wiki/How-to-open-a-given-folder-different-from-root-folder-when-opening-the-filemanager) +* [Opening exclusively a given folder](https://github.com/simogeo/Filemanager/wiki/How-to-open-%28exclusively%29-a-given-subfolder) +* [Passing parameters to the FM](https://github.com/simogeo/Filemanager/wiki/Passing-parameters-to-the-FM) +* [File types restriction](https://github.com/simogeo/Filemanager/wiki/Set-up-upload-restriction-on-file-type) +* Video and audio player relying on web browser capabilities +* Textbox Search filter +* Thumbnails generation +* Image auto-resize +* File size limit +* File exclusion based on name and patterns +* Images files only +* Prevent files overwriting (or not) +* Switch from list to grid view and vice-versa +* Copy direct file URL +* [CSS Themes](https://github.com/simogeo/Filemanager/wiki/Create-your-own-theme) - **Please, share your themes with others !** +* and more ... + + +Screenshot +------------- + +![Filemanager Screenshot](http://i57.tinypic.com/35cqw74.png) + + +Documentation +------------- + +Filemanager is highly documented on the [wiki pages](https://github.com/simogeo/Filemanager/wiki). API, see below. + + +Installation and Setup +---------------------- + +**Preamble** + +Since many changes have been done recently, only PHP and MVC connectors are now available. You can try the latest version for others connectors, but with no warranty they implement all features and work correctly. + +To use other connectors, please download v0.8 version from https://github.com/simogeo/Filemanager/archive/v0.8.zip +(PHP, ASHX, ASP, CFM, lasso, PL and JSP connectors are available) + +A JSP/Java connector implementation is available at : https://github.com/th-schwarz/C5Connector.Java + +--- + +**(1)** Check out a copy of the FileManager from the repository using Git : + +git clone http://github.com/simogeo/Filemanager.git + +or download the archive from Github : https://github.com/simogeo/Filemanager/archive/master.zip + +You can place the FileManager anywhere within your web serving root directory. + +**(2)** Make a copy of the default configuration file ("filemanager.config.default.json" located in the scripts directory), removing the '.default' from the end of the filename, and edit the options according to the following wiki page : https://github.com/simogeo/Filemanager/wiki/Filemanager-configuration-file + Having a look on configuration cases study may also be helpful to you : https://github.com/simogeo/Filemanager/wiki/Specify-user-folder%2C-configuration-cases + +**(3a)** If you are integrating the FileManager with FCKEditor, open your fckconfig.js file and find the lines which specify what file browser to use for images, links, etc. Look toward the bottom of the file. You will need to change lines such as this: + +```javascript +FCKConfig.ImageBrowser = false ; +FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector=../../connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ; +``` + +...to this: + +```javascript +FCKConfig.ImageBrowser = true ; +FCKConfig.ImageBrowserURL = '[Path to Filemanager]/index.html' ; +``` + +**(3b)** If you are integrating the FileManager with CKEditor 3.x or higher, simply set the URL when you configure your instance, like so: + +```javascript +CKEDITOR.replace('instancename', { + filebrowserBrowseUrl: '[Path to Filemanager]/index.html', + ...other configuration options... +}); +``` + +If you want to use the **modal dialog mode** (instead of pop-up), please refer to [the dedicated wiki page](https://github.com/simogeo/Filemanager/wiki/How-to-open-the-Filemanager-from-CKEditor-in-a-modal-window). + +**(3c)** If you are integrating the FileManager with TinyMCE (>= 3.0), you should: + +Create a Javascript callback function that will open the FileManager index.html base page (see URL below for examples) +Add a line like: "file_browser_callback : 'name_of_callback_function'" in the tinyMCE.init command +See http://www.tinymce.com/wiki.php/TinyMCE3x:How-to_implement_a_custom_file_browser for more details. + +See also the dedicated wiki page, with TinyMCE 4 sample : https://github.com/simogeo/Filemanager/wiki/How-to-use-the-Filemanager-with-tinyMCE-3-or-4 + + +**(4)** Last but not least, **worry about security**! + +For **PHP connector** : copy/paste the `/connectors/php/default.config.php` to `/connectors/php/user.config.php` to define your own authentication function. +To do so, you will find an example on the [dedicated wiki page](https://github.com/simogeo/Filemanager/wiki/Security-concern). + +**jQuery dependency and compatibility** + +We try to keep updating jQuery core library regularly. +If, for any reason, you can't use the embedded jQuery version just now that the Filemanager will probably work with a jQuery version >= 1.6. +You'll have to use the [jQuery.migrate() plugin](https://github.com/jquery/jquery-migrate) to use it with jQuery version 1.9+. + + +Set-up & security +----------------- + +**Important** : The Filemanager is designed to work without any special configuration but **using it without any configuration is VERY unsafe**. +Please set-up your own **authentication function**, based on [default file](https://github.com/simogeo/Filemanager/blob/master/connectors/php/default.config.php) and refering to the [dedicated wiki page](https://github.com/simogeo/Filemanager/wiki/Security-concern). + + +API +--- + + +Connector Location +------------------ +You can create a connector for your server side language of choice by following this simple API. You must have a script at the following location which can respond to HTTP GET requests by returning an appropriate JSON object: + + [path to FileManager]/connectors/[language extension]/filemanager.[language extension] + +FileManager currently includes connectors for PHP, MVC, JSP, lasso, ASP, ASHX, PL and CFM in the following locations: + + PHP: .../connectors/php/filemanager.php + ASP.NET MVC Framework .../connectors/mvc/FilemanagerController.cs + JSP: .../connectors/jsp/filemanager.jsp + lasso: .../connectors/lasso/filemanager.lasso + ASP: .../connectors/asp/filemanager.asp + ASHX: .../connectors/ashx/filemanager.asp + PL: .../connectors/pl/filemanager.pl + CFM: .../connectors/cfm/filemanager.cfm + +As long as a script exists at this location to respond to requests, you may split up the code (external libraries, configuration files, etc.) however you see fit. + + +Error Handling +-------------- +Every response should include two keys specific to error handling: Error, and Code. If an error occurs in your script, you may populate these keys with whatever values you feel are most appropriate. If there is no error, Error should remain empty or null, and Code should be empty, null, or zero (0). Do not use zero for any actual errors. The following example would be an appropriate response if the connector uses an external file for configuration (recommended), but that file cannot be found: + +```json +{ + "Error": "Configuration file missing.", + "Code": -1 +} +``` + +Methods +------- +Your script should include support for the following methods/functions. GET requests from FileManager include a parameter "mode" which will indicate which type of response to return. Additional parameters will provide other information required to fulfill the request, such as the current directory. + +getinfo +------- +The `getinfo` method returns information about a single file. Requests with mode "getinfo" will include an additional parameter, "path", indicating which file to inspect. A boolean parameter "getsize" indicates whether the dimensions of the file (if an image) should be returned. + +Example Request: + + [path to connector]?mode=getinfo&path=/UserFiles/Image/logo.png&getsize=true + +Example Response: + +```json +{ + "Path": "/UserFiles/Image/logo.png", + "Filename": "logo.png", + "File Type": "png", + "Preview": "/UserFiles/Image/logo.png", + "Protected": 0, + "Properties": { + "Date Created": null, + "Date Modified": "02/09/2007 14:01:06", + "filemtime": 1360237058, + "Height": 14, + "Width": 14, + "Size": 384 + }, + "Error": "", + "Code": 0 +} +``` + +The keys are as follows: + + Path: The path to the file. Should match what was passed in the request. + + Filename: The name of the file, i.e., the last part of the path. + + File Type: The file extension, "dir" if a directory, or "txt" if missing/unknown. + + Preview: Path to a preview image. If the file is an image that can be displayed in a web browser (i.e., gif, jpg, or png), you should return the path to the image. Otherwise, check to see if there is a matching file icon based on the file extension, constructing the path like so: + + Directories: images/fileicons/_Open.png + Files: images/fileicons/[extension].png + Unknown: images/fileicons/default.png + + Protected: Indicates if the file has some reading / writing restrictions. If not, set to 0. Else set to 1. + + Properties: A nested JSON object containing specific properties of the file. + + Date Created: The file's creation date, if available. + Date Modified: The file's modification date, if available. + Height: If an image, the height in pixels. + Width: If an image, the width in pixels. + Size: The file size in bytes. + + Capabilities (optional): You can limit the operation buttons shown for a specific file. It is an array containing ['select','delete','rename','download'] (for all capabilities), or [] (for no capabilities). If not present, all capabilities are enabled. + + Error: An error message, or empty/null if there was no error. + + Code: An error code, or 0 if there was no error. + + +getfolder +--------- +The `getfolder` method returns an array of file and folder objects representing the contents of the given directory (indicated by a "path" parameter). It should call the getinfo method to retrieve the properties of each file. A boolean parameter "getsizes" indicates whether image dimensions should be returned for each item. Folders should always be returned before files. +Optionally a "type" parameter can be specified to restrict returned files (depending on the connector). If a "type" parameter is given for the main index.html URL, the same parameter value is reused and passed to getfolder. This can be used for example to only show image files in a file system tree. + +Example Request: + + [path to connector]?mode=getfolder&path=/UserFiles/Image/&getsizes=true&type=images + +Example Response: + +```json +{ + "/UserFiles/Image/logo.png": { + "Path": "/UserFiles/Image/logo.png", + "Filename": "logo.png", + "File Type": "png", + "Preview": "/UserFiles/Image/logo.png", + "Protected": 0, + "Properties": { + "Date Created": null, + "Date Modified": "02/09/2007 14:01:06", + "filemtime": 1360237058, + "Height": 14, + "Width": 14, + "Size": 384 + }, + "Error": "", + "Code": 0 + }, + "/UserFiles/Image/icon.png": { + "Path": "/UserFiles/Image/icon.png", + "Filename": "icon.png", + "File Type": "png", + "Preview": "/UserFiles/Image/icon.png", + "Properties": { + "Date Created": null, + "Date Modified": "02/09/2007 14:01:06", + "filemtime": 1360237058, + "Height": 14, + "Width": 14, + "Size": 384 + }, + "Error": "", + "Code": 0 + }, + "/UserFiles/folder/":{ + "Path":"/UserFiles/folder/", + "Filename":"folder", + "File Type":"dir", + "Preview":"images\/fileicons\/_Open.png", + "Properties": { + "Date Created":null, + "Date Modified": "02/09/2007 14:01:06", + "filemtime": 1360237058, + "Height":null, + "Width":null, + "Size":null + }, + "Error":"", + "Code":0 + } +} +``` + +Each key in the array is the path to an individual item, and the value is the file object for that item. + + +rename +------ +The `rename` method renames the item at the path given in the "old" parameter with the name given in the "new" parameter and returns an object indicating the results of that action. + +Example Request: + + [path to connector]?mode=rename&old=/UserFiles/Image/logo.png&new=id.png + +Example Response: + +```json +{ + "Error": "No error", + "Code": 0, + "Old Path": "/a_folder_renamed/thisisareallylongincrediblylongfilenamefortesting.txt", + "Old Name": "thisisareallylongincrediblylongfilenamefortesting.txt", + "New Path": "/a_folder_renamed/a_renamed_file", + "New Name": "a_renamed_file" +} +``` + +move +------ +The `move` method move "old" file or directory to specified "new" directory. It is possible to specify absolute path from fileRoot dir or relative path from "old" item. "root" value is mandatory to secure that relative paths don't get above fileRoot. + +Example Request: Move file + + [path to connector]?mode=move&old=/uploads/images/original/Image/logo.png&new=/moved/&root=/uploads/images/ + +Example Response: + +```json +{ + "Error": "No error", + "Code": 0, + "Old Path": "/uploads/images/original/Image/", + "Old Name": "logo.png", + "New Path": "/uploads/images/moved/", + "New Name": "logo.png" +} +``` + +Example Request: Move directory to not existing directory (will be created) + + [path to connector]?mode=move&old=/uploads/images/original/Image&new=../new_dir/&root=/uploads/images/ + +Example Response: + +```json +{ + "Error": "No error", + "Code": 0, + "Old Path": "/uploads/images/original/", + "Old Name": "Image", + "New Path": "/uploads/new_dir/", + "New Name": "Image" +} +``` + + + +delete +------ +The `delete` method deletes the item at the given path. + +Example Request: + + [path to connector]?mode=delete&path=/UserFiles/Image/logo.png + +Example Response: + +```json +{ + "Error": "No error", + "Code": 0, + "Path": "/UserFiles/Image/logo.png" +} +``` + +add +--- +The `add` method adds the uploaded file to the specified path. Unlike the other methods, this method must return its JSON response wrapped in an HTML `"),e=e+''+(''),e+='",e+='",e+="",a("#preview").find("img").hide(), -a("#preview").prepend(e).hide().fadeIn(),a("#edit-cancel").click(function(){a("#preview").find("form#edit-form").hide();a("#preview").find("img").fadeIn();a("#edit-file").show()}),a("#edit-save").click(function(){var d=codeMirrorEditor.getValue();a("textarea#edit-content").val(d);d=a("#edit-form").serializeArray();a.ajax({type:"POST",url:k,dataType:"json",data:d,async:!1,success:function(d){0==d.Code?(isEdited=!0,a.prompt(b.successful_edit)):(isEdited=!1,a.prompt(d.Error))}})}),codeMirrorEditor=instantiateCodeMirror(q(c.Path), -f)):(isEdited=!1,a.prompt(e.Error),a(this).show())}})});return isEdited},aa=function(b){a("#filetree").find('a[data-path="'+b+'"]').parent().fadeOut("slow",function(){a(this).remove()});if(a("#uploader h1").attr("data-path")==b){var f=b.split("/").slice(0,length-2).join("/")+"/";m(f)}"grid"==a("#fileinfo").data("view")?a('#contents img[data-path="'+b+'"]').parent().parent().fadeOut("slow",function(){a(this).remove()}):a("table#contents").find('td[data-path="'+b+'"]').parent().fadeOut("slow",function(){a(this).remove()}); -a("#preview").length&&m(b.substr(0,b.lastIndexOf("/")+1))},Y=function(c,g){var e='',d=a("#filetree").find('a[data-path="'+c+'"]');c!=fileRoot?d.next("ul").prepend(e).prev("a").click().click():(a("#filetree ul.jqueryFileTree").prepend(e),a("#filetree").find('li a[data-path="'+c+g+'/"]').attr("class","cap_rename cap_delete").click(function(){m(c+g+"/")}).each(function(){a(this).contextMenu({menu:v(a(this))}, -function(d,b,c){b=a(b).attr("data-path");z(d,b)})}));f.options.showConfirmation&&a.prompt(b.successful_added_folder)},G=function(b){b.lastIndexOf("/")==b.length-1?(m(b),a("#filetree").find('a[data-path="'+b+'"]').click()):E(b)},z=function(b,f){var e=new Date;a.getJSON(k+"?mode=getinfo&path="+f+"&time="+e.getMilliseconds(),function(d){"grid"==a("#fileinfo").data("view")?a("#fileinfo").find('img[data-path="'+d.Path+'"]').parent():a("#fileinfo").find('td[data-path="'+d.Path+'"]').parent();switch(b){case "select":D(d); -break;case "download":window.location=k+"?mode=download&path="+d.Path+"&time="+e.getMilliseconds();break;case "rename":K(d);break;case "replace":M(d);break;case "move":L(d);break;case "delete":N(d)}})},E=function(c){a(".contextMenu").hide();var g=c.substr(0,c.lastIndexOf("/")+1);C(g);var e;e='

'+('");-1!=a.inArray("select",n)&&(a.urlParam("CKEditor")|| -window.opener||window.tinyMCEPopup||a.urlParam("field_name"))&&(e+='");-1!=a.inArray("download",n)&&(e+='");-1!=a.inArray("rename",n)&&1!=f.options.browseOnly&&(e+='");-1!=a.inArray("move",n)&&1!=f.options.browseOnly&&(e+='");-1!=a.inArray("delete",n)&&1!=f.options.browseOnly&&(e+='");-1!=a.inArray("replace",n)&&1!=f.options.browseOnly&&(e+='",e+='
',e+=' ',e+=''); -e+="
";0'+b.copy_to_clipboard+ -""),loadJS("./scripts/zeroclipboard/copy.js?d"+e.getMilliseconds()),a("#copy-button").click(function(){a("#fileinfo").find("div#tools").append(''+b.copied+"");a("#copied").delay(500).fadeOut(1E3,function(){a(this).remove()})}));e="";d.Properties.Width&&""!=d.Properties.Width&&(e+="
"+b.dimensions+"
"+d.Properties.Width+"x"+d.Properties.Height+"
");d.Properties["Date Created"]&&""!=d.Properties["Date Created"]&&(e+="
"+b.created+"
"+d.Properties["Date Created"]+ -"
");d.Properties["Date Modified"]&&""!=d.Properties["Date Modified"]&&(e+="
"+b.modified+"
"+d.Properties["Date Modified"]+"
");if(d.Properties.Size||0==parseInt(d.Properties.Size))e+="
"+b.size+"
"+H(d.Properties.Size)+"
";a("#fileinfo").find("dl").html(e);O(d)}else a.prompt(d.Error)})},m=function(c){C(c);var g='';0';for(key in c){g++;var h=c[key].Properties,l="";for(cap in n)r(c[key],n[cap])&&(l+=" cap_"+n[cap]);var F= -64,k=h.Width;1
'+c[key].Path+'

'+c[key].Filename+"

";h.Width&&""!=h.Width&&(d+=''+h.Width+"x"+h.Height+"");h.Size&&""!=h.Size&&(d+=''+h.Size+"");h.Size&&""!=h.Size&&(p+=h.Size);h["Date Created"]&&""!=h["Date Created"]&& -(d+=''+h["Date Created"]+"");h["Date Modified"]&&""!=h["Date Modified"]&&(d+=''+h["Date Modified"]+"");d+=""}d+=""}else{d=d+''+('");d+="";for(key in c){g++;h=c[key].Properties;l="";f.options.showTitleAttr? -title=' title="'+c[key].Path+'"':title="";for(cap in n)r(c[key],n[cap])&&(l+=" cap_"+n[cap]);d+='';d+='";d=h.Width&&""!=h.Width?d+(""):d+"";h.Size&&""!=h.Size?(d+='",p+=h.Size):d+="";d=h["Date Modified"]&&""!=h["Date Modified"]?d+(""):d+"";d+=""}d+="";d+="
'+b.name+""+b.dimensions+""+b.size+""+b.modified+"
'+c[key].Filename+""+h.Width+"x"+h.Height+"'+H(h.Size)+""+h["Date Modified"]+"
"}}else d+= -"

"+b.could_not_retrieve_folder+"

";0