}
$wlist = htmlspecialchars($_GET['wlist']);
$type = htmlspecialchars($_GET['type']);
$title = "List";
if (isset($id) && isset($wlist)) {
    $a_rule = $config['installedpackages']['snortglobal']['rule'][$id];
    if ($type == "homenet") {
        $list = snort_build_list($a_rule, $wlist);
        $contents = implode("\n", $list);
        $title = "HOME_NET";
    } elseif ($type == "passlist") {
        $list = snort_build_list($a_rule, $wlist, true);
        $contents = implode("\n", $list);
        $title = "Pass List";
    } elseif ($type == "suppress") {
        $list = snort_find_list($wlist, $type);
        $contents = str_replace("\r", "", base64_decode($list['suppresspassthru']));
        $title = "Suppress List";
    } elseif ($type == "externalnet") {
        if ($wlist == "default") {
            $list = snort_build_list($a_rule, $a_rule['homelistname']);
            $contents = "";
            foreach ($list as $ip) {
                $contents .= "!{$ip}\n";
            }
            $contents = trim($contents, "\n");
        } else {
            $list = snort_build_list($a_rule, $wlist, false, true);
            $contents = implode("\n", $list);
        }
        $title = "EXTERNAL_NET";
}
/* define spoink */
$spoink_type = "";
if ($snortcfg['blockoffenders7'] == "on") {
    $pfkill = "";
    if ($snortcfg['blockoffenderskill'] == "on") {
        $pfkill = "kill";
    }
    $spoink_wlist = snort_build_list($snortcfg, $snortcfg['whitelistname'], true);
    /* write Pass List */
    @file_put_contents("{$snortcfgdir}/{$snortcfg['whitelistname']}", implode("\n", $spoink_wlist));
    $spoink_type = "output alert_pf: {$snortcfgdir}/{$snortcfg['whitelistname']},snort2c,{$snortcfg['blockoffendersip']},{$pfkill}";
}
/* define selected suppress file */
$suppress_file_name = "";
$suppress = snort_find_list($snortcfg['suppresslistname'], 'suppress');
if (!empty($suppress)) {
    $suppress_data = str_replace("\r", "", base64_decode($suppress['suppresspassthru']));
    @file_put_contents("{$snortcfgdir}/supp{$snortcfg['suppresslistname']}", $suppress_data);
    $suppress_file_name = "include {$snortcfgdir}/supp{$snortcfg['suppresslistname']}";
}
/* set the snort performance model */
$snort_performance = "ac-bnfa";
if (!empty($snortcfg['performance'])) {
    $snort_performance = $snortcfg['performance'];
}
/* if user has defined a custom ssh port, use it */
if (is_array($config['system']['ssh']) && isset($config['system']['ssh']['port'])) {
    $ssh_port = $config['system']['ssh']['port'];
} else {
    $ssh_port = "22";