]> git.sur5r.net Git - contagged/commitdiff
more granular uid's to avoid conflicts
authorMarco van Beek <mvanbeek@forgetaboutit.net>
Thu, 20 May 2010 09:23:19 +0000 (11:23 +0200)
committerAndreas Gohr <gohr@cosmocode.de>
Thu, 20 May 2010 09:23:19 +0000 (11:23 +0200)
with more than one entry created per second.

entry.php

index 15208345f9cb0f4ae7a19763a239398ffbeadaf9..c14ff2d70dfaf7ab66169b63c80a1dd269902f4b 100644 (file)
--- a/entry.php
+++ b/entry.php
@@ -130,8 +130,8 @@ function _saveData(){
   $entry = $_REQUEST['entry'];
   $dn    = $_REQUEST['dn'];
   //construct new dn
-  $now    = time();
-  $newdn  = 'uid='.$now;
+  $new_uid = time().str_pad(mt_rand(0,99999999),8,"0", STR_PAD_LEFT);
+  $newdn   = 'uid='.$new_uid;
   if (empty($_REQUEST['type'])) { $_REQUEST['type']='public'; }
   if($_REQUEST['type'] == 'private' && $conf['privatebook']){
     $newdn .= ', '.$conf['privatebook'].', '.$_SESSION['ldapab']['binddn'];
@@ -149,7 +149,7 @@ print '</pre>';
 
   if(empty($dn)){
     //new entry
-    $entry['uid'][] = $now;
+    $entry['uid'][] = $new_uid;
     $r = ldap_add($LDAP_CON,$newdn,$entry);
     tpl_ldaperror();
     return $newdn;