From e69d55f2aea69e68acc6ba1017e2758f5399843e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 12 Oct 2010 14:14:26 -0600 Subject: [PATCH] Partial revert of 1948e4f501a18c5856cbe45caf09267c0020e036 No idea why this was removed. Broke session parsing. --- .../Core/lib/Horde/Core/Factory/SessionHandler.php | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/framework/Core/lib/Horde/Core/Factory/SessionHandler.php b/framework/Core/lib/Horde/Core/Factory/SessionHandler.php index 32362fda3..b24a4ad88 100644 --- a/framework/Core/lib/Horde/Core/Factory/SessionHandler.php +++ b/framework/Core/lib/Horde/Core/Factory/SessionHandler.php @@ -86,6 +86,46 @@ class Horde_Core_Factory_SessionHandler } /** + * Reads session data to determine if it contains Horde authentication + * credentials. + * + * @param string $session_data The session data. + * + * @return array An array of the user's sesion information if + * authenticated or false. The following information is + * returned: userid, timestamp, remoteAddr, browser, apps. + */ + public function readSessionData($session_data) + { + if (empty($session_data) || + (($pos = strpos($session_data, 'horde_auth|')) === false)) { + return false; + } + + $pos += 11; + $endpos = $pos + 1; + + while ($endpos !== false) { + $endpos = strpos($session_data, '|', $endpos); + $data = @unserialize(substr($session_data, $pos, $endpos)); + if (is_array($data)) { + return empty($data) + ? false + : array( + 'apps' => empty($data['app']) ? array('horde') : array_keys($data['app']), + 'browser' => $data['browser'], + 'remoteAddr' => $data['remoteAddr'], + 'timestamp' => $data['timestamp'], + 'userid' => $data['userId'] + ); + } + ++$endpos; + } + + return false; + } + + /** */ public function getModified() { -- 2.11.0