-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogs.php
More file actions
36 lines (35 loc) · 1.09 KB
/
logs.php
File metadata and controls
36 lines (35 loc) · 1.09 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
<?php
// db connection vars
// replace with values from physics secrets.js
$host = "";
$user = "";
$pass = "";
$db = "";
//absolute path to physics folder
$path = "";
// TODO: append class ID and datestamp csv filename
$fname = "logs.csv";
$fullName = $path.$fname;
$file = fopen($fullName,"w");
$connection = mysql_connect($host,$user,$pass);
mysql_select_db($db,$connection);
// TODO: only query for logs from URL $_GET parameter classid
$mysql_string = "Select * from physics_logs";
$result = mysql_query($mysql_string);
fwrite($file,"log_id,student_name,log,date_created,class_id,group_id".PHP_EOL);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
fwrite($file,$row["log_id"] .',"'.
$row["student_name"] .'","'.
$row["log"] .'","'.
$row["date_created"].'","'.
$row["class_id"].'",'.
$row["group_id"].PHP_EOL);
}
fclose($file);
header('Content-Type: application/download');
header('Content-Disposition: attachment; filename="'.$fname.'"');
header("Content-Length: " . filesize($fullName));
$fp = fopen($fullName, "r");
fpassthru($fp);
fclose($fp);
?>