如何在使用ckeditor插件pgrfilemanager上传时使用Zend_Auth验证用户 [英] how to use Zend_Auth to authenticate user when uploading using ckeditor plugin pgrfilemanager

查看:243
本文介绍了如何在使用ckeditor插件pgrfilemanager上传时使用Zend_Auth验证用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好好的人!

我有一个基于Zend Framework 1.11.12(从1.10.8升级)的Web应用程序(我的第一个类型)使用模块化方法文件夹结构所有模块都在 application / modules 下。我使用的Doctrine 1.2.4

I have a web application (my first of this type) based on Zend Framework 1.11.12 ( upgraded from 1.10.8) using "modular approach" folder structure i mean by that all the modules are under application/modules. i used Doctrine 1.2.4

我也使用文件夹中的所有第三方库, CKEditor PGRFilemanager 。 pgrfile管理器用于从管理面板将文件上传到ima​​ges文件夹。
这里是全局我的文件结构。

i also use library folder for all the third party libraries including ZF except 2: CKEditor and PGRFilemanager. pgrfile manager for uploading files to images folder from an admin panel. here is globally my file structure.

/application
    /configs
        application.ini
        routes.ini
    /layouts
        /scripts
            /partials
                  *.all_the_partials_files.phtml
            *.all_the_layouts.phtml
    /modules
         all_the_module_folders
    Boostrap.php
/logs
/library
    /Zend
    /Doctrine
    /SwiftMailer
    /Abra //where all my classes reside
        /Model
            User.php
            Role.php
            other_doctrine_entities_class
/public
    /javascript
    /css
    /images
        .htaccess // added an htaccess file here
    /fonts
    `/ckeditor`
        a_lot_of_files_including_php_files
        other_folders
        /plugins
            other_folders
            `/pgrfilemanager`
                /php
                    auth.php
                myconfig.php
                other_folders_and_files_including_php
    index.php
    .htaccess

在我开发这个网站的时候,我没有使用Zend_Acl,因此session_start()在 /public/ckeditor/plugins/pgrfilemanager/php/auth.php 工作正常一段时间,因为pgrfilemanager带有默认身份验证功能。但是一旦我开始使用Zend_Acl,我运行类__PHP_Incomplete_Class没有unserializer数组异常,当 session_start() ~~ / auth.php 文件。我最初认为这是由于事实,我没有使用 Zend_Session 但显然我是由于这个事实这里解释(如果错误感谢,请更正我)

At the point i was developing this site ,i wasn't using Zend_Acl so the session_start() in /public/ckeditor/plugins/pgrfilemanager/php/auth.php worked fine for some time since pgrfilemanager came with a default authentication feature. but once i started using Zend_Acl i run into issues like Class __PHP_Incomplete_Class has no unserializer Array exception when session_start() is called from the ~~/auth.php file . I initially thought it was due do the fact i wasn't using Zend_Session but apparently i was rather due to this fact explained here (correct me if am wrong thanks)

用它?感谢阅读

推荐答案

因为我发现了一个关于这个问题的解决方法,我想我会分享,也许我会得到更好的观点。

Since i found a workaround about this issue, i thought i would share, maybe i would get better perspective.

类的回答__PHP_Incomplete_Class没有unserializer数组现在清除了Session如何将格式设置为 unserialize 意味着php不得不知道存储在会话中的对象的定义。

The Answer for the Class __PHP_Incomplete_Class has no unserializer Array is clear now as Session does how which format to unserialize to meaning php had to know the definition of the object stored in the session.

根据文件结构,我创建了一个auth文件, myauth.php public / ckeditor / puglins / pgrfilemanager / userfiles 我将引用此路径 pgr / userdir

Based on the file structure i created an auth file say myauth.php in /public/ckeditor/puglins/pgrfilemanager/userfiles i will refer to this path is pgr/userdir

$path = realpath("../../../../library");
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require "Zend/Loader/Autoloader.php";

require_once 'Doctrine/Doctrine.php';
spl_autoload_register(array("Doctrine", "autoload"), true);
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace(array("Abra_"));
/*$p seem to be empty throwing error on Zend_Config_Ini but returns the config anyway.I never figured out
*/
$p = realpath("./../../../../application/configs/application.ini"); 
try {
    //     $config = parse_ini_file($p, "production");
    $config = new Zend_Config_Ini($p, "production");
    $conn = Doctrine_Manager::connection($config->doctrine->dsn);
    $user = new Abra_Model_User();
    $role = new Abra_Model_Role();
    $auth = Zend_Auth::getInstance();
    if(!$auth->hasIdentity()|| !in_array($auth->getIdentity()->Role->name,  array("superadmin","administrator")) ){
        die("Not authenticated");
    }
} catch (Exception $ex) {
*/
$p = realpath("./../../../../application/configs/application.ini"); 
try {
    //     $config = parse_ini_file($p, "production");
    $config = new Zend_Config_Ini($p, "production");
    $conn = Doctrine_Manager::connection($config->doctrine->dsn);
    $user = new Abra_Model_User();
    $role = new Abra_Model_Role();
    $auth = Zend_Auth::getInstance();
    if(!$auth->hasIdentity()|| !in_array($auth->getIdentity()->Role->name,  array("superadmin","administrator")) ){
        die("Not authenticated");
    }
} catch (Exception $ex) {

}

}

pgr / php / folders.php pgr / php / files.php i包含

$path = realpath("../../../../library");
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

。然后我包括 pgr / userfiles / myauth.php pgr / myconfig ,如下所示

at the top. then i included the pgr/userfiles/myauth.php in pgr/myconfig as shown below

include_once dirname(__FILE__) . '/userfiles/myauth.php';

我希望这会帮助别人。感谢

I hope this would help someone. thanks

这篇关于如何在使用ckeditor插件pgrfilemanager上传时使用Zend_Auth验证用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆