Beispiel #1
0
function form_actions()
{
    global $config, $syslog_actions, $fields_syslog_action_edit;
    include dirname(__FILE__) . '/config.php';
    get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9_]+)$/')));
    /* if we are to save this form, instead of display it */
    if (isset_request_var('selected_items')) {
        $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
        if ($selected_items != false) {
            if (get_request_var('drp_action') == '1') {
                /* delete */
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_syslog_removal_remove($selected_items[$i]);
                }
            } else {
                if (get_request_var('drp_action') == '2') {
                    /* disable */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        api_syslog_removal_disable($selected_items[$i]);
                    }
                } else {
                    if (get_request_var('drp_action') == '3') {
                        /* enable */
                        for ($i = 0; $i < count($selected_items); $i++) {
                            api_syslog_removal_enable($selected_items[$i]);
                        }
                    } else {
                        if (get_request_var('drp_action') == '4') {
                            /* reprocess */
                            for ($i = 0; $i < count($selected_items); $i++) {
                                api_syslog_removal_reprocess($selected_items[$i]);
                            }
                        }
                    }
                }
            }
        }
        header('Location: syslog_removal.php?header=false');
        exit;
    }
    top_header();
    form_start('syslog_removal.php');
    html_start_box($syslog_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    /* setup some variables */
    $removal_array = array();
    $removal_list = '';
    /* loop through each of the clusters 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]);
            /* ==================================================== */
            $removal_info = syslog_db_fetch_cell("SELECT name FROM `" . $syslogdb_default . "`.`syslog_remove` WHERE id=" . $matches[1]);
            $removal_list .= '<li>' . $removal_info . '</li>';
            $removal_array[] = $matches[1];
        }
    }
    if (sizeof($removal_array)) {
        if (get_request_var('drp_action') == '1') {
            /* delete */
            print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>";
            print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
            $title = __('Delete Syslog Removal Rule(s)');
        } else {
            if (get_request_var('drp_action') == '2') {
                /* disable */
                print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Disable the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>";
                print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
                $title = __('Disable Syslog Removal Rule(s)');
            } else {
                if (get_request_var('drp_action') == '3') {
                    /* enable */
                    print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Enable the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>";
                    print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
                    $title = __('Enable Syslog Removal Rule(s)');
                } else {
                    if (get_request_var('drp_action') == '4') {
                        /* reprocess */
                        print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Re-process the following Syslog Removal Rule(s).') . "</p>\n\t\t\t\t\t<ul>{$removal_list}</ul>";
                        print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
                        $title = __('Retroactively Process Syslog Removal Rule(s)');
                    }
                }
            }
        }
        $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='{$title}'";
    } else {
        print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Syslog Removal Rule.') . "</span></td></tr>\n";
        $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
    }
    print "\t<tr>\n\t\t<td 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($removal_array) ? serialize($removal_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n";
    html_end_box();
    form_end();
    bottom_footer();
}
Beispiel #2
0
function form_actions()
{
    global $colors, $config, $syslog_actions, $fields_syslog_action_edit;
    include dirname(__FILE__) . "/config.php";
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = unserialize(stripslashes($_POST["selected_items"]));
        if ($_POST["drp_action"] == "1") {
            /* delete */
            for ($i = 0; $i < count($selected_items); $i++) {
                /* ================= input validation ================= */
                input_validate_input_number($selected_items[$i]);
                /* ==================================================== */
                api_syslog_removal_remove($selected_items[$i]);
            }
        } else {
            if ($_POST["drp_action"] == "2") {
                /* disable */
                for ($i = 0; $i < count($selected_items); $i++) {
                    /* ================= input validation ================= */
                    input_validate_input_number($selected_items[$i]);
                    /* ==================================================== */
                    api_syslog_removal_disable($selected_items[$i]);
                }
            } else {
                if ($_POST["drp_action"] == "3") {
                    /* enable */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        /* ================= input validation ================= */
                        input_validate_input_number($selected_items[$i]);
                        /* ==================================================== */
                        api_syslog_removal_enable($selected_items[$i]);
                    }
                }
            }
        }
        header("Location: syslog_removal.php");
        exit;
    }
    include_once $config['base_path'] . "/include/top_header.php";
    html_start_box("<strong>" . $syslog_actions[$_POST["drp_action"]] . "</strong>", "60%", $colors["header_panel"], "3", "center", "");
    print "<form action='syslog_removal.php' method='post'>\n";
    /* setup some variables */
    $removal_array = array();
    $removal_list = "";
    /* loop through each of the clusters 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]);
            /* ==================================================== */
            $removal_info = syslog_db_fetch_cell("SELECT name FROM `" . $syslogdb_default . "`.`syslog_remove` WHERE id=" . $matches[1]);
            $removal_list .= "<li>" . $removal_info . "<br>";
            $removal_array[] = $matches[1];
        }
    }
    if (sizeof($removal_array)) {
        if ($_POST["drp_action"] == "1") {
            /* delete */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t\t<p>If you click 'Continue', the following Syslog Removal Rule(s) will be deleted</p>\n\t\t\t\t\t\t<ul>{$removal_list}</ul>";
            print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
            $title = "Delete Syslog Removal Rule(s)";
        } else {
            if ($_POST["drp_action"] == "2") {
                /* disable */
                print "\t<tr>\n\t\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t\t<p>If you click 'Continue', the following Syslog Removal Rule(s) will be disabled</p>\n\t\t\t\t\t\t<ul>{$removal_list}</ul>";
                print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $title = "Disable Syslog Removal Rule(s)";
            } else {
                if ($_POST["drp_action"] == "3") {
                    /* enable */
                    print "\t<tr>\n\t\t\t\t\t<td class='textArea' bgcolor='#" . $colors["form_alternate1"] . "'>\n\t\t\t\t\t\t<p>If you click 'Continue', the following Syslog Removal Rule(s) will be enabled</p>\n\t\t\t\t\t\t<ul>{$removal_list}</ul>";
                    print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                    $title = "Enable Syslog Removal Rule(s)";
                }
            }
        }
        $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='{$title}'";
    } else {
        print "<tr><td bgcolor='#" . $colors["form_alternate1"] . "'><span class='textError'>You must select at least one Syslog Removal Rule.</span></td></tr>\n";
        $save_html = "<input type='button' value='Return' onClick='window.history.back()'>";
    }
    print "\t<tr>\n\t\t\t<td 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($removal_array) ? serialize($removal_array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n\t\t";
    html_end_box();
    include_once $config['base_path'] . "/include/bottom_footer.php";
}