diff options
author | Renato Botelho <garga@FreeBSD.org> | 2015-04-27 08:50:27 -0300 |
---|---|---|
committer | Renato Botelho <garga@FreeBSD.org> | 2015-04-27 08:50:27 -0300 |
commit | daac712a3cab2c67c09baed3fa3b518ea2aad263 (patch) | |
tree | d0e7fb4c801d574d3a82e6b828a97c1b76021369 /usr | |
parent | 306b9d003078f40999d352803e998867ebbc5086 (diff) | |
parent | 7c49037086e89b69a839e758db37c1e275c90a72 (diff) | |
download | pfsense-daac712a3cab2c67c09baed3fa3b518ea2aad263.zip pfsense-daac712a3cab2c67c09baed3fa3b518ea2aad263.tar.gz |
Merge pull request #1618 from phil-davis/www-widgets
Diffstat (limited to 'usr')
21 files changed, 926 insertions, 829 deletions
diff --git a/usr/local/www/widgets/widgets/captive_portal_status.widget.php b/usr/local/www/widgets/widgets/captive_portal_status.widget.php index 4d2d49d..21c44e3 100644 --- a/usr/local/www/widgets/widgets/captive_portal_status.widget.php +++ b/usr/local/www/widgets/widgets/captive_portal_status.widget.php @@ -1,4 +1,4 @@ -<?php +<?php /* captive_portal_status.widget.php Copyright (C) 2013-2015 Electric Sheep Fencing, LP @@ -9,20 +9,20 @@ status_captiveportal.php part of m0n0wall (http://m0n0.ch/wall) - + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. All rights reserved. - + Redistribution and use in source and binary forms, with or without 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. - + 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. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -47,16 +47,19 @@ require_once("captiveportal.inc"); <?php -if (!is_array($config['captiveportal'])) - $config['captiveportal'] = array(); +if (!is_array($config['captiveportal'])) { + $config['captiveportal'] = array(); +} $a_cp =& $config['captiveportal']; $cpzone = $_GET['zone']; -if (isset($_POST['zone'])) - $cpzone = $_POST['zone']; +if (isset($_POST['zone'])) { + $cpzone = $_POST['zone']; +} -if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid'])) +if (isset($cpzone) && !empty($cpzone) && isset($a_cp[$cpzone]['zoneid'])) { $cpzoneid = $a_cp[$cpzone]['zoneid']; +} if (($_GET['act'] == "del") && !empty($cpzone) && isset($cpzoneid)) { captiveportal_disconnect_client($_GET['id']); @@ -78,25 +81,27 @@ foreach ($a_cp as $cpzone => $cp) { $cpdb = captiveportal_read_db(); foreach ($cpdb as $cpent) { $cpent[10] = $cpzone; - if ($showact == 1) + if ($showact == 1) { $cpent[11] = captiveportal_get_last_activity($cpent[2], $cpentry[3]); + } $cpdb_all[] = $cpent; } } if ($_GET['order']) { - if ($_GET['order'] == "ip") + if ($_GET['order'] == "ip") { $order = 2; - else if ($_GET['order'] == "mac") + } else if ($_GET['order'] == "mac") { $order = 3; - else if ($_GET['order'] == "user") + } else if ($_GET['order'] == "user") { $order = 4; - else if ($_GET['order'] == "lastact") + } else if ($_GET['order'] == "lastact") { $order = 5; - else if ($_GET['order'] == "zone") + } else if ($_GET['order'] == "zone") { $order = 10; - else + } else { $order = 0; + } usort($cpdb_all, "clientcmp"); } ?> diff --git a/usr/local/www/widgets/widgets/carp_status.widget.php b/usr/local/www/widgets/widgets/carp_status.widget.php index 8d2e5ed..bb68dbd 100644 --- a/usr/local/www/widgets/widgets/carp_status.widget.php +++ b/usr/local/www/widgets/widgets/carp_status.widget.php @@ -42,11 +42,12 @@ $carp_enabled = get_carp_status(); ?> <table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0" summary="carp status"> <?php - if(is_array($config['virtualip']['vip'])) { + if (is_array($config['virtualip']['vip'])) { $carpint=0; - foreach($config['virtualip']['vip'] as $carp) { - if ($carp['mode'] != "carp") + foreach ($config['virtualip']['vip'] as $carp) { + if ($carp['mode'] != "carp") { continue; + } $ipaddress = $carp['subnet']; $password = $carp['password']; $netmask = $carp['subnet_bits']; @@ -62,7 +63,7 @@ $carp_enabled = get_carp_status(); </td> <td width="65%" class="listr"> <?php - if($carp_enabled == false) { + if ($carp_enabled == false) { $status = "DISABLED"; echo "<img src='/themes/".$g['theme']."/images/icons/icon_block.gif' title=\"$status\" alt=\"$status\" />"; } else { diff --git a/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php b/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php index 570b22d..09723d7 100644 --- a/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php +++ b/usr/local/www/widgets/widgets/deactivated/cpu_graphs.widget.php @@ -1,45 +1,45 @@ <?php /* - $Id$ + $Id$ - Copyright (C) 2013-2015 Electric Sheep Fencing, LP - All rights reserved. + Copyright (C) 2013-2015 Electric Sheep Fencing, LP + All rights reserved. - Copyright 2007 Scott Dale - Part of pfSense widgets (https://www.pfsense.org) - originally based on m0n0wall (http://m0n0.ch/wall) + Copyright 2007 Scott Dale + Part of pfSense widgets (https://www.pfsense.org) + originally based on m0n0wall (http://m0n0.ch/wall) - Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net> - and Jonathan Watt <jwatt@jwatt.org>. - All rights reserved. + Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net> + and Jonathan Watt <jwatt@jwatt.org>. + All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + 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. + 1. Redistributions of source code must retain the above copyright notice, + 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. + 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. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. */ require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); ?> -<link href="/themes/<?=$g['theme'];?>/graphlink.css" rel="stylesheet" type="text/css" /> +<link href="/themes/<?=$g['theme'];?>/graphlink.css" rel="stylesheet" type="text/css" /> <script src="/widgets/javascript/cpu_graphs.js" type="text/javascript"></script> <script type="text/javascript"> /* initialize the graph */ diff --git a/usr/local/www/widgets/widgets/dyn_dns_status.widget.php b/usr/local/www/widgets/widgets/dyn_dns_status.widget.php index 3c82e59..632c87b 100644 --- a/usr/local/www/widgets/widgets/dyn_dns_status.widget.php +++ b/usr/local/www/widgets/widgets/dyn_dns_status.widget.php @@ -42,29 +42,32 @@ require_once("pfsense-utils.inc"); require_once("functions.inc"); require_once("/usr/local/www/widgets/include/dyn_dns_status.inc"); -if (!is_array($config['dyndnses']['dyndns'])) +if (!is_array($config['dyndnses']['dyndns'])) { $config['dyndnses']['dyndns'] = array(); +} $a_dyndns = &$config['dyndnses']['dyndns']; -if($_REQUEST['getdyndnsstatus']) { +if ($_REQUEST['getdyndnsstatus']) { $first_entry = true; foreach ($a_dyndns as $dyndns) { - if ($first_entry) + if ($first_entry) { $first_entry = false; - else + } else { // Put a vertical bar delimiter between the echoed HTML for each entry processed. echo "|"; + } $filename = "{$g['conf_path']}/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache"; if (file_exists($filename)) { $ipaddr = dyndnsCheckIP($dyndns['interface']); $cached_ip_s = explode(':', file_get_contents($filename)); $cached_ip = $cached_ip_s[0]; - if ($ipaddr <> $cached_ip) + if ($ipaddr <> $cached_ip) { echo "<font color='red'>"; - else + } else { echo "<font color='green'>"; + } echo htmlspecialchars($cached_ip); echo "</font>"; } else { @@ -89,20 +92,22 @@ if($_REQUEST['getdyndnsstatus']) { <?php $iflist = get_configured_interface_with_descr(); foreach ($iflist as $if => $ifdesc) { if ($dyndns['interface'] == $if) { - if (!isset($dyndns['enable'])) + if (!isset($dyndns['enable'])) { echo "<span class=\"gray\">{$ifdesc}</span>"; - else + } else { echo "{$ifdesc}"; + } break; } } $groupslist = return_gateway_groups_array(); foreach ($groupslist as $if => $group) { if ($dyndns['interface'] == $if) { - if (!isset($dyndns['enable'])) + if (!isset($dyndns['enable'])) { echo "<span class=\"gray\">{$if}</span>"; - else + } else { echo "{$if}"; + } break; } } @@ -112,22 +117,25 @@ if($_REQUEST['getdyndnsstatus']) { <?php $types = explode(",", DYNDNS_PROVIDER_DESCRIPTIONS); $vals = explode(" ", DYNDNS_PROVIDER_VALUES); - for ($j = 0; $j < count($vals); $j++) + for ($j = 0; $j < count($vals); $j++) { if ($vals[$j] == $dyndns['type']) { - if (!isset($dyndns['enable'])) + if (!isset($dyndns['enable'])) { echo "<span class=\"gray\">".htmlspecialchars($types[$j])."</span>"; - else + } else { echo htmlspecialchars($types[$j]); + } break; } + } ?> </td> <td class="listr"> <?php - if (!isset($dyndns['enable'])) + if (!isset($dyndns['enable'])) { echo "<span class=\"gray\">".htmlspecialchars($dyndns['host'])."</span>"; - else + } else { echo htmlspecialchars($dyndns['host']); + } ?> </td> <td class="listr"> @@ -155,8 +163,7 @@ if($_REQUEST['getdyndnsstatus']) { function dyndnscallback(transport) { // The server returns a string of statuses separated by vertical bars var responseStrings = transport.responseText.split("|"); - for (var count=0; count<responseStrings.length; count++) - { + for (var count=0; count<responseStrings.length; count++) { var divlabel = '#dyndnsstatus' + count; jQuery(divlabel).prop('innerHTML',responseStrings[count]); } diff --git a/usr/local/www/widgets/widgets/gateways.widget.php b/usr/local/www/widgets/widgets/gateways.widget.php index 4f34191..acbb533 100644 --- a/usr/local/www/widgets/widgets/gateways.widget.php +++ b/usr/local/www/widgets/widgets/gateways.widget.php @@ -64,13 +64,15 @@ $counter = 1; <div id="gateway<?php echo $counter; ?>" style="display:inline"><b> <?php $if_gw = ''; - if (is_ipaddr($gateway['gateway'])) + if (is_ipaddr($gateway['gateway'])) { $if_gw = htmlspecialchars($gateway['gateway']); - else { - if($gateway['ipprotocol'] == "inet") + } else { + if ($gateway['ipprotocol'] == "inet") { $if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface'])); - if($gateway['ipprotocol'] == "inet6") + } + if ($gateway['ipprotocol'] == "inet6") { $if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface'])); + } } echo ($if_gw == '' ? '~' : $if_gw); unset ($if_gw); @@ -82,19 +84,21 @@ $counter = 1; <tr> <td class="listr ellipsis" align="center" id="gateway<?php echo $counter; ?>"> <?php - if ($gateways_status[$gname]) + if ($gateways_status[$gname]) { echo htmlspecialchars($gateways_status[$gname]['delay']); - else + } else { echo gettext("Pending"); + } ?> <?php $counter++; ?> </td> <td class="listr ellipsis" align="center" id="gateway<?php echo $counter; ?>"> <?php - if ($gateways_status[$gname]) + if ($gateways_status[$gname]) { echo htmlspecialchars($gateways_status[$gname]['loss']); - else + } else { echo gettext("Pending"); + } ?> <?php $counter++; ?> </td> diff --git a/usr/local/www/widgets/widgets/installed_packages.widget.php b/usr/local/www/widgets/widgets/installed_packages.widget.php index a9ab804..3190e1b 100644 --- a/usr/local/www/widgets/widgets/installed_packages.widget.php +++ b/usr/local/www/widgets/widgets/installed_packages.widget.php @@ -41,8 +41,8 @@ require_once("functions.inc"); require_once("/usr/local/www/widgets/include/installed_packages.inc"); require_once("pkg-utils.inc"); -if(is_array($config['installedpackages']['package'])) { - foreach($config['installedpackages']['package'] as $instpkg) { +if (is_array($config['installedpackages']['package'])) { + foreach ($config['installedpackages']['package'] as $instpkg) { $tocheck[] = $instpkg['name']; } $currentvers = get_pkg_info($tocheck, array('version', 'xmlver')); @@ -58,16 +58,17 @@ $updateavailable = false; <td width="30%" class="listhdrr">Package Version</td> </tr> <?php - if($config['installedpackages']['package'] != "") { + if ($config['installedpackages']['package'] != "") { $instpkgs = array(); - foreach($config['installedpackages']['package'] as $instpkg) + foreach ($config['installedpackages']['package'] as $instpkg) { $instpkgs[] = $instpkg['name']; + } natcasesort($instpkgs); $y=1; foreach ($instpkgs as $index => $pkgname){ $pkg = $config['installedpackages']['package'][$index]; - if($pkg['name'] <> "") { ?> + if ($pkg['name'] <> "") { ?> <tr valign="top"> <td class="listlr"> <?= $pkg['name'] ?> @@ -78,14 +79,14 @@ $updateavailable = false; <td class="listr"> <?php $latest_package = $currentvers[$pkg['name']]['version']; - if($latest_package == false) { + if ($latest_package == false) { // We can't determine this package's version status. echo "Current: Unknown.<br />Installed: " . $pkg['version']; - } elseif(strcmp($pkg['version'], $latest_package) > 0) { + } elseif (strcmp($pkg['version'], $latest_package) > 0) { /* we're running a newer version of the package */ echo "Current: {$latest_package}"; echo "<br />Installed: {$pkg['version']}"; - } elseif(strcmp($pkg['version'], $latest_package) < 0) { + } elseif (strcmp($pkg['version'], $latest_package) < 0) { /* our package is out of date */ $updateavailable = true; ?> @@ -115,7 +116,7 @@ $updateavailable = false; //<![CDATA[ window.onload = function(in_event) { - for (y=1; y<=<?php echo $y;?>; y++){ + for (y=1; y<=<?php echo $y;?>; y++) { textID = "#updatediv-" + y; jQuery(textID).effect('pulsate'); } diff --git a/usr/local/www/widgets/widgets/interface_statistics.widget.php b/usr/local/www/widgets/widgets/interface_statistics.widget.php index 22dd50f..a124ea3 100644 --- a/usr/local/www/widgets/widgets/interface_statistics.widget.php +++ b/usr/local/www/widgets/widgets/interface_statistics.widget.php @@ -40,175 +40,177 @@ require_once("pfsense-utils.inc"); require_once("functions.inc"); require_once("/usr/local/www/widgets/include/interface_statistics.inc"); - $ifdescrs = get_configured_interface_with_descr(); - - $array_in_packets = array(); - $array_out_packets = array(); - $array_in_bytes = array(); - $array_out_bytes = array(); - $array_in_errors = array(); - $array_out_errors = array(); - $array_collisions = array(); - $array_interrupt = array(); - $interfacecounter = 0; - - //build data arrays - foreach ($ifdescrs as $ifdescr => $ifname){ - $ifinfo = get_interface_info($ifdescr); - $interfacecounter++; - if ($ifinfo['status'] != "down"){ - $array_in_packets[] = $ifinfo['inpkts']; - $array_out_packets[] = $ifinfo['outpkts']; - $array_in_bytes[] = format_bytes($ifinfo['inbytes']); - $array_out_bytes[] = format_bytes($ifinfo['outbytes']); - if (isset($ifinfo['inerrs'])){ - $array_in_errors[] = $ifinfo['inerrs']; - $array_out_errors[] = $ifinfo['outerrs']; - } - else{ - $array_in_errors[] = "n/a"; - $array_out_errors[] = "n/a"; - } - if (isset($ifinfo['collisions'])) - $array_collisions[] = htmlspecialchars($ifinfo['collisions']); - else - $array_collisions[] = "n/a"; - } - - - }//end for - - - - - ?> - <div id="int_labels" style="float:left;width:32%"> - <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="interfaces statistics"> - <tr><td class="widgetsubheader" style="height:25px"> </td></tr> - <tr> - <td class="vncellt" style="height:25px">Packets In</td> - </tr> - <tr> - <td class="vncellt" style="height:25px">Packets Out</td> - </tr> - <tr> - <td class="vncellt" style="height:25px">Bytes In</td> - </tr> - <tr> - <td class="vncellt" style="height:25px">Bytes Out</td> - </tr> - <tr> - <td class="vncellt" style="height:25px">Errors In</td> - </tr> - <tr> - <td class="vncellt" style="height:25px">Errors Out</td> - </tr> - <tr> - <td class="vncellt" style="height:25px">Collisions</td> - </tr> - </table> - </div> - <div id="interfacestats" style="float:right;overflow: auto; width:68%"> - - <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="the stats"> - <tr> - <?php - $interface_names = array(); - foreach ($ifdescrs as $ifdescr => $ifname): - $ifinfo = get_interface_info($ifdescr); - if ($ifinfo['status'] != "down"){ ?> - <td class="widgetsubheader nowrap" style="height:25px"> - <?=htmlspecialchars($ifname);?> - </td> - <?php - //build array of interface names - $interface_names[] = $ifname; - } - endforeach; ?> - </tr> - - <tr> - <?php - $counter = 1; - foreach ($array_in_packets as $data): ?> - <td class="listr nowrap" id="stat<?php echo $counter?>" style="height:25px"> - <?=htmlspecialchars($data);?> - </td> - <?php - $counter = $counter + 7; - endforeach; ?> - </tr> - - <tr> - <?php - $counter = 2; - foreach ($array_out_packets as $data): ?> - <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> - <?=htmlspecialchars($data);?> - </td> - <?php - $counter = $counter + 7; - endforeach; ?> - </tr> - - <tr> - <?php - $counter = 3; - foreach ($array_in_bytes as $data): ?> - <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> - <?=htmlspecialchars($data);?> - </td> - <?php - $counter = $counter + 7; - endforeach; ?> - </tr> - - <tr> - <?php - $counter = 4; - foreach ($array_out_bytes as $data): ?> - <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> - <?=htmlspecialchars($data);?> - </td> - <?php - $counter = $counter + 7; - endforeach; ?> - </tr> - - <tr> - <?php - $counter = 5; - foreach ($array_in_errors as $data): ?> - <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> - <?=htmlspecialchars($data);?> - </td> - <?php - $counter = $counter + 7; - endforeach; ?> - </tr> - - <tr> - <?php - $counter = 6; - foreach ($array_out_errors as $data): ?> - <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> - <?=htmlspecialchars($data);?> - </td> - <?php - $counter = $counter + 7; - endforeach; ?> - </tr> - - <tr> - <?php - $counter = 7; - foreach ($array_collisions as $data): ?> - <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> - <?=htmlspecialchars($data);?> - </td> - <?php - $counter = $counter + 7; - endforeach; ?> - </tr> - </table> - </div> +$ifdescrs = get_configured_interface_with_descr(); + +$array_in_packets = array(); +$array_out_packets = array(); +$array_in_bytes = array(); +$array_out_bytes = array(); +$array_in_errors = array(); +$array_out_errors = array(); +$array_collisions = array(); +$array_interrupt = array(); +$interfacecounter = 0; + +//build data arrays +foreach ($ifdescrs as $ifdescr => $ifname) { + $ifinfo = get_interface_info($ifdescr); + $interfacecounter++; + if ($ifinfo['status'] != "down") { + $array_in_packets[] = $ifinfo['inpkts']; + $array_out_packets[] = $ifinfo['outpkts']; + $array_in_bytes[] = format_bytes($ifinfo['inbytes']); + $array_out_bytes[] = format_bytes($ifinfo['outbytes']); + if (isset($ifinfo['inerrs'])) { + $array_in_errors[] = $ifinfo['inerrs']; + $array_out_errors[] = $ifinfo['outerrs']; + } else { + $array_in_errors[] = "n/a"; + $array_out_errors[] = "n/a"; + } + if (isset($ifinfo['collisions'])) { + $array_collisions[] = htmlspecialchars($ifinfo['collisions']); + } else { + $array_collisions[] = "n/a"; + } + } +} //end for + + + + +?> + <div id="int_labels" style="float:left;width:32%"> + <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="interfaces statistics"> + <tr> + <td class="widgetsubheader" style="height:25px"> </td> + </tr> + <tr> + <td class="vncellt" style="height:25px">Packets In</td> + </tr> + <tr> + <td class="vncellt" style="height:25px">Packets Out</td> + </tr> + <tr> + <td class="vncellt" style="height:25px">Bytes In</td> + </tr> + <tr> + <td class="vncellt" style="height:25px">Bytes Out</td> + </tr> + <tr> + <td class="vncellt" style="height:25px">Errors In</td> + </tr> + <tr> + <td class="vncellt" style="height:25px">Errors Out</td> + </tr> + <tr> + <td class="vncellt" style="height:25px">Collisions</td> + </tr> + </table> + </div> + <div id="interfacestats" style="float:right;overflow: auto; width:68%"> + <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="the stats"> + <tr> + <?php + $interface_names = array(); + foreach ($ifdescrs as $ifdescr => $ifname): + $ifinfo = get_interface_info($ifdescr); + if ($ifinfo['status'] != "down") { ?> + <td class="widgetsubheader nowrap" style="height:25px"> + <?=htmlspecialchars($ifname);?> + </td> + <?php + //build array of interface names + $interface_names[] = $ifname; + } + endforeach; + ?> + </tr> + + <tr> + <?php + $counter = 1; + foreach ($array_in_packets as $data): + ?> + <td class="listr nowrap" id="stat<?php echo $counter?>" style="height:25px"> + <?=htmlspecialchars($data);?> + </td> + <?php + $counter = $counter + 7; + endforeach; + ?> + </tr> + + <tr> + <?php + $counter = 2; + foreach ($array_out_packets as $data): ?> + <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> + <?=htmlspecialchars($data);?> + </td> + <?php + $counter = $counter + 7; + endforeach; ?> + </tr> + + <tr> + <?php + $counter = 3; + foreach ($array_in_bytes as $data): ?> + <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> + <?=htmlspecialchars($data);?> + </td> + <?php + $counter = $counter + 7; + endforeach; ?> + </tr> + + <tr> + <?php + $counter = 4; + foreach ($array_out_bytes as $data): ?> + <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> + <?=htmlspecialchars($data);?> + </td> + <?php + $counter = $counter + 7; + endforeach; ?> + </tr> + + <tr> + <?php + $counter = 5; + foreach ($array_in_errors as $data): ?> + <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> + <?=htmlspecialchars($data);?> + </td> + <?php + $counter = $counter + 7; + endforeach; ?> + </tr> + + <tr> + <?php + $counter = 6; + foreach ($array_out_errors as $data): ?> + <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> + <?=htmlspecialchars($data);?> + </td> + <?php + $counter = $counter + 7; + endforeach; ?> + </tr> + + <tr> + <?php + $counter = 7; + foreach ($array_collisions as $data): ?> + <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> + <?=htmlspecialchars($data);?> + </td> + <?php + $counter = $counter + 7; + endforeach; ?> + </tr> + </table> + </div> diff --git a/usr/local/www/widgets/widgets/interfaces.widget.php b/usr/local/www/widgets/widgets/interfaces.widget.php index be790e8..e49a030 100644 --- a/usr/local/www/widgets/widgets/interfaces.widget.php +++ b/usr/local/www/widgets/widgets/interfaces.widget.php @@ -51,12 +51,14 @@ foreach ($ifdescrs as $ifdescr => $ifname): if ($ifinfo['ppplink']) { $icon = '3g'; } else if (is_interface_wireless($ifdescr)) { - if($ifinfo['status'] == "associated") + if ($ifinfo['status'] == "associated") { $icon = 'wlan'; - else + } else { $icon = 'wlan_d'; - } else + } + } else { $icon = 'cablenic'; + } if ($ifinfo['status'] == "up" || $ifinfo['status'] == "associated") { $known_status = true; @@ -73,8 +75,9 @@ foreach ($ifdescrs as $ifdescr => $ifname): $up_display = "none"; $down_display = "none"; $block_display = "inline"; - } else + } else { $known_status = false; + } ?> <tr> <td class="vncellt" rowspan="2"> @@ -83,8 +86,9 @@ foreach ($ifdescrs as $ifdescr => $ifname): <u><?=htmlspecialchars($ifname);?></u> </span> <?php - if ($ifinfo['dhcplink']) + if ($ifinfo['dhcplink']) { echo "<br />(DHCP)"; + } ?> </td> <?php diff --git a/usr/local/www/widgets/widgets/ipsec.widget.php b/usr/local/www/widgets/widgets/ipsec.widget.php index d53adf8..49250ce 100644 --- a/usr/local/www/widgets/widgets/ipsec.widget.php +++ b/usr/local/www/widgets/widgets/ipsec.widget.php @@ -39,7 +39,8 @@ require_once("guiconfig.inc"); require_once("functions.inc"); require_once("ipsec.inc"); -if (isset($config['ipsec']['phase1'])) { ?> +if (isset($config['ipsec']['phase1'])) { +?> <div> </div> <?php $tab_array = array(); @@ -63,30 +64,36 @@ if (isset($config['ipsec']['phase1'])) { ?> } else if (!is_array($ipsec_status['query']['ikesalist'])) { $ipsec_status['query']['ikesalist'] = array(); $ipsec_status['query']['ikesalist']['ikesa'] = array(); - } else if (!is_array($ipsec_status['query']['ikesalist']['ikesa'])) + } else if (!is_array($ipsec_status['query']['ikesalist']['ikesa'])) { $ipsec_status['query']['ikesalist']['ikesa'] = array(); + } $ipsec_detail_array = array(); $ikenum = array(); if (isset($config['ipsec']['phase2'])) { foreach ($config['ipsec']['phase2'] as $ph2ent) { - if (!ipsec_lookup_phase1($ph2ent,$ph1ent)) + if (!ipsec_lookup_phase1($ph2ent,$ph1ent)) { continue; + } - if ($ph2ent['remoteid']['type'] == "mobile" || isset($ph1ent['mobile'])) + if ($ph2ent['remoteid']['type'] == "mobile" || isset($ph1ent['mobile'])) { continue; - if (isset($ph1ent['disabled']) || isset($ph2ent['disabled'])) + } + if (isset($ph1ent['disabled']) || isset($ph2ent['disabled'])) { continue; + } if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == 'ikev1') { - if (!isset($ikenum[$ph1ent['ikeid']])) + if (!isset($ikenum[$ph1ent['ikeid']])) { $ikenum[$ph1ent['ikeid']] = 0; - else + } else { $ikenum[$ph1ent['ikeid']]++; + } $ikeid = "con{$ph1ent['ikeid']}00" . $ikenum[$ph1ent['ikeid']]; } else { - if (isset($ikenum[$ph1ent['ikeid']])) + if (isset($ikenum[$ph1ent['ikeid']])) { continue; + } $ikeid = "con{$ph1ent['ikeid']}"; $ikenum[$ph1ent['ikeid']] = true; } @@ -94,7 +101,7 @@ if (isset($config['ipsec']['phase1'])) { ?> $found = false; foreach ($ipsec_status['query']['ikesalist']['ikesa'] as $ikesa) { if (isset($ikesa['childsalist']) && isset($ikesa['childsalist']['childsa'])) { - foreach($ikesa['childsalist']['childsa'] as $childsa) { + foreach ($ikesa['childsalist']['childsa'] as $childsa) { if ($ikeid == $childsa['childconfig']) { $found = true; break; @@ -134,22 +141,23 @@ if (isset($config['ipsec']['phase1'])) { ?> unset($ikenum); } - if (isset($config['ipsec']['phase2'])) { ?> +if (isset($config['ipsec']['phase2'])) { +?> <div id="ipsec-Overview" style="display:block;background-color:#EEEEEE;"> <div> - <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="heading"> - <tr> - <td class="listhdrr nowrap">Active Tunnels</td> - <td class="listhdrr nowrap">Inactive Tunnels</td> - <td class="listhdrr nowrap">Mobile Users</td> - </tr> - <tr> - <td class="listlr"><?php echo $activecounter; ?></td> - <td class="listr"><?php echo $inactivecounter; ?></td> - <td class="listr"><?php if (is_array($mobile['pool'])) echo htmlspecialchars($mobile['pool'][0]['usage']); else echo 0; ?></td> - </tr> - </table> + <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="heading"> + <tr> + <td class="listhdrr nowrap">Active Tunnels</td> + <td class="listhdrr nowrap">Inactive Tunnels</td> + <td class="listhdrr nowrap">Mobile Users</td> + </tr> + <tr> + <td class="listlr"><?php echo $activecounter; ?></td> + <td class="listr"><?php echo $inactivecounter; ?></td> + <td class="listr"><?php if (is_array($mobile['pool'])) echo htmlspecialchars($mobile['pool'][0]['usage']); else echo 0; ?></td> + </tr> + </table> </div> </div> @@ -163,38 +171,41 @@ if (isset($config['ipsec']['phase1'])) { ?> </div> <div style="max-height:105px;overflow:auto;"> - <?php foreach ($ipsec_detail_array as $ipsec) : ?> - - <div style="display:table-row;"> - <div class="listlr" style="display:table-cell;width:39px"> - <?php echo htmlspecialchars($ipsec['src']);?> - </div> - <div class="listr" style="display:table-cell;width:100px"> - <?php echo $ipsec['remote-subnet'];?> - <br /> - (<?php echo htmlspecialchars($ipsec['dest']);?>) - </div> - <div class="listr" style="display:table-cell;width:90px"> - <?php echo htmlspecialchars($ipsec['descr']);?> - </div> - <div class="listr" style="display:table-cell;width:37px" align="center"> - <?php + <?php + foreach ($ipsec_detail_array as $ipsec) : + ?> - if ($ipsec['status'] == "true") { - /* tunnel is up */ - $iconfn = "interface_up"; - } else { - /* tunnel is down */ - $iconfn = "interface_down"; - } + <div style="display:table-row;"> + <div class="listlr" style="display:table-cell;width:39px"> + <?php echo htmlspecialchars($ipsec['src']);?> + </div> + <div class="listr" style="display:table-cell;width:100px"> + <?php echo $ipsec['remote-subnet'];?> + <br /> + (<?php echo htmlspecialchars($ipsec['dest']);?>) + </div> + <div class="listr" style="display:table-cell;width:90px"> + <?php echo htmlspecialchars($ipsec['descr']);?> + </div> + <div class="listr" style="display:table-cell;width:37px" align="center"> + <?php + if ($ipsec['status'] == "true") { + /* tunnel is up */ + $iconfn = "interface_up"; + } else { + /* tunnel is down */ + $iconfn = "interface_down"; + } - echo "<img src ='/themes/{$g['theme']}/images/icons/icon_{$iconfn}.gif' alt='Tunnel status' width='11' height='11' />"; - ?> + echo "<img src ='/themes/{$g['theme']}/images/icons/icon_{$iconfn}.gif' alt='Tunnel status' width='11' height='11' />"; + ?> + </div> </div> + <?php + endforeach; + ?> </div> - <?php endforeach; ?> </div> - </div> </div> <div id="ipsec-mobile" style="display:none;background-color:#EEEEEE;"> <div style="padding: 10px"> @@ -206,47 +217,49 @@ if (isset($config['ipsec']['phase1'])) { ?> <div style="max-height:105px;overflow:auto;"> <?php if (is_array($mobile['pool'])): - foreach ($mobile['pool'] as $pool): - if (is_array($pool['lease'])): - foreach ($pool['lease'] as $muser) : ?> - <div style="display:table-row;"> - <div class="listlr" style="display:table-cell;width:139px"> - <?php echo htmlspecialchars($muser['id']);?><br /> - </div> - <div class="listr" style="display:table-cell;width:130px"> - <?php echo htmlspecialchars($muser['host']);?><br /> - </div> - <div class="listr" style="display:table-cell;width:30px"> - <?php echo htmlspecialchars($muser['status']);?><br/> + foreach ($mobile['pool'] as $pool): + if (is_array($pool['lease'])): + foreach ($pool['lease'] as $muser) : +?> + <div style="display:table-row;"> + <div class="listlr" style="display:table-cell;width:139px"> + <?php echo htmlspecialchars($muser['id']);?><br /> + </div> + <div class="listr" style="display:table-cell;width:130px"> + <?php echo htmlspecialchars($muser['host']);?><br /> + </div> + <div class="listr" style="display:table-cell;width:30px"> + <?php echo htmlspecialchars($muser['status']);?><br/> + </div> </div> - </div> <?php - endforeach; - endif; - endforeach; + endforeach; + endif; + endforeach; endif; ?> </div> </div> </div> -<?php //end ipsec tunnel -}//end if tunnels are configured, else show code below -else { ?> +<?php // end if tunnels are configured, else show code below +} else { +?> <div style="display:block"> - <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="note"> - <tr> - <td colspan="4"> - <span class="vexpl"> - <span class="red"> - <strong> - Note: There are no configured IPsec Tunnels<br /> - </strong> - </span> - You can configure your IPsec - <a href="vpn_ipsec.php">here</a>. - </span> - </td> - </tr> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="note"> + <tr> + <td colspan="4"> + <span class="vexpl"> + <span class="red"> + <strong> + Note: There are no configured IPsec Tunnels<br /> + </strong> + </span> + You can configure your IPsec <a href="vpn_ipsec.php">here</a>. + </span> + </td> + </tr> </table> </div> -<?php } ?> +<?php +} +?> diff --git a/usr/local/www/widgets/widgets/load_balancer_status.widget.php b/usr/local/www/widgets/widgets/load_balancer_status.widget.php index 098a028..f5ddda9 100644 --- a/usr/local/www/widgets/widgets/load_balancer_status.widget.php +++ b/usr/local/www/widgets/widgets/load_balancer_status.widget.php @@ -60,8 +60,9 @@ $relay_hosts = get_lb_summary(); $lb_logfile = "{$g['varlog_path']}/relayd.log"; $nentries = $config['syslog']['nentries']; -if (!$nentries) +if (!$nentries) { $nentries = 50; +} ?> @@ -71,7 +72,10 @@ if (!$nentries) <td width="10%" class="listhdrr">Pool</td> <td width="30%" class="listhdr">Description</td> </tr> - <?php $i = 0; foreach ($a_vs as $vsent): ?> +<?php +$i = 0; +foreach ($a_vs as $vsent): +?> <tr> <?php switch (trim($rdr_a[$vsent['name']]['status'])) { @@ -85,7 +89,7 @@ if (!$nentries) break; default: $bgcolor = "#D3D3D3"; // lightgray - $rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?'; + $rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?'; } ?> <td class="listlr"> @@ -94,54 +98,58 @@ if (!$nentries) <?=$vsent['ipaddr'].":".$vsent['port'];?><br /> </td> <td class="listr" align="center" > - <table border="0" cellpadding="0" cellspacing="2" summary="status"> - <?php - foreach ($a_pool as $pool) { - if ($pool['name'] == $vsent['poolname']) { - $pool_hosts=array(); - foreach ((array) $pool['servers'] as $server) { - $svr['ip']['addr']=$server; - $svr['ip']['state']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['state']; - $svr['ip']['avail']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['avail']; - $pool_hosts[]=$svr; - } - foreach ((array) $pool['serversdisabled'] as $server) { - $svr['ip']['addr']="$server"; - $svr['ip']['state']='disabled'; - $svr['ip']['avail']='disabled'; - $pool_hosts[]=$svr; - } - asort($pool_hosts); - foreach ((array) $pool_hosts as $server) { - if($server['ip']['addr']!="") { - switch ($server['ip']['state']) { - case 'up': - $bgcolor = "#90EE90"; // lightgreen - $checked = "checked"; - break; - case 'disabled': - $bgcolor = "#FFFFFF"; // white - $checked = ""; - break; - default: - $bgcolor = "#F08080"; // lightcoral - $checked = "checked"; + <table border="0" cellpadding="0" cellspacing="2" summary="status"> + <?php + foreach ($a_pool as $pool) { + if ($pool['name'] == $vsent['poolname']) { + $pool_hosts=array(); + foreach ((array) $pool['servers'] as $server) { + $svr['ip']['addr']=$server; + $svr['ip']['state']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['state']; + $svr['ip']['avail']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['avail']; + $pool_hosts[]=$svr; + } + foreach ((array) $pool['serversdisabled'] as $server) { + $svr['ip']['addr']="$server"; + $svr['ip']['state']='disabled'; + $svr['ip']['avail']='disabled'; + $pool_hosts[]=$svr; + } + asort($pool_hosts); + foreach ((array) $pool_hosts as $server) { + if ($server['ip']['addr']!="") { + switch ($server['ip']['state']) { + case 'up': + $bgcolor = "#90EE90"; // lightgreen + $checked = "checked"; + break; + case 'disabled': + $bgcolor = "#FFFFFF"; // white + $checked = ""; + break; + default: + $bgcolor = "#F08080"; // lightcoral + $checked = "checked"; + } + echo "<tr>"; + echo "<td bgcolor=\"{$bgcolor}\"> {$server['ip']['addr']}:{$pool['port']} </td><td bgcolor=\"{$bgcolor}\"> "; + if ($server['ip']['avail']) { + echo " ({$server['ip']['avail']}) "; + } + echo " </td></tr>"; } - echo "<tr>"; - echo "<td bgcolor=\"{$bgcolor}\"> {$server['ip']['addr']}:{$pool['port']} </td><td bgcolor=\"{$bgcolor}\"> "; - if($server['ip']['avail']) - echo " ({$server['ip']['avail']}) "; - echo " </td></tr>"; } } } - } - ?> - </table> + ?> + </table> </td> <td class="listbg" > <font color="#FFFFFF"><?=$vsent['descr'];?></font> </td> </tr> - <?php $i++; endforeach; ?> +<?php + $i++; +endforeach; +?> </table> diff --git a/usr/local/www/widgets/widgets/log.widget.php b/usr/local/www/widgets/widgets/log.widget.php index 1bbd086..47a522c 100644 --- a/usr/local/www/widgets/widgets/log.widget.php +++ b/usr/local/www/widgets/widgets/log.widget.php @@ -16,7 +16,7 @@ 1. Redistributions of source code must retain the above copyright notice, 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. @@ -42,24 +42,32 @@ require_once("functions.inc"); /* In an effort to reduce duplicate code, many shared functions have been moved here. */ require_once("filter_log.inc"); -if(is_numeric($_POST['filterlogentries'])) { +if (is_numeric($_POST['filterlogentries'])) { $config['widgets']['filterlogentries'] = $_POST['filterlogentries']; $acts = array(); - if ($_POST['actpass']) $acts[] = "Pass"; - if ($_POST['actblock']) $acts[] = "Block"; - if ($_POST['actreject']) $acts[] = "Reject"; + if ($_POST['actpass']) { + $acts[] = "Pass"; + } + if ($_POST['actblock']) { + $acts[] = "Block"; + } + if ($_POST['actreject']) { + $acts[] = "Reject"; + } - if (!empty($acts)) + if (!empty($acts)) { $config['widgets']['filterlogentriesacts'] = implode(" ", $acts); - else + } else { unset($config['widgets']['filterlogentriesacts']); + } unset($acts); - if( ($_POST['filterlogentriesinterfaces']) and ($_POST['filterlogentriesinterfaces'] != "All") ) + if (($_POST['filterlogentriesinterfaces']) and ($_POST['filterlogentriesinterfaces'] != "All")) { $config['widgets']['filterlogentriesinterfaces'] = trim($_POST['filterlogentriesinterfaces']); - else + } else { unset($config['widgets']['filterlogentriesinterfaces']); + } write_config("Saved Filter Log Entries via Dashboard"); Header("Location: /"); @@ -97,17 +105,18 @@ var isPaused = false; var nentries = <?php echo $nentries; ?>; <?php -if(isset($config['syslog']['reverse'])) +if (isset($config['syslog']['reverse'])) { echo "var isReverse = true;\n"; -else +} else { echo "var isReverse = false;\n"; +} ?> /* Called by the AJAX updater */ function format_log_line(row) { var rrText = "<?php echo gettext("Reverse Resolve with DNS"); ?>"; - if ( row[8] == '6' ) { + if (row[8] == '6') { srcIP = '[' + row[3] + ']'; dstIP = '[' + row[5] + ']'; } else { @@ -115,14 +124,16 @@ function format_log_line(row) { 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 = '<td class="listMRlr" align="center">' + row[0] + '</td>' + '<td class="listMRr ellipsis" title="' + row[1] + '">' + row[1].slice(0,-3) + '</td>' + @@ -136,8 +147,12 @@ function format_log_line(row) { var Action = row[0].match(/alt=.*?(pass|block|reject)/i).join("").match(/pass|block|reject/i).join(""); var Interface = row[2]; - if ( !(in_arrayi(Action, nentriesacts.replace (/\s+/g, ',').split(',') ) ) && (nentriesacts != 'All') ) return false; - if ( !(in_arrayi(Interface, nentriesinterfaces.replace(/\s+/g, ',').split(',') ) ) && (nentriesinterfaces != 'All') ) return false; + if (!(in_arrayi(Action, nentriesacts.replace (/\s+/g, ',').split(','))) && (nentriesacts != 'All')) { + return false; + } + if (!(in_arrayi(Interface, nentriesinterfaces.replace(/\s+/g, ',').split(','))) && (nentriesinterfaces != 'All')) { + return false; + } return line; } @@ -157,7 +172,9 @@ function format_log_line(row) { <?php $Include_Act = explode(" ", $nentriesacts); - if ($nentriesinterfaces == "All") $nentriesinterfaces = ""; + if ($nentriesinterfaces == "All") { + $nentriesinterfaces = ""; + } ?> <input id="actpass" name="actpass" type="checkbox" value="Pass" <?php if (in_arrayi('Pass', $Include_Act)) echo "checked=\"checked\""; ?> /> Pass <input id="actblock" name="actblock" type="checkbox" value="Block" <?php if (in_arrayi('Block', $Include_Act)) echo "checked=\"checked\""; ?> /> Block @@ -205,25 +222,27 @@ function format_log_line(row) { <?php $rowIndex = 0; foreach ($filterlog as $filterent): - $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; - $rowIndex++; - if ($filterent['version'] == '6') { - $srcIP = "[" . htmlspecialchars($filterent['srcip']) . "]"; - $dstIP = "[" . htmlspecialchars($filterent['dstip']) . "]"; - } else { - $srcIP = htmlspecialchars($filterent['srcip']); - $dstIP = htmlspecialchars($filterent['dstip']); - } - - if ($filterent['srcport']) - $srcPort = ":" . htmlspecialchars($filterent['srcport']); - else - $srcPort = ""; - - if ($filterent['dstport']) - $dstPort = ":" . htmlspecialchars($filterent['dstport']); - else - $dstPort = ""; + $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; + $rowIndex++; + if ($filterent['version'] == '6') { + $srcIP = "[" . htmlspecialchars($filterent['srcip']) . "]"; + $dstIP = "[" . htmlspecialchars($filterent['dstip']) . "]"; + } else { + $srcIP = htmlspecialchars($filterent['srcip']); + $dstIP = htmlspecialchars($filterent['dstip']); + } + + if ($filterent['srcport']) { + $srcPort = ":" . htmlspecialchars($filterent['srcport']); + } else { + $srcPort = ""; + } + + if ($filterent['dstport']) { + $dstPort = ":" . htmlspecialchars($filterent['dstport']); + } else { + $dstPort = ""; + } ?> <tr class="<?=$evenRowClass?>"> @@ -241,11 +260,14 @@ function format_log_line(row) { <a href="diag_dns.php?host=<?php echo "{$filterent['dstip']}"; ?>" title="<?=gettext("Reverse Resolve with DNS");?>"> <?php echo $dstIP;?></a><?php echo $dstPort;?></td> <?php - if ($filterent['proto'] == "TCP") + if ($filterent['proto'] == "TCP") { $filterent['proto'] .= ":{$filterent['tcpflags']}"; + } ?> </tr> - <?php endforeach; ?> + <?php + endforeach; + ?> </tbody> </table> diff --git a/usr/local/www/widgets/widgets/ntp_status.widget.php b/usr/local/www/widgets/widgets/ntp_status.widget.php index a444f32..64522be 100644 --- a/usr/local/www/widgets/widgets/ntp_status.widget.php +++ b/usr/local/www/widgets/widgets/ntp_status.widget.php @@ -41,12 +41,13 @@ require_once("functions.inc"); require_once("/usr/local/www/widgets/include/ntp_status.inc"); -if($_REQUEST['updateme']) { +if ($_REQUEST['updateme']) { //this block displays only on ajax refresh - if (isset($config['system']['ipv6allow'])) + if (isset($config['system']['ipv6allow'])) { $inet_version = ""; - else + } else { $inet_version = " -4"; + } exec("/usr/local/sbin/ntpq -pn $inet_version | /usr/bin/tail +3", $ntpq_output); $ntpq_counter = 0; @@ -88,7 +89,7 @@ if($_REQUEST['updateme']) { $gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1); $gps_la = $gps_vars[4]; $gps_lo = $gps_vars[6]; - }elseif (substr($tmp, 0, 6) == '$GPGGA') { + } elseif (substr($tmp, 0, 6) == '$GPGGA') { $gps_vars = explode(",", $tmp); $gps_ok = $gps_vars[6]; $gps_lat_deg = substr($gps_vars[2], 0, 2); @@ -104,7 +105,7 @@ if($_REQUEST['updateme']) { $gps_sat = $gps_vars[7]; $gps_la = $gps_vars[3]; $gps_lo = $gps_vars[5]; - }elseif (substr($tmp, 0, 6) == '$GPGLL') { + } elseif (substr($tmp, 0, 6) == '$GPGLL') { $gps_vars = explode(",", $tmp); $gps_ok = ($gps_vars[6] == "A"); $gps_lat_deg = substr($gps_vars[1], 0, 2); @@ -124,9 +125,9 @@ if($_REQUEST['updateme']) { if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && (isset($gps_ok))) { //GSV message is only enabled by init commands in services_ntpd_gps.php for SureGPS board $gpsport = fopen("/dev/gps0", "r+"); - while($gpsport){ + while ($gpsport) { $buffer = fgets($gpsport); - if(substr($buffer, 0, 6)=='$GPGSV'){ + if (substr($buffer, 0, 6)=='$GPGSV') { //echo $buffer."\n"; $gpgsv = explode(',',$buffer); $gps_satview = $gpgsv[3]; @@ -153,20 +154,31 @@ if($_REQUEST['updateme']) { <td width="40%" class="vncellt">Clock location</td> <td width="60%" class="listr"> <a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>"> - <?php - echo sprintf("%.5f", $gps_lat) . " " . $gps_la . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lo; ?> + <?php + echo sprintf("%.5f", $gps_lat) . " " . $gps_la . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lo; + ?> </a> - <?php if (isset($gps_alt)) {echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)";} ?> + <?php + if (isset($gps_alt)) { + echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)"; + } + ?> </td> </tr> <?php if (isset($gps_sat) || isset($gps_satview)): ?> <tr> <td width="40%" class="vncellt">Satellites</td> <td width="60%" class="listr"> - <?php - if (isset($gps_satview)) {echo 'in view ' . intval($gps_satview);} - if (isset($gps_sat) && isset($gps_satview)) {echo ', ';} - if (isset($gps_sat)) {echo 'in use ' . $gps_sat;} + <?php + if (isset($gps_satview)) { + echo 'in view ' . intval($gps_satview); + } + if (isset($gps_sat) && isset($gps_satview)) { + echo ', '; + } + if (isset($gps_sat)) { + echo 'in use ' . $gps_sat; + } ?> </td> </tr> @@ -174,7 +186,7 @@ if($_REQUEST['updateme']) { <?php endif; ?> </tbody> </table> -<?php +<?php exit; } @@ -205,11 +217,11 @@ function getServerDateItems($inDate) { } function clockDateString($inDate) { - return date('Y. F j l',$inDate); // eg "Monday, January 1, 2002" + return date('Y. F j l',$inDate); // eg "Monday, January 1, 2002" } function clockTimeString($inDate, $showSeconds) { - return date($showSeconds ? 'G:i:s' : 'g:i',$inDate).' '; + return date($showSeconds ? 'G:i:s' : 'g:i',$inDate).' '; } /*** Clock -- end of server-side support code ***/ ?> @@ -273,7 +285,7 @@ History: 1.0 2000-05-09 GIF-image digits cookies to work around Win IE stale-time bug 2.1 2002-10-12 Noted Mozilla 1.0 compatibility; released PHP version. 2.1.1 2002-10-20 Fixed octal bug in the PHP translation; the number of - minutes & seconds were misinterpretes when less than 10 + minutes & seconds were misinterpreted when less than 10 2.1.2 2003-08-07 The previous fix had introduced a bug when the minutes or seconds were exactly 0. Thanks to Man Bui for reporting the bug. @@ -287,73 +299,70 @@ var clockTimerID = null; function clockInit(localDateObject, serverDateObject) { - var origRemoteClock = parseInt(clockGetCookieData("remoteClock")); - var origLocalClock = parseInt(clockGetCookieData("localClock")); - var newRemoteClock = serverDateObject.getTime(); - // May be stale (WinIE); will check against cookie later - // Can't use the millisec. ctor here because of client inconsistencies. - var newLocalClock = localDateObject.getTime(); - var maxClockAge = 60 * 60 * 1000; // get new time from server every 1hr - - if (newRemoteClock != origRemoteClock) { - // new clocks are up-to-date (newer than any cookies) - document.cookie = "remoteClock=" + newRemoteClock; - document.cookie = "localClock=" + newLocalClock; - clockOffset = newRemoteClock - newLocalClock; - clockExpirationLocal = newLocalClock + maxClockAge; - localTime = newLocalClock; // to keep clockUpdate() happy - } - else if (origLocalClock != origLocalClock) { - // error; localClock cookie is invalid (parsed as NaN) - clockOffset = null; - clockExpirationLocal = null; - } - else { - // fall back to clocks in cookies - clockOffset = origRemoteClock - origLocalClock; - clockExpirationLocal = origLocalClock + maxClockAge; - localTime = origLocalClock; - // so clockUpdate() will reload if newLocalClock - // is earlier (clock was reset) - } - /* Reload page at server midnight to display the new date, - by expiring the clock then */ - var nextDayLocal = (new Date(serverDateObject.getFullYear(), - serverDateObject.getMonth(), - serverDateObject.getDate() + 1)).getTime() - clockOffset; - if (nextDayLocal < clockExpirationLocal) { - clockExpirationLocal = nextDayLocal; - } + var origRemoteClock = parseInt(clockGetCookieData("remoteClock")); + var origLocalClock = parseInt(clockGetCookieData("localClock")); + var newRemoteClock = serverDateObject.getTime(); + // May be stale (WinIE); will check against cookie later + // Can't use the millisec. ctor here because of client inconsistencies. + var newLocalClock = localDateObject.getTime(); + var maxClockAge = 60 * 60 * 1000; // get new time from server every 1hr + + if (newRemoteClock != origRemoteClock) { + // new clocks are up-to-date (newer than any cookies) + document.cookie = "remoteClock=" + newRemoteClock; + document.cookie = "localClock=" + newLocalClock; + clockOffset = newRemoteClock - newLocalClock; + clockExpirationLocal = newLocalClock + maxClockAge; + localTime = newLocalClock; // to keep clockUpdate() happy + } else if (origLocalClock != origLocalClock) { + // error; localClock cookie is invalid (parsed as NaN) + clockOffset = null; + clockExpirationLocal = null; + } else { + // fall back to clocks in cookies + clockOffset = origRemoteClock - origLocalClock; + clockExpirationLocal = origLocalClock + maxClockAge; + localTime = origLocalClock; + // so clockUpdate() will reload if newLocalClock + // is earlier (clock was reset) + } + /* Reload page at server midnight to display the new date, + by expiring the clock then */ + var nextDayLocal = (new Date(serverDateObject.getFullYear(), + serverDateObject.getMonth(), + serverDateObject.getDate() + 1)).getTime() - clockOffset; + if (nextDayLocal < clockExpirationLocal) { + clockExpirationLocal = nextDayLocal; + } } function clockOnLoad() { - clockUpdate(); + clockUpdate(); } function clockOnUnload() { - clockClearTimeout(); + clockClearTimeout(); } function clockClearTimeout() { - if (clockTimerID) { - clearTimeout(clockTimerID); - clockTimerID = null; - } + if (clockTimerID) { + clearTimeout(clockTimerID); + clockTimerID = null; + } } function clockToggleSeconds() { - clockClearTimeout(); - if (clockShowsSeconds) { - clockShowsSeconds = false; - clockIncrementMillis = 60000; - } - else { - clockShowsSeconds = true; - clockIncrementMillis = 1000; - } - clockUpdate(); + clockClearTimeout(); + if (clockShowsSeconds) { + clockShowsSeconds = false; + clockIncrementMillis = 60000; + } else { + clockShowsSeconds = true; + clockIncrementMillis = 1000; + } + clockUpdate(); } function clockTimeString(inHours, inMinutes, inSeconds) { @@ -363,57 +372,56 @@ function clockTimeString(inHours, inMinutes, inSeconds) { } function clockDisplayTime(inHours, inMinutes, inSeconds) { - - clockWriteToDiv("ClockTime", clockTimeString(inHours, inMinutes, inSeconds)); + clockWriteToDiv("ClockTime", clockTimeString(inHours, inMinutes, inSeconds)); } function clockWriteToDiv(divName, newValue) // APS 6/29/00 { - var divObject = simpleFindObj(divName); - newValue = '<b>' + newValue + '<' + '/b>'; - if (divObject && divObject.innerHTML) { - divObject.innerHTML = newValue; - } - else if (divObject && divObject.document) { - divObject.document.writeln(newValue); - divObject.document.close(); - } - // else divObject wasn't found; it's only a clock, so don't bother complaining + var divObject = simpleFindObj(divName); + newValue = '<b>' + newValue + '<' + '/b>'; + if (divObject && divObject.innerHTML) { + divObject.innerHTML = newValue; + } else if (divObject && divObject.document) { + divObject.document.writeln(newValue); + divObject.document.close(); + } + // else divObject wasn't found; it's only a clock, so don't bother complaining } function clockGetCookieData(label) { - /* find the value of the specified cookie in the document's - semicolon-delimited collection. For IE Win98 compatibility, search - from the end of the string (to find most specific host/path) and - don't require "=" between cookie name & empty cookie values. Returns - null if cookie not found. One remaining problem: Under IE 5 [Win98], - setting a cookie with no equals sign creates a cookie with no name, - just data, which is indistinguishable from a cookie with that name - but no data but can't be overwritten by any cookie with an equals - sign. */ - var c = document.cookie; - if (c) { - var labelLen = label.length, cEnd = c.length; - while (cEnd > 0) { - var cStart = c.lastIndexOf(';',cEnd-1) + 1; - /* bug fix to Danny Goodman's code: calculate cEnd, to - prevent walking the string char-by-char & finding cookie - labels that contained the desired label as suffixes */ - // skip leading spaces - while (cStart < cEnd && c.charAt(cStart)==" ") cStart++; - if (cStart + labelLen <= cEnd && c.substr(cStart,labelLen) == label) { - if (cStart + labelLen == cEnd) { - return ""; // empty cookie value, no "=" - } - else if (c.charAt(cStart+labelLen) == "=") { - // has "=" after label - return unescape(c.substring(cStart + labelLen + 1,cEnd)); - } - } - cEnd = cStart - 1; // skip semicolon - } - } - return null; + /* find the value of the specified cookie in the document's + semicolon-delimited collection. For IE Win98 compatibility, search + from the end of the string (to find most specific host/path) and + don't require "=" between cookie name & empty cookie values. Returns + null if cookie not found. One remaining problem: Under IE 5 [Win98], + setting a cookie with no equals sign creates a cookie with no name, + just data, which is indistinguishable from a cookie with that name + but no data but can't be overwritten by any cookie with an equals + sign. */ + var c = document.cookie; + if (c) { + var labelLen = label.length, cEnd = c.length; + while (cEnd > 0) { + var cStart = c.lastIndexOf(';',cEnd-1) + 1; + /* bug fix to Danny Goodman's code: calculate cEnd, to + prevent walking the string char-by-char & finding cookie + labels that contained the desired label as suffixes */ + // skip leading spaces + while (cStart < cEnd && c.charAt(cStart)==" ") { + cStart++; + } + if (cStart + labelLen <= cEnd && c.substr(cStart,labelLen) == label) { + if (cStart + labelLen == cEnd) { + return ""; // empty cookie value, no "=" + } else if (c.charAt(cStart+labelLen) == "=") { + // has "=" after label + return unescape(c.substring(cStart + labelLen + 1,cEnd)); + } + } + cEnd = cStart - 1; // skip semicolon + } + } + return null; } /* Called regularly to update the clock display as well as onLoad (user @@ -421,38 +429,36 @@ function clockGetCookieData(label) { an immediate update) */ function clockUpdate() { - var lastLocalTime = localTime; - localTime = (new Date()).getTime(); - - /* Sanity-check the diff. in local time between successive calls; - reload if user has reset system clock */ - if (clockOffset == null) { - clockDisplayTime(null, null, null); - } - else if (localTime < lastLocalTime || clockExpirationLocal < localTime) { - /* Clock expired, or time appeared to go backward (user reset - the clock). Reset cookies to prevent infinite reload loop if - server doesn't give a new time. */ - document.cookie = 'remoteClock=-'; - document.cookie = 'localClock=-'; - location.reload(); // will refresh time values in cookies - } - else { - // Compute what time would be on server - var serverTime = new Date(localTime + clockOffset); - clockDisplayTime(serverTime.getHours(), serverTime.getMinutes(), - serverTime.getSeconds()); - - // Reschedule this func to run on next even clockIncrementMillis boundary - clockTimerID = setTimeout("clockUpdate()", - clockIncrementMillis - (serverTime.getTime() % clockIncrementMillis)); - } + var lastLocalTime = localTime; + localTime = (new Date()).getTime(); + + /* Sanity-check the diff. in local time between successive calls; + reload if user has reset system clock */ + if (clockOffset == null) { + clockDisplayTime(null, null, null); + } else if (localTime < lastLocalTime || clockExpirationLocal < localTime) { + /* Clock expired, or time appeared to go backward (user reset + the clock). Reset cookies to prevent infinite reload loop if + server doesn't give a new time. */ + document.cookie = 'remoteClock=-'; + document.cookie = 'localClock=-'; + location.reload(); // will refresh time values in cookies + } else { + // Compute what time would be on server + var serverTime = new Date(localTime + clockOffset); + clockDisplayTime(serverTime.getHours(), serverTime.getMinutes(), + serverTime.getSeconds()); + + // Reschedule this func to run on next even clockIncrementMillis boundary + clockTimerID = setTimeout("clockUpdate()", + clockIncrementMillis - (serverTime.getTime() % clockIncrementMillis)); + } } /*** End of Clock ***/ - window.onload=clockInit(clockLocalStartTime, clockServerStartTime);clockOnLoad(); - window.onunload=clockOnUnload() - clockUpdate(); +window.onload=clockInit(clockLocalStartTime, clockServerStartTime);clockOnLoad(); +window.onunload=clockOnUnload() +clockUpdate(); //]]> </script> diff --git a/usr/local/www/widgets/widgets/openvpn.widget.php b/usr/local/www/widgets/widgets/openvpn.widget.php index 75ccc3f..6f813c5 100644 --- a/usr/local/www/widgets/widgets/openvpn.widget.php +++ b/usr/local/www/widgets/widgets/openvpn.widget.php @@ -34,8 +34,8 @@ require_once("guiconfig.inc"); require_once("openvpn.inc"); /* Handle AJAX */ -if($_GET['action']) { - if($_GET['action'] == "kill") { +if ($_GET['action']) { + if ($_GET['action'] == "kill") { $port = $_GET['port']; $remipp = $_GET['remipp']; if (!empty($port) and !empty($remipp)) { @@ -67,12 +67,14 @@ function kill_client($port, $remipp) { $line = fgets($fp, 1024); $info = stream_get_meta_data($fp); - if ($info['timed_out']) + if ($info['timed_out']) { break; + } /* parse header list line */ - if (strpos($line, "INFO:") !== false) + if (strpos($line, "INFO:") !== false) { continue; + } if (strpos($line, "SUCCESS") !== false) { $killed = 0; } @@ -109,7 +111,7 @@ $clients = openvpn_get_active_clients(); function killComplete(req) { var values = req.responseText.split("|"); - if(values[3] != "0") { + if (values[3] != "0") { alert('<?=gettext("An error occurred.");?>' + ' (' + values[3] + ')'); return; } @@ -132,45 +134,46 @@ $clients = openvpn_get_active_clients(); <tr> <td> <table style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" sortableMultirow="2"> - <tr> - <td class="listhdrr">Name/Time</td> - <td class="listhdrr">Real/Virtual IP</td> - </tr> - <?php $rowIndex = 0; - foreach ($server['conns'] as $conn): + <tr> + <td class="listhdrr">Name/Time</td> + <td class="listhdrr">Real/Virtual IP</td> + </tr> + <?php + $rowIndex = 0; + foreach ($server['conns'] as $conn): $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; $rowIndex++; - ?> - <tr name='<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>' class="<?=$evenRowClass?>"> - <td class="listMRlr"> - <?=$conn['common_name'];?> - </td> - <td class="listMRr"> - <?=$conn['remote_host'];?> - </td> - <td class='listMR' rowspan="2"> - <img src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif' height='17' width='17' border='0' - onclick="killClient('<?php echo $server['mgmt']; ?>', '<?php echo $conn['remote_host']; ?>');" style='cursor:pointer;' - name='<?php echo "i:{$server['mgmt']}:{$conn['remote_host']}"; ?>' - title='Kill client connection from <?php echo $conn['remote_host']; ?>' alt='' /> - </td> - </tr> - <tr name='<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>' class="<?=$evenRowClass?>"> - <td class="listMRlr"> - <?=$conn['connect_time'];?> - </td> - <td class="listMRr"> - <?=$conn['virtual_addr'];?> - </td> - </tr> + ?> + <tr name='<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>' class="<?=$evenRowClass?>"> + <td class="listMRlr"> + <?=$conn['common_name'];?> + </td> + <td class="listMRr"> + <?=$conn['remote_host'];?> + </td> + <td class='listMR' rowspan="2"> + <img src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif' height='17' width='17' border='0' + onclick="killClient('<?php echo $server['mgmt']; ?>', '<?php echo $conn['remote_host']; ?>');" style='cursor:pointer;' + name='<?php echo "i:{$server['mgmt']}:{$conn['remote_host']}"; ?>' + title='Kill client connection from <?php echo $conn['remote_host']; ?>' alt='' /> + </td> + </tr> + <tr name='<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>' class="<?=$evenRowClass?>"> + <td class="listMRlr"> + <?=$conn['connect_time'];?> + </td> + <td class="listMRr"> + <?=$conn['virtual_addr'];?> + </td> + </tr> - <?php endforeach; ?> - <tfoot> - <tr> - <td colspan="6" class="list" height="12"></td> - </tr> - </tfoot> - </table> + <?php endforeach; ?> + <tfoot> + <tr> + <td colspan="6" class="list" height="12"></td> + </tr> + </tfoot> + </table> </td> </tr> </table> @@ -235,41 +238,41 @@ $clients = openvpn_get_active_clients(); </tr> <tr> <table style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td class="listhdrr">Name/Time</td> - <td class="listhdrr">Remote/Virtual IP</td> - </tr> + <tr> + <td class="listhdrr">Name/Time</td> + <td class="listhdrr">Remote/Virtual IP</td> + </tr> -<?php foreach ($clients as $client): ?> - <tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'> - <td class="listlr"> - <?=$client['name'];?> - </td> - <td class="listr"> - <?=$client['remote_host'];?> - </td> - <td rowspan="2" align="center"> - <?php - if ($client['status'] == "up") { - /* tunnel is up */ - $iconfn = "interface_up"; - } else { - /* tunnel is down */ - $iconfn = "interface_down"; - } - echo "<img src ='/themes/{$g['theme']}/images/icons/icon_{$iconfn}.gif' alt='' />"; - ?> - </td> - </tr> - <tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'> - <td class="listlr"> - <?=$client['connect_time'];?> - </td> - <td class="listr"> - <?=$client['virtual_addr'];?> - </td> - </tr> -<?php endforeach; ?> + <?php foreach ($clients as $client): ?> + <tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'> + <td class="listlr"> + <?=$client['name'];?> + </td> + <td class="listr"> + <?=$client['remote_host'];?> + </td> + <td rowspan="2" align="center"> + <?php + if ($client['status'] == "up") { + /* tunnel is up */ + $iconfn = "interface_up"; + } else { + /* tunnel is down */ + $iconfn = "interface_down"; + } + echo "<img src ='/themes/{$g['theme']}/images/icons/icon_{$iconfn}.gif' alt='' />"; + ?> + </td> + </tr> + <tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'> + <td class="listlr"> + <?=$client['connect_time'];?> + </td> + <td class="listr"> + <?=$client['virtual_addr'];?> + </td> + </tr> + <?php endforeach; ?> </table> </tr> </table> diff --git a/usr/local/www/widgets/widgets/picture.widget.php b/usr/local/www/widgets/widgets/picture.widget.php index 1ef9516..681634a 100644 --- a/usr/local/www/widgets/widgets/picture.widget.php +++ b/usr/local/www/widgets/widgets/picture.widget.php @@ -33,11 +33,12 @@ require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); -if($_GET['getpic']=="true") { +if ($_GET['getpic']=="true") { $pic_type_s = explode(".", $config['widgets']['picturewidget_filename']); $pic_type = $pic_type_s[1]; - if($config['widgets']['picturewidget']) + if ($config['widgets']['picturewidget']) { $data = base64_decode($config['widgets']['picturewidget']); + } header("Content-Disposition: inline; filename=\"{$config['widgets']['picturewidget_filename']}\""); header("Content-Type: image/{$pic_type}"); header("Content-Length: " . strlen($data)); @@ -45,16 +46,16 @@ if($_GET['getpic']=="true") { exit; } -if($_POST) { +if ($_POST) { if (is_uploaded_file($_FILES['pictfile']['tmp_name'])) { /* read the file contents */ $fd_pic = fopen($_FILES['pictfile']['tmp_name'], "rb"); - while ( ($buf=fread( $fd_pic, 8192 )) != '' ) { + while (($buf=fread($fd_pic, 8192)) != '') { // Here, $buf is guaranteed to contain data $data .= $buf; } fclose($fd_pic); - if(!$data) { + if (!$data) { log_error("Warning, could not read file " . $_FILES['pictfile']['tmp_name']); die("Could not read temporary file"); } else { diff --git a/usr/local/www/widgets/widgets/rss.widget.php b/usr/local/www/widgets/widgets/rss.widget.php index 4c21a29..cfe77a3 100644 --- a/usr/local/www/widgets/widgets/rss.widget.php +++ b/usr/local/www/widgets/widgets/rss.widget.php @@ -34,7 +34,7 @@ require_once("guiconfig.inc"); require_once("pfsense-utils.inc"); require_once("functions.inc"); -if($_POST['rssfeed']) { +if ($_POST['rssfeed']) { $config['widgets']['rssfeed'] = str_replace("\n", ",", htmlspecialchars($_POST['rssfeed'], ENT_QUOTES | ENT_HTML401)); $config['widgets']['rssmaxitems'] = str_replace("\n", ",", htmlspecialchars($_POST['rssmaxitems'], ENT_QUOTES | ENT_HTML401)); $config['widgets']['rsswidgetheight'] = htmlspecialchars($_POST['rsswidgetheight'], ENT_QUOTES | ENT_HTML401); @@ -44,37 +44,45 @@ if($_POST['rssfeed']) { } // Use saved feed and max items -if($config['widgets']['rssfeed']) +if ($config['widgets']['rssfeed']) { $rss_feed_s = explode(",", $config['widgets']['rssfeed']); +} -if($config['widgets']['rssmaxitems']) +if ($config['widgets']['rssmaxitems']) { $max_items = $config['widgets']['rssmaxitems']; +} -if(is_numeric($config['widgets']['rsswidgetheight'])) +if (is_numeric($config['widgets']['rsswidgetheight'])) { $rsswidgetheight = $config['widgets']['rsswidgetheight']; +} -if(is_numeric($config['widgets']['rsswidgettextlength'])) +if (is_numeric($config['widgets']['rsswidgettextlength'])) { $rsswidgettextlength = $config['widgets']['rsswidgettextlength']; +} // Set a default feed if none exists -if(!$rss_feed_s) { +if (!$rss_feed_s) { $rss_feed_s = "https://blog.pfsense.org"; $config['widgets']['rssfeed'] = "https://blog.pfsense.org"; } -if(!$max_items) +if (!$max_items) { $max_items = 10; +} -if(!$rsswidgetheight) +if (!$rsswidgetheight) { $rsswidgetheight = 300; +} -if(!$rsswidgettextlength) +if (!$rsswidgettextlength) { $rsswidgettextlength = 140; // oh twitter, how do we love thee? +} -if($config['widgets']['rssfeed']) +if ($config['widgets']['rssfeed']) { $textarea_txt = str_replace(",", "\n", $config['widgets']['rssfeed']); -else +} else { $textarea_txt = ""; +} ?> @@ -93,8 +101,9 @@ else <select name='rssmaxitems' id='rssmaxitems'> <option value='<?= $max_items ?>'><?= $max_items ?></option> <?php - for($x=100; $x<5100; $x=$x+100) + for ($x=100; $x<5100; $x=$x+100) { echo "<option value='{$x}'>{$x}</option>\n"; + } ?> </select> </td> @@ -107,8 +116,9 @@ else <select name='rsswidgetheight' id='rsswidgetheight'> <option value='<?= $rsswidgetheight ?>'><?= $rsswidgetheight ?>px</option> <?php - for($x=100; $x<5100; $x=$x+100) + for ($x=100; $x<5100; $x=$x+100) { echo "<option value='{$x}'>{$x}px</option>\n"; + } ?> </select> </td> @@ -121,8 +131,9 @@ else <select name='rsswidgettextlength' id='rsswidgettextlength'> <option value='<?= $rsswidgettextlength ?>'><?= $rsswidgettextlength ?></option> <?php - for($x=10; $x<5100; $x=$x+10) + for ($x=10; $x<5100; $x=$x+10) { echo "<option value='{$x}'>{$x}</option>\n"; + } ?> </select> </td> @@ -141,7 +152,7 @@ else <div id="rss-widgets" style="padding: 5px; height: <?=$rsswidgetheight?>px; overflow:scroll;"> <?php - if(!is_dir("/tmp/simplepie")) { + if (!is_dir("/tmp/simplepie")) { mkdir("/tmp/simplepie"); mkdir("/tmp/simplepie/cache"); } @@ -149,9 +160,10 @@ else exec("chmod a+rw /tmp/simplepie/cache/."); require_once("simplepie/simplepie.inc"); function textLimit($string, $length, $replacer = '...') { - if(strlen($string) > $length) - return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer; - return $string; + if (strlen($string) > $length) { + return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer; + } + return $string; } $feed = new SimplePie(); $feed->set_cache_location("/tmp/simplepie/"); @@ -159,7 +171,7 @@ else $feed->init(); $feed->handle_content_type(); $counter = 1; - foreach($feed->get_items() as $item) { + foreach ($feed->get_items() as $item) { $feed = $item->get_feed(); $feed->strip_htmltags(); echo "<a target='blank' href='" . $item->get_permalink() . "'>" . $item->get_title() . "</a><br />"; @@ -168,8 +180,9 @@ else echo textLimit($content, $rsswidgettextlength) . "<br />"; echo "Source: <a target='_blank' href='" . $item->get_permalink() . "'><img src='" . $feed->get_favicon() . "' alt='" . $feed->get_title() . "' title='" . $feed->get_title() . "' border='0' width='16' height='16' /></a><br />"; $counter++; - if($counter > $max_items) + if ($counter > $max_items) { break; + } echo "<hr/>"; } ?> diff --git a/usr/local/www/widgets/widgets/services_status.widget.php b/usr/local/www/widgets/widgets/services_status.widget.php index 771561b..f9f9166 100644 --- a/usr/local/www/widgets/widgets/services_status.widget.php +++ b/usr/local/www/widgets/widgets/services_status.widget.php @@ -42,7 +42,7 @@ require_once("/usr/local/www/widgets/include/services_status.inc"); $services = get_services(); -if(isset($_POST['servicestatusfilter'])) { +if (isset($_POST['servicestatusfilter'])) { $config['widgets']['servicestatusfilter'] = htmlspecialchars($_POST['servicestatusfilter'], ENT_QUOTES | ENT_HTML401); write_config("Saved Service Status Filter via Dashboard"); header("Location: ../../index.php"); @@ -69,20 +69,23 @@ $skipservices = explode(",", $config['widgets']['servicestatusfilter']); if (count($services) > 0) { uasort($services, "service_name_compare"); - foreach($services as $service) { - if((!$service['name']) || (in_array($service['name'], $skipservices)) || (!is_service_enabled($service['name']))) + foreach ($services as $service) { + if ((!$service['name']) || (in_array($service['name'], $skipservices)) || (!is_service_enabled($service['name']))) { continue; - if (empty($service['description'])) + } + if (empty($service['description'])) { $service['description'] = get_pkg_descr($service['name']); + } $service_desc = explode(".",$service['description']); echo "<tr><td class=\"listlr\">" . $service['name'] . "</td>\n"; echo "<td class=\"listr\">" . $service_desc[0] . "</td>\n"; // if service is running then listr else listbg $bgclass = null; - if (get_service_status($service)) + if (get_service_status($service)) { $bgclass = "listr"; - else + } else { $bgclass = "listbg"; + } echo "<td class=\"" . $bgclass . "\" align=\"center\">" . get_service_status_icon($service, false, true) . "</td>\n"; echo "<td valign=\"middle\" class=\"list nowrap\">" . get_service_control_links($service) . "</td></tr>\n"; } diff --git a/usr/local/www/widgets/widgets/smart_status.widget.php b/usr/local/www/widgets/widgets/smart_status.widget.php index 89509e4..87f0605 100644 --- a/usr/local/www/widgets/widgets/smart_status.widget.php +++ b/usr/local/www/widgets/widgets/smart_status.widget.php @@ -46,23 +46,23 @@ $devs = array(); ## Get all adX, daX, and adaX (IDE, SCSI, and AHCI) devices currently installed $devs = get_smart_drive_list(); -if(count($devs) > 0) { - foreach($devs as $dev) { ## for each found drive do +if (count($devs) > 0) { + foreach ($devs as $dev) { ## for each found drive do $dev_ident = exec("diskinfo -v /dev/$dev | grep ident | awk '{print $1}'"); ## get identifier from drive $dev_state = trim(exec("smartctl -H /dev/$dev | awk -F: '/^SMART overall-health self-assessment test result/ {print $2;exit} /^SMART Health Status/ {print $2;exit}'")); ## get SMART state from drive switch ($dev_state) { - case "PASSED": - case "OK": - $color = "#90EE90"; - break; - case "": - $dev_state = "Unknown"; - $color = "#C0B788"; - break; - default: - $color = "#F08080"; - break; + case "PASSED": + case "OK": + $color = "#90EE90"; + break; + case "": + $dev_state = "Unknown"; + $color = "#C0B788"; + break; + default: + $color = "#F08080"; + break; } ?> <tr> diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php index 2eed279..6143ac1 100644 --- a/usr/local/www/widgets/widgets/system_information.widget.php +++ b/usr/local/www/widgets/widgets/system_information.widget.php @@ -37,38 +37,40 @@ require_once("guiconfig.inc"); require_once('notices.inc'); include_once("includes/functions.inc.php"); -if($_REQUEST['getupdatestatus']) { - if(isset($config['system']['firmware']['disablecheck'])) { +if ($_REQUEST['getupdatestatus']) { + if (isset($config['system']['firmware']['disablecheck'])) { exit; } - if(isset($config['system']['firmware']['alturl']['enable'])) + if (isset($config['system']['firmware']['alturl']['enable'])) { $updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}"; - else + } else { $updater_url = $g['update_url']; + } $nanosize = ""; if ($g['platform'] == "nanobsd") { - if (file_exists("/etc/nano_use_vga.txt")) + if (file_exists("/etc/nano_use_vga.txt")) { $nanosize = "-nanobsd-vga-"; - else + } else { $nanosize = "-nanobsd-"; + } $nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt"))); } @unlink("/tmp/{$g['product_name']}_version"); - if (download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true) + if (download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true) { $remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version")); + } - if(empty($remote_version)) + if (empty($remote_version)) { echo "<br /><br />Unable to check for updates."; - else { + } else { $current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime")); $current_installed_version = trim(file_get_contents("/etc/version")); - if(!$remote_version) { + if (!$remote_version) { echo "<br /><br />Unable to check for updates."; - } - else { + } else { $needs_system_upgrade = false; if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) { echo "<br /><span class=\"red\" id=\"updatealert\"><b>Update available. </b></span><a href=\"/system_firmware_check.php\">Click Here</a> to view update."; @@ -77,8 +79,9 @@ if($_REQUEST['getupdatestatus']) { echo "jQuery('#updatealert').effect('pulsate',{times: 30},10000);\n"; echo "//]]>\n"; echo "</script>\n"; - } else + } else { echo "<br />You are on the latest version."; + } } } exit; @@ -91,7 +94,7 @@ $filesystems = get_mounted_filesystems(); ?> <script type="text/javascript"> //<![CDATA[ - jQuery(function() { + jQuery(function() { jQuery("#statePB").progressbar( { value: <?php echo get_pfstate(true); ?> } ); jQuery("#mbufPB").progressbar( { value: <?php echo get_mbuf(true); ?> } ); jQuery("#cpuPB").progressbar( { value:false } ); @@ -102,7 +105,7 @@ $filesystems = get_mounted_filesystems(); jQuery("#diskUsagePB<?php echo $d++; ?>").progressbar( { value: <?php echo $fs['percent_used']; ?> } ); <?PHP endforeach; ?> - <?php if($showswap == true): ?> + <?php if ($showswap == true): ?> jQuery("#swapUsagePB").progressbar( { value: <?php echo swap_usage(); ?> } ); <?php endif; ?> <?php if (get_temp() != ""): ?> @@ -125,16 +128,16 @@ $filesystems = get_mounted_filesystems(); (<?php echo php_uname("m"); ?>) <br /> built on <?php readfile("/etc/version.buildtime"); ?> - <?php if(!$g['hideuname']): ?> + <?php if (!$g['hideuname']): ?> <br /> <div id="uname"><a href="#" onclick='swapuname(); return false;'><?php echo php_uname("s") . " " . php_uname("r"); ?></a></div> <?php endif; ?> - <?php if(!isset($config['system']['firmware']['disablecheck'])): ?> + <?php if (!isset($config['system']['firmware']['disablecheck'])): ?> <div id='updatestatus'><br /><?php echo gettext("Obtaining update status"); ?> ...</div> <?php endif; ?> </td> </tr> - <?php if(!$g['hideplatform']): ?> + <?php if (!$g['hideplatform']): ?> <tr> <td width="25%" class="vncellt"><?=gettext("Platform");?></td> <td width="75%" class="listr"> @@ -167,15 +170,16 @@ $filesystems = get_mounted_filesystems(); <tr> <td width="25%" class="vncellt"><?=gettext("CPU Type");?></td> <td width="75%" class="listr"> - <?php + <?php echo (htmlspecialchars(get_single_sysctl("hw.model"))); ?> <div id="cpufreq"><?= get_cpufreq(); ?></div> - <?php $cpucount = get_cpu_count(); + <?php + $cpucount = get_cpu_count(); if ($cpucount > 1): ?> <div id="cpucount"> <?= htmlspecialchars($cpucount) ?> CPUs: <?= htmlspecialchars(get_cpu_count(true)); ?></div> - <?php endif; ?> + <?php endif; ?> </td> </tr> <?php if ($hwcrypto): ?> @@ -194,17 +198,17 @@ $filesystems = get_mounted_filesystems(); <div id="datetime"><?= date("D M j G:i:s T Y"); ?></div> </td> </tr> - <tr> - <td width="30%" class="vncellt"><?=gettext("DNS server(s)");?></td> - <td width="70%" class="listr"> - <?php - $dns_servers = get_dns_servers(); - foreach($dns_servers as $dns) { - echo "{$dns}<br />"; - } - ?> + <tr> + <td width="30%" class="vncellt"><?=gettext("DNS server(s)");?></td> + <td width="70%" class="listr"> + <?php + $dns_servers = get_dns_servers(); + foreach ($dns_servers as $dns) { + echo "{$dns}<br />"; + } + ?> </td> - </tr> + </tr> <?php if ($config['revision']): ?> <tr> <td width="25%" class="vncellt"><?=gettext("Last config change");?></td> @@ -214,7 +218,8 @@ $filesystems = get_mounted_filesystems(); <tr> <td width="25%" class="vncellt"><?=gettext("State table size");?></td> <td width="75%" class="listr"> - <?php $pfstatetext = get_pfstate(); + <?php + $pfstatetext = get_pfstate(); $pfstateusage = get_pfstate(true); ?> <div id="statePB"></div> @@ -234,16 +239,16 @@ $filesystems = get_mounted_filesystems(); <span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<span id="mbuf"><?= $mbufstext ?></span>) </td> </tr> - <?php if (get_temp() != ""): ?> - <tr> - <td width="25%" class="vncellt"><?=gettext("Temperature");?></td> + <?php if (get_temp() != ""): ?> + <tr> + <td width="25%" class="vncellt"><?=gettext("Temperature");?></td> <td width="75%" class="listr"> <?php $TempMeter = $temp = get_temp(); ?> <div id="tempPB"></div> <span id="tempmeter"><?= $temp."°C"; ?></span> </td> - </tr> - <?php endif; ?> + </tr> + <?php endif; ?> <tr> <td width="25%" class="vncellt"><?=gettext("Load average");?></td> <td width="75%" class="listr"> @@ -265,7 +270,7 @@ $filesystems = get_mounted_filesystems(); <span id="memusagemeter"><?= $memUsage.'%'; ?></span> of <?= sprintf("%.0f", get_single_sysctl('hw.physmem') / (1024*1024)) ?> MB </td> </tr> - <?php if($showswap == true): ?> + <?php if ($showswap == true): ?> <tr> <td width="25%" class="vncellt"><?=gettext("SWAP usage");?></td> <td width="75%" class="listr"> @@ -278,13 +283,13 @@ $filesystems = get_mounted_filesystems(); <tr> <td width="25%" class="vncellt"><?=gettext("Disk usage");?></td> <td width="75%" class="listr"> -<?PHP $d = 0; ?> -<?PHP foreach ($filesystems as $fs): ?> + <?php $d = 0; ?> + <?php foreach ($filesystems as $fs): ?> <div id="diskUsagePB<?php echo $d; ?>"></div> - <?PHP if (substr(basename($fs['device']), 0, 2) == "md") $fs['type'] .= " in RAM"; ?> - <?PHP echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> of <?PHP echo $fs['total_size'];?> + <?php if (substr(basename($fs['device']), 0, 2) == "md") $fs['type'] .= " in RAM"; ?> + <?php echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> of <?PHP echo $fs['total_size'];?> <br /> -<?PHP endforeach; ?> + <?php endforeach; ?> </td> </tr> </tbody> @@ -294,7 +299,7 @@ $filesystems = get_mounted_filesystems(); function swapuname() { jQuery('#uname').html("<?php echo php_uname("a"); ?>"); } - <?php if(!isset($config['system']['firmware']['disablecheck'])): ?> + <?php if (!isset($config['system']['firmware']['disablecheck'])): ?> function getstatus() { scroll(0,0); var url = "/widgets/widgets/system_information.widget.php"; diff --git a/usr/local/www/widgets/widgets/thermal_sensors.widget.php b/usr/local/www/widgets/widgets/thermal_sensors.widget.php index f451197..00a1bf1 100644 --- a/usr/local/www/widgets/widgets/thermal_sensors.widget.php +++ b/usr/local/www/widgets/widgets/thermal_sensors.widget.php @@ -40,9 +40,9 @@ require_once("/usr/local/www/widgets/include/thermal_sensors.inc"); //========================================================================= //called by showThermalSensorsData() (jQuery Ajax call) in thermal_sensors.js if (isset($_GET["getThermalSensorsData"])) { - //get Thermal Sensors data and return - echo getThermalSensorsData(); - return; + //get Thermal Sensors data and return + echo getThermalSensorsData(); + return; } //========================================================================= @@ -86,11 +86,9 @@ function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $cr $criticalValue = (int) $postArray[$criticalValueKey]; } - if ( - ($warningValue >= MIN_THRESHOLD_VALUE && $warningValue <= MAX_THRESHOLD_VALUE) && - ($criticalValue >= MIN_THRESHOLD_VALUE && $criticalValue <= MAX_THRESHOLD_VALUE) && - ($warningValue < $criticalValue) - ) { + if (($warningValue >= MIN_THRESHOLD_VALUE && $warningValue <= MAX_THRESHOLD_VALUE) && + ($criticalValue >= MIN_THRESHOLD_VALUE && $criticalValue <= MAX_THRESHOLD_VALUE) && + ($warningValue < $criticalValue)) { //all validated ok, save to config array $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$warningValueKey] = $warningValue; $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$criticalValueKey] = $criticalValue; @@ -98,7 +96,7 @@ function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $cr } function saveGraphDisplaySettings(&$configArray, &$postArray, $valueKey) { - $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey] = isset($postArray[$valueKey]) ? 1 : 0; + $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey] = isset($postArray[$valueKey]) ? 1 : 0; } //========================================================================= @@ -172,95 +170,95 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) { <form action="/widgets/widgets/thermal_sensors.widget.php" method="post" id="iform_thermal_sensors_settings" name="iform_thermal_sensors_settings"> <table width="100%" border="0" summary="thermal sensors widget"> <tr> - <td align="left" colspan="2"> - <span style="font-weight: bold" >Thresholds in °C (1 to 100):</span> - </td> - <td align="right" colspan="1"> - <span style="font-weight: bold" >Display settings:</span> - </td> + <td align="left" colspan="2"> + <span style="font-weight: bold" >Thresholds in °C (1 to 100):</span> + </td> + <td align="right" colspan="1"> + <span style="font-weight: bold" >Display settings:</span> + </td> </tr> <tr> - <td align="right"> - Zone Warning: - </td> - <td> - <input type="text" maxlength="3" size="3" class="formfld unknown" - name="thermal_sensors_widget_zone_warning_threshold" - id="thermal_sensors_widget_zone_warning_threshold" - value="<?= $thermal_sensors_widget_zoneWarningTempThreshold; ?>" /> - </td> - <td align="right"> - <label for="thermal_sensors_widget_show_raw_output">Show raw output (no graph): </label> - <input type="checkbox" - id="thermal_sensors_widget_show_raw_output" - name="thermal_sensors_widget_show_raw_output" - value="<?= $thermal_sensors_widget_showRawOutput; ?>" <?= ($thermal_sensors_widget_showRawOutput) ? " checked='checked'" : ""; ?> /> - </td> + <td align="right"> + Zone Warning: + </td> + <td> + <input type="text" maxlength="3" size="3" class="formfld unknown" + name="thermal_sensors_widget_zone_warning_threshold" + id="thermal_sensors_widget_zone_warning_threshold" + value="<?= $thermal_sensors_widget_zoneWarningTempThreshold; ?>" /> + </td> + <td align="right"> + <label for="thermal_sensors_widget_show_raw_output">Show raw output (no graph): </label> + <input type="checkbox" + id="thermal_sensors_widget_show_raw_output" + name="thermal_sensors_widget_show_raw_output" + value="<?= $thermal_sensors_widget_showRawOutput; ?>" <?= ($thermal_sensors_widget_showRawOutput) ? " checked='checked'" : ""; ?> /> + </td> </tr> <tr> - <td align="right"> - Zone Critical: - </td> - <td> - <input type="text" maxlength="3" size="3" class="formfld unknown" - name="thermal_sensors_widget_zone_critical_threshold" - id="thermal_sensors_widget_zone_critical_threshold" - value="<?= $thermal_sensors_widget_zoneCriticalTempThreshold; ?>" /> - </td> - <td align="right"> - <label for="thermal_sensors_widget_show_full_sensor_name">Show full sensor name: </label> - <input type="checkbox" - id="thermal_sensors_widget_show_full_sensor_name" - name="thermal_sensors_widget_show_full_sensor_name" - value="<?= $thermal_sensors_widget_showFullSensorName; ?>" <?= ($thermal_sensors_widget_showFullSensorName) ? " checked='checked'" : ""; ?> /> - </td> + <td align="right"> + Zone Critical: + </td> + <td> + <input type="text" maxlength="3" size="3" class="formfld unknown" + name="thermal_sensors_widget_zone_critical_threshold" + id="thermal_sensors_widget_zone_critical_threshold" + value="<?= $thermal_sensors_widget_zoneCriticalTempThreshold; ?>" /> + </td> + <td align="right"> + <label for="thermal_sensors_widget_show_full_sensor_name">Show full sensor name: </label> + <input type="checkbox" + id="thermal_sensors_widget_show_full_sensor_name" + name="thermal_sensors_widget_show_full_sensor_name" + value="<?= $thermal_sensors_widget_showFullSensorName; ?>" <?= ($thermal_sensors_widget_showFullSensorName) ? " checked='checked'" : ""; ?> /> + </td> </tr> <tr> - <td align="right"> - Core Warning: - </td> - <td> - <input type="text" maxlength="3" size="3" class="formfld unknown" - name="thermal_sensors_widget_core_warning_threshold" - id="thermal_sensors_widget_core_warning_threshold" - value="<?= $thermal_sensors_widget_coreWarningTempThreshold ?>" /> - </td> - <td align="right"> - <label for="thermal_sensors_widget_pulsate_warning">Pulsate Warning: </label> - <input type="checkbox" - id="thermal_sensors_widget_pulsate_warning" - name="thermal_sensors_widget_pulsate_warning" - value="<?= $thermal_sensors_widget_pulsateWarning; ?>" <?= ($thermal_sensors_widget_pulsateWarning) ? " checked='checked'" : ""; ?> /> - </td> + <td align="right"> + Core Warning: + </td> + <td> + <input type="text" maxlength="3" size="3" class="formfld unknown" + name="thermal_sensors_widget_core_warning_threshold" + id="thermal_sensors_widget_core_warning_threshold" + value="<?= $thermal_sensors_widget_coreWarningTempThreshold ?>" /> + </td> + <td align="right"> + <label for="thermal_sensors_widget_pulsate_warning">Pulsate Warning: </label> + <input type="checkbox" + id="thermal_sensors_widget_pulsate_warning" + name="thermal_sensors_widget_pulsate_warning" + value="<?= $thermal_sensors_widget_pulsateWarning; ?>" <?= ($thermal_sensors_widget_pulsateWarning) ? " checked='checked'" : ""; ?> /> + </td> </tr> <tr> - <td align="right"> - Core Critical: - </td> - <td> - <input type="text" maxlength="3" size="3" class="formfld unknown" - name="thermal_sensors_widget_core_critical_threshold" - id="thermal_sensors_widget_core_critical_threshold" - value="<?= $thermal_sensors_widget_coreCriticalTempThreshold ?>" /> - </td> - <td align="right"> - <label for="thermal_sensors_widget_pulsate_critical">Pulsate Critical: </label> - <input type="checkbox" - id="thermal_sensors_widget_pulsate_critical" - name="thermal_sensors_widget_pulsate_critical" - value="<?= $thermal_sensors_widget_pulsateCritical; ?>" <?= ($thermal_sensors_widget_pulsateCritical) ? " checked='checked'" : ""; ?> /> - </td> + <td align="right"> + Core Critical: + </td> + <td> + <input type="text" maxlength="3" size="3" class="formfld unknown" + name="thermal_sensors_widget_core_critical_threshold" + id="thermal_sensors_widget_core_critical_threshold" + value="<?= $thermal_sensors_widget_coreCriticalTempThreshold ?>" /> + </td> + <td align="right"> + <label for="thermal_sensors_widget_pulsate_critical">Pulsate Critical: </label> + <input type="checkbox" + id="thermal_sensors_widget_pulsate_critical" + name="thermal_sensors_widget_pulsate_critical" + value="<?= $thermal_sensors_widget_pulsateCritical; ?>" <?= ($thermal_sensors_widget_pulsateCritical) ? " checked='checked'" : ""; ?> /> + </td> </tr> <tr> - <td align="right" colspan="3"> - <input type="submit" id="thermal_sensors_widget_submit" name="thermal_sensors_widget_submit" class="formbtn" value="Save" /> - </td> + <td align="right" colspan="3"> + <input type="submit" id="thermal_sensors_widget_submit" name="thermal_sensors_widget_submit" class="formbtn" value="Save" /> + </td> </tr> <tr> - <td align="left" colspan="3"> - <span>* You can configure a proper Thermal Sensor / Module under <br /> - <a href="system_advanced_misc.php">System > Advanced > Miscellaneous : Thermal Sensors section</a>.</span> - </td> + <td align="left" colspan="3"> + <span>* You can configure a proper Thermal Sensor / Module under <br /> + <a href="system_advanced_misc.php">System > Advanced > Miscellaneous : Thermal Sensors section</a>.</span> + </td> </tr> </table> </form> diff --git a/usr/local/www/widgets/widgets/traffic_graphs.widget.php b/usr/local/www/widgets/widgets/traffic_graphs.widget.php index 8404f61..b125740 100644 --- a/usr/local/www/widgets/widgets/traffic_graphs.widget.php +++ b/usr/local/www/widgets/widgets/traffic_graphs.widget.php @@ -54,8 +54,9 @@ if (!is_array($a_config["shown"]["item"])) { } $ifdescrs = get_configured_interface_with_descr(); -if (isset($config['ipsec']['enable'])) +if (isset($config['ipsec']['enable'])) { $ifdescrs['enc0'] = "IPsec"; +} if ($_POST) { if (isset($_POST["refreshinterval"])) { @@ -106,7 +107,7 @@ if (isset($a_config["scale_type"])) { <input type="hidden" name="shown[<?= $ifname ?>]" value="<?= $shown[$ifname] ? "show" : "hide" ?>" /> <?php } ?> Default AutoScale: - <?php + <?php $scale_type_up="checked=\"checked\""; $scale_type_follow=""; if (isset($config["widgets"]["trafficgraphs"]["scale_type"])) { @@ -114,8 +115,7 @@ if (isset($a_config["scale_type"])) { if ($selected_radio == "up") { $scale_type_up = "checked=\"checked\""; $scale_type_follow=""; - } - else if ($selected_radio == "follow") { + } else if ($selected_radio == "follow") { $scale_type_up=""; $scale_type_follow = "checked=\"checked\""; } diff --git a/usr/local/www/widgets/widgets/wake_on_lan.widget.php b/usr/local/www/widgets/widgets/wake_on_lan.widget.php index dbce90b..9cb760a 100644 --- a/usr/local/www/widgets/widgets/wake_on_lan.widget.php +++ b/usr/local/www/widgets/widgets/wake_on_lan.widget.php @@ -32,10 +32,11 @@ $nocsrf = true; require_once("guiconfig.inc"); require_once("/usr/local/www/widgets/include/wake_on_lan.inc"); -if (is_array($config['wol']['wolentry'])) +if (is_array($config['wol']['wolentry'])) { $wolcomputers = $config['wol']['wolentry']; -else +} else { $wolcomputers = array(); +} ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="wol status"> @@ -50,12 +51,12 @@ else <?php if (count($wolcomputers) > 0) { - foreach($wolcomputers as $wolent) { + foreach ($wolcomputers as $wolent) { echo '<tr><td class="listlr">' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n"; echo '<td class="listr">' . convert_friendly_interface_to_friendly_descr($wolent['interface']) . '</td>' . "\n"; $is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'"); - if($is_active == 1) { + if ($is_active == 1) { echo '<td class="listr" align="center">' . "\n"; echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_pass.gif\" alt=\"pass\" /> " . gettext("Online") . "</td>\n"; } else { @@ -63,7 +64,7 @@ if (count($wolcomputers) > 0) { echo "<img src=\"/themes/" . $g["theme"] . "/images/icons/icon_block.gif\" alt=\"block\" /> <font color=\"white\">" . gettext("Offline") . "</font></td>\n"; } echo '<td valign="middle" class="list nowrap">'; - /*if($is_active) { */ + /*if ($is_active) { */ /* Will always show wake-up button even if pfsense thinks it is awake */ /* } else { */ echo "<a href='services_wol.php?mac={$wolent['mac']}&if={$wolent['interface']}'> "; |