CK Editor file manager

edited February 2013 in Bug Reports
Hey,

I have read these discussions.
http://www.getfuelcms.com/forums/discussion/525/integrate-image-upload-right-from-ckeditor-wysiwyg/p1
http://getfuelcms.com/forums/discussion/635/better-asset-manager-in-fuel-cms/p1

I am trying to integrate the follwing file manager with CK Editor but to no avail.
https://github.com/simogeo/Filemanager

When I click the "Browse server" button in CK Editor it opens the file manager and that's it. No files or folders only the loading animation appears.
I have tried all kinds of stuff but everything leads to the same result.

What I did (without all the experiments):

- Downloaded the file manager and put it in fuel/modules/fuel/assets/js/editors/ckeditor

- Modified MY_fuel.php under application/config. Added
'filebrowserBrowseUrl' => BASE_URL . 'fuel/modules/fuel/assets/js/editors/ckeditor/filemanager/index.html' in the ck_editor_setting array.

- Modified the filemanager.config.js file. Changed the "fileRoot" to "http://mydomain.com/funsongs/assets/". "mydomain" is a dummy name.

- Assets folder and all subfolders are writable.

The "auth" function in connectors/php/filemanager.php always returns true.

What could be the problem? Did I left out something essential?

Comments

  • edited 6:22AM
    I think the easiest way to debug this would be to get the filemanager.php to render outside of FUEL and CKEditor. It's setup to operate independently. I would try browsing to the following file and see what sort of error messages in the console show up:
    http://mydomain.com/funsongs/fuel/modules/fuel/assets/js/editors/ckeditor/filemanager/
  • edited March 2014
    Am using the latest fuelCMS version. I'm having trouble with this as well but only at the server. I'm using a Mac locally using a virtual domain name so my local build is using a mydevsite.com type URL. I first placed the filemanager directory into the ckeditor directory as you mentioned might be the problem above but it worked perfectly in my local build so I pushed the changes to the server and it opens the filemanager/index.html file and seems to style the container but no file results. The loader animation appears and that's all.

    So, I moved it into the /assets/ directory and it worked locally again but same results on the server. Then moved it out of all the fuel directories into its own directory right under the root and still the same results - works locally but not on the server.

    I've been checking permissions on filemanager/ and all its subdirectories all along and they're the same on the server as my local build - 755. assets/images/* -> 777.

    I wouldn't think it would be the htaccess file would you? It's unaltered from how you have it set up initially.

    UPDATE:
    Just looked at my server error_log and found this:
    [11-Mar-2014 08:20:48 America/Chicago] PHP Notice: Undefined index: HTTP_HOST in /home/mydomain/public_html/fuel/modules/fuel/config/fuel_constants.php on line 66
  • edited 6:22AM
    That $_SERVER variable should probably be set by the server, but if it doesn't exist, you can set it in the index.php file:
    $_SERVER['HTTP_HOST'] = 'myhost.com';
  • edited 6:22AM
    gotcha. The issue of the filemanager not showing up has now been fixed, btw. Turns out it was a permissions issue. I've asked the server tech to let me know what he did to fix it so I can pass it on here.
  • edited March 2014
    I found out what was going on and hope this can help someone else. My server uses suPHP. Here's the reply from the server tech:
    ********************************************
    The fix had to do with the file ownership and permissions. Your server runs suPHP, you need to ensure your files have permissions of 644 and your directories have permissions of 755. suPHP runs scripts with the permissions of the user account, so any file writeable to that user is writable by the script. This makes managing permissions much easier, but has the side effect of giving an error if your file permissions are either group or world writable. This means that 777 files will not work with suPHP along with incorrect ownership.
    ********************************************
    The next issue I have is how to isolate the filemanager files. I used the auth function located in /filemanager/connectors/php/filemanager.php and all I know to do when I don't have access to CI or Fuel is to check for the presence of the ci_session cookie.

    Here's my attempt in the filemanager.php file...
    function auth() { // You can insert your own code over here to check if the user is authorized. // If you use a session variable, you've got to start the session first (session_start()) if(isset($_COOKIE['ci_session'])) { return true; } else { return false; } }I really need to restrict users to certain directories. Is there any way you know of to identify users from inside filemanager.php?
  • edited 6:22AM
    This probably isn't the best thing to do but I just edited the filemanager.js file. There's a config function that looks like this around line 28...
    // We retrieve config settings from filemanager.config.js var config = (function () { var json = null; $.ajax({ 'async': false, 'url': './scripts/filemanager.config.js', 'dataType': "json", cache: false, 'success': function (data) { json = data; } }); return json; })();
    I have several users in the CMS and they all use a different folder under the /assets/images directory based on the id of their record in a client_id's table. So, I created a controller named client_by_session.php with a get_client_id method that snags and returns the client_id based on the CI->session. So, now the same config function looks like this:
    // We retrieve config settings from filemanager.config.js var config = (function () { var json = null; $.ajax({ 'async': false, 'url': './scripts/filemanager.config.js', 'dataType': "json", cache: false, 'success': function (data) { json = data; } }); // added to restrict access by logged in clients to only their folder in case they attempt to open /filemanager directly var client_id = checkClientID(); if(client_id != "empty" && client_id != undefined && client_id != "super_admin") { var fileRoot = json['options']['fileRoot'] + client_id + "/"; json['options']['fileRoot'] = fileRoot; return json; } else { if(client_id == "super_admin") { return json; } else { // must not be authorized - get 'em outta here window.location="/"; } } })();
    So, now, if you are logged in as a client and you happen to know that you can get to the filemanager directory, even if you do, you'll only see your files. If you're the super_admin you'll see them all and if you're not logged in you'll be quietly redirected to the homepage.
Sign In or Register to comment.