示例#1
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_report_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_report_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_report_enable($selected_items[$i]);
                    }
                }
            }
        }
        header("Location: syslog_reports.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_reports.php' method='post'>\n";
    /* setup some variables */
    $report_array = array();
    $report_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]);
            /* ==================================================== */
            $report_info = syslog_db_fetch_cell("SELECT name FROM `" . $syslogdb_default . "`.`syslog_reports` WHERE id=" . $matches[1]);
            $report_list .= "<li>" . $report_info . "<br>";
            $report_array[] = $matches[1];
        }
    }
    if (sizeof($report_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 Report(s) will be deleted</p>\n\t\t\t\t\t\t<ul>{$report_list}</ul>";
            print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
            $title = "Delete Syslog Report(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 Report(s) will be disabled</p>\n\t\t\t\t\t\t<ul>{$report_list}</ul>";
                print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $title = "Disable Syslog Report(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 Report(s) will be enabled</p>\n\t\t\t\t\t\t<ul>{$report_list}</ul>";
                    print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                    $title = "Enable Syslog Report(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 Report.</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($report_array) ? serialize($report_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";
}
示例#2
0
function form_actions()
{
    global $colors, $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_report_remove($selected_items[$i]);
                }
            } else {
                if (get_request_var('drp_action') == '2') {
                    /* disable */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        api_syslog_report_disable($selected_items[$i]);
                    }
                } else {
                    if (get_request_var('drp_action') == '3') {
                        /* enable */
                        for ($i = 0; $i < count($selected_items); $i++) {
                            api_syslog_report_enable($selected_items[$i]);
                        }
                    }
                }
            }
        }
        header('Location: syslog_reports.php?header=false');
        exit;
    }
    top_header();
    form_start('syslog_reports.php');
    html_start_box($syslog_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    /* setup some variables */
    $report_array = array();
    $report_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]);
            /* ==================================================== */
            $report_info = syslog_db_fetch_cell('SELECT name FROM `' . $syslogdb_default . '`.`syslog_reports` WHERE id=' . $matches[1]);
            $report_list .= '<li>' . $report_info . '</li>';
            $report_array[] = $matches[1];
        }
    }
    if (sizeof($report_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 Report(s).') . "</p>\n\t\t\t\t\t<ul>{$report_list}</ul>";
            print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
            $title = __('Delete Syslog Report(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 Report(s).') . "</p>\n\t\t\t\t\t<ul>{$report_list}</ul>";
                print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
                $title = __('Disable Syslog Report(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 Report(s).') . "</p>\n\t\t\t\t\t<ul>{$report_list}</ul>";
                    print "</td></tr>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
                    $title = __('Enable Syslog Report(s)');
                }
            }
        }
        $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='{$title}'";
    } else {
        print "<tr><td class='odd'><span class='textError'>" . __('You must select at least one Syslog Report.') . "</span></td></tr>\n";
        $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
    }
    print "<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($report_array) ? serialize($report_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();
}