mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Move enable/disable to API
Also check CORS for all API calls. With the same import, we can enable CSRF token checking on the API.
This commit is contained in:
+5
-15
@@ -4,16 +4,6 @@
|
||||
|
||||
check_cors();
|
||||
|
||||
if (isset($_GET['enable']) && $auth) {
|
||||
exec('sudo pihole enable');
|
||||
$refer = $_SERVER['HTTP_REFERER'];
|
||||
header("location:$refer");
|
||||
} elseif (isset($_GET['disable']) && $auth) {
|
||||
exec('sudo pihole disable');
|
||||
$refer = $_SERVER['HTTP_REFERER'];
|
||||
header("location:$refer");
|
||||
}
|
||||
|
||||
// Web based change of temperature unit
|
||||
if (isset($_GET['tempunit']))
|
||||
{
|
||||
@@ -193,11 +183,11 @@
|
||||
<?php
|
||||
$pistatus = exec('sudo pihole status web');
|
||||
if ($pistatus == "1") {
|
||||
echo '<a href="#"><i class="fa fa-circle" style="color:#7FFF00"></i> Active</a>';
|
||||
echo '<a href="#" id="status"><i class="fa fa-circle" style="color:#7FFF00"></i> Active</a>';
|
||||
} elseif ($pistatus == "0") {
|
||||
echo '<a href="#"><i class="fa fa-circle" style="color:#FF0000"></i> Offline</a>';
|
||||
echo '<a href="#" id="status"><i class="fa fa-circle" style="color:#FF0000"></i> Offline</a>';
|
||||
} else {
|
||||
echo '<a href="#"><i class="fa fa-circle" style="color:#ff9900"></i> Starting</a>';
|
||||
echo '<a href="#" id="status"><i class="fa fa-circle" style="color:#ff9900"></i> Starting</a>';
|
||||
}
|
||||
|
||||
// CPU Temp
|
||||
@@ -285,9 +275,9 @@
|
||||
<!-- Toggle -->
|
||||
<?php
|
||||
if ($pistatus == "1") {
|
||||
echo ' <li><a href="?disable"><i class="fa fa-stop"></i> <span>Disable</span></a></li>';
|
||||
echo ' <li><a href="#" id="flip-status"><i class="fa fa-stop"></i> <span>Disable</span></a></li>';
|
||||
} else {
|
||||
echo ' <li><a href="?enable"><i class="fa fa-play"></i> <span>Enable</span></a></li>';
|
||||
echo ' <li><a href="#" id="flip-status"><i class="fa fa-play"></i> <span>Enable</span></a></li>';
|
||||
}
|
||||
?>
|
||||
<!-- Logout -->
|
||||
|
||||
Reference in New Issue
Block a user