I am using responsive FileManager 9.14.0 with TinyMCE 5.0.16 and Laravel 6 running on Nginx 1.16.1
I have the following folder structure:
| public
| |- uploads
| |- thumbs
| |- filemanager
| |- js
| | |- tinymce
| | | |- plugins
| | | | |- responsivefilemanager
| | | | | |- plugin.min.js
I use laravel authentication to protect a 'create' page where the user can add text using tinyMCE and upload images using RFM as tyniMCE plugin.
But RFM is accessible directly if with the following URL
http://www.myhost.test/filemanager/dialog.php
How can I prevent this behavior. I want RFM to be accessible only from the tinyMCE editor.
im not familier with laravel but ...
in Responsive File Manager 9.0 there is a folder called config that contain config.php
| public
| |- uploads
| |- thumbs
| |- filemanager
| | |- config
| | | |- config.php
| |- js
| | |- tinymce
| | | |- plugins
| | | | |- responsivefilemanager
| | | | | |- plugin.min.js
open config.php and change
define('USE_ACCESS_KEYS', false); // TRUE or FALSE -------- to ------> define('USE_ACCESS_KEYS', true); // TRUE or FALSE
this force Responsive File Manager to use Aaccess Key to prevent all attempt from being accessed to your files and folders.
in same file at line 190 add your users auth_key for whom they need to use file-manager .
for example :
username: jim auth_key: a1s2d3f4g5h6j7k8l9mm
username: lisa auth_key: zqxwd3f4vrbth6j7btny
so line 190 should rewrite like line below:
'access_keys' => array( "a1s2d3f4g5h6j7k8l9" , "zqxwd3f4vrbth6j7btny"),
go to your form and add a button/link to access RESPONSIVE FILE MANAGER
<a href="https://www.example.com/admin/responsive-filemanager/filemanager/dialog.php?akey=<?php echo {{{your authenticated user AUTH_KEY}}}; ?> </a>
if there is no {{{your authenticated user AUTH_KEY}}} there is 2 way:
1)) add a column auth_key to your users table and generate auth_key that should be equal for users they want to access to responsive file manager in both database and config.php file.
2)) use username instead of auth_key so your config at line 19 will be:
'access_keys' => array( "jim" , "lisa"),
and now your responsive file manager access link will be like this:
<a href="https://www.example.com/admin/responsive-filemanager/filemanager/dialog.php?akey=jim ></a>
jim is static here u should make it dynamic by call function to return authenticated user USERNAME and put it after &akey= in link
now if akey value in link find in access_key array the responsive file manager page will be work otherwise it show you ACCESS DENIED!!!
If it's still relevant, I can show you how I did it in Laravel 8
I proceeded from the opposite - if the user logged in under the admin, then there is no need to check it and therefore USE_ACCESS_KEYS do FALSE, otherwise - TRUE
And therefore, if he is NOT authenticated as an administrator, then he will NOT get access to the ResponsiveFileManager.
To do this, add such a function in the responsive_filemanager / filemanager / config / config.php file somewhere at the beginning of the file.
( Specify your own paths to the files '/vendor/autoload.php' and '/bootstrap/app.php' )
function use_access_keys() {
require dirname(__DIR__, 4) . '/vendor/autoload.php';
$app = require_once dirname(__DIR__, 4) . '/bootstrap/app.php';
$request = Illuminate\Http\Request::capture();
$request->setMethod('GET');
$app->make('Illuminate\Contracts\Http\Kernel')->handle($request);
if (Auth::check() && Auth::user()->hasRole('admin')) {
return false;
}
return true;
}
and then this line:
define('USE_ACCESS_KEYS', false);
replace with this:
define('USE_ACCESS_KEYS', use_access_keys());
And one moment.
If after that, when opening the FileManager, the following error suddenly pops up: "Undefined variable: lang"
then open responsive_filemanager / filemanager / dialog.php
find the array $get_params and in it change like this:
'lang' => 'en',
Related
I have a problem in my Route.
I see this error:
Route [utilizadores.editar] not defined
The error occurs on the page when I try to update the data in my DB.
My Route:
Route::put('Utilizadores/{item}', [FuncionarioController::class, 'editar'])->name('utilizadores.editar');
Route::get('Utilizadores/{item}/edit', [FuncionarioController::class, 'edit'])->name('utilizadores.edit');
My controller:
public function editar(Request $request, funcionario $item){
$item->nome = $request->nome;
$item->email = $request->email;
$item->telefone = $request->telefone;
$item->foto = $request->foto;
$item->data_nasc = $request->data_nasc;
$item->nacionalidade = $request->nacionalidade;
$item->n_cartao_cc = $request->n_cartao_cc;
$item->nif = $request->nif;
$item->morada = $request->morada;
$item->n_porta = $request->n_porta;
$item->localidade = $request->localidade;
$item->concelho = $request->concelho;
$item->distrito = $request->distrito;
$item->cp = $request->cp;
$item->data_entrada = $request->data_entrada;
$item->funcao = $request->funcao;
$item->estado = $request->estado;
// $item->n_ferias_disponiveis = $request->n_ferias_disponiveis;
// $item->data_registo = $now;
dd($item);
$item->save();
return redirect()->route('utilizadores.index');
}
My View:
<form class="needs-validation" method="POST" action="{{route('utilizadores.editar',$item->id)}}" enctype="multipart/form-data">
#csrf
#method('put')
Where am I wrong? I have other pages like this done and it works.
Thanks to anyone who can help me.
Edit: My php artisan route:list
| | DELETE | Utilizadores/{item} | utilizadores.delete | App\Http\Controllers\FuncionarioController#delete | web
|
| | PUT | Utilizadores/{item} | utilizadores.editar_perfil | App\Http\Controllers\FuncionarioController#editar_perfil | web
|
| | GET|HEAD | Utilizadores/{item}/delete | utilizadores.modal | App\Http\Controllers\FuncionarioController#modal | web
|
| | GET|HEAD | Utilizadores/{item}/edit | utilizadores.edit | App\Http\Controllers\FuncionarioController#edit | web
|
| | GET|HEAD | Utilizadores/{item}/edit_perfil | utilizadores.edit_perfil | App\Http\Controllers\FuncionarioController#edit_perfil | web
|
| | PUT | Utilizadores/{item}/editpass | utilizadores.passwordeditar | App\Http\Controllers\FuncionarioController#passwordeditar | web
Just swap edit and editar route. Something like this
Route::get('Utilizadores/{item}/edit', [FuncionarioController::class, 'edit'])->name('utilizadores.edit');
Route::put('Utilizadores/{item}', [FuncionarioController::class, 'editar'])->name('utilizadores.editar');
Or better, use resource controller for simpler Route file
Route::resource('utilizadores', FuncionarioController::class);
Keep in mind that you will tweak some function name and route file
Docs
You cannot have two identical routes for the same method/path. It is apparent in route:list that you already have a route registered for put('Utilizadores/{item}') with a different name (utilizadores.editar_perfil), therefore,
Route::put('Utilizadores/{item}',
[FuncionarioController::class, 'editar'])
->name('utilizadores.editar');
is not being registered, so you get that error when you try to insert {{ route('utilizadores.editar',$item->id) }} in your view.
First look to your route list using below command
php artisan route:list
If the routes exists then hit this command :
php artisan optimize
php artisan optimize:clear
I have Laravel 5.3 site.
I added some api routes today but they are not called.
Indeed I have a NewRouteController file under Http/Api
But the route returns 404 error. The controller is never reached.
There are other routes in api.php that work fine (call one of them api/workingroute, for instance). But if I comment out their route in api.php, they still work!
Here is the api.php file:
Route::group(['prefix' => 'api'], function () { Route::resource('workingroute', 'Api\WorkingRouteController'); });
Route::group(['prefix' => 'api'], function () { Route::resource('newroute', 'Api\NewRouteController'); });
I think the problem is revealed by route:list
GET|HEAD | api/api/newitems | newitems.index | App\Http\Controllers\Api\New RouteController#index | api |
| | POST | api/api/newitems | newitems.store | App\Http\Controllers\Api\New Route#store | api |
| | GET|HEAD | api/api/newitems/create | newitems.create | App\Http\Controllers\Api\New Route#create | api |
| | GET|HEAD | api/api/newitems/{newitem} | newitems.show | App\Http\Controllers\Api\New Route#show | api |
| | DELETE | api/api/newitems/{newitem} | newitems.destroy | App\Http\Controllers\Api\New Route#destroy | api |
| | PUT|PATCH | api/api/newitems/{newitem} | newitems.update | App\Http\Controllers\Api\New Route#update | api |
| | GET|HEAD | api/api/newitems/{newitem}/edit | newitems.edit | App\Http\Controllers\Api\New Route#edit | api
Not sure why we have api/api since I don't see anywhere where I would have indicated the route that way, especially since I am just repeating everything that exists for working api routes. Or I suppose since I am using api.php that the prefix is already added.
Also, odd that for my working route, I have a bunch of entries of form api/route, but they also have repeat entries of form api/api/route
And for routes of form api/api/item we have these sorts of lines
api/api/item/{item} | item.show | App\Http\Controllers\Api\ItemController#show | api
For routes of form api/item these sorts of lines:
GET|HEAD | api/item/{item} | lesson.show | App\Http\Controllers\Api\ItemController#show | web,auth,admin
I looked at routes.php which is holdover from Laravel 5.2 which is still in my folder structure, and we have these sorts of lines:
// Api
Route::group(['middleware' => ['api', 'auth', 'admin']], function () {
Route::group(array('prefix' => 'api'), function() {
RegisterResourceRoute('item', 'Item');
I think maybe I broke something when I upgraded from 5.2 to 5.3. Strangely enough, the routes defined by this routes.php are the ones of form api/item, and they work. The question now is what to do to get routes back to normal, so that all api routes are of form api/item and all have web,auth,admin?
ALso, for what it is worth (not sure if cacheing somehow influences my issue), there is .gitignore in the bootstrap/cache folder as well as all storage folders.
And here is cache.php:
return [
/*
|--------------------------------------------------------------------------
| Default Cache Store
|--------------------------------------------------------------------------
|
| This option controls the default cache connection that gets used while
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
*/
'default' => env('CACHE_DRIVER', 'file'),
/*
|--------------------------------------------------------------------------
| Cache Stores
|--------------------------------------------------------------------------
|
| Here you may define all of the cache "stores" for your application as
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
*/
'stores' => [
'apc' => [
'driver' => 'apc',
],
'array' => [
'driver' => 'array',
],
'database' => [
'driver' => 'database',
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache'),
],
'memcached' => [
'driver' => 'memcached',
'servers' => [
[
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
'port' => env('MEMCACHED_PORT', 11211),
'weight' => 100,
],
],
],
'redis' => [
'driver' => 'redis',
'connection' => 'default',
],
],
/*
|--------------------------------------------------------------------------
| Cache Key Prefix
|--------------------------------------------------------------------------
|
| When utilizing a RAM based store such as APC or Memcached, there might
| be other applications utilizing the same cache. So, we'll specify a
| value to get prefixed to all our keys so we can avoid collisions.
|
*/
'prefix' => 'laravel',
];
Ideas?
Thanks,
Brian
I suspect several things have happened, but in short check your bootstrap/cache folder. In it I hope you will find a file called routes.php and it has probably been committed into your repo and now you've pulled it down or maybe you even accidentally created it yourself when playing with artisan commands.
Canonically you would use php artisan route:clear but if your command line isn't working that won't work, however you should be ok to delete it.
If this is the case, it was created with php artisan route:cache but it is advisable only to use that on your production server (possibly as part of a deploymnet script or perhaps as a git hook.)
Ideally there would be a .gitignore (if you're using git) file in the cache folder to avoid this sort of thing being transmitted between different developers.
(Edit - this is only true for later versions of Laravel, but not 5.3 - the OP's version. I leave this here in case other people have the same problem.) It is also possible that someone (if you're working in a team) has done all this on purpose and just not communicated the changes. If so it's also possible that they have specifically set another path for route caching using the environment variable 'APP_ROUTES_CACHE' in which case you'll have to look there.
Sorry this is so complicated - but because of the flexibilty of laravel there are many different ways this could be happening. Please do try them all, though - this is almost certainly a caching issue.
I use these routes
Route::namespace('Panel\Admin')->prefix('admin')->group(function (){
$this->get('/', 'HomeController#index');
$this->namespace('Users')->prefix('users')->group(function (){
$this->get('/' , 'UserController#index')->name('users');
$this->delete('/{user}/destroy' , 'UserController#destroy')->name('users.destroy');
$this->get('/create' , 'UserController#create')->name('users.create');
$this->post('/store' , 'UserController#store')->name('users.store');
$this->get('/{user}/edit' , 'UserController#edit')->name('users.edit');
$this->patch('/{user}/update' , 'UserController#update')->name('users.update');
it works.
for example with php artisan route:list I have these:
admin/users | users
admin/users/create | users.create
admin/users/store | users.store
admin/users/{user}/destroy | users.destroy
But I want write the code short:
Route::namespace('Panel\Admin')->prefix('admin')->group(function (){
$this->get('/', 'HomeController#index');
$this->namespace('Users')->prefix('users')->group(function (){
$this->resource('/' , 'UserController');
$this->resource('/test' , 'UserController');
with php artisan route:list I have these:
admin/users | index
admin/users | store
admin/users/create | create
admin/users/{} | show
admin/users/{} | update
admin/users/{} | destroy
admin/users/{}/edit | edit
It's wrong. but for test is correct. for example:
admin/users/test | test.store
admin/users/test/{test}/edit | test.edit
what is my wrong?
$this->resource('user' , 'UserController');
That will create all of your standard routes for users.
You should not include the prefix user, since it will create that.
The first parameter of resource method should be a name for the resource,
so you should remove the users prefix and add users as name for the resource
$this->resource('users' , 'UserController');
you can read more about it on the documentation
I'm starting to implement a simple component based on angular 2 , but i get an issue tsconfig.json and import
Here is my structure
Root
|
node_modules
| |
| #angular
| |
| Core
| platform-broswer-dynamic
Script
|
Components
|
MyFirstComponent.ts
MyFirstComponentService.ts
Here is my code
import { bootstrap } from '#angular/platform-browser-dynamic'; // this line is ok
import { Component } from '#angular/core'; // this line is ok
import { FirstService } from 'Root/Script/Components/MyFirstComponentService'; // this line get error
#Component({
selector: 'firstcomponent',
template: '<div>My First Component</div>',
})
export class MyFirstComponent {
constructor(public abc : FirstService)
{
console.log(abc.doSomething());
}
}
bootstrap(MyFirstComponent, [FirstService]);
But i get error at
import { ABCService } from 'Root/Script/Components/MyFirstComponent';
Because some reason i don't want to use import { ABCService } from ./MyFirstComponent';
What config should i use in tsconfig.json to make three import work ? i've tried with rootDir but it not help
I'm using VS2015 , typescript 1.8.32
Thanks you very much!
You do not need to specify the full path, the service and the component are both in the same file location so you will need to use ./ like so:
import { FirstService } from './MyFirstComponentService';
EDIT: Going by your comment, I THINK you're asking this. Say you have another sub folder inside your Root, and another sub folder inside your Components, so you have this now:
Root
|
node_modules
| |
| #angular
| |
| Core
| platform-broswer-dynamic
Script
|
Components
| |
| MyFirstComponent.ts
| MyFirstComponentService.ts
| |
| navbar
| |
| navbar.component.ts
| navbar.component.html
|
Shared
|
authservice.component.ts
if you wanted to access the the navbar.component from inside that same file, you would use:
import { FirstService } from './navbar/navbar.component';
You would would need to specify that from the current folder, ./, go to the navbar folder, then get the component there.
Now if you wanted to access the authservice.component, you would do the following:
import { FirstService } from '../Shared/authservice.component';
The reason for this is that the Shared folder is located one folder higher than the current folder you're in, that's why you would use ../, this essentially takes you one folder "higher".
Does that explain it better? I just added random "common" components. Also maybe consider changing your folder structure, and naming your folder/components as lower case only.
use ./MyFirstComponent in place of that full path.. it work fine with that
I'm writing a program to test update scripts for Azure sql.
The idea is to
- first clone a database (or fill a clone with the source schema and content)
- then run the update script on the clone
Locally I have this working, but for azure I have the probem that I don't see any file names. If I restore one database to another on the same azure "server", don't I have to rename the data files during restore too?
For local restore I do this:
restore.Devices.AddDevice(settings.BackupFileName, DeviceType.File);
restore.RelocateFiles.Add(new RelocateFile("<db>", Path.Combine(settings.DataFileDirectory, settings.TestDatabaseName + ".mdf")));
restore.RelocateFiles.Add(new RelocateFile("<db>_log", Path.Combine(settings.DataFileDirectory, settings.TestDatabaseName + "_1.ldf")));
restore.SqlRestore(srv);
Is something similar required for cloning a database on azure?
Lots of Greetings!
Volker
You can create a database as a copy of [source]:
CREATE DATABASE database_name [ COLLATE collation_name ]
| AS COPY OF [source_server_name].source_database_name
{
(<edition_options> [, ...n])
}
<edition_options> ::=
{
MAXSIZE = { 100 MB | 500 MB | 1 | 5 | 10 | 20 | 30 … 150…500 } GB
| EDITION = { 'web' | 'business' | 'basic' | 'standard' | 'premium' }
| SERVICE_OBJECTIVE =
{ 'basic' | 'S0' | 'S1' | 'S2' | 'S3'
| 'P1' | 'P2' | 'P3' | 'P4'| 'P6' | 'P11'
| { ELASTIC_POOL(name = <elastic_pool_name>) } }
}
[;]