Ejemplo n.º 1
0
function form_actions()
{
    global $config, $macw_actions, $fields_mactrack_macw_edit;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    /* 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_mactrack_macw_remove($selected_items[$i]);
                }
            }
            header('Location: mactrack_macwatch.php');
            exit;
        }
    }
    /* setup some variables */
    $macw_list = '';
    $i = 0;
    /* loop through each of the mac watch items 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]);
            /* ==================================================== */
            $macw_info = db_fetch_cell_prepared('SELECT name FROM mac_track_macwatch WHERE mac_id = ?', array($matches[1]));
            $macw_list .= '<li>' . $macw_info . '</li>';
            $macw_array[$i] = $matches[1];
        }
        $i++;
    }
    top_header();
    html_start_box($macw_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    form_start('mactrack_macwatch.php');
    if (!isset($macw_array)) {
        print "<tr><td class='even'><span class='textError'>" . __('You must select at least one watched Mac to delete.') . "</span></td></tr>\n";
        $save_html = "";
    } else {
        $save_html = "<input type='submit' name='save' value='" . __('Yes') . "'>";
        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>" . __('Are you sure you want to delete the following watched Mac\'s?') . "</p>\n\t\t\t\t\t<p><ul>{$macw_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        }
    }
    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($macw_array) ? serialize($macw_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>" . (strlen($save_html) ? "\n\t\t\t<input type='button' name='cancel' onClick='cactiReturnTo()' value='" . __('No') . "'>\n\t\t\t{$save_html}" : "<input type='button' onClick='cactiReturnTo()' name='cancel' value='" . __('Return') . "'>") . "\n\t\t</td>\n\t</tr>";
    html_end_box();
    form_end();
    bottom_footer();
}
Ejemplo n.º 2
0
function actions_devices()
{
    global $flow_actions, $config;
    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_devices WHERE id = ' . $selected_items[$i]);
                }
            }
        }
        header('Location: flowview_devices.php?tab=listeners&header=false');
        exit;
    }
    /* setup some variables */
    $device_list = '';
    $i = 0;
    /* 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]);
            /* ==================================================== */
            $device_list .= '<li>' . db_fetch_cell('SELECT name FROM plugin_flowview_devices WHERE id=' . $matches[1]) . '</li>';
            $device_array[$i] = $matches[1];
        }
        $i++;
    }
    general_header();
    form_start('flowview_devices.php');
    html_start_box($flow_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 Net-Flow Listeners.  After which, you will need to restart your Flow-Capture Service.</p>\n\t\t\t\t<p>Also, remember to remove any left over files from your Net-Flow Capture location.</p>\n\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t</td>\n\t\t</tr>\n";
    }
    if (!isset($device_array)) {
        print "<tr><td class='even'><span class='textError'>You must select at least one device.</span></td></tr>\n";
        $save_html = '';
    } else {
        $save_html = "<input type='submit' value='Continue'>";
    }
    print "<tr>\n\t\t<td 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($device_array) ? serialize($device_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_filter_request_var('drp_action') . "'>\n\t\t\t<input type='button' onClick='javascript:document.location=\"flowview_devices.php\"' value='Cancel'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>\n";
    html_end_box();
    form_end();
    bottom_footer();
}
Ejemplo n.º 3
0
function form_mactrack_snmp_actions()
{
    global $config, $mactrack_snmp_actions;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    /* 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_nfilter_request_var('drp_action') == '1') {
                /* delete */
                db_execute('DELETE FROM mac_track_snmp WHERE ' . array_to_sql_or($selected_items, 'id'));
                db_execute('DELETE FROM mac_track_snmp_items WHERE ' . str_replace('id', 'snmp_id', array_to_sql_or($selected_items, 'id')));
            } elseif (get_nfilter_request_var('drp_action') == '2') {
                /* duplicate */
                for ($i = 0; $i < count($selected_items); $i++) {
                    duplicate_mactrack($selected_items[$i], get_nfilter_request_var('name_format'));
                }
            }
            header('Location: mactrack_snmp.php?header=false');
            exit;
        }
    }
    /* setup some variables */
    $snmp_groups = '';
    $i = 0;
    /* loop through each of the graphs 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]);
            /* ==================================================== */
            $snmp_groups .= '<li>' . db_fetch_cell_prepared('SELECT name FROM mac_track_snmp WHERE id = ?', array($matches[1])) . '</li>';
            $mactrack_array[$i] = $matches[1];
            $i++;
        }
    }
    general_header();
    display_output_messages();
    ?>
	<script type='text/javascript'>
	function goTo(strURL) {
		loadPageNoHeader(strURL);
	}
	</script>
	<?php 
    form_start('mactrack_snmp.php', 'mactrack');
    html_start_box($mactrack_snmp_actions[get_nfilter_request_var('drp_action')], '60%', '', '3', 'center', '');
    if (!isset($mactrack_array)) {
        print "<tr><td class='even'><span class='textError'>" . __('You must select at least one SNMP Option.') . "</span></td></tr>\n";
        $save_html = "";
    } else {
        $save_html = "<input type='submit' value='" . __('Yes') . "' name='save'>";
        if (get_nfilter_request_var("drp_action") == '1') {
            /* delete */
            print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Are you sure you want to delete the following SNMP Options?') . "</p>\n\t\t\t\t\t<p><ul>{$snmp_groups}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        } elseif (get_nfilter_request_var("drp_action") == '2') {
            /* duplicate */
            print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('When you click save, the following SNMP Options will be duplicated. You can optionally change the title format for the new SNMP Options.') . "</p>\n\t\t\t\t\t<p><ul>{$snmp_groups}</ul></p>\n\t\t\t\t\t<p>" . __('Name Format:') . "<br>";
            form_text_box('name_format', '<name> (1)', '', '255', '30', 'text');
            print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        }
    }
    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($mactrack_array) ? serialize($mactrack_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='goTo(\"" . "mactrack_snmp.php" . "\")' value='" . ($save_html == '' ? 'Return' : 'No') . "' name='cancel'>\n\t\t\t{$save_html}\n\t\t</td>\n\t</tr>";
    html_end_box();
    bottom_footer();
}
Ejemplo n.º 4
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();
}
Ejemplo n.º 5
0
function form_actions()
{
    global $actions, $assoc_actions;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset_request_var('selected_items')) {
        if (isset_request_var('save_list')) {
            $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
            if ($selected_items != false) {
                if (get_request_var('drp_action') == '1') {
                    /* delete */
                    db_execute('DELETE FROM plugin_notification_lists WHERE ' . array_to_sql_or($selected_items, 'id'));
                    db_execute('UPDATE host SET thold_send_email=0 WHERE thold_send_email=2 AND ' . array_to_sql_or($selected_items, 'thold_host_email'));
                    db_execute('UPDATE host SET thold_send_email=1 WHERE thold_send_email=3 AND ' . array_to_sql_or($selected_items, 'thold_host_email'));
                    db_execute('UPDATE host SET thold_host_email=0 WHERE ' . array_to_sql_or($selected_items, 'thold_host_email'));
                } elseif (get_request_var('drp_action') == '2') {
                    /* duplicate */
                    // To Do
                }
            }
            header('Location: notify_lists.php?header=false');
            exit;
        } elseif (isset_request_var('save_associate')) {
            $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
            if ($selected_items != false) {
                get_filter_request_var('notification_action');
                if (get_request_var('drp_action') == '1') {
                    /* associate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        /* set the notification list */
                        db_execute('UPDATE host SET thold_host_email=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                        /* set the global/list election */
                        db_execute('UPDATE host SET thold_send_email=' . get_request_var('notification_action') . ' WHERE id=' . $selected_items[$i]);
                    }
                } elseif (get_request_var('drp_action') == '2') {
                    /* disassociate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        /* set the notification list */
                        db_execute('UPDATE host SET thold_host_email=0 WHERE id=' . $selected_items[$i]);
                        /* set the global/list election */
                        db_execute('UPDATE host SET thold_send_email=' . get_request_var('notification_action') . ' WHERE id=' . $selected_items[$i]);
                    }
                }
            }
            header('Location: notify_lists.php?header=false&action=edit&tab=hosts&id=' . get_request_var('id'));
            exit;
        } elseif (isset_request_var('save_templates')) {
            $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
            if ($selected_items != false) {
                get_filter_request_var('notification_action');
                if (get_request_var('drp_action') == '1') {
                    /* associate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        if (get_request_var('notification_warning_action') > 0) {
                            /* clear other settings */
                            if (get_request_var('notification_warning_action') == 1) {
                                /* set the notification list */
                                db_execute('UPDATE thold_template SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                                /* clear other items */
                                db_execute("UPDATE thold_template SET notify_warning_extra='' WHERE id=" . $selected_items[$i]);
                            } else {
                                /* set the notification list */
                                db_execute('UPDATE thold_template SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                            }
                        }
                        if (get_request_var('notification_alert_action') > 0) {
                            /* clear other settings */
                            if (get_request_var('notification_alert_action') == 1) {
                                /* set the notification list */
                                db_execute('UPDATE thold_template SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                                /* clear other items */
                                db_execute("UPDATE thold_template SET notify_extra='' WHERE id=" . $selected_items[$i]);
                                db_execute('DELETE FROM plugin_thold_template_contact WHERE template_id=' . $selected_items[$i]);
                            } else {
                                /* set the notification list */
                                db_execute('UPDATE thold_template SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                            }
                        }
                    }
                } elseif (get_request_var('drp_action') == '2') {
                    /* disassociate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        if (get_request_var('notification_warning_action') > 0) {
                            /* set the notification list */
                            db_execute('UPDATE thold_template SET notify_warning=0 WHERE id=' . $selected_items[$i] . ' AND notify_warning=' . get_request_var('id'));
                        }
                        if (get_request_var('notification_alert_action') > 0) {
                            /* set the notification list */
                            db_execute('UPDATE thold_template SET notify_alert=0 WHERE id=' . $selected_items[$i] . ' AND notify_alert=' . get_request_var('id'));
                        }
                    }
                }
            }
            header('Location: notify_lists.php?header=false&action=edit&tab=templates&id=' . get_request_var('id'));
            exit;
        } elseif (isset_request_var('save_tholds')) {
            $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
            if ($selected_items != false) {
                get_filter_request_var('notification_action');
                if (get_request_var('drp_action') == '1') {
                    /* associate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        if (get_request_var('notification_warning_action') > 0) {
                            /* clear other settings */
                            if (get_request_var('notification_warning_action') == 1) {
                                /* set the notification list */
                                db_execute('UPDATE thold_data SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                                /* clear other items */
                                db_execute("UPDATE thold_data SET notify_warning_extra='' WHERE id=" . $selected_items[$i]);
                            } else {
                                /* set the notification list */
                                db_execute('UPDATE thold_data SET notify_warning=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                            }
                        }
                        if (get_request_var('notification_alert_action') > 0) {
                            /* clear other settings */
                            if (get_request_var('notification_alert_action') == 1) {
                                /* set the notification list */
                                db_execute('UPDATE thold_data SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                                /* clear other items */
                                db_execute("UPDATE thold_data SET notify_extra='' WHERE id=" . $selected_items[$i]);
                                db_execute('DELETE FROM plugin_thold_threshold_contact WHERE thold_id=' . $selected_items[$i]);
                            } else {
                                /* set the notification list */
                                db_execute('UPDATE thold_data SET notify_alert=' . get_request_var('id') . ' WHERE id=' . $selected_items[$i]);
                            }
                        }
                    }
                } elseif (get_request_var('drp_action') == '2') {
                    /* disassociate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        if (get_request_var('notification_warning_action') > 0) {
                            /* set the notification list */
                            db_execute('UPDATE thold_data SET notify_warning=0 WHERE id=' . $selected_items[$i] . ' AND notify_warning=' . get_request_var('id'));
                        }
                        if (get_request_var('notification_alert_action') > 0) {
                            /* set the notification list */
                            db_execute('UPDATE thold_data SET notify_alert=0 WHERE id=' . $selected_items[$i] . ' AND notify_alert=' . get_request_var('id'));
                        }
                    }
                }
            }
            header('Location: notify_lists.php?header=false&action=edit&tab=tholds&id=' . get_request_var('id'));
            exit;
        }
    }
    /* setup some variables */
    $list = '';
    $array = array();
    $list_name = '';
    if (isset_request_var('id')) {
        $list_name = db_fetch_cell('SELECT name FROM plugin_notification_lists WHERE id=' . get_filter_request_var('id'));
    }
    if (isset_request_var('save_list')) {
        /* loop through each of the notification lists 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]);
                /* ==================================================== */
                $list .= '<li><b>' . db_fetch_cell('SELECT name FROM plugin_notification_lists WHERE id=' . $matches[1]) . '</b></li>';
                $array[] = $matches[1];
            }
        }
        top_header();
        form_start('notify_lists.php');
        html_start_box($actions[get_request_var('drp_action')] . " {$list_name}", '60%', '', '3', 'center', '');
        print "<form action='notify_lists.php' method='post'>\n";
        if (sizeof($array)) {
            if (get_request_var('drp_action') == '1') {
                /* delete */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete Notification Lists(s).  Any Device(s) or Threshold(s) associated with the List(s) will be reverted to the default.') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Delete Notification List(s)') . "'>";
            } elseif (get_request_var('drp_action') == '2') {
                /* duplicate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Duplicate the following Notification List(s).') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Duplicate Notification List(s)') . "'>";
            }
        } else {
            print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Notification List.') . "</span></td></tr>\n";
            $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
        }
        print "<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='save_list' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
        html_end_box();
        form_end();
        bottom_footer();
    } elseif (isset_request_var('save_templates')) {
        /* loop through each of the notification lists 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]);
                /* ==================================================== */
                $list .= '<li><b>' . db_fetch_cell('SELECT name FROM thold_template WHERE id=' . $matches[1]) . '</b></li>';
                $array[] = $matches[1];
            }
        }
        top_header();
        form_start('notify_lists.php');
        html_start_box(__('%s Threshold Template(s)', $assoc_actions[get_request_var('drp_action')]), '60%', '', '3', 'center', '');
        if (sizeof($array)) {
            if (get_request_var('drp_action') == '1') {
                /* associate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Association the Notification List \'<b>%s</b>\' with the Threshold Template(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>";
                form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>";
                form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>";
            } elseif (get_request_var('drp_action') == '2') {
                /* disassociate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Thresholds Template(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>";
                form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>";
                form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>";
            }
        } else {
            print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Threshold Template.') . "</span></td></tr>\n";
            $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
        }
        print "\t<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_templates' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
        html_end_box();
        form_end();
        bottom_footer();
    } elseif (isset_request_var('save_tholds')) {
        /* loop through each of the notification lists 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]);
                /* ==================================================== */
                $list .= '<li><b>' . db_fetch_cell('SELECT name FROM thold_data WHERE id=' . $matches[1]) . '</b></li>';
                $array[] = $matches[1];
            }
        }
        top_header();
        form_start('notify_lists.php');
        html_start_box(__('%s Threshold(s)', $assoc_actions[get_request_var('drp_action')]), '60%', '', '3', 'center', '');
        if (sizeof($array)) {
            if (get_request_var('drp_action') == '1') {
                /* associate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Associate the Notification List \'<b>%s</b>\' with the Threshold(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>";
                form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>";
                form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Notification List Only'), 2 => __('Notification List, Retain Other Settings')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>";
            } elseif (get_request_var('drp_action') == '2') {
                /* disassociate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Thresholds(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Warning Membership:') . "</b><br>";
                form_dropdown('notification_warning_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t\t<p><b>" . __('Alert Membership:') . "</b><br>";
                form_dropdown('notification_alert_action', array(0 => __('No Change'), 1 => __('Remove List')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>";
            }
        } else {
            print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Threshold.') . "</span></td></tr>\n";
            $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
        }
        print "\t<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_tholds' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
        html_end_box();
        form_end();
        bottom_footer();
    } else {
        /* loop through each of the notification lists 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]);
                /* ==================================================== */
                $list .= '<li>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</li>';
                $array[] = $matches[1];
            }
        }
        top_header();
        form_start('notify_lists.php');
        html_start_box($assoc_actions[get_request_var('drp_action')] . ' Device(s)', '60%', '', '3', 'center', '');
        if (sizeof($array)) {
            if (get_request_var('drp_action') == '1') {
                /* associate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Associate the Notification List \'<b>%s</b>\' with the Device(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Resulting Membership:') . "<br>";
                form_dropdown('notification_action', array(2 => __('Notification List Only'), 3 => __('Notification and Global Lists')), '', '', 2, '', '');
                print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Associate Notification List(s)') . "'>";
            } elseif (get_request_var('drp_action') == '2') {
                /* disassociate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Disassociate the Notification List \'<b>%s</b>\' from the Device(s) below.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t\t<p><b>" . __('Resulting Membership:') . "</b><br>";
                form_dropdown('notification_action', array(1 => __('Global List'), 0 => __('Disabled')), '', '', 1, '', '');
                print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Notification List(s)') . "'>";
            }
        } else {
            print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n";
            $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
        }
        print "<tr>\n\t\t\t\t<td class='saveRow'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_associate' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
        html_end_box();
        form_end();
        bottom_footer();
    }
}
Ejemplo n.º 6
0
function form_aggregated_actions()
{
    global $config, $mactrack_view_agg_macs_actions;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    /* 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') == '01') {
                /* Delete */
                if (sizeof($selected_items)) {
                    db_execute('DELETE FROM mac_track_aggregated_ports WHERE row_id IN (' . implode(',', $selected_items) . ')');
                }
            }
            header('Location: mactrack_view_macs.php');
            exit;
        }
    }
    /* setup some variables */
    $row_array = array();
    $mac_address_list = '';
    $row_list = '';
    $i = 0;
    $row_ids = '';
    /* loop through each of the ports 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]);
            /* ==================================================== */
            $row_array[] = $matches[1];
        }
    }
    if (sizeof($row_array)) {
        $row_ids = implode(',', $row_array);
        $rows_info = db_fetch_assoc('SELECT device_name, mac_address, ip_address, port_number, count_rec 
			FROM mac_track_aggregated_ports 
			WHERE row_id IN (' . implode(',', $row_array) . ')');
        if (isset($rows_info)) {
            foreach ($rows_info as $row_info) {
                $row_list .= '<li>' . __(' Dev.:%s IP.:%s MAC.:%s PORT.:%s Count.: [%s]', $row_info['device_name'], $row_info['ip_address'], $row_info['mac_address'], $row_info['port_number'], $row_info['count_rec']) . '</li>';
            }
        }
    }
    top_header();
    html_start_box($mactrack_view_agg_macs_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    form_start('mactrack_view_macs.php');
    if (!sizeof($row_array)) {
        print "<tr><td class='even'><span class='textError'>" . __('You must select at least one Row.') . "</span></td></tr>\n";
        $save_html = "";
    } else {
        if (!mactrack_check_user_realm(2122)) {
            print "<tr><td class='even'><span class='textError'>" . __('You are not permitted to delete rows.') . "</span></td></tr>\n";
            $save_html = "";
        } else {
            $save_html = "<input type='submit' name='save' value='" . __('Yes') . "'>";
            if (get_request_var('drp_action') == '1') {
                /* Delete Macs */
                print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Are you sure you want to Delete the following rows from Aggregated table?') . "</p>\n\t\t\t\t\t<p><ul>{$row_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
            }
        }
    }
    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($row_array) ? serialize($row_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>" . (strlen($save_html) ? "\n\t\t\t<input type='submit' name='cancel_x' value='No'>\n\t\t\t{$save_html}" : "<input type='submit' name='cancel' value='Return'>") . "\n\t\t</td>\n\t</tr>";
    html_end_box();
    bottom_footer();
}
Ejemplo n.º 7
0
function form_actions()
{
    global $graph_actions;
    /* ================= input validation ================= */
    input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)\$");
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = sanitize_unserialize_selected_items($_POST['selected_items']);
        if ($selected_items != false) {
            if ($_POST["drp_action"] == "1") {
                /* delete */
                if (!isset($_POST["delete_type"])) {
                    $_POST["delete_type"] = 1;
                }
                switch ($_POST["delete_type"]) {
                    case '2':
                        /* delete all data sources referenced by this graph */
                        $data_sources = array_rekey(db_fetch_assoc("SELECT data_template_data.local_data_id\n\t\t\t\t\t\t\tFROM (data_template_rrd, data_template_data, graph_templates_item)\n\t\t\t\t\t\t\tWHERE graph_templates_item.task_item_id=data_template_rrd.id\n\t\t\t\t\t\t\tAND data_template_rrd.local_data_id=data_template_data.local_data_id\n\t\t\t\t\t\t\tAND " . array_to_sql_or($selected_items, "graph_templates_item.local_graph_id") . "\n\t\t\t\t\t\t\tAND data_template_data.local_data_id > 0"), "local_data_id", "local_data_id");
                        if (sizeof($data_sources)) {
                            api_data_source_remove_multi($data_sources);
                            api_plugin_hook_function('data_source_remove', $data_sources);
                        }
                        break;
                }
                api_graph_remove_multi($selected_items);
                api_plugin_hook_function('graphs_remove', $selected_items);
            } elseif ($_POST["drp_action"] == "2") {
                /* change graph template */
                input_validate_input_number(get_request_var_post("graph_template_id"));
                for ($i = 0; $i < count($selected_items); $i++) {
                    change_graph_template($selected_items[$i], $_POST["graph_template_id"], true);
                }
            } elseif ($_POST["drp_action"] == "3") {
                /* duplicate */
                for ($i = 0; $i < count($selected_items); $i++) {
                    duplicate_graph($selected_items[$i], 0, $_POST["title_format"]);
                }
            } elseif ($_POST["drp_action"] == "4") {
                /* graph -> graph template */
                for ($i = 0; $i < count($selected_items); $i++) {
                    graph_to_graph_template($selected_items[$i], $_POST["title_format"]);
                }
            } elseif (preg_match("/^tr_([0-9]+)\$/", $_POST["drp_action"], $matches)) {
                /* place on tree */
                input_validate_input_number(get_request_var_post("tree_id"));
                input_validate_input_number(get_request_var_post("tree_item_id"));
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_tree_item_save(0, $_POST["tree_id"], TREE_ITEM_TYPE_GRAPH, $_POST["tree_item_id"], "", $selected_items[$i], read_graph_config_option("default_rra_id"), 0, 0, 0, false);
                }
            } elseif ($_POST["drp_action"] == "5") {
                /* change host */
                input_validate_input_number(get_request_var_post("host_id"));
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute("update graph_local set host_id=" . $_POST["host_id"] . " where id=" . $selected_items[$i]);
                    update_graph_title_cache($selected_items[$i]);
                }
            } elseif ($_POST["drp_action"] == "6") {
                /* reapply suggested naming */
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_reapply_suggested_graph_title($selected_items[$i]);
                    update_graph_title_cache($selected_items[$i]);
                }
            } elseif ($_POST["drp_action"] == "7") {
                /* resize graphs */
                input_validate_input_number(get_request_var_post("graph_width"));
                input_validate_input_number(get_request_var_post("graph_height"));
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_resize_graphs($selected_items[$i], $_POST["graph_width"], $_POST["graph_height"]);
                }
            } else {
                api_plugin_hook_function('graphs_action_execute', $_POST['drp_action']);
            }
            api_plugin_hook_function('graphs_action_bottom', array($_POST['drp_action'], $selected_items));
        }
        header("Location: graphs.php");
        exit;
    }
    /* setup some variables */
    $graph_list = "";
    $i = 0;
    /* loop through each of the graphs 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]);
            /* ==================================================== */
            $graph_list .= "<li>" . htmlspecialchars(get_graph_title($matches[1])) . "</li>";
            $graph_array[$i] = $matches[1];
            $i++;
        }
    }
    include_once "./include/top_header.php";
    /* add a list of tree names to the actions dropdown */
    add_tree_names_to_actions_array();
    html_start_box("<strong>" . $graph_actions[$_POST["drp_action"]] . "</strong>", "60%", "", "3", "center", "");
    print "<form action='graphs.php' method='post'>\n";
    if (isset($graph_array) && sizeof($graph_array)) {
        if ($_POST["drp_action"] == "1") {
            /* delete */
            $graphs = array();
            /* find out which (if any) data sources are being used by this graph, so we can tell the user */
            if (isset($graph_array) && sizeof($graph_array)) {
                $data_sources = db_fetch_assoc("select\n\t\t\t\t\tdata_template_data.local_data_id,\n\t\t\t\t\tdata_template_data.name_cache\n\t\t\t\t\tfrom (data_template_rrd,data_template_data,graph_templates_item)\n\t\t\t\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\t\t\t\tand data_template_rrd.local_data_id=data_template_data.local_data_id\n\t\t\t\t\tand " . array_to_sql_or($graph_array, "graph_templates_item.local_graph_id") . "\n\t\t\t\t\tand data_template_data.local_data_id > 0\n\t\t\t\t\tgroup by data_template_data.local_data_id\n\t\t\t\t\torder by data_template_data.name_cache");
            }
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Graph(s) will be deleted.  Please note, Data Source(s) should be deleted only if they are only used by these Graph(s)\n\t\t\t\t\t\tand not others.</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>";
            if (isset($data_sources) && sizeof($data_sources)) {
                print "<tr><td class='textArea'><p>The following Data Source(s) are in use by these Graph(s):</p>\n";
                print "<ul>";
                foreach ($data_sources as $data_source) {
                    print "<li><strong>" . $data_source["name_cache"] . "</strong></li>\n";
                }
                print "</ul>";
                print "<br>";
                form_radio_button("delete_type", "1", "1", "Leave the Data Source(s) untouched.", "1");
                print "<br>";
                form_radio_button("delete_type", "1", "2", "Delete all <strong>Data Source(s)</strong> referenced by these Graph(s).", "1");
                print "<br>";
                print "</td></tr>";
            }
            print "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete Graph(s)'>";
        } elseif ($_POST["drp_action"] == "2") {
            /* change graph template */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>Choose a Graph Template and click \"Continue\" to change the Graph Template for\n\t\t\t\t\t\tthe following Graph(s). Be aware that all warnings will be suppressed during the\n\t\t\t\t\t\tconversion, so Graph data loss is possible.</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>New Graph Template:</strong><br>";
            form_dropdown("graph_template_id", db_fetch_assoc("select graph_templates.id,graph_templates.name from graph_templates order by name"), "name", "id", "", "", "0");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Change Graph Template'>";
        } elseif ($_POST["drp_action"] == "3") {
            /* duplicate */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Graph(s) will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new Graph(s).</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>";
            form_text_box("title_format", "<graph_title> (1)", "", "255", "30", "text");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Duplicate Graph(s)'>";
        } elseif ($_POST["drp_action"] == "4") {
            /* graph -> graph template */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Graph(s) will be converted into Graph Template(s).\n\t\t\t\t\t\tYou can optionally change the title format for the new Graph Template(s).</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>";
            form_text_box("title_format", "<graph_title> Template", "", "255", "30", "text");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Convert to Graph Template'>";
        } elseif (preg_match("/^tr_([0-9]+)\$/", $_POST["drp_action"], $matches)) {
            /* place on tree */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Graph(s) will be placed under the Tree Branch selected below.</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Destination Branch:</strong><br>";
            grow_dropdown_tree($matches[1], "tree_item_id", "0");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t<input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Place Graph(s) on Tree'>";
        } elseif ($_POST["drp_action"] == "5") {
            /* change host */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>Choose a new Device for these Graph(s) and click \"Continue\"</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>New Host:</strong><br>";
            form_dropdown("host_id", db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"), "name", "id", "", "", "0");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Change Graph(s) Associated Device'>";
        } elseif ($_POST["drp_action"] == "6") {
            /* reapply suggested naming to host */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Graph(s) will have thier suggested naming convensions\n\t\t\t\t\t\trecalculated and applied to the Graph(s).</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Reapply Suggested Naming to Graph(s)'>";
        } elseif ($_POST["drp_action"] == "7") {
            /* resize graphs */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Graph(s) will be resized per your specifications.</p>\n\t\t\t\t\t\t<p><ul>{$graph_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Graph Height:</strong><br>";
            form_text_box("graph_height", "", "", "255", "30", "text");
            print "</p>\n\t\t\t\t\t\t<p><strong>Graph Width:</strong><br>";
            form_text_box("graph_width", "", "", "255", "30", "text");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Resize Selected Graph(s)'>";
        } else {
            $save['drp_action'] = $_POST['drp_action'];
            $save['graph_list'] = $graph_list;
            $save['graph_array'] = isset($graph_array) ? $graph_array : array();
            api_plugin_hook_function('graphs_action_prepare', $save);
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
        }
    } else {
        print "<tr><td class='even'><span class='textError'>You must select at least one graph.</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' class='saveRow'>\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($graph_array) ? serialize($graph_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 "./include/bottom_footer.php";
}
Ejemplo n.º 8
0
/**
 * perform mactrack_device execute action
 * @arg $action				action to be performed
 * return				-
 *  */
function mactrack_device_action_execute($action)
{
    global $config;
    # it's our turn
    if ($action == 'plugin_mactrack_device') {
        /* mactrack */
        /* find out which (if any) hosts have been checked, so we can tell the user */
        if (isset_request_var('selected_items')) {
            $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
            if ($selected_items != false) {
                /* work on all selected hosts */
                for ($i = 0; $i < count($selected_items); $i++) {
                    # fetch row from host table
                    $device = db_fetch_row_prepared('SELECT * from host WHERE id = ?', array($selected_items[$i]));
                    # now fetch the related device from mac_track_devices, if any
                    $mt_device = db_fetch_row_prepared('SELECT * from mac_track_devices WHERE host_id = ?', array($device['id']));
                    if (is_array($device)) {
                        # update mac_track_device
                        $device_id = api_mactrack_device_save(isset($mt_device['device_id']) ? $mt_device['device_id'] : '0', $device['id'], get_request_var('site_id'), $device['hostname'], $device['description'], get_request_var('scan_type'), get_request_var('snmp_options'), $device['snmp_community'], $device['snmp_version'], $device['snmp_username'], $device['snmp_password'], $device['snmp_auth_protocol'], $device['snmp_priv_passphrase'], $device['snmp_priv_protocol'], $device['snmp_context'], $device['snmp_engine_id'], $device['snmp_port'], $device['snmp_timeout'], get_request_var('snmp_retries'), $device['max_oids'], get_request_var('ignorePorts'), $device['notes'], get_request_var('user_name'), get_request_var('user_password'), get_request_var('term_type'), get_request_var('private_key_path'), isset_request_var('disabled') ? get_request_var('disabled') : '');
                    }
                }
            }
        }
    }
    return $action;
}
Ejemplo n.º 9
0
function form_mactrack_actions()
{
    global $config, $device_actions, $fields_mactrack_device_edit, $fields_mactrack_snmp_item;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    include_once $config['base_path'] . '/lib/functions.php';
    /* 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') == '2') {
                /* Enable Selected Devices */
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute_prepared("UPDATE mac_track_devices SET disabled='' WHERE device_id = ?", array($selected_items[$i]));
                }
            } elseif (get_request_var('drp_action') == '3') {
                /* Disable Selected Devices */
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute_prepared("UPDATE mac_track_devices SET disabled='on' WHERE device_id = ?", array($selected_items[$i]));
                }
            } elseif (get_request_var('drp_action') == '4') {
                /* change snmp options */
                for ($i = 0; $i < count($selected_items); $i++) {
                    reset($fields_mactrack_device_edit);
                    while (list($field_name, $field_array) = each($fields_mactrack_device_edit)) {
                        if (isset_request_var("t_{$field_name}")) {
                            db_execute_prepared("UPDATE mac_track_devices \n\t\t\t\t\t\t\t\tSET {$field_name} = ?\n\t\t\t\t\t\t\t\tWHERE device_id = ?", array(get_request_var($field_name), $selected_items[$i]));
                        }
                    }
                }
            } elseif (get_request_var('drp_action') == '5') {
                /* change port settings for multiple devices */
                for ($i = 0; $i < count($selected_items); $i++) {
                    reset($fields_mactrack_device_edit);
                    while (list($field_name, $field_array) = each($fields_host_edit)) {
                        if (isset_request_var("t_{$field_name}")) {
                            db_execute_prepared("UPDATE mac_track_devices \n\t\t\t\t\t\t\t\tSET {$field_name} = ? WHERE id = ?", array(get_request_var($field_name), $selected_items[$i]));
                        }
                    }
                }
            } elseif (get_request_var('drp_action') == '6') {
                /* Connect Selected Devices */
                for ($i = 0; $i < count($selected_items); $i++) {
                    $cacti_host = db_fetch_row_prepared('SELECT host.id, host.description FROM mac_track_devices 
						LEFT JOIN host ON (mac_track_devices.hostname=host.hostname) 
						WHERE mac_track_devices.device_id=?', array($selected_items[$i]));
                    if (sizeof($cacti_host)) {
                        db_execute_prepared('UPDATE mac_track_devices SET host_id = ?, device_name = ? WHERE device_id = ?', array($cacti_host['id'], $cacti_host['description'], $selected_items[$i]));
                    }
                }
            } elseif (get_request_var('drp_action') == '7') {
                /* Copy SNMP Settings */
                for ($i = 0; $i < count($selected_items); $i++) {
                    $cacti_host = db_fetch_row_prepared("SELECT host.*, \n\t\t\t\t\t\thost.snmp_community as snmp_readstring, \n\t\t\t\t\t\thost.ping_retries as snmp_retries\n\t\t\t\t\t\tFROM mac_track_devices \n\t\t\t\t\t\tLEFT JOIN host ON (mac_track_devices.hostname=host.hostname) \n\t\t\t\t\t\tWHERE mac_track_devices.device_id = ?", array($selected_items[$i]));
                    if (isset($cacti_host['id'])) {
                        reset($fields_mactrack_snmp_item);
                        $updates = '';
                        while (list($field_name, $field_array) = each($fields_mactrack_snmp_item)) {
                            if (isset($cacti_host[$field_name])) {
                                $updates .= ($updates != '' ? ', ' : '') . $field_name . "='" . $cacti_host[$field_name] . "'";
                            }
                        }
                        if (strlen($updates)) {
                            db_execute('UPDATE mac_track_devices SET ' . $updates . ' WHERE device_id=' . $selected_items[$i]);
                        }
                    } else {
                        # skip silently; possible enhacement: tell the user what we did
                    }
                }
            } elseif (get_request_var('drp_action') == '1') {
                /* delete */
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_mactrack_device_remove($selected_items[$i]);
                }
            }
            header('Location: mactrack_devices.php');
            exit;
        }
    }
    /* setup some variables */
    $device_list = '';
    $i = 0;
    /* loop through each of the host templates 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]);
            /* ==================================================== */
            $device_info = db_fetch_row_prepared('SELECT hostname, device_name FROM mac_track_devices WHERE device_id = ?', array($matches[1]));
            $device_list .= '<li>' . $device_info['device_name'] . ' (' . $device_info['hostname'] . ')</li>';
            $device_array[] = $matches[1];
        }
    }
    top_header();
    form_start('mactrack_devices.php');
    html_start_box($device_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    if (!sizeof($device_array)) {
        print "<tr><td class='even'><span class='textError'>" . __('You must select at least one device.') . "</span></td></tr>\n";
        $save_html = "";
    } else {
        $save_html = "<input type='submit' value='" . __('Yes') . "' name='save'>";
        if (get_request_var('drp_action') == '2') {
            /* Enable Devices */
            print "<tr>\n\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t<p>" . __('To enable the following devices, press the "yes" button below.') . "</p>\n\t\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        } elseif (get_request_var('drp_action') == '3') {
            /* Disable Devices */
            print "<tr>\n\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t<p>" . __('To disable the following devices, press the "yes" button below.') . "</p>\n\t\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        } elseif (get_request_var('drp_action') == '4') {
            /* change snmp options */
            print "<tr>\n\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t<p>" . __('To change SNMP parameters for the following devices, check the box next to the fields you want to update, fill in the new value, and click Save.') . "</p>\n\t\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
            $form_array = array();
            while (list($field_name, $field_array) = each($fields_mactrack_device_edit)) {
                if (preg_match('/^snmp_/', $field_name)) {
                    $form_array += array($field_name => $fields_mactrack_device_edit[$field_name]);
                    $form_array[$field_name]['value'] = '';
                    $form_array[$field_name]['device_name'] = '';
                    $form_array[$field_name]['form_id'] = 0;
                    $form_array[$field_name]['sub_checkbox'] = array('name' => 't_' . $field_name, 'friendly_name' => 'Update this Field<br/>', 'value' => '');
                }
            }
            draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
        } elseif (get_request_var('drp_action') == '5') {
            /* change port settngs for multiple devices */
            print "<tr>\n\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t<p>" . __('To change upper or lower port parameters for the following devices, check the box next to the fields you want to update, fill in the new value, and click Save.') . "</p>\n\t\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
            $form_array = array();
            while (list($field_name, $field_array) = each($fields_mactrack_device_edit)) {
                if (preg_match('/^port_/', $field_name)) {
                    $form_array += array($field_name => $fields_mactrack_device_edit[$field_name]);
                    $form_array[$field_name]['value'] = '';
                    $form_array[$field_name]['device_name'] = '';
                    $form_array[$field_name]['form_id'] = 0;
                    $form_array[$field_name]['sub_checkbox'] = array('name' => 't_' . $field_name, 'friendly_name' => 'Update this Field', 'value' => '');
                }
            }
            draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => $form_array));
        } elseif (get_request_var('drp_action') == '6') {
            /* Connect Devices */
            print "<tr>\n\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t<p>" . __('To connect the following devices to their respective Cacti Device, press the "yes" button below.  The relation will be built on equal hostnames. Description will be updated as well.') . "</p>\n\t\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        } elseif (get_request_var('drp_action') == '7') {
            /* Copy SNMP Settings */
            print "<tr>\n\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t<p>" . __('To copy SNMP Settings from connected Cacti Device to MacTrack Device, press the "yes" button below.  All not connected Devices will silently be skipped. SNMP retries will be taken from Ping retries.') . "</p>\n\t\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        } elseif (get_request_var('drp_action') == '1') {
            /* delete */
            print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Are you sure you want to delete the following devices?') . "</p>\n\t\t\t\t\t<p><ul>{$device_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        }
    }
    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($device_array) ? serialize($device_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>" . (strlen($save_html) ? "\n\t\t\t<input type='button' name='cancel' onClick='cactiReturnTo()' value='" . __('No') . "'>\n\t\t\t{$save_html}" : "<input type='button' onClick='cactiReturnTo()' name='cancel' value='" . __('Return') . "'>") . "\n\t\t</td>\n\t</tr>";
    html_end_box();
    form_end();
    bottom_footer();
}
Ejemplo n.º 10
0
function form_actions()
{
    global $user_actions, $auth_realms;
    /* ================= input validation ================= */
    input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)\$");
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        if (get_request_var_post("drp_action") != "2") {
            $selected_items = sanitize_unserialize_selected_items($_POST['selected_items']);
        }
        if ($selected_items != false) {
            if (get_request_var_post("drp_action") == "1") {
                /* delete */
                for ($i = 0; $i < count($selected_items); $i++) {
                    user_remove($selected_items[$i]);
                    api_plugin_hook_function('user_remove', $selected_items[$i]);
                }
            }
            if (get_request_var_post("drp_action") == "2") {
                /* copy */
                /* ================= input validation ================= */
                input_validate_input_number(get_request_var_post("selected_items"));
                input_validate_input_number(get_request_var_post("new_realm"));
                /* ==================================================== */
                $new_username = get_request_var_post("new_username");
                $new_realm = get_request_var_post("new_realm", 0);
                $template_user = db_fetch_row("SELECT username, realm FROM user_auth WHERE id = " . get_request_var_post("selected_items"));
                $overwrite = array("full_name" => get_request_var_post("new_fullname"));
                if (strlen($new_username)) {
                    if (sizeof(db_fetch_assoc("SELECT username FROM user_auth WHERE username = '******' AND realm = " . $new_realm))) {
                        raise_message(19);
                    } else {
                        if (user_copy($template_user["username"], $new_username, $template_user["realm"], $new_realm, false, $overwrite) === false) {
                            raise_message(2);
                        } else {
                            raise_message(1);
                        }
                    }
                }
            }
            if (get_request_var_post("drp_action") == "3") {
                /* enable */
                for ($i = 0; $i < count($selected_items); $i++) {
                    user_enable($selected_items[$i]);
                }
            }
            if (get_request_var_post("drp_action") == "4") {
                /* disable */
                for ($i = 0; $i < count($selected_items); $i++) {
                    user_disable($selected_items[$i]);
                }
            }
            if (get_request_var_post("drp_action") == "5") {
                /* batch copy */
                /* ================= input validation ================= */
                input_validate_input_number(get_request_var_post("template_user"));
                /* ==================================================== */
                $copy_error = false;
                $template = db_fetch_row("SELECT username, realm FROM user_auth WHERE id = " . get_request_var_post("template_user"));
                for ($i = 0; $i < count($selected_items); $i++) {
                    $user = db_fetch_row("SELECT username, realm FROM user_auth WHERE id = " . $selected_items[$i]);
                    if (isset($user) && isset($template)) {
                        if (user_copy($template["username"], $user["username"], $template["realm"], $user["realm"], true) === false) {
                            $copy_error = true;
                        }
                    }
                }
                if ($copy_error) {
                    raise_message(2);
                } else {
                    raise_message(1);
                }
            }
        }
        header("Location: user_admin.php");
        exit;
    }
    /* loop through each of the users and process them */
    $user_list = "";
    $user_array = array();
    $i = 0;
    while (list($var, $val) = each($_POST)) {
        if (preg_match("/^chk_([0-9]+)\$/", $var, $matches)) {
            /* ================= input validation ================= */
            input_validate_input_number($matches[1]);
            /* ==================================================== */
            if (get_request_var_post("drp_action") != "2") {
                $user_list .= "<li>" . htmlspecialchars(db_fetch_cell("SELECT username FROM user_auth WHERE id=" . $matches[1])) . "</li>";
            }
            $user_array[$i] = $matches[1];
            $i++;
        }
    }
    /* Check for deleting of Graph Export User */
    if (get_request_var_post("drp_action") == "1" && isset($user_array) && sizeof($user_array)) {
        /* delete */
        $exportuser = read_config_option('export_user_id');
        if (in_array($exportuser, $user_array)) {
            raise_message(22);
            header("Location: user_admin.php");
            exit;
        }
    }
    include_once "./include/top_header.php";
    html_start_box("<strong>" . $user_actions[get_request_var_post("drp_action")] . "</strong>", "60%", "", "3", "center", "");
    print "<form action='user_admin.php' method='post'>\n";
    if (isset($user_array) && sizeof($user_array)) {
        if (get_request_var_post("drp_action") == "1" && sizeof($user_array)) {
            /* delete */
            print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the selected User(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$user_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete User(s)'>";
        }
        $user_id = "";
        if (get_request_var_post("drp_action") == "2" && sizeof($user_array)) {
            /* copy */
            $user_id = $user_array[0];
            $user_realm = db_fetch_cell("SELECT realm FROM user_auth WHERE id = " . $user_id);
            print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tWhen you click \"Continue\" the selected User will be copied to the new User below<br><br>\n\t\t\t\t\t</td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tTemplate Username: <i>" . db_fetch_cell("SELECT username FROM user_auth WHERE id=" . $user_id) . "</i>\n\t\t\t\t\t</td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\tNew Username: "******"new_username", "", "", 25);
            print "\t\t\t\t</td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tNew Full Name: ";
            print form_text_box("new_fullname", "", "", 35);
            print "\t\t\t\t</td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tNew Realm: \n";
            print form_dropdown("new_realm", $auth_realms, "", "", $user_realm, "", 0);
            print "\t\t\t\t</td>\n\n\t\t\t\t</tr>\n";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Copy User'>";
        }
        if (get_request_var_post("drp_action") == "3" && sizeof($user_array)) {
            /* enable */
            print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the selected User(s) will be enabled.</p>\n\t\t\t\t\t\t<p><ul>{$user_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Enable User(s)'>";
        }
        if (get_request_var_post("drp_action") == "4" && sizeof($user_array)) {
            /* disable */
            print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the selected User(s) will be disabled.</p>\n\t\t\t\t\t\t<p><ul>{$user_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Disable User(s)'>";
        }
        if (get_request_var_post("drp_action") == "5" && sizeof($user_array)) {
            /* batch copy */
            $usernames = db_fetch_assoc("SELECT id,username FROM user_auth WHERE realm = 0 ORDER BY username");
            print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea' class='odd'>When you click \"Continue\" you will overwrite selected the User(s) settings with the selected template User settings and permissions?  Original user Full Name, Password, Realm and Enable status will be retained, all other fields will be overwritten from Template User.<br><br></td>\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\tTemplate User: \n";
            print form_dropdown("template_user", $usernames, "username", "id", "", "", 0);
            print "\t\t</td>\n\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>User(s) to update:\n\t\t\t\t\t\t<ul>{$user_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Reset User(s) Settings'>";
        }
    } else {
        print "<tr><td class='odd'><span class='textError'>You must select at least one user.</span></td></tr>\n";
        $save_html = "<input type='button' value='Return' onClick='window.history.back()'>";
    }
    print " <tr>\n\t\t\t<td align='right' bgcolor='#eaeaea'>\n\t\t\t\t<input type='hidden' name='action' value='actions'>";
    if (get_request_var_post("drp_action") == "2") {
        /* copy */
        print "\t\t\t\t<input type='hidden' name='selected_items' value='" . $user_id . "'>\n";
    } else {
        print "\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($user_array) ? serialize($user_array) : '') . "'>\n";
    }
    print "\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var_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 "./include/bottom_footer.php";
}
Ejemplo n.º 11
0
function form_actions()
{
    global $config, $device_types_actions, $fields_mactrack_device_types_edit;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    /* 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_mactrack_device_type_remove($selected_items[$i]);
                }
            } elseif (get_nfilter_request_var('drp_action') == '2') {
                /* duplicate */
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_mactrack_duplicate_device_type($selected_items[$i], $i, get_request_var('title_format'));
                }
            }
            header('Location: mactrack_device_types.php');
            exit;
        }
    }
    /* setup some variables */
    $device_types_list = '';
    $i = 0;
    /* loop through each of the device types 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]);
            /* ==================================================== */
            $device_types_info = db_fetch_row_prepared('SELECT description FROM mac_track_device_types WHERE device_type_id = ?', array($matches[1]));
            $device_types_list .= '<li>' . $device_types_info['description'] . '</li>';
            $device_types_array[] = $matches[1];
        }
    }
    top_header();
    form_start('mactrack_device_types.php');
    html_start_box($device_types_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    if (!isset($device_types_array)) {
        print "<tr><td class='even'><span class='textError'>" . __('You must select at least one device type.') . "</span></td></tr>\n";
        $save_html = '';
    } else {
        $save_html = "<input type='submit' value='" . __('Yes') . "' name='save'>";
        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>" . __('Are you sure you want to delete the following device types?') . "</p>\n\t\t\t\t\t<p><ul>{$device_types_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        } elseif (get_request_var('drp_action') == '2') {
            /* duplicate */
            print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('When you click save, the following device types will be duplicated. You may optionally change the description for the new device types.  Otherwise, do not change value below and the original name will be replicated with a new suffix.') . "</p>\n\t\t\t\t\t<p><ul>{$device_types_list}</ul></p>\n\t\t\t\t\t<p>" . __('Device Type Prefix:') . '<br>';
            form_text_box('title_format', '<description> (1)', '', '255', '30', 'text');
            print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>";
        }
    }
    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($device_types_array) ? serialize($device_types_array) : '') . "'>\n\t\t\t<input type='hidden' name='drp_action' value='" . get_nfilter_request_var('drp_action') . "'>" . (strlen($save_html) ? "\n\t\t\t<input type='button' onClick='cactiReturnTo()' name='cancel' value='" . __('No') . "'>\n\t\t\t{$save_html}" : "<input type='submit' onClick='cactiReturnTo()' name='cancel' value='" . __('Return') . "'>") . "\n\t\t</td>\n\t</tr>";
    html_end_box();
    form_end();
    bottom_footer();
}
Ejemplo n.º 12
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();
}
Ejemplo n.º 13
0
function thold_graphs_action_execute($action)
{
    global $config, $form_array;
    include_once $config['base_path'] . '/plugins/thold/thold_functions.php';
    if ($action == 'plugin_thold_create') {
        $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
        if ($selected_items != false) {
            $message = '';
            get_filter_request_var('thold_template_id');
            $template = db_fetch_row_prepared('SELECT * FROM thold_template WHERE id = ?', array(get_request_var('thold_template_id')));
            for ($i = 0; $i < count($selected_items); $i++) {
                $graph = $selected_items[$i];
                $temp = db_fetch_row("SELECT dtr.*\n\t\t\t\t\t FROM data_template_rrd AS dtr\n\t\t\t\t\t LEFT JOIN graph_templates_item AS gti\n\t\t\t\t\t ON gti.task_item_id=dtr.id\n\t\t\t\t\t LEFT JOIN graph_local AS gl\n\t\t\t\t\t ON gl.id=gti.local_graph_id\n\t\t\t\t\t WHERE gl.id={$graph}");
                $data_template_id = $temp['data_template_id'];
                $local_data_id = $temp['local_data_id'];
                $data_source = db_fetch_row('SELECT * FROM data_local WHERE id=' . $local_data_id);
                $data_template_id = $data_source['data_template_id'];
                $existing = db_fetch_assoc('SELECT id FROM thold_data WHERE local_data_id=' . $local_data_id . ' AND data_template_rrd_id=' . $data_template_id);
                if (count($existing) == 0 && count($template)) {
                    if ($graph) {
                        $rrdlookup = db_fetch_cell("SELECT id \n\t\t\t\t\t\t\tFROM data_template_rrd\n\t\t\t\t\t\t\tWHERE local_data_id={$local_data_id}\n\t\t\t\t\t\t\tORDER BY id\n\t\t\t\t\t\t\tLIMIT 1");
                        $grapharr = db_fetch_row("SELECT graph_template_id\n\t\t\t\t\t\t\tFROM graph_templates_item\n\t\t\t\t\t\t\tWHERE task_item_id={$rrdlookup}\n\t\t\t\t\t\t\tAND local_graph_id={$graph}");
                        $data_source_name = $template['data_source_name'];
                        $insert = array();
                        $name = thold_format_name($template, $graph, $local_data_id, $data_source_name);
                        $insert['name'] = $name;
                        $insert['host_id'] = $data_source['host_id'];
                        $insert['local_data_id'] = $local_data_id;
                        $insert['local_graph_id'] = $graph;
                        $insert['data_template_id'] = $data_template_id;
                        $insert['graph_template_id'] = $grapharr['graph_template_id'];
                        $insert['thold_hi'] = $template['thold_hi'];
                        $insert['thold_low'] = $template['thold_low'];
                        $insert['thold_fail_trigger'] = $template['thold_fail_trigger'];
                        $insert['thold_enabled'] = $template['thold_enabled'];
                        $insert['bl_ref_time_range'] = $template['bl_ref_time_range'];
                        $insert['bl_pct_down'] = $template['bl_pct_down'];
                        $insert['bl_pct_up'] = $template['bl_pct_up'];
                        $insert['bl_fail_trigger'] = $template['bl_fail_trigger'];
                        $insert['bl_alert'] = $template['bl_alert'];
                        $insert['repeat_alert'] = $template['repeat_alert'];
                        $insert['notify_extra'] = $template['notify_extra'];
                        $insert['cdef'] = $template['cdef'];
                        $insert['thold_template_id'] = $template['id'];
                        $insert['template_enabled'] = 'on';
                        $rrdlist = db_fetch_assoc("SELECT id, data_input_field_id FROM data_template_rrd where local_data_id='{$local_data_id}' and data_source_name='{$data_source_name}'");
                        $int = array('id', 'data_template_id', 'data_source_id', 'thold_fail_trigger', 'bl_ref_time_range', 'bl_pct_down', 'bl_pct_up', 'bl_fail_trigger', 'bl_alert', 'repeat_alert', 'cdef');
                        foreach ($rrdlist as $rrdrow) {
                            $data_rrd_id = $rrdrow['id'];
                            $insert['data_id'] = $data_rrd_id;
                            $existing = db_fetch_assoc("SELECT id FROM thold_data WHERE local_data_id='{$local_data_id}' AND data_template_rrd_id='{$data_rrd_id}'");
                            if (count($existing) == 0) {
                                $insert['id'] = 0;
                                $id = sql_save($insert, 'thold_data');
                                if ($id) {
                                    thold_template_update_threshold($id, $insert['template']);
                                    $l = db_fetch_assoc("SELECT name FROM data_template where id={$data_template_id}");
                                    $tname = $l[0]['name'];
                                    $name = $data_source_name;
                                    if ($rrdrow['data_input_field_id'] != 0) {
                                        $l = db_fetch_assoc('SELECT name FROM data_input_fields where id=' . $rrdrow['data_input_field_id']);
                                        $name = $l[0]['name'];
                                    }
                                    plugin_thold_log_changes($id, 'created', " {$tname} [{$name}]");
                                    $message .= __('Created threshold for the Graph \'<i>%s</i>\' using the Data Source \'<i>%s</i>\'', $tname, $name) . "<br>";
                                }
                            }
                        }
                    }
                }
            }
            if (strlen($message)) {
                $_SESSION['thold_message'] = "<font size=-2>{$message}</font>";
            } else {
                $_SESSION['thold_message'] = "<font size=-2>" . __('Threshold(s) Already Exist - No Thresholds Created') . "</font>";
            }
            raise_message('thold_message');
        }
    }
    return $action;
}
Ejemplo n.º 14
0
function form_actions()
{
    global $device_actions, $fields_host_edit;
    /* ================= input validation ================= */
    input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)\$");
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = sanitize_unserialize_selected_items($_POST['selected_items']);
        if ($selected_items != false) {
            if ($_POST["drp_action"] == "2") {
                /* Enable Selected Devices */
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute("update host set disabled='' where id='" . $selected_items[$i] . "'");
                    /* update poller cache */
                    $data_sources = db_fetch_assoc("select id from data_local where host_id='" . $selected_items[$i] . "'");
                    $poller_items = $local_data_ids = array();
                    if (sizeof($data_sources) > 0) {
                        foreach ($data_sources as $data_source) {
                            $local_data_ids[] = $data_source["id"];
                            $poller_items = array_merge($poller_items, update_poller_cache($data_source["id"]));
                        }
                    }
                    if (sizeof($local_data_ids)) {
                        poller_update_poller_cache_from_buffer($local_data_ids, $poller_items);
                    }
                }
            } elseif ($_POST["drp_action"] == "3") {
                /* Disable Selected Devices */
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute("update host set disabled='on' where id='" . $selected_items[$i] . "'");
                    /* update poller cache */
                    db_execute("delete from poller_item where host_id='" . $selected_items[$i] . "'");
                    db_execute("delete from poller_reindex where host_id='" . $selected_items[$i] . "'");
                }
            } elseif ($_POST["drp_action"] == "4") {
                /* change snmp options */
                for ($i = 0; $i < count($selected_items); $i++) {
                    reset($fields_host_edit);
                    while (list($field_name, $field_array) = each($fields_host_edit)) {
                        if (isset($_POST["t_{$field_name}"])) {
                            db_execute("update host set {$field_name} = '" . $_POST[$field_name] . "' where id='" . $selected_items[$i] . "'");
                        }
                    }
                    push_out_host($selected_items[$i]);
                }
            } elseif ($_POST["drp_action"] == "5") {
                /* Clear Statisitics for Selected Devices */
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute("update host set min_time = '9.99999', max_time = '0', cur_time = '0',\tavg_time = '0',\n\t\t\t\t\t\t\ttotal_polls = '0', failed_polls = '0',\tavailability = '100.00'\n\t\t\t\t\t\t\twhere id = '" . $selected_items[$i] . "'");
                }
            } elseif ($_POST["drp_action"] == "6") {
                /* change availability options */
                for ($i = 0; $i < count($selected_items); $i++) {
                    reset($fields_host_edit);
                    while (list($field_name, $field_array) = each($fields_host_edit)) {
                        if (isset($_POST["t_{$field_name}"])) {
                            db_execute("update host set {$field_name} = '" . $_POST[$field_name] . "' where id='" . $selected_items[$i] . "'");
                        }
                    }
                    push_out_host($selected_items[$i]);
                }
            } elseif ($_POST["drp_action"] == "1") {
                /* delete */
                if (!isset($_POST["delete_type"])) {
                    $_POST["delete_type"] = 2;
                }
                $data_sources_to_act_on = array();
                $graphs_to_act_on = array();
                $devices_to_act_on = array();
                for ($i = 0; $i < count($selected_items); $i++) {
                    $data_sources = db_fetch_assoc("select\n\t\t\t\t\t\tdata_local.id as local_data_id\n\t\t\t\t\t\tfrom data_local\n\t\t\t\t\t\twhere " . array_to_sql_or($selected_items, "data_local.host_id"));
                    if (sizeof($data_sources) > 0) {
                        foreach ($data_sources as $data_source) {
                            $data_sources_to_act_on[] = $data_source["local_data_id"];
                        }
                    }
                    if ($_POST["delete_type"] == 2) {
                        $graphs = db_fetch_assoc("select\n\t\t\t\t\t\t\tgraph_local.id as local_graph_id\n\t\t\t\t\t\t\tfrom graph_local\n\t\t\t\t\t\t\twhere " . array_to_sql_or($selected_items, "graph_local.host_id"));
                        if (sizeof($graphs) > 0) {
                            foreach ($graphs as $graph) {
                                $graphs_to_act_on[] = $graph["local_graph_id"];
                            }
                        }
                    }
                    $devices_to_act_on[] = $selected_items[$i];
                }
                switch ($_POST["delete_type"]) {
                    case '1':
                        /* leave graphs and data_sources in place, but disable the data sources */
                        api_data_source_disable_multi($data_sources_to_act_on);
                        api_plugin_hook_function('data_source_remove', $data_sources_to_act_on);
                        break;
                    case '2':
                        /* delete graphs/data sources tied to this device */
                        api_data_source_remove_multi($data_sources_to_act_on);
                        api_graph_remove_multi($graphs_to_act_on);
                        api_plugin_hook_function('graphs_remove', $graphs_to_act_on);
                        break;
                }
                api_device_remove_multi($devices_to_act_on);
                api_plugin_hook_function('device_remove', $devices_to_act_on);
            } elseif (preg_match("/^tr_([0-9]+)\$/", $_POST["drp_action"], $matches)) {
                /* place on tree */
                input_validate_input_number(get_request_var_post("tree_id"));
                input_validate_input_number(get_request_var_post("tree_item_id"));
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_tree_item_save(0, $_POST["tree_id"], TREE_ITEM_TYPE_HOST, $_POST["tree_item_id"], "", 0, read_graph_config_option("default_rra_id"), $selected_items[$i], 1, 1, false);
                }
            } else {
                api_plugin_hook_function('device_action_execute', $_POST['drp_action']);
            }
            api_plugin_hook_function('device_action_bottom', array($_POST['drp_action'], $selected_items));
        }
        header("Location: host.php");
        exit;
    }
    /* setup some variables */
    $host_list = "";
    $i = 0;
    /* loop through each of the host templates 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]);
            /* ==================================================== */
            $host_list .= "<li>" . htmlspecialchars(db_fetch_cell("select description from host where id=" . $matches[1])) . "<br>";
            $host_array[$i] = $matches[1];
            $i++;
        }
    }
    include_once "./include/top_header.php";
    /* add a list of tree names to the actions dropdown */
    add_tree_names_to_actions_array();
    html_start_box("<strong>" . $device_actions[get_request_var_post("drp_action")] . "</strong>", "60%", "", "3", "center", "");
    print "<form action='host.php' autocomplete='off' method='post'>\n";
    if (isset($host_array) && sizeof($host_array)) {
        if ($_POST["drp_action"] == "2") {
            /* Enable Devices */
            print "\t<tr>\n\t\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t\t<p>To enable the following Device(s), click \"Continue\".</p>\n\t\t\t\t\t\t<p><ul>" . $host_list . "</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Enable Device(s)'>";
        } elseif ($_POST["drp_action"] == "3") {
            /* Disable Devices */
            print "\t<tr>\n\t\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t\t<p>To disable the following Device(s), click \"Continue\".</p>\n\t\t\t\t\t\t<p><ul>" . $host_list . "</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Disable Device(s)'>";
        } elseif ($_POST["drp_action"] == "4") {
            /* change snmp options */
            print "\t<tr>\n\t\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t\t<p>To change SNMP parameters for the following Device(s), check the box next to the fields\n\t\t\t\t\t\tyou want to update, fill in the new value, and click \"Continue\".</p>\n\t\t\t\t\t\t<p><ul>" . $host_list . "</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
            $form_array = array();
            while (list($field_name, $field_array) = each($fields_host_edit)) {
                if (preg_match("/^snmp_/", $field_name) || $field_name == "max_oids") {
                    $form_array += array($field_name => $fields_host_edit[$field_name]);
                    $form_array[$field_name]["value"] = "";
                    $form_array[$field_name]["description"] = "";
                    $form_array[$field_name]["form_id"] = 0;
                    $form_array[$field_name]["sub_checkbox"] = array("name" => "t_" . $field_name, "friendly_name" => "Update this Field", "value" => "");
                }
            }
            draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => $form_array));
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Change Device(s) SNMP Options'>";
        } elseif ($_POST["drp_action"] == "6") {
            /* change availability options */
            print "\t<tr>\n\t\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t\t<p>To change Availability parameters for the following Device(s), check the box next to the fields\n\t\t\t\t\t\tyou want to update, fill in the new value, and click \"Continue\".</p>\n\t\t\t\t\t\t<p><ul>" . $host_list . "</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
            $form_array = array();
            while (list($field_name, $field_array) = each($fields_host_edit)) {
                if (preg_match("/(availability_method|ping_method|ping_port)/", $field_name)) {
                    $form_array += array($field_name => $fields_host_edit[$field_name]);
                    $form_array[$field_name]["value"] = "";
                    $form_array[$field_name]["description"] = "";
                    $form_array[$field_name]["form_id"] = 0;
                    $form_array[$field_name]["sub_checkbox"] = array("name" => "t_" . $field_name, "friendly_name" => "Update this Field", "value" => "");
                }
            }
            draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => $form_array));
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Change Device(s) Availability Options'>";
        } elseif ($_POST["drp_action"] == "5") {
            /* Clear Statisitics for Selected Devices */
            print "\t<tr>\n\t\t\t\t\t<td colspan='2' class='textArea'>\n\t\t\t\t\t\t<p>To clear the counters for the following Device(s), press the \"Continue\" button below.</p>\n\t\t\t\t\t\t<p><ul>" . $host_list . "</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t\t</tr>";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Clear Statistics on Device(s)'>";
        } elseif ($_POST["drp_action"] == "1") {
            /* delete */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the following Device(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>" . $host_list . "</ul></p>";
            form_radio_button("delete_type", "2", "1", "Leave all Graph(s) and Data Source(s) untouched.  Data Source(s) will be disabled however.", "1");
            print "<br>";
            form_radio_button("delete_type", "2", "2", "Delete all associated <strong>Graph(s)</strong> and <strong>Data Source(s)</strong>.", "1");
            print "<br>";
            print "</td></tr>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete Device(s)'>";
        } elseif (preg_match("/^tr_([0-9]+)\$/", $_POST["drp_action"], $matches)) {
            /* place on tree */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Device(s) will be placed under the branch selected\n\t\t\t\t\t\tbelow.</p>\n\t\t\t\t\t\t<p><ul>" . $host_list . "</ul></p>\n\t\t\t\t\t\t<p><strong>Destination Branch:</strong><br>";
            grow_dropdown_tree($matches[1], "tree_item_id", "0");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t<input type='hidden' name='tree_id' value='" . $matches[1] . "'>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Place Device(s) on Tree'>";
        } else {
            $save['drp_action'] = $_POST['drp_action'];
            $save['host_list'] = $host_list;
            $save['host_array'] = isset($host_array) ? $host_array : array();
            api_plugin_hook_function('device_action_prepare', $save);
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
        }
    } else {
        print "<tr><td class='even'><span class='textError'>You must select at least one device.</span></td></tr>\n";
        $save_html = "<input type='button' value='Return' onClick='window.history.back()'>";
    }
    print "\t<tr>\n\t\t\t<td colspan='2' align='right' class='saveRow'>\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($host_array) ? serialize($host_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 "./include/bottom_footer.php";
}
Ejemplo n.º 15
0
function form_actions()
{
    global $ds_actions;
    /* ================= input validation ================= */
    input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)\$");
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = sanitize_unserialize_selected_items($_POST['selected_items']);
        if ($selected_items != false) {
            if ($_POST["drp_action"] == "1") {
                /* delete */
                if (!isset($_POST["delete_type"])) {
                    $_POST["delete_type"] = 1;
                }
                switch ($_POST["delete_type"]) {
                    case '2':
                        /* delete all graph items tied to this data source */
                        $data_template_rrds = array_rekey(db_fetch_assoc("select id from data_template_rrd where " . array_to_sql_or($selected_items, "local_data_id")), "id", "id");
                        /* loop through each data source item */
                        if (sizeof($data_template_rrds) > 0) {
                            db_execute("delete from graph_templates_item where task_item_id IN (" . implode(",", $data_template_rrds) . ") and local_graph_id > 0");
                        }
                        api_plugin_hook_function('graph_items_remove', $data_template_rrds);
                        break;
                    case '3':
                        /* delete all graphs tied to this data source */
                        $graphs = array_rekey(db_fetch_assoc("select\n\t\t\t\t\t\t\tgraph_templates_graph.local_graph_id\n\t\t\t\t\t\t\tfrom (data_template_rrd,graph_templates_item,graph_templates_graph)\n\t\t\t\t\t\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\t\t\t\t\t\tand graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id\n\t\t\t\t\t\t\tand " . array_to_sql_or($selected_items, "data_template_rrd.local_data_id") . "\n\t\t\t\t\t\t\tand graph_templates_graph.local_graph_id > 0\n\t\t\t\t\t\t\tgroup by graph_templates_graph.local_graph_id"), "local_graph_id", "local_graph_id");
                        if (sizeof($graphs) > 0) {
                            api_graph_remove_multi($graphs);
                        }
                        api_plugin_hook_function('graphs_remove', $graphs);
                        break;
                }
                api_data_source_remove_multi($selected_items);
                api_plugin_hook_function('data_source_remove', $selected_items);
            } elseif ($_POST["drp_action"] == "2") {
                /* change graph template */
                input_validate_input_number(get_request_var_post("data_template_id"));
                for ($i = 0; $i < count($selected_items); $i++) {
                    change_data_template($selected_items[$i], $_POST["data_template_id"]);
                }
            } elseif ($_POST["drp_action"] == "3") {
                /* change host */
                input_validate_input_number(get_request_var_post("host_id"));
                for ($i = 0; $i < count($selected_items); $i++) {
                    db_execute("update data_local set host_id=" . $_POST["host_id"] . " where id=" . $selected_items[$i]);
                    push_out_host($_POST["host_id"], $selected_items[$i]);
                    update_data_source_title_cache($selected_items[$i]);
                }
            } elseif ($_POST["drp_action"] == "4") {
                /* duplicate */
                for ($i = 0; $i < count($selected_items); $i++) {
                    duplicate_data_source($selected_items[$i], 0, $_POST["title_format"]);
                }
            } elseif ($_POST["drp_action"] == "5") {
                /* data source -> data template */
                for ($i = 0; $i < count($selected_items); $i++) {
                    data_source_to_data_template($selected_items[$i], $_POST["title_format"]);
                }
            } elseif ($_POST["drp_action"] == "6") {
                /* data source enable */
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_data_source_enable($selected_items[$i]);
                }
            } elseif ($_POST["drp_action"] == "7") {
                /* data source disable */
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_data_source_disable($selected_items[$i]);
                }
            } elseif ($_POST["drp_action"] == "8") {
                /* reapply suggested data source naming */
                for ($i = 0; $i < count($selected_items); $i++) {
                    api_reapply_suggested_data_source_title($selected_items[$i]);
                    update_data_source_title_cache($selected_items[$i]);
                }
            } else {
                api_plugin_hook_function('data_source_action_execute', $_POST['drp_action']);
            }
            api_plugin_hook_function('data_source_action_bottom', array($_POST['drp_action'], $selected_items));
        }
        header("Location: data_sources.php");
        exit;
    }
    /* setup some variables */
    $ds_list = "";
    $i = 0;
    /* loop through each of the graphs 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]);
            /* ==================================================== */
            $ds_list .= "<li>" . htmlspecialchars(get_data_source_title($matches[1])) . "</li>";
            $ds_array[$i] = $matches[1];
            $i++;
        }
    }
    include_once "./include/top_header.php";
    html_start_box("<strong>" . $ds_actions[$_POST["drp_action"]] . "</strong>", "60%", "", "3", "center", "");
    print "<form action='data_sources.php' method='post'>\n";
    if (isset($ds_array) && sizeof($ds_array)) {
        if ($_POST["drp_action"] == "1") {
            /* delete */
            $graphs = array();
            /* find out which (if any) graphs are using this data source, so we can tell the user */
            if (isset($ds_array)) {
                $graphs = db_fetch_assoc("select\n\t\t\t\t\tgraph_templates_graph.local_graph_id,\n\t\t\t\t\tgraph_templates_graph.title_cache\n\t\t\t\t\tfrom (data_template_rrd,graph_templates_item,graph_templates_graph)\n\t\t\t\t\twhere graph_templates_item.task_item_id=data_template_rrd.id\n\t\t\t\t\tand graph_templates_item.local_graph_id=graph_templates_graph.local_graph_id\n\t\t\t\t\tand " . array_to_sql_or($ds_array, "data_template_rrd.local_data_id") . "\n\t\t\t\t\tand graph_templates_graph.local_graph_id > 0\n\t\t\t\t\tgroup by graph_templates_graph.local_graph_id\n\t\t\t\t\torder by graph_templates_graph.title_cache");
            }
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Source(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>";
            if (sizeof($graphs) > 0) {
                print "<tr><td class='textArea'><p class='textArea'>The following graphs are using these data sources:</p>\n";
                print "<ul>";
                foreach ($graphs as $graph) {
                    print "<li><strong>" . $graph["title_cache"] . "</strong></li>\n";
                }
                print "</ul>";
                print "<br>";
                form_radio_button("delete_type", "3", "1", "Leave the Graph(s) untouched.", "1");
                print "<br>";
                form_radio_button("delete_type", "3", "2", "Delete all <strong>Graph Item(s)</strong> that reference these Data Source(s).", "1");
                print "<br>";
                form_radio_button("delete_type", "3", "3", "Delete all <strong>Graph(s)</strong> that reference these Data Source(s).", "1");
                print "<br>";
                print "</td></tr>";
            }
            print "\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete Data Source(s)'>";
        } elseif ($_POST["drp_action"] == "2") {
            /* change graph template */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>Choose a Data Template and click \"Continue\" to change the Data Template for\n\t\t\t\t\t\tthe following Data Source(s). Be aware that all warnings will be suppressed during the\n\t\t\t\t\t\tconversion, so graph data loss is possible.</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t\t<p><strong>New Data Template:</strong><br>";
            form_dropdown("data_template_id", db_fetch_assoc("select data_template.id,data_template.name from data_template order by data_template.name"), "name", "id", "", "", "0");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Change Graph Template for Data Source(s)'>";
        } elseif ($_POST["drp_action"] == "3") {
            /* change host */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>Choose a new Device for these Data Source(s) and click \"Continue\"</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t\t<p><strong>New Host:</strong><br>";
            form_dropdown("host_id", db_fetch_assoc("select id,CONCAT_WS('',description,' (',hostname,')') as name from host order by description,hostname"), "name", "id", "", "", "0");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Change Device'>";
        } elseif ($_POST["drp_action"] == "4") {
            /* duplicate */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Source(s) will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new Data Source(s).</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>";
            form_text_box("title_format", "<ds_title> (1)", "", "255", "30", "text");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Duplicate Data Source(s)'>";
        } elseif ($_POST["drp_action"] == "5") {
            /* data source -> data template */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Source(s) will be converted into Data Template(s).\n\t\t\t\t\t\tYou can optionally change the title format for the new Data Template(s).</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>";
            form_text_box("title_format", "<ds_title> Template", "", "255", "30", "text");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Convert Data Source(s) to Data Template(s)'>";
        } elseif ($_POST["drp_action"] == "6") {
            /* data source enable */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Source(s) will be enabled.</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Enable Data Source(s)'>";
        } elseif ($_POST["drp_action"] == "7") {
            /* data source disable */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Source(s) will be disabled.</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Disable Data Source(s)'>";
        } elseif ($_POST["drp_action"] == "8") {
            /* reapply suggested data source naming */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Source(s) will will have there suggested naming convention\n\t\t\t\t\t\trecalculated.</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Reapply Suggested Naming to Data Source(s)'>";
        } else {
            $save['drp_action'] = $_POST['drp_action'];
            $save['ds_list'] = $ds_list;
            $save['ds_array'] = isset($ds_array) ? $ds_array : array();
            api_plugin_hook_function('data_source_action_prepare', $save);
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue'>";
        }
    } else {
        print "<tr><td class='even'><span class='textError'>You must select at least one data source.</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' class='saveRow'>\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($ds_array) ? serialize($ds_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 "./include/bottom_footer.php";
}
Ejemplo n.º 16
0
function form_actions()
{
    global $cdef_actions;
    /* ================= input validation ================= */
    input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)\$");
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = sanitize_unserialize_selected_items($_POST['selected_items']);
        if ($selected_items != false) {
            if ($_POST["drp_action"] == "1") {
                /* delete */
                db_execute("delete from cdef where " . array_to_sql_or($selected_items, "id"));
                db_execute("delete from cdef_items where " . array_to_sql_or($selected_items, "cdef_id"));
            } elseif ($_POST["drp_action"] == "2") {
                /* duplicate */
                for ($i = 0; $i < count($selected_items); $i++) {
                    duplicate_cdef($selected_items[$i], $_POST["title_format"]);
                }
            }
        }
        header("Location: cdef.php");
        exit;
    }
    /* setup some variables */
    $cdef_list = "";
    $i = 0;
    /* loop through each of the graphs 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]);
            /* ==================================================== */
            $cdef_list .= "<li>" . htmlspecialchars(db_fetch_cell("select name from cdef where id=" . $matches[1])) . "</li>";
            $cdef_array[$i] = $matches[1];
            $i++;
        }
    }
    include_once "./include/top_header.php";
    print "<form action='cdef.php' method='post'>\n";
    html_start_box("<strong>" . $cdef_actions[$_POST["drp_action"]] . "</strong>", "60%", "", "3", "center", "");
    if (isset($cdef_array) && sizeof($cdef_array)) {
        if ($_POST["drp_action"] == "1") {
            /* delete */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea' class='odd'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the folling CDEF(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$cdef_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete CDEF(s)'>";
        } elseif ($_POST["drp_action"] == "2") {
            /* duplicate */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea' class='odd'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following CDEFs will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new CDEFs.</p>\n\t\t\t\t\t\t<p><ul>{$cdef_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>";
            form_text_box("title_format", "<cdef_title> (1)", "", "255", "30", "text");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Duplicate CDEF(s)'>";
        }
    } else {
        print "<tr><td class='odd'><span class='textError'>You must select at least one CDEF.</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' class='saveRow'>\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($cdef_array) ? serialize($cdef_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 "./include/bottom_footer.php";
}
Ejemplo n.º 17
0
function form_actions()
{
    global $actions, $assoc_actions;
    /* ================= input validation ================= */
    get_filter_request_var('id');
    get_filter_request_var('drp_action', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9_]+)$/')));
    /* ================= input validation ================= */
    /* if we are to save this form, instead of display it */
    if (isset_request_var('selected_items')) {
        if (isset_request_var('save_list')) {
            if (get_request_var('drp_action') == '2') {
                /* delete */
                schedule_delete();
            } elseif (get_request_var('drp_action') == '1') {
                /* update */
                schedule_update();
            }
            header('Location: maint.php?header=false');
            exit;
        } elseif (isset_request_var('save_hosts')) {
            $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
            if ($selected_items != false) {
                if (get_request_var('drp_action') == '1') {
                    /* associate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        db_execute('REPLACE INTO plugin_maint_hosts (type, host, schedule) VALUES (1, ' . $selected_items[$i] . ', ' . get_request_var('id') . ')');
                    }
                } elseif (get_request_var('drp_action') == '2') {
                    /* disassociate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        db_execute('DELETE FROM plugin_maint_hosts WHERE type=1 AND host=' . $selected_items[$i] . ' AND schedule=' . get_request_var('id'));
                    }
                }
            }
            header('Location: maint.php?action=edit&tab=hosts&header=false&id=' . get_request_var('id'));
            exit;
        } elseif (isset_request_var('save_webseer')) {
            $selected_items = sanitize_unserialize_selected_items(get_nfilter_request_var('selected_items'));
            if ($selected_items != false) {
                if (get_request_var('drp_action') == '1') {
                    /* associate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        db_execute('REPLACE INTO plugin_maint_hosts (type, host, schedule) VALUES (2, ' . $selected_items[$i] . ', ' . get_request_var('id') . ')');
                    }
                } elseif (get_request_var('drp_action') == '2') {
                    /* disassociate */
                    for ($i = 0; $i < count($selected_items); $i++) {
                        db_execute('DELETE FROM plugin_maint_hosts WHERE type=2 AND host=' . $selected_items[$i] . ' AND schedule=' . get_request_var('id'));
                    }
                }
            }
            header('Location: maint.php?action=edit&tab=webseer&header=false&id=' . get_request_var('id'));
            exit;
        } else {
            api_plugin_hook_function('maint_actions_execute');
        }
    }
    /* setup some variables */
    $list = '';
    $array = array();
    $list_name = '';
    if (isset_request_var('id')) {
        $list_name = db_fetch_cell('SELECT name FROM plugin_maint_schedules WHERE id=' . get_request_var('id'));
    }
    if (isset_request_var('save_list')) {
        /* loop through each of the notification lists 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]);
                /* ==================================================== */
                $list .= '<li><b>' . db_fetch_cell('SELECT name FROM plugin_maint_schedules WHERE id=' . $matches[1]) . '</b></li>';
                $array[] = $matches[1];
            }
        }
        top_header();
        form_start('maint.php');
        html_start_box($actions[get_request_var('drp_action')] . " {$list_name}", '60%', '', '3', 'center', '');
        if (sizeof($array)) {
            if (get_request_var('drp_action') == '1') {
                /* update */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Update the following Maintenance Schedule(s).') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Update Maintenance Schedule(s)') . "'>";
            } elseif (get_request_var('drp_action') == '2') {
                /* delete */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Maintenance Schedule(s).  Any Devices(s) Associated with this Schedule will be Disassociated.') . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Delete Maintenance Schedule(s)') . "'>";
            }
        } else {
            print "<tr><td><span class='textError'>" . __('You must select at least one Maintenance Schedule.') . "</span></td></tr>\n";
            $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
        }
        print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='save_list' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
        html_end_box();
        form_end();
        bottom_footer();
    } elseif (isset_request_var('save_hosts')) {
        /* loop through each of the notification lists 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]);
                /* ==================================================== */
                $list .= '<li><b>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</b></li>';
                $array[] = $matches[1];
            }
        }
        top_header();
        form_start('maint.php');
        html_start_box($assoc_actions[get_request_var('drp_action')] . ' ' . __('Device(s)'), '60%', '', '3', 'center', '');
        if (sizeof($array)) {
            if (get_request_var('drp_action') == '1') {
                /* associate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to associate the following Device(s) with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Associate Maintenance Schedule(s)') . "'>";
            } elseif (get_request_var('drp_action') == '2') {
                /* disassociate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to disassociate the following Device(s) with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Maintenance Schedule(s)') . "'>";
            }
        } else {
            print "<tr><td><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n";
            $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
        }
        print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_hosts' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
        html_end_box();
        form_end();
        bottom_footer();
    } elseif (isset_request_var('save_webseer')) {
        /* loop through each of the notification lists 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]);
                /* ==================================================== */
                $list .= '<li><b>' . db_fetch_cell('SELECT description FROM host WHERE id=' . $matches[1]) . '</b></li>';
                $array[] = $matches[1];
            }
        }
        top_header();
        html_start_box($assoc_actions[get_request_var('drp_action')] . ' ' . __('Device(s)'), '60%', '', '3', 'center', '');
        form_start('maint.php');
        if (sizeof($array)) {
            if (get_request_var('drp_action') == '1') {
                /* associate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to associate the Device(s) below with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Associate Maintenance Schedule(s)') . "'>";
            } elseif (get_request_var('drp_action') == '2') {
                /* disassociate */
                print "<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>" . __('Click \'Continue\' to disassociate the Devices(s) below with the Maintenance Schedule \'<b>%s</b>\'.', $list_name) . "</p>\n\t\t\t\t\t\t<ul>{$list}</ul>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
                $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Disassociate Maintenance Schedule(s)') . "'>";
            }
        } else {
            print "<tr><td><span class='textError'>" . __('You must select at least one Device.') . "</span></td></tr>\n";
            $save_html = "<input type='button' value='" . __('Return') . "' onClick='cactiReturnTo()'>";
        }
        print "<tr class='saveRow'>\n\t\t\t<td>\n\t\t\t\t<input type='hidden' name='action' value='actions'>\n\t\t\t\t<input type='hidden' name='id' value='" . get_request_var('id') . "'>\n\t\t\t\t<input type='hidden' name='save_webseer' value='1'>\n\t\t\t\t<input type='hidden' name='selected_items' value='" . (isset($array) ? serialize($array) : '') . "'>\n\t\t\t\t<input type='hidden' name='drp_action' value='" . get_request_var('drp_action') . "'>\n\t\t\t\t{$save_html}\n\t\t\t</td>\n\t\t</tr>\n";
        form_end();
        html_end_box();
        bottom_footer();
    } else {
        api_plugin_hook_function('maint_actions_prepare');
    }
}
Ejemplo n.º 18
0
function form_actions()
{
    global $dq_actions;
    /* ================= input validation ================= */
    input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)\$");
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = sanitize_unserialize_selected_items($_POST['selected_items']);
        if ($selected_items != false) {
            if ($_POST["drp_action"] == "1") {
                /* delete */
                for ($i = 0; $i < count($selected_items); $i++) {
                    data_query_remove($selected_items[$i]);
                }
            }
        }
        header("Location: data_queries.php");
        exit;
    }
    /* setup some variables */
    $dq_list = "";
    $i = 0;
    /* loop through each of the data queries and process them */
    while (list($var, $val) = each($_POST)) {
        if (preg_match("/^chk_([0-9]+)\$/", $var, $matches)) {
            /* ================= input validation ================= */
            input_validate_input_number($matches[1]);
            /* ==================================================== */
            $dq_list .= "<li>" . htmlspecialchars(db_fetch_cell("SELECT snmp_query.name FROM snmp_query WHERE id='" . $matches[1] . "'")) . "</li>";
            $dq_array[$i] = $matches[1];
            $i++;
        }
    }
    include_once "./include/top_header.php";
    html_start_box("<strong>" . $dq_actions[$_POST["drp_action"]] . "</strong>", "60%", "", "3", "center", "");
    print "<form action='data_queries.php' method='post'>\n";
    if (isset($dq_array) && sizeof($dq_array)) {
        if ($_POST["drp_action"] == "1") {
            /* delete */
            $graphs = array();
            print "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='textArea' class='odd'>\n\t\t\t\t\t\t<p>When you click \"Continue\" the following Data Querie(s) will be deleted.</p>\n\t\t\t\t\t\t<p><ul>{$dq_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
        }
        $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete Data Querie(s)'>";
    } else {
        print "<tr><td class='odd'><span class='textError'>You must select at least one data query.</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' class='saveRow'>\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($dq_array) ? serialize($dq_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 "./include/bottom_footer.php";
}
Ejemplo n.º 19
0
function form_actions()
{
    global $ds_actions;
    /* ================= input validation ================= */
    input_validate_input_regex(get_request_var_post('drp_action'), "^([a-zA-Z0-9_]+)\$");
    /* ==================================================== */
    /* if we are to save this form, instead of display it */
    if (isset($_POST["selected_items"])) {
        $selected_items = sanitize_unserialize_selected_items($_POST['selected_items']);
        if ($selected_items != false) {
            if ($_POST["drp_action"] == "1") {
                /* delete */
                $data_template_datas = db_fetch_assoc("select id from data_template_data where " . array_to_sql_or($selected_items, "data_template_id") . " and local_data_id=0");
                if (sizeof($data_template_datas) > 0) {
                    foreach ($data_template_datas as $data_template_data) {
                        db_execute("delete from data_template_data_rra where data_template_data_id=" . $data_template_data["id"]);
                    }
                }
                db_execute("delete from data_template_data where " . array_to_sql_or($selected_items, "data_template_id") . " and local_data_id=0");
                db_execute("delete from data_template_rrd where " . array_to_sql_or($selected_items, "data_template_id") . " and local_data_id=0");
                db_execute("delete from snmp_query_graph_rrd where " . array_to_sql_or($selected_items, "data_template_id"));
                db_execute("delete from snmp_query_graph_rrd_sv where " . array_to_sql_or($selected_items, "data_template_id"));
                db_execute("delete from data_template where " . array_to_sql_or($selected_items, "id"));
                /* "undo" any graph that is currently using this template */
                db_execute("update data_template_data set local_data_template_data_id=0,data_template_id=0 where " . array_to_sql_or($selected_items, "data_template_id"));
                db_execute("update data_template_rrd set local_data_template_rrd_id=0,data_template_id=0 where " . array_to_sql_or($selected_items, "data_template_id"));
                db_execute("update data_local set data_template_id=0 where " . array_to_sql_or($selected_items, "data_template_id"));
            } elseif ($_POST["drp_action"] == "2") {
                /* duplicate */
                for ($i = 0; $i < count($selected_items); $i++) {
                    duplicate_data_source(0, $selected_items[$i], $_POST["title_format"]);
                }
            }
        }
        header("Location: data_templates.php");
        exit;
    }
    /* setup some variables */
    $ds_list = "";
    $i = 0;
    /* loop through each of the graphs 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]);
            /* ==================================================== */
            $ds_list .= "<li>" . htmlspecialchars(db_fetch_cell("select name from data_template where id=" . $matches[1])) . "</li>";
            $ds_array[$i] = $matches[1];
            $i++;
        }
    }
    include_once "./include/top_header.php";
    html_start_box("<strong>" . $ds_actions[$_POST["drp_action"]] . "</strong>", "60%", "", "3", "center", "");
    print "<form action='data_templates.php' method='post'>\n";
    if (isset($ds_array) && sizeof($ds_array)) {
        if ($_POST["drp_action"] == "1") {
            /* delete */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Template(s) will be deleted.  Any data sources attached\n\t\t\t\t\t\tto these templates will become individual Data Source(s) and all Templating benefits will be removed.</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Delete Data Template(s)'>";
        } elseif ($_POST["drp_action"] == "2") {
            /* duplicate */
            print "\t<tr>\n\t\t\t\t\t<td class='textArea'>\n\t\t\t\t\t\t<p>When you click \"Continue\", the following Data Template(s) will be duplicated. You can\n\t\t\t\t\t\toptionally change the title format for the new Data Template(s).</p>\n\t\t\t\t\t\t<p><ul>{$ds_list}</ul></p>\n\t\t\t\t\t\t<p><strong>Title Format:</strong><br>";
            form_text_box("title_format", "<template_title> (1)", "", "255", "30", "text");
            print "</p>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\n\t\t\t\t";
            $save_html = "<input type='button' value='Cancel' onClick='window.history.back()'>&nbsp;<input type='submit' value='Continue' title='Duplicate Data Template(s)'>";
        }
    } else {
        print "<tr><td class='even'><span class='textError'>You must select at least one data template.</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' class='saveRow'>\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($ds_array) ? serialize($ds_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 "./include/bottom_footer.php";
}
Ejemplo n.º 20
0
function form_actions()
{
    global $config, $host_types_actions, $fields_hmib_host_types_edit;
    /* ================= input validation ================= */
    get_filter_request_var('drp_action');
    /* ==================================================== */
    /* 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 */
                foreach ($selected_items as $item) {
                    api_hmib_host_type_remove($item);
                }
            } elseif (get_request_var('drp_action') == '2') {
                /* duplicate */
                foreach ($selected_items as $item) {
                    hmib_duplicate_host_type($item, $i, get_request_var('title_format'));
                }
            }
        }
        header('Location: hmib_types.php?heder=false');
        exit;
    }
    /* setup some variables */
    $host_types_list = '';
    $i = 0;
    /* loop through each of the device types 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]);
            /* ==================================================== */
            $host_types_info = db_fetch_row('SELECT name FROM plugin_hmib_hrSystemTypes WHERE id=' . $matches[1]);
            $host_types_list .= '<li>' . $host_types_info['name'] . '</li>';
            $host_types_array[$i] = $matches[1];
        }
        $i++;
    }
    top_header();
    form_start('hmib_types.php');
    html_start_box($host_types_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    if (get_filter_request_var('drp_action') == '1') {
        /* delete */
        print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Delete the following Host Type(s)') . "</p>\n\t\t\t\t\t<p><ul>{$host_types_list}</ul></p>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
        $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Delete Host Type(s)') . "'>";
    } elseif (get_filter_request_var('drp_action') == '2') {
        /* duplicate */
        print "\t<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Click \'Continue\' to Duplicate the following Host Type(s). You may optionally change the description for the new Host Type(s).  Otherwise, do not change value below and the original name will be replicated with a new suffix.') . "</p>\n\t\t\t\t\t<p><ul>{$host_types_list}</ul></p>\n\t\t\t\t\t<p><strong>" . __('Host Type Prefix:') . "</strong><br>";
        form_text_box('title_format', '<description> (1)', '', '255', '30', 'text');
        print "</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n";
        $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>&nbsp;<input type='submit' value='" . __('Continue') . "' title='" . __('Duplicate Host Type(s)') . "'>";
    }
    if (!isset($host_types_array)) {
        print "<tr><td class='odd'><span class='textError'>" . __('You must select at least one Host Type.') . "</span></td></tr>\n";
        $save_html = "<input type='button' value='" . __('Cancel') . "' onClick='cactiReturnTo()'>";
    } else {
    }
    print "<tr class='even'>\n\t\t<td colspan='2' 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($host_types_array) ? serialize($host_types_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();
}