home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / class / auth / authfactory.php < prev    next >
Encoding:
PHP Script  |  2007-09-09  |  3.6 KB  |  83 lines

  1. <?php
  2. // $Id: authfactory.php 1029 2007-09-09 03:49:25Z phppp $
  3. // authfactory.php - Authentification class factory
  4. //  ------------------------------------------------------------------------ //
  5. //                XOOPS - PHP Content Management System                      //
  6. //                    Copyright (c) 2000 XOOPS.org                           //
  7. //                       <http://www.xoops.org/>                             //
  8. //  ------------------------------------------------------------------------ //
  9. //  This program is free software; you can redistribute it and/or modify     //
  10. //  it under the terms of the GNU General Public License as published by     //
  11. //  the Free Software Foundation; either version 2 of the License, or        //
  12. //  (at your option) any later version.                                      //
  13. //                                                                           //
  14. //  You may not change or alter any portion of this comment or credits       //
  15. //  of supporting developers from this source code or any supporting         //
  16. //  source code which is considered copyrighted (c) material of the          //
  17. //  original comment or credit authors.                                      //
  18. //                                                                           //
  19. //  This program is distributed in the hope that it will be useful,          //
  20. //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
  21. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
  22. //  GNU General Public License for more details.                             //
  23. //                                                                           //
  24. //  You should have received a copy of the GNU General Public License        //
  25. //  along with this program; if not, write to the Free Software              //
  26. //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
  27. //  ------------------------------------------------------------------------ //
  28. /**
  29.  * @package     kernel
  30.  * @subpackage  auth
  31.  * @description    Authentification class factory
  32.  * @author        Pierre-Eric MENUET    <pemphp@free.fr>
  33.  * @copyright    copyright (c) 2000-2005 XOOPS.org
  34.  */
  35. class XoopsAuthFactory
  36. {
  37.  
  38.     /**
  39.      * Get a reference to the only instance of authentication class
  40.      * 
  41.      * if the class has not been instantiated yet, this will also take 
  42.      * care of that
  43.      * 
  44.      * @static
  45.      * @return      object  Reference to the only instance of authentication class
  46.      */
  47.     function &getAuthConnection($uname)
  48.     {
  49.         static $auth_instance;        
  50.         if (!isset($auth_instance)) {
  51.             $config_handler =& xoops_gethandler('config');    
  52.             $authConfig =& $config_handler->getConfigsByCat(XOOPS_CONF_AUTH);            
  53.             require_once XOOPS_ROOT_PATH.'/class/auth/auth.php';
  54.             if (empty($authConfig['auth_method'])) { // If there is a config error, we use xoops
  55.                 $xoops_auth_method = 'xoops';
  56.             } else {
  57.                 $xoops_auth_method = $authConfig['auth_method'];
  58.             }
  59.             // Verify if uname allow to bypass LDAP auth 
  60.             if (in_array($uname, $authConfig['ldap_users_bypass'])) $xoops_auth_method = 'xoops';
  61.             $file = XOOPS_ROOT_PATH . '/class/auth/auth_' . $xoops_auth_method . '.php';            
  62.             require_once $file;
  63.             $class = 'XoopsAuth' . ucfirst($xoops_auth_method);
  64.             switch ($xoops_auth_method) {
  65.                 case 'xoops' :
  66.                     $dao =& $GLOBALS['xoopsDB'];
  67.                     break;
  68.                 case 'ldap'  : 
  69.                     $dao = null;
  70.                     break;
  71.                 case 'ads'  : 
  72.                     $dao = null;
  73.                     break;
  74.  
  75.             }
  76.             $auth_instance = new $class($dao);
  77.         }
  78.         return $auth_instance;
  79.     }
  80.  
  81. }
  82.  
  83. ?>