diff --git a/scripts/pi-hole/php/header.php b/scripts/pi-hole/php/header.php
index 6a6cd4fa..870981f6 100644
--- a/scripts/pi-hole/php/header.php
+++ b/scripts/pi-hole/php/header.php
@@ -4,18 +4,45 @@
check_cors();
- $cmd = "echo $((`cat /sys/class/thermal/thermal_zone0/temp | cut -c1-2`))";
- $output = shell_exec($cmd);
- $celsius = str_replace(array("\r\n","\r","\n"),"", $output);
- $fahrenheit = round(str_replace(["\r\n","\r","\n"],"", $output*9./5)+32);
-
- if(isset($setupVars['TEMPERATUREUNIT']))
+ // Try to get temperature value from different places (OS dependent)
+ if(file_exists("/sys/class/thermal/thermal_zone0/temp"))
{
- $temperatureunit = $setupVars['TEMPERATUREUNIT'];
+ $output = rtrim(file_get_contents("/sys/class/thermal/thermal_zone0/temp"));
+ }
+ elseif (file_exists("/sys/class/hwmon/hwmon0/temp1_input"))
+ {
+ $output = rtrim(file_get_contents("/sys/class/hwmon/hwmon0/temp1_input"));
}
else
{
- $temperatureunit = "C";
+ $output = "";
+ }
+
+ // Test if we succeeded in getting the temperature
+ if(is_numeric($output))
+ {
+ $celsius = intVal($output)*1e-3;
+ $fahrenheit = ($celsius*9./5)+32.0;
+
+ if(isset($setupVars['TEMPERATUREUNIT']))
+ {
+ $temperatureunit = $setupVars['TEMPERATUREUNIT'];
+ }
+ else
+ {
+ $temperatureunit = "C";
+ }
+ // Override temperature unit setting if it is changed via Settings page
+ if(isset($_POST["tempunit"]))
+ {
+ $temperatureunit = $_POST["tempunit"];
+ }
+ }
+ else
+ {
+ // Nothing can be colder than -273.15 degree Celsius (= 0 Kelvin)
+ // This is the minimum temperature possible (AKA absolute zero)
+ $celsius = -273.16;
}
// Get load
@@ -69,7 +96,7 @@
$boxedlayout = true;
}
- // Override layout setting if layout is changed via Settings page3
+ // Override layout setting if layout is changed via Settings page
if(isset($_POST["field"]))
{
if($_POST["field"] === "webUI" && isset($_POST["boxedlayout"]))
@@ -224,20 +251,26 @@
}
// CPU Temp
- echo '= -273.15) {
+ echo " 45) {
+ echo "#FF0000";
+ }
+ else
+ {
+ echo "#3366FF";
+ }
+ echo "\"> Temp: ";
+ if($temperatureunit != "F")
+ {
+ echo round($celsius,1) . "°C";
+ }
+ else
+ {
+ echo round($fahrenheit,1) . "°F";
+ }
+ echo "";
}
- else
- {
- echo '#3366FF';
- }
- echo '"> Temp: ';
- if($temperatureunit != "F")
- echo $celsius . '°C';
- else
- echo $fahrenheit . '°F';
- echo '';
?>
0)
+ {
+ $secondaryIP = $_POST["DNS2IP"];
+ }
+ else
+ {
+ $secondaryIP = "none";
+ }
}
else
{
@@ -73,7 +80,7 @@ function validDomain($domain_name)
}
// Validate secondary IP
- if (!validIP($secondaryIP) && strlen($secondaryIP) > 0)
+ if (!validIP($secondaryIP) && $secondaryIP != "none" && strlen($secondaryIP) > 0)
{
$error .= "Secondary IP (".$secondaryIP.") is invalid!
";
}
diff --git a/settings.php b/settings.php
index 02d90e57..e18d4e5d 100644
--- a/settings.php
+++ b/settings.php
@@ -140,7 +140,7 @@
disabled>
-
+