
Public Member Functions | |
| getip () | |
| cookiesAccepted () | |
| setNew () | |
| rememberMe ($request) | |
| purge ($timeout=0) | |
Static Public Member Functions | |
| static | isAdminPresent () |
Public Attributes | |
| $session_id = null | |
| $time = null | |
| $userid = 0 | |
| $usertype = '' | |
| $username = '' | |
| $gid = 0 | |
| $guest = 1 | |
Protected Member Functions | |
| __construct () | |
| __clone () | |
| checkValidSession () | |
| setSessionData ($my) | |
| forceLogout ($exp) | |
Protected Attributes | |
| $_lifetime | |
| $_newsess = false | |
Static Protected Attributes | |
| static | $currentSession = null |
Private Member Functions | |
| saveOrphanData () | |
| updateTime () | |
Definition at line 56 of file aliroSession.php.
| aliroSession::__construct | ( | ) | [protected] |
Reimplemented in aliroUserSession, and aliroAdminSession.
Definition at line 68 of file aliroSession.php.
References aliroSessionData::getInstance().
00068 { 00069 $this->time = time(); 00070 ini_set('session.use_cookies', 1); 00071 ini_set('session.use_only_cookies', 1); 00072 session_name(md5('aliro_'.$this->_prefix.$this->getip().criticalInfo::getInstance()->absolute_path)); 00073 if (!session_id()) { 00074 $sh = aliroSessionData::getInstance(); 00075 session_set_save_handler(array($sh,'sess_open'), array($sh,'sess_close'), array($sh,'sess_read'), 00076 array($sh,'sess_write'), array($sh,'sess_destroy'), array($sh,'sess_gc')); 00077 session_start(); 00078 } 00079 }
| aliroSession::__clone | ( | ) | [protected] |
| aliroSession::getip | ( | ) |
Definition at line 85 of file aliroSession.php.
00085 { 00086 $ip = false; 00087 if (!empty($_SERVER['HTTP_CLIENT_IP'])) $ip = $_SERVER['HTTP_CLIENT_IP']; 00088 if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { 00089 $ips = explode (', ', $_SERVER['HTTP_X_FORWARDED_FOR']); 00090 if ($ip != false) { 00091 array_unshift($ips,$ip); 00092 $ip = false; 00093 } 00094 $count = count($ips); 00095 // Exclude IP addresses that are reserved for LANs 00096 for ($i = 0; $i < $count; $i++) { 00097 if (!preg_match("/^(10|172\.16|192\.168)\./i", $ips[$i])) { 00098 $ip = $ips[$i]; 00099 break; 00100 } 00101 } 00102 } 00103 if (false == $ip AND isset($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR']; 00104 return $ip; 00105 }
| aliroSession::cookiesAccepted | ( | ) |
| aliroSession::setNew | ( | ) |
| aliroSession::checkValidSession | ( | ) | [protected] |
Definition at line 116 of file aliroSession.php.
References saveOrphanData(), T_(), and updateTime().
Referenced by aliroAdminSession::getInstance(), and aliroUserSession::getInstance().
00116 { 00117 if ($this->session_id = session_id()) { 00118 // We try to update the time stamp in the matching record of the session table 00119 $result = $this->updateTime(); 00120 if (!$result) { 00121 setcookie('aliroCookieCheck', 'A', time()+365*24*60*60, '/'); 00122 $this->saveOrphanData(); 00123 $this->session_id = ''; 00124 } 00125 return $result; 00126 } 00127 else { 00128 trigger_error(T_('No session ID found, although aliroSession has been instantiated')); 00129 return false; 00130 } 00131 }
| aliroSession::saveOrphanData | ( | ) | [private] |
Definition at line 133 of file aliroSession.php.
References $_REQUEST, and aliroCoreDatabase::getInstance().
Referenced by checkValidSession().
00133 { 00134 if (isset($_REQUEST['option']) AND ('login' == $_REQUEST['option'] OR 'logout' == $_REQUEST['option'])) return; 00135 $orphandata['get'] = $_GET; 00136 $orphandata['post'] = $_POST; 00137 $orphanstring = base64_encode(serialize($orphandata)); 00138 $database = aliroCoreDatabase::getInstance(); 00139 $database->doSQL("INSERT INTO #__orphan_data VALUES ('$this->session_id', '$orphanstring') ON DUPLICATE KEY UPDATE orphandata = '$orphanstring'"); 00140 setcookie ('aliroOrphanData', $this->session_id, time()+300, '/'); 00141 }
| aliroSession::rememberMe | ( | $ | request | ) |
Definition at line 143 of file aliroSession.php.
References aliroUserAuthenticator::getInstance(), aliroUser::getInstance(), and T_().
00143 { 00144 if (!$this->_newsess) return; 00145 $user = aliroUser::getInstance(); 00146 if (0 == $user->id AND $usercookie = isset($_COOKIE['usercookie']) ? $_COOKIE['usercookie'] : null) { 00147 // Remember me cookie exists. Login with usercookie information if all present. 00148 if (!empty($usercookie['username']) AND !empty($usercookie['password'])) { 00149 // If the login is successful, then the session data will be updated 00150 // In any case, the return will be set either to user data or to null 00151 $message = aliroUserAuthenticator::getInstance()->systemLogin ($usercookie['username'], $usercookie['password'], 1); 00152 if ($message) $request->setErrorMessage(T_('Remember Me login failed - incorrect username-password combination'), _ALIRO_ERROR_WARN); 00153 else $user->reset(); 00154 } 00155 } 00156 }
| aliroSession::updateTime | ( | ) | [private] |
Definition at line 158 of file aliroSession.php.
References aliroCoreDatabase::getInstance(), and aliro::getInstance().
Referenced by checkValidSession().
00158 { 00159 if (aliro::getInstance()->installed) { 00160 $database = aliroCoreDatabase::getInstance(); 00161 $past = $this->time - $this->_lifetime; 00162 $database->doSQL("UPDATE #__session SET time = '$this->time', marker = marker+1 WHERE session_id = '$this->session_id' AND isadmin = $this->isadmin AND time > $past"); 00163 return ($database->getAffectedRows()) ? true : false; 00164 } 00165 return false; 00166 }
| aliroSession::setSessionData | ( | $ | my | ) | [protected] |
Definition at line 168 of file aliroSession.php.
References $_REQUEST, aliroCoreDatabase::getInstance(), int(), and purge().
Referenced by aliroAdminSession::setNewUserData(), and aliroUserSession::setNewUserData().
00168 { 00169 $database = aliroCoreDatabase::getInstance(); 00170 if ($my->id AND !empty($_COOKIE['aliroOrphanData'])) { 00171 $database->setQuery("SELECT orphandata FROM #__orphan_data WHERE session_id = '{$_COOKIE['aliroOrphanData']}'"); 00172 $orphanstring = $database->loadResult(); 00173 if (!empty($orphanstring)) { 00174 $orphandata = unserialize(base64_decode($orphanstring)); 00175 foreach (array_keys($_GET) as $key) unset($_REQUEST[$key]); 00176 foreach (array_keys($_POST) as $key) unset($_REQUEST[$key]); 00177 $_GET = $orphandata['get']; 00178 $_POST = $orphandata['post']; 00179 foreach ($_GET as $key=>$value) $_REQUEST[$key] = $value; 00180 foreach ($_POST as $key=>$value) $_REQUEST[$key] = $value; 00181 // $database->doSQL("DELETE FROM #__orphan_data WHERE session_id = '{$_COOKIE['aliroOrphanData']}'"); 00182 setcookie('aliroOrphanData', 'A', time()-7*24*60*60, '/'); 00183 } 00184 } 00185 session_regenerate_id(); 00186 $this->session_id = session_id(); 00187 $this->httphost = $_SERVER['HTTP_HOST']; 00188 $this->servername = $_SERVER['SERVER_NAME']; 00189 $this->ipaddress = getenv('REMOTE_ADDR'); 00190 $_SESSION["aliro_{$this->_prefix}id"] = $this->userid = $my->id; 00191 $_SESSION["aliro_{$this->_prefix}name"] = $my->name; 00192 $_SESSION["aliro_{$this->_prefix}username"] = $this->username = $my->username; 00193 $_SESSION["aliro_{$this->_prefix}email"] = $my->email; 00194 $_SESSION["aliro_{$this->_prefix}sendEmail"] = $my->sendEmail; 00195 $_SESSION["aliro_{$this->_prefix}type"] = $this->usertype = $my->usertype; 00196 $_SESSION["aliro_{$this->_prefix}gid"] = $this->gid = $my->gid; 00197 $_SESSION["aliro_{$this->_prefix}logintime"] = $this->time = time(); 00198 if (!isset($_SESSION["aliro_{$this->_prefix}state"])) $_SESSION["aliro_{$this->_prefix}state"] = array(); 00199 $this->userid = (int) $this->userid; 00200 $this->gid = (int) $this->gid; 00201 $database->insertObject('#__session', $this); 00202 $this->purge(); 00203 }
| aliroSession::purge | ( | $ | timeout = 0 |
) |
Definition at line 205 of file aliroSession.php.
References forceLogout(), aliroSessionData::getInstance(), aliroCoreDatabase::getInstance(), and aliro::getInstance().
Referenced by setSessionData().
00205 { 00206 // Note purge only records on the current side - admin or user - because lifetime may be different 00207 if (aliro::getInstance()->installed) { 00208 $past = time() - ($timeout ? $timeout : $this->_lifetime); 00209 $database = aliroCoreDatabase::getInstance(); 00210 $database->setQuery("SELECT session_id, username, isadmin FROM #__session WHERE (time < $past) AND isadmin = $this->isadmin"); 00211 $expired = $database->loadObjectList(); 00212 if ($expired) foreach ($expired as $exp) { 00213 $sessions[] = $exp->session_id; 00214 $this->forceLogout ($exp); 00215 } 00216 if (isset($sessions)) { 00217 $sessionlist = implode ("','", $sessions); 00218 $database->doSQL("DELETE LOW_PRIORITY FROM `#__session` WHERE session_id IN('$sessionlist')"); 00219 } 00220 aliroSessionData::getInstance()->sess_destroy_orphans(); 00221 } 00222 }
| aliroSession::forceLogout | ( | $ | exp | ) | [protected] |
Reimplemented in aliroUserSession.
Definition at line 224 of file aliroSession.php.
Referenced by purge().
| static aliroSession::isAdminPresent | ( | ) | [static] |
Definition at line 228 of file aliroSession.php.
References aliroCoreDatabase::getInstance().
Referenced by aliroUserRequest::doControl().
00228 { 00229 if (isset($_COOKIE['aliroAdminSession'])) $admin_session = $_COOKIE['aliroAdminSession']; 00230 else return false; 00231 $database = aliroCoreDatabase::getInstance(); 00232 $database->setQuery("SELECT COUNT(session_id) FROM #__session WHERE session_id = '$admin_session' AND isadmin = 1"); 00233 return $database->loadResult() ? true : false; 00234 }
aliroSession::$currentSession = null [static, protected] |
Definition at line 57 of file aliroSession.php.
| aliroSession::$session_id = null |
Definition at line 58 of file aliroSession.php.
| aliroSession::$time = null |
Definition at line 59 of file aliroSession.php.
| aliroSession::$userid = 0 |
Definition at line 60 of file aliroSession.php.
| aliroSession::$usertype = '' |
Definition at line 61 of file aliroSession.php.
| aliroSession::$username = '' |
Definition at line 62 of file aliroSession.php.
| aliroSession::$gid = 0 |
Definition at line 63 of file aliroSession.php.
| aliroSession::$guest = 1 |
Definition at line 64 of file aliroSession.php.
aliroSession::$_lifetime [protected] |
Definition at line 65 of file aliroSession.php.
aliroSession::$_newsess = false [protected] |
Definition at line 66 of file aliroSession.php.
1.5.5