| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: |
|
| 19: |
|
| 20: | defined('XOOPS_ROOT_PATH') || exit('Restricted access');
|
| 21: |
|
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: |
|
| 30: | class XoopsAuthFactory
|
| 31: | {
|
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: |
|
| 44: | public static function getAuthConnection($uname)
|
| 45: | {
|
| 46: | static $auth_instance;
|
| 47: | if (!isset($auth_instance)) {
|
| 48: |
|
| 49: | $config_handler = xoops_getHandler('config');
|
| 50: | $authConfig = $config_handler->getConfigsByCat(XOOPS_CONF_AUTH);
|
| 51: |
|
| 52: | include_once $GLOBALS['xoops']->path('class/auth/auth.php');
|
| 53: |
|
| 54: | if (empty($authConfig['auth_method'])) {
|
| 55: | $xoops_auth_method = 'xoops';
|
| 56: | } else {
|
| 57: | $xoops_auth_method = $authConfig['auth_method'];
|
| 58: | }
|
| 59: |
|
| 60: | if (in_array($uname, $authConfig['ldap_users_bypass'])) {
|
| 61: | $xoops_auth_method = 'xoops';
|
| 62: | }
|
| 63: |
|
| 64: | $ret = include_once $GLOBALS['xoops']->path('class/auth/auth_' . $xoops_auth_method . '.php');
|
| 65: | if ($ret == false) {
|
| 66: | return false;
|
| 67: | }
|
| 68: |
|
| 69: | $class = 'XoopsAuth' . ucfirst($xoops_auth_method);
|
| 70: | if (!class_exists($class)) {
|
| 71: | $GLOBALS['xoopsLogger']->triggerError($class, _XO_ER_CLASSNOTFOUND, __FILE__, __LINE__, E_USER_ERROR);
|
| 72: |
|
| 73: | return false;
|
| 74: | }
|
| 75: | switch ($xoops_auth_method) {
|
| 76: | case 'xoops':
|
| 77: | $dao = XoopsDatabaseFactory::getDatabaseConnection();
|
| 78: | break;
|
| 79: | case 'ldap':
|
| 80: | $dao = null;
|
| 81: | break;
|
| 82: | case 'ads':
|
| 83: | $dao = null;
|
| 84: | break;
|
| 85: | }
|
| 86: | $auth_instance = new $class($dao);
|
| 87: | }
|
| 88: |
|
| 89: | return $auth_instance;
|
| 90: | }
|
| 91: | }
|
| 92: | |