-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
96 lines (89 loc) · 3.06 KB
/
index.php
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
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['duration_minutes'])) {
$duration_minutes = $_POST['duration_minutes'];
if (!is_numeric($duration_minutes)) {
exit;
}
exec("sudo pihole disable " . $duration_minutes . "m");
echo "pihole disabled for " . $duration_minutes . " minutes";
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Pihole Disabler</title>
<link rel="icon" href="favicon.ico" type="image/png">
<style>
#header {
font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, sans-serif;
font-size: larger;
font-weight: bold;
margin-bottom: 12px;
text-align: center;
}
/* Button from Stripe */
.btn {
appearance: button;
backface-visibility: hidden;
background-color: #405cf5;
border-radius: 6px;
border-width: 0;
box-shadow: rgba(50, 50, 93, .1) 0 0 0 1px inset, rgba(50, 50, 93, .1) 0 2px 5px 0, rgba(0, 0, 0, .07) 0 1px 1px 0;
box-sizing: border-box;
color: #fff;
cursor: pointer;
font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, sans-serif;
font-size: 100%;
height: 44px;
line-height: 1.15;
margin: 12px 0 0 0;
outline: none;
overflow: hidden;
padding: 0 25px;
position: relative;
text-align: center;
text-transform: none;
transform: translateZ(0);
transition: all .2s, box-shadow .08s ease-in;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
width: 100%;
}
.btn:hover,
.btn:focus {
box-shadow: rgba(50, 50, 93, .1) 0 0 0 1px inset, rgba(50, 50, 93, .2) 0 6px 15px 0, rgba(0, 0, 0, .1) 0 2px 2px 0, rgba(50, 151, 211, .3) 0 0 0 4px;
}
#msg {
color: red;
font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, sans-serif;
font-size: larger;
margin-top: 12px;
text-align: center;
}
</style>
</head>
<body>
<p id="header">Disable Pihole for:</p>
<button class="btn" role="button" onclick="disable(5)">5 min</button>
<button class="btn" role="button" onclick="disable(30)">30 min</button>
<div id="msg" />
</body>
<script>
async function disable(durationMinutes) {
let response = await fetch(window.location.href, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: `duration_minutes=${durationMinutes}`,
cache: 'no-store'
});
let data = await response.text();
document.getElementById("msg").innerHTML = data;
}
</script>
</html>