forked from KeyAuth/KeyAuth-Source-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.php
More file actions
49 lines (33 loc) · 1.24 KB
/
stats.php
File metadata and controls
49 lines (33 loc) · 1.24 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
49
<?php
include 'includes/connection.php';
// database stats
$result = mysqli_query($link,"select count(1) FROM `accounts`");
$row = mysqli_fetch_array($result);
$accs = number_format($row[0]);
$result = mysqli_query($link,"select count(1) FROM `apps`");
$row = mysqli_fetch_array($result);
$apps = number_format($row[0]);
$result = mysqli_query($link,"select count(1) FROM `keys`");
$row = mysqli_fetch_array($result);
$keys = number_format($row[0]);
mysqli_close($link);
// availability stats
$url = "https://stats.uptimerobot.com/api/getMonitorList/2DrzGFk4PY"; // uptimerobot status page https://stats.uptimerobot.com/2DrzGFk4PY
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
$json = json_decode($resp);
$discord = $json->psp->monitors[0]->{'30dRatio'}->ratio;
$website = $json->psp->monitors[1]->{'30dRatio'}->ratio;
$avgUptime = number_format(array_sum(array($discord, $website)) / 2,2, '.', '');
// output JSON
die(json_encode(array(
"accounts" => $accs,
"applications" => $apps,
"licenses" => $keys,
"uptime" => $avgUptime
)));
?>