From 8c14b9962144ebbebc9f0b855b86f8f8413b05de Mon Sep 17 00:00:00 2001 From: Michael Larabel Date: Tue, 16 Dec 2008 19:08:08 -0500 Subject: pts-core: Add support for specifying multiple possible points in read_acpi() to provide some fallback support --- .../functions/pts-functions_system_parsing.php | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'pts-core') diff --git a/pts-core/functions/pts-functions_system_parsing.php b/pts-core/functions/pts-functions_system_parsing.php index 3932e66..701e7b7 100644 --- a/pts-core/functions/pts-functions_system_parsing.php +++ b/pts-core/functions/pts-functions_system_parsing.php @@ -26,27 +26,35 @@ function read_acpi($point, $match) // Read ACPI - Advanced Configuration and Power Interface $value = ""; - if(is_file("/proc/acpi" . $point)) + if(!is_array($point)) { - $acpi_lines = explode("\n", file_get_contents("/proc/acpi" . $point)); + $point = array($point); + } - for($i = 0; $i < count($acpi_lines) && $value == ""; $i++) + for($i = 0; $i < count($point) && empty($value); $i++) + { + if(is_file("/proc/acpi" . $point[$i])) { - $line = explode(": ", $acpi_lines[$i]); - $this_attribute = trim($line[0]); + $acpi_lines = explode("\n", file_get_contents("/proc/acpi" . $point[$i])); - if(count($line) > 1) - { - $this_value = trim($line[1]); - } - else + for($i = 0; $i < count($acpi_lines) && $value == ""; $i++) { - $this_value = ""; - } + $line = explode(": ", $acpi_lines[$i]); + $this_attribute = trim($line[0]); - if($this_attribute == $match) - { - $value = $this_value; + if(count($line) > 1) + { + $this_value = trim($line[1]); + } + else + { + $this_value = ""; + } + + if($this_attribute == $match) + { + $value = $this_value; + } } } } -- cgit