-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvcard.php
41 lines (36 loc) · 1.06 KB
/
vcard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
if($input->get->id){
$item = json_decode(base64_decode($sanitizer->text($input->get->id)));
$file = $sanitizer->pageName($item->name1 ."-". $item->name2 .".vcf",true);
$area = "+358";
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=". $file .";");
echo "BEGIN:VCARD
VERSION:3.0
REV:". date("c") ."
N;CHARSET=utf-8:$item->name2;$item->name1;;;
FN;CHARSET=utf-8:$item->name1 $item->name2
TITLE;CHARSET=utf-8:$item->title
EMAIL;INTERNET:$item->email\n";
foreach($item->phone as $item){
if (strpos($item, $area) == false) $item = $area . str_replace(" ","", substr($item,1));
echo "TEL;PREF;WORK:$item\n";
}
echo "ADR;WORK;POSTAL;CHARSET=utf-8:;;$item->street;$item->area;;$item->postal;
ORG;CHARSET=utf-8:Polarputki Oy
END:VCARD";
}
?>
<a href="/vcard?id=<?= base64_encode(json_encode([
"name1" => "Timo",
"name2" => "Anttila",
"email" => "timo.anttila@example.com",
"phone" => [
"0401234567",
"0501234567"
],
"title" => "Web Developer",
"street" => "Testikuja 8",
"postal" => "37130",
"area" => "Nokia"
])) ?>" rel="nofollow">vcard</a>