· 6 years ago · Apr 10, 2020, 04:16 AM
1<?php
2
3require "db.php";
4
5if(isset($_POST['api_key'], $_POST['cpu'])) {
6
7
8 $sql_key = $connSettings->prepare('SELECT * FROM `api` WHERE `name`="api_key"');
9 $sql_key->execute();
10 $sql_key_res = $sql_key->get_result();
11
12 if($sql_key_res->num_rows > 0) {
13 $info = $sql_key_res->fetch_object();
14 $key = $info->value;
15
16 if ($_POST['api_key'] == $key) {
17
18 $cpu = strtoupper($_POST['cpu']);
19
20
21 $sql_dizzy = $connDizzy->prepare('SELECT * FROM `consoles` WHERE `cpukey`=?');
22 $sql_dizzy->bind_param('s', $cpu);
23 $sql_dizzy->execute();
24 $sql_dizzy_res = $sql_dizzy->get_result();
25
26 if($sql_dizzy_res->num_rows == 1) {
27
28 $infoClient = $sql_dizzy_res->fetch_array();
29
30 if(isset($_POST['unbanned'])) {
31
32 $unbanned_r = $infoClient['kvtime'];
33 $expire_time = strtotime($infoClient['expire']);
34
35 $unbanned_f = strtotime($unbanned_r);
36 $now = time();
37 $difference = $now - $unbanned_f;
38 $unbanned = $difference;
39 $seconds_unbanned = $unbanned % 60;
40 $minutes_unbanned = (($unbanned - $seconds_unbanned) / 60) % 60;
41 $hours_unbanned = (((($unbanned - $seconds_unbanned) / 60) - $minutes_unbanned) / 60) % 24;
42 $days_unbanned = floor(((((($unbanned - $seconds_unbanned) / 60)- $minutes_unbanned) / 60) / 24) );
43
44 if($expire_time < $now) {
45 $expire = 'Expired';
46 }
47 else {
48 $expires = $expire_time - $now;
49 $seconds_expires = $expires % 60;
50 $minutes_expires = (($expires - $seconds_expires) / 60) % 60;
51 $hours_expires = (((($expires - $seconds_expires) / 60) - $minutes_expires) / 60) % 24;
52 $days_expires = floor(((((($expires - $seconds_expires) / 60)- $minutes_expires) / 60) / 24) );
53 $expire = $days_expires . "D " . $hours_expires . "H " . $minutes_expires . "M";
54 }
55
56 $response = array(
57 'unbanned' => $days_unbanned . "D " . $hours_unbanned . "H " . $minutes_unbanned . "M",
58 'name' => $infoClient['name'],
59 'expire' => $expire
60 );
61
62 echo json_encode($response, JSON_PRETTY_PRINT);
63
64 }
65
66 }
67 else {
68 echo "Wrong cpu";
69 }
70 }
71 else {
72 echo "Authentication-Key Error!";
73 }
74 }
75 else {
76 echo "Authentication Error!";
77 }
78}
79
80?>