static public function embedCode($options)
{
if (empty($options['container'])) {
- $domid = md5(uniqid());
+ $domid = uniqid();
$options['container'] = $domid;
} else {
$domid = $options['container'];
} catch (Ansel_Exception $e) {
$error = sprintf(_("The gallery \"%s\" couldn't be created: %s"), $gallery_name, $e->getMessage());
Horde::logMessage($error, 'ERR');
- }
+ }
} else {
if (empty($galleryId) && $prefs->getValue('autoname')) {
- $galleryId = md5(microtime());
+ $galleryId = strval(new Horde_Support_Uuid());
}
if (!$gallery_name) {
$gallery_name = _("Untitled");
*/
function _addAccount($number, $type, $name, $eo, $desc, $closed)
{
- $accountId = md5(uniqid(mt_rand(), true));
+ $accountId = strval(new Horde_Support_Uuid());
$query = sprintf(
'INSERT INTO %s (account_id, account_owner, account_number, account_type, ' .
*/
function _addPosting($type, $date, $asset, $account, $eo, $amount, $desc)
{
- $postingId = md5(uniqid(mt_rand(), true));
+ $postingId = strval(new Horde_Support_Uuid());
$query = sprintf(
'INSERT INTO %s (posting_id, posting_owner, posting_type, posting_date, ' .
function execute()
{
// Create new share.
- $ledger = $GLOBALS['fima_shares']->newShare(md5(microtime()));
+ $ledger = $GLOBALS['fima_shares']->newShare(strval(new Horde_Support_Uuid()));
if (is_a($ledger, 'PEAR_Error')) {
return $ledger;
}
* Add group
*
* @param string $group Group name
+ * @throws Horde_Share_Exception
*/
public function addGroup($name)
{
$GLOBALS['folks_shares'] = $GLOBALS['injector']->getInstance('Horde_Share')->getScope();
- $share = $GLOBALS['folks_shares']->newShare(hash('md5', microtime()));
- if ($share instanceof PEAR_Error) {
- return $share;
- }
+ $share = $GLOBALS['folks_shares']->newShare(strval(new Horde_Support_Uuid()));
$share->set('name', $name);
$result = $GLOBALS['folks_shares']->addShare($share);
- if ($result instanceof PEAR_Error) {
- return $result;
- }
return $share->getId();
}
}
if (!empty($url)) {
- header('Location: ' . Horde_Util::addParameter($url, 'unique',
- md5(microtime()), false));
+ $url = new Horde_Url($url);
+ header('Location: ' . strval($url->unique()->setRaw(true)));
}
}
switch ($node->tagName) {
case 'configdescription':
if (empty($name)) {
- $name = hash('md5', uniqid(mt_rand(), true));
+ $name = uniqid(mt_rand());
}
$conf[$name] = array(
case 'configheader':
if (empty($name)) {
- $name = hash('md5', uniqid(mt_rand(), true));
+ $name = uniqid(mt_rand());
}
$conf[$name] = array(
'_type' => 'text',
'required' => true,
'desc' => $desc,
- 'default' => $this->_default($curctx, sha1(uniqid(mt_rand(), true))),
+ 'default' => $this->_default($curctx, strval(new Horde_Support_Uuid())),
'is_default' => $this->_isDefault($curctx, $this->_getNodeOnlyText($node))
);
break;
break;
case 'configtab':
- $key = hash('md5', uniqid(mt_rand(), true));
+ $key = uniqid(mt_rand());
$conf[$key] = array(
'tab' => $name,
break;
case 'configplaceholder':
- $conf[hash('md5', uniqid(mt_rand(), true))] = 'placeholder';
+ $conf[uniqid(mt_rand())] = 'placeholder';
break;
default:
{
$varname = $var->getVarName();
$varvalue = $vars->get($varname);
- $fieldId = $this->_genID(md5(uniqid(rand(), true)), false) . 'id';
+ $fieldId = $this->_genID(uniqid(mt_rand()), false) . 'id';
$html = '
<script type="text/javascript">
var obrowserWindowName;
<channel>pear.horde.org</channel>
</package>
<package>
+ <name>Support</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>Url</name>
<channel>pear.horde.org</channel>
</package>
{
$varname = $var->getVarName();
$varvalue = $vars->get($varname);
- $fieldId = 'obrowser_' . hash('md5', uniqid(rand(), true));
+ $fieldId = 'obrowser_' . uniqid(mt_rand());
$html = '
<script type="text/javascript">
var obrowserWindowName;
{
global $conf;
- $hash = base_convert(microtime() . mt_rand(), 10, 36);
+ $hash = base_convert(strval(new Horde_Support_Uuid()), 10, 36);
$pref = @unserialize($this->_prefs->getValue('confirm_email', false));
$pref = $pref
// a little naive, this sequence *might* be part of the content
// but it's really not likely and rather expensive to check
- $this->multipart_separator = "SEPARATOR_".md5(microtime());
+ $this->multipart_separator = "SEPARATOR_" . uniqid(mt_rand());
// generate HTTP header
header("Content-type: multipart/byteranges; boundary=".$this->multipart_separator);
$key = $_COOKIE[$keyname . '_key'];
$set = false;
} else {
- $key = $_COOKIE[$keyname . '_key'] = hash('md5', uniqid());
+ $key = $_COOKIE[$keyname . '_key'] = uniqid(mt_rand());
}
} else {
$key = session_id();
// Generate an id (suid). It's also possible to use a database
// generated primary key here.
- $suid = $this->_generateID();
+ $suid = strval(new Horde_Support_Uuid());
$created_ts = $this->getCurrentTimeStamp();
$r = $this->_db->exec(
}
/**
- * Generates a unique ID used as suid
- *
- * @return string A unique ID.
- */
- function _generateID()
- {
- return date('YmdHis') . '.'
- . substr(str_pad(base_convert(microtime(), 10, 36),
- 16,
- uniqid(mt_rand()),
- STR_PAD_LEFT),
- -16)
- . '@'
- . (!empty($_SERVER['SERVER_NAME'])
- ? $_SERVER['SERVER_NAME']
- : 'localhost');
- }
-
- /**
* Checks if the parameter is a PEAR_Error object and if so logs the
* error.
*
// Generate an id (suid). It's also possible to use a database
// generated primary key here. */
- $suid = $this->_generateID();
+ $suid = strval(new Horde_Support_Uuid());
$created_ts = $this->getCurrentTimeStamp();
$r = $this->_db->exec(
<min>1.4.0b1</min>
</pearinstaller>
<package>
+ <name>Support</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>XML_WBXML</name>
<channel>pear.horde.org</channel>
</package>
*/
static public function generateId($seed = '')
{
- return Horde_Url::uriB64Encode(pack('H*', sha1(uniqid(mt_rand(), true) . $seed . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''))));
+ return Horde_Url::uriB64Encode(pack('H*', hash('sha1', uniqid(mt_rand()) . $seed . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''))));
}
}
/* Get the first 8 characters of a random string to use as a temporary
directory name. */
do {
- $new_dir = $temp_dir . '/' . substr(base_convert(mt_rand() . microtime(), 10, 36), 0, 8);
+ $new_dir = $temp_dir . '/' . substr(base_convert(uniqid(mt_rand()), 10, 36), 0, 8);
} while (file_exists($new_dir));
$old_umask = umask(0000);
// Default values.
$requiredAttributes = array();
$requiredAttributes['DTSTAMP'] = time();
- $requiredAttributes['UID'] = $this->_exportDateTime(time())
- . substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16)
- . '@' . (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost');
+ $requiredAttributes['UID'] = strval(new Horde_Support_Uuid());
$method = !empty($this->_container) ?
$this->_container->getAttribute('METHOD') : 'PUBLISH';
<channel>pear.horde.org</channel>
</package>
<package>
+ <name>Support</name>
+ <channel>pear.horde.org</channel>
+ </package>
+ <package>
<name>Util</name>
<channel>pear.horde.org</channel>
</package>
public function setSelectlist($selectid = '', $files = array())
{
if (empty($selectid)) {
- $selectid = uniqid(mt_rand(), true);
+ $selectid = uniqid(mt_rand());
}
if (count($files) > 0) {
/* Create a new cache ID if one does not already exist. */
$cacheid = Horde_Util::getFormData('cacheid');
if (empty($cacheid)) {
- $cacheid = uniqid(mt_rand(), true);
+ $cacheid = uniqid(mt_rand());
$_SESSION['gollem']['selectlist'][$cacheid] = array();
}
if ($form->validate()) {
$form->getInfo($vars, $info);
if (empty($info['alarm'])) {
- $info['alarm'] = date('YmdHis') . '.'
- . substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16)
- . '@' . $GLOBALS['conf']['server']['name'];
+ $info['alarm'] = strval(new Horde_Support_Uuid());
}
$params = array();
function view(url, partid)
{
param = "menubar=yes,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes";
- window.open(url, '<?php echo base_convert(microtime(), 10, 36) ?>' + tr(partid), param);
+ window.open(url, '<?php echo uniqid() ?>' + tr(partid), param);
}
// -->
$data .= sprintf("Application: %s\n", 'txfax');
$data .= sprintf("Data: %s|caller\n", $filename);
- $outfile = sprintf("%s/%s.call", $conf['fax']['params']['outgoing'], md5(microtime()));
+ $outfile = sprintf("%s/%s.call", $conf['fax']['params']['outgoing'], strval(new Horde_Support_Uuid()));
if ($fh = fopen($outfile, "w")) {
fwrite($fh, $data);
fclose($fh);
}
} else {
/* Create a random identifier for this file. */
- $id = uniqid(mt_rand());
+ $id = strval(new Horde_Support_Uuid());
try {
$vfsroot->writeData($full_path, $file_name . '.notify', $id, true);
if ($GLOBALS['conf']['compose']['use_vfs']) {
try {
$vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs();
- $cacheID = uniqid(mt_rand());
+ $cacheID = strval(new Horde_Support_Uuid());
if ($vfs_file) {
$vfs->write(self::VFS_ATTACH_PATH, $cacheID, $data, true);
if (empty($_SESSION['imp']['cache']['tree'])) {
if (!($cache instanceof Horde_Cache_Null)) {
- $_SESSION['imp']['cache']['tree'] = uniqid(mt_rand() . $GLOBALS['registry']->getAuth());
+ $_SESSION['imp']['cache']['tree'] = strval(new Horde_Support_Uuid());
}
} else {
$instance = @unserialize($cache->get($_SESSION['imp']['cache']['tree'], 86400));
'command' => '/usr/bin/sivtest',
// name of the socket we're using
'socket' => Horde::getTempDir() . '/sivtest.'
- . md5(uniqid(rand())) . '.sock',
+ . uniqid(mt_rand()) . '.sock',
),
'script' => 'sieve',
'scriptparams' => array(),
if ($event->id) {
$id = $event->id;
} else {
- $id = hash('md5', uniqid(mt_rand(), true));
+ $id = strval(new Horde_Support_Uuid);
$event->id = $id;
}
public static function addShare($info)
{
try {
- $calendar = $GLOBALS['kronolith_shares']->newShare(hash('md5', microtime()));
+ $calendar = $GLOBALS['kronolith_shares']->newShare(strval(new Horde_String_Uuid()));
} catch (Horde_Share_Exception $e) {
throw new Kronolith_Exception($e);
}
static public function addResource($resource)
{
// Create a new calendar id.
- $calendar = 'resource_' . hash('md5', microtime());
+ $calendar = 'resource_' . uniqid(mt_rand());
$resource->set('calendar', $calendar);
$driver = Kronolith::getDriver('Resource');
return false;
}
-}
\ No newline at end of file
+}
}
/**
- * Generate a universal / unique identifier for a task. This is
- * NOT something that we expect to be able to parse into a
- * tasklist and a taskId.
- *
- * @return string A nice unique string (should be 255 chars or less).
- */
- function generateUID()
- {
- return date('YmdHis') . '.'
- . substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16)
- . '@' . $GLOBALS['conf']['server']['name'];
- }
-
- /**
* Update the description (short summary) of a memo.
*
* @param integer $memo_id The memo to update.
if (isset($uid)) {
$result = $this->_kolab->loadObject($uid);
} else {
- $uid = md5(uniqid(mt_rand(), true));
+ $uid = strval(new Horde_Support_Uuid());
$result = $this->_kolab->newObject($uid);
}
if (is_a($result, 'PEAR_Error')) {
function _setObject($desc, $body, $category = '', $uid = null, $passphrase = null)
{
if (empty($uid)) {
- $note_uid = $this->_store->generateUID();
+ $note_uid = strval(new Horde_Support_Uuid());
$old_uid = null;
$action = array('action' => 'add');
} else {
*/
function add($desc, $body, $category = '', $uid = null, $passphrase = null)
{
- $noteId = md5(uniqid(mt_rand(), true));
+ $noteId = strval(new Horde_Support_Uuid());
if ($passphrase) {
$body = $this->encrypt($body, $passphrase);
}
if (is_null($uid)) {
- $uid = $this->generateUID();
+ $uid = strval(new Horde_Support_Uuid());
}
$query = 'INSERT INTO ' . $this->_params['table'] .
{
/* Make sure notes always have a UID. */
if (empty($row['memo_uid'])) {
- $row['memo_uid'] = $this->generateUID();
+ $row['memo_uid'] = strval(new Horde_Support_Uuid());
$query = 'UPDATE ' . $this->_params['table'] .
' SET memo_uid = ?' .
{
// Create new share.
try {
- $notepad = $GLOBALS['mnemo_shares']->newShare(md5(microtime()));
+ $notepad = $GLOBALS['mnemo_shares']->newShare(strval(new Horde_Support_Uuid()));
} catch (Horde_Share_Exception $e) {
Horde::logMessage($e->getMessage(), 'ERR');
throw new Mnemo_Exception($e);
}
/**
- * Generate a universal / unique identifier for a task. This is
- * NOT something that we expect to be able to parse into a
- * tasklist and a taskId.
- *
- * @return string A nice unique string (should be 255 chars or less).
- */
- function generateUID()
- {
- return date('YmdHis') . '.'
- . substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16)
- . '@' . $GLOBALS['conf']['server']['name'];
- }
-
- /**
* Attempts to return a concrete Nag_Driver instance based on $driver.
*
* @param string $tasklist The name of the tasklist to load.
$owner = null, $assignee = null)
{
if (is_null($uid)) {
- $uid = $this->generateUID();
+ $uid = strval(new Horde_Support_Uuid());
}
if (is_null($owner)) {
$owner = $GLOBALS['registry']->getAuth();
{
// Usually provided by the generic Driver class
if ($uid !== null) {
- $uid = $this->generateUID();
+ $uid = strval(new Horde_Support_Uuid());
}
// Load the object into the kolab driver
$completed_date = null)
{
if (empty($uid)) {
- $task_uid = $this->_store->generateUID();
+ $task_uid = strval(new Horde_Support_Uuid());
$old_uid = null;
} else {
list($task_uid, $tasklist) = $this->_splitId($uid);
$methods = null, $uid = null, $parent = '', $private = false,
$owner = null, $assignee = null)
{
- $taskId = md5(uniqid(mt_rand(), true));
+ $taskId = strval(new Horde_Support_Uuid());
if ($uid === null) {
- $uid = $this->generateUID();
+ $uid = strval(new Horde_Support_Uuid());
}
$query = sprintf(
{
/* Make sure tasks always have a UID. */
if (empty($row['task_uid'])) {
- $row['task_uid'] = $this->generateUID();
+ $row['task_uid'] = strval(new Horde_Support_Uuid());
$query = 'UPDATE ' . $this->_params['table'] .
' SET task_uid = ?' .
public static function addTasklist($info)
{
try {
- $tasklist = $GLOBALS['nag_shares']->newShare(md5(microtime()));
+ $tasklist = $GLOBALS['nag_shares']->newShare(strval(new Horde_Support_Uuid()));
$tasklist->set('name', $info['name']);
$tasklist->set('color', $info['color']);
$tasklist->set('desc', $info['description']);
return $instances[$signature];
}
- /**
- * Generate a universal / unique identifier for an entry. This is
- * NOT something that we expect to be able to parse into a
- * entry list.
- *
- * @return string A nice unique string (should be 255 chars or less).
- */
- function generateUID()
- {
- return date('YmdHis') . '.'
- . substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16)
- . '@' . $GLOBALS['conf']['server']['name'];
- }
}
$query = 'INSERT INTO ' . $this->_params['objects_table'] .
' (object_id, object_owner, object_uid, class_id, student_id, object_time, object_type)' .
' VALUES (?, ?, ?, ?, ?, ?, ?)';
- $entryId = md5(uniqid(mt_rand(), true));
+ $entryId = strval(new Horde_Support_Uuid());
$date = new Horde_Date($vars->get('object_time'));
- $values = array($entryId, $GLOBALS['registry']->getAuth(), $this->generateUID(), $this->_class, $studentid, $date->datestamp(), $vars->get('object_type'));
+ $values = array($entryId, $GLOBALS['registry']->getAuth(), strval(new Horde_Support_Uuid()), $this->_class, $studentid, $date->datestamp(), $vars->get('object_type'));
/* Log the query at a DEBUG log level. */
Horde::logMessage(sprintf('Skoli_Driver_sql::addEntry(): %s', $query), 'DEBUG');
}
// Create new share.
- $this->shareid = md5(microtime());
+ $this->shareid = strval(new Horde_Support_Uuid());
$class = $GLOBALS['skoli_shares']->newShare($this->shareid);
if (is_a($class, 'PEAR_Error')) {
return $class;
*/
function addFolder($properties)
{
- $folder = &$this->_shareOb->newFolder($this->getName() . ':' . md5(uniqid(mt_rand())), $properties);
+ $folder = &$this->_shareOb->newFolder($this->getName() . ':' . strval(new Horde_Support_Uuid()), $properties);
$this->_shareOb->addFolder($folder);
return $this->datatree->getId($folder);
}
}
if (!isset($attributes['__uid'])) {
- $attributes['__uid'] = $this->generateUID();
+ $attributes['__uid'] = strval(new Horde_Support_Uuid());
}
$key = $attributes['__key'] = $this->_makeKey($this->toDriverKeys($attributes));
}
/**
- * Generates a universal/unique identifier for a contact. This is NOT
- * something that we expect to be able to parse into an addressbook and a
- * contactId.
- *
- * @return string A nice unique string (should be 255 chars or less).
- */
- function generateUID()
- {
- return date('YmdHis') . '.'
- . substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16)
- . '@' . $GLOBALS['conf']['server']['name'];
- }
-
- /**
* Exports a given Turba_Object as an iCalendar vCard.
*
* @param Turba_Object $object Turba_Object.
*/
function generateUID()
{
- if (method_exists($this->_wrapper, 'generateUID')) {
- return $this->_wrapper->generateUID();
- } else {
- return parent::generateUID();
- }
+ return method_exists($this->_wrapper, 'generateUID')
+ ? $this->_wrapper->generateUID()
+ : strval(new Horde_Support_Uuid());
}
/**
}
do {
- $key = md5(uniqid(mt_rand(), true));
+ $key = strval(new Horde_Support_Uuid());
} while(in_array($key, array_keys($this->_contacts_cache)));
return $key;
*/
function _makeKey($attributes)
{
- return md5(uniqid(mt_rand(), true));
+ return strval(new Horde_Support_Uuid());
}
/**
}
// Create the new share.
-$owner_uid = md5(microtime());
+$owner_uid = strval(new Horde_Support_Uuid());
$share = &$turba_shares->newShare($sourceKey . ':' . $owner_uid);
-if (is_a($share, 'PEAR_Error')) {
+if ($share instanceof Horde_Share_Exception) {
var_dump($share);
exit;
}
'criteria' => $params['criteria'])));
try {
- $share = Turba::createShare(md5(microtime()), $params);
+ $share = Turba::createShare(strval(new Horde_Support_Uuid()), $params);
} catch (Horde_Share_Exception $e) {
throw new Turba_Exception($e);
}
}
} else {
// Create a new share for the query.
- $share = $this->_shareManager->newShare(md5(microtime()));
+ $share = $this->_shareManager->newShare(strval(new Horde_Support_Uuid());
$share->set('name', $query->name);
$share->set('slug', $query->slug);
try {
function Whups_View_Results($params)
{
parent::Whups_View($params);
- $this->_id = md5(uniqid(mt_rand()));
+ $this->_id = uniqid(mt_rand());
}
function html()
$pageBody .= "\n";
if (is_null($pageName)) {
- $pageName = "EmailMessage" . ucfirst(md5(uniqid('wicked', true)));
+ $pageName = "EmailMessage" . ucfirst(md5(uniqid('wicked')));
}
$res = $wicked->newPage($pageName, $pageBody);