Changeset 745
- Timestamp:
- May 31, 2021 1:50:48 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Auth_Simple.inc.php
r708 r745 35 35 * @param optional array $params A hash containing parameters. 36 36 */ 37 function __construct($namespace='')37 public function __construct($namespace='') 38 38 { 39 39 $app =& App::getInstance(); … … 60 60 * @return bool true on success, false on failure 61 61 */ 62 function setParam($params)62 public function setParam($params) 63 63 { 64 64 if (isset($params) && is_array($params)) { … … 75 75 * @return mixed Configured parameter value. 76 76 */ 77 function getParam($param)77 public function getParam($param) 78 78 { 79 79 $app =& App::getInstance(); … … 94 94 * @param mixed $val Value to set variable to. 95 95 */ 96 function set($key, $val)96 public function set($key, $val) 97 97 { 98 98 if (!isset($_SESSION['_auth_simple'][$this->_ns]['user_data'])) { … … 110 110 * @return mixed Value stored in session. 111 111 */ 112 function get($key, $default='')112 public function get($key, $default='') 113 113 { 114 114 if (isset($_SESSION['_auth_simple'][$this->_ns][$key])) { … … 126 126 * @access public 127 127 */ 128 function clear()128 public function clear() 129 129 { 130 130 $_SESSION['_auth_simple'][$this->_ns] = array('authenticated' => false); … … 141 141 * @since 04 Mar 2009 21:07:33 142 142 */ 143 function login($user_id, $password, $callback)143 public function login($user_id, $password, $callback) 144 144 { 145 145 global $acct; … … 174 174 * @since 04 Mar 2009 21:07:33 175 175 */ 176 function createSession($user_id)176 public function createSession($user_id) 177 177 { 178 178 $app =& App::getInstance(); … … 200 200 * @since 04 Mar 2009 21:10:41 201 201 */ 202 function isLoggedIn()202 public function isLoggedIn($update_last_access_datetime=true) 203 203 { 204 204 $app =& App::getInstance(); … … 212 212 ) { 213 213 // User is authenticated! 214 $_SESSION['_auth_simple'][$this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s'); 215 return true; 214 if ($update_last_access_datetime) { 215 $_SESSION['_auth_simple'][$this->_ns]['last_access_datetime'] = date('Y-m-d H:i:s'); 216 } 217 $seconds_until_login_timeout = max(0, $this->_params['login_timeout'] - $result['seconds_since_last_login']); 218 $seconds_until_idle_timeout = max(0, $this->_params['idle_timeout'] - $result['seconds_since_last_access']); 219 $session_expiry_seconds = min($seconds_until_login_timeout, $seconds_until_idle_timeout); 220 $app->logMsg(sprintf('Returning true login status for user_id %s (session expires in %s seconds)', $_SESSION['_auth_simple'][$this->_ns]['user_id'], $session_expiry_seconds), LOG_DEBUG, __FILE__, __LINE__); 221 return $session_expiry_seconds; 216 222 } else if (isset($_SESSION['_auth_simple'][$this->_ns]['authenticated']) && true === $_SESSION['_auth_simple'][$this->_ns]['authenticated']) { 217 223 // User is authenticated, but login has expired. … … 250 256 * @access public 251 257 */ 252 function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)258 public function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null) 253 259 { 254 260 $app =& App::getInstance(); … … 272 278 * @return string Empty string 273 279 */ 274 function getUsername($null=null)280 public function getUsername($null=null) 275 281 { 276 282 return ''; 277 283 } 278 284 } 279 280 ?>
Note: See TracChangeset
for help on using the changeset viewer.