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

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

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看