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. */ |
16 | define('SM_PATH','../'); |
17 | |
18 | /* SquirrelMail required files. */ |
19 | require_once(SM_PATH . 'include/validate.php'); |
20 | require_once(SM_PATH . 'functions/strings.php'); |
21 | require_once(SM_PATH . 'functions/prefs.php'); |
22 | require_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"); |
29 | while (!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 | |
37 | fclose ($fp); |
38 | |
97424ab0 |
39 | |
6099e09d |
40 | function write_vcard($abook) { |
41 | global $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 | |
49 | fputs($fp0, "BEGIN:VCARD |
97424ab0 |
50 | VERSION:3.0 |
6099e09d |
51 | N:$abook[1];$abook[2]; |
52 | NICKNAME:$abook[0] |
53 | EMAIL;INTERNET:$abook[3]; |
97424ab0 |
54 | END:VCARD<P> |
6099e09d |
55 | "); |
56 | $i++; |
57 | fclose($fp0); |
58 | |
97424ab0 |
59 | } |
60 | |
6099e09d |
61 | echo "done ;) seem to have written $i files."; |
97424ab0 |
62 | ?> |