#!/usr/local/bin/php . All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // Title $pgtitle = array("Services", "Scheduler"); // m0n0wall & shared functions require_once("guiconfig.inc"); // Default config croen_set_default_config(); // Save if (isset($_POST['save']) || isset($_POST['apply'])) { unset($input_errors); // Validate if (!isset($_POST['apply'])) { // 1: Input validation (required fields exist) $reqdfields = Array('interval'); $reqdfieldsn = Array('Loop interval'); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); // 2: Input validation (field values) if (!$input_errors) { if (!ctype_digit($_POST['interval']) || (int)$_POST['interval'] < 1 || (int)$_POST['interval'] > 60) { $input_errors[] = "The loop interval has to be between 1 and 60"; } } // 3: Set config variables & write config if (!$input_errors) { // Config variables $config['croen']['interval'] = (int)$_POST['interval']; $config['croen']['enable'] = (isset($_POST['enable']) ? TRUE : FALSE); // Write config write_config(); } } // Restart service & retrieve save message if (!$input_errors) { $retval = 0; if (!file_exists($d_sysrebootreqd_path)) { config_lock(); $retval = services_croen_configure(); config_unlock(); } $savemsg = get_std_save_message($retval); if ($retval == 0) { if (file_exists($d_croendirty_path)) { unlink($d_croendirty_path); } } } } // Shared vars $data = croen_vars(Array('descr', 'repeat', 'date_once', 'date_weekly')); // Croen form vars $pconfig['enable'] = (isset($config['croen']['enable']) ? TRUE : FALSE); $pconfig['interval'] = (isset($config['croen']['interval']) ? $config['croen']['interval'] : 10); $pconfig['jobset'] = &$config['croen']['jobset']; // Actions $config_changed = FALSE; foreach ($_POST as $pn => $pv) { // Delete job if (preg_match("/^del_(\d+)_x$/", $pn, $matches)) { unset($pconfig['jobset'][$matches[1]]); $config_changed = TRUE; // Toggle job } elseif (preg_match("/^toggle_(\d+)_x$/", $pn, $matches)) { if (isset($pconfig['jobset'][$matches[1]])) { $pconfig['jobset'][$matches[1]]['disabled'] = !isset($pconfig['jobset'][$matches[1]]['disabled']); } $config_changed = TRUE; } } // Changed someting: Write config, set dirty & reroute if ($config_changed) { if ($pconfig['enable']) { touch($d_croendirty_path); } write_config(); header("Location: services_croen.php"); exit; } // Include webinterface include("fbegin.inc"); // JavaScript to modify forms echo ' '; // Show errors (if any) if ($input_errors) { print_input_errors($input_errors); } // Show savemsg (if any) if ($savemsg) { print_info_box($savemsg); } // Show form echo '
'; // m0n0wall include("fend.inc"); ?>