Almost correct parsing addresses, the rest should be good

This commit is contained in:
Miles Lott 2001-03-20 07:14:42 +00:00
parent 1080b3ad97
commit d1aa599fa4

View File

@ -198,25 +198,24 @@
$types = explode(";",$buffer[$i][$value]); $types = explode(";",$buffer[$i][$value]);
if ($types[1]) { if ($types[1]) {
while ($type = strtoupper(each($types))) { while ($type = strtoupper(each($types))) {
$typei[$i][$type] .= ";".$type; $typei[$i][$mult[2]] .= ";".$type;
} }
//echo "PREF1";
} elseif ($types[0]) { } elseif ($types[0]) {
$typei[$i][strtoupper($types[0])] = ";".$types[0]; $typei[$i][$mult[2]] .= ";".strtoupper($types[0]);
//echo "PREF=".strtoupper($prefer[0]); } else {
} elseif ($buffer[$i][$value]) { $typei[$i][$mult[2]] .= ";".strtoupper($buffer[$i][$value]);
$typei[$i][$buffer[$i][$value]] = ";".$value;
//echo "PREF3";
} }
//$typei[$i][strtoupper($types[0])] = ";".$types[0];
//echo "TYPE;".$mult[2]."=".$buffer[$i][$value];
break; break;
case "WORK": case "WORK":
$workaddr .= $buffer[$i][$value].";"; $workaddr .= $buffer[$i][$value].";";
$workattr = $mult[0].";".$mult[1].$prefi[$i][$mult[1]]; $workattr = $mult[0].";".$mult[1].$typei[$i][$mult[1]];
//$entries .= "A.".$mult[0].";".$mult[1].$prefi[$i][$mult[1]].":".$buffer[$i][$value]."\r\n"; //$entries .= "A.".$mult[0].";".$mult[1].$prefi[$i][$mult[1]].":".$buffer[$i][$value]."\r\n";
break; break;
case "HOME": case "HOME":
$homeaddr .= $buffer[$i][$value].";"; $homeaddr .= $buffer[$i][$value].";";
$homeattr = $mult[0].";".$mult[1].$prefi[$i][$mult[1]]; $homeattr = $mult[0].";".$mult[1].$typei[$i][$mult[1]];
//$entries .= "B.".$mult[0].";".$mult[1].$prefi[$i][$mult[1]].":".$buffer[$i][$value]."\r\n"; //$entries .= "B.".$mult[0].";".$mult[1].$prefi[$i][$mult[1]].":".$buffer[$i][$value]."\r\n";
break; break;
default: default:
@ -282,11 +281,13 @@
$entries .= "FN".$buffer[$i]['N.GIVEN']." ".$buffer[$i]['N.FAMILY']."\r\n"; $entries .= "FN".$buffer[$i]['N.GIVEN']." ".$buffer[$i]['N.FAMILY']."\r\n";
} }
} }
$workattr = ereg_replace("ADR;","",$workattr); $workattr = ereg_replace("ADR;","",$workattr);
$homeattr = ereg_replace("ADR;","",$homeattr); $homeattr = ereg_replace("ADR;","",$homeattr);
if (!$buffer[$i]['EXT']) { $buffer[$i]['EXT'] = ";"; } if (!$buffer[$i]['EXT']) { $buffer[$i]['EXT'] = ";"; }
if ($workaddr) {$work = "A.ADR;".$workattr.":;".$buffer[$i]['EXT'].substr($workaddr,0,-1)."\r\n"; } if ($workaddr) {$work = "A.ADR;".$workattr.":;".$buffer[$i]['EXT'].substr($workaddr,0,-1)."\r\n"; }
if ($homeaddr) {$home = "B.ADR;".$homeattr.":;;".substr($homeaddr,0,-1)."\r\n"; } if ($homeaddr) {$home = "B.ADR;".$homeattr.":;;".substr($homeaddr,0,-1)."\r\n"; }
$entries .= $work.$home."END:VCARD\r\n"; $entries .= $work.$home."END:VCARD\r\n";
$entries .= "\r\n"; $entries .= "\r\n";
} }