function form_actions()
{
    global $config, $mactrack_view_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') == '1') {
                /* Authorize */
                if (sizeof($selected_items)) {
                    foreach ($selected_items as $mac) {
                        $mac = sanitize_search_string($mac);
                        api_mactrack_authorize_mac_addresses($mac);
                    }
                }
            } elseif (get_request_var('drp_action') == '2') {
                /* Revoke */
                $errors = '';
                if (sizeof($selected_items)) {
                    foreach ($selected_items as $mac) {
                        $mac = sanitize_search_string($mac);
                        $mac_found = db_fetch_cell_prepared('SELECT mac_address FROM mac_track_macauth WHERE mac_address = ?', array($mac));
                        if ($mac_found) {
                            api_mactrack_revoke_mac_addresses($mac);
                        } else {
                            $errors .= ', ' . $mac;
                        }
                    }
                }
                if ($errors) {
                    $_SESSION['sess_messages'] = __('The following MAC Addresses Could not be revoked because they are members of Group Authorizations %s', $errors);
                }
            }
        }
        header('Location: mactrack_view_macs.php');
        exit;
    }
    /* setup some variables */
    $mac_address_list = '';
    $delim = read_config_option('mt_mac_delim');
    /* 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 (substr($var, 0, 4) == 'chk_') {
            $matches = substr($var, 4);
            /* clean up the mac_address */
            if (isset($matches)) {
                $matches = sanitize_search_string($matches);
                $parts = explode('-', $matches);
                $mac = str_replace('_', $delim, $parts[0]);
            }
            if (!isset($mac_address_array[$mac])) {
                $mac_address_list .= '<li>' . $mac . '</li>';
                $mac_address_array[$mac] = $mac;
            }
        }
    }
    top_header();
    html_start_box($mactrack_view_macs_actions[get_request_var('drp_action')], '60%', '', '3', 'center', '');
    form_start('mmactrack_view_macs.php');
    if (get_request_var('drp_action') == '1') {
        /* Authorize Macs */
        print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Are you sure you want to Authorize the following MAC Addresses?') . "</p>\n\t\t\t\t\t<p>{$mac_address_list}</p>\n\t\t\t\t</td>\n\t\t\t</tr>";
    } elseif (get_request_var('drp_action') == '2') {
        /* Revoke Macs */
        print "<tr>\n\t\t\t\t<td class='textArea'>\n\t\t\t\t\t<p>" . __('Are you sure you want to Revoke the following MAC Addresses?') . "</p>\n\t\t\t\t\t<p>{$mac_address_list}</p>\n\t\t\t\t</td>\n\t\t\t</tr>";
    }
    if (!isset($mac_address_array)) {
        print "<tr><td class='even'><span class='textError'>" . __('You must select at least one MAC Address.') . "</span></td></tr>\n";
        $save_html = '';
    } else {
        if (!mactrack_check_user_realm(2122)) {
            print "<tr><td clsas='even'><span class='textError'>" . __('You are not permitted to change Mac Authorizations.') . "</span></td></tr>\n";
            $save_html = '';
        } else {
            $save_html = "<input type='submit' name='save' value='" . __('Yes') . "'>";
        }
    }
    print "<tr>\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($mac_address_array) ? serialize($mac_address_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' 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();
}
function form_actions() {
	global $colors, $config, $mactrack_view_macs_actions;

	/* if we are to save this form, instead of display it */
	if (isset($_POST["selected_items"])) {
		$selected_items = unserialize(stripslashes($_POST["selected_items"]));

		if ($_POST["drp_action"] == "1") { /* Authorize */
			if (sizeof($selected_items)) {
			foreach($selected_items as $mac) {
				$mac = sanitize_search_string($mac);

				api_mactrack_authorize_mac_addresses($mac);
			}
			}
		}elseif ($_POST["drp_action"] == "2") { /* Revoke */
			$errors = "";
			if (sizeof($selected_items)) {
			foreach($selected_items as $mac) {
				/* clean up the mac_address */
				$mac = sanitize_search_string($mac);

				$mac_found = db_fetch_cell("SELECT mac_address FROM mac_track_macauth WHERE mac_address='$mac'");

				if ($mac_found) {
					api_mactrack_revoke_mac_addresses($mac);
				}else{
					$errors .= ", $mac";
				}
			}
			}

			if ($errors) {
				$_SESSION["sess_messages"] = "The following MAC Addresses Could not be revoked because they are members of Group Authorizations" . $errors;
			}
		}

		header("Location: mactrack_view_macs.php");
		exit;
	}

	/* setup some variables */
	$mac_address_list = "";
	$delim = read_config_option("mt_mac_delim");

	/* 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 (substr($var,0,4) == "chk_") {
			$matches = substr($var,4);

			/* clean up the mac_address */
			if (isset($matches)) {
				$matches = sanitize_search_string($matches);
				$parts   = explode("-", $matches);
				$mac     = str_replace("_", $delim, $parts[0]);
			}

			if (!isset($mac_address_array[$mac])) {
				$mac_address_list .= "<li>" . $mac . "<br>";
				$mac_address_array[$mac] = $mac;
			}
		}
	}

	include_once("./include/top_header.php");

	html_start_box("<strong>" . $mactrack_view_macs_actions{$_POST["drp_action"]} . "</strong>", "60%", $colors["header_panel"], "3", "center", "");

	print "<form action='mactrack_view_macs.php' method='post'>\n";

	if ($_POST["drp_action"] == "1") { /* Authorize Macs */
		print "	<tr>
				<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
					<p>Are you sure you want to Authorize the following MAC Addresses?</p>
					<p>$mac_address_list</p>
				</td>
			</tr>\n
			";
	}elseif ($_POST["drp_action"] == "2") { /* Revoke Macs */
		print "	<tr>
				<td class='textArea' bgcolor='#" . $colors["form_alternate1"]. "'>
					<p>Are you sure you want to Revoke the following MAC Addresses?</p>
					<p>$mac_address_list</p>
				</td>
			</tr>\n
			";
	}

	if (!isset($mac_address_array)) {
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You must select at least one MAC Address.</span></td></tr>\n";
		$save_html = "";
	}else if (!mactrack_check_user_realm(2122)) {
		print "<tr><td bgcolor='#" . $colors["form_alternate1"]. "'><span class='textError'>You are not permitted to change Mac Authorizations.</span></td></tr>\n";
		$save_html = "";
	}else{
		$save_html = "<input type='submit' name='save_x' value='Yes'>";
	}

	print "	<tr>
			<td colspan='2' align='right' bgcolor='#eaeaea'>
				<input type='hidden' name='action' value='actions'>
				<input type='hidden' name='selected_items' value='" . (isset($mac_address_array) ? serialize($mac_address_array) : '') . "'>
				<input type='hidden' name='drp_action' value='" . $_POST["drp_action"] . "'>" . (strlen($save_html) ? "
				<input type='submit' name='cancel_x' value='No'>
				$save_html" : "<input type='submit' name='cancel_x' value='Return'>") . "
			</td>
		</tr>
		";

	html_end_box();

	include_once("./include/bottom_footer.php");
}