-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetCSVstats.php
More file actions
executable file
·60 lines (48 loc) · 1.23 KB
/
getCSVstats.php
File metadata and controls
executable file
·60 lines (48 loc) · 1.23 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
55
56
57
58
59
60
<?php
require_once 'CAS-1.3.4/CAS.php';
// Enable debugging
//phpCAS::setDebug();
// Enable verbose error messages. Disable in production!
phpCAS::setVerbose(false);
// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,'cas.byu.edu',443,'cas');
// check CAS authentication
$auth = phpCAS::checkAuthentication();
if($auth)
{
require_once("DBConnect.php");
$thisUsersID = phpCAS::getUser();
if(verifyTA($thisUsersID))
{
$array = getStats();
date_default_timezone_set ("America/Denver");
$fileName = 'QUEUE CSV '.(string)date("g:i:s A n/d/y").'.csv';
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Description: File Transfer');
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename={$fileName}");
header("Expires: 0");
header("Pragma: public");
$fh = @fopen( 'php://output', 'w' );
$headerDisplayed = false;
$headers = array("NetId", "Name", "Help Count", "Pass Off Count");
fputcsv($fh, $headers);
foreach($array["students"] as $row)
{
fputcsv($fh, $row);
}
// Close the file
fclose($fh);
// Make sure nothing else is sent, our file is done
exit;
}
else
{
echo "Not authorized";
}
}
else
{
echo "Not BYU authorized";
}
?>