/class/xml/rpc/class/auth/authfactory.php

https://gitlab.com/VoyaTrax/vtCMS · PHP · 83 lines · 36 code · 4 blank · 43 comment · 5 complexity · f4d38cbd6681704c5e43595610f3ef04 MD5 · raw file

  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. * Get a reference to the only instance of authentication class
  39. *
  40. * if the class has not been instantiated yet, this will also take
  41. * care of that
  42. *
  43. * @static
  44. * @return object Reference to the only instance of authentication class
  45. */
  46. function &getAuthConnection($uname)
  47. {
  48. static $auth_instance;
  49. if (!isset($auth_instance)) {
  50. $config_handler =& xoops_gethandler('config');
  51. $authConfig =& $config_handler->getConfigsByCat(XOOPS_CONF_AUTH);
  52. require_once XOOPS_ROOT_PATH.'/class/auth/auth.php';
  53. if (empty($authConfig['auth_method'])) { // If there is a config error, we use xoops
  54. $xoops_auth_method = 'xoops';
  55. } else {
  56. $xoops_auth_method = $authConfig['auth_method'];
  57. }
  58. // Verify if uname allow to bypass LDAP auth
  59. if (in_array($uname, $authConfig['ldap_users_bypass'])) $xoops_auth_method = 'xoops';
  60. $file = XOOPS_ROOT_PATH . '/class/auth/auth_' . $xoops_auth_method . '.php';
  61. require_once $file;
  62. $class = 'XoopsAuth' . ucfirst($xoops_auth_method);
  63. switch ($xoops_auth_method) {
  64. case 'xoops' :
  65. $dao =& $GLOBALS['xoopsDB'];
  66. break;
  67. case 'ldap' :
  68. $dao = null;
  69. break;
  70. case 'ads' :
  71. $dao = null;
  72. break;
  73. }
  74. $auth_instance = new $class($dao);
  75. }
  76. return $auth_instance;
  77. }
  78. }
  79. ?>