6

I am trying to integrate ckfinder with ckeditor. Everything is OK, except one. when I try to upload the image, I get this error (Please check image)

Unable to configure ckfinder with ckeditor

It says "The file browser is disabled for security reasons. Please contact your system administrator and check the CKFinder configuration file"

Anyone who can help me? Please.

Muaaz Khalid
  • 2,199
  • 2
  • 28
  • 51
  • sometimes relogin will resolve the issue and check this first if you not seen this error before. – Iman Dec 27 '14 at 10:45

2 Answers2

7

Look in the ckFinder config file, you will see a function like this:

function CheckAuthentication()
{

    return false;
}

By default CheckAuthentication() it is disabled for security reason, because it would allow anyone to upload files to your server.

For testing purposes you can return true but the point is that you implement some logic to only authorize autenticated user.

function CheckAuthentication()
{
    //put some logic here

    return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];
}
meda
  • 45,103
  • 14
  • 92
  • 122
  • 1
    Thank you! You solved my problem... I was searching for this, since 2 days,, But, couldn't find the exact solution. Thanks again... – Muaaz Khalid Feb 15 '14 at 16:30
  • Yup, That's it! you would expect something like that to be a part of the installation guide ... – Roy Toledo Apr 21 '14 at 11:41
  • @meda, bro could you please take a look at my problem https://stackoverflow.com/questions/45340568/how-to-change-image-save-location-in-ckeditor-drupal-7 ? – May Phyu Jul 27 '17 at 03:42
0

A simple solution is to force the authentication method using a function that always returns true, using the following code in your config file.

Your Script (for codeigniter):

if(login()){
   set_cookie('ckf_role','admin',2592000*10); // 10 month
}

Top:

        $config['authentication'] = function() {
            return true;
        };

Middle:

    session_start();
    $config['roleSessionVar'] = 'CKFinder_UserRole';
    $_SESSION['CKFinder_UserRole'] = !empty($_COOKIE['ckf_role']) ? strtolower($_COOKIE['ckf_role']) : "guest";

    $config['accessControl'][] = array(
    'role'                => 'guest',
    'resourceType'        => '*',
    'folder'              => '/',
    'FOLDER_VIEW'         => false,
    'FOLDER_CREATE'       => false,
    'FOLDER_RENAME'       => false,
    'FOLDER_DELETE'       => false,
    'FILE_VIEW'           => false,
    'FILE_UPLOAD'         => false,
    'FILE_RENAME'         => false,
    'FILE_DELETE'         => false,
    'IMAGE_RESIZE'        => false,
    'IMAGE_RESIZE_CUSTOM' => false
    );

   $config['accessControl'][] = array(
    'role'                => 'admin',
    'resourceType'        => '*',
    'folder'              => '/',
    'FOLDER_VIEW'         => true,
    'FOLDER_CREATE'       => true,
    'FOLDER_RENAME'       => true,
    'FOLDER_DELETE'       => true,
    'FILE_VIEW'           => true,
    'FILE_UPLOAD'         => true,
    'FILE_RENAME'         => true,
    'FILE_DELETE'         => true,
    'IMAGE_RESIZE'        => true,
    'IMAGE_RESIZE_CUSTOM' => true
    );
Limitless isa
  • 3,689
  • 36
  • 28