-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtotal_amount_last24.php
More file actions
38 lines (38 loc) · 1.32 KB
/
total_amount_last24.php
File metadata and controls
38 lines (38 loc) · 1.32 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
<?php
header('Content-Type: text/plain; charset=UTF-8');
if($_GET["secret"] === ",yD:n]kDu7Z?zjn<") {
$servername = "localhost";
$username = "tekntehf_trivias_user";
$password = "Fo3A4QZ)*s+d";
$dbname = "tekntehf_trivias";
$minTimeStamp = (time() * 1000) - (24 * 60 * 60 * 1000);
$trivias = array();
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$lang_change = "SET NAMES utf8mb4";
if (mysqli_query($conn, $lang_change)) {
//echo "Successful: Language change. ";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$sql = "SELECT total FROM trivia_data WHERE time > $minTimeStamp";
$total = 0;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$total = $total + $row['total'];
}
} else {
echo "0";
}
$conn->close();
echo $total;
} else {
echo "The provided secret key is wrong or you didn't even provide a secret key.";
}
?>