"LDAP",
'radius' => "Radius");
$ldap_urltypes = array(
'TCP - Standard' => 389,
'SSL - Encrypted' => 636);
$ldap_scopes = array(
'one' => gettext("One Level"),
'subtree' => gettext("Entire Subtree"));
$ldap_protvers = array(
2,
3);
$ldap_templates = array(
'open' => array(
'desc' => "OpenLDAP",
'attr_user' => "cn",
'attr_group' => "cn",
'attr_member' => "member"),
'msad' => array(
'desc' => "Microsoft AD",
'attr_user' => "samAccountName",
'attr_group' => "cn",
'attr_member' => "memberOf"),
'edir' => array(
'desc' => "Novell eDirectory",
'attr_user' => "cn",
'attr_group' => "cn",
'attr_member' => "uniqueMember"));
$radius_srvcs = array(
'both' => gettext("Authentication and Accounting"),
'auth' => gettext("Authentication"),
'acct' => gettext("Accounting"));
$netbios_nodetypes = array(
'0' => "none",
'1' => "b-node",
'2' => "p-node",
'4' => "m-node",
'8' => "h-node");
/* some well known ports */
$wkports = array(
5999 => "CVSup",
53 => "DNS",
21 => "FTP",
3000 => "HBCI",
80 => "HTTP",
443 => "HTTPS",
5190 => "ICQ",
113 => "IDENT/AUTH",
143 => "IMAP",
993 => "IMAP/S",
4500 => "IPsec NAT-T",
500 => "ISAKMP",
1701 => "L2TP",
389 => "LDAP",
1755 => "MMS/TCP",
7000 => "MMS/UDP",
445 => "MS DS",
3389 => "MS RDP",
1512 => "MS WINS",
1863 => "MSN",
119 => "NNTP",
123 => "NTP",
138 => "NetBIOS-DGM",
137 => "NetBIOS-NS",
139 => "NetBIOS-SSN",
1194 => "OpenVPN",
110 => "POP3",
995 => "POP3/S",
1723 => "PPTP",
1812 => "RADIUS",
1813 => "RADIUS accounting",
5004 => "RTP",
5060 => "SIP",
25 => "SMTP",
465 => "SMTP/S",
161 => "SNMP",
162 => "SNMP-Trap",
22 => "SSH",
3478 => "STUN",
587 => "SUBMISSION",
3544 => "Teredo",
23 => "Telnet",
69 => "TFTP",
5900 => "VNC");
/* TCP flags */
$tcpflags = array("fin", "syn", "rst", "psh", "ack", "urg", "ece", "cwr");
$specialnets = array(
"(self)" => gettext("This Firewall"),
"pppoe" => gettext("PPPoE clients"),
"l2tp" => gettext("L2TP clients"));
$spiflist = get_configured_interface_with_descr(false, true);
foreach ($spiflist as $ifgui => $ifdesc) {
$specialnets[$ifgui] = $ifdesc . " net";
$specialnets[$ifgui . 'ip'] = $ifdesc . " address";
}
$medias = array(
"auto" => gettext("autoselect"),
"100full" => gettext("100BASE-TX full-duplex"),
"100half" => gettext("100BASE-TX half-duplex"),
"10full" => gettext("10BASE-T full-duplex"),
"10half" => gettext("10BASE-T half-duplex"));
$wlan_modes = array(
"bss" => gettext("Infrastructure (BSS)"),
"adhoc" => gettext("Ad-hoc (IBSS)"),
"hostap" => gettext("Access Point"));
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, &$input_errors) {
/* check for bad control characters */
foreach ($postdata as $pn => $pd) {
if (is_string($pd) && preg_match("/[\\x00-\\x08\\x0b\\x0c\\x0e-\\x1f]/", $pd)) {
$input_errors[] = sprintf(gettext("The field %s contains invalid characters."), $pn);
}
}
for ($i = 0; $i < count($reqdfields); $i++) {
if ($_POST[$reqdfields[$i]] == "" && $_REQUEST[$reqdfields[$i]] == "") {
$input_errors[] = sprintf(gettext("The field %s is required."), $reqdfieldsn[$i]);
}
}
}
function print_input_errors($input_errors) {
echo '
';
}
function verify_gzip_file($fname) {
$returnvar = mwexec("/usr/bin/gzip -t " . escapeshellarg($fname));
if ($returnvar != 0) {
return 0;
} else {
return 1;
}
}
function print_info_box_np($msg, $name="apply", $value="", $showapply=false, $class="alert-warning",$showbtn = true) {
global $g;
if (strpos($class, "alert-") !== 0) {
$class = 'alert-' . $class;
}
if (empty($value)) {
$value = gettext("Apply changes");
}
$msg = '' . $msg . '
';
// The $msg string might or might not have had a known translation into the target language.
// So check it against the keywords "apply", "save and "create" in both the target language and English.
if ((stristr($msg, gettext("apply")) != false) || (stristr($msg, gettext("save")) != false) || (stristr($msg, gettext("create")) != false) ||
(stristr($msg, "apply") != false) || (stristr($msg, "save") != false) || (stristr($msg, "create") != false) || $showapply) {
$msg .= '';
} else if ($showbtn) {
$msg = '× ' . $msg;
}
echo '' . $msg . '
';
}
function print_info_box_np_undo($msg, $name = "apply", $value = "Apply changes", $undo) {
global $g;
if (stristr($msg, "apply") != false || stristr($msg, "save") != false || stristr($msg, "create") != false) {
$savebutton = "";
$savebutton .= " ";
$savebutton .= " ";
$savebutton .= " ";
if ($_POST['if']) {
$savebutton .= " ";
}
}
$nifty_redbox = "#990000";
$nifty_blackbox = "#000000";
if (!$savebutton) {
$savebutton = " ";
}
echo <<
{$msg}
{$savebutton}
{$undobutton}
EOFnp;
}
function print_info_box($msg, $class="alert-warning", $showbtn = true) {
print_info_box_np($msg, null, null, false, $class, $showbtn);
}
function get_std_save_message($ok) {
$filter_related = false;
$filter_pages = array("nat", "filter");
$to_return = gettext("The changes have been applied successfully.");
foreach ($filter_pages as $fp) {
if (stristr($_SERVER['SCRIPT_FILENAME'], $fp)) {
$filter_related = true;
}
}
if ($filter_related) {
$to_return .= " " . gettext("You can also monitor the filter reload progress.");
}
return $to_return;
}
function pprint_address($adr) {
global $specialnets;
if (isset($adr['any'])) {
$padr = "*";
} else if ($adr['network']) {
$padr = $specialnets[$adr['network']];
} else {
$padr = $adr['address'];
}
if (isset($adr['not'])) {
$padr = "! " . $padr;
}
return $padr;
}
function pprint_port($port) {
global $wkports;
$pport = "";
if (!$port) {
return "*";
} else {
$srcport = explode("-", $port);
if ((!$srcport[1]) || ($srcport[0] == $srcport[1])) {
$pport = $srcport[0];
if ($wkports[$srcport[0]]) {
$pport .= " (" . $wkports[$srcport[0]] . ")";
}
} else {
$pport .= $srcport[0] . " - " . $srcport[1];
}
}
return $pport;
}
function firewall_check_for_advanced_options(&$item) {
$item_set = "";
if ($item['os']) {
$item_set .= "os {$item['os']} ";
}
if ($item['dscp']) {
$item_set .= "dscp {$item['dscp']} ";
}
if ($item['max']) {
$item_set .= "max {$item['max']} ";
}
if ($item['max-src-nodes']) {
$item_set .= "max-src-nodes {$item['max-src-nodes']} ";
}
if ($item['max-src-conn']) {
$item_set .= "max-src-conn {$item['max-src-conn']} ";
}
if ($item['max-src-states']) {
$item_set .= "max-src-states {$item['max-src-states']} ";
}
if (isset($item['nopfsync'])) {
$item_set .= "nopfsync ";
}
if ($item['statetype'] != "keep state" && $item['statetype'] != "") {
$item_set .= "statetype {$item['statetype']} ";
}
if ($item['statetimeout']) {
$item_set .= "statetimeout {$item['statetimeout']} ";
}
if (isset($item['nosync'])) {
$item_set .= "no XMLRPC Sync ";
}
if ($item['max-src-conn-rate']) {
$item_set .= "max-src-conn-rate {$item['max-src-conn-rate']} ";
}
if ($item['max-src-conn-rates']) {
$item_set .= "max-src-conn-rates {$item['max-src-conn-rates']} ";
}
if ($item['vlanprio']) {
$item_set .= "vlanprio {$item['vlanprio']} ";
}
if ($item['vlanprioset']) {
$item_set .= "vlanprioset {$item['vlanprioset']} ";
}
if ($item['gateway']) {
$item_set .= "gateway {$item['gateway']} ";
}
if ($item['dnpipe']) {
$item_set .= "limiter {$item['dnpipe']} ";
}
if ($item['pdnpipe']) {
$item_set .= "limiter {$item['pdnpipe']} ";
}
if ($item['ackqueue']) {
$item_set .= "ackqueue {$item['ackqueue']} ";
}
if ($item['defaultqueue']) {
$item_set .= "defaultqueue {$item['defaultqueue']} ";
}
if ($item['tag']) {
$item_set .= "tag {$item['tag']} ";
}
if ($item['tagged']) {
$item_set .= "tagged {$item['tagged']} ";
}
if (isset($item['allowopts'])) {
$item_set .= "allowopts ";
}
if (isset($item['disablereplyto'])) {
$item_set .= "disable reply-to ";
}
if ($item['tcpflags_any'] || $item['tcpflags1'] || $item['tcpflags2']) {
$item_set .= "tcpflags set";
}
return $item_set;
}
function gentitle($title) {
global $navlevelsep;
if (!is_array($title)) {
return $title;
} else {
return join($navlevelsep, $title);
}
}
function genhtmltitle($title) {
if (!is_array($title)) {
return '';
}
$heading = '';
// If the array contains only one element, there are no breadcrumbs, so don't
// add anything else
if (count($title) > 1) {
$bc = '';
foreach ($title as $el) {
$bc .= ''.$el.' ';
}
$bc .= ' ';
} else {
$bc = "";
}
return $heading . $bc;
}
/* update the changedesc and changecount(er) variables */
function update_changedesc($update) {
global $changedesc;
global $changecount;
$changedesc .= " {$update}";
$changecount++;
}
// This version of dump_clog() does not output or any other table elements.
function dump_clog_no_table($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
global $g, $config;
$sor = isset($config['syslog']['reverse']) ? "-r" : "";
$specific_log = basename($logfile, '.log') . '_settings';
if ($config['syslog'][$specific_log]['cronorder'] == 'forward') $sor = "";
if ($config['syslog'][$specific_log]['cronorder'] == 'reverse') $sor = "-r";
$logarr = array();
$grepline = " ";
if (is_array($grepfor)) {
$invert = '';
if ((strpos($grepfor[0], '!') === 0)) {
$grepfor[0] = substr($grepfor[0], 1);
$invert = '-v';
}
$grepline .= " | /usr/bin/egrep {$invert} " . escapeshellarg(implode("|", $grepfor));
}
if (is_array($grepinvert)) {
$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
}
if (is_dir($logfile)) {
$logarr = array(sprintf(gettext("File %s is a directory."), $logfile));
} elseif (file_exists($logfile) && filesize($logfile) == 0) {
$logarr = array(gettext("Log file started."));
} else {
if ($config['system']['disablesyslogclog']) {
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} else {
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
}
echo "\n";
$rows = 0;
foreach ($logarr as $logent) {
$rows++;
$logent = preg_split("/\s+/", $logent, 6);
if ($withorig) {
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " ";
$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]);
echo "{$entry_date_time}";
echo " " . "{$entry_text}" . "\n";
} else {
echo htmlspecialchars($logent[5]) . "\n";
}
}
return($rows);
}
function dump_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "") {
global $g, $config;
$sor = isset($config['syslog']['reverse']) ? "-r" : "";
$specific_log = basename($logfile, '.log') . '_settings';
if ($config['syslog'][$specific_log]['cronorder'] == 'forward') $sor = "";
if ($config['syslog'][$specific_log]['cronorder'] == 'reverse') $sor = "-r";
$logarr = array();
$grepline = " ";
if (is_array($grepfor)) {
$invert = '';
if ((strpos($grepfor[0], '!') === 0)) {
$grepfor[0] = substr($grepfor[0], 1);
$invert = '-v';
}
$grepline .= " | /usr/bin/egrep {$invert} " . escapeshellarg(implode("|", $grepfor));
}
if (is_array($grepinvert)) {
$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
}
if (is_dir($logfile)) {
$logarr = array(sprintf(gettext("File %s is a directory."), $logfile));
} elseif (file_exists($logfile) && filesize($logfile) == 0) {
$logarr = array(gettext("Log file started."));
} else {
if ($config['system']['disablesyslogclog']) {
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} else {
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
}
$rows = 0;
foreach ($logarr as $logent) {
$rows++;
$logent = preg_split("/\s+/", $logent, 6);
echo "\n";
if ($withorig) {
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " ";
$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]);
echo "{$entry_date_time} \n";
echo "{$entry_text} \n";
} else {
echo "" . htmlspecialchars($logent[5]) . " \n";
}
echo " \n";
}
return($rows);
}
function return_clog($logfile, $tail, $withorig = true, $grepfor = "", $grepinvert = "", $grepreverse = false) {
global $g, $config;
$sor = (isset($config['syslog']['reverse']) || $grepreverse) ? "-r" : "";
$specific_log = basename($logfile, '.log') . '_settings';
if (($config['syslog'][$specific_log]['cronorder'] == 'forward') && !$grepreverse) $sor = "";
if (($config['syslog'][$specific_log]['cronorder'] == 'reverse') || $grepreverse) $sor = "-r";
$logarr = array();
$grepline = " ";
if (is_array($grepfor)) {
$grepline .= " | /usr/bin/egrep " . escapeshellarg(implode("|", $grepfor));
}
if (is_array($grepinvert)) {
$grepline .= " | /usr/bin/egrep -v " . escapeshellarg(implode("|", $grepinvert));
}
if ($config['system']['disablesyslogclog']) {
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
} else {
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
return($logarr);
}
/* Check if variable has changed, update and log if it has
* returns true if var changed
* varname = variable name in plain text
* orig = original value
* new = new value
*/
function update_if_changed($varname, & $orig, $new) {
if (is_array($orig) && is_array($new)) {
$a_diff = array_diff($orig, $new);
foreach ($a_diff as $diff) {
update_changedesc("removed {$varname}: \"{$diff}\"");
}
$a_diff = array_diff($new, $orig);
foreach ($a_diff as $diff) {
update_changedesc("added {$varname}: \"{$diff}\"");
}
$orig = $new;
return true;
} else {
if ($orig != $new) {
update_changedesc("{$varname}: \"{$orig}\" -> \"{$new}\"");
$orig = $new;
return true;
}
}
return false;
}
function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
if (isset($adr['any'])) {
$padr = "any";
} else if ($adr['network']) {
$padr = $adr['network'];
} else if ($adr['address']) {
list($padr, $pmask) = explode("/", $adr['address']);
if (!$pmask) {
if (is_ipaddrv6($padr)) {
$pmask = 128;
} else {
$pmask = 32;
}
}
}
if (isset($adr['not'])) {
$pnot = 1;
} else {
$pnot = 0;
}
if ($adr['port']) {
list($pbeginport, $pendport) = explode("-", $adr['port']);
if (!$pendport) {
$pendport = $pbeginport;
}
} else if (!is_alias($pbeginport) && !is_alias($pendport)) {
$pbeginport = "any";
$pendport = "any";
}
}
function pconfig_to_address(&$adr, $padr, $pmask, $pnot = false, $pbeginport = 0, $pendport = 0) {
$adr = array();
if ($padr == "any") {
$adr['any'] = true;
} else if (is_specialnet($padr)) {
$adr['network'] = $padr;
} else {
$adr['address'] = $padr;
if (is_ipaddrv6($padr)) {
if ($pmask != 128) {
$adr['address'] .= "/" . $pmask;
}
} else {
if ($pmask != 32) {
$adr['address'] .= "/" . $pmask;
}
}
}
if ($pnot) {
$adr['not'] = true;
} else {
unset($adr['not']);
}
if (($pbeginport != 0) && ($pbeginport != "any")) {
if ($pbeginport != $pendport) {
$adr['port'] = $pbeginport . "-" . $pendport;
} else {
$adr['port'] = $pbeginport;
}
}
if (is_alias($pbeginport)) {
$adr['port'] = $pbeginport;
}
}
function is_specialnet($net) {
global $specialsrcdst;
if (!$net) {
return false;
}
if (in_array($net, $specialsrcdst)) {
return true;
} else {
return false;
}
}
//function to create widget tabs when called
function display_widget_tabs(& $tab_array) {
echo "";
$tabscounter = 0;
foreach ($tab_array as $ta) {
$dashpos = strpos($ta[2], '-');
$tabname = $ta[2] . "-tab";
$tabclass = substr($ta[2], 0, $dashpos);
$tabclass = $tabclass . "-class";
if ($ta[1] == true) {
$tabActive = "table-cell";
$tabNonActive = "none";
} else {
$tabActive = "none";
$tabNonActive = "table-cell";
}
echo "
";
echo " {$ta[0]}";
echo " ";
echo "
";
echo "
";
echo " {$ta[0]}";
echo " ";
echo "
";
}
echo "
";
}
// Return inline javascript file or CSS to minimize
// request count going back to server.
function outputJavaScriptFileInline($javascript) {
if (file_exists($javascript)) {
echo "\n\n";
} else {
echo "\n\n\n\n";
}
}
function outputCSSPrintFileInline($css) {
if (file_exists($css)) {
echo "\n\n";
} else {
echo "\n\n\n\n";
}
}
function outputCSSFileInline($css) {
if (file_exists($css)) {
echo "\n\n";
} else {
echo "\n\n\n\n";
}
}
$rfc2616 = array(
100 => "100 Continue",
101 => "101 Switching Protocols",
200 => "200 OK",
201 => "201 Created",
202 => "202 Accepted",
203 => "203 Non-Authoritative Information",
204 => "204 No Content",
205 => "205 Reset Content",
206 => "206 Partial Content",
300 => "300 Multiple Choices",
301 => "301 Moved Permanently",
302 => "302 Found",
303 => "303 See Other",
304 => "304 Not Modified",
305 => "305 Use Proxy",
306 => "306 (Unused)",
307 => "307 Temporary Redirect",
400 => "400 Bad Request",
401 => "401 Unauthorized",
402 => "402 Payment Required",
403 => "403 Forbidden",
404 => "404 Not Found",
405 => "405 Method Not Allowed",
406 => "406 Not Acceptable",
407 => "407 Proxy Authentication Required",
408 => "408 Request Timeout",
409 => "409 Conflict",
410 => "410 Gone",
411 => "411 Length Required",
412 => "412 Precondition Failed",
413 => "413 Request Entity Too Large",
414 => "414 Request-URI Too Long",
415 => "415 Unsupported Media Type",
416 => "416 Requested Range Not Satisfiable",
417 => "417 Expectation Failed",
500 => "500 Internal Server Error",
501 => "501 Not Implemented",
502 => "502 Bad Gateway",
503 => "503 Service Unavailable",
504 => "504 Gateway Timeout",
505 => "505 HTTP Version Not Supported"
);
function is_rfc2616_code($code) {
global $rfc2616;
if (isset($rfc2616[$code])) {
return true;
} else {
return false;
}
}
function print_rfc2616_select($tag, $current) {
global $rfc2616;
/* Default to 200 OK if not set */
if ($current == "") {
$current = 200;
}
echo "\n";
foreach ($rfc2616 as $code => $message) {
if ($code == $current) {
$sel = " selected";
} else {
$sel = "";
}
echo "{$message} \n";
}
echo " \n";
}
// Useful debugging function, much cleaner than print_r
function echo_array($array, $return_me = false) {
if (is_array($array) == false) {
$return = "The provided variable is not an array.";
} else {
foreach ($array as $name=>$value) {
if (is_array($value)) {
$return .= "";
$return .= "['$name '] {\n";
$return .= echo_array($value, true);
$return .= "
}";
$return .= "\n\n";
} else {
if (is_string($value)) {
$value = "\"$value\"";
}
$return .= "['$name '] = $value\n\n";
}
}
}
if ($return_me == true) {
return $return;
} else {
echo "".$return." ";
}
}
/****f* pfsense-utils/display_top_tabs
* NAME
* display_top_tabs - display tabs with rounded edges
* INPUTS
* $text - array of tabs
* RESULT
* null
******/
function display_top_tabs(& $tab_array, $no_drop_down = false, $type = 'pills') {
global $config;
global $g;
global $tab_array_indent;
global $tab_array_space;
global $tab_array_char_limit;
/* does the user have access to this tab?
* master user has access to everything.
* if the user does not have access, simply
* unset the tab item.
*/
/* empty string code */
if ($tab_array_indent == '') {
$tab_array_indent = 0;
}
if ($tab_array_space == '') {
$tab_array_space = 1;
}
if ($tab_array_char_limit == '') {
$tab_array_char_limit = 92;
}
foreach ($tab_array as $tab_id => $ta) {
if (!isAllowedPage($ta[2])) {
unset ($tab_array[$tab_id]);
}
}
$tab_active_bg = "#EEEEEE";
$tab_inactive_bg = "#777777";
$nifty_tabs_corners = "#FFF";
$font_color = "white";
$tabcharcount = 0;
foreach ($tab_array as $ta) {
$tabcharcount = $tabcharcount + strlen($ta[0]);
}
if ($no_drop_down == true) {
$tabcharcount = 0;
unset($tab_array_char_limit);
}
// If the character count of the tab names is > 670
// then show a select item dropdown menubox.
if ($tabcharcount > $tab_array_char_limit) {
echo gettext("Currently viewing: ");
echo "\n";
foreach ($tab_array as $ta) {
if ($ta[1] == "true") {
$selected = " selected";
} else {
$selected = "";
}
// Onclick in option will not work in some browser
// echo "{$ta['0']} \n";
echo "{$ta['0']} \n";
}
echo " \n
";
echo "";
} else {
echo '';
}
}
function add_package_tabs($tabgroup, &$tab_array) {
global $config, $g;
if (!isset($config['installedpackages']['package'])) {
return;
}
foreach ($config['installedpackages']['package'] as $pkg) {
$pkg_config = read_package_configurationfile($pkg['name']);
if (!isset($pkg_config['tabs']['tab'])) {
continue;
}
foreach ($pkg_config['tabs']['tab'] as $tab) {
$tab_entry = array();
if ($tab['name']) {
$tab_entry[] = $tab['name'];
$tab_entry[] = false;
$tab_entry[] = $tab['url'];
$tab_array[] = $tab_entry;
}
}
}
}
function alias_info_popup($alias_id) {
global $config;
if (!is_array($config['aliases']['alias'][$alias_id])) {
return;
}
$maxlength = 60;
$alias = $config['aliases']['alias'][$alias_id];
$content = "";
if ($alias['url']) {
// TODO: Change it when pf supports tables with ports
if ($alias['type'] == "urltable") {
exec("/sbin/pfctl -t {$alias['name']} -T show | wc -l", $total_entries);
$counter=preg_replace("/\D/", "", $total_entries[0]);
exec("/sbin/pfctl -t {$alias['name']} -T show | head -10002", $alias_addresses);
} else {
$urlfn = alias_expand_urltable($alias['name']);
$alias_addresses = explode("\n", file_get_contents($urlfn));
$counter = count($alias_addresses);
}
$content .= ''. $alias['url'] .' '. implode(' ', $alias_addresses) .' ';
if ($counter > 10002) {
$content .= ''. gettext("listing only first 10k items") .' ';
}
} else {
$alias_addresses = explode (" ", $alias['address']);
$alias_details = explode ("||", $alias['detail']);
$idx = 0;
$content .= "\n";
$content .= "\n";
$content .= "\n";
$content .= "" . gettext("Value") . " " . gettext("Description") . " \n";
$content .= " \n";
$content .= "\n";
foreach ($alias_addresses as $ap) {
$content .= " \n";
$content .= " \n";
$content .= $ap;
$content .= " \n";
$content .= " \n";
$content .= $alias_details[$idx];
$content .= " \n";
$content .= " \n";
$idx++;
}
$content .= " \n";
$content .= "\n";
}
if (strlen($alias['descr']) >= $maxlength) {
$alias['descr'] = substr($alias['descr'], 0, $maxlength) . '…';
}
return $content;
}
function rule_columns_with_alias($src, $srcport, $dst, $dstport) {
global $config;
if ($config['aliases']['alias'] == "" || !is_array($config['aliases']['alias'])) {
return;
}
$columns = array();
foreach ($config['aliases']['alias'] as $alias_id => $alias_name) {
if ($alias_name['name'] == $src) {
$columns['src'] = $alias_id;
}
if ($alias_name['name'] == $srcport) {
$columns['srcport'] = $alias_id;
}
if ($alias_name['name'] == $dst) {
$columns['dst'] = $alias_id;
}
if ($alias_name['name'] == $dstport) {
$columns['dstport'] = $alias_id;
}
}
return $columns;
}
function form_output_row($name, $label, $content) {
var_dump($content);die;
?>
$flash_message) {
print_info_box_np(implode(" ", $flash_message), null, null, false, $class);
}
unset($_SESSION['flash_messages']);
}
}
/* Retrieve GET or POST Value/State
* Eample Usage:
* $value = getGETPOSTsettingvalue('get/post parameter name', "");
* $value = getGETPOSTsettingvalue('get/post parameter name', null);
* $state = getGETPOSTsettingvalue('get/post parameter name', null);
* $state = getGETPOSTsettingvalue('get/post parameter name', false);
*/
function getGETPOSTsettingvalue($settingname, $default) {
$settingvalue = $default;
if ($_GET[$settingname]) {
$settingvalue = $_GET[$settingname];
}
if ($_POST[$settingname]) {
$settingvalue = $_POST[$settingname];
}
return $settingvalue;
}
/* set timezone */
if (isset($config['system']['timezone']) &&
!empty($config['system']['timezone'])) {
$timezone = $config['system']['timezone'];
} elseif (isset($g['default_timezone']) && !empty($g['default_timezone'])) {
$timezone = $g['default_timezone'];
} else {
$timezone = "Etc/UTC";
}
date_default_timezone_set($timezone);
?>