-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpayments_export_csv.php
More file actions
54 lines (48 loc) · 1.78 KB
/
payments_export_csv.php
File metadata and controls
54 lines (48 loc) · 1.78 KB
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
<?php
echo "File is not anabled. Please let your ATutor administrator know."
exit;
define('AT_INCLUDE_PATH', '../../include/');
require(AT_INCLUDE_PATH.'vitals.inc.php');
$sql1 = stripslashes(urldecode($_GET['thisquery']));
$result1 = mysql_query($sql1,$db);
$today = date("Y-m-d_h-m-s");
$path = AT_CONTENT_DIR . 'payments_'.$today.'.csv';
function quote_csv($line) {
$line = str_replace('"','""', $line);
$line = str_replace(",", "", $line);
//$line = str_replace("\n", '\n', $line);
//$line = str_replace("\r", '\r', $line);
$line = str_replace("\x00", '\0', $line);
$line = trim($line);
return '"'.$line.'"';
}
$fp = fopen($path, 'w');
$this_purchase .= '';
while($row = mysql_fetch_array($result1)){
$this_purchase .= quote_csv($row['shopid']);
$this_purchase .= quote_csv($row['member_id']);
$this_purchase .= quote_csv($row['firstname']);
$this_purchase .= quote_csv($row['lastname']);
$this_purchase .= quote_csv($row['email']);
$this_purchase .= quote_csv($row['organization']);
$this_purchase .= quote_csv($row['address']);
$this_purchase .= quote_csv($row['postal']);
$this_purchase .= quote_csv($row['telephone']);
$this_purchase .= quote_csv($row['country']);
$this_purchase .= quote_csv($row['miraid']);
$this_purchase .= quote_csv($row['date']);
$this_purchase .= quote_csv($row['course_name']);
$this_purchase .= quote_csv($row['amount']);
$this_purchase .= quote_csv($row['comments']);
$this_purchase .= quote_csv($row['course_id'])."\r\n";
}
fputs($fp, $this_purchase);
fclose($fp);
header('Content-Type: application/x-excel');
header('Content-Disposition: inline; filename="payments_'.$today.'.csv"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
echo $this_purchase;
exit;
?>