1: <?php
2: /**
3: * XOOPS Authentification base class
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
13: * @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
14: * @package kernel
15: * @subpackage auth
16: * @since 2.0
17: * @author Pierre-Eric MENUET <pemphp@free.fr>
18: */
19:
20: defined('XOOPS_ROOT_PATH') || exit('Restricted access');
21:
22: /**
23: *
24: * @package kernel
25: * @subpackage auth
26: * @description Authentification base class
27: * @author Pierre-Eric MENUET <pemphp@free.fr>
28: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
29: */
30: class XoopsAuth
31: {
32: public $_dao;
33: public $_errors;
34:
35: /**
36: * Authentication Service constructor
37: * @param XoopsDatabase $dao
38: */
39: public function __construct(XoopsDatabase $dao = null)
40: {
41: $this->_dao = $dao;
42: }
43:
44: /**
45: * @param string $uname
46: * @abstract need to be write in the dervied class
47: */
48: public function authenticate($uname)
49: {
50: $authenticated = false;
51:
52: return $authenticated;
53: }
54:
55: /**
56: * add an error
57: *
58: * @param int $err_no
59: * @param string $err_str error value to add
60: *
61: * @access public
62: */
63: public function setErrors($err_no, $err_str)
64: {
65: $this->_errors[$err_no] = trim($err_str);
66: }
67:
68: /**
69: * return the errors for this object as an array
70: *
71: * @return array an array of errors
72: * @access public
73: */
74: public function getErrors()
75: {
76: return $this->_errors;
77: }
78:
79: /**
80: * return the errors for this object as html
81: *
82: * @return string html listing the errors
83: * @access public
84: */
85: public function getHtmlErrors()
86: {
87: global $xoopsConfig;
88: $ret = '<br>';
89: if ($xoopsConfig['debug_mode'] == 1 || $xoopsConfig['debug_mode'] == 2) {
90: if (!empty($this->_errors)) {
91: foreach ($this->_errors as $errstr) {
92: $ret .= $errstr . '<br>';
93: }
94: } else {
95: $ret .= _NONE . '<br>';
96: }
97: $ret .= sprintf(_AUTH_MSG_AUTH_METHOD, $this->auth_method);
98: } else {
99: $ret .= _US_INCORRECTLOGIN;
100: }
101:
102: return $ret;
103: }
104: }
105: