-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.php
executable file
·91 lines (78 loc) · 3.23 KB
/
export.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
include ("include/dbconnect.php");
if(isset($_REQUEST['type']) && $_REQUEST['type'] == "vCard-zip") {
require "include/export.vcard.php";
Header("Content-Type: archive/zip");
Header('Content-Disposition: attachment; filename="'.date("Y_m_d-Hi").'.zip"');
$zip = new ZipArchive();
$filename = tempnam("/tmp", "pdd").".zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
$sql="SELECT * FROM $month_from_where";
if(isset($part_sql)) {
$sql .= " AND ".$part_sql;
}
$result = mysql_query($sql);
while($address = mysql_fetch_array($result)) {
$vcfname = $address['firstname'].(isset($address['middlename']) ? "_".$address['middlename']:"")."_".$address['lastname']."-".$address['id'].".vcf";
$vcfname = str_replace(" ","_",$vcfname); // middlename may contain spaces, for example "van der" in Dutch
setlocale(LC_ALL, 'en_US.UTF8');
$vcfname = str_replace( "?", "", iconv('UTF-8', 'ASCII//TRANSLIT', $vcfname));
$zip->addFromString($vcfname, address2vcard($address));
}
$zip->close();
readfile($filename);
unlink($filename);
} elseif(isset($_REQUEST['type']) && $_REQUEST['type'] == "vCard-one") {
Header("Content-Type: text/x-vCard");
$filename = utf8_to_latin1("All_Contacts_of_domin-".$domain_id."-".date("Y_m_d-Hi"));
Header('Content-Disposition: attachment; filename="'.$filename.'.vcf"');
require "include/export.vcard.php";
$sql = "SELECT * FROM $month_from_where";
$result = mysql_query($sql);
while($links = mysql_fetch_array($result)) {
echo address2vcard($links);
}
} elseif(isset($_REQUEST['type']) && $_REQUEST['type'] == "xls-Nokia") {
require "include/export.xls-nokia.php";
} else {
include ("include/format.inc.php");
?>
<title><?php echo ucfmsg("ADDRESS_BOOK").($group_name != "" ? " ($group_name)":""); ?></title>
<?php include ("include/header.inc.php"); ?>
<h1><?php echo ucfmsg('EXPORT'); ?></h1>
<h2>Addressbook</h2>
<form>
<label>vCards for Outlook:</label>
<input type="hidden" name="type" value="vCard-zip">
<input type="submit" name="submit" value="Download">
</form>
<br>
<form>
<label>All in one vCard:</label>
<input type="hidden" name="type" value="vCard-one">
<input type="submit" name="submit" value="Download">
</form>
<br>
<form method="get" action="csv<?php echo $page_ext; ?>">
<label>CSV for Excel: </label>
<input type="hidden" name="group" value="<?php echo $group; ?>">
<input type="submit" name="submit" value="Download">
</form>
<br>
<form>
<label>CSV for Nokia:</label>
<input type="hidden" name="type" value="xls-Nokia">
<input type="submit" name="submit" value="Download"><br>
</form>
<h2>Calendar</h2>
<form method="get" action="birthdays<?php echo $page_ext; ?>">
<label>Birthdays (iCalendar): </label>
<input type="hidden" name="ics" value="">
<input type="submit" name="submit" value="Download"> (<a href="birthdays<?php echo $page_ext; ?>?ics&user=XXX&pass=YYY">Link</a>)<br>
</form>
<?php
include ("include/footer.inc.php");
}
?>