From 77c1e8ff946f53a643a15af1b53f01e99e7a6b47 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 19 Dec 2016 12:44:24 +0100 Subject: [PATCH 1/9] Immediately apply changed temperature unit --- header.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/header.php b/header.php index ca688c30..f13a47c7 100644 --- a/header.php +++ b/header.php @@ -17,6 +17,11 @@ { $temperatureunit = "C"; } + // Override temperature unit setting if it is changed via Settings page + if(isset($_POST["tempunit"])) + { + $temperatureunit = $_POST["tempunit"]; + } // Get load $loaddata = sys_getloadavg(); @@ -69,7 +74,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"])) From 79af8826277a61a0d329128b23a2f7914d4ccb16 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 19 Dec 2016 13:06:49 +0100 Subject: [PATCH 2/9] Show "N/A" if we cannot get the temperature on the current machine (like in a virtual box) --- header.php | 62 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/header.php b/header.php index f13a47c7..d23dcdbf 100644 --- a/header.php +++ b/header.php @@ -4,23 +4,30 @@ 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'])) + if(file_exists("/sys/class/thermal/thermal_zone0/temp")) { - $temperatureunit = $setupVars['TEMPERATUREUNIT']; + $cmd = "echo $((`cat /sys/class/thermal/thermal_zone0/temp | cut -c1-2`))"; + $output = rtrim(shell_exec($cmd)); + $celsius = intVal($output); + $fahrenheit = round(($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 { - $temperatureunit = "C"; - } - // Override temperature unit setting if it is changed via Settings page - if(isset($_POST["tempunit"])) - { - $temperatureunit = $_POST["tempunit"]; + $celsius = -273.16; } // Get load @@ -229,20 +236,31 @@ } // CPU Temp - echo ' 45 || $celsius < -273.15) { + echo "#FF0000"; } else { - echo '#3366FF'; + echo "#3366FF"; + } + echo "\"> Temp: "; + if($celsius >= -273.15) + { + if($temperatureunit != "F") + { + echo $celsius . "°C"; + } + else + { + echo $fahrenheit . "°F"; + } } - echo '"> Temp: '; - if($temperatureunit != "F") - echo $celsius . '°C'; else - echo $fahrenheit . '°F'; - echo ''; + { + echo "N/A"; + } + echo ""; ?>
Date: Mon, 19 Dec 2016 13:09:44 +0100 Subject: [PATCH 3/9] Increase resolution of displayed temperature --- header.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/header.php b/header.php index d23dcdbf..473ab23e 100644 --- a/header.php +++ b/header.php @@ -6,10 +6,10 @@ if(file_exists("/sys/class/thermal/thermal_zone0/temp")) { - $cmd = "echo $((`cat /sys/class/thermal/thermal_zone0/temp | cut -c1-2`))"; + $cmd = "echo $((`cat /sys/class/thermal/thermal_zone0/temp`))"; $output = rtrim(shell_exec($cmd)); - $celsius = intVal($output); - $fahrenheit = round(($celsius*9./5)+32.0); + $celsius = intVal($output)*1e-3; + $fahrenheit = ($celsius*9./5)+32.0; if(isset($setupVars['TEMPERATUREUNIT'])) { @@ -249,11 +249,11 @@ { if($temperatureunit != "F") { - echo $celsius . "°C"; + echo round($celsius,1) . "°C"; } else { - echo $fahrenheit . "°F"; + echo round($fahrenheit,1) . "°F"; } } else From d18269e8355af77001ac9bdbd3a94caa0cf3fa01 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 19 Dec 2016 13:15:59 +0100 Subject: [PATCH 4/9] Hide CPU temp if it is not available --- header.php | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/header.php b/header.php index 473ab23e..dc9827f0 100644 --- a/header.php +++ b/header.php @@ -236,17 +236,16 @@ } // CPU Temp - echo " 45 || $celsius < -273.15) { - echo "#FF0000"; - } - else - { - echo "#3366FF"; - } - echo "\"> Temp: "; - if($celsius >= -273.15) - { + if ($celsius >= -273.15) { + echo " 45) { + echo "#FF0000"; + } + else + { + echo "#3366FF"; + } + echo "\"> Temp: "; if($temperatureunit != "F") { echo round($celsius,1) . "°C"; @@ -255,12 +254,8 @@ { echo round($fahrenheit,1) . "°F"; } + echo ""; } - else - { - echo "N/A"; - } - echo ""; ?>
Date: Mon, 19 Dec 2016 13:25:20 +0100 Subject: [PATCH 5/9] Something different as well --- settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.php b/settings.php index ed2e7b0b..2c58bc49 100644 --- a/settings.php +++ b/settings.php @@ -140,7 +140,7 @@ disabled> - +
Router
From da1c38ea5a79b76bec8ac77e1096a68ac76b7887 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 19 Dec 2016 13:44:12 +0100 Subject: [PATCH 6/9] Pass "none" to backend if we want no secondary DNS server --- php/savesettings.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/php/savesettings.php b/php/savesettings.php index 27fa763c..edf67902 100644 --- a/php/savesettings.php +++ b/php/savesettings.php @@ -65,7 +65,14 @@ function validDomain($domain_name) // Get secondary DNS server IP address if($secondaryDNS === "Custom") { - $secondaryIP = $_POST["DNS2IP"]; + if(strlen($_POST["DNS2IP"]) > 0) + { + $secondaryIP = $_POST["DNS2IP"]; + } + else + { + $secondaryIP = "none"; + } } else { From 4ddadd7043eba4bfc5a1ce66771582afceaa2f10 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 19 Dec 2016 13:46:38 +0100 Subject: [PATCH 7/9] Skip validation of secondary IP if set to "none" --- php/savesettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/savesettings.php b/php/savesettings.php index edf67902..911b82ee 100644 --- a/php/savesettings.php +++ b/php/savesettings.php @@ -80,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!
"; } From fc43a05e885564bdb1b6969985d742bd43078be8 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 19 Dec 2016 14:09:58 +0100 Subject: [PATCH 8/9] Try to get temperature value from different places (OS dependent) --- header.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/header.php b/header.php index dc9827f0..c4aea030 100644 --- a/header.php +++ b/header.php @@ -4,10 +4,23 @@ check_cors(); + // Try to get temperature value from different places (OS dependent) if(file_exists("/sys/class/thermal/thermal_zone0/temp")) { - $cmd = "echo $((`cat /sys/class/thermal/thermal_zone0/temp`))"; - $output = rtrim(shell_exec($cmd)); + $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 + { + $output = ""; + } + + // Test if we succeeded in getting the temperature + if(is_numeric($output)) + { $celsius = intVal($output)*1e-3; $fahrenheit = ($celsius*9./5)+32.0; From 7ab611eb44e10ea6eba9643b1c70468cb69d195b Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 19 Dec 2016 22:57:23 +0100 Subject: [PATCH 9/9] Added comment about absolute zero --- header.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/header.php b/header.php index c4aea030..56f970dd 100644 --- a/header.php +++ b/header.php @@ -40,6 +40,8 @@ } else { + // Nothing can be colder than -273.15 degree Celsius (= 0 Kelvin) + // This is the minimum temperature possible (AKA absolute zero) $celsius = -273.16; }