dpy83214 2012-08-19 08:44
浏览 52
已采纳

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

Hello Good People !!

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

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

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)

How to use it? Thanks for reading

  • 写回答

1条回答 默认 最新

  • dsf55s1233 2012-08-21 07:03
    关注

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

    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.

    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) {
    
    }
    
    }
    

    in pgr/php/folders.php and pgr/php/files.php i included the

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

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?