sleeping sucks anyway. ;)
authorcentaurix <centaurix@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 20 Jan 2003 06:01:16 +0000 (06:01 +0000)
committercentaurix <centaurix@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Mon, 20 Jan 2003 06:01:16 +0000 (06:01 +0000)
it writes vcards now. not pretty ones (strip whitespace, encoding, etc is still missing).
but works for me as inital tool.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4441 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/abook2vcard.php

index a9d6567edbe0d29869e50a7036ddec34955933d4..260edf31cf9498849252d1486f9cf0e346507e9e 100644 (file)
@@ -22,28 +22,41 @@ require_once(SM_PATH . 'functions/prefs.php');
 require_once(SM_PATH . 'config/config.php');
 
 $abook_file=$data_dir.$username.".abook";
-$vcard_dir=$data_dir.$username."/";
+$vcard_base=$data_dir.$username;
+$i=0;
 
 $fp = fopen ($abook_file,"r");
 while (!feof ($fp)) {
-    $buffer .= fgets($fp, 4096);
+    $buffer = fgets($fp, 8096);
+   $line=explode("|",$buffer);
+   if (count($line)>1) {
+    write_vcard($line);
+   }
 }
 
 fclose ($fp);
 
-$abook=explode("|",$buffer);
-print_r($abook);
-echo "<p>".$buffer;
 
-while ( list($nick,$email,$fn,$ln,$email)=each($abook) ) {
-echo "
-BEGIN:VCARD
+function write_vcard($abook) {
+global $vcard_base,$i;
+
+
+// FIXME check if filename is ok
+$vcard_fn = $vcard_base.".".$abook[0].".vcard";
+
+$fp0 = fopen ($vcard_fn,"w");
+
+fputs($fp0, "BEGIN:VCARD
 VERSION:3.0
-N:$ln;$fn;
-NICKNAME:$nick
-EMAIL;INTERNET:$email
+N:$abook[1];$abook[2];
+NICKNAME:$abook[0]
+EMAIL;INTERNET:$abook[3];
 END:VCARD<P>
-";
+");
+$i++;
+fclose($fp0);
+
 }
 
+echo "done ;) seem to have written $i files.";
 ?>