-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathport.php
39 lines (37 loc) · 1.19 KB
/
port.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
<?php
require_once "backend/database.php";
if (isset($_FILES['importFile'])) {
try {
$delim = isset($_POST['delimiter']) ? $_POST['delimiter'] : ',';
$rawData = file ($_FILES['importFile']['tmp_name']);
$data = array ();
foreach($rawData as $line){
$data[] = str_getcsv($line, $delim);
}
if (count($data)) {
if (importCsv($data)){
exit('<meta http-equiv="refresh" content="0; url=./">');
} else {
exit("No success.");
}
} else {
throw new Exception("Invalid import format");
}
} catch (Exception $e){
exit($e->getMessage());
}
} else if($_REQUEST["action"]=="export"){
$csv = exportCsv();
header('Content-Description: File Transfer');
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="'.date('Y-m-d H:i').' Member database.csv"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: private');
header('Pragma: public');
header('Content-Length: ' . strlen($csv)/*$fileStat["size"]*/);
ob_clean();
echo $csv;
flush();
}
?>