-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_ls.php
executable file
·53 lines (36 loc) · 1.5 KB
/
export_ls.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
<?php
ob_end_clean();
// export_ls.php###
//start session for export feature
session_start();
$allsqlresults= $_SESSION['query2'];
//for testing
//print_r($_SESSION['query2']);
require '/var/www/cdlc_script/cdlc_function.php';
// Connect to database
require '/var/www/cdlc_script/cdlc_db.inc';
//check if the person is logged in
if (strlen($display_username)>1) {
//for testing
//echo "the query".$allsqlresults."<br>";
$db = mysqli_connect($dbhost, $dbuser, $dbpass);
mysqli_select_db($db, $dbname);
$GETLIST = mysqli_query($db, $allsqlresults);
$row = mysqli_fetch_assoc($GETLIST);
$delimiter=",";
$filename= "eform_export_".$lastname."_". date('Ymd').".csv";
$f= fopen('php://memory', 'w');
$fields = array('ID', 'NAME', 'System','ILL EMAIL', 'PHONE', 'Dept', 'Street Address', 'City, State, Zip', 'LOC Location', 'Email Alert', 'Participant', 'Syspend');
fputcsv($f, $fields, $delimiter);
while ($row=$GETLIST->fetch_assoc()) {
$lineData = array($row['recnum'], $row['Name'], $row['system'], $row['ill_email'], $row['phone'], $row['address1'], $row['address2'], $row['address3'],$row['loc'], $ealert, $status,$suspend);
fputcsv($f, $lineData, $delimiter);
}
fseek($f, 0);
$file = "./sites/cdlc.senylrc.org/files/".$filename; // File to Save
chmod($file, 0777);
file_put_contents($file, $f);
echo "<a href='/sites/cdlc.senylrc.org/files/".$filename."'>Export Ready For Download</a>";
}else{
echo "Please log into the system";
}