Пример #1
0
function actions_schedules()
{
    global $colors, $sched_actions, $config;
    if (isset($_POST["selected_items"])) {
        $selected_items = unserialize(stripslashes($_POST["selected_items"]));
        if ($_POST["drp_action"] == "1") {
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                db_execute("DELETE FROM plugin_flowview_schedules WHERE id = " . $selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "3") {
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                db_execute("UPDATE plugin_flowview_schedules SET enabled='' WHERE id = " . $selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "4") {
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                db_execute("UPDATE plugin_flowview_schedules SET enabled='on' WHERE id = " . $selected_items[$i]);
            }
        } elseif ($_POST["drp_action"] == "2") {
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                plugin_flowview_run_schedule($selected_items[$i]);
            }
        }
        header("Location: flowview_schedules.php");
        exit;
    }
    /* setup some variables */
    $schedule_list = "";
    /* loop through each of the devices selected on the previous page and get more info about them */
    while (list($var, $val) = each($_POST)) {
        if (ereg("^chk_([0-9]+)\$", $var, $matches)) {
            /* ================= input validation ================= */
            input_validate_input_number($matches[1]);
            /* ==================================================== */
            $schedule_list .= "<li>" . db_fetch_cell("SELECT name FROM plugin_flowview_queries AS pfq\n\t\t\t\tINNER JOIN plugin_flowview_schedules AS pfs \n\t\t\t\tON pfq.id=pfs.savedquery\n\t\t\t\tWHERE pfs.id=" . $matches[1]) . "</li>";
            $schedule_array[] = $matches[1];
        }
    }
    include_once "./plugins/flowview/general_header.php";
    html_start_box("<strong>" . $sched_actions[$_POST["drp_action"]] . "</strong>", "60%", $colors["header_panel"], "3", "center", "");
    print "<form action='flowview_schedules.php' method='post'>\n";
    if ($_POST["drp_action"] == "1") {
        /* Delete */
        print "\t<tr>\n\t\t\t\t<td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>To delete the following Schedule(s), press the 'Continue' button.</p>\n\t\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t\t</tr>";
    } elseif ($_POST["drp_action"] == "2") {
        /* Send Now */
        print "\t<tr>\n\t\t\t\t<td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>To send the following Schedule(s), press the 'Continue' button.</p>\n\t\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t\t</tr>";
    } elseif ($_POST["drp_action"] == "3") {
        /* Disable */
        print "\t<tr>\n\t\t\t\t<td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>To Disable the following Schedule(s), press the 'Continue' button.</p>\n\t\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t\t</tr>";
    } elseif ($_POST["drp_action"] == "4") {
        /* Enable */
        print "\t<tr>\n\t\t\t\t<td colspan='2' class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t<p>To Enable the following Schedule(s), press the 'Continue' button.</p>\n\t\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t\t</tr>";
    }
    if (!isset($schedule_array)) {
        print "<tr><td bgcolor='#" . $colors["form_alternate1"] . "'><span class='textError'>You must select at least one schedule.</span></td></tr>\n";
        $save_html = "";
    } else {
        $save_html = "<input type='submit' value='Continue'>";
    }
    print "\t<tr>\n\t\t\t<td colspan='2' align='right' bgcolor='#eaeaea'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($schedule_array) ? serialize($schedule_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>\n\t\t\t\t<input type='button' onClick='javascript:document.location=\"flowview_schedules.php\"' value='Cancel'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n\t\t";
    html_end_box();
    include_once "./include/bottom_footer.php";
}
Пример #2
0
 +-------------------------------------------------------------------------+
 | http://www.cacti.net/                                                   |
 +-------------------------------------------------------------------------+
*/
/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
    die("<br><strong>This script is only meant to run at the command line.</strong>");
}
error_reporting('E_ALL');
$dir = dirname(__FILE__);
chdir($dir);
ini_set("max_execution_time", 0);
ini_set("memory_limit", "256M");
if (strpos($dir, 'plugins') !== false) {
    chdir('../../');
}
if (file_exists("./include/global.php")) {
    include "./include/global.php";
} else {
    include "./include/config.php";
}
include_once $config['base_path'] . '/plugins/flowview/functions.php';
$t = time();
$r = intval($t / 60) * 60;
$schedules = db_fetch_assoc("SELECT * FROM plugin_flowview_schedules WHERE enabled = 'on' AND ({$t} - sendinterval > lastsent)");
if (count($schedules)) {
    foreach ($schedules as $s) {
        plugin_flowview_run_schedule($s['id']);
        db_execute("UPDATE plugin_flowview_schedules SET lastsent = {$r} WHERE id = " . $s['id']);
    }
}
Пример #3
0
function actions_schedules()
{
    global $colors, $sched_actions, $config;
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var_post('drp_action'));
    /* ==================================================== */
    if (isset_request_var('selected_items')) {
        $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
        if ($selected_items != false) {
            if (get_nfilter_request_var('drp_action') == '1') {
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute('DELETE FROM plugin_flowview_schedules WHERE id = ' . $selected_items[$i]);
                }
            } elseif (get_nfilter_request_var('drp_action') == '3') {
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute("UPDATE plugin_flowview_schedules SET enabled='' WHERE id = " . $selected_items[$i]);
                }
            } elseif (get_nfilter_request_var('drp_action') == '4') {
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute("UPDATE plugin_flowview_schedules SET enabled='on' WHERE id = " . $selected_items[$i]);
                }
            } elseif (get_nfilter_request_var('drp_action') == '2') {
                for ($i = 0; $i < count($selected_items); $i++) {
                    plugin_flowview_run_schedule($selected_items[$i]);
                }
            }
        }
        header('Location: flowview_schedules.php?tab=sched&header=false');
        exit;
    }
    /* setup some variables */
    $schedule_list = '';
    /* loop through each of the devices selected on the previous page and get more info about them */
    while (list($var, $val) = each($_POST)) {
        if (preg_match('/^chk_([0-9]+)$/', $var, $matches)) {
            /* ================= input validation ================= */
            input_validate_input_number($matches[1]);
            /* ==================================================== */
            $schedule_list .= '<li>' . db_fetch_cell_prepared('SELECT name FROM plugin_flowview_queries AS pfq
				INNER JOIN plugin_flowview_schedules AS pfs 
				ON pfq.id=pfs.savedquery
				WHERE pfs.id = ?', array($matches[1])) . '</li>';
            $schedule_array[] = $matches[1];
        }
    }
    general_header();
    form_start('flowview_schedules.php');
    html_start_box($sched_actions[get_nfilter_request_var('drp_action')], '60%', '', '3', 'center', '');
    if (get_nfilter_request_var('drp_action') == '1') {
        /* Delete */
        print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to delete the following Schedule(s).</p>\n\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>";
    } elseif (get_nfilter_request_var('drp_action') == '2') {
        /* Send Now */
        print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to send the following Schedule(s) now.</p>\n\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>";
    } elseif (get_nfilter_request_var('drp_action') == '3') {
        /* Disable */
        print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to Disable the following Schedule(s).</p>\n\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>";
    } elseif (get_nfilter_request_var('drp_action') == '4') {
        /* Enable */
        print "<tr>\n\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t<p>Click 'Continue' to Enable the following Schedule(s).</p>\n\t\t\t\t<p><ul>{$schedule_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>";
    }
    if (!isset($schedule_array)) {
        print "<tr><td><span class='textError'>You must select at least one schedule.</span></td></tr>\n";
        $save_html = '';
    } else {
        $save_html = "<input type='submit' value='Continue'>";
    }
    print "<tr>\n\t\t<td colspan='2' align='right' class='saveRow'>\n\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t<input type='hidden' name='selected_items' value='" . (isset($schedule_array) ? serialize($schedule_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_nfilter_request_var('drp_action') . "'>\n\t\t\t<input type='button' onClick='cactiReturnTo()' value='Cancel'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>";
    html_end_box();
    form_end();
    bottom_footer();
}