-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogExclude.php
More file actions
executable file
·48 lines (43 loc) · 1.5 KB
/
LogExclude.php
File metadata and controls
executable file
·48 lines (43 loc) · 1.5 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
<?php
header('Content-Type: application/json');
require __DIR__ . '/Credentials.php';
// Connect to the database
$Conn = new mysqli($Servername, $Username, $Password, $Dbname);
if ($Conn->connect_error) {
die("Connection failed: " . $Conn->connect_error);
}
$Now = new DateTimeImmutable("now", new DateTimeZone('Europe/London'));
$DateTime_Exclude = $Now->format('Y-m-d\TH:i:s');
// Get the input
$Input = json_decode(file_get_contents('php://input'), true);
$PoolId = $Input['PoolId'];
$SubjectId = $Input['SubjectId'];
$OS = $Input['OS'];
$Browser = $Input['Browser'];
$ScreenWidth = $Input['ScreenWidth'];
$ScreenHeight = $Input['ScreenHeight'];
$PoolId = mysqli_real_escape_string($Conn, $PoolId);
$SubjectId = mysqli_real_escape_string($Conn, $SubjectId);
$OS = mysqli_real_escape_string($Conn, $OS);
$Browser = mysqli_real_escape_string($Conn, $Browser);
$ScreenWidth = mysqli_real_escape_string($Conn, $ScreenWidth);
$ScreenHeight = mysqli_real_escape_string($Conn, $ScreenHeight);
if (!boolval($PoolId)) {
$PoolId = 'null';
}
if (!boolval($SubjectId)) {
$SubjectId = 'null';
}
// Write to the database
$Sql = "INSERT INTO Exclusions
(PoolId, SubjectId, OS, Browser,
ScreenWidth, ScreenHeight, DateTime_Exclude)
VALUES
('$PoolId', '$SubjectId', '$OS', '$Browser',
$ScreenWidth, $ScreenHeight, '$DateTime_Exclude')";
if ($Conn->query($Sql) === true) {
$Result['Success'] = true;
} else {
die("Query Sql failed to execute successfully!\n" . $Conn->error);
}
$Conn->close();