如何在使用ckeditor插件pgrfilemanager上传时使用Zend_Auth对用户进行身份验证

时间:2012-08-19 08:44:04

标签: php zend-framework ckeditor security

Hello Good People !!

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

除了2:libraryPGRFilemanager之外,我还对包括ZF在内的所有第三方库使用CKEditor文件夹。用于从管理面板将文件上载到images文件夹的pgrfile管理器。 这是全局我的文件结构。

/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,因此/public/ckeditor/plugins/pgrfilemanager/php/auth.php中的session_start()工作正常一段时间,因为pgrfilemanager带有默认的身份验证功能。但是一旦我开始使用Zend_Acl,当从Class __PHP_Incomplete_Class has no unserializer Array文件中调用session_start()时,我会遇到~~/auth.php异常等问题。我最初认为这是因为我没有使用Zend_Session,但显然我是因为这个事实explained here(如果我错了,请纠正我)

如何使用它?感谢您的阅读

1 个答案:

答案 0 :(得分:1)

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

Class __PHP_Incomplete_Class has no unserializer Array的答案现在很明显,因为Session确定了unserialize的格式,意味着php必须知道会话中存储的对象的定义。

根据文件结构,我在myauth.php中创建了一个auth文件/public/ckeditor/puglins/pgrfilemanager/userfiles,我将引用此路径为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.phppgr/php/files.php中包含了

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

在顶部。然后我将pgr/userfiles/myauth.php包含在pgr/myconfig中,如下所示

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

我希望这会对某人有所帮助。感谢