-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.php
47 lines (36 loc) · 1.31 KB
/
status.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
<?php
ini_set('session.cookie_httponly', 1);
ini_set('session.cookie_secure', 1);
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
header('X-Frame-Options: DENY');
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type-Options: nosniff');
header('Strict-Transport-Security: max-age=63072000');
header('X-Robots-Tag: noindex, nofollow', true);
try {
$db = new SQLite3('./db/watchlist.db');
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['watched'])) {
foreach ($_POST['watched'] as $id => $watched) {
$id = filter_var($id, FILTER_VALIDATE_INT);
$watched = filter_var($watched, FILTER_VALIDATE_BOOLEAN);
if ($id !== false && $id > 0) {
$stmt = $db->prepare("UPDATE watchlist SET watched = :watched WHERE id = :id");
$stmt->bindValue(':id', $id, SQLITE3_INTEGER);
$stmt->bindValue(':watched', $watched, SQLITE3_INTEGER);
$stmt->execute();
}
}
}
$db->close();
if(isset($_SESSION['prev_page']) && !empty($_SESSION['prev_page'])) {
header("Location: " . $_SESSION['prev_page']);
} else {
header("Location: /");
}
exit;
} catch (Exception $e) {
echo "Error: " . htmlspecialchars($e->getMessage());
}
?>