-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathheatmap.php
More file actions
28 lines (24 loc) · 765 Bytes
/
Copy pathheatmap.php
File metadata and controls
28 lines (24 loc) · 765 Bytes
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
<?php
require 'course-setup.php';
$origin = $_SERVER['HTTP_ORIGIN'];
if (in_array($origin, $HANDOUT_ORIGINS)) {
// allow CORS
header("Access-Control-Allow-Origin: $origin");
// send cookies with CORS
header('Access-Control-Allow-Credentials: true');
}
header('Content-Type: text/plain');
print "\n";
$json = json_decode($_POST['visible']);
$visible = is_array($json) ? $json : [];
$log = implode("\t", array(
date('c'),
$_SERVER['REMOTE_ADDR'],
$_COOKIE['shibauth'],
str_replace($_SERVER['HTTP_ORIGIN'], '', $_SERVER['HTTP_REFERER']),
$_POST['id'], # handout ID
reset($visible), # first visible element
end($visible) # last visible element
));
file_put_contents('log/access-' . date('Y-m-d') . '.log', "$log\n", FILE_APPEND | LOCK_EX);
?>