Partial revert of 1948e4f501a18c5856cbe45caf09267c0020e036
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 12 Oct 2010 20:14:26 +0000 (14:14 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 12 Oct 2010 20:31:25 +0000 (14:31 -0600)
No idea why this was removed.  Broke session parsing.

framework/Core/lib/Horde/Core/Factory/SessionHandler.php

index 32362fd..b24a4ad 100644 (file)
@@ -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()
     {