// convert relative time-span settings into absolute ones foreach ($list_modules as $modul) { if (isset($_SESSION['set_' . $modul . '_time_rel']) && $_SESSION['set_' . $modul . '_time_rel']) { if (!$_SESSION['set_' . $modul . '_time_span']) { $changed[$modul] = true; } else { if (isset($_SESSION['set_' . $modul . '_time_start'])) { $old_start = $_SESSION['set_' . $modul . '_time_start']; } if (isset($_SESSION['set_' . $modul . '_time_end'])) { $old_end = $_SESSION['set_' . $modul . '_time_end']; } } $_SESSION['set_' . $modul . '_time_span'] = true; $_SESSION['set_' . $modul . '_time_start'] = parse_str_to_time($_SESSION['set_' . $modul . '_time_rel_start']); $_SESSION['set_' . $modul . '_time_end'] = parse_str_to_time($_SESSION['set_' . $modul . '_time_rel_end']); $_SESSION['set_' . $modul . '_time_name'] = time_replace_chars($_SESSION['set_' . $modul . '_time_rel_name']); if (isset($old_start) && isset($old_end) && ($old_start != $_SESSION['set_' . $modul . '_time_start'] || $old_end != $_SESSION['set_' . $modul . '_time_end'])) { $changed[$modul] = true; } unset($old_start); unset($old_end); } } if (empty($message_fatal)) { // read cache $all_cached = true; foreach ($list_modules as $modul) { if ($config_stat_cache && isset($_SESSION['module_' . $modul . '_data']) && (!isset($changed[$modul]) || !$changed[$modul]) && (!isset($_GET['reload']) || $_GET['reload'] != 'true')) { $cached[$modul] = true; } else {
function preset($preset_id, $overwrite = true, $check_only = false, $correct_time_overflow = false) { /* This function iterates through a $config_preset-Array and does different things: - (normally) loads the given preset (this is triggered via the preset-selection-box) - if $overwrite is false, do not overwrite existing settings! (this is used to always load the default-preset without overwriting changed settings) - if $check_only is true, only check whether the settings for IP and time are currently set (this is used for DFC/PFC) - if $correct_time_overflow is true, clear data that was cached but is no longer within timespan. */ #echo "<b>$preset_id | overwrite=".($overwrite?1:0)." | check_only=".($check_only?1:0)." | correct_time_overflow=".($correct_time_overflow?1:0)." </b><br />"; global $list_modules, $list_modules_limit, $list_modules_diagram, $list_modules_calendar, $config_preset, $changed; $analyze_settings = array('ip', 'time_start', 'time_end', 'time_span', 'time_rel', 'time_rel_start', 'time_rel_end'); $preset_data = $config_preset[$preset_id]; // load presets which this preset is based on if (!empty($preset_data['presets'])) { foreach ($preset_data['presets'] as $load_preset) { if ($check_only && !preset($load_preset, $overwrite, $check_only)) { return false; } elseif (!$check_only) { preset($load_preset, $overwrite, $check_only, $correct_time_overflow); } } } // set module-specific settings if (!empty($preset_data['modules'])) { foreach ($preset_data['modules'] as $modul => $module_data) { $global = false; switch ($modul) { case 'ALL': $set_modules = $list_modules; break; case 'LIMIT': $set_modules = $list_modules_limit; break; case 'CHARTS': $set_modules = $list_modules_diagram; break; case 'CALENDAR': $set_modules = $list_modules_calendar; break; case 'GLOBAL': $global = true; break; default: $set_modules = array($modul); } // now we know for which modules the settings are meant if (!$global) { foreach ($set_modules as $set_module) { $mod_isrel = isset($_SESSION['set_' . $set_module . '_time_rel']) && $_SESSION['set_' . $set_module . '_time_rel']; // if $correct_time_overflow is true, check and clear (if outdated) cache data if (!$check_only && $correct_time_overflow && $mod_isrel && isset($module_data['time_rel_start'])) { $check_start = parse_str_to_time($module_data['time_rel_start']); foreach ($_SESSION['module_' . $set_module . '_data_timestamps'] as $mod_value => $check_timestamps) { foreach ($check_timestamps as $check_timestamp_id => $check_timestamp) { if ($check_timestamp < $check_start) { // delete this timestamp and decrease this value by one unset($_SESSION['module_' . $set_module . '_data_timestamps'][$mod_value][$check_timestamp_id]); $_SESSION['module_' . $set_module . '_data'][$mod_value]--; // if the value is <=0, delete the entry if the module supports "limit" if ($_SESSION['module_' . $set_module . '_data'][$mod_value] < 1 && in_array($set_module, $list_modules_limit)) { unset($_SESSION['module_' . $set_module . '_data'][$mod_value]); } } } } } else { foreach ($module_data as $setting => $value) { // first convert "GNU times" (such as "today") into timestamps if (($setting == 'time_start' || $setting == 'time_end') && is_string($value)) { $value = strtotime($value); } // here the actual action is performed // normally: set the setting to the new value if (!$check_only && !$correct_time_overflow && ($overwrite || !isset($_SESSION['set_' . $set_module . '_' . $setting])) && (!isset($_SESSION['set_' . $set_module . '_' . $setting]) || $_SESSION['set_' . $set_module . '_' . $setting] !== $value)) { if (in_array($setting, $analyze_settings) && (!isset($_SESSION['set_' . $set_module . '_' . $setting]) || $_SESSION['set_' . $set_module . '_' . $setting] !== $value)) { $changed[$set_module] = true; } $_SESSION['set_' . $set_module . '_' . $setting] = $value; } elseif ($check_only && !$correct_time_overflow && in_array($setting, $analyze_settings) && (!isset($_SESSION['set_' . $set_module . '_' . $setting]) || $_SESSION['set_' . $set_module . '_' . $setting] != $value) && (!$mod_isrel || $setting != 'time_end' && $setting != 'time_start')) { return false; } } } } } elseif (!$check_only && !$correct_time_overflow) { foreach ($module_data as $setting => $value) { if ($setting == 'tree' && $value == 'auto' && isset($_SESSION['ajax']) && $_SESSION['ajax']) { $value = 'ajax'; } elseif ($setting == 'tree' && $value == 'auto') { $value = 'mk'; } if ($overwrite || !isset($_SESSION[$setting])) { $_SESSION[$setting] = $value; } } } } } if ($check_only) { return true; } }
<tr><td> </td><td><?php if (isset($_POST['rel_start']) && isset($_POST['action']) && $_POST['action'] == L_CALENDAR_RELATIVE_CHECK) { echo date(L_DATE_FORMAT . ' - ' . L_TIME_FORMAT, parse_str_to_time($_POST['rel_start'])); } ?> </td></tr> <tr><td><?php echo L_CALENDAR_END; ?> *</td><td><input type="text" id="rel_end" name="rel_end" value="<?php echo isset($_POST['rel_end']) ? $_POST['rel_end'] : (isset($_SESSION['set_' . $module . '_time_rel_end']) ? $_SESSION['set_' . $module . '_time_rel_end'] : '%Y/%m/1 +1month -1second'); ?> " onchange="is_custom()" /></td></tr> <tr><td> </td><td><?php if (isset($_POST['rel_end']) && isset($_POST['action']) && $_POST['action'] == L_CALENDAR_RELATIVE_CHECK) { echo date(L_DATE_FORMAT . ' - ' . L_TIME_FORMAT, parse_str_to_time($_POST['rel_end'])); } ?> </td></tr> <tr><td><?php echo L_CALENDAR_START; ?> #</td><td><input type="text" id="rel_startid" name="rel_startid" value="<?php echo isset($_POST['rel_startid']) ? $_POST['rel_startid'] : (isset($_SESSION['set_' . $module . '_time_rel_startid']) ? $_SESSION['set_' . $module . '_time_rel_startid'] : ''); ?> " onchange="is_custom()" /></td></tr> <tr><td> </td><td><?php if (isset($_POST['rel_startid']) && isset($_POST['action']) && $_POST['action'] == L_CALENDAR_RELATIVE_CHECK) { echo calc_start_id($_POST['rel_startid']); } ?>