= MIN_THRESHOLD_VALUE && $warningValue <= MAX_THRESHOLD_VALUE) && ($criticalValue >= MIN_THRESHOLD_VALUE && $criticalValue <= MAX_THRESHOLD_VALUE) && ($warningValue < $criticalValue)) { //all validated ok, save to config array $configArray[WIDGETS_CONFIG_SECTION_KEY][$postArray['widgetkey']][$warningValueKey] = $warningValue; $configArray[WIDGETS_CONFIG_SECTION_KEY][$postArray['widgetkey']][$criticalValueKey] = $criticalValue; } } } if (!function_exists('saveGraphDisplaySettings')) { function saveGraphDisplaySettings(&$configArray, &$postArray, $valueKey) { $configArray[WIDGETS_CONFIG_SECTION_KEY][$postArray['widgetkey']][$valueKey] = isset($postArray[$valueKey]) ? 1 : 0; } } if (!function_exists('getThresholdValueFromConfig')) { function getThresholdValueFromConfig(&$configArray, $valueKey, $defaultValue, $widgetKey) { $thresholdValue = $defaultValue; if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][$widgetKey][$valueKey])) { $thresholdValue = (int) $configArray[WIDGETS_CONFIG_SECTION_KEY][$widgetKey][$valueKey]; } if ($thresholdValue < MIN_THRESHOLD_VALUE || $thresholdValue > MAX_THRESHOLD_VALUE) { //set to default if not in allowed range $thresholdValue = $defaultValue; } return $thresholdValue; } } if (!function_exists('getBoolValueFromConfig')) { function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue, $widgetKey) { $boolValue = false; if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][$widgetKey][$valueKey])) { $boolValue = (bool) $configArray[WIDGETS_CONFIG_SECTION_KEY][$widgetKey][$valueKey]; } else { //set to default if not in allowed range $boolValue = $defaultValue; } return $boolValue; } } //NOTE: keys used in $_POST and $config and $user_settings should match text and checkbox inputs' IDs/names in HTML code section //========================================================================= //save widget config settings on POST if ($_POST['widgetkey']) { set_customwidgettitle($user_settings); saveThresholdSettings($user_settings, $_POST, "thermal_sensors_widget_zone_warning_threshold", "thermal_sensors_widget_zone_critical_threshold"); saveThresholdSettings($user_settings, $_POST, "thermal_sensors_widget_core_warning_threshold", "thermal_sensors_widget_core_critical_threshold"); //handle checkboxes separately saveGraphDisplaySettings($user_settings, $_POST, "thermal_sensors_widget_show_raw_output"); saveGraphDisplaySettings($user_settings, $_POST, "thermal_sensors_widget_show_full_sensor_name"); saveGraphDisplaySettings($user_settings, $_POST, "thermal_sensors_widget_pulsate_warning"); saveGraphDisplaySettings($user_settings, $_POST, "thermal_sensors_widget_pulsate_critical"); //write settings to config file save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved thermal_sensors_widget settings via Dashboard.")); header("Location: ../../index.php"); } $widgetkey_nodash = str_replace("-", "", $widgetkey); //========================================================================= //get Threshold settings from config (apply defaults if missing) $thermal_sensors_widget_zoneWarningTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_zone_warning_threshold", DEFAULT_WARNING_THRESHOLD, $widgetkey); $thermal_sensors_widget_zoneCriticalTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_zone_critical_threshold", DEFAULT_CRITICAL_THRESHOLD, $widgetkey); $thermal_sensors_widget_coreWarningTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_core_warning_threshold", DEFAULT_WARNING_THRESHOLD, $widgetkey); $thermal_sensors_widget_coreCriticalTempThreshold = getThresholdValueFromConfig($user_settings, "thermal_sensors_widget_core_critical_threshold", DEFAULT_CRITICAL_THRESHOLD, $widgetkey); //get display settings from config (apply defaults if missing) $thermal_sensors_widget_showRawOutput = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_show_raw_output", false, $widgetkey); $thermal_sensors_widget_showFullSensorName = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_show_full_sensor_name", false, $widgetkey); $thermal_sensors_widget_pulsateWarning = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_pulsate_warning", true, $widgetkey); $thermal_sensors_widget_pulsateCritical = getBoolValueFromConfig($user_settings, "thermal_sensors_widget_pulsate_critical", true, $widgetkey); //========================================================================= ?>