How to integrate CKFinder with Laravel?

I am trying to integrate CKFinder with Laravel, and I'm about 95% there. I can make everything work, except for the function CheckAuthentication- I need to do this return trueregardless of whether the download boots.

What I tried to do was load Laravel in the config.php file and then check if the user is registered, as shown below:

state / packages / ckfinder / config.php

<?php
/*
 * ### CKFinder : Configuration File - Basic Instructions
 *
 * In a generic usage case, the following tasks must be done to configure
 * CKFinder:
 *     1. Check the $baseUrl and $baseDir variables;
 *     2. If available, paste your license key in the "LicenseKey" setting;
 *     3. Create the CheckAuthentication() function that enables CKFinder for authenticated users;
 *
 * Other settings may be left with their default values, or used to control
 * advanced features of CKFinder.
 */

/** RIPPED FROM public/index.php **/

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

require __DIR__.'/../../../bootstrap/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight these users.
|
*/

$app = require __DIR__.'/../../../bootstrap/start.php';

/** END public/index.php **/

/**
 * This function must check the user session to be sure that he/she is
 * authorized to upload and access files in the File Browser.
 *
 * @return boolean
 */
function CheckAuthentication()
{
    // WARNING : DO NOT simply return "true". By doing so, you are allowing
    // "anyone" to upload and list the files in your server. You must implement
    // some kind of session validation here. Even something very simple as...

    return Auth::check();
}

This always returns false. I also tried directly using Laravel Sessionto set the variable to true when someone logs in, and false when logging out, and then checks this in the config.php file, but always returns the default value to Session::get("IsAuthorized", false);. Can anyone suggest some kind of guidance -

1) , ?

2) Laravel , -, , ?

+4
2

simogeo Filemanager KCFinder Laravel, .

Laravel :

https://gist.github.com/frzsombor/ddd0e11f93885060ef35

+1

, 4.1.28, Application:: boot() .

, , , Auth:: check() . $_SESSION.

. :

require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';
$app->boot();
return Auth::check();

Auth:: check() $app- > run(). , , ... Laravel .

- - :

// Somewhere in your app - e.g. in filters.php, "auth"/"guest" filters declaration
if (session_id() == '') {
    @session_start();
    /* or Session:start(); */
}
$_SESSION['isLoggedIn'] = Auth::check() ? true : false;

:

function CheckAuthentication()
{
    if (session_id() == '') {
        @session_start();
    }
    return isset( $_SESSION['isLoggedIn'] ) && $_SESSION['isLoggedIn'] == true;
}

N.B. Ajax , API JSON ( ), , .

- , . Laravel, , . - , - , .

0

Source: https://habr.com/ru/post/1542650/


All Articles