diff --git a/scripts/pi-hole/js/footer.js b/scripts/pi-hole/js/footer.js
index 73ab2107..e982c0d6 100644
--- a/scripts/pi-hole/js/footer.js
+++ b/scripts/pi-hole/js/footer.js
@@ -160,10 +160,6 @@ function initCheckboxRadioStyle() {
function initCPUtemp() {
function setCPUtemp(unit) {
- if (localStorage) {
- localStorage.setItem("tempunit", tempunit);
- }
-
var temperature = parseFloat($("#rawtemp").text());
var displaytemp = $("#tempdisplay");
if (!isNaN(temperature)) {
@@ -185,10 +181,30 @@ function initCPUtemp() {
}
}
- // Read from local storage, initialize if needed
- var tempunit = localStorage ? localStorage.getItem("tempunit") : null;
- if (tempunit === null) {
- tempunit = "C";
+ function setSetupvarsTempUnit(unit, showmsg = true) {
+ var token = encodeURIComponent($("#token").text());
+ $.getJSON("api.php?setTempUnit=" + unit + "&token=" + token, function (data) {
+ if (showmsg === true) {
+ if ("result" in data && data.result === "success") {
+ utils.showAlert("success", "", "Temperature unit set to " + unit, "");
+ } else {
+ utils.showAlert("error", "", "", "Temperature unit not set");
+ }
+ }
+ });
+ }
+
+ // Read the temperature unit from HTML code
+ var tempunit = $("#tempunit").text();
+ if (!tempunit) {
+ // if no value was set in setupVars.conf, tries to retrieve the old config from localstorage
+ tempunit = localStorage ? localStorage.getItem("tempunit") : null;
+ if (tempunit === null) {
+ tempunit = "C";
+ } else {
+ // if some value was found on localstorage, set the value in setupVars.conf
+ setSetupvarsTempUnit(tempunit, false);
+ }
}
setCPUtemp(tempunit);
@@ -200,6 +216,9 @@ function initCPUtemp() {
tempunitSelector.on("change", function () {
tempunit = $(this).val();
setCPUtemp(tempunit);
+
+ // store the selected value on setupVars.conf
+ setSetupvarsTempUnit(tempunit);
});
}
}
diff --git a/scripts/pi-hole/php/func.php b/scripts/pi-hole/php/func.php
index 6a7ed0f5..1c6652aa 100644
--- a/scripts/pi-hole/php/func.php
+++ b/scripts/pi-hole/php/func.php
@@ -220,7 +220,7 @@ function getCustomDNSEntries()
return $entries;
}
-function addCustomDNSEntry($ip = '', $domain = '', $reload = '', $json = true)
+function addCustomDNSEntry($ip = '', $domain = '', $reload = '', $json = true, $teleporter = false)
{
try {
if (isset($_REQUEST['ip'])) {
@@ -279,7 +279,8 @@ function addCustomDNSEntry($ip = '', $domain = '', $reload = '', $json = true)
foreach ($domains as $domain) {
pihole_execute('-a addcustomdns '.$ip.' '.$domain.' '.$reload);
}
- if ($num > 0) {
+ // restart only if not called from teleporter.php as it handles restarts itself
+ if (($num > 0) && (!$teleporter)) {
pihole_execute('restartdns');
}
@@ -397,7 +398,7 @@ function getCustomCNAMEEntries()
return $entries;
}
-function addCustomCNAMEEntry($domain = '', $target = '', $reload = '', $json = true)
+function addCustomCNAMEEntry($domain = '', $target = '', $reload = '', $json = true, $teleporter = false)
{
try {
if (isset($_REQUEST['domain'])) {
@@ -460,7 +461,8 @@ function addCustomCNAMEEntry($domain = '', $target = '', $reload = '', $json = t
pihole_execute('-a addcustomcname '.$d.' '.$target.' '.$reload);
}
- if ($num > 0) {
+ // restart only if not called from teleporter.php as it handles restarts itself
+ if (($num > 0) && (!$teleporter)) {
pihole_execute('restartdns');
}
diff --git a/scripts/pi-hole/php/header_authenticated.php b/scripts/pi-hole/php/header_authenticated.php
index f84ee5ef..b022d4a6 100644
--- a/scripts/pi-hole/php/header_authenticated.php
+++ b/scripts/pi-hole/php/header_authenticated.php
@@ -98,7 +98,23 @@ function getTemperature()
$limit = null;
}
- return array($celsius, $limit);
+ // Get user-defined temperature limit if set
+ if (isset($setupVars['TEMPERATUREUNIT'])) {
+ switch (strtoupper($setupVars['TEMPERATUREUNIT'])) {
+ case 'F':
+ case 'K':
+ $unit = strtoupper($setupVars['TEMPERATUREUNIT']);
+ break;
+
+ default:
+ $unit = 'C';
+ }
+ } else {
+ // no value is set in setupVars.conf
+ $unit = '';
+ }
+
+ return array($celsius, $limit, $unit);
}
check_cors();
@@ -113,7 +129,7 @@ $token = $_SESSION['token'];
$maxlifetime = ini_get('session.gc_maxlifetime');
// Get temperature
-list($celsius, $temperaturelimit) = getTemperature();
+list($celsius, $temperaturelimit, $temperatureunit) = getTemperature();
// Get CPU load
$loaddata = sys_getloadavg();
diff --git a/scripts/pi-hole/php/sidebar.php b/scripts/pi-hole/php/sidebar.php
index b15a6717..1d474901 100644
--- a/scripts/pi-hole/php/sidebar.php
+++ b/scripts/pi-hole/php/sidebar.php
@@ -57,6 +57,7 @@
}
echo '
';
echo 'Temp: '.$celsius.'';
+ echo ''.$temperatureunit.'';
echo '';
}
?>
diff --git a/scripts/pi-hole/php/teleporter.php b/scripts/pi-hole/php/teleporter.php
index 0161a9ad..4941db91 100644
--- a/scripts/pi-hole/php/teleporter.php
+++ b/scripts/pi-hole/php/teleporter.php
@@ -493,6 +493,7 @@ if (isset($_POST['action'])) {
if (isset($_POST['localdnsrecords']) && $file->getFilename() === 'custom.list') {
ob_start();
$reload = 'false';
+ $teleporter = true;
if ($flushtables) {
// Defined in func.php included via auth.php
// passing reload="false" will not restart Pi-hole
@@ -502,7 +503,7 @@ if (isset($_POST['action'])) {
$localdnsrecords = process_file(file_get_contents($file));
foreach ($localdnsrecords as $record) {
list($ip, $domain) = explode(' ', $record);
- if (addCustomDNSEntry($ip, $domain, $reload, false)) {
+ if (addCustomDNSEntry($ip, $domain, $reload, false, $teleporter)) {
++$num;
}
}
@@ -517,6 +518,7 @@ if (isset($_POST['action'])) {
if (isset($_POST['localcnamerecords']) && $file->getFilename() === '05-pihole-custom-cname.conf') {
ob_start();
$reload = 'false';
+ $teleporter = true;
if ($flushtables) {
// Defined in func.php included via auth.php
// passing reload="false" will not restart Pi-hole
@@ -534,7 +536,7 @@ if (isset($_POST['action'])) {
$domain = implode(',', array_slice($explodedLine, 0, -1));
$target = $explodedLine[count($explodedLine) - 1];
- if (addCustomCNAMEEntry($domain, $target, $reload, false)) {
+ if (addCustomCNAMEEntry($domain, $target, $reload, false, $teleporter)) {
++$num;
}
}
diff --git a/settings.php b/settings.php
index f024b894..2f21449a 100644
--- a/settings.php
+++ b/settings.php
@@ -196,7 +196,7 @@ if (isset($setupVars['API_QUERY_LOG_SHOW'])) {
?>
class="active">
DHCP
+
class="active">
+ Web interface
+
class="active">
- API / Web interface
+ API
class="active">
Privacy
@@ -1026,10 +1029,162 @@ if (isset($piholeFTLConf['RATE_LIMIT'])) {