25 "N" =>
"US_LNAME;US_FNAME",
26 "N;GIVEN" =>
"US_FNAME",
27 "N;FAMILY" =>
"US_LNAME",
36 "URL" =>
"US_WORKWEB",
37 "URL;WORK" =>
"US_WORKWEB",
39 "ORG" =>
"US_SOCIETY;US_UNIT",
40 "ORG;NAME" =>
"US_SOCIETY",
44 "ADR;TYPE;WORK" =>
"",
45 "ADR;TYPE;HOME" =>
"",
47 "EMAIL;INTERNET" =>
"US_MAIL",
48 "EMAIL;INTERNET;WORK" =>
"US_MAIL",
49 "EMAIL;PREF;INTERNET" =>
"US_MAIL",
50 "EMAIL;INTERNET;HOME" =>
"",
52 "ADR;WORK" =>
"0;0;US_WORKADDR;US_WORKTOWN;0;US_WORKPOSTALCODE;US_COUNTRY",
53 "ADR;WORK;STREET" =>
"US_WORKADDR",
54 "ADR;WORK;LOCALITY" =>
"US_WORKTOWN",
55 "ADR;WORK;REGION" =>
"",
56 "ADR;WORK;POSTALCODE" =>
"US_WORKPOSTALCODE",
57 "ADR;WORK;COUNTRYNAME" =>
"US_COUNTRY",
61 "ADR;HOME" =>
"0;0;320;325;0;322",
62 "ADR;HOME;STREET" =>
"320",
63 "ADR;HOME;LOCALITY" =>
"325",
64 "ADR;HOME;REGION" =>
"",
65 "ADR;HOME;POSTALCODE" =>
"322",
66 "ADR;HOME;COUNTRYNAME" =>
"",
68 "TEL;WORK" =>
"US_PPHONE",
69 "TEL;WORK;VOICE" =>
"US_PPHONE",
72 "TEL;FAX" =>
"US_PFAX",
73 "TEL;WORK;FAX" =>
"US_PFAX",
75 "TEL;CELL" =>
"US_MOBILE",
76 "TEL;CELL;VOICE" =>
"US_MOBILE",
100 if ($this->fd) fclose($this->fd);
106 $endCardFound =
false;
107 $beginCardFound =
false;
110 while ((!feof($this->fd)) && (!$beginCardFound)) {
111 $line = fgets($this->fd, 4096);
112 $beginCardFound = preg_match(
"/BEGIN:VCARD(.*)/",
$line);
115 while ((!feof($this->fd)) && (!$endCardFound)) {
116 $line = fgets($this->fd, 4096);
117 $endCardFound = preg_match(
"/END:VCARD(.*)/",
$line);
118 if (!$endCardFound) {
119 if (preg_match(
"/([A-Z;]*);ENCODING=QUOTED-PRINTABLE:(.*)/",
$line, $reg)) {
120 $tattr[$reg[1]] = utf8_encode(quoted_printable_decode(rtrim($reg[2])));
121 } elseif (preg_match(
"/([A-Z;]*);CHARSET=UTF-8:(.*)/",
$line, $reg)) {
122 $tattr[$reg[1]] = rtrim($reg[2]);
123 } elseif (preg_match(
"/([A-Z;]*):(.*)/",
$line, $reg)) {
125 $tattr[$reg[1]] = str_replace(
"\\n",
"\n", rtrim($reg[2]));
130 return (!feof($this->fd));
139 while (list($k, $v) = each($tbrut)) {
141 if (isset($this->
import[$k]) && ($this->
import[$k] !=
"")) {
143 if (preg_match(
"/^[0-9A-Z_]*$/", $this->
import[$k])) {
145 if ($this->
import[$k] ==
"US_WORKWEB") $tattr[$this->
import[$k]] = str_replace(
"http://",
"", $v);
146 else $tattr[$this->
import[$k]] = $v;
150 $complxreg =
"/([^;]*)[;]{0,1}([^;]*)[;]{0,1}([^;]*)[;]{0,1}([^;]*)[;]{0,1}([^;]*)[;]{0,1}([^;]*)[;]{0,1}/";
152 if (preg_match($complxreg, $this->
import[$k], $reg)) {
153 if (preg_match($complxreg, $v, $regv)) {
154 for ($ir = 1; $ir < 7; $ir++) {
155 if ($reg[$ir] ==
"US_WORKWEB") $tattr[$reg[$ir]] = str_replace(
"http://",
"", $regv[$ir]);
156 else $tattr[$reg[$ir]] = $regv[$ir];
169 fputs($this->fd,
"BEGIN:VCARD\n");
170 fputs($this->fd,
"FN:" . chop(
$title) .
"\n");
171 reset($this->
import);
173 while (list($k, $v) = each($this->
import)) {
176 if (isset($tattr[$v])) fputs($this->fd, $k .
":" . str_replace(
"\n",
"\\n", $tattr[$v]) .
"\n");
178 $lidattr = explode(
";", $v);
179 if ((is_array($lidattr)) && (count($lidattr) > 1)) {
180 fputs($this->fd,
"$k:");
181 while (list($k2, $idattr) = each($lidattr)) {
183 if (isset($tattr[$idattr])) fputs($this->fd, str_replace(
"\n",
"\\n", $tattr[$idattr]));
184 if ($k2 < count($lidattr) - 1) fputs($this->fd,
";");
186 fputs($this->fd,
"\n");
191 fputs($this->fd,
"END:VCARD\n\n");