-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrack.php
More file actions
30 lines (26 loc) · 747 Bytes
/
track.php
File metadata and controls
30 lines (26 loc) · 747 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
29
30
<?php
include('includes/auth.php');
include('includes/db.php');
if (isset($_GET['resource_id'])) {
$user_id = $_SESSION['user_id'];
$resource_id = intval($_GET['resource_id']);
// Log the access
$stmt = $conn->prepare("INSERT INTO usage_logs (user_id, resource_id) VALUES (?, ?)");
$stmt->bind_param("ii", $user_id, $resource_id);
$stmt->execute();
// Get the actual resource link
$res = $conn->prepare("SELECT path FROM resources WHERE id = ?");
$res->bind_param("i", $resource_id);
$res->execute();
$result = $res->get_result();
$row = $result->fetch_assoc();
if ($row) {
header("Location: " . $row['path']);
exit;
} else {
echo "Invalid resource.";
}
} else {
echo "No resource specified.";
}
?>