sleeping sucks anyway. ;)
[squirrelmail.git] / src / abook2vcard.php
CommitLineData
97424ab0 1<?php
2
3/**
4 * read_body.php
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file is used for reading the msgs array and displaying
10 * the resulting emails in the right frame.
11 *
12 * $Id$
13 */
14
15/* Path for SquirrelMail required files. */
16define('SM_PATH','../');
17
18/* SquirrelMail required files. */
19require_once(SM_PATH . 'include/validate.php');
20require_once(SM_PATH . 'functions/strings.php');
21require_once(SM_PATH . 'functions/prefs.php');
22require_once(SM_PATH . 'config/config.php');
23
24$abook_file=$data_dir.$username.".abook";
6099e09d 25$vcard_base=$data_dir.$username;
26$i=0;
97424ab0 27
28$fp = fopen ($abook_file,"r");
29while (!feof ($fp)) {
6099e09d 30 $buffer = fgets($fp, 8096);
31 $line=explode("|",$buffer);
32 if (count($line)>1) {
33 write_vcard($line);
34 }
97424ab0 35}
36
37fclose ($fp);
38
97424ab0 39
6099e09d 40function write_vcard($abook) {
41global $vcard_base,$i;
42
43
44// FIXME check if filename is ok
45$vcard_fn = $vcard_base.".".$abook[0].".vcard";
46
47$fp0 = fopen ($vcard_fn,"w");
48
49fputs($fp0, "BEGIN:VCARD
97424ab0 50VERSION:3.0
6099e09d 51N:$abook[1];$abook[2];
52NICKNAME:$abook[0]
53EMAIL;INTERNET:$abook[3];
97424ab0 54END:VCARD<P>
6099e09d 55");
56$i++;
57fclose($fp0);
58
97424ab0 59}
60
6099e09d 61echo "done ;) seem to have written $i files.";
97424ab0 62?>