1: <?php
2: /**
3: * The Horde_Token:: class provides a common abstracted interface into the
4: * various token generation mediums. It also includes all of the
5: * functions for retrieving, storing, and checking tokens.
6: *
7: * Copyright 1999-2012 Horde LLC (http://www.horde.org/)
8: *
9: * See the enclosed file COPYING for license information (LGPL). If you
10: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
11: *
12: * @author Max Kalika <max@horde.org>
13: * @author Chuck Hagenbuch <chuck@horde.org>
14: * @category Horde
15: * @package Token
16: */
17: class Horde_Token
18: {
19: /**
20: * Generates a connection id and returns it.
21: *
22: * @param string $seed A unique ID to be included in the token.
23: *
24: * @return string The generated id string.
25: */
26: static public function generateId($seed = '')
27: {
28: return Horde_Url::uriB64Encode(pack('H*', hash('sha1', uniqid(mt_rand()) . $seed . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''))));
29: }
30:
31: }
32: