* @copyright Authors */ // Laravel init require getcwd().'/../../../../bootstrap/autoload.php'; $app = require_once getcwd().'/../../../../bootstrap/app.php'; $kernel = $app->make('Illuminate\Contracts\Http\Kernel'); $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); $id = $app['encrypter']->decrypt($_COOKIE[$app['config']['session.cookie']]); $app['session']->driver()->setId($id); $app['session']->driver()->start(); // Folder path $folderPath = $app->basePath().'/public/'.config('filemanager.folder_path'); // Check if user in authentified if (!$app['auth']->check()) { $laravelAuth = false; } else { // Check if user has all access if ($app['auth']->user()->accessMediasAll()) { $laravelAuth = true; } elseif (method_exists($app['auth']->user(), 'accessMediasFolder')) { // Check if user has access to one folder if ($app['auth']->user()->accessMediasFolder()) { // Folder name with user id $folderPath .= 'user'.$app['auth']->id(); // Create folder if doesn't exist if (!is_dir($folderPath)) { mkdir($folderPath); } $laravelAuth = true; } else { $laravelAuth = false; } } else { $laravelAuth = false; } } /** * Check if user is authorized. * * * @return bool true if access granted, false if no access */ function auth() { return $GLOBALS['laravelAuth']; } $fm = new Filemanager(); $fm->setFileRoot($folderPath);