]> git.sur5r.net Git - contagged/blobdiff - entry.php
Merge pull request #15 from cweiske/master
[contagged] / entry.php
index 15208345f9cb0f4ae7a19763a239398ffbeadaf9..1e5e7552976de876ee184fccb105b3866df15614 100644 (file)
--- a/entry.php
+++ b/entry.php
@@ -71,7 +71,9 @@ if($_REQUEST['mode']=='vcf'){
   $filename = $entry['givenname'].'_'.$entry['name'].'.vcf';
   header("Content-Disposition: attachment; filename=\"$filename\"");
   header("Content-type: text/x-vcard; name=\"$filename\"; charset=utf-8");
-  $smarty->display($template);
+  $output = $smarty->fetch($template) . "\n";
+  $output = str_replace("\n", "\r\n", $output);
+  echo $output;
 }else{
   header('Content-Type: text/html; charset=utf-8');
   $smarty->display($template);
@@ -130,13 +132,13 @@ 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'];
+    $newdn .= ','.$conf['privatebook'].','.$_SESSION['ldapab']['binddn'];
   }else{
-    $newdn .= ', '.$conf['publicbook'];
+    $newdn .= ','.$conf['publicbook'];
   }
   $entry['displayname'] = $entry['givenname'].' '.$entry['name'];;
   $entry = prepare_ldap_entry($entry);
@@ -149,8 +151,8 @@ print '</pre>';
 
   if(empty($dn)){
     //new entry
-    $entry['uid'][] = $now;
-    $r = ldap_add($LDAP_CON,$newdn,$entry);
+    $entry['uid'][] = $new_uid;
+    $r = @ldap_add($LDAP_CON,$newdn,$entry);
     tpl_ldaperror();
     return $newdn;
   }else{