Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 到特定url的LAVEL路由筛选器_Php_Routing_Ckeditor_Laravel - Fatal编程技术网

Php 到特定url的LAVEL路由筛选器

Php 到特定url的LAVEL路由筛选器,php,routing,ckeditor,laravel,Php,Routing,Ckeditor,Laravel,我正在尝试将路由筛选器应用于特定url。因此,我的文件位于公共目录下: /public/js/kcfinder/browse.php 我的过滤器: Route::filter('admin', function () { if (!Sentry::check()) { // if not logged in, redirect to login return Redirect::to_route('admin_login'); }

我正在尝试将路由筛选器应用于特定url。因此,我的文件位于公共目录下:

/public/js/kcfinder/browse.php
我的过滤器:

Route::filter('admin', function ()
{

    if (!Sentry::check())
    {
        // if not logged in, redirect to login

        return Redirect::to_route('admin_login');
    }
    elseif (!Sentry::user()->has_access('is_admin'))
    {
        //logout
        Sentry::logout();
        // has no access
        return View::make('error.access_error');
    }

});
最后,我的模式:

Route::filter('pattern: js/kcfinder/*', 'admin');
如果我尝试访问

/public/js/kcfinder/browse.php
这条规则行不通

我可以看到文件的全部内容

如果我试图通过

/public/js/kcfinder/blahblah.php
过滤器工作得很好。因为没有名为

blahblah.php
在目录下


任何帮助都会非常好

这是因为您的
.htaccess
文件指出,如果请求URI与现有文件匹配,则不要重写,只需按原样显示/执行文件

因此,您有两种选择:

您可以在
.htaccess
文件中创建必要的过滤器,以便某些目录中的文件总是被重写并发送到
index.php

RewriteCond %{REQUEST_URI} ^/js/kcfinder
RewriteRule \.php$ index.php [L,QSA]
此条件和规则集需要置于检查文件和目录的条件之上


或者,您可以在Laravel中创建经过身份验证的路由,手动获取和执行文件。(不建议这样做,因为您必须使用
eval()

我一直在尝试将ckfinder集成到Laravels auth系统中,最终发现这太费劲了。这可能是可能的,但我的解决方案很简单。在呈现Ckeditor小部件时,我在PHP中设置了一个普通的旧会话变量,然后在ckfinders auth check例程中检查会话变量是否存在

// When rendering widget
session_start();
$_SESSION['enable_ckeditor'] = true;

// In ckfinder somewhere
session_start();
return isset( $_SESSION['enable_ckeditor'] ) ?: $_SESSION['enable_ckeditor'];

我也用同样的方法修复了。刚刚添加了session start to start.php,并在使用eventlistener监听所有视图事件之后。。。