From 5f6010605ba8e3ab2fbc27080ec2db80dbd0e32e Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 19 Apr 2015 18:00:00 +0545 Subject: Code style usr-local-www diag --- usr/local/www/diag_arp.php | 72 ++++---- usr/local/www/diag_authentication.php | 20 ++- usr/local/www/diag_backup.php | 271 +++++++++++++++-------------- usr/local/www/diag_confbak.php | 122 ++++++------- usr/local/www/diag_dns.php | 92 +++++----- usr/local/www/diag_dump_states.php | 33 ++-- usr/local/www/diag_dump_states_sources.php | 23 ++- usr/local/www/diag_gmirror.php | 207 +++++++++++----------- usr/local/www/diag_ipsec.php | 118 ++++++++----- usr/local/www/diag_ipsec_leases.php | 2 +- usr/local/www/diag_ipsec_xml.php | 12 +- usr/local/www/diag_limiter_info.php | 60 ++++--- usr/local/www/diag_logs.php | 30 ++-- usr/local/www/diag_logs_auth.php | 10 +- usr/local/www/diag_logs_dhcp.php | 7 +- usr/local/www/diag_logs_filter.php | 223 +++++++++++++----------- usr/local/www/diag_logs_filter_dynamic.php | 43 +++-- usr/local/www/diag_logs_filter_summary.php | 52 +++--- usr/local/www/diag_logs_gateways.php | 33 ++-- usr/local/www/diag_logs_ipsec.php | 22 +-- usr/local/www/diag_logs_ntpd.php | 54 +++--- usr/local/www/diag_logs_openvpn.php | 20 ++- usr/local/www/diag_logs_ppp.php | 22 +-- usr/local/www/diag_logs_relayd.php | 51 +++--- usr/local/www/diag_logs_resolver.php | 38 ++-- usr/local/www/diag_logs_routing.php | 60 ++++--- usr/local/www/diag_logs_settings.php | 28 +-- usr/local/www/diag_logs_vpn.php | 47 ++--- usr/local/www/diag_logs_wireless.php | 60 ++++--- usr/local/www/diag_nanobsd.php | 46 ++--- usr/local/www/diag_ndp.php | 41 +++-- usr/local/www/diag_packet_capture.php | 78 +++++---- usr/local/www/diag_patterns.php | 9 +- usr/local/www/diag_pf_info.php | 85 ++++----- usr/local/www/diag_ping.php | 27 +-- usr/local/www/diag_pkglogs.php | 76 ++++---- usr/local/www/diag_resetstate.php | 126 +++++++------- usr/local/www/diag_routes.php | 117 +++++++------ usr/local/www/diag_smart.php | 61 +++---- usr/local/www/diag_sockets.php | 148 ++++++++++------ usr/local/www/diag_states_summary.php | 20 ++- usr/local/www/diag_system_activity.php | 87 ++++----- usr/local/www/diag_system_pftop.php | 79 ++++----- usr/local/www/diag_tables.php | 63 ++++--- usr/local/www/diag_testport.php | 41 +++-- usr/local/www/diag_traceroute.php | 28 +-- 46 files changed, 1640 insertions(+), 1324 deletions(-) diff --git a/usr/local/www/diag_arp.php b/usr/local/www/diag_arp.php index 16b3303..00af12f 100644 --- a/usr/local/www/diag_arp.php +++ b/usr/local/www/diag_arp.php @@ -13,11 +13,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -58,11 +58,13 @@ function adjust_gmt($dt) { } function remove_duplicate($array, $field) { - foreach ($array as $sub) + foreach ($array as $sub) { $cmp[] = $sub[$field]; + } $unique = array_unique($cmp); - foreach ($unique as $k => $rien) + foreach ($unique as $k => $rien) { $new[] = $array[$k]; + } return $new; } @@ -78,7 +80,7 @@ $cleanpattern = "'{ gsub(\"#.*\", \"\");} { gsub(\";\", \"\"); print;}'"; /* We then split the leases file by } */ $splitpattern = "'BEGIN { RS=\"}\";} {for (i=1; i<=NF; i++) printf \"%s \", \$i; printf \"}\\n\";}'"; -/* stuff the leases file in a proper format into a array by line */ +/* stuff the leases file in a proper format into an array by line */ exec("cat {$leasesfile} | {$awk} {$cleanpattern} | {$awk} {$splitpattern}", $leases_content); $leases_count = count($leases_content); @@ -88,19 +90,19 @@ $i = 0; $l = 0; $p = 0; // Put everything together again -while($i < $leases_count) { +while ($i < $leases_count) { /* split the line by space */ $data = explode(" ", $leases_content[$i]); /* walk the fields */ $f = 0; $fcount = count($data); /* with less then 20 fields there is nothing useful */ - if($fcount < 20) { + if ($fcount < 20) { $i++; continue; } - while($f < $fcount) { - switch($data[$f]) { + while ($f < $fcount) { + switch ($data[$f]) { case "failover": $pools[$p]['name'] = $data[$f+2]; $pools[$p]['mystate'] = $data[$f+7]; @@ -166,7 +168,7 @@ while($i < $leases_count) { case "hardware": $leases[$l]['mac'] = $data[$f+2]; /* check if it's online and the lease is active */ - if($leases[$l]['act'] == "active") { + if ($leases[$l]['act'] == "active") { $online = exec("/usr/sbin/arp -an |/usr/bin/awk '/{$leases[$l]['ip']}/ {print}'|wc -l"); if ($online == 1) { $leases[$l]['online'] = 'online'; @@ -177,11 +179,11 @@ while($i < $leases_count) { $f = $f+2; break; case "client-hostname": - if($data[$f+1] <> "") { + if ($data[$f+1] <> "") { $leases[$l]['hostname'] = preg_replace('/"/','',$data[$f+1]); } else { $hostname = gethostbyaddr($leases[$l]['ip']); - if($hostname <> "") { + if ($hostname <> "") { $leases[$l]['hostname'] = $hostname; } } @@ -198,11 +200,11 @@ while($i < $leases_count) { } /* remove duplicate items by mac address */ -if(count($leases) > 0) { +if (count($leases) > 0) { $leases = remove_duplicate($leases,"ip"); } -if(count($pools) > 0) { +if (count($pools) > 0) { $pools = remove_duplicate($pools,"name"); asort($pools); } @@ -225,8 +227,9 @@ $ifdescrs = get_configured_interface_with_descr(); foreach ($ifdescrs as $key => $interface) { $thisif = convert_friendly_interface_to_real_interface_name($key); - if (!empty($thisif)) + if (!empty($thisif)) { $hwif[$thisif] = $interface; + } } $data = array(); @@ -245,15 +248,16 @@ foreach ($rawdata as $line) { function _getHostName($mac,$ip) { global $dhcpmac, $dhcpip; - if ($dhcpmac[$mac]) + if ($dhcpmac[$mac]) { return $dhcpmac[$mac]; - else if ($dhcpip[$ip]) + } else if ($dhcpip[$ip]) { return $dhcpip[$ip]; - else{ + } else { exec("host -W 1 " . escapeshellarg($ip), $output); if (preg_match('/.*pointer ([A-Za-z_0-9.-]+)\..*/',$output[0],$matches)) { - if ($matches[1] <> $ip) - return $matches[1]; + if ($matches[1] <> $ip) { + return $matches[1]; + } } } return ""; @@ -276,28 +280,34 @@ include("head.inc"); {$mac_man[$mac_hi]}"; } + if (isset($mac_man[$mac_hi])) { print "
{$mac_man[$mac_hi]}"; } ?> diff --git a/usr/local/www/diag_authentication.php b/usr/local/www/diag_authentication.php index df68560..1c02828 100644 --- a/usr/local/www/diag_authentication.php +++ b/usr/local/www/diag_authentication.php @@ -10,11 +10,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -48,19 +48,22 @@ if ($_POST) { unset($input_errors); $authcfg = auth_get_authserver($_POST['authmode']); - if (!$authcfg) + if (!$authcfg) { $input_errors[] = $_POST['authmode'] . " " . gettext("is not a valid authentication server"); + } - if (empty($_POST['username']) || empty($_POST['passwordfld'])) + if (empty($_POST['username']) || empty($_POST['passwordfld'])) { $input_errors[] = gettext("A username and password must be specified."); + } if (!$input_errors) { if (authenticate_user($_POST['username'], $_POST['passwordfld'], $authcfg)) { $savemsg = gettext("User") . ": " . $_POST['username'] . " " . gettext("authenticated successfully."); $groups = getUserGroups($_POST['username'], $authcfg); $savemsg .= "
" . gettext("This user is a member of these groups") . ":
"; - foreach ($groups as $group) + foreach ($groups as $group) { $savemsg .= "{$group} "; + } } else { $input_errors[] = gettext("Authentication failed."); } @@ -95,11 +98,12 @@ include("head.inc"); $auth_servers = auth_get_authserver_list(); foreach ($auth_servers as $auth_server): $selected = ""; - if ($auth_server['name'] == $pconfig['authmode']) + if ($auth_server['name'] == $pconfig['authmode']) { $selected = "selected=\"selected\""; + } ?> - + diff --git a/usr/local/www/diag_backup.php b/usr/local/www/diag_backup.php index a83bdab..6c25f02 100644 --- a/usr/local/www/diag_backup.php +++ b/usr/local/www/diag_backup.php @@ -85,7 +85,7 @@ function rrd_data_xml() { function restore_rrddata() { global $config, $g, $rrdtool, $input_errors; - foreach($config['rrddata']['rrddatafile'] as $rrd) { + foreach ($config['rrddata']['rrddatafile'] as $rrd) { if ($rrd['xmldata']) { $rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}"; $xml_file = preg_replace('/\.rrd$/', ".xml", $rrd_file); @@ -101,8 +101,7 @@ function restore_rrddata() { continue; } unlink($xml_file); - } - else if ($rrd['data']) { + } else if ($rrd['data']) { $rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}"; $rrd_fd = fopen($rrd_file, "w"); if (!$rrd_fd) { @@ -137,18 +136,21 @@ function add_base_packages_menu_items() { global $g, $config; $base_packages = explode(",", $g['base_packages']); $modified_config = false; - foreach($base_packages as $bp) { + foreach ($base_packages as $bp) { $basepkg_path = "/usr/local/pkg/{$bp}"; $tmpinfo = pathinfo($basepkg_path, PATHINFO_EXTENSION); - if($tmpinfo['extension'] == "xml" && file_exists($basepkg_path)) { + if ($tmpinfo['extension'] == "xml" && file_exists($basepkg_path)) { $pkg_config = parse_xml_config_pkg($basepkg_path, "packagegui"); - if($pkg_config['menu'] != "") { - if(is_array($pkg_config['menu'])) { - foreach($pkg_config['menu'] as $menu) { - if(is_array($config['installedpackages']['menu'])) - foreach($config['installedpackages']['menu'] as $amenu) - if($amenu['name'] == $menu['name']) + if ($pkg_config['menu'] != "") { + if (is_array($pkg_config['menu'])) { + foreach ($pkg_config['menu'] as $menu) { + if (is_array($config['installedpackages']['menu'])) { + foreach ($config['installedpackages']['menu'] as $amenu) { + if ($amenu['name'] == $menu['name']) { continue; + } + } + } $config['installedpackages']['menu'][] = $menu; $modified_config = true; } @@ -158,7 +160,7 @@ function add_base_packages_menu_items() { } } } - if($modified_config) { + if ($modified_config) { write_config(gettext("Restored base_package menus after configuration restore.")); $config = parse_config(true); } @@ -170,8 +172,9 @@ function remove_bad_chars($string) { function check_and_returnif_section_exists($section) { global $config; - if(is_array($config[$section])) + if (is_array($config[$section])) { return true; + } return false; } @@ -179,41 +182,45 @@ function spit_out_select_items($name, $showall) { global $config; $areas = array("aliases" => gettext("Aliases"), - "captiveportal" => gettext("Captive Portal"), - "voucher" => gettext("Captive Portal Vouchers"), - "dnsmasq" => gettext("DNS Forwarder"), - "unbound" => gettext("DNS Resolver"), - "dhcpd" => gettext("DHCP Server"), - "dhcpdv6" => gettext("DHCPv6 Server"), - "filter" => gettext("Firewall Rules"), - "interfaces" => gettext("Interfaces"), - "ipsec" => gettext("IPSEC"), - "nat" => gettext("NAT"), - "openvpn" => gettext("OpenVPN"), - "installedpackages" => gettext("Package Manager"), - "pptpd" => gettext("PPTP Server"), - "rrddata" => gettext("RRD Data"), - "cron" => gettext("Scheduled Tasks"), - "syslog" => gettext("Syslog"), - "system" => gettext("System"), - "staticroutes" => gettext("Static routes"), - "sysctl" => gettext("System tunables"), - "snmpd" => gettext("SNMP Server"), - "shaper" => gettext("Traffic Shaper"), - "vlans" => gettext("VLANS"), - "wol" => gettext("Wake on LAN") + "captiveportal" => gettext("Captive Portal"), + "voucher" => gettext("Captive Portal Vouchers"), + "dnsmasq" => gettext("DNS Forwarder"), + "unbound" => gettext("DNS Resolver"), + "dhcpd" => gettext("DHCP Server"), + "dhcpdv6" => gettext("DHCPv6 Server"), + "filter" => gettext("Firewall Rules"), + "interfaces" => gettext("Interfaces"), + "ipsec" => gettext("IPSEC"), + "nat" => gettext("NAT"), + "openvpn" => gettext("OpenVPN"), + "installedpackages" => gettext("Package Manager"), + "pptpd" => gettext("PPTP Server"), + "rrddata" => gettext("RRD Data"), + "cron" => gettext("Scheduled Tasks"), + "syslog" => gettext("Syslog"), + "system" => gettext("System"), + "staticroutes" => gettext("Static routes"), + "sysctl" => gettext("System tunables"), + "snmpd" => gettext("SNMP Server"), + "shaper" => gettext("Traffic Shaper"), + "vlans" => gettext("VLANS"), + "wol" => gettext("Wake on LAN") ); $select = "\n"; @@ -246,32 +253,32 @@ if ($_POST['apply']) { if ($_POST) { unset($input_errors); - if (stristr($_POST['Submit'], gettext("Restore configuration"))) + if (stristr($_POST['Submit'], gettext("Restore configuration"))) { $mode = "restore"; - else if (stristr($_POST['Submit'], gettext("Reinstall"))) + } else if (stristr($_POST['Submit'], gettext("Reinstall"))) { $mode = "reinstallpackages"; - else if (stristr($_POST['Submit'], gettext("Clear Package Lock"))) + } else if (stristr($_POST['Submit'], gettext("Clear Package Lock"))) { $mode = "clearpackagelock"; - else if (stristr($_POST['Submit'], gettext("Download"))) + } else if (stristr($_POST['Submit'], gettext("Download"))) { $mode = "download"; - else if (stristr($_POST['Submit'], gettext("Restore version"))) + } else if (stristr($_POST['Submit'], gettext("Restore version"))) { $mode = "restore_ver"; - - if ($_POST["nopackages"] <> "") + } + if ($_POST["nopackages"] <> "") { $options = "nopackages"; - - if ($_POST["ver"] <> "") + } + if ($_POST["ver"] <> "") { $ver2restore = $_POST["ver"]; - + } if ($mode) { - if ($mode == "download") { - if ($_POST['encrypt']) { - if(!$_POST['encrypt_password'] || !$_POST['encrypt_passconf']) + if (!$_POST['encrypt_password'] || !$_POST['encrypt_passconf']) { $input_errors[] = gettext("You must supply and confirm the password for encryption."); - if($_POST['encrypt_password'] != $_POST['encrypt_passconf']) + } + if ($_POST['encrypt_password'] != $_POST['encrypt_passconf']) { $input_errors[] = gettext("The supplied 'Password' and 'Confirm' field values must match."); + } } if (!$input_errors) { @@ -282,8 +289,8 @@ if ($_POST) { $name = "config-{$host}-".date("YmdHis").".xml"; $data = ""; - if($options == "nopackages") { - if(!$_POST['backuparea']) { + if ($options == "nopackages") { + if (!$_POST['backuparea']) { /* backup entire configuration */ $data = file_get_contents("{$g['conf_path']}/config.xml"); } else { @@ -296,7 +303,7 @@ if ($_POST) { exec("sed '//,/<\/installedpackages>/d' {$sfn} > {$sfn}-new"); $data = file_get_contents($sfn . "-new"); } else { - if(!$_POST['backuparea']) { + if (!$_POST['backuparea']) { /* backup entire configuration */ $data = file_get_contents("{$g['conf_path']}/config.xml"); } else if ($_POST['backuparea'] === "rrddata") { @@ -343,21 +350,21 @@ if ($_POST) { } if ($mode == "restore") { - if ($_POST['decrypt']) { - if(!$_POST['decrypt_password'] || !$_POST['decrypt_passconf']) + if (!$_POST['decrypt_password'] || !$_POST['decrypt_passconf']) { $input_errors[] = gettext("You must supply and confirm the password for decryption."); - if($_POST['decrypt_password'] != $_POST['decrypt_passconf']) + } + if ($_POST['decrypt_password'] != $_POST['decrypt_passconf']) { $input_errors[] = gettext("The supplied 'Password' and 'Confirm' field values must match."); + } } if (!$input_errors) { - if (is_uploaded_file($_FILES['conffile']['tmp_name'])) { /* read the file contents */ $data = file_get_contents($_FILES['conffile']['tmp_name']); - if(!$data) { + if (!$data) { log_error(sprintf(gettext("Warning, could not read file %s"), $_FILES['conffile']['tmp_name'])); return 1; } @@ -370,15 +377,15 @@ if ($_POST) { $data = decrypt_data($data, $_POST['decrypt_password']); } - if(stristr($data, "")) { + if (stristr($data, "")) { log_error(gettext("Upgrading m0n0wall configuration to pfsense.")); /* m0n0wall was found in config. convert it. */ $data = str_replace("m0n0wall", "pfsense", $data); $m0n0wall_upgrade = true; } - if($_POST['restorearea']) { + if ($_POST['restorearea']) { /* restore a specific area of the configuration */ - if(!stristr($data, "<" . $_POST['restorearea'] . ">")) { + if (!stristr($data, "<" . $_POST['restorearea'] . ">")) { $input_errors[] = gettext("You have selected to restore an area but we could not locate the correct xml tag."); } else { if (!restore_config_section($_POST['restorearea'], $data)) { @@ -398,7 +405,7 @@ if ($_POST) { } } } else { - if(!stristr($data, "<" . $g['xml_rootobj'] . ">")) { + if (!stristr($data, "<" . $g['xml_rootobj'] . ">")) { $input_errors[] = sprintf(gettext("You have selected to restore the full configuration but we could not locate a %s tag."), $g['xml_rootobj']); } else { /* restore the entire configuration */ @@ -409,8 +416,9 @@ if ($_POST) { mark_subsystem_dirty("restore"); touch("/conf/needs_package_sync"); /* remove cache, we will force a config reboot */ - if(file_exists("{$g['tmp_path']}/config.cache")) + if (file_exists("{$g['tmp_path']}/config.cache")) { unlink("{$g['tmp_path']}/config.cache"); + } $config = parse_config(true); if (file_exists("/boot/loader.conf")) { $loaderconf = file_get_contents("/boot/loader.conf"); @@ -421,7 +429,7 @@ if ($_POST) { unset($loaderconf); } /* extract out rrd items, unset from $config when done */ - if($config['rrddata']) { + if ($config['rrddata']) { restore_rrddata(); unset($config['rrddata']); unlink_if_exists("{$g['tmp_path']}/config.cache"); @@ -430,20 +438,23 @@ if ($_POST) { convert_config(); conf_mount_ro(); } - if($m0n0wall_upgrade == true) { - if($config['system']['gateway'] <> "") + if ($m0n0wall_upgrade == true) { + if ($config['system']['gateway'] <> "") { $config['interfaces']['wan']['gateway'] = $config['system']['gateway']; + } unset($config['shaper']); /* optional if list */ $ifdescrs = get_configured_interface_list(true, true); /* remove special characters from interface descriptions */ - if(is_array($ifdescrs)) - foreach($ifdescrs as $iface) + if (is_array($ifdescrs)) { + foreach ($ifdescrs as $iface) { $config['interfaces'][$iface]['descr'] = remove_bad_chars($config['interfaces'][$iface]['descr']); + } + } /* check for interface names with an alias */ - if(is_array($ifdescrs)) { - foreach($ifdescrs as $iface) { - if(is_alias($config['interfaces'][$iface]['descr'])) { + if (is_array($ifdescrs)) { + foreach ($ifdescrs as $iface) { + if (is_alias($config['interfaces'][$iface]['descr'])) { // Firewall rules $origname = $config['interfaces'][$iface]['descr']; $newname = $config['interfaces'][$iface]['descr'] . "Alias"; @@ -465,58 +476,60 @@ if ($_POST) { $config['system']['version'] = "1.0"; // Deal with descriptions longer than 63 characters for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) { - if(count($config['filter']['rule'][$i]['descr']) > 63) + if (count($config['filter']['rule'][$i]['descr']) > 63) { $config['filter']['rule'][$i]['descr'] = substr($config['filter']['rule'][$i]['descr'], 0, 63); + } } // Move interface from ipsec to enc0 for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) { - if($config['filter']['rule'][$i]['interface'] == "ipsec") + if ($config['filter']['rule'][$i]['interface'] == "ipsec") { $config['filter']['rule'][$i]['interface'] = "enc0"; + } } // Convert icmp types // http://www.openbsd.org/cgi-bin/man.cgi?query=icmp&sektion=4&arch=i386&apropos=0&manpath=OpenBSD+Current for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) { - if($config["filter"]["rule"][$i]['icmptype']) { - switch($config["filter"]["rule"][$i]['icmptype']) { - case "echo": - $config["filter"]["rule"][$i]['icmptype'] = "echoreq"; - break; - case "unreach": - $config["filter"]["rule"][$i]['icmptype'] = "unreach"; - break; - case "echorep": - $config["filter"]["rule"][$i]['icmptype'] = "echorep"; - break; - case "squench": - $config["filter"]["rule"][$i]['icmptype'] = "squench"; - break; - case "redir": - $config["filter"]["rule"][$i]['icmptype'] = "redir"; - break; - case "timex": - $config["filter"]["rule"][$i]['icmptype'] = "timex"; - break; - case "paramprob": - $config["filter"]["rule"][$i]['icmptype'] = "paramprob"; - break; - case "timest": - $config["filter"]["rule"][$i]['icmptype'] = "timereq"; - break; - case "timestrep": - $config["filter"]["rule"][$i]['icmptype'] = "timerep"; - break; - case "inforeq": - $config["filter"]["rule"][$i]['icmptype'] = "inforeq"; - break; - case "inforep": - $config["filter"]["rule"][$i]['icmptype'] = "inforep"; - break; - case "maskreq": - $config["filter"]["rule"][$i]['icmptype'] = "maskreq"; - break; - case "maskrep": - $config["filter"]["rule"][$i]['icmptype'] = "maskrep"; - break; + if ($config["filter"]["rule"][$i]['icmptype']) { + switch ($config["filter"]["rule"][$i]['icmptype']) { + case "echo": + $config["filter"]["rule"][$i]['icmptype'] = "echoreq"; + break; + case "unreach": + $config["filter"]["rule"][$i]['icmptype'] = "unreach"; + break; + case "echorep": + $config["filter"]["rule"][$i]['icmptype'] = "echorep"; + break; + case "squench": + $config["filter"]["rule"][$i]['icmptype'] = "squench"; + break; + case "redir": + $config["filter"]["rule"][$i]['icmptype'] = "redir"; + break; + case "timex": + $config["filter"]["rule"][$i]['icmptype'] = "timex"; + break; + case "paramprob": + $config["filter"]["rule"][$i]['icmptype'] = "paramprob"; + break; + case "timest": + $config["filter"]["rule"][$i]['icmptype'] = "timereq"; + break; + case "timestrep": + $config["filter"]["rule"][$i]['icmptype'] = "timerep"; + break; + case "inforeq": + $config["filter"]["rule"][$i]['icmptype'] = "inforeq"; + break; + case "inforep": + $config["filter"]["rule"][$i]['icmptype'] = "inforep"; + break; + case "maskreq": + $config["filter"]["rule"][$i]['icmptype'] = "maskreq"; + break; + case "maskrep": + $config["filter"]["rule"][$i]['icmptype'] = "maskrep"; + break; } } } @@ -528,8 +541,8 @@ if ($_POST) { $savemsg = gettext("The m0n0wall configuration has been restored and upgraded to pfSense."); mark_subsystem_dirty("restore"); } - if(is_array($config['captiveportal'])) { - foreach($config['captiveportal'] as $cp) { + if (is_array($config['captiveportal'])) { + foreach ($config['captiveportal'] as $cp) { if (isset($cp['enable'])) { /* for some reason ipfw doesn't init correctly except on bootup sequence */ mark_subsystem_dirty("restore"); @@ -538,7 +551,7 @@ if ($_POST) { } } setup_serial_port(); - if(is_interface_mismatch() == true) { + if (is_interface_mismatch() == true) { touch("/var/run/interface_mismatch_reboot_needed"); clear_subsystem_dirty("restore"); convert_config(); @@ -564,7 +577,6 @@ if ($_POST) { } if ($mode == "reinstallpackages") { - header("Location: pkg_mgr_install.php?mode=reinstallall"); exit; } else if ($mode == "clearpackagelock") { @@ -603,18 +615,20 @@ include("head.inc"); function encrypt_change() { - if (!document.iform.encrypt.checked) + if (!document.iform.encrypt.checked) { document.getElementById("encrypt_opts").style.display="none"; - else + } else { document.getElementById("encrypt_opts").style.display=""; + } } function decrypt_change() { - if (!document.iform.decrypt.checked) + if (!document.iform.decrypt.checked) { document.getElementById("decrypt_opts").style.display="none"; - else + } else { document.getElementById("decrypt_opts").style.display=""; + } } function backuparea_change(obj) { @@ -797,7 +811,8 @@ decrypt_change(); diff --git a/usr/local/www/diag_confbak.php b/usr/local/www/diag_confbak.php index bf6c3f2..babdbfe 100644 --- a/usr/local/www/diag_confbak.php +++ b/usr/local/www/diag_confbak.php @@ -1,32 +1,32 @@ @@ -160,32 +163,32 @@ include("head.inc");
- - - - - - - + + + + + - - + : +
+
: + + " /> + + " /> + +
: + +
" /> + + + @@ -236,11 +239,12 @@ include("head.inc"); - - - - - + + + + + - diff --git a/usr/local/www/diag_dump_states_sources.php b/usr/local/www/diag_dump_states_sources.php index ca01d32..e46a316 100644 --- a/usr/local/www/diag_dump_states_sources.php +++ b/usr/local/www/diag_dump_states_sources.php @@ -29,7 +29,7 @@ */ /* - pfSense_BUILDER_BINARIES: /sbin/pfctl + pfSense_BUILDER_BINARIES: /sbin/pfctl pfSense_MODULE: filter */ @@ -43,8 +43,8 @@ require_once("guiconfig.inc"); /* handle AJAX operations */ -if($_GET['action']) { - if($_GET['action'] == "remove") { +if ($_GET['action']) { + if ($_GET['action'] == "remove") { if (is_ipaddr($_GET['srcip']) and is_ipaddr($_GET['dstip'])) { $retval = mwexec("/sbin/pfctl -K " . escapeshellarg($_GET['srcip']) . " -K " . escapeshellarg($_GET['dstip'])); echo htmlentities("|{$_GET['srcip']}|{$_GET['dstip']}|{$retval}|"); @@ -56,10 +56,9 @@ if($_GET['action']) { } /* get our states */ -if($_GET['filter']) { +if ($_GET['filter']) { exec("/sbin/pfctl -s Sources | grep " . escapeshellarg(htmlspecialchars($_GET['filter'])), $sources); -} -else { +} else { exec("/sbin/pfctl -s Sources", $sources); } @@ -92,7 +91,7 @@ include("head.inc"); function removeComplete(req) { var values = req.responseText.split("|"); - if(values[3] != "0") { + if (values[3] != "0") { alert(''); return; } @@ -154,10 +153,11 @@ include("head.inc"); 0) { - foreach($sources as $line) { - if($row >= 1000) +if (count($sources) > 0) { + foreach ($sources as $line) { + if ($row >= 1000) { break; + } // 192.168.20.2 -> 216.252.56.1 ( states 10, connections 0, rate 0.0/0s ) @@ -185,8 +185,7 @@ if(count($sources) > 0) { diff --git a/usr/local/www/diag_ipsec.php b/usr/local/www/diag_ipsec.php index 460a23d..4492b86 100644 --- a/usr/local/www/diag_ipsec.php +++ b/usr/local/www/diag_ipsec.php @@ -72,20 +72,23 @@ if ($_GET['act'] == 'connect') { } } else if ($_GET['act'] == 'ikedisconnect') { if (ctype_digit($_GET['ikeid'])) { - if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) + if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) { mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']) . "[" . escapeshellarg($_GET['ikesaid']) . "]"); - else + } else { mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid'])); + } } } else if ($_GET['act'] == 'childdisconnect') { if (ctype_digit($_GET['ikeid'])) { - if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) + if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) { mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']) . "{" . escapeshellarg($_GET['ikesaid']) . "}"); + } } } -if (!is_array($config['ipsec']['phase1'])) - $config['ipsec']['phase1'] = array(); +if (!is_array($config['ipsec']['phase1'])) { + $config['ipsec']['phase1'] = array(); +} $a_phase1 = &$config['ipsec']['phase1']; @@ -141,12 +144,13 @@ $status = ipsec_smp_dump_status(); $ipsecconnected[$con_id] = $ph1idx = $con_id; } - if (ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ikesa['id'])) + if (ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ikesa['id'])) { $icon = "pass"; - elseif (!isset($config['ipsec']['enable'])) + } elseif (!isset($config['ipsec']['enable'])) { $icon = "block"; - else + } else { $icon = "reject"; + } ?> @@ -312,30 +324,36 @@ $status = ipsec_smp_dump_status(); "; - else + } + } else { echo gettext("Unknown"); + } ?>
  + +
  - : -
-
: - - " /> - - " /> - -
: - -
" /> -
 
diff --git a/usr/local/www/diag_dns.php b/usr/local/www/diag_dns.php index cbce9aa..5ee7927 100644 --- a/usr/local/www/diag_dns.php +++ b/usr/local/www/diag_dns.php @@ -10,11 +10,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -38,7 +38,7 @@ require("guiconfig.inc"); $host = trim($_REQUEST['host'], " \t\n\r\0\x0B[];\"'"); $host_esc = escapeshellarg($host); -/* If this section of config.xml has not been populated yet we need to set it up +/* If this section of config.xml has not been populated yet we need to set it up */ if (!is_array($config['aliases']['alias'])) { $config['aliases']['alias'] = array(); @@ -48,43 +48,47 @@ $a_aliases = &$config['aliases']['alias']; $aliasname = str_replace(array(".","-"), "_", $host); $alias_exists = false; $counter=0; -foreach($a_aliases as $a) { - if($a['name'] == $aliasname) { +foreach ($a_aliases as $a) { + if ($a['name'] == $aliasname) { $alias_exists = true; $id=$counter; } $counter++; } -if(isset($_POST['create_alias']) && (is_hostname($host) || is_ipaddr($host))) { - if($_POST['override']) +if (isset($_POST['create_alias']) && (is_hostname($host) || is_ipaddr($host))) { + if ($_POST['override']) { $override = true; + } $resolved = gethostbyname($host); $type = "hostname"; - if($resolved) { + if ($resolved) { $resolved = array(); exec("/usr/bin/drill {$host_esc} A | /usr/bin/grep {$host_esc} | /usr/bin/grep -v ';' | /usr/bin/awk '{ print $5 }'", $resolved); $isfirst = true; - foreach($resolved as $re) { - if($re <> "") { - if(!$isfirst) + foreach ($resolved as $re) { + if ($re <> "") { + if (!$isfirst) { $addresses .= " "; + } $addresses .= rtrim($re) . "/32"; $isfirst = false; } } $newalias = array(); - if($override) + if ($override) { $alias_exists = false; - if($alias_exists == false) { + } + if ($alias_exists == false) { $newalias['name'] = $aliasname; $newalias['type'] = "network"; $newalias['address'] = $addresses; $newalias['descr'] = "Created from Diagnostics-> DNS Lookup"; - if($override) + if ($override) { $a_aliases[$id] = $newalias; - else + } else { $a_aliases[] = $newalias; + } write_config(); $createdalias = true; } @@ -98,7 +102,7 @@ if ($_POST) { $reqdfieldsn = explode(",", "Host"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors); - + if (!is_hostname($host) && !is_ipaddr($host)) { $input_errors[] = gettext("Host must be a valid hostname or IP address."); } else { @@ -108,8 +112,9 @@ if ($_POST) { exec("/usr/bin/grep nameserver /etc/resolv.conf | /usr/bin/cut -f2 -d' '", $dns_servers); foreach ($dns_servers as $dns_server) { $query_time = exec("/usr/bin/drill {$host_esc} " . escapeshellarg("@" . trim($dns_server)) . " | /usr/bin/grep Query | /usr/bin/cut -d':' -f2"); - if($query_time == "") + if ($query_time == "") { $query_time = gettext("No response"); + } $new_qt = array(); $new_qt['dns_server'] = $dns_server; $new_qt['query_time'] = $query_time; @@ -127,18 +132,20 @@ if ($_POST) { $type = "ip"; $resolved = gethostbyaddr($host); $ipaddr = $host; - if ($host != $resolved) + if ($host != $resolved) { $hostname = $resolved; + } } elseif (is_hostname($host)) { $type = "hostname"; $resolved = gethostbyname($host); - if($resolved) { + if ($resolved) { $resolved = array(); exec("/usr/bin/drill {$host_esc} A | /usr/bin/grep {$host_esc} | /usr/bin/grep -v ';' | /usr/bin/awk '{ print $5 }'", $resolved); } $hostname = $host; - if ($host != $resolved) + if ($host != $resolved) { $ipaddr = $resolved[0]; + } } if ($host == $resolved) { @@ -147,7 +154,7 @@ if ($_POST) { } } -if( ($_POST['host']) && ($_POST['dialog_output']) ) { +if (($_POST['host']) && ($_POST['dialog_output'])) { display_host_results ($host,$resolved,$dns_speeds); exit; } @@ -175,18 +182,18 @@ include("head.inc"); ?> - - + @@ -276,7 +284,7 @@ include("head.inc"); ?>
+
- + - +
- +
@@ -196,28 +203,28 @@ include("head.inc"); ?> "") { + if (is_array($resolved)) { + foreach ($resolved as $hostitem) { + if ($hostitem <> "") { echo $hostitem . "
"; $found++; } } } else { - echo $resolved; - } - if($found > 0) { ?> + echo $resolved; + } + if ($found > 0) { ?>
- + An alias already exists for the hostname .
- + - + Alias created with name - @@ -226,7 +233,7 @@ include("head.inc"); ?>
@@ -240,8 +247,8 @@ include("head.inc"); ?>
@@ -252,7 +259,8 @@ include("head.inc"); ?>
 
  - " /> + " />
diff --git a/usr/local/www/diag_dump_states.php b/usr/local/www/diag_dump_states.php index f41a4fd..1cc844a 100755 --- a/usr/local/www/diag_dump_states.php +++ b/usr/local/www/diag_dump_states.php @@ -44,7 +44,7 @@ require_once("guiconfig.inc"); require_once("interfaces.inc"); /* handle AJAX operations */ -if(isset($_POST['action']) && $_POST['action'] == "remove") { +if (isset($_POST['action']) && $_POST['action'] == "remove") { if (isset($_POST['srcip']) && isset($_POST['dstip']) && is_ipaddr($_POST['srcip']) && is_ipaddr($_POST['dstip'])) { $retval = pfSense_kill_states($_POST['srcip'], $_POST['dstip']); echo htmlentities("|{$_POST['srcip']}|{$_POST['dstip']}|0|"); @@ -104,7 +104,7 @@ include("head.inc"); function removeComplete(req) { var values = req.responseText.split("|"); - if(values[3] != "0") { + if (values[3] != "0") { alert(''); return; } @@ -122,8 +122,9 @@ include("head.inc"); @@ -180,8 +181,9 @@ $row = 0; $grepline = (isset($_POST['filter'])) ? "| /usr/bin/egrep " . escapeshellarg(htmlspecialchars($_POST['filter'])) : ""; $fd = popen("/sbin/pfctl -s state {$grepline}", "r" ); while ($line = chop(fgets($fd))) { - if($row >= 10000) + if ($row >= 10000) { break; + } $line_split = preg_split("/\s+/", $line); @@ -202,16 +204,16 @@ while ($line = chop(fgets($fd))) { ?>
- - + +
" . gettext("No source tracking entries were found.") . " diff --git a/usr/local/www/diag_gmirror.php b/usr/local/www/diag_gmirror.php index adb61f5..f1ceef2 100644 --- a/usr/local/www/diag_gmirror.php +++ b/usr/local/www/diag_gmirror.php @@ -8,11 +8,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INClUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -53,7 +53,7 @@ include("head.inc"); - gettext("Forget all formerly connected consumers"), "clear" => gettext("Remove metadata from disk"), @@ -77,41 +77,51 @@ if ($_POST) { } $input_errors = ""; - if (($_POST['action'] != "clear") && !is_valid_mirror($_POST['mirror'])) + if (($_POST['action'] != "clear") && !is_valid_mirror($_POST['mirror'])) { $input_errors[] = gettext("You must supply a valid mirror name."); + } - if (!empty($_POST['consumer']) && !is_valid_consumer($_POST['consumer'])) + if (!empty($_POST['consumer']) && !is_valid_consumer($_POST['consumer'])) { $input_errors[] = gettext("You must supply a valid consumer name"); + } /* Additional action-specific validation that hasn't already been tested */ switch ($_POST['action']) { case "insert": - if (!is_consumer_unused($_POST['consumer'])) + if (!is_consumer_unused($_POST['consumer'])) { $input_errors[] = gettext("Consumer is already in use and cannot be inserted. Remove consumer from existing mirror first."); - if (gmirror_consumer_has_metadata($_POST['consumer'])) + } + if (gmirror_consumer_has_metadata($_POST['consumer'])) { $input_errors[] = gettext("Consumer has metadata from an existing mirror. Clear metadata before inserting consumer."); + } $mstat = gmirror_get_status_single($_POST['mirror']); - if (strtoupper($mstat) != "COMPLETE") + if (strtoupper($mstat) != "COMPLETE") { $input_errors[] = gettext("Mirror is not in a COMPLETE state, cannot insert consumer. Forget disconnected disks or wait for rebuild to finish."); + } break; case "clear": - if (!is_consumer_unused($_POST['consumer'])) + if (!is_consumer_unused($_POST['consumer'])) { $input_errors[] = gettext("Consumer is in use and cannot be cleared. Deactivate disk first."); - if (!gmirror_consumer_has_metadata($_POST['consumer'])) + } + if (!gmirror_consumer_has_metadata($_POST['consumer'])) { $input_errors[] = gettext("Consumer has no metadata to clear."); + } break; case "activate": - if (is_consumer_in_mirror($_POST['consumer'], $_POST['mirror'])) + if (is_consumer_in_mirror($_POST['consumer'], $_POST['mirror'])) { $input_errors[] = gettext("Consumer is already present on specified mirror."); - if (!gmirror_consumer_has_metadata($_POST['consumer'])) + } + if (!gmirror_consumer_has_metadata($_POST['consumer'])) { $input_errors[] = gettext("Consumer has no metadata and cannot be reactivated."); - + } + break; case "remove": case "deactivate": case "rebuild": - if (!is_consumer_in_mirror($_POST['consumer'], $_POST['mirror'])) + if (!is_consumer_in_mirror($_POST['consumer'], $_POST['mirror'])) { $input_errors[] = gettext("Consumer must be present on the specified mirror."); + } break; } @@ -156,14 +166,17 @@ $mirror_list = gmirror_get_mirrors(); $unused_disks = gmirror_get_disks(); $unused_consumers = array(); foreach ($unused_disks as $disk) { - if (is_consumer_unused($disk)) + if (is_consumer_unused($disk)) { $unused_consumers = array_merge($unused_consumers, gmirror_get_all_unused_consumer_sizes_on_disk($disk)); + } } -if ($input_errors) +if ($input_errors) { print_input_errors($input_errors); -if ($_GET["error"] && ($_GET["error"] != 0)) +} +if ($_GET["error"] && ($_GET["error"] != 0)) { print_info_box(gettext("There was an error performing the chosen mirror operation. Check the System Log for details.")); +} ?> @@ -181,152 +194,152 @@ if ($_GET["error"] && ($_GET["error"] != 0))

- + - + - + - + - + - + - + - + - +
  - : + :
-
: - " /> - -
: - " /> - - -
: - " /> - +
: + " /> + +
: + " /> + + +
: + " /> +
-
" /> +
" />
- 0): ?> + 0): ?> - - - + + + - $name): + $name): $components = count($name["components"]); ?> - - - 1): + 1): $morecomponents = array_slice($name["components"], 1); ?> - + - - - - - - + + + + + +
- -
Size: +
+ +
Size:
- - -
[] - +
+ + +
[] +
- - + +
- 1)): ?> - [] - [] - [] - + 1)): ?> + [] + [] + [] +
- - + +
- 1)): ?> - [] - [] - [] - + 1)): ?> + [] + [] + [] +
-
+
- 0): ?> + 0): ?> - - - + + + - + - + - - - - + + + +
- + - - [] -
[] - - &mirror=">[] +
[] + + - $mirror_size): ?> - - - - + $mirror_size): ?> + + + +
-
+
 

@@ -156,71 +160,79 @@ $status = ipsec_smp_dump_status(); ' . gettext('Port: ') . htmlspecialchars($ikesa['local']['port']); - else + } else { echo gettext("Unknown"); - if ($ikesa['local']['port'] == '4500') + } + if ($ikesa['local']['port'] == '4500') { echo " NAT-T"; + } } ?> {$identity}"; } else { - if (empty($identity)) + if (empty($identity)) { echo gettext("Unknown"); - else + } else { echo $identity; + } } } ?> ' . gettext('Port: ') . htmlspecialchars($ikesa['remote']['port']); - else + } else { echo gettext("Unknown"); - if ($ikesa['remote']['port'] == '4500') + } + if ($ikesa['remote']['port'] == '4500') { echo " NAT-T"; + } } ?> " . gettext("Remote: ") . htmlspecialchars($childsa['remote']['spi']); + } ?> "; - else + } + } else { echo gettext("Unknown"); + } ?> @@ -407,11 +425,13 @@ $status = ipsec_smp_dump_status(); $rgmap = array(); foreach ($a_phase1 as $ph1ent): - if (isset($ph1ent['disabled'])) + if (isset($ph1ent['disabled'])) { continue; + } $rgmap[$ph1ent['remote-gateway']] = $ph1ent['remote-gateway']; - if ($ipsecconnected[$ph1ent['ikeid']]) + if ($ipsecconnected[$ph1ent['ikeid']]) { continue; + } ?>
@@ -422,37 +442,41 @@ $status = ipsec_smp_dump_status(); diff --git a/usr/local/www/diag_ipsec_leases.php b/usr/local/www/diag_ipsec_leases.php index 173d516..60e9846 100644 --- a/usr/local/www/diag_ipsec_leases.php +++ b/usr/local/www/diag_ipsec_leases.php @@ -71,7 +71,7 @@ $mobile = ipsec_dump_mobile();
- +
diff --git a/usr/local/www/diag_ipsec_xml.php b/usr/local/www/diag_ipsec_xml.php index 2c76225..a219da9 100644 --- a/usr/local/www/diag_ipsec_xml.php +++ b/usr/local/www/diag_ipsec_xml.php @@ -44,8 +44,9 @@ global $g; require("guiconfig.inc"); require("ipsec.inc"); -if (!is_array($config['ipsec']['phase2'])) - $config['ipsec']['phase2'] = array(); +if (!is_array($config['ipsec']['phase2'])) { + $config['ipsec']['phase2'] = array(); +} $ipsec_status = array(); @@ -58,12 +59,13 @@ if (is_array($status['query']) && $status['query']['ikesalist'] && $status['quer ipsec_lookup_phase1($ph2ent,$ph1ent); $tunnel = array(); if (!isset($ph2ent['disabled']) && !isset($ph1ent['disabled'])) { - if(ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ph1ent['ikeid'])) + if(ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ph1ent['ikeid'])) { $tunnel['state'] = "up"; - elseif(!isset($config['ipsec']['enable'])) + } elseif(!isset($config['ipsec']['enable'])) { $tunnel['state'] = "disabled"; - else + } else { $tunnel['state'] = "down"; + } $tunnel['src'] = ipsec_get_phase1_src($ph1ent); $tunnel['endpoint'] = $ph1ent['remote-gateway']; diff --git a/usr/local/www/diag_limiter_info.php b/usr/local/www/diag_limiter_info.php index c3f8045..66574ed 100644 --- a/usr/local/www/diag_limiter_info.php +++ b/usr/local/www/diag_limiter_info.php @@ -1,31 +1,31 @@
"; print_info_box($savemsg); - echo "
"; + echo ""; } - if ($input_errors) + if ($input_errors) { print_input_errors($input_errors); + } ?> - +
+
@@ -110,7 +112,7 @@ include("head.inc");
-
diff --git a/usr/local/www/diag_logs.php b/usr/local/www/diag_logs.php index cb76724..6520999 100755 --- a/usr/local/www/diag_logs.php +++ b/usr/local/www/diag_logs.php @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: system */ @@ -48,20 +48,25 @@ require("guiconfig.inc"); $system_logfile = "{$g['varlog_path']}/system.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($system_logfile); +} -if ($_GET['filtertext']) +if ($_GET['filtertext']) { $filtertext = htmlspecialchars($_GET['filtertext']); +} -if ($_POST['filtertext']) +if ($_POST['filtertext']) { $filtertext = htmlspecialchars($_POST['filtertext']); +} -if ($filtertext) +if ($filtertext) { $filtertextmeta="?filtertext=$filtertext"; +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("General")); include("head.inc"); @@ -110,26 +115,27 @@ include("head.inc");
- " /> + " />
- - " /> + + " />
-
+
diff --git a/usr/local/www/diag_logs_auth.php b/usr/local/www/diag_logs_auth.php index ce296bc..230fadd 100644 --- a/usr/local/www/diag_logs_auth.php +++ b/usr/local/www/diag_logs_auth.php @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: captiveportal */ @@ -48,11 +48,13 @@ require("guiconfig.inc"); $portal_logfile = "{$g['varlog_path']}/portalauth.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($portal_logfile); +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Portal Auth")); $shortcut_section = "captiveportal"; @@ -81,7 +83,7 @@ include("head.inc"); ?> - +
diff --git a/usr/local/www/diag_logs_dhcp.php b/usr/local/www/diag_logs_dhcp.php index 5cfa4d6..c60af86 100644 --- a/usr/local/www/diag_logs_dhcp.php +++ b/usr/local/www/diag_logs_dhcp.php @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: dhcpserver */ @@ -48,8 +48,9 @@ require("guiconfig.inc"); $dhcpd_logfile = "{$g['varlog_path']}/dhcpd.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} if ($_POST['clear']) { clear_log_file($dhcpd_logfile); @@ -84,7 +85,7 @@ include("head.inc"); ?> - "; } @@ -125,14 +126,16 @@ function pie_block($summary, $stat, $num) { for ($i=0; $i < $num; $i++) { if ($k[$i]) { print " { data: d{$stat}{$i}, label: \"{$k[$i]}\"}"; - if (!(($i == ($numentries - 1)) && ($leftover <= 0))) + if (!(($i == ($numentries - 1)) && ($leftover <= 0))) { print ",\n"; - else + } else { print "\n"; + } } } - if ($leftover > 0) + if ($leftover > 0) { print " { data: d{$stat}{$i}, label: \"Other\"}\n"; + } print " ],\n"; print " {\n"; print " pies: {show: true, autoScale: true},\n"; @@ -150,18 +153,21 @@ function pie_block($summary, $stat, $num) { foreach ($filterlog as $fe) { $specialfields = array('srcport', 'dstport'); foreach (array_keys($fields) as $field) { - if (!in_array($field, $specialfields)) + if (!in_array($field, $specialfields)) { $summary[$field][$fe[$field]]++; + } } /* Handle some special cases */ - if ($fe['srcport']) + if ($fe['srcport']) { $summary['srcport'][$fe['proto'].'/'.$fe['srcport']]++; - else + } else { $summary['srcport'][$fe['srcport']]++; - if ($fe['dstport']) + } + if ($fe['dstport']) { $summary['dstport'][$fe['proto'].'/'.$fe['dstport']]++; - else + } else { $summary['dstport'][$fe['dstport']]++; + } } include("head.inc"); ?> @@ -199,7 +205,7 @@ include("head.inc"); ?> $tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php"); display_top_tabs($tab_array); ?> - + - + + -
+
diff --git a/usr/local/www/diag_logs_filter.php b/usr/local/www/diag_logs_filter.php index 7dac52b..f81b0f5 100644 --- a/usr/local/www/diag_logs_filter.php +++ b/usr/local/www/diag_logs_filter.php @@ -2,7 +2,7 @@ /* $Id$ */ /* diag_logs_filter.php - part of pfSense + part of pfSense Copyright (C) 2004-2009 Scott Ullrich Copyright (C) 2013-2015 Electric Sheep Fencing, LP originally based on m0n0wall (http://m0n0.ch/wall) @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: filter */ @@ -51,12 +51,13 @@ require_once("filter_log.inc"); if (isset($_POST['resolve'])) { $ip = strtolower($_POST['resolve']); $res = (is_ipaddr($ip) ? gethostbyaddr($ip) : ''); - - if ($res && $res != $ip) + + if ($res && $res != $ip) { $response = array('resolve_ip' => $ip, 'resolve_text' => $res); - else + } else { $response = array('resolve_ip' => $ip, 'resolve_text' => gettext("Cannot resolve")); - + } + echo json_encode(str_replace("\\","\\\\", $response)); // single escape chars can break JSON decode exit; } @@ -64,15 +65,17 @@ if (isset($_POST['resolve'])) { function getGETPOSTsettingvalue($settingname, $default) { $settingvalue = $default; - if($_GET[$settingname]) + if ($_GET[$settingname]) { $settingvalue = $_GET[$settingname]; - if($_POST[$settingname]) + } + if ($_POST[$settingname]) { $settingvalue = $_POST[$settingname]; + } return $settingvalue; } $rulenum = getGETPOSTsettingvalue('getrulenum', null); -if($rulenum) { +if ($rulenum) { list($rulenum, $tracker, $type) = explode(',', $rulenum); $rule = find_rule_by_number($rulenum, $tracker, $type); echo gettext("The rule that triggered this action is") . ":\n\n{$rule}"; @@ -111,14 +114,17 @@ $filter_logfile = "{$g['varlog_path']}/filter.log"; $nentries = $config['syslog']['nentries']; # Override Display Quantity -if ($filterlogentries_qty) +if ($filterlogentries_qty) { $nentries = $filterlogentries_qty; +} -if (!$nentries || !is_numeric($nentries)) +if (!$nentries || !is_numeric($nentries)) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($filter_logfile); +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Firewall")); $shortcut_section = "firewall"; @@ -145,7 +151,7 @@ include("head.inc"); $tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php"); display_top_tabs($tab_array); ?> - + - + - @@ -444,18 +467,18 @@ function resolve_ip_callback(transport) { var response = jQuery.parseJSON(transport.responseText); var resolve_class = htmlspecialchars(response.resolve_ip.replace(/[.:]/g, '-')); var resolve_text = '
' + htmlspecialchars(response.resolve_text) + '<\/small>'; - + jQuery('span.RESOLVE-' + resolve_class).html(resolve_text); jQuery('img.ICON-' + resolve_class).removeAttr('title'); jQuery('img.ICON-' + resolve_class).removeAttr('alt'); jQuery('img.ICON-' + resolve_class).attr('src', '/themes//images/icons/icon_log_d.gif'); - jQuery('img.ICON-' + resolve_class).prop('onclick', null); + jQuery('img.ICON-' + resolve_class).prop('onclick', null); // jQuery cautions that "removeAttr('onclick')" fails in some versions of IE } // From http://stackoverflow.com/questions/5499078/fastest-method-to-escape-html-tags-as-html-entities function htmlspecialchars(str) { - return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); + return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); } //]]> diff --git a/usr/local/www/diag_logs_filter_dynamic.php b/usr/local/www/diag_logs_filter_dynamic.php index c9fe2e3..02307a0 100755 --- a/usr/local/www/diag_logs_filter_dynamic.php +++ b/usr/local/www/diag_logs_filter_dynamic.php @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: filter */ @@ -54,8 +54,9 @@ $nentries = 50; /* AJAX related routines */ handle_ajax($nentries, $nentries + 20); -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($filter_logfile); +} $filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100); @@ -76,10 +77,11 @@ include("head.inc"); var isPaused = false; var nentries = ; /* Called by the AJAX updater */ function format_log_line(row) { @@ -91,14 +93,16 @@ include("head.inc"); dstIP = row[5]; } - if ( row[4] == '' ) + if ( row[4] == '' ) { srcPort = ''; - else + } else { srcPort = ':' + row[4]; - if ( row[6] == '' ) + } + if ( row[6] == '' ) { dstPort = ''; - else + } else { dstPort = ':' + row[6]; + } var line = '
' + '' + @@ -128,7 +132,7 @@ include("head.inc"); $tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php"); display_top_tabs($tab_array); ?> - + - + + - +
+
" summary="main area"> + @@ -329,88 +346,94 @@ include("head.inc"); + foreach ($filterlog as $filterent): + $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; + $rowIndex++;?> - - - + + - ".find_rule_by_number_buffer($filterent['rulenum'],$filterent['tracker'],$filterent['act']).""); - - $int = strtolower($filterent['interface']); - $proto = strtolower($filterent['proto']); - if($filterent['version'] == '6') { - $ipproto = "inet6"; - $filterent['srcip'] = "[{$filterent['srcip']}]"; - $filterent['dstip'] = "[{$filterent['dstip']}]"; - } else { - $ipproto = "inet"; - } - - $srcstr = $filterent['srcip'] . get_port_with_service($filterent['srcport'], $proto); - $src_htmlclass = str_replace(array('.', ':'), '-', $filterent['srcip']); - $dststr = $filterent['dstip'] . get_port_with_service($filterent['dstport'], $proto); - $dst_htmlclass = str_replace(array('.', ':'), '-', $filterent['dstip']); - ?> - - - ".find_rule_by_number_buffer($filterent['rulenum'],$filterent['tracker'],$filterent['act']).""); + } + + $int = strtolower($filterent['interface']); + $proto = strtolower($filterent['proto']); + if ($filterent['version'] == '6') { + $ipproto = "inet6"; + $filterent['srcip'] = "[{$filterent['srcip']}]"; + $filterent['dstip'] = "[{$filterent['dstip']}]"; + } else { + $ipproto = "inet"; + } + + $srcstr = $filterent['srcip'] . get_port_with_service($filterent['srcport'], $proto); + $src_htmlclass = str_replace(array('.', ':'), '-', $filterent['srcip']); + $dststr = $filterent['dstip'] . get_port_with_service($filterent['dstport'], $proto); + $dst_htmlclass = str_replace(array('.', ':'), '-', $filterent['dstip']); + ?> + + + - + } + ?> + - + - + - - - - + + + + } + ?> - - - + + +
">
- @@ -238,30 +244,36 @@ include("head.inc");
" class="listtopic"> - + } + printf(gettext("Max(%s)"),$nentries); + ?>
-
- ', outputrule);"> - <?php echo $filterent['act'] .'/'. $filterent['tracker'];?> -
+ +
+ ', outputrule);"> + <?php echo $filterent['act'] .'/'. $filterent['tracker'];?> +
Direction=OUT - ');" title="" class="ICON-" border="0" src="/themes//images/icons/icon_log.gif" alt="Icon Reverse Resolve with DNS"/> - " title="" onclick="return confirm('')"> - Icon Easy Rule: Add to Block List - ';?> - - ');" title="" class="ICON-" border="0" src="/themes//images/icons/icon_log.gif" alt="Icon Reverse Resolve with DNS"/> - " title="" onclick="return confirm('')"> - Icon Easy Rule: Pass this traffic - ';?> - + ');" title="" class="ICON-" border="0" src="/themes//images/icons/icon_log.gif" alt="Icon Reverse Resolve with DNS"/> + " title="" onclick="return confirm('')"> + Icon Easy Rule: Add to Block List + ';?> + + ');" title="" class="ICON-" border="0" src="/themes//images/icons/icon_log.gif" alt="Icon Reverse Resolve with DNS"/> + " title="" onclick="return confirm('')"> + Icon Easy Rule: Pass this traffic + ';?> +
- +
-
+
- - " /> - -
+
+ " /> +
+
' + row[0] + '' + row[1] + '
-
+
@@ -172,15 +176,17 @@ include("head.inc"); $dstIP = htmlspecialchars($filterent['dstip']); } - if ($filterent['srcport']) + if ($filterent['srcport']) { $srcPort = ":" . htmlspecialchars($filterent['srcport']); - else + } else { $srcPort = ""; + } - if ($filterent['dstport']) + if ($filterent['dstport']) { $dstPort = ":" . htmlspecialchars($filterent['dstport']); - else + } else { $dstPort = ""; + } ?> @@ -202,7 +209,7 @@ include("head.inc");
@@ -193,8 +199,9 @@ include("head.inc");
-

: F - FIN, S - SYN, A or . - ACK, R - RST, P - PSH, U - URG, E - ECE, C - CWR

diff --git a/usr/local/www/diag_logs_filter_summary.php b/usr/local/www/diag_logs_filter_summary.php index 0abe6d7..e4150a0 100644 --- a/usr/local/www/diag_logs_filter_summary.php +++ b/usr/local/www/diag_logs_filter_summary.php @@ -9,11 +9,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -27,8 +27,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* - pfSense_BUILDER_BINARIES: +/* + pfSense_BUILDER_BINARIES: pfSense_MODULE: filter */ @@ -60,10 +60,10 @@ foreach (array_keys($fields) as $f) { $totals = array(); function cmp($a, $b) { - if ($a == $b) { - return 0; - } - return ($a < $b) ? 1 : -1; + if ($a == $b) { + return 0; + } + return ($a < $b) ? 1 : -1; } function stat_block($summary, $stat, $num) { @@ -84,8 +84,9 @@ function stat_block($summary, $stat, $num) { } elseif (substr_count($outstr, '/') == 1) { list($proto, $port) = explode('/', $outstr); $service = getservbyport($port, strtolower($proto)); - if ($service) + if ($service) { $outstr .= ": {$service}"; + } } print "
{$outstr}{$summary[$stat][$k[$i]]}
$tab_array[] = array(gettext("Summary View"), true, "/diag_logs_filter_summary.php"); display_top_tabs($tab_array); ?> -
+
- +
@@ -220,7 +226,7 @@ include("head.inc"); ?>
"; stat_block($summary, $field , $entriesperblock); diff --git a/usr/local/www/diag_logs_gateways.php b/usr/local/www/diag_logs_gateways.php index bd3f0a7..2991f2e 100755 --- a/usr/local/www/diag_logs_gateways.php +++ b/usr/local/www/diag_logs_gateways.php @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: system */ @@ -49,20 +49,25 @@ require("guiconfig.inc"); $system_logfile = "{$g['varlog_path']}/gateways.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($system_logfile); +} -if ($_GET['filtertext']) +if ($_GET['filtertext']) { $filtertext = htmlspecialchars($_GET['filtertext']); +} -if ($_POST['filtertext']) +if ($_POST['filtertext']) { $filtertext = htmlspecialchars($_POST['filtertext']); +} -if ($filtertext) +if ($filtertext) { $filtertextmeta="?filtertext=$filtertext"; +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Gateways")); $shortcut_section = "gateways"; @@ -92,7 +97,8 @@ include("head.inc"); ?>
+
- " /> + " />
- - " /> + + " />
-
+
diff --git a/usr/local/www/diag_logs_ipsec.php b/usr/local/www/diag_logs_ipsec.php index 7966918..ee932fd 100644 --- a/usr/local/www/diag_logs_ipsec.php +++ b/usr/local/www/diag_logs_ipsec.php @@ -32,8 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* - pfSense_BUILDER_BINARIES: /sbin/ifconfig /usr/bin/awk +/* + pfSense_BUILDER_BINARIES: /sbin/ifconfig /usr/bin/awk pfSense_MODULE: ipsec */ @@ -50,11 +50,13 @@ require("ipsec.inc"); $ipsec_logfile = "{$g['varlog_path']}/ipsec.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($ipsec_logfile); +} $ipsec_logarr = return_clog($ipsec_logfile, $nentries); @@ -66,7 +68,7 @@ include("head.inc"); - + + - \n"; echo "\n"; - if ($llent[0] == "login") + if ($llent[0] == "login") { echo "\n"; - else + } else { echo "\n"; + } echo "\n"; echo "\n"; @@ -163,7 +168,7 @@ include("head.inc"); ?> - @@ -280,6 +284,6 @@ if ($savemsg) // Clear the loading indicator echo ""; +echo ""; ?> diff --git a/usr/local/www/diag_ndp.php b/usr/local/www/diag_ndp.php index 03f80be..f2fcfd5 100644 --- a/usr/local/www/diag_ndp.php +++ b/usr/local/www/diag_ndp.php @@ -14,11 +14,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -60,8 +60,8 @@ foreach ($ifdescrs as $key =>$interface) { $hwif[$config['interfaces'][$key]['if']] = $interface; } -/* Array ( [0] => Neighbor [1] => Linklayer [2] => Address -[3] => Netif [4] => Expire [5] => S +/* Array ( [0] => Neighbor [1] => Linklayer [2] => Address +[3] => Netif [4] => Expire [5] => S [6] => Flags ) */ $data = array(); array_shift($rawdata); @@ -77,13 +77,14 @@ foreach ($rawdata as $line) { /* FIXME: Not ipv6 compatible dns resolving. PHP needs fixing */ function _getHostName($mac,$ip) -{ - if(is_ipaddr($ip)) { +{ + if (is_ipaddr($ip)) { list($ip, $scope) = explode("%", $ip); - if(gethostbyaddr($ip) <> "" and gethostbyaddr($ip) <> $ip) + if (gethostbyaddr($ip) <> "" and gethostbyaddr($ip) <> $ip) { return gethostbyaddr($ip); - else + } else { return ""; + } } } @@ -92,12 +93,13 @@ function _getHostName($mac,$ip) // resolvable addresses will appear last in the list. foreach ($data as &$entry) { $dns = trim(_getHostName($entry['mac'], $entry['ipv6'])); - if(trim($dns)) + if (trim($dns)) { $entry['dnsresolve'] = "$dns"; - else + } else { $entry['dnsresolve'] = "Z_ "; + } } - + // Sort the data alpha first $data = msort($data, "dnsresolve"); @@ -121,7 +123,9 @@ include("head.inc"); @@ -144,7 +148,9 @@ ob_implicit_flush(1); $mac=trim($entry['mac']); $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); print $mac; - if(isset($mac_man[$mac_hi])){ print "
{$mac_man[$mac_hi]}"; } + if (isset($mac_man[$mac_hi])) { + print "
{$mac_man[$mac_hi]}"; + } ?> diff --git a/usr/local/www/diag_packet_capture.php b/usr/local/www/diag_packet_capture.php index 73fb7c4..71ed928 100644 --- a/usr/local/www/diag_packet_capture.php +++ b/usr/local/www/diag_packet_capture.php @@ -1,6 +1,6 @@ 0) ? get_host_boolean($value, $host) : ""; - if (is_ipaddr($host)) + if (is_ipaddr($host)) { return "{$andor}host {$not}" . $host; - elseif (is_subnet($host)) + } elseif (is_subnet($host)) { return "{$andor}net {$not}" . $host; - else + } else { return ""; + } } -if ($_POST['downloadbtn'] == gettext("Download Capture")) +if ($_POST['downloadbtn'] == gettext("Download Capture")) { $nocsrf = true; +} $pgtitle = array(gettext("Diagnostics"), gettext("Packet Capture")); require_once("guiconfig.inc"); @@ -101,8 +103,9 @@ $protos = array('icmp', 'icmp6', 'tcp', 'udp', 'arp', 'carp', 'esp', $input_errors = array(); $interfaces = get_configured_interface_with_descr(); -if (isset($config['ipsec']['enable'])) +if (isset($config['ipsec']['enable'])) { $interfaces['ipsec'] = "IPsec"; +} foreach (array('server', 'client') as $mode) { if (is_array($config['openvpn']["openvpn-{$mode}"])) { foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) { @@ -132,7 +135,7 @@ if ($_POST) { if ($proto !== "" && !in_array(strip_not($proto), $protos)) { $input_errors[] = gettext("Invalid protocol."); } - + if ($host != "") { $host_string = str_replace(array(" ", "|", ","), array("", "#|", "#+"), $host); if (strpos($host_string, '#') === false) { @@ -191,8 +194,9 @@ if ($_POST) { $action = gettext("Start"); //delete previous packet capture if it exists - if (file_exists($fp.$fn)) + if (file_exists($fp.$fn)) { unlink ($fp.$fn); + } } elseif ($_POST['stopbtn']!= "") { $action = gettext("Stop"); @@ -243,8 +247,6 @@ include("fbegin.inc"); @@ -343,7 +345,7 @@ include("fbegin.inc"); @@ -356,14 +358,15 @@ include("fbegin.inc"); /* check to see if packet capture tcpdump is already running */ $processcheck = (trim(shell_exec("/bin/ps axw -O pid= | /usr/bin/grep tcpdump | /usr/bin/grep {$fn} | /usr/bin/egrep -v '(pflog|grep)'"))); - if ($processcheck != "") + if ($processcheck != "") { $processisrunning = true; - else + } else { $processisrunning = false; + } - if (($action == gettext("Stop") or $action == "") and $processisrunning != true) + if (($action == gettext("Stop") or $action == "") and $processisrunning != true) { echo " "; - else { + } else { echo " "; } if (file_exists($fp.$fn) and $processisrunning != true) { @@ -381,32 +384,37 @@ include("fbegin.inc");
-
+
- + - + \n"; diff --git a/usr/local/www/diag_logs_ntpd.php b/usr/local/www/diag_logs_ntpd.php index 0754dcb..921ec23 100644 --- a/usr/local/www/diag_logs_ntpd.php +++ b/usr/local/www/diag_logs_ntpd.php @@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: ntpd */ @@ -46,11 +46,13 @@ require("guiconfig.inc"); $ntpd_logfile = "{$g['varlog_path']}/ntpd.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($ntpd_logfile); +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("NTP")); $shortcut_section = "ntp"; @@ -61,7 +63,8 @@ include("head.inc");
- + - - - + + + + +
+
-
-
- - - - - - -
-

-
- " /> -
-
-
-
+
+ + + + + + + + +
+ +
+
+
+ " /> +
+
+
+
diff --git a/usr/local/www/diag_logs_openvpn.php b/usr/local/www/diag_logs_openvpn.php index feda5ca..c9e4bed 100644 --- a/usr/local/www/diag_logs_openvpn.php +++ b/usr/local/www/diag_logs_openvpn.php @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: openvpn */ @@ -52,11 +52,13 @@ require_once("vpn.inc"); $openvpn_logfile = "{$g['varlog_path']}/openvpn.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($openvpn_logfile); +} include("head.inc"); @@ -64,7 +66,7 @@ include("head.inc"); - + + -
-
+
- + - + diff --git a/usr/local/www/diag_logs_ppp.php b/usr/local/www/diag_logs_ppp.php index 8a53214..c56c7e0 100644 --- a/usr/local/www/diag_logs_ppp.php +++ b/usr/local/www/diag_logs_ppp.php @@ -32,8 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* - pfSense_BUILDER_BINARIES: /sbin/ifconfig /usr/bin/awk +/* + pfSense_BUILDER_BINARIES: /sbin/ifconfig /usr/bin/awk pfSense_MODULE: */ @@ -49,11 +49,13 @@ require("guiconfig.inc"); $ppp_logfile = "{$g['varlog_path']}/ppp.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($ppp_logfile); +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("PPP")); include("head.inc"); @@ -62,7 +64,7 @@ include("head.inc");

- " /> + " />
- + + - - +
-
+
- + - + diff --git a/usr/local/www/diag_logs_relayd.php b/usr/local/www/diag_logs_relayd.php index e44b082..053dbc9 100644 --- a/usr/local/www/diag_logs_relayd.php +++ b/usr/local/www/diag_logs_relayd.php @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: routing */ @@ -47,11 +47,13 @@ require("guiconfig.inc"); $relayd_logfile = "{$g['varlog_path']}/relayd.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($relayd_logfile); +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Load Balancer")); $shortcut_section = "relayd"; @@ -62,7 +64,8 @@ include("head.inc");

- " /> + " />
- + - - - + + + + +
+
-
-
- - - - - - -
-

-" />
-
-
+
+ + + + + + + + +
+ +
+
+
+ " /> +
+
+
+
diff --git a/usr/local/www/diag_logs_resolver.php b/usr/local/www/diag_logs_resolver.php index dd8f74a..981d473 100755 --- a/usr/local/www/diag_logs_resolver.php +++ b/usr/local/www/diag_logs_resolver.php @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: system */ @@ -49,26 +49,32 @@ require("guiconfig.inc"); $system_logfile = "{$g['varlog_path']}/resolver.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($system_logfile); +} -if ($_GET['filtertext']) +if ($_GET['filtertext']) { $filtertext = htmlspecialchars($_GET['filtertext']); +} -if ($_POST['filtertext']) +if ($_POST['filtertext']) { $filtertext = htmlspecialchars($_POST['filtertext']); +} -if ($filtertext) +if ($filtertext) { $filtertextmeta="?filtertext=$filtertext"; +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Resolver")); -if (isset($config['dnsmasq']['enable'])) +if (isset($config['dnsmasq']['enable'])) { $shortcut_section = "forwarder"; -else +} else { $shortcut_section = "resolver"; +} include("head.inc"); @@ -96,7 +102,8 @@ include("head.inc"); ?>
+
- " /> + " />
- - " /> + + " />
-
+
diff --git a/usr/local/www/diag_logs_routing.php b/usr/local/www/diag_logs_routing.php index bb14680..0fdbc67 100644 --- a/usr/local/www/diag_logs_routing.php +++ b/usr/local/www/diag_logs_routing.php @@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: routing */ @@ -46,11 +46,13 @@ require("guiconfig.inc"); $routing_logfile = "{$g['varlog_path']}/routing.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($routing_logfile); +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Routing")); $shortcut_section = "routing"; @@ -61,7 +63,8 @@ include("head.inc"); - + - + + + - - - - + + + + +
+
-
+
-
-
- - - - - - -
-

-" />
-
-
+
+ + + + + + + + +
+ +
+
+
+ " /> +
+
+
+
diff --git a/usr/local/www/diag_logs_settings.php b/usr/local/www/diag_logs_settings.php index 5f48985..9d1ecfa 100644 --- a/usr/local/www/diag_logs_settings.php +++ b/usr/local/www/diag_logs_settings.php @@ -75,8 +75,9 @@ $pconfig['filterdescriptions'] = $config['syslog']['filterdescriptions']; $pconfig['disablelocallogging'] = isset($config['syslog']['disablelocallogging']); $pconfig['logfilesize'] = $config['syslog']['logfilesize']; -if (!$pconfig['nentries']) +if (!$pconfig['nentries']) { $pconfig['nentries'] = 50; +} function is_valid_syslog_server($target) { return (is_ipaddr($target) @@ -150,11 +151,12 @@ if ($_POST['resetlogs'] == gettext("Reset Log Files")) { $config['syslog']['nologprivatenets'] = $_POST['logprivatenets'] ? false : true; $config['syslog']['nologlighttpd'] = $_POST['loglighttpd'] ? false : true; $config['syslog']['rawfilter'] = $_POST['rawfilter'] ? true : false; - if (is_numeric($_POST['filterdescriptions']) && $_POST['filterdescriptions'] > 0) + if (is_numeric($_POST['filterdescriptions']) && $_POST['filterdescriptions'] > 0) { $config['syslog']['filterdescriptions'] = $_POST['filterdescriptions']; - else + } else { unset($config['syslog']['filterdescriptions']); - if($config['syslog']['enable'] == false) { + } + if ($config['syslog']['enable'] == false) { unset($config['syslog']['remoteserver']); unset($config['syslog']['remoteserver2']); unset($config['syslog']['remoteserver3']); @@ -164,11 +166,12 @@ if ($_POST['resetlogs'] == gettext("Reset Log Files")) { $retval = 0; $retval = system_syslogd_start(); - if (($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock'])) - || ($oldnologdefaultpass !== isset($config['syslog']['nologdefaultpass'])) - || ($oldnologbogons !== isset($config['syslog']['nologbogons'])) - || ($oldnologprivatenets !== isset($config['syslog']['nologprivatenets']))) + if (($oldnologdefaultblock !== isset($config['syslog']['nologdefaultblock'])) || + ($oldnologdefaultpass !== isset($config['syslog']['nologdefaultpass'])) || + ($oldnologbogons !== isset($config['syslog']['nologbogons'])) || + ($oldnologprivatenets !== isset($config['syslog']['nologprivatenets']))) { $retval |= filter_configure(); + } $savemsg = get_std_save_message($retval); @@ -342,9 +345,9 @@ function check_everything() {
Filter descriptions
@@ -382,8 +385,9 @@ function check_everything() { $sipname): $selected = ""; - if (!link_interface_to_bridge($sipvalue) && ($sipvalue == $pconfig['sourceip'])) + if (!link_interface_to_bridge($sipvalue) && ($sipvalue == $pconfig['sourceip'])) { $selected = 'selected="selected"'; + } ?>
" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "\"in\"\"out\"" . htmlspecialchars($llent[3]) . "" . htmlspecialchars($llent[2]) . " 
+
@@ -178,9 +183,9 @@ include("head.inc"); - + endif; ?>

diff --git a/usr/local/www/diag_logs_wireless.php b/usr/local/www/diag_logs_wireless.php index 5dfbf72..49998cf 100644 --- a/usr/local/www/diag_logs_wireless.php +++ b/usr/local/www/diag_logs_wireless.php @@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: routing */ @@ -48,11 +48,13 @@ require("guiconfig.inc"); $wireless_logfile = "{$g['varlog_path']}/wireless.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} -if ($_POST['clear']) +if ($_POST['clear']) { clear_log_file($wireless_logfile); +} $pgtitle = array(gettext("Status"),gettext("System logs"),gettext("Wireless")); $shortcut_section = "wireless"; @@ -63,7 +65,8 @@ include("head.inc"); - + - + + + - - - - + + + + +
+
-
+
-
-
- - - - - - -
-

-" />
-
-
+
+ + + + + + + + +
+ +
+
+
+ " /> +
+
+
+
diff --git a/usr/local/www/diag_nanobsd.php b/usr/local/www/diag_nanobsd.php index 206ed66..63a4f35 100644 --- a/usr/local/www/diag_nanobsd.php +++ b/usr/local/www/diag_nanobsd.php @@ -27,7 +27,7 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_BUILDER_BINARIES: /sbin/mount /sbin/glabel /usr/bin/grep /usr/bin/cut /usr/bin/head /bin/cp pfSense_BUILDER_BINARIES: /usr/sbin/boot0cfg /bin/mkdir /sbin/fsck_ufs /sbin/mount /bin/dd /sbin/tunefs pfSense_MODULE: nanobsd @@ -66,11 +66,11 @@ nanobsd_detect_slice_info(); $NANOBSD_SIZE = nanobsd_get_size(); -if($_POST['bootslice']) { - $statusmsg = gettext("Setting slice information, please wait..."); +if ($_POST['bootslice']) { + $statusmsg = gettext("Setting slice information, please wait..."); echo << - +
+ $statusmsg

 

@@ -82,16 +82,16 @@ EOF; } -if($_POST['destslice']) { +if ($_POST['destslice']) { $statusmsg = gettext("Duplicating slice. Please wait, this will take a moment..."); -echo << + echo << $statusmsg

  EOF; - if(nanobsd_clone_slice($_POST['destslice'])) { + if (nanobsd_clone_slice($_POST['destslice'])) { $savemsg = gettext("The slice has been duplicated.") . "

" . gettext("If you would like to boot from this newly duplicated slice please set it using the bootup information area."); } else { $savemsg = gettext("There was an error while duplicating the slice. Operation aborted."); @@ -110,17 +110,19 @@ if ($_POST['changero']) { if ($_POST['setrw']) { conf_mount_rw(); - if (isset($_POST['nanobsd_force_rw'])) + if (isset($_POST['nanobsd_force_rw'])) { $config['system']['nanobsd_force_rw'] = true; - else + } else { unset($config['system']['nanobsd_force_rw']); + } write_config("Changed Permanent Read/Write Setting"); conf_mount_ro(); } -if ($savemsg) - print_info_box($savemsg) +if ($savemsg) { + print_info_box($savemsg); +} ?> @@ -144,7 +146,7 @@ if ($savemsg) - + - + @@ -180,12 +182,14 @@ if ($savemsg) $refdisplay = " (reference count " . $refcount . ")"; } echo gettext("Read/Write") . $refdisplay; - if (!isset($config['system']['nanobsd_force_rw'])) + if (!isset($config['system']['nanobsd_force_rw'])) { echo "
"; + } } else { echo gettext("Read-Only"); - if (!isset($config['system']['nanobsd_force_rw'])) + if (!isset($config['system']['nanobsd_force_rw'])) { echo "
"; + } } ?>
@@ -234,10 +238,10 @@ if ($savemsg) Advanced, Miscellaneous tab")?>. - + - + @@ -265,7 +269,7 @@ if ($savemsg) - +
@@ -163,7 +165,7 @@ if ($savemsg)
 
 
 

@@ -153,11 +159,12 @@ ob_implicit_flush(1); ?> -
- /> + />

:
- /> + />

:
"; - if ($processisrunning == true) + if ($processisrunning == true) { echo("" . gettext("Packet Capture is running.") . "
"); + } if ($do_tcpdump) { $matches = array(); - if (in_array($fam, $fams)) + if (in_array($fam, $fams)) { $matches[] = $fam; + } if (in_array($proto, $protos)) { $matches[] = fixup_not($proto); } - if ($port != "") + if ($port != "") { $matches[] = "port ".fixup_not($port); + } if ($host != "") { $hostmatch = ""; $hostcount = 0; foreach ($hosts as $h) { $h = fixup_host($h, $hostcount++); - if (!empty($h)) + if (!empty($h)) { $hostmatch .= " " . $h; + } } - if (!empty($hostmatch)) + if (!empty($hostmatch)) { $matches[] = "({$hostmatch})"; + } } if ($count != "0" ) { @@ -430,7 +438,7 @@ include("fbegin.inc"); ?>
"; print_info_box($savemsg); - echo "
"; + echo ""; } - if ($input_errors) + if ($input_errors) { print_input_errors($input_errors); + } ?> - - - + + +
- - - - -
- - -
-
- -
-
-
-
+ + + + +
+ + +
+
+ +
+
+
+
diff --git a/usr/local/www/diag_ping.php b/usr/local/www/diag_ping.php index 0c289cf..954d9f2 100644 --- a/usr/local/www/diag_ping.php +++ b/usr/local/www/diag_ping.php @@ -13,11 +13,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -47,7 +47,6 @@ $allowautocomplete = true; $pgtitle = array(gettext("Diagnostics"), gettext("Ping")); require_once("guiconfig.inc"); - define('MAX_COUNT', 10); define('DEFAULT_COUNT', 3); @@ -66,17 +65,20 @@ if ($_POST || $_REQUEST['host']) { $host = trim($_REQUEST['host']); $ipproto = $_REQUEST['ipproto']; - if (($ipproto == "ipv4") && is_ipaddrv6($host)) + if (($ipproto == "ipv4") && is_ipaddrv6($host)) { $input_errors[] = gettext("When using IPv4, the target host must be an IPv4 address or hostname."); - if (($ipproto == "ipv6") && is_ipaddrv4($host)) + } + if (($ipproto == "ipv6") && is_ipaddrv4($host)) { $input_errors[] = gettext("When using IPv6, the target host must be an IPv6 address or hostname."); + } if (!$input_errors) { $do_ping = true; $sourceip = $_REQUEST['sourceip']; $count = $_POST['count']; - if (preg_match('/[^0-9]/', $count) ) + if (preg_match('/[^0-9]/', $count) ) { $count = DEFAULT_COUNT; + } } } if (!isset($do_ping)) { @@ -118,8 +120,9 @@ include("head.inc"); ?> $sipname): $selected = ""; - if (!link_interface_to_bridge($sipvalue) && ($sipvalue == $sourceip)) + if (!link_interface_to_bridge($sipvalue) && ($sipvalue == $sourceip)) { $selected = "selected=\"selected\""; + } ?>
@@ -291,7 +285,7 @@ switch($action) { $tab_array[0] = array(gettext("Information/Tests"), true, $_SERVER['PHP_SELF']); //$tab_array[1] = array("Config", false, $_SERVER['PHP_SELF'] . "?action=config"); display_top_tabs($tab_array); - ?> + ?> @@ -317,8 +311,7 @@ switch($action) { " . $dev . ""; } ?> @@ -393,8 +385,7 @@ switch($action) { " . $dev . ""; } ?> @@ -448,15 +438,18 @@ switch($action) { } // print back button on pages -if(isset($_POST['submit']) && $_POST['submit'] != "Save") -{ +if (isset($_POST['submit']) && $_POST['submit'] != "Save") { ?> " onclick="window.location.href=''" />
-" . $ulmsg . "

\n"; ?> +" . $ulmsg . "

\n"; +} +?> diff --git a/usr/local/www/diag_sockets.php b/usr/local/www/diag_sockets.php index 53daa3f..1c960bd 100644 --- a/usr/local/www/diag_sockets.php +++ b/usr/local/www/diag_sockets.php @@ -11,11 +11,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -31,7 +31,7 @@ */ /* - pfSense_BUILDER_BINARIES: /usr/bin/sockstat + pfSense_BUILDER_BINARIES: /usr/bin/sockstat */ ##|+PRIV ##|*IDENT=page-diagnostics-sockets @@ -57,20 +57,19 @@ $showAllOption = $showAll ? "" : "?showAll"; ?>
- - - - - - - - - + + + + + + + + +
Information about listening sockets for both IPv4 and IPv6.
For explanation about the meaning of the information listed for each socket click here.
To show information about both listening and connected sockets click this.
Information about listening sockets for both IPv4 and IPv6.
For explanation about the meaning of the information listed for each socket click here.
To show information about both listening and connected sockets click this.
- -
- - $line) { - if ($i == 0) - $class = 'listhdrr'; - else - $class = 'listlr'; - - if (trim($line) == "") - continue; - print("\n"); - $j = 0; - foreach (explode(' ', $line) as $entry) { - if ($entry == '' || $entry == "ADDRESS") continue; - if ($i == 0) - print("\n"); - else - print("\n"); - if ($i > 0) - $class = 'listr'; - $j++; - } - print("\n"); - }?> + + + + + +
$entry$entry
+ + $line) { + if ($i == 0) { + $class = 'listhdrr'; + } else { + $class = 'listlr'; + } + + if (trim($line) == "") { + continue; + } + print("\n"); + $j = 0; + foreach (explode(' ', $line) as $entry) { + if ($entry == '' || $entry == "ADDRESS") { + continue; + } + if ($i == 0) { + print("\n"); + } else { + print("\n"); + } + if ($i > 0) { + $class = 'listr'; + } + $j++; + } + print("\n"); + } + ?> +
$entry$entry
+
-

- - + + + + - - - - - - - - +The information listed for each socket is: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Socket information explanation
+
Socket information explanation
This page show the output for the commands: "sockstat -4lL" and "sockstat -6lL".
Or in case of showing all sockets the output for: "sockstat -4" and "sockstat -6".

-The information listed for each socket is:
USER The user who owns the socket.
COMMAND The command which holds the socket.
PID The process ID of the command which holds the socket.
FD The file descriptor number of the socket.
PROTO The transport protocol associated with the socket for Internet sockets, or the type of socket (stream or data-gram) for UNIX sockets.
ADDRESS (UNIX sockets only) For bound sockets, this is the file-name of the socket. For other sockets, it is the name, PID and file descriptor number of the peer, or ``(none)'' if the socket is neither bound nor connected.
LOCAL ADDRESS (Internet sockets only) The address the local end of the socket is bound to (see getsockname(2)).
FOREIGN ADDRESS (Internet sockets only) The address the foreign end of the socket is bound to (see getpeername(2)).
USER The user who owns the socket.
COMMANDThe command which holds the socket.
PIDThe process ID of the command which holds the socket.
FDThe file descriptor number of the socket.
PROTOThe transport protocol associated with the socket for Internet sockets, or the type of socket (stream or data-gram) for UNIX sockets.
ADDRESS(UNIX sockets only) For bound sockets, this is the file-name of the socket. For other sockets, it is the name, PID and file descriptor number of the peer, or ``(none)'' if the socket is neither bound nor connected.
LOCAL ADDRESS(Internet sockets only) The address the local end of the socket is bound to (see getsockname(2)).
FOREIGN ADDRESS(Internet sockets only) The address the foreign end of the socket is bound to (see getpeername(2)).
0) { - foreach($states as $line) { +if (count($states) > 0) { + foreach ($states as $line) { $line_split = preg_split("/\s+/", $line); $iface = array_shift($line_split); $proto = array_shift($line_split); @@ -71,7 +71,7 @@ if(count($states) > 0) { $info = implode(" ", $line_split); /* Handle NAT cases - Replaces an external IP + NAT by the internal IP */ + Replaces an external IP + NAT by the internal IP */ if (strpos($info, ') ->') !== FALSE) { /* Outbound NAT */ $info = preg_replace('/(\S+) \((\S+)\)/U', "$2", $info); @@ -129,16 +129,18 @@ function sort_by_ip($a, $b) { } function build_port_info($portarr, $proto) { - if (!$portarr) + if (!$portarr) { return ''; + } $ports = array(); asort($portarr); foreach (array_reverse($portarr, TRUE) as $port => $count) { $str = ""; $service = getservbyport($port, strtolower($proto)); $port = "{$proto}/{$port}"; - if ($service) + if ($service) { $port = "{$port} ({$service})"; + } $ports[] = "{$port}: {$count}"; } return implode($ports, ', '); @@ -156,9 +158,11 @@ function print_summary_table($label, $iparr, $sort = TRUE) { ?> - $ipinfo) { ?> + } + foreach ($iparr as $ip => $ipinfo) { ?> @@ -167,7 +171,7 @@ function print_summary_table($label, $iparr, $sort = TRUE) { ?>     - $protoinfo) { ?> + $protoinfo) { ?>     diff --git a/usr/local/www/diag_system_activity.php b/usr/local/www/diag_system_activity.php index cc2c41e..4426184 100644 --- a/usr/local/www/diag_system_activity.php +++ b/usr/local/www/diag_system_activity.php @@ -1,32 +1,32 @@
"; print_info_box($savemsg); - echo "
"; + echo "
"; } - if ($input_errors) + if ($input_errors) { print_input_errors($input_errors); + } ?> - - - + + +
- - - - -
- - -
-
- -
-
-
-
+ + + + +
+ + + + +
+
+ +
+
+
+
diff --git a/usr/local/www/diag_system_pftop.php b/usr/local/www/diag_system_pftop.php index f5cc443..c959e00 100644 --- a/usr/local/www/diag_system_pftop.php +++ b/usr/local/www/diag_system_pftop.php @@ -1,31 +1,31 @@
"; print_info_box($savemsg); - echo "
"; + echo ""; } - if ($input_errors) + if ($input_errors) { print_input_errors($input_errors); + } ?>
@@ -178,18 +179,18 @@ if($_REQUEST['sorttype'] && in_array($_REQUEST['sorttype'], $sorttypes)
- - - - -
-
-
+ + + + +
+
+
- +
diff --git a/usr/local/www/diag_tables.php b/usr/local/www/diag_tables.php index 09237e3..289d39f 100644 --- a/usr/local/www/diag_tables.php +++ b/usr/local/www/diag_tables.php @@ -50,42 +50,46 @@ require_once("guiconfig.inc"); // Set default table $tablename = "sshlockout"; -if($_REQUEST['type']) +if ($_REQUEST['type']) { $tablename = $_REQUEST['type']; +} -if($_REQUEST['delete']) { - if(is_ipaddr($_REQUEST['delete']) || is_subnet($_REQUEST['delete'])) { +if ($_REQUEST['delete']) { + if (is_ipaddr($_REQUEST['delete']) || is_subnet($_REQUEST['delete'])) { exec("/sbin/pfctl -t " . escapeshellarg($_REQUEST['type']) . " -T delete " . escapeshellarg($_REQUEST['delete']), $delete); echo htmlentities($_REQUEST['delete']); } exit; } -if($_REQUEST['deleteall']) { +if ($_REQUEST['deleteall']) { exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T show", $entries); - if(is_array($entries)) { - foreach($entries as $entryA) { + if (is_array($entries)) { + foreach ($entries as $entryA) { $entry = trim($entryA); exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T delete " . escapeshellarg($entry), $delete); } } } -if((($tablename == "bogons") || ($tablename == "bogonsv6")) && ($_POST['Download'])) { +if ((($tablename == "bogons") || ($tablename == "bogonsv6")) && ($_POST['Download'])) { mwexec_bg("/etc/rc.update_bogons.sh now"); $maxtimetowait = 0; $loading = true; - while($loading == true) { + while ($loading == true) { $isrunning = `/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep bogons`; - if($isrunning == "") + if ($isrunning == "") { $loading = false; + } $maxtimetowait++; - if($maxtimetowait > 89) + if ($maxtimetowait > 89) { $loading = false; + } sleep(1); } - if($maxtimetowait < 90) + if ($maxtimetowait < 90) { $savemsg = gettext("The bogons database has been updated."); + } } exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T show", $entries); @@ -121,12 +125,14 @@ include("head.inc"); @@ -136,37 +142,44 @@ include("head.inc"); - - + - + delete - " . gettext("No entries exist in this table.") . "  " . " " . gettext(" the latest bogon data."); - else + } else { echo "" . gettext("No entries exist in this table."); + } + } ?> 0) - if( ($tablename == "bogons") || ($tablename == "bogonsv6") ) { + if ($count > 0) { + if (($tablename == "bogons") || ($tablename == "bogonsv6")) { $last_updated = exec('/usr/bin/grep -i -m 1 -E "^# last updated" /etc/' . escapeshellarg($tablename)); echo " $count " . gettext("entries in this table.") . "  " . " " . gettext(" the latest bogon data.") . "
" . "$last_updated"; - } - else + } else { echo "" . gettext("Delete") . " " . gettext("all") . " " . "$count " . gettext("entries in this table."); + } + } ?> diff --git a/usr/local/www/diag_testport.php b/usr/local/www/diag_testport.php index 393c757..7054a95 100644 --- a/usr/local/www/diag_testport.php +++ b/usr/local/www/diag_testport.php @@ -14,11 +14,11 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY @@ -83,7 +83,7 @@ if ($_POST || $_REQUEST['host']) { $do_testport = true; $timeout = NC_TIMEOUT; } - + /* Save these request vars even if there were input errors. Then the fields are refilled for the user to correct. */ $host = $_REQUEST['host']; $sourceip = $_REQUEST['sourceip']; @@ -111,8 +111,9 @@ include("head.inc"); ?> - - + + + @@ -142,13 +143,14 @@ include("head.inc"); ?> $sipname): $selected = ""; - if (!link_interface_to_bridge($sipvalue) && ($sipvalue == $sourceip)) + if (!link_interface_to_bridge($sipvalue) && ($sipvalue == $sourceip)) { $selected = "selected=\"selected\""; + } ?> - + @@ -184,7 +186,7 @@ include("head.inc"); ?> ?>