forked from KeyAuth/KeyAuth-Source-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprimary.php
More file actions
116 lines (89 loc) · 3.12 KB
/
primary.php
File metadata and controls
116 lines (89 loc) · 3.12 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
namespace dashboard\primary;
use misc\mysql;
function time2str($date)
{
$now = time();
$diff = $now - $date;
if ($diff < 60) {
return sprintf($diff > 1 ? '%s seconds' : 'second', $diff);
}
$diff = floor($diff / 60);
if ($diff < 60) {
return sprintf($diff > 1 ? '%s minutes' : 'minute', $diff);
}
$diff = floor($diff / 60);
if ($diff < 24) {
return sprintf($diff > 1 ? '%s hours' : 'hour', $diff);
}
$diff = floor($diff / 24);
if ($diff < 7) {
return sprintf($diff > 1 ? '%s days' : 'day', $diff);
}
if ($diff < 30) {
$diff = floor($diff / 7);
return sprintf($diff > 1 ? '%s weeks' : 'week', $diff);
}
$diff = floor($diff / 30);
if ($diff < 12) {
return sprintf($diff > 1 ? '%s months' : 'month', $diff);
}
$diff = date('Y', $now) - date('Y', $date);
return sprintf($diff > 1 ? '%s years' : 'year', $diff);
}
function expireCheck($username, $expires)
{
if ($expires < time()) {
$_SESSION['role'] = "tester";
$query = mysql\query("UPDATE `accounts` SET `role` = 'tester' WHERE `username` = ?",[$username]);
}
if ($expires - time() < 2629743) // check if account expires in month or less
{
return true;
} else {
return false;
}
}
function wh_log($webhook_url, $msg, $un)
{
$json_data = json_encode([
// Message
"content" => $msg,
// Username
"username" => "$un",
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$ch = curl_init($webhook_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json'
));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
}
function error($msg)
{
echo '<script src="https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css"><script type=\'text/javascript\'>
const notyf = new Notyf();
notyf
.error({
message: \'' . addslashes($msg) . '\',
duration: 3500,
dismissible: true
});
</script>';
}
function success($msg)
{
echo '<script src="https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css"><script type=\'text/javascript\'>
const notyf = new Notyf();
notyf
.success({
message: \'' . addslashes($msg) . '\',
duration: 3500,
dismissible: true
});
</script>';
}