diff options
author | Phil Davis <phil.davis@inf.org> | 2015-05-15 11:40:50 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2015-05-15 11:40:50 +0545 |
commit | 42b0c92129b93ca6d182f4904ec92708c9a8c750 (patch) | |
tree | 7d396b83ba7920878bb6e8f42ae5907e9518c003 /usr/local | |
parent | c8f1c7bd70cd156f23a59400e5c738ef8bf5281b (diff) | |
download | pfsense-42b0c92129b93ca6d182f4904ec92708c9a8c750.zip pfsense-42b0c92129b93ca6d182f4904ec92708c9a8c750.tar.gz |
Code style WWW Status
Diffstat (limited to 'usr/local')
21 files changed, 1774 insertions, 1446 deletions
diff --git a/usr/local/www/status_captiveportal.php b/usr/local/www/status_captiveportal.php index 90d3d28..769b755 100644 --- a/usr/local/www/status_captiveportal.php +++ b/usr/local/www/status_captiveportal.php @@ -1,23 +1,23 @@ -<?php +<?php /* $Id$ */ /* status_captiveportal.php part of m0n0wall (http://m0n0.ch/wall) - + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. Copyright (C) 2013-2015 Electric Sheep Fencing, LP 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 @@ -29,7 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: captiveportal */ @@ -47,26 +47,30 @@ require("shaper.inc"); require("captiveportal.inc"); $cpzone = $_GET['zone']; -if (isset($_POST['zone'])) +if (isset($_POST['zone'])) { $cpzone = $_POST['zone']; +} $pgtitle = array(gettext("Status: Captive portal")); $shortcut_section = "captiveportal"; -if (!is_array($config['captiveportal'])) - $config['captiveportal'] = array(); +if (!is_array($config['captiveportal'])) { + $config['captiveportal'] = array(); +} $a_cp =& $config['captiveportal']; -if (count($a_cp) == 1) +if (count($a_cp) == 1) { $cpzone = current(array_keys($a_cp)); +} /* If the zone does not exist, do not display the invalid zone */ if (!array_key_exists($cpzone, $a_cp)) { $cpzone = ""; } -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) && isset($_GET['id'])) { captiveportal_disconnect_client($_GET['id']); @@ -93,16 +97,17 @@ if (!empty($cpzone)) { $cpdb = captiveportal_read_db(); 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 + } else { $order = 0; + } usort($cpdb, "clientcmp"); } } @@ -114,107 +119,139 @@ $mac_man = load_mac_manufacturer_table(); <?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane"> -<tr><td class="tabnavtbl"> -<?php - $tab_array = array(); - $tab_array[] = array(gettext("Active Users"), true, "status_captiveportal.php?zone=" . htmlspecialchars($cpzone)); - $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone=" . htmlspecialchars($cpzone)); - $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone=" . htmlspecialchars($cpzone)); - $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone=" . htmlspecialchars($cpzone)); - $tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone=" . htmlspecialchars($cpzone)); - display_top_tabs($tab_array); -?> -</td></tr> -<tr> -<td class="tabcont"> + <tr><td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Active Users"), true, "status_captiveportal.php?zone=" . htmlspecialchars($cpzone)); + $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone=" . htmlspecialchars($cpzone)); + $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone=" . htmlspecialchars($cpzone)); + $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone=" . htmlspecialchars($cpzone)); + $tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone=" . htmlspecialchars($cpzone)); + display_top_tabs($tab_array); +?> + </td></tr> + <tr> + <td class="tabcont"> <?php endif; ?> -<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> - <tr> - <td width="20%" class="vncell" valign="top"> - <br /><?=gettext("Captive Portal Zone"); ?><br/><br /> - </td> - <td class="vncell" width="30%" align="center"> - <?php if (count($a_cp) > 1) { ?> - <form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> - <select name="zone" class="formselect" onchange="document.form1.submit()"> - <option value="">none</option> - <?php foreach ($a_cp as $cpkey => $cp) { - echo "<option value=\"" . htmlspecialchars($cpkey) . "\" "; - if ($cpzone == $cpkey) - echo "selected=\"selected\""; - echo ">" . htmlspecialchars($cp['zone']) . "</option>\n"; - } - ?> - </select> - <br /> - </form> - <?php } else echo htmlspecialchars($a_cp[$cpzone]['zone']); ?> - </td> - <td colspan="3" width="50%"></td> - </tr> - <tr><td colspan="5"><br /></td></tr> -<?php if (!empty($cpzone)): ?> - <tr> - <td colspan="5" valign="top" class="listtopic"><?=gettext("Captive Portal status");?></td> - </tr> - <tr> - <td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=ip&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("IP address");?></a></td> - <td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=mac&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("MAC address");?></a></td> - <td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=user&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Username");?></a></td> - <?php if ($_GET['showact']): ?> - <td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=start&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td> - <td class="listhdr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=lastact&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Last activity");?></a></td> - <?php else: ?> - <td class="listhdr" colspan="2"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=start&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td> - <?php endif; ?> - <td class="list sort_ignore"></td> - </tr> -<?php foreach ($cpdb as $cpent): ?> - <tr> - <td class="listlr"><?=$cpent[2];?></td> - <td class="listr"> - <?php - $mac=trim($cpent[3]); - if (!empty($mac)) { - $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); - print htmlentities($mac); - if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; } + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> + <tr> + <td width="20%" class="vncell" valign="top"> + <br /><?=gettext("Captive Portal Zone"); ?><br/><br /> + </td> + <td class="vncell" width="30%" align="center"> +<?php + if (count($a_cp) > 1) { +?> + <form action="status_captiveportal.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> + <select name="zone" class="formselect" onchange="document.form1.submit()"> + <option value="">none</option> +<?php + foreach ($a_cp as $cpkey => $cp) { + echo "<option value=\"" . htmlspecialchars($cpkey) . "\" "; + if ($cpzone == $cpkey) { + echo "selected=\"selected\""; + } + echo ">" . htmlspecialchars($cp['zone']) . "</option>\n"; } - ?> - </td> - <td class="listr"><?=htmlspecialchars($cpent[4]);?> </td> - <?php if ($_GET['showact']): - $last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]); ?> - <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td> - <td class="listr"><?php if ($last_act != 0) echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));?></td> - <?php else: ?> - <td class="listr" colspan="2"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td> - <?php endif; ?> - <td valign="middle" class="list nowrap"> - <a href="?zone=<?=htmlspecialchars($cpzone);?>&order=<?=$_GET['order'];?>&showact=<?=htmlspecialchars($_GET['showact']);?>&act=del&id=<?=$cpent[5];?>" onclick="return confirm('<?=gettext("Do you really want to disconnect this client?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("Disconnect");?>"></a> - </td> - </tr> -<?php endforeach; endif; ?> -</table> +?> + </select> + <br /> + </form> +<?php + } else { + echo htmlspecialchars($a_cp[$cpzone]['zone']); + } +?> + </td> + <td colspan="3" width="50%"></td> + </tr> + <tr> + <td colspan="5"><br /></td> + </tr> +<?php + if (!empty($cpzone)): +?> + <tr> + <td colspan="5" valign="top" class="listtopic"><?=gettext("Captive Portal status");?></td> + </tr> + <tr> + <td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=ip&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("IP address");?></a></td> + <td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=mac&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("MAC address");?></a></td> + <td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=user&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Username");?></a></td> +<?php + if ($_GET['showact']): +?> + <td class="listhdrr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=start&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td> + <td class="listhdr"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=lastact&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Last activity");?></a></td> +<?php + else: +?> + <td class="listhdr" colspan="2"><a href="?zone=<?=htmlspecialchars($cpzone)?>&order=start&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Session start");?></a></td> +<?php + endif; +?> + <td class="list sort_ignore"></td> + </tr> +<?php + foreach ($cpdb as $cpent): +?> + <tr> + <td class="listlr"><?=$cpent[2];?></td> + <td class="listr"> +<?php + $mac=trim($cpent[3]); + if (!empty($mac)) { + $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); + print htmlentities($mac); + if (isset($mac_man[$mac_hi])) { + print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; + } + } +?> + + </td> + <td class="listr"><?=htmlspecialchars($cpent[4]);?> </td> +<?php + if ($_GET['showact']): + $last_act = captiveportal_get_last_activity($cpent[2], $cpent[3]); +?> + <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td> + <td class="listr"><?php if ($last_act != 0) echo htmlspecialchars(date("m/d/Y H:i:s", $last_act));?></td> +<?php + else: +?> + <td class="listr" colspan="2"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent[0]));?></td> +<?php + endif; +?> + <td valign="middle" class="list nowrap"> + <a href="?zone=<?=htmlspecialchars($cpzone);?>&order=<?=$_GET['order'];?>&showact=<?=htmlspecialchars($_GET['showact']);?>&act=del&id=<?=$cpent[5];?>" onclick="return confirm('<?=gettext("Do you really want to disconnect this client?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="<?=gettext("Disconnect");?>"></a> + </td> + </tr> +<?php + endforeach; + endif; +?> + </table> <?php if (!empty($cpzone) && isset($config['voucher'][$cpzone]['enable'])): ?> -</td> -</tr> + </td> + </tr> </table> <?php endif; ?> <form action="status_captiveportal.php" method="get" style="margin: 14px;"> -<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" /> + <input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" /> <?php if (!empty($cpzone)): ?> <?php if ($_GET['showact']): ?> -<input type="hidden" name="showact" value="0" /> -<input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" /> + <input type="hidden" name="showact" value="0" /> + <input type="submit" class="formbtn" value="<?=gettext("Don't show last activity");?>" /> <?php else: ?> -<input type="hidden" name="showact" value="1" /> -<input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" /> + <input type="hidden" name="showact" value="1" /> + <input type="submit" class="formbtn" value="<?=gettext("Show last activity");?>" /> <?php endif; ?> -<input type="hidden" name="zone" value="<?=htmlspecialchars($cpzone);?>" /> + <input type="hidden" name="zone" value="<?=htmlspecialchars($cpzone);?>" /> <?php endif; ?> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/status_captiveportal_expire.php b/usr/local/www/status_captiveportal_expire.php index 5207b20..c4233d9 100644 --- a/usr/local/www/status_captiveportal_expire.php +++ b/usr/local/www/status_captiveportal_expire.php @@ -45,16 +45,18 @@ require("captiveportal.inc"); require_once("voucher.inc"); $cpzone = $_GET['zone']; -if (isset($_POST['zone'])) +if (isset($_POST['zone'])) { $cpzone = $_POST['zone']; +} if (empty($cpzone)) { header("Location: services_captiveportal_zones.php"); exit; } -if (!is_array($config['captiveportal'])) +if (!is_array($config['captiveportal'])) { $config['captiveportal'] = array(); +} $a_cp =& $config['captiveportal']; $pgtitle = array(gettext("Status"), gettext("Captive portal"), gettext("Expire Vouchers"), $a_cp[$cpzone]['zone']); @@ -66,53 +68,56 @@ include("head.inc"); <form action="status_captiveportal_expire.php" method="post" enctype="multipart/form-data" name="iform" id="iform"> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane"> -<tr><td class="tabnavtbl"> + <tr><td class="tabnavtbl"> <?php - $tab_array = array(); - $tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Expire Vouchers"), true, "status_captiveportal_expire.php?zone={$cpzone}"); - display_top_tabs($tab_array); + $tab_array = array(); + $tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Expire Vouchers"), true, "status_captiveportal_expire.php?zone={$cpzone}"); + display_top_tabs($tab_array); ?> -</td></tr> -<tr> -<td class="tabcont"> + </td></tr> + <tr> + <td class="tabcont"> -<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="content pane"> - <tr> - <td valign="top" class="vncellreq"><?=gettext("Voucher(s)"); ?></td> - <td class="vtable"> - <textarea name="vouchers" cols="65" rows="3" id="vouchers" class="formpre"><?=htmlspecialchars($_POST['vouchers']);?></textarea> - <br /> -<?=gettext("Enter multiple vouchers separated by space or newline. All valid vouchers will be marked as expired"); ?>.</td> - </tr> - <tr> - <td width="22%" valign="top"> </td> - <td width="78%"> - <input name="zone" type="hidden" value="<?=htmlspecialchars($cpzone);?>" /> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Submit"); ?>" /> - </td> - </tr> + <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="content pane"> + <tr> + <td valign="top" class="vncellreq"><?=gettext("Voucher(s)"); ?></td> + <td class="vtable"> + <textarea name="vouchers" cols="65" rows="3" id="vouchers" class="formpre"><?=htmlspecialchars($_POST['vouchers']);?></textarea> + <br /> + <?=gettext("Enter multiple vouchers separated by space or newline. All valid vouchers will be marked as expired"); ?>. + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="zone" type="hidden" value="<?=htmlspecialchars($cpzone);?>" /> + <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Submit"); ?>" /> + </td> + </tr> + </table> + </td> + </tr> </table> -</td></tr></table> </form> <br/> <?php if ($_POST) { - if ($_POST['vouchers']) { - $result = voucher_expire($_POST['vouchers']); - echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\" summary=\"results\">\n"; - if ( $result) { - echo "<tr><td bgcolor=\"#D9DEE8\"><img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" alt=\"pass\" /></td>"; - echo "<td bgcolor=\"#D9DEE8\">Success</td></tr>"; - } else { - echo "<tr><td bgcolor=\"#FFD9D1\"><img src=\"/themes/{$g['theme']}/images/icons/icon_block.gif\" alt=\"block\" /></td>"; - echo "<td bgcolor=\"#FFD9D1\">Error</td></tr>"; - } - echo "</table>"; - } + if ($_POST['vouchers']) { + $result = voucher_expire($_POST['vouchers']); + echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\" summary=\"results\">\n"; + if ( $result) { + echo "<tr><td bgcolor=\"#D9DEE8\"><img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" alt=\"pass\" /></td>"; + echo "<td bgcolor=\"#D9DEE8\">Success</td></tr>"; + } else { + echo "<tr><td bgcolor=\"#FFD9D1\"><img src=\"/themes/{$g['theme']}/images/icons/icon_block.gif\" alt=\"block\" /></td>"; + echo "<td bgcolor=\"#FFD9D1\">Error</td></tr>"; + } + echo "</table>"; + } } include("fend.inc"); diff --git a/usr/local/www/status_captiveportal_test.php b/usr/local/www/status_captiveportal_test.php index 4caafb4..d13578d 100644 --- a/usr/local/www/status_captiveportal_test.php +++ b/usr/local/www/status_captiveportal_test.php @@ -26,7 +26,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: captiveportal */ @@ -46,15 +46,16 @@ require_once("voucher.inc"); $cpzone = $_GET['zone']; if (isset($_POST['zone'])) - $cpzone = $_POST['zone']; + $cpzone = $_POST['zone']; if (empty($cpzone)) { - header("Location: services_captiveportal_zones.php"); - exit; + header("Location: services_captiveportal_zones.php"); + exit; } -if (!is_array($config['captiveportal'])) - $config['captiveportal'] = array(); +if (!is_array($config['captiveportal'])) { + $config['captiveportal'] = array(); +} $a_cp =& $config['captiveportal']; $pgtitle = array(gettext("Status"), gettext("Captive portal"), gettext("Test Vouchers"), $a_cp[$cpzone]['zone']); @@ -67,55 +68,57 @@ include("head.inc"); <form action="status_captiveportal_test.php" method="post" enctype="multipart/form-data" name="iform" id="iform"> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane"> -<tr><td class="tabnavtbl"> -<?php - $tab_array = array(); - $tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Test Vouchers"), true, "status_captiveportal_test.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}"); - display_top_tabs($tab_array); -?> -</td></tr> -<tr> -<td class="tabcont"> - -<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="content pane"> - <tr> - <td valign="top" class="vncellreq"><?=gettext("Voucher(s)"); ?></td> - <td class="vtable"> - <textarea name="vouchers" cols="65" rows="3" id="vouchers" class="formpre"><?=htmlspecialchars($_POST['vouchers']);?></textarea> - <br /> -<?=gettext("Enter multiple vouchers separated by space or newline. The remaining time, if valid, will be shown for each voucher"); ?>.</td> - </tr> - <tr> - <td width="22%" valign="top"> </td> - <td width="78%"> - <input name="zone" type="hidden" value="<?=htmlspecialchars($cpzone);?>" /> - <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Submit"); ?>" /> - </td> - </tr> + <tr><td class="tabnavtbl"> +<?php + $tab_array = array(); + $tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Active Vouchers"), false, "status_captiveportal_vouchers.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Test Vouchers"), true, "status_captiveportal_test.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}"); + display_top_tabs($tab_array); +?> + </td></tr> + <tr> + <td class="tabcont"> + <table width="100%" border="0" cellpadding="6" cellspacing="0" summary="content pane"> + <tr> + <td valign="top" class="vncellreq"><?=gettext("Voucher(s)"); ?></td> + <td class="vtable"> + <textarea name="vouchers" cols="65" rows="3" id="vouchers" class="formpre"><?=htmlspecialchars($_POST['vouchers']);?></textarea> + <br /> + <?=gettext("Enter multiple vouchers separated by space or newline. The remaining time, if valid, will be shown for each voucher"); ?>. + </td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="zone" type="hidden" value="<?=htmlspecialchars($cpzone);?>" /> + <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Submit"); ?>" /> + </td> + </tr> + </table> + </td> + </tr> </table> -</td></tr></table> </form> <br/> <?php if ($_POST) { - if ($_POST['vouchers']) { - $test_results = voucher_auth($_POST['vouchers'], 1); - echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\" summary=\"results\">\n"; - foreach ($test_results as $result) { - if (strpos($result, " good ") || strpos($result, " granted ")) { - echo "<tr><td bgcolor=\"#D9DEE8\"><img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" alt=\"pass\" /></td>"; - echo "<td bgcolor=\"#D9DEE8\">$result</td></tr>"; - } else { - echo "<tr><td bgcolor=\"#FFD9D1\"><img src=\"/themes/{$g['theme']}/images/icons/icon_block.gif\" alt=\"block\" /></td>"; - echo "<td bgcolor=\"#FFD9D1\">$result</td></tr>"; - } - } - echo "</table>"; - } + if ($_POST['vouchers']) { + $test_results = voucher_auth($_POST['vouchers'], 1); + echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\" summary=\"results\">\n"; + foreach ($test_results as $result) { + if (strpos($result, " good ") || strpos($result, " granted ")) { + echo "<tr><td bgcolor=\"#D9DEE8\"><img src=\"/themes/{$g['theme']}/images/icons/icon_pass.gif\" alt=\"pass\" /></td>"; + echo "<td bgcolor=\"#D9DEE8\">$result</td></tr>"; + } else { + echo "<tr><td bgcolor=\"#FFD9D1\"><img src=\"/themes/{$g['theme']}/images/icons/icon_block.gif\" alt=\"block\" /></td>"; + echo "<td bgcolor=\"#FFD9D1\">$result</td></tr>"; + } + } + echo "</table>"; + } } include("fend.inc"); diff --git a/usr/local/www/status_captiveportal_voucher_rolls.php b/usr/local/www/status_captiveportal_voucher_rolls.php index 7d54645..feada71 100644 --- a/usr/local/www/status_captiveportal_voucher_rolls.php +++ b/usr/local/www/status_captiveportal_voucher_rolls.php @@ -46,16 +46,18 @@ require("captiveportal.inc"); require_once("voucher.inc"); $cpzone = $_GET['zone']; -if (isset($_POST['zone'])) +if (isset($_POST['zone'])) { $cpzone = $_POST['zone']; +} if (empty($cpzone)) { header("Location: services_captiveportal_zones.php"); exit; } -if (!is_array($config['captiveportal'])) +if (!is_array($config['captiveportal'])) { $config['captiveportal'] = array(); +} $a_cp =& $config['captiveportal']; $pgtitle = array(gettext("Status"), gettext("Captive portal"), gettext("Voucher Rolls"), $a_cp[$cpzone]['zone']); $shortcut_section = "captiveportal-vouchers"; @@ -99,12 +101,13 @@ include("head.inc"); </tr> <?php $voucherlck = lock("vouche{$cpzone}r"); - $i = 0; foreach($a_roll as $rollent): - $used = voucher_used_count($rollent['number']); - $active = count(voucher_read_active_db($rollent['number']),$rollent['minutes']); - $ready = $rollent['count'] - $used; - /* used also count active vouchers, remove them */ - $used = $used - $active; + $i = 0; + foreach($a_roll as $rollent): + $used = voucher_used_count($rollent['number']); + $active = count(voucher_read_active_db($rollent['number']),$rollent['minutes']); + $ready = $rollent['count'] - $used; + /* used also count active vouchers, remove them */ + $used = $used - $active; ?> <tr> <td class="listlr"> @@ -129,7 +132,11 @@ include("head.inc"); <?=htmlspecialchars($ready); ?> </td> </tr> - <?php $i++; endforeach; unlock($voucherlck); ?> + <?php + $i++; + endforeach; + unlock($voucherlck); + ?> </table> </td> </tr> diff --git a/usr/local/www/status_captiveportal_vouchers.php b/usr/local/www/status_captiveportal_vouchers.php index 094a046..e8cf0a8 100644 --- a/usr/local/www/status_captiveportal_vouchers.php +++ b/usr/local/www/status_captiveportal_vouchers.php @@ -45,16 +45,18 @@ require("captiveportal.inc"); require_once("voucher.inc"); $cpzone = $_GET['zone']; -if (isset($_POST['zone'])) +if (isset($_POST['zone'])) { $cpzone = $_POST['zone']; +} if (empty($cpzone)) { header("Location: services_captiveportal_zones.php"); exit; } -if (!is_array($config['captiveportal'])) +if (!is_array($config['captiveportal'])) { $config['captiveportal'] = array(); +} $a_cp =& $config['captiveportal']; $pgtitle = array(gettext("Status"), gettext("Captive portal"), gettext("Vouchers"), $a_cp[$cpzone]['zone']); $shortcut_section = "captiveportal-vouchers"; @@ -75,11 +77,12 @@ foreach($a_roll as $rollent) { $roll = $rollent['number']; $minutes = $rollent['minutes']; - if (!file_exists("{$g['vardb_path']}/voucher_{$cpzone}_active_$roll.db")) + if (!file_exists("{$g['vardb_path']}/voucher_{$cpzone}_active_$roll.db")) { continue; + } $active_vouchers = file("{$g['vardb_path']}/voucher_{$cpzone}_active_$roll.db", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - foreach($active_vouchers as $voucher => $line) { + foreach ($active_vouchers as $voucher => $line) { list($voucher,$timestamp, $minutes) = explode(",", $line); $remaining = (($timestamp + 60*$minutes) - time()); if ($remaining > 0) { @@ -105,42 +108,41 @@ include("head.inc"); <form action="status_captiveportal_vouchers.php" method="post" enctype="multipart/form-data" name="iform" id="iform"> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="tab pane"> -<tr><td class="tabnavtbl"> + <tr><td class="tabnavtbl"> <?php - $tab_array = array(); - $tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Active Vouchers"), true, "status_captiveportal_vouchers.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone={$cpzone}"); - $tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}"); - display_top_tabs($tab_array); + $tab_array = array(); + $tab_array[] = array(gettext("Active Users"), false, "status_captiveportal.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Active Vouchers"), true, "status_captiveportal_vouchers.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Voucher Rolls"), false, "status_captiveportal_voucher_rolls.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Test Vouchers"), false, "status_captiveportal_test.php?zone={$cpzone}"); + $tab_array[] = array(gettext("Expire Vouchers"), false, "status_captiveportal_expire.php?zone={$cpzone}"); + display_top_tabs($tab_array); ?> -</td></tr> -<tr> -<td class="tabcont"> - -<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="content pane"> - <tr> - <td class="listhdrr"><a href="?order=0&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Voucher"); ?></a></td> - <td class="listhdrr"><a href="?order=1&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Roll"); ?></a></td> - <td class="listhdrr"><a href="?order=2&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Activated at"); ?></a></td> - <td class="listhdrr"><a href="?order=3&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Expires in"); ?></a></td> - <td class="listhdr"><a href="?order=4&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Expires at"); ?></a></td> - <td class="list"></td> - </tr> + </td></tr> + <tr> + <td class="tabcont"> + <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="content pane"> + <tr> + <td class="listhdrr"><a href="?order=0&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Voucher"); ?></a></td> + <td class="listhdrr"><a href="?order=1&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Roll"); ?></a></td> + <td class="listhdrr"><a href="?order=2&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Activated at"); ?></a></td> + <td class="listhdrr"><a href="?order=3&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Expires in"); ?></a></td> + <td class="listhdr"><a href="?order=4&showact=<?=htmlspecialchars($_GET['showact']);?>"><?=gettext("Expires at"); ?></a></td> + <td class="list"></td> + </tr> <?php foreach ($db as $dbent): ?> - <tr> - <td class="listlr"><?=$dbent[0];?></td> - <td class="listr"><?=$dbent[1];?></td> - <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[2]));?></td> - <td class="listr"><?=$dbent[3];?> <?=gettext("min"); ?></td> - <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[4]));?></td> - <td class="list"></td> - </tr> + <tr> + <td class="listlr"><?=$dbent[0];?></td> + <td class="listr"><?=$dbent[1];?></td> + <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[2]));?></td> + <td class="listr"><?=$dbent[3];?> <?=gettext("min"); ?></td> + <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $dbent[4]));?></td> + <td class="list"></td> + </tr> <?php endforeach; ?> -</table> -</td> -</tr> + </table> + </td> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/status_dhcp_leases.php b/usr/local/www/status_dhcp_leases.php index 158a733..97ab938 100644 --- a/usr/local/www/status_dhcp_leases.php +++ b/usr/local/www/status_dhcp_leases.php @@ -102,8 +102,9 @@ function adjust_gmt($dt) { $dhcpd = $config['dhcpd']; foreach ($dhcpd as $dhcpditem) { $dhcpleaseinlocaltime = $dhcpditem['dhcpleaseinlocaltime']; - if ($dhcpleaseinlocaltime == "yes") + if ($dhcpleaseinlocaltime == "yes") { break; + } } if ($dhcpleaseinlocaltime == "yes") { $ts = strtotime($dt . " GMT"); @@ -117,11 +118,13 @@ function adjust_gmt($dt) { function remove_duplicate($array, $field) { - foreach ($array as $sub) + foreach ($array as $sub) { $cmp[] = $sub[$field]; + } $unique = array_unique(array_reverse($cmp,true)); - foreach ($unique as $k => $rien) + foreach ($unique as $k => $rien) { $new[] = $array[$k]; + } return $new; } @@ -153,19 +156,19 @@ $l = 0; $p = 0; // Put everything together again -foreach($leases_content as $lease) { +foreach ($leases_content as $lease) { /* split the line by space */ $data = explode(" ", $lease); /* walk the fields */ $f = 0; $fcount = count($data); /* with less than 20 fields there is nothing useful */ - if($fcount < 20) { + if ($fcount < 20) { $i++; continue; } while($f < $fcount) { - switch($data[$f]) { + switch ($data[$f]) { case "failover": $pools[$p]['name'] = trim($data[$f+2], '"'); $pools[$p]['name'] = "{$pools[$p]['name']} (" . convert_friendly_interface_to_friendly_descr(substr($pools[$p]['name'], 5)) . ")"; @@ -213,7 +216,7 @@ foreach($leases_content as $lease) { $f = $f+3; break; case "binding": - switch($data[$f+2]) { + switch ($data[$f+2]) { case "active": $leases[$l]['act'] = "active"; break; @@ -247,11 +250,11 @@ foreach($leases_content as $lease) { $f = $f+2; break; case "client-hostname": - if($data[$f+1] <> "") { + if ($data[$f+1] <> "") { $leases[$l]['hostname'] = preg_replace('/"/','',$data[$f+1]); } else { $hostname = gethostbyaddr($leases[$l]['ip']); - if($hostname <> "") { + if ($hostname <> "") { $leases[$l]['hostname'] = $hostname; } } @@ -272,20 +275,20 @@ foreach($leases_content as $lease) { unset($lease_content); /* remove duplicate items by mac address */ -if(count($leases) > 0) { +if (count($leases) > 0) { $leases = remove_duplicate($leases,"ip"); } -if(count($pools) > 0) { +if (count($pools) > 0) { $pools = remove_duplicate($pools,"name"); asort($pools); } -foreach($config['interfaces'] as $ifname => $ifarr) { +foreach ($config['interfaces'] as $ifname => $ifarr) { if (is_array($config['dhcpd'][$ifname]) && - is_array($config['dhcpd'][$ifname]['staticmap'])) { + is_array($config['dhcpd'][$ifname]['staticmap'])) { $staticmap_array_index = 0; - foreach($config['dhcpd'][$ifname]['staticmap'] as $static) { + foreach ($config['dhcpd'][$ifname]['staticmap'] as $static) { $slease = array(); $slease['ip'] = $static['ipaddr']; $slease['type'] = "static"; @@ -303,33 +306,33 @@ foreach($config['interfaces'] as $ifname => $ifarr) { } } -if ($_GET['order']) +if ($_GET['order']) { usort($leases, "leasecmp"); +} /* only print pool status when we have one */ -if(count($pools) > 0) { +if (count($pools) > 0) { ?> <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases"> - <tr> - <td class="listhdrr"><?=gettext("Failover Group"); ?></a></td> - <td class="listhdrr"><?=gettext("My State"); ?></a></td> - <td class="listhdrr"><?=gettext("Since"); ?></a></td> - <td class="listhdrr"><?=gettext("Peer State"); ?></a></td> - <td class="listhdrr"><?=gettext("Since"); ?></a></td> - </tr> + <tr> + <td class="listhdrr"><?=gettext("Failover Group"); ?></a></td> + <td class="listhdrr"><?=gettext("My State"); ?></a></td> + <td class="listhdrr"><?=gettext("Since"); ?></a></td> + <td class="listhdrr"><?=gettext("Peer State"); ?></a></td> + <td class="listhdrr"><?=gettext("Since"); ?></a></td> + </tr> <?php -foreach ($pools as $data) { - echo "<tr>\n"; - echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n"; - echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n"; - echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n"; - echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n"; - echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n"; - echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; - echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; - echo "</tr>\n"; -} - + foreach ($pools as $data) { + echo "<tr>\n"; + echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n"; + echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n"; + echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n"; + echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n"; + echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n"; + echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; + echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; + echo "</tr>\n"; + } ?> </table> @@ -341,14 +344,14 @@ foreach ($pools as $data) { <br/> <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases"> - <tr> - <td class="listhdrr"><a href="#"><?=gettext("IP address"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("MAC address"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("Hostname"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td> + <tr> + <td class="listhdrr"><a href="#"><?=gettext("IP address"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("MAC address"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("Hostname"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td> </tr> <?php // Load MAC-Manufacturer table @@ -365,8 +368,9 @@ foreach ($leases as $data) { $lip = ip2ulong($data['ip']); if ($data['act'] != "static") { foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) { - if (!is_array($dhcpifconf['range'])) + if (!is_array($dhcpifconf['range'])) { continue; + } if (($lip >= ip2ulong($dhcpifconf['range']['from'])) && ($lip <= ip2ulong($dhcpifconf['range']['to']))) { $data['if'] = $dhcpif; break; @@ -389,13 +393,13 @@ foreach ($leases as $data) { $mac=$data['mac']; $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); if ($data['online'] != "online") { - if(isset($mac_man[$mac_hi])){ // Manufacturer for this MAC is defined + if (isset($mac_man[$mac_hi])) { // Manufacturer for this MAC is defined echo "<td class=\"listr\">{$fspans}<a href=\"services_wol.php?if={$data['if']}&mac=$mac\" title=\"" . gettext("$mac - send Wake on LAN packet to this MAC address") ."\">{$mac}</a><br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>{$fspane}</td>\n"; } else { echo "<td class=\"listr\">{$fspans}<a href=\"services_wol.php?if={$data['if']}&mac={$data['mac']}\" title=\"" . gettext("send Wake on LAN packet to this MAC address") ."\">{$data['mac']}</a>{$fspane}</td>\n"; } } else { - if(isset($mac_man[$mac_hi])){ // Manufacturer for this MAC is defined + if (isset($mac_man[$mac_hi])) { // Manufacturer for this MAC is defined echo "<td class=\"listr\">{$fspans}{$mac}<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>{$fspane}</td>\n"; } else { echo "<td class=\"listr\">{$fspans}{$data['mac']}{$fspane}</td>\n"; @@ -436,16 +440,16 @@ foreach ($leases as $data) { </table> <br/> <form action="status_dhcp_leases.php" method="get"> -<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" /> + <input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" /> <?php if ($_GET['all']): ?> -<input type="hidden" name="all" value="0" /> -<input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" /> + <input type="hidden" name="all" value="0" /> + <input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" /> <?php else: ?> -<input type="hidden" name="all" value="1" /> -<input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" /> + <input type="hidden" name="all" value="1" /> + <input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" /> <?php endif; ?> </form> -<?php if($leases == 0): ?> +<?php if ($leases == 0): ?> <p><strong><?=gettext("No leases file found. Is the DHCP server active"); ?>?</strong></p> <?php endif; ?> diff --git a/usr/local/www/status_dhcpv6_leases.php b/usr/local/www/status_dhcpv6_leases.php index d91b803..c82a93a 100644 --- a/usr/local/www/status_dhcpv6_leases.php +++ b/usr/local/www/status_dhcpv6_leases.php @@ -111,8 +111,9 @@ function adjust_gmt($dt) { $dhcpdv6 = $config['dhcpdv6']; foreach ($dhcpdv6 as $dhcpv6leaseinlocaltime) { $dhcpv6leaseinlocaltime = $dhcpv6leaseinlocaltime['dhcpv6leaseinlocaltime']; - if ($dhcpv6leaseinlocaltime == "yes") + if ($dhcpv6leaseinlocaltime == "yes") { break; + } } } @@ -124,17 +125,19 @@ function adjust_gmt($dt) { $offset = $this_tz->getOffset($dhcp_lt); $ts = $ts + $offset; return strftime("%Y/%m/%d %I:%M:%S%p", $ts); - } - else + } else { return strftime("%Y/%m/%d %H:%M:%S", $ts); + } } function remove_duplicate($array, $field) { - foreach ($array as $sub) + foreach ($array as $sub) { $cmp[] = $sub[$field]; + } $unique = array_unique(array_reverse($cmp,true)); - foreach ($unique as $k => $rien) + foreach ($unique as $k => $rien) { $new[] = $array[$k]; + } return $new; } @@ -208,12 +211,12 @@ while($i < $leases_count) { $f = 0; $fcount = count($data); /* with less then 12 fields there is nothing useful */ - if($fcount < 12) { + if ($fcount < 12) { $i++; continue; } while($f < $fcount) { - switch($data[$f]) { + switch ($data[$f]) { case "failover": $pools[$p]['name'] = $data[$f+2]; $pools[$p]['mystate'] = $data[$f+7]; @@ -285,7 +288,7 @@ while($i < $leases_count) { $f = $f+3; break; case "binding": - switch($data[$f+2]) { + switch ($data[$f+2]) { case "active": $entry['act'] = "active"; break; @@ -311,11 +314,11 @@ while($i < $leases_count) { $f = $f+2; break; case "client-hostname": - if($data[$f+1] <> "") { + if ($data[$f+1] <> "") { $entry['hostname'] = preg_replace('/"/','',$data[$f+1]); } else { $hostname = gethostbyaddr($entry['ip']); - if($hostname <> "") { + if ($hostname <> "") { $entry['hostname'] = $hostname; } } @@ -338,23 +341,23 @@ while($i < $leases_count) { $is_prefix = false; } -if(count($leases) > 0) { +if (count($leases) > 0) { $leases = remove_duplicate($leases,"ip"); } -if(count($prefixes) > 0) { +if (count($prefixes) > 0) { $prefixes = remove_duplicate($prefixes,"prefix"); } -if(count($pools) > 0) { +if (count($pools) > 0) { $pools = remove_duplicate($pools,"name"); asort($pools); } -foreach($config['interfaces'] as $ifname => $ifarr) { +foreach ($config['interfaces'] as $ifname => $ifarr) { if (is_array($config['dhcpdv6'][$ifname]) && - is_array($config['dhcpdv6'][$ifname]['staticmap'])) { - foreach($config['dhcpdv6'][$ifname]['staticmap'] as $static) { + is_array($config['dhcpdv6'][$ifname]['staticmap'])) { + foreach ($config['dhcpdv6'][$ifname]['staticmap'] as $static) { $slease = array(); $slease['ip'] = $static['ipaddrv6']; $slease['type'] = "static"; @@ -374,11 +377,12 @@ foreach($config['interfaces'] as $ifname => $ifarr) { } } -if ($_GET['order']) +if ($_GET['order']) { usort($leases, "leasecmp"); +} /* only print pool status when we have one */ -if(count($pools) > 0) { +if (count($pools) > 0) { ?> <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases"> <tr> @@ -389,18 +393,17 @@ if(count($pools) > 0) { <td class="listhdrr"><?=gettext("Since"); ?></a></td> </tr> <?php -foreach ($pools as $data) { - echo "<tr>\n"; - echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n"; - echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n"; - echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n"; - echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n"; - echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n"; - echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; - echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; - echo "</tr>\n"; -} - + foreach ($pools as $data) { + echo "<tr>\n"; + echo "<td class=\"listlr\">{$fspans}{$data['name']}{$fspane}</td>\n"; + echo "<td class=\"listr\">{$fspans}{$data['mystate']}{$fspane}</td>\n"; + echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['mydate']) . "{$fspane}</td>\n"; + echo "<td class=\"listr\">{$fspans}{$data['peerstate']}{$fspane}</td>\n"; + echo "<td class=\"listr\">{$fspans}" . adjust_gmt($data['peerdate']) . "{$fspane}</td>\n"; + echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; + echo "<td class=\"list\" valign=\"middle\" width=\"17\"> </td>\n"; + echo "</tr>\n"; + } ?> </table> @@ -412,15 +415,15 @@ foreach ($pools as $data) { <br/> <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="dhcp leases"> - <tr> - <td class="listhdrr"><a href="#"><?=gettext("IPv6 address"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("Hostname/MAC"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td> - <td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td> + <tr> + <td class="listhdrr"><a href="#"><?=gettext("IPv6 address"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("IAID"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("DUID"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("Hostname/MAC"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("Start"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("End"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("Online"); ?></a></td> + <td class="listhdrr"><a href="#"><?=gettext("Lease Type"); ?></a></td> </tr> <?php foreach ($leases as $data) { @@ -435,7 +438,7 @@ foreach ($leases as $data) { if ($data['act'] == "static") { foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) { - if(is_array($dhcpifconf['staticmap'])) { + if (is_array($dhcpifconf['staticmap'])) { foreach ($dhcpifconf['staticmap'] as $staticent) { if ($data['ip'] == $staticent['ipaddr']) { $data['if'] = $dhcpif; @@ -444,8 +447,9 @@ foreach ($leases as $data) { } } /* exit as soon as we have an interface */ - if ($data['if'] != "") + if ($data['if'] != "") { break; + } } } else { $data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip'])); @@ -463,7 +467,9 @@ foreach ($leases as $data) { if (!empty($mac)) { $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); print htmlentities($mac); - if(isset($mac_man[$mac_hi])){ print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; } + if (isset($mac_man[$mac_hi])) { + print "<br /><font size=\"-2\"><i>{$mac_man[$mac_hi]}</i></font>"; + } } echo "{$fspane} </td>\n"; @@ -519,7 +525,7 @@ foreach ($prefixes as $data) { if ($data['act'] == "static") { foreach ($config['dhcpdv6'] as $dhcpif => $dhcpifconf) { - if(is_array($dhcpifconf['staticmap'])) { + if (is_array($dhcpifconf['staticmap'])) { foreach ($dhcpifconf['staticmap'] as $staticent) { if ($data['ip'] == $staticent['ipaddr']) { $data['if'] = $dhcpif; @@ -528,8 +534,9 @@ foreach ($prefixes as $data) { } } /* exit as soon as we have an interface */ - if ($data['if'] != "") + if ($data['if'] != "") { break; + } } } else { $data['if'] = convert_real_interface_to_friendly_interface_name(guess_interface_from_ip($data['ip'])); @@ -556,16 +563,16 @@ foreach ($prefixes as $data) { </table> <br/> <form action="status_dhcpv6_leases.php" method="get"> -<input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" /> + <input type="hidden" name="order" value="<?=htmlspecialchars($_GET['order']);?>" /> <?php if ($_GET['all']): ?> -<input type="hidden" name="all" value="0" /> -<input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" /> + <input type="hidden" name="all" value="0" /> + <input type="submit" class="formbtn" value="<?=gettext("Show active and static leases only"); ?>" /> <?php else: ?> -<input type="hidden" name="all" value="1" /> -<input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" /> + <input type="hidden" name="all" value="1" /> + <input type="submit" class="formbtn" value="<?=gettext("Show all configured leases"); ?>" /> <?php endif; ?> </form> -<?php if($leases == 0): ?> +<?php if ($leases == 0): ?> <p><strong><?=gettext("No leases file found. Is the DHCP server active"); ?>?</strong></p> <?php endif; ?> diff --git a/usr/local/www/status_filter_reload.php b/usr/local/www/status_filter_reload.php index 21e12e6..bd8a573 100644 --- a/usr/local/www/status_filter_reload.php +++ b/usr/local/www/status_filter_reload.php @@ -27,7 +27,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: filter */ @@ -45,19 +45,20 @@ require_once("functions.inc"); $pgtitle = array(gettext("Status"),gettext("Filter Reload Status")); $shortcut_section = "firewall"; -if(file_exists("{$g['varrun_path']}/filter_reload_status")) +if (file_exists("{$g['varrun_path']}/filter_reload_status")) { $status = file_get_contents("{$g['varrun_path']}/filter_reload_status"); +} -if($_GET['getstatus']) { +if ($_GET['getstatus']) { echo "|{$status}|"; exit; } -if($_POST['reloadfilter']) { +if ($_POST['reloadfilter']) { send_event("filter reload"); header("Location: status_filter_reload.php"); exit; } -if($_POST['syncfilter']) { +if ($_POST['syncfilter']) { send_event("filter sync"); header("Location: status_filter_reload.php"); exit; @@ -71,10 +72,10 @@ include("head.inc"); <?php include("fbegin.inc"); ?> <br /> <form action="status_filter_reload.php" method="post" name="filter"> -<input type="submit" value="Reload Filter" name="reloadfilter" id="reloadfilter" /> + <input type="submit" value="Reload Filter" name="reloadfilter" id="reloadfilter" /> <?php if ($config['hasync'] && $config['hasync']["synchronizetoip"] != ""): ?> - -<input type="submit" value="Force Config Sync" name="syncfilter" id="syncfilter" /> + + <input type="submit" value="Force Config Sync" name="syncfilter" id="syncfilter" /> <?php endif; ?> </form> <br /><br /><br /> @@ -89,8 +90,6 @@ include("head.inc"); <div id="reloadinfo"><?=gettext("This page will automatically refresh every 3 seconds until the filter is done reloading"); ?>.</div> - - <script type="text/javascript"> //<![CDATA[ /* init update "thread */ @@ -108,9 +107,9 @@ function update_data(obj) { } else { jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> Obtaining filter status...'); } - if(result_text == "Initializing") { + if (result_text == "Initializing") { jQuery('#status').html('<img src="/themes/<?=$g['theme'];?>/images/misc/loader.gif" alt="loader" /> Initializing...'); - } else if(result_text == "Done") { + } else if (result_text == "Done") { jQuery('#status').effect('highlight'); jQuery('#status').html('Done. The filter rules have been reloaded.'); jQuery('#reloadinfo').css("visibility","hidden"); @@ -129,43 +128,46 @@ function update_data(obj) { * popular. If getURL is undefined we spin our own by wrapping XMLHttpRequest. */ if (typeof getURL == 'undefined') { - getURL = function(url, callback) { - if (!url) - throw 'No URL for getURL'; - - try { - if (typeof callback.operationComplete == 'function') - callback = callback.operationComplete; - } catch (e) {} - if (typeof callback != 'function') - throw 'No callback function for getURL'; - - var http_request = null; - if (typeof XMLHttpRequest != 'undefined') { - http_request = new XMLHttpRequest(); - } - else if (typeof ActiveXObject != 'undefined') { - try { - http_request = new ActiveXObject('Msxml2.XMLHTTP'); - } catch (e) { - try { - http_request = new ActiveXObject('Microsoft.XMLHTTP'); - } catch (e) {} - } - } - if (!http_request) - throw 'Both getURL and XMLHttpRequest are undefined'; - - http_request.onreadystatechange = function() { - if (http_request.readyState == 4) { - callback( { success : true, - content : http_request.responseText, - contentType : http_request.getResponseHeader("Content-Type") } ); - } - } - http_request.open('GET', url, true); - http_request.send(null); - } + getURL = function(url, callback) { + if (!url) { + throw 'No URL for getURL'; + } + + try { + if (typeof callback.operationComplete == 'function') { + callback = callback.operationComplete; + } + } catch (e) {} + if (typeof callback != 'function') { + throw 'No callback function for getURL'; + } + + var http_request = null; + if (typeof XMLHttpRequest != 'undefined') { + http_request = new XMLHttpRequest(); + } else if (typeof ActiveXObject != 'undefined') { + try { + http_request = new ActiveXObject('Msxml2.XMLHTTP'); + } catch (e) { + try { + http_request = new ActiveXObject('Microsoft.XMLHTTP'); + } catch (e) {} + } + } + if (!http_request) { + throw 'Both getURL and XMLHttpRequest are undefined'; + } + + http_request.onreadystatechange = function() { + if (http_request.readyState == 4) { + callback( { success : true, + content : http_request.responseText, + contentType : http_request.getResponseHeader("Content-Type") } ); + } + } + http_request.open('GET', url, true); + http_request.send(null); + } } window.setTimeout('update_status_thread()', 2500); //]]> diff --git a/usr/local/www/status_gateway_groups.php b/usr/local/www/status_gateway_groups.php index 20ea08f..1d6e9b5 100755 --- a/usr/local/www/status_gateway_groups.php +++ b/usr/local/www/status_gateway_groups.php @@ -29,7 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: routing */ @@ -42,8 +42,9 @@ require("guiconfig.inc"); -if (!is_array($config['gateways']['gateway_group'])) +if (!is_array($config['gateways']['gateway_group'])) { $config['gateways']['gateway_group'] = array(); +} $a_gateway_groups = &$config['gateways']['gateway_group']; $changedesc = gettext("Gateway Groups") . ": "; @@ -58,108 +59,114 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> - <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td> <?php $tab_array = array(); $tab_array[0] = array(gettext("Gateways"), false, "status_gateways.php"); $tab_array[1] = array(gettext("Gateway Groups"), true, "status_gateway_groups.php"); display_top_tabs($tab_array); ?> -</td></tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td width="20%" class="listhdrr"><?=gettext("Group Name"); ?></td> - <td width="50%" class="listhdrr"><?=gettext("Gateways"); ?></td> - <td width="30%" class="listhdr"><?=gettext("Description"); ?></td> - </tr> - <?php $i = 0; foreach ($a_gateway_groups as $gateway_group): ?> - <tr> - <td class="listlr"> - <?php - echo $gateway_group['name']; - ?> - - </td> - <td class="listr"> - <table border='0'> - <?php - /* process which priorities we have */ - $priorities = array(); - foreach($gateway_group['item'] as $item) { - $itemsplit = explode("|", $item); - $priorities[$itemsplit[1]] = true; - } - $priority_count = count($priorities); - ksort($priorities); - - echo "<tr>"; - foreach($priorities as $number => $tier) { - echo "<td width='120'>" . sprintf(gettext("Tier %s"), $number) . "</td>"; - } - echo "</tr>\n"; - - /* inverse gateway group to gateway priority */ - $priority_arr = array(); - foreach($gateway_group['item'] as $item) { - $itemsplit = explode("|", $item); - $priority_arr[$itemsplit[1]][] = $itemsplit[0]; - } - ksort($priority_arr); - $p = 1; - foreach($priority_arr as $number => $tier) { - /* for each priority process the gateways */ - foreach($tier as $member) { - /* we always have $priority_count fields */ - echo "<tr>"; - $c = 1; - while($c <= $priority_count) { - $monitor = lookup_gateway_monitor_ip_by_name($member); - if($p == $c) { - $status = $gateways_status[$monitor]['status']; - if (stristr($status, "down")) { - $online = gettext("Offline"); - $bgcolor = "#F08080"; // lightcoral - } elseif (stristr($status, "loss")) { - $online = gettext("Warning, Packetloss"); - $bgcolor = "#F0E68C"; // khaki - } elseif (stristr($status, "delay")) { - $online = gettext("Warning, Latency"); - $bgcolor = "#F0E68C"; // khaki - } elseif ($status == "none") { - $online = gettext("Online"); - $bgcolor = "#90EE90"; // lightgreen - } else { - $online = gettext("Gathering data"); - $bgcolor = "#ADD8E6"; // lightblue - } - echo "<td bgcolor='$bgcolor'> ". htmlspecialchars($member) .", $online </td>"; + </td> + </tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td width="20%" class="listhdrr"><?=gettext("Group Name"); ?></td> + <td width="50%" class="listhdrr"><?=gettext("Gateways"); ?></td> + <td width="30%" class="listhdr"><?=gettext("Description"); ?></td> + </tr> +<?php + $i = 0; + foreach ($a_gateway_groups as $gateway_group): +?> + <tr> + <td class="listlr"> +<?php + echo $gateway_group['name']; +?> + </td> + <td class="listr"> + <table border='0'> +<?php + /* process which priorities we have */ + $priorities = array(); + foreach ($gateway_group['item'] as $item) { + $itemsplit = explode("|", $item); + $priorities[$itemsplit[1]] = true; + } + $priority_count = count($priorities); + ksort($priorities); + + echo "<tr>"; + foreach ($priorities as $number => $tier) { + echo "<td width='120'>" . sprintf(gettext("Tier %s"), $number) . "</td>"; + } + echo "</tr>\n"; + + /* inverse gateway group to gateway priority */ + $priority_arr = array(); + foreach ($gateway_group['item'] as $item) { + $itemsplit = explode("|", $item); + $priority_arr[$itemsplit[1]][] = $itemsplit[0]; + } + ksort($priority_arr); + $p = 1; + foreach ($priority_arr as $number => $tier) { + /* for each priority process the gateways */ + foreach ($tier as $member) { + /* we always have $priority_count fields */ + echo "<tr>"; + $c = 1; + while ($c <= $priority_count) { + $monitor = lookup_gateway_monitor_ip_by_name($member); + if ($p == $c) { + $status = $gateways_status[$monitor]['status']; + if (stristr($status, "down")) { + $online = gettext("Offline"); + $bgcolor = "#F08080"; // lightcoral + } elseif (stristr($status, "loss")) { + $online = gettext("Warning, Packetloss"); + $bgcolor = "#F0E68C"; // khaki + } elseif (stristr($status, "delay")) { + $online = gettext("Warning, Latency"); + $bgcolor = "#F0E68C"; // khaki + } elseif ($status == "none") { + $online = gettext("Online"); + $bgcolor = "#90EE90"; // lightgreen } else { - echo "<td> </td>"; + $online = gettext("Gathering data"); + $bgcolor = "#ADD8E6"; // lightblue } - $c++; + echo "<td bgcolor='$bgcolor'> ". htmlspecialchars($member) .", $online </td>"; + } else { + echo "<td> </td>"; } - echo "</tr>\n"; + $c++; } - $p++; + echo "</tr>\n"; } - ?> - </table> - </td> - <td class="listbg"> - <?=htmlspecialchars($gateway_group['descr']);?> - </td> - </tr> - <?php $i++; endforeach; ?> - - </table> - </div> - </td> - </tr> + $p++; + } +?> + </table> + </td> + <td class="listbg"> + <?=htmlspecialchars($gateway_group['descr']);?> + </td> + </tr> +<?php + $i++; + endforeach; +?> + + </table> + </div> + </td> + </tr> </table> <?php include("fend.inc"); ?> </body> diff --git a/usr/local/www/status_gateways.php b/usr/local/www/status_gateways.php index 5910ef5..1d77689 100644 --- a/usr/local/www/status_gateways.php +++ b/usr/local/www/status_gateways.php @@ -29,7 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: routing */ @@ -57,101 +57,111 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr><td class="tabnavtbl"> + <tr><td class="tabnavtbl"> <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Gateways"), true, "status_gateways.php"); - $tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php"); - display_top_tabs($tab_array); + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Gateways"), true, "status_gateways.php"); + $tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php"); + display_top_tabs($tab_array); ?> - </td></tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td width="10%" class="listhdrr"><?=gettext("Name"); ?></td> - <td width="10%" class="listhdrr"><?=gettext("Gateway"); ?></td> - <td width="10%" class="listhdrr"><?=gettext("Monitor"); ?></td> - <td width="8%" class="listhdrr"><?=gettext("RTT"); ?></td> - <td width="7%" class="listhdrr"><?=gettext("Loss"); ?></td> - <td width="35%" class="listhdrr"><?=gettext("Status"); ?></td> - <td width="20%" class="listhdr"><?=gettext("Description"); ?></td> - </tr> - <?php foreach ($a_gateways as $gname => $gateway) { - ?> - <tr> - <td class="listlr"> - <?=$gateway['name'];?> - </td> - <td class="listr" align="center" > - <?php echo lookup_gateway_ip_by_name($gname);?> - </td> - <td class="listr" align="center" > - <?php if ($gateways_status[$gname]) - echo $gateways_status[$gname]['monitorip']; - else - echo $gateway['monitorip']; - ?> - </td> - <td class="listr" align="center"> - <?php if ($gateways_status[$gname]) - echo $gateways_status[$gname]['delay']; - else - echo gettext("Pending"); - ?> - </td> - <td class="listr" align="center"> - <?php if ($gateways_status[$gname]) - echo $gateways_status[$gname]['loss']; - else - echo gettext("Pending"); - ?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td width="10%" class="listhdrr"><?=gettext("Name"); ?></td> + <td width="10%" class="listhdrr"><?=gettext("Gateway"); ?></td> + <td width="10%" class="listhdrr"><?=gettext("Monitor"); ?></td> + <td width="8%" class="listhdrr"><?=gettext("RTT"); ?></td> + <td width="7%" class="listhdrr"><?=gettext("Loss"); ?></td> + <td width="35%" class="listhdrr"><?=gettext("Status"); ?></td> + <td width="20%" class="listhdr"><?=gettext("Description"); ?></td> + </tr> +<?php + foreach ($a_gateways as $gname => $gateway) { +?> + <tr> + <td class="listlr"> + <?=$gateway['name'];?> + </td> + <td class="listr" align="center" > + <?php echo lookup_gateway_ip_by_name($gname);?> + </td> + <td class="listr" align="center" > + <?php + if ($gateways_status[$gname]) { + echo $gateways_status[$gname]['monitorip']; + } else { + echo $gateway['monitorip']; + } + ?> + </td> + <td class="listr" align="center"> + <?php + if ($gateways_status[$gname]) { + echo $gateways_status[$gname]['delay']; + } else { + echo gettext("Pending"); + } + ?> + </td> + <td class="listr" align="center"> + <?php + if ($gateways_status[$gname]) { + echo $gateways_status[$gname]['loss']; + } else { + echo gettext("Pending"); + } + ?> + </td> + <td class="listr" > + <table border="0" cellpadding="0" cellspacing="2"> + <?php + if ($gateways_status[$gname]) { + $status = $gateways_status[$gname]; + if (stristr($status['status'], "force_down")) { + $online = gettext("Offline (forced)"); + $bgcolor = "#F08080"; // lightcoral + } elseif (stristr($status['status'], "down")) { + $online = gettext("Offline"); + $bgcolor = "#F08080"; // lightcoral + } elseif (stristr($status['status'], "loss")) { + $online = gettext("Warning, Packetloss").': '.$status['loss']; + $bgcolor = "#F0E68C"; // khaki + } elseif (stristr($status['status'], "delay")) { + $online = gettext("Warning, Latency").': '.$status['delay']; + $bgcolor = "#F0E68C"; // khaki + } elseif ($status['status'] == "none") { + $online = gettext("Online"); + $bgcolor = "#90EE90"; // lightgreen + } + } else if (isset($gateway['monitor_disable'])) { + $online = gettext("Online"); + $bgcolor = "#90EE90"; // lightgreen + } else { + $online = gettext("Pending"); + $bgcolor = "#D3D3D3"; // lightgray + } + echo "<tr><td><table width='100%'><tr><td bgcolor=\"$bgcolor\"> $online </td></tr><tr><td>"; + $lastchange = $gateways_status[$gname]['lastcheck']; + if (!empty($lastchange)) { + echo gettext("Last check:") . '<br />' . $lastchange; + } + echo "</td></tr></table></td></tr>"; + ?> + </table> + </td> + <td class="listbg"> <?=$gateway['descr']; ?></td> + </tr> +<?php + } // foreach gateway +?> + </table> + </div> </td> - <td class="listr" > - <table border="0" cellpadding="0" cellspacing="2"> - <?php - if ($gateways_status[$gname]) { - $status = $gateways_status[$gname]; - if (stristr($status['status'], "force_down")) { - $online = gettext("Offline (forced)"); - $bgcolor = "#F08080"; // lightcoral - } elseif (stristr($status['status'], "down")) { - $online = gettext("Offline"); - $bgcolor = "#F08080"; // lightcoral - } elseif (stristr($status['status'], "loss")) { - $online = gettext("Warning, Packetloss").': '.$status['loss']; - $bgcolor = "#F0E68C"; // khaki - } elseif (stristr($status['status'], "delay")) { - $online = gettext("Warning, Latency").': '.$status['delay']; - $bgcolor = "#F0E68C"; // khaki - } elseif ($status['status'] == "none") { - $online = gettext("Online"); - $bgcolor = "#90EE90"; // lightgreen - } - } else if (isset($gateway['monitor_disable'])) { - $online = gettext("Online"); - $bgcolor = "#90EE90"; // lightgreen - } else { - $online = gettext("Pending"); - $bgcolor = "#D3D3D3"; // lightgray - } - echo "<tr><td><table width='100%'><tr><td bgcolor=\"$bgcolor\"> $online </td></tr><tr><td>"; - $lastchange = $gateways_status[$gname]['lastcheck']; - if(!empty($lastchange)) { - echo gettext("Last check:") . '<br />' . $lastchange; - } - echo "</td></tr></table></td></tr>"; - ?> - </table> - </td> - <td class="listbg"> <?=$gateway['descr']; ?></td> - </tr> - <?php } ?> - </table> - </div> -</td></tr> + </tr> </table> <?php include("fend.inc"); ?> diff --git a/usr/local/www/status_graph.php b/usr/local/www/status_graph.php index 3c8ba8f..28d13c1 100644 --- a/usr/local/www/status_graph.php +++ b/usr/local/www/status_graph.php @@ -32,7 +32,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: routing */ @@ -48,20 +48,23 @@ require("guiconfig.inc"); -if ($_POST['width']) +if ($_POST['width']) { $width = $_POST['width']; -else +} else { $width = "100%"; +} -if ($_POST['height']) +if ($_POST['height']) { $height = $_POST['height']; -else +} else { $height = "200"; +} // Get configured interface list $ifdescrs = get_configured_interface_with_descr(); -if (isset($config['ipsec']['enable'])) +if (isset($config['ipsec']['enable'])) { $ifdescrs['enc0'] = "IPsec"; +} foreach (array('server', 'client') as $mode) { if (is_array($config['openvpn']["openvpn-{$mode}"])) { foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) { @@ -90,8 +93,7 @@ if ($_GET['if']) { /* Handle the case when WAN has been disabled. Use the first key in ifdescrs. */ reset($ifdescrs); $curif = key($ifdescrs); - } - else { + } else { $curif = "wan"; } } @@ -122,42 +124,42 @@ include("head.inc"); <script type="text/javascript"> //<![CDATA[ -function updateBandwidth(){ - var hostinterface = jQuery("#if").val(); +function updateBandwidth() { + var hostinterface = jQuery("#if").val(); var sorting = jQuery("#sort").val(); var filter = jQuery("#filter").val(); var hostipformat = jQuery("#hostipformat").val(); - bandwidthAjax(hostinterface, sorting, filter, hostipformat); + bandwidthAjax(hostinterface, sorting, filter, hostipformat); } function bandwidthAjax(hostinterface, sorting, filter, hostipformat) { uri = "bandwidth_by_ip.php?if=" + hostinterface + "&sort=" + sorting + "&filter=" + filter + "&hostipformat=" + hostipformat; var opt = { - // Use GET - type: 'get', - error: function(req) { - /* XXX: Leave this for debugging purposes: Handle 404 - if(req.status == 404) - alert('Error 404: location "' + uri + '" was not found.'); - */ - /* Handle other errors - else - alert('Error ' + req.status + ' -- ' + req.statusText + ' -- ' + uri); - */ - }, + // Use GET + type: 'get', + error: function(req) { + /* XXX: Leave this for debugging purposes: Handle 404 + if (req.status == 404) + alert('Error 404: location "' + uri + '" was not found.'); + */ + /* Handle other errors + else + alert('Error ' + req.status + ' -- ' + req.statusText + ' -- ' + uri); + */ + }, success: function(data) { updateBandwidthHosts(data); - } + } } jQuery.ajax(uri, opt); } -function updateBandwidthHosts(data){ - var hosts_split = data.split("|"); - d = document; - //parse top ten bandwidth abuser hosts - for (var y=0; y<10; y++){ - if ((y < hosts_split.length) && (hosts_split[y] != "") && (hosts_split[y] != "no info")) { +function updateBandwidthHosts(data) { + var hosts_split = data.split("|"); + d = document; + //parse top ten bandwidth abuser hosts + for (var y=0; y<10; y++) { + if ((y < hosts_split.length) && (hosts_split[y] != "") && (hosts_split[y] != "no info")) { hostinfo = hosts_split[y].split(";"); //update host ip info @@ -177,22 +179,20 @@ function updateBandwidthHosts(data){ //make the row appear if hidden var rowid = "#host" + y; - if (jQuery(rowid).css('display') == "none"){ + if (jQuery(rowid).css('display') == "none") { //hide rows that contain no data jQuery(rowid).show(1000); } - } - else - { - var rowid = "#host" + y; - if (jQuery(rowid).css('display') != "none"){ - //hide rows that contain no data - jQuery(rowid).fadeOut(2000); - } - } - } - - setTimeout('updateBandwidth()', 1000); + } else { + var rowid = "#host" + y; + if (jQuery(rowid).css('display') != "none") { + //hide rows that contain no data + jQuery(rowid).fadeOut(2000); + } + } + } + + setTimeout('updateBandwidth()', 1000); } //]]> </script> @@ -200,138 +200,141 @@ function updateBandwidthHosts(data){ <?php /* link the ipsec interface magically */ -if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) +if (isset($config['ipsec']['enable']) || isset($config['ipsec']['client']['enable'])) { $ifdescrs['enc0'] = "IPsec"; +} ?> <form name="form1" action="status_graph.php" method="get" style="padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid #999999"> <?=gettext("Interface"); ?>: -<select id="if" name="if" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> + <select id="if" name="if" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> <?php -foreach ($ifdescrs as $ifn => $ifd) { - echo "<option value=\"$ifn\""; - if ($ifn == $curif) echo " selected=\"selected\""; - echo ">" . htmlspecialchars($ifd) . "</option>\n"; -} + foreach ($ifdescrs as $ifn => $ifd) { + echo "<option value=\"$ifn\""; + if ($ifn == $curif) { + echo " selected=\"selected\""; + } + echo ">" . htmlspecialchars($ifd) . "</option>\n"; + } ?> -</select> -, Sort by: -<select id="sort" name="sort" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> - <option value="">Bw In</option> - <option value="out"<?php if ($cursort == "out") echo " selected=\"selected\"";?>>Bw Out</option> -</select> -, Filter: -<select id="filter" name="filter" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> - <option value="local"<?php if ($curfilter == "local") echo " selected=\"selected\"";?>>Local</option> - <option value="remote"<?php if ($curfilter == "remote") echo " selected=\"selected\"";?>>Remote</option> - <option value="all"<?php if ($curfilter == "all") echo " selected=\"selected\"";?>>All</option> -</select> -, Display: -<select id="hostipformat" name="hostipformat" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> - <option value="">IP Address</option> - <option value="hostname"<?php if ($curhostipformat == "hostname") echo " selected";?>>Host Name</option> - <option value="fqdn"<?php if ($curhostipformat == "fqdn") echo " selected=\"selected\"";?>>FQDN</option> -</select> + </select> +, Sort by: + <select id="sort" name="sort" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> + <option value="">Bw In</option> + <option value="out"<?php if ($cursort == "out") echo " selected=\"selected\"";?>>Bw Out</option> + </select> +, Filter: + <select id="filter" name="filter" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> + <option value="local"<?php if ($curfilter == "local") echo " selected=\"selected\"";?>>Local</option> + <option value="remote"<?php if ($curfilter == "remote") echo " selected=\"selected\"";?>>Remote</option> + <option value="all"<?php if ($curfilter == "all") echo " selected=\"selected\"";?>>All</option> + </select> +, Display: + <select id="hostipformat" name="hostipformat" class="formselect" style="z-index: -10;" onchange="document.form1.submit()"> + <option value="">IP Address</option> + <option value="hostname"<?php if ($curhostipformat == "hostname") echo " selected";?>>Host Name</option> + <option value="fqdn"<?php if ($curhostipformat == "fqdn") echo " selected=\"selected\"";?>>FQDN</option> + </select> </form> <p> </p> <div id="niftyOutter"> - <div id="col1" style="float: left; width: 46%; padding: 5px; position: relative;"> - <object data="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=rawurlencode($ifdescrs[htmlspecialchars($curif)]);?>"> - <param name="id" value="graph" /> - <param name="type" value="image/svg+xml" /> - <param name="width" value="<? echo $width; ?>" /> - <param name="height" value="<? echo $height; ?>" /> - <param name="pluginspage" value="http://www.adobe.com/svg/viewer/install/auto" /> - </object> - </div> - <div id="col2" style="float: right; width: 48%; padding: 5px; position: relative;"> - <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="status"> - <tr> - <td class="listtopic" valign="top"><?=(($curhostipformat=="") ? gettext("Host IP") : gettext("Host Name or IP")); ?></td> - <td class="listtopic" valign="top"><?=gettext("Bandwidth In"); ?></td> - <td class="listtopic" valign="top"><?=gettext("Bandwidth Out"); ?></td> - </tr> - <tr id="host0" style="display:none"> - <td id="hostip0" class="vncell"> - </td> - <td id="bandwidthin0" class="listr"> - </td> - <td id="bandwidthout0" class="listr"> - </td> - </tr> - <tr id="host1" style="display:none"> - <td id="hostip1" class="vncell"> - </td> - <td id="bandwidthin1" class="listr"> - </td> - <td id="bandwidthout1" class="listr"> - </td> - </tr> - <tr id="host2" style="display:none"> - <td id="hostip2" class="vncell"> - </td> - <td id="bandwidthin2" class="listr"> - </td> - <td id="bandwidthout2" class="listr"> - </td> - </tr> - <tr id="host3" style="display:none"> - <td id="hostip3" class="vncell"> - </td> - <td id="bandwidthin3" class="listr"> - </td> - <td id="bandwidthout3" class="listr"> - </td> - </tr> - <tr id="host4" style="display:none"> - <td id="hostip4" class="vncell"> - </td> - <td id="bandwidthin4" class="listr"> - </td> - <td id="bandwidthout4" class="listr"> - </td> - </tr> - <tr id="host5" style="display:none"> - <td id="hostip5" class="vncell"> - </td> - <td id="bandwidthin5" class="listr"> - </td> - <td id="bandwidthout5" class="listr"> - </td> - </tr> - <tr id="host6" style="display:none"> - <td id="hostip6" class="vncell"> - </td> - <td id="bandwidthin6" class="listr"> - </td> - <td id="bandwidthout6" class="listr"> - </td> - </tr> - <tr id="host7" style="display:none"> - <td id="hostip7" class="vncell"> - </td> - <td id="bandwidthin7" class="listr"> - </td> - <td id="bandwidthout7" class="listr"> - </td> - </tr> - <tr id="host8" style="display:none"> - <td id="hostip8" class="vncell"> - </td> - <td id="bandwidthin8" class="listr"> - </td> - <td id="bandwidthout8" class="listr"> - </td> - </tr> - <tr id="host9" style="display:none"> - <td id="hostip9" class="vncell"> - </td> - <td id="bandwidthin9" class="listr"> - </td> - <td id="bandwidthout9" class="listr"> - </td> - </tr> - </table> + <div id="col1" style="float: left; width: 46%; padding: 5px; position: relative;"> + <object data="graph.php?ifnum=<?=htmlspecialchars($curif);?>&ifname=<?=rawurlencode($ifdescrs[htmlspecialchars($curif)]);?>"> + <param name="id" value="graph" /> + <param name="type" value="image/svg+xml" /> + <param name="width" value="<? echo $width; ?>" /> + <param name="height" value="<? echo $height; ?>" /> + <param name="pluginspage" value="http://www.adobe.com/svg/viewer/install/auto" /> + </object> + </div> + <div id="col2" style="float: right; width: 48%; padding: 5px; position: relative;"> + <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="status"> + <tr> + <td class="listtopic" valign="top"><?=(($curhostipformat=="") ? gettext("Host IP") : gettext("Host Name or IP")); ?></td> + <td class="listtopic" valign="top"><?=gettext("Bandwidth In"); ?></td> + <td class="listtopic" valign="top"><?=gettext("Bandwidth Out"); ?></td> + </tr> + <tr id="host0" style="display:none"> + <td id="hostip0" class="vncell"> + </td> + <td id="bandwidthin0" class="listr"> + </td> + <td id="bandwidthout0" class="listr"> + </td> + </tr> + <tr id="host1" style="display:none"> + <td id="hostip1" class="vncell"> + </td> + <td id="bandwidthin1" class="listr"> + </td> + <td id="bandwidthout1" class="listr"> + </td> + </tr> + <tr id="host2" style="display:none"> + <td id="hostip2" class="vncell"> + </td> + <td id="bandwidthin2" class="listr"> + </td> + <td id="bandwidthout2" class="listr"> + </td> + </tr> + <tr id="host3" style="display:none"> + <td id="hostip3" class="vncell"> + </td> + <td id="bandwidthin3" class="listr"> + </td> + <td id="bandwidthout3" class="listr"> + </td> + </tr> + <tr id="host4" style="display:none"> + <td id="hostip4" class="vncell"> + </td> + <td id="bandwidthin4" class="listr"> + </td> + <td id="bandwidthout4" class="listr"> + </td> + </tr> + <tr id="host5" style="display:none"> + <td id="hostip5" class="vncell"> + </td> + <td id="bandwidthin5" class="listr"> + </td> + <td id="bandwidthout5" class="listr"> + </td> + </tr> + <tr id="host6" style="display:none"> + <td id="hostip6" class="vncell"> + </td> + <td id="bandwidthin6" class="listr"> + </td> + <td id="bandwidthout6" class="listr"> + </td> + </tr> + <tr id="host7" style="display:none"> + <td id="hostip7" class="vncell"> + </td> + <td id="bandwidthin7" class="listr"> + </td> + <td id="bandwidthout7" class="listr"> + </td> + </tr> + <tr id="host8" style="display:none"> + <td id="hostip8" class="vncell"> + </td> + <td id="bandwidthin8" class="listr"> + </td> + <td id="bandwidthout8" class="listr"> + </td> + </tr> + <tr id="host9" style="display:none"> + <td id="hostip9" class="vncell"> + </td> + <td id="bandwidthin9" class="listr"> + </td> + <td id="bandwidthout9" class="listr"> + </td> + </tr> + </table> </div> <div style="clear: both;"></div> </div> diff --git a/usr/local/www/status_graph_cpu.php b/usr/local/www/status_graph_cpu.php index a95c1e6..6712508 100644 --- a/usr/local/www/status_graph_cpu.php +++ b/usr/local/www/status_graph_cpu.php @@ -1,22 +1,22 @@ -<?php +<?php /* $Id$ part of m0n0wall (http://m0n0.ch/wall) - + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. Copyright (C) 2013-2015 Electric Sheep Fencing, LP 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 @@ -28,7 +28,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: system */ @@ -48,7 +48,7 @@ $pgtitle = gettext("Status: CPU Graph"); ?> <div align="center"> -<embed src="graph_cpu.php" type="image/svg+xml" + <embed src="graph_cpu.php" type="image/svg+xml" width="550" height="275" pluginspage="http://www.adobe.com/svg/viewer/install/auto" /> </div> <br /><span class="red"><strong><?=gettext("Note"); ?>:</strong></span> <?=gettext("if you can't see the graph, you may have to install the"); ?> <a href="http://www.adobe.com/svg/viewer/install/" target="_blank"><?=gettext("Adobe SVG viewer"); ?></a>. diff --git a/usr/local/www/status_interfaces.php b/usr/local/www/status_interfaces.php index f98adea..190765f 100644 --- a/usr/local/www/status_interfaces.php +++ b/usr/local/www/status_interfaces.php @@ -32,7 +32,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_MODULE: interfaces */ @@ -49,10 +49,11 @@ require_once("filter.inc"); if ($_POST['if'] && $_POST['submit']) { $interface = $_POST['if']; - if ($_POST['status'] == "up") + if ($_POST['status'] == "up") { interface_bring_down($interface); - else - interface_configure($interface); + } else { + interface_configure($interface); + } header("Location: status_interfaces.php"); exit; } @@ -66,19 +67,23 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0" summary="status interfaces"> -<?php - $i = 0; +<?php + $i = 0; $ifdescrs = get_configured_interface_with_descr(false, true); foreach ($ifdescrs as $ifdescr => $ifname): - $ifinfo = get_interface_info($ifdescr); - // Load MAC-Manufacturer table - $mac_man = load_mac_manufacturer_table(); + $ifinfo = get_interface_info($ifdescr); + // Load MAC-Manufacturer table + $mac_man = load_mac_manufacturer_table(); +?> +<?php + if ($i): ?> -<?php if ($i): ?> <tr> <td colspan="8" class="list" height="12"></td> </tr> -<?php endif; ?> +<?php + endif; +?> <tr> <td colspan="2" class="listtopic"> <?=htmlspecialchars($ifname);?> <?=gettext("interface"); ?> (<?=htmlspecialchars($ifdescr);?>, <?=htmlspecialchars($ifinfo['hwif']);?>) @@ -90,7 +95,9 @@ include("head.inc"); <?=htmlspecialchars($ifinfo['status']);?> </td> </tr> - <?php if ($ifinfo['dhcplink']): ?> +<?php + if ($ifinfo['dhcplink']): +?> <tr> <td width="22%" class="vncellt"> DHCP @@ -105,8 +112,10 @@ include("head.inc"); </form> </td> </tr> - <?php endif; - if ($ifinfo['dhcp6link']): ?> +<?php + endif; + if ($ifinfo['dhcp6link']): +?> <tr> <td width="22%" class="vncellt"> DHCP6 @@ -121,7 +130,10 @@ include("head.inc"); </form> </td> </tr> - <?php endif; if ($ifinfo['pppoelink']): ?> +<?php + endif; + if ($ifinfo['pppoelink']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("PPPoE"); ?></td> <td width="78%" class="listr"> @@ -134,7 +146,10 @@ include("head.inc"); </form> </td> </tr> - <?php endif; if ($ifinfo['pptplink']): ?> +<?php + endif; + if ($ifinfo['pptplink']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("PPTP"); ?></td> <td width="78%" class="listr"> @@ -147,7 +162,10 @@ include("head.inc"); </form> </td> </tr> - <?php endif; if ($ifinfo['l2tplink']): ?> +<?php + endif; + if ($ifinfo['l2tplink']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("L2TP"); ?></td> <td width="78%" class="listr"> @@ -160,7 +178,10 @@ include("head.inc"); </form> </td> </tr> - <?php endif; if ($ifinfo['ppplink']): ?> +<?php + endif; + if ($ifinfo['ppplink']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("PPP"); ?></td> <td width="78%" class="listr"> @@ -178,99 +199,143 @@ include("head.inc"); </form> </td> </tr> - <?php endif; if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): ?> +<?php + endif; + if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Uptime ");?><?php if ($ifinfo['ppp_uptime_accumulated']) echo "(historical)"; ?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['ppp_uptime']);?> <?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?> </td> - </tr> - <?php endif; if ($ifinfo['cell_rssi']): ?> + </tr> +<?php + endif; + if ($ifinfo['cell_rssi']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Cell Signal (RSSI)");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['cell_rssi']);?> </td> - </tr> - <?php endif; if ($ifinfo['cell_mode']): ?> + </tr> +<?php + endif; + if ($ifinfo['cell_mode']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Cell Mode");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['cell_mode']);?> </td> - </tr> - <?php endif; if ($ifinfo['cell_simstate']): ?> + </tr> +<?php + endif; + if ($ifinfo['cell_simstate']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Cell SIM State");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['cell_simstate']);?> </td> - </tr> - <?php endif; if ($ifinfo['cell_service']): ?> + </tr> +<?php + endif; + if ($ifinfo['cell_service']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Cell Service");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['cell_service']);?> </td> - </tr> - <?php endif; if ($ifinfo['cell_bwupstream']): ?> + </tr> +<?php + endif; + if ($ifinfo['cell_bwupstream']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Cell Upstream");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['cell_bwupstream']);?> kbit/s </td> - </tr> - <?php endif; if ($ifinfo['cell_bwdownstream']): ?> + </tr> +<?php + endif; + if ($ifinfo['cell_bwdownstream']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Cell Downstream");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['cell_bwdownstream']);?> kbit/s </td> - </tr> - <?php endif; if ($ifinfo['cell_upstream']): ?> + </tr> +<?php + endif; + if ($ifinfo['cell_upstream']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Cell Current Up");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['cell_upstream']);?> kbit/s </td> - </tr> - <?php endif; if ($ifinfo['cell_downstream']): ?> + </tr> +<?php + endif; + if ($ifinfo['cell_downstream']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Cell Current Down");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['cell_downstream']);?> kbit/s </td> - </tr> - <?php endif; if ($ifinfo['macaddr']): ?> + </tr> +<?php + endif; + if ($ifinfo['macaddr']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("MAC address");?></td> <td width="78%" class="listr"> - <?php - $mac=$ifinfo['macaddr']; + <?php + $mac=$ifinfo['macaddr']; $mac_hi = strtoupper($mac[0] . $mac[1] . $mac[3] . $mac[4] . $mac[6] . $mac[7]); - if(isset($mac_man[$mac_hi])){ print "<span>" . $mac . " - " . htmlspecialchars($mac_man[$mac_hi]); print "</span>"; } - else {print htmlspecialchars($mac);} + if (isset($mac_man[$mac_hi])) { + print "<span>" . $mac . " - " . htmlspecialchars($mac_man[$mac_hi]); print "</span>"; + } else { + print htmlspecialchars($mac); + } ?> </td> </tr> - <?php endif; if ($ifinfo['status'] != "down"): ?> - <?php if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): ?> - <?php if ($ifinfo['ipaddr']): ?> +<?php + endif; + if ($ifinfo['status'] != "down"): +?> +<?php + if ($ifinfo['dhcplink'] != "down" && $ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down"): + if ($ifinfo['ipaddr']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("IPv4 address");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['ipaddr']);?> - + </td> </tr> - <?php endif; ?><?php if ($ifinfo['subnet']): ?> +<?php + endif; + if ($ifinfo['subnet']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Subnet mask IPv4");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['subnet']);?> </td> </tr> - <?php endif; ?><?php if ($ifinfo['gateway']): ?> +<?php + endif; + if ($ifinfo['gateway']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Gateway IPv4");?></td> <td width="78%" class="listr"> @@ -278,30 +343,42 @@ include("head.inc"); <?=htmlspecialchars($ifinfo['gateway']);?> </td> </tr> - <?php endif; ?><?php if ($ifinfo['linklocal']): ?> +<?php + endif; + if ($ifinfo['linklocal']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("IPv6 Link Local");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['linklocal']);?> - + </td> </tr> - <?php endif; ?><?php if ($ifinfo['ipaddrv6']): ?> +<?php + endif; + if ($ifinfo['ipaddrv6']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("IPv6 address");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['ipaddrv6']);?> - + </td> </tr> - <?php endif; ?><?php if ($ifinfo['subnetv6']): ?> +<?php + endif; + if ($ifinfo['subnetv6']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Subnet mask IPv6");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['subnetv6']);?> </td> </tr> - <?php endif; ?><?php if ($ifinfo['gatewayv6']): ?> +<?php + endif; + if ($ifinfo['gatewayv6']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Gateway IPv6");?></td> <td width="78%" class="listr"> @@ -309,84 +386,122 @@ include("head.inc"); <?=htmlspecialchars($ifinfo['gatewayv6']);?> </td> </tr> - <?php endif; if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): ?> +<?php + endif; + if ($ifdescr == "wan" && file_exists("{$g['varetc_path']}/resolv.conf")): +?> <tr> - <td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td> - <td width="78%" class="listr"> - <?php - $dns_servers = get_dns_servers(); - foreach($dns_servers as $dns) { - echo "{$dns}<br />"; - } - ?> + <td width="22%" class="vncellt"><?=gettext("ISP DNS servers");?></td> + <td width="78%" class="listr"> + <?php + $dns_servers = get_dns_servers(); + foreach ($dns_servers as $dns) { + echo "{$dns}<br />"; + } + ?> </td> </tr> - <?php endif; endif; if ($ifinfo['mtu']): ?> +<?php + endif; + endif; + if ($ifinfo['mtu']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("MTU");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['mtu']);?> </td> </tr> - <?php endif; if ($ifinfo['media']): ?> +<?php + endif; + if ($ifinfo['media']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Media");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['media']);?> </td> </tr> - <?php endif; if ($ifinfo['laggproto']): ?> +<?php + endif; + if ($ifinfo['laggproto']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("LAGG Protocol");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['laggproto']);?> </td> </tr> - <?php endif; if (is_array($ifinfo['laggport'])): ?> +<?php + endif; + if (is_array($ifinfo['laggport'])): +?> <tr> <td width="22%" class="vncellt"><?=gettext("LAGG Ports");?></td> <td width="78%" class="listr"> - <?php foreach ($ifinfo['laggport'] as $laggport) { ?> - <?php echo htmlspecialchars($laggport); ?><br /> - <?php } ?> + <?php + foreach ($ifinfo['laggport'] as $laggport) { + echo htmlspecialchars($laggport); + ?> + <br /> + <?php + } + ?> </td> </tr> -<?php endif; ?><?php if ($ifinfo['channel']): ?> +<?php + endif; + if ($ifinfo['channel']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Channel");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['channel']);?> </td> </tr> -<?php endif; ?><?php if ($ifinfo['ssid']): ?> +<?php + endif; + if ($ifinfo['ssid']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("SSID");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['ssid']);?> </td> </tr> -<?php endif; ?><?php if ($ifinfo['bssid']): ?> +<?php + endif; + if ($ifinfo['bssid']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("BSSID");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['bssid']);?> </td> </tr> -<?php endif; ?><?php if ($ifinfo['rate']): ?> +<?php + endif; + if ($ifinfo['rate']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Rate");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['rate']);?> </td> </tr> -<?php endif; ?><?php if ($ifinfo['rssi']): ?> +<?php + endif; + if ($ifinfo['rssi']): +?> <tr> <td width="22%" class="vncellt"><?=gettext("RSSI");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['rssi']);?> </td> </tr> -<?php endif; ?> +<?php + endif; +?> <tr> <td width="22%" class="vncellt"><?=gettext("In/out packets");?></td> <td width="78%" class="listr"> @@ -399,61 +514,68 @@ include("head.inc"); <tr> <td width="22%" class="vncellt"><?=gettext("In/out packets (pass)");?></td> <td width="78%" class="listr"> - <?php - echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " ("); - echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")"); - ?> + <?php + echo htmlspecialchars($ifinfo['inpktspass'] . "/" . $ifinfo['outpktspass'] . " ("); + echo htmlspecialchars(format_bytes($ifinfo['inbytespass']) . "/" . format_bytes($ifinfo['outbytespass']) . ")"); + ?> </td> </tr> <tr> <td width="22%" class="vncellt"><?=gettext("In/out packets (block)");?></td> <td width="78%" class="listr"> - <?php - echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " ("); - echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")"); - ?> + <?php + echo htmlspecialchars($ifinfo['inpktsblock'] . "/" . $ifinfo['outpktsblock'] . " ("); + echo htmlspecialchars(format_bytes($ifinfo['inbytesblock']) . "/" . format_bytes($ifinfo['outbytesblock']) . ")"); + ?> </td> </tr> -<?php if (isset($ifinfo['inerrs'])): ?> +<?php + if (isset($ifinfo['inerrs'])): +?> <tr> <td width="22%" class="vncellt"><?=gettext("In/out errors");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['inerrs'] . "/" . $ifinfo['outerrs']);?> </td> </tr> -<?php endif; ?> -<?php if (isset($ifinfo['collisions'])): ?> +<?php + endif; + if (isset($ifinfo['collisions'])): +?> <tr> <td width="22%" class="vncellt"><?=gettext("Collisions");?></td> <td width="78%" class="listr"> <?=htmlspecialchars($ifinfo['collisions']);?> </td> </tr> -<?php endif; ?> -<?php endif; ?> -<?php if ($ifinfo['bridge']): ?> +<?php + endif; + endif; +?> +<?php + if ($ifinfo['bridge']): +?> <tr> <td width="22%" class="vncellt"><?php printf(gettext("Bridge (%s)"),$ifinfo['bridgeint']);?></td> <td width="78%" class="listr"> <?=$ifinfo['bridge'];?> </td> </tr> -<?php endif; ?> -<?php if(file_exists("/usr/bin/vmstat")): ?> <?php - $real_interface = ""; - $interrupt_total = ""; - $interrupt_sec = ""; - $real_interface = $ifinfo['hwif']; - $interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`; - $interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`; - if(strstr($interrupt_total, "hci")) { - $interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`; - $interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`; - } - unset($interrupt_total); // XXX: FIX ME! Need a regex and parse correct data 100% of the time. -?> -<?php if($interrupt_total): ?> + endif; + if (file_exists("/usr/bin/vmstat")): + $real_interface = ""; + $interrupt_total = ""; + $interrupt_sec = ""; + $real_interface = $ifinfo['hwif']; + $interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $3 }'`; + $interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $4 }'`; + if (strstr($interrupt_total, "hci")) { + $interrupt_total = `vmstat -i | grep $real_interface | awk '{ print $4 }'`; + $interrupt_sec = `vmstat -i | grep $real_interface | awk '{ print $5 }'`; + } + unset($interrupt_total); // XXX: FIX ME! Need a regex and parse correct data 100% of the time. + if ($interrupt_total): ?> <tr> <td width="22%" class="vncellt"><?=gettext("Interrupts/Second");?></td> <td width="78%" class="listr"> @@ -464,9 +586,12 @@ include("head.inc"); ?> </td> </tr> -<?php endif; ?> -<?php endif; ?> -<?php $i++; endforeach; ?> +<?php + endif; + endif; + $i++; + endforeach; +?> </table> <br /> diff --git a/usr/local/www/status_lb_pool.php b/usr/local/www/status_lb_pool.php index fcb5acb..d5b277d 100644 --- a/usr/local/www/status_lb_pool.php +++ b/usr/local/www/status_lb_pool.php @@ -74,7 +74,7 @@ if ($_POST) { $newservers = array(); foreach ($_POST as $name => $value) { /* Look through the POST vars to find the pool data */ - if (strpos($name, '|') !== false){ + if (strpos($name, '|') !== false) { list($poolname, $ip) = explode("|", $name); $ip = str_replace('_', '.', $ip); $newservers[$poolname][] = $ip; @@ -112,32 +112,34 @@ if ($_POST) { <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="status load balancer pools"> <tr><td class="tabnavtbl"> <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Pools"), true, "status_lb_pool.php"); - $tab_array[] = array(gettext("Virtual Servers"), false, "status_lb_vs.php"); - display_top_tabs($tab_array); + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Pools"), true, "status_lb_pool.php"); + $tab_array[] = array(gettext("Virtual Servers"), false, "status_lb_vs.php"); + display_top_tabs($tab_array); ?> </td></tr> <tr> - <td> - <div id="mainarea"> - <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont sortable" id="sortabletable" summary="main area"> - <tr> - <td width="10%" class="listhdrr"><?=gettext("Name");?></td> - <td width="10%" class="listhdrr"><?=gettext("Mode");?></td> - <td width="20%" class="listhdrr"><?=gettext("Servers");?></td> - <td width="10%" class="listhdrr"><?=gettext("Monitor");?></td> - <td width="30%" class="listhdr"><?=gettext("Description");?></td> - </tr> - <?php foreach ($a_pool as & $pool): ?> - <tr> - <td class="listlr"> - <?=$pool['name'];?> - </td> - <td class="listr" align="center" > - <?php - switch($pool['mode']) { + <td> + <div id="mainarea"> + <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont sortable" id="sortabletable" summary="main area"> + <tr> + <td width="10%" class="listhdrr"><?=gettext("Name");?></td> + <td width="10%" class="listhdrr"><?=gettext("Mode");?></td> + <td width="20%" class="listhdrr"><?=gettext("Servers");?></td> + <td width="10%" class="listhdrr"><?=gettext("Monitor");?></td> + <td width="30%" class="listhdr"><?=gettext("Description");?></td> + </tr> +<?php + foreach ($a_pool as & $pool): +?> + <tr> + <td class="listlr"> + <?=$pool['name'];?> + </td> + <td class="listr" align="center" > +<?php + switch ($pool['mode']) { case "loadbalance": echo "Load balancing"; break; @@ -147,11 +149,11 @@ if ($_POST) { default: echo "(default)"; } - ?> - </td> - <td class="listr" align="center"> - <table border="0" cellpadding="2" cellspacing="0" summary="status"> - <?php +?> + </td> + <td class="listr" align="center"> + <table border="0" cellpadding="2" cellspacing="0" summary="status"> +<?php $pool_hosts=array(); foreach ((array) $pool['servers'] as $server) { $svr['ip']['addr']=$server; @@ -168,7 +170,7 @@ if ($_POST) { asort($pool_hosts); foreach ((array) $pool_hosts as $server) { - if($server['ip']['addr']!="") { + if ($server['ip']['addr']!="") { switch ($server['ip']['state']) { case 'up': $bgcolor = "#90EE90"; // lightgreen @@ -193,31 +195,35 @@ if ($_POST) { } echo "<td bgcolor=\"{$bgcolor}\"> {$server['ip']['addr']}:{$pool['port']} </td><td bgcolor=\"{$bgcolor}\"> "; # echo "<td bgcolor=\"{$bgcolor}\"> {$server['ip']['addr']}:{$pool['port']} "; - if($server['ip']['avail']) - echo " ({$server['ip']['avail']}) "; + if ($server['ip']['avail']) { + echo " ({$server['ip']['avail']}) "; + } echo " </td></tr>"; } } - ?> - </table> - </td> - <td class="listr" > - <?php echo $pool['monitor']; ?> - </td> - <td class="listbg" > - <?=$pool['descr'];?> +?> + </table> + </td> + <td class="listr" > + <?php echo $pool['monitor']; ?> + </td> + <td class="listbg" > + <?=$pool['descr'];?> + </td> + </tr> +<?php + endforeach; +?> + <tr> + <td colspan="5"> + <input name="Submit" type="submit" class="formbtn" value="<?= gettext("Save"); ?>" /> + <input name="Reset" type="reset" class="formbtn" value="<?= gettext("Reset"); ?>" /> + </td> + </tr> + </table> + </div> </td> - </tr> - <?php endforeach; ?> - <tr> - <td colspan="5"> - <input name="Submit" type="submit" class="formbtn" value="<?= gettext("Save"); ?>" /> - <input name="Reset" type="reset" class="formbtn" value="<?= gettext("Reset"); ?>" /> - </td> - </tr> - </table> - </div> -</td></tr> + </tr> </table> </form> <?php include("fend.inc"); ?> diff --git a/usr/local/www/status_lb_vs.php b/usr/local/www/status_lb_vs.php index 62ae530..07c1736 100644 --- a/usr/local/www/status_lb_vs.php +++ b/usr/local/www/status_lb_vs.php @@ -61,84 +61,96 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="status load balancer virtual servers"> - <tr><td class="tabnavtbl"> - <?php - /* active tabs */ - $tab_array = array(); - $tab_array[] = array(gettext("Pools"), false, "status_lb_pool.php"); - $tab_array[] = array(gettext("Virtual Servers"), true, "status_lb_vs.php"); - display_top_tabs($tab_array); - ?> - </td></tr> - <tr> - <td> - <div id="mainarea"> - <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> - <tr> - <td width="10%" class="listhdrr"><?=gettext("Name"); ?></td> - <td width="20%" class="listhdrr"><?=gettext("Address"); ?></td> - <td width="10%" class="listhdrr"><?=gettext("Servers"); ?></td> - <td width="25%" class="listhdrr"><?=gettext("Status"); ?></td> - <td width="25%" class="listhdr"><?=gettext("Description"); ?></td> + <tr><td class="tabnavtbl"> + <?php + /* active tabs */ + $tab_array = array(); + $tab_array[] = array(gettext("Pools"), false, "status_lb_pool.php"); + $tab_array[] = array(gettext("Virtual Servers"), true, "status_lb_vs.php"); + display_top_tabs($tab_array); + ?> + </td></tr> + <tr> + <td> + <div id="mainarea"> + <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> + <tr> + <td width="10%" class="listhdrr"><?=gettext("Name"); ?></td> + <td width="20%" class="listhdrr"><?=gettext("Address"); ?></td> + <td width="10%" class="listhdrr"><?=gettext("Servers"); ?></td> + <td width="25%" class="listhdrr"><?=gettext("Status"); ?></td> + <td width="25%" class="listhdr"><?=gettext("Description"); ?></td> </tr> - <?php $i = 0; foreach ($a_vs as $vsent): ?> - <tr> - <td class="listlr"> - <?=$vsent['name'];?> - </td> - <td class="listr" align="center" > - <?=$vsent['ipaddr']." : ".$vsent['port'];?> - <br /> - </td> - <td class="listr" align="center" > - <table border="0" cellpadding="0" cellspacing="2" summary="servers"> - <?php - foreach ($a_pool as $vipent) { - if ($vipent['name'] == $vsent['poolname']) { - foreach ((array) $vipent['servers'] as $server) { - print "<tr><td> {$server} </td></tr>"; - } +<?php + $i = 0; + foreach ($a_vs as $vsent): +?> + <tr> + <td class="listlr"> + <?=$vsent['name'];?> + </td> + <td class="listr" align="center" > + <?=$vsent['ipaddr']." : ".$vsent['port'];?> + <br /> + </td> + <td class="listr" align="center" > + <table border="0" cellpadding="0" cellspacing="2" summary="servers"> +<?php + foreach ($a_pool as $vipent) { + if ($vipent['name'] == $vsent['poolname']) { + foreach ((array) $vipent['servers'] as $server) { + print "<tr><td> {$server} </td></tr>"; } } + } ?> - </table> - </td> - <?php - switch (trim($rdr_a[$vsent['name']]['status'])) { - case 'active': - $bgcolor = "#90EE90"; // lightgreen - $rdr_a[$vsent['name']]['status'] = "Active"; - break; - case 'down': - $bgcolor = "#F08080"; // lightcoral - $rdr_a[$vsent['name']]['status'] = "Down"; - break; - default: - $bgcolor = "#D3D3D3"; // lightgray - $rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?'; - } - ?> - <td class="listr nowrap"> - <table border="0" cellpadding="3" cellspacing="2" summary="status"> - <tr><td bgcolor="<?=$bgcolor?>"><?=$rdr_a[$vsent['name']]['status']?> </td></tr> - </table> - <?php - if (!empty($rdr_a[$vsent['name']]['total'])) - echo "Total Sessions: {$rdr_a[$vsent['name']]['total']}\n"; - if (!empty($rdr_a[$vsent['name']]['last'])) - echo "<br />Last: {$rdr_a[$vsent['name']]['last']}\n"; - if (!empty($rdr_a[$vsent['name']]['average'])) - echo "<br />Average: {$rdr_a[$vsent['name']]['average']}\n"; - ?> - </td> - <td class="listbg" > + </table> + </td> +<?php + switch (trim($rdr_a[$vsent['name']]['status'])) { + case 'active': + $bgcolor = "#90EE90"; // lightgreen + $rdr_a[$vsent['name']]['status'] = "Active"; + break; + case 'down': + $bgcolor = "#F08080"; // lightcoral + $rdr_a[$vsent['name']]['status'] = "Down"; + break; + default: + $bgcolor = "#D3D3D3"; // lightgray + $rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?'; + } +?> + <td class="listr nowrap"> + <table border="0" cellpadding="3" cellspacing="2" summary="status"> + <tr> + <td bgcolor="<?=$bgcolor?>"><?=$rdr_a[$vsent['name']]['status']?> </td> + </tr> + </table> +<?php + if (!empty($rdr_a[$vsent['name']]['total'])) { + echo "Total Sessions: {$rdr_a[$vsent['name']]['total']}\n"; + } + if (!empty($rdr_a[$vsent['name']]['last'])) { + echo "<br />Last: {$rdr_a[$vsent['name']]['last']}\n"; + } + if (!empty($rdr_a[$vsent['name']]['average'])) { + echo "<br />Average: {$rdr_a[$vsent['name']]['average']}\n"; + } +?> + </td> + <td class="listbg" > <?=$vsent['descr'];?> - </td> - </tr> - <?php $i++; endforeach; ?> - </table> - </div> -</td></tr> + </td> + </tr> +<?php + $i++; + endforeach; +?> + </table> + </div> + </td> + </tr> </table> <?php include("fend.inc"); ?> diff --git a/usr/local/www/status_ntpd.php b/usr/local/www/status_ntpd.php index a5a68ad..44c9733 100644 --- a/usr/local/www/status_ntpd.php +++ b/usr/local/www/status_ntpd.php @@ -44,11 +44,12 @@ require_once("guiconfig.inc"); -if(!isset($config['ntpd']['noquery'])) { - if (isset($config['system']['ipv6allow'])) +if (!isset($config['ntpd']['noquery'])) { + 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); @@ -116,7 +117,7 @@ if(!isset($config['ntpd']['noquery'])) { $gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1); $gps_lon = $gps_lon_deg + $gps_lon_min; $gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1); - }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); @@ -130,7 +131,7 @@ if(!isset($config['ntpd']['noquery'])) { $gps_alt = $gps_vars[9]; $gps_alt_unit = $gps_vars[10]; $gps_sat = $gps_vars[7]; - }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); @@ -150,9 +151,9 @@ if(!isset($config['ntpd']['noquery'])) { 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]; @@ -168,108 +169,151 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="status ntpd"> -<tr><td><div id="mainarea"> - <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="heading"> - <tr><td class="listtopic">Network Time Protocol Status</td></tr> - </table> - <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> - <thead> - <tr> - <th class="listhdrr"><?=gettext("Status"); ?></th> - <th class="listhdrr"><?=gettext("Server"); ?></th> - <th class="listhdrr"><?=gettext("Ref ID"); ?></th> - <th class="listhdrr"><?=gettext("Stratum"); ?></th> - <th class="listhdrr"><?=gettext("Type"); ?></th> - <th class="listhdrr"><?=gettext("When"); ?></th> - <th class="listhdrr"><?=gettext("Poll"); ?></th> - <th class="listhdrr"><?=gettext("Reach"); ?></th> - <th class="listhdrr"><?=gettext("Delay"); ?></th> - <th class="listhdrr"><?=gettext("Offset"); ?></th> - <th class="listhdr"><?=gettext("Jitter"); ?></th> - </tr> - </thead> - <tbody> - <?php if (isset($config['ntpd']['noquery'])): ?> - <tr><td class="listlr" colspan="11" align="center"> - Statistics unavailable because ntpq and ntpdc queries are disabled in the <a href="services_ntpd.php">NTP service settings</a>. - </td></tr> - <?php elseif (count($ntpq_servers) == 0): ?> - <tr><td class="listlr" colspan="11" align="center"> - No peers found, <a href="status_services.php">is the ntp service running?</a>. - </td></tr> - <?php else: ?> - <?php $i = 0; foreach ($ntpq_servers as $server): ?> - <tr> - <td class="listlr nowrap"> - <?=$server['status'];?> - </td> - <td class="listr"> - <?=$server['server'];?> - </td> - <td class="listr"> - <?=$server['refid'];?> - </td> - <td class="listr"> - <?=$server['stratum'];?> - </td> - <td class="listr"> - <?=$server['type'];?> - </td> - <td class="listr"> - <?=$server['when'];?> - </td> - <td class="listr"> - <?=$server['poll'];?> - </td> - <td class="listr"> - <?=$server['reach'];?> - </td> - <td class="listr"> - <?=$server['delay'];?> - </td> - <td class="listr"> - <?=$server['offset'];?> - </td> - <td class="listr"> - <?=$server['jitter'];?> - </td> - </tr> -<?php $i++; endforeach; endif; ?> - </tbody> - </table> -<?php if (($gps_ok) && ($gps_lat) && ($gps_lon)): ?> - <?php $gps_goo_lnk = 2; ?> - <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="gps status"> - <thead> <tr> - <th class="listhdrr"><?=gettext("Clock Latitude"); ?></th> - <th class="listhdrr"><?=gettext("Clock Longitude"); ?></th> - <?php if (isset($gps_alt)) { echo '<th class="listhdrr">' . gettext("Clock Altitude") . '</th>'; $gps_goo_lnk++;}?> - <?php if (isset($gps_sat) || isset($gps_satview)) { echo '<th class="listhdrr">' . gettext("Satellites") . '</th>'; $gps_goo_lnk++;}?> - </tr> - </thead> - <tbody> - <tr> - <td class="listlr" align="center"><?php echo sprintf("%.5f", $gps_lat); ?> (<?php echo sprintf("%d", $gps_lat_deg); ?>° <?php echo sprintf("%.5f", $gps_lat_min*60); ?><?php echo $gps_vars[4]; ?>)</td> - <td class="listlr" align="center"><?php echo sprintf("%.5f", $gps_lon); ?> (<?php echo sprintf("%d", $gps_lon_deg); ?>° <?php echo sprintf("%.5f", $gps_lon_min*60); ?><?php echo $gps_vars[6]; ?>)</td> - <?php if (isset($gps_alt)) { echo '<td class="listlr" align="center">' . $gps_alt . ' ' . $gps_alt_unit . '</td>';}?> - <?php - if (isset($gps_sat) || isset($gps_satview)) { - echo '<td class="listr" align="center">'; - 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;} - echo '</td>'; + <td> + <div id="mainarea"> + <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="heading"> + <tr> + <td class="listtopic">Network Time Protocol Status</td> + </tr> + </table> + <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="main area"> + <thead> + <tr> + <th class="listhdrr"><?=gettext("Status"); ?></th> + <th class="listhdrr"><?=gettext("Server"); ?></th> + <th class="listhdrr"><?=gettext("Ref ID"); ?></th> + <th class="listhdrr"><?=gettext("Stratum"); ?></th> + <th class="listhdrr"><?=gettext("Type"); ?></th> + <th class="listhdrr"><?=gettext("When"); ?></th> + <th class="listhdrr"><?=gettext("Poll"); ?></th> + <th class="listhdrr"><?=gettext("Reach"); ?></th> + <th class="listhdrr"><?=gettext("Delay"); ?></th> + <th class="listhdrr"><?=gettext("Offset"); ?></th> + <th class="listhdr"><?=gettext("Jitter"); ?></th> + </tr> + </thead> + <tbody> +<?php + if (isset($config['ntpd']['noquery'])): +?> + <tr> + <td class="listlr" colspan="11" align="center"> + Statistics unavailable because ntpq and ntpdc queries are disabled in the <a href="services_ntpd.php">NTP service settings</a>. + </td> + </tr> +<?php + elseif (count($ntpq_servers) == 0): +?> + <tr> + <td class="listlr" colspan="11" align="center"> + No peers found, <a href="status_services.php">is the ntp service running?</a>. + </td> + </tr> +<?php + else: + $i = 0; + foreach ($ntpq_servers as $server): +?> + <tr> + <td class="listlr nowrap"> + <?=$server['status'];?> + </td> + <td class="listr"> + <?=$server['server'];?> + </td> + <td class="listr"> + <?=$server['refid'];?> + </td> + <td class="listr"> + <?=$server['stratum'];?> + </td> + <td class="listr"> + <?=$server['type'];?> + </td> + <td class="listr"> + <?=$server['when'];?> + </td> + <td class="listr"> + <?=$server['poll'];?> + </td> + <td class="listr"> + <?=$server['reach'];?> + </td> + <td class="listr"> + <?=$server['delay'];?> + </td> + <td class="listr"> + <?=$server['offset'];?> + </td> + <td class="listr"> + <?=$server['jitter'];?> + </td> + </tr> +<?php + $i++; + endforeach; + endif; +?> + </tbody> + </table> +<?php + if (($gps_ok) && ($gps_lat) && ($gps_lon)): + $gps_goo_lnk = 2; +?> + <table class="tabcont sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="gps status"> + <thead> + <tr> + <th class="listhdrr"><?=gettext("Clock Latitude"); ?></th> + <th class="listhdrr"><?=gettext("Clock Longitude"); ?></th> +<?php + if (isset($gps_alt)) { + echo '<th class="listhdrr">' . gettext("Clock Altitude") . '</th>'; + $gps_goo_lnk++; + } + + if (isset($gps_sat) || isset($gps_satview)) { + echo '<th class="listhdrr">' . gettext("Satellites") . '</th>'; + $gps_goo_lnk++; + } +?> + </tr> + </thead> + <tbody> + <tr> + <td class="listlr" align="center"><?php echo sprintf("%.5f", $gps_lat); ?> (<?php echo sprintf("%d", $gps_lat_deg); ?>° <?php echo sprintf("%.5f", $gps_lat_min*60); ?><?php echo $gps_vars[4]; ?>)</td> + <td class="listlr" align="center"><?php echo sprintf("%.5f", $gps_lon); ?> (<?php echo sprintf("%d", $gps_lon_deg); ?>° <?php echo sprintf("%.5f", $gps_lon_min*60); ?><?php echo $gps_vars[6]; ?>)</td> +<?php + if (isset($gps_alt)) { + echo '<td class="listlr" align="center">' . $gps_alt . ' ' . $gps_alt_unit . '</td>'; + } + + if (isset($gps_sat) || isset($gps_satview)) { + echo '<td class="listr" align="center">'; + if (isset($gps_satview)) { + echo 'in view ' . intval($gps_satview); } - ?> - </tr> - <tr> - <td class="listlr" colspan="<?php echo $gps_goo_lnk; ?>" align="center"><a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>">Google Maps Link</a></td> - </tr> - </tbody> - </table> -<?php endif; ?> -</div></td></tr> + if (isset($gps_sat) && isset($gps_satview)) { + echo ', '; + } + if (isset($gps_sat)) { + echo 'in use ' . $gps_sat; + } + echo '</td>'; + } +?> + </tr> + <tr> + <td class="listlr" colspan="<?php echo $gps_goo_lnk; ?>" align="center"><a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>">Google Maps Link</a></td> + </tr> + </tbody> + </table> +<?php + endif; +?> + </div> + </td> + </tr> </table> <?php include("fend.inc"); ?> </body> diff --git a/usr/local/www/status_openvpn.php b/usr/local/www/status_openvpn.php index 492eded..0b0e92d 100644 --- a/usr/local/www/status_openvpn.php +++ b/usr/local/www/status_openvpn.php @@ -52,10 +52,10 @@ require_once("shortcuts.inc"); require_once("service-utils.inc"); /* Handle AJAX */ -if($_GET['action']) { - if($_GET['action'] == "kill") { - $port = $_GET['port']; - $remipp = $_GET['remipp']; +if ($_GET['action']) { + if ($_GET['action'] == "kill") { + $port = $_GET['port']; + $remipp = $_GET['remipp']; if (!empty($port) and !empty($remipp)) { $retval = kill_client($port, $remipp); echo htmlentities("|{$port}|{$remipp}|{$retval}|"); @@ -85,12 +85,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; } @@ -130,7 +132,7 @@ include("head.inc"); ?> function killComplete(req) { var values = req.responseText.split("|"); - if(values[3] != "0") { + if (values[3] != "0") { alert('<?=gettext("An error occurred.");?>' + ' (' + values[3] + ')'); return; } @@ -141,8 +143,10 @@ include("head.inc"); ?> } //]]> </script> -<?php $i = 0; ?> -<?php foreach ($servers as $server): ?> +<?php + $i = 0; + foreach ($servers as $server): +?> <table style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0" summary="status openvpn"> <tr> @@ -153,66 +157,70 @@ include("head.inc"); ?> <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" summary="connections"> - <tr> - <td class="listhdrr"><?=gettext("Common Name"); ?></td> - <td class="listhdrr"><?=gettext("Real Address"); ?></td> - <td class="listhdrr"><?=gettext("Virtual Address"); ?></td> - <td class="listhdrr"><?=gettext("Connected Since"); ?></td> - <td class="listhdrr"><?=gettext("Bytes Sent"); ?></td> - <td class="listhdrr"><?=gettext("Bytes Received"); ?></td> - </tr> - - <?php foreach ($server['conns'] as $conn): ?> - <tr id="<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>"> - <td class="listlr"> - <?=$conn['common_name'];?> - </td> - <td class="listr"> - <?=$conn['remote_host'];?> - </td> - <td class="listr"> - <?=$conn['virtual_addr'];?> - </td> - <td class="listr"> - <?=$conn['connect_time'];?> - </td> - <td class="listr"> - <?=format_bytes($conn['bytes_sent']);?> - </td> - <td class="listr"> - <?=format_bytes($conn['bytes_recv']);?> - </td> - <td class="list"> - <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;" - id="<?php echo "i:{$server['mgmt']}:{$conn['remote_host']}"; ?>" - title="<?php echo gettext("Kill client connection from") . " " . $conn['remote_host']; ?>" alt="delete" /> - </td> - </tr> - - <?php endforeach; ?> + <tr> + <td class="listhdrr"><?=gettext("Common Name"); ?></td> + <td class="listhdrr"><?=gettext("Real Address"); ?></td> + <td class="listhdrr"><?=gettext("Virtual Address"); ?></td> + <td class="listhdrr"><?=gettext("Connected Since"); ?></td> + <td class="listhdrr"><?=gettext("Bytes Sent"); ?></td> + <td class="listhdrr"><?=gettext("Bytes Received"); ?></td> + </tr> +<?php + foreach ($server['conns'] as $conn): +?> + <tr id="<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>"> + <td class="listlr"> + <?=$conn['common_name'];?> + </td> + <td class="listr"> + <?=$conn['remote_host'];?> + </td> + <td class="listr"> + <?=$conn['virtual_addr'];?> + </td> + <td class="listr"> + <?=$conn['connect_time'];?> + </td> + <td class="listr"> + <?=format_bytes($conn['bytes_sent']);?> + </td> + <td class="listr"> + <?=format_bytes($conn['bytes_recv']);?> + </td> + <td class="list"> + <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;" + id="<?php echo "i:{$server['mgmt']}:{$conn['remote_host']}"; ?>" + title="<?php echo gettext("Kill client connection from") . " " . $conn['remote_host']; ?>" alt="delete" /> + </td> + </tr> +<?php + endforeach; +?> <tfoot> - <tr> - <td colspan="2" class="list" height="12"> - <table> <tr> - <td><?php $ssvc = find_service_by_openvpn_vpnid($server['vpnid']); ?> - <?= get_service_status_icon($ssvc, true, true); ?> - <?= get_service_control_links($ssvc, true); ?></td> + <td colspan="2" class="list" height="12"> + <table> + <tr> + <td><?php $ssvc = find_service_by_openvpn_vpnid($server['vpnid']); ?> + <?= get_service_status_icon($ssvc, true, true); ?> + <?= get_service_control_links($ssvc, true); ?></td> + </tr> + </table> + </td> + <td colspan="4" class="list" height="12"> </td> </tr> - </table> - </td> - <td colspan="4" class="list" height="12"> </td> - </tr> </tfoot> - </table> + </table> </td> </tr> </table> -<?php if (is_array($server['routes']) && count($server['routes'])): ?> +<?php + if (is_array($server['routes']) && count($server['routes'])): +?> <div id="shroutebut-<?= $i ?>"> -<input type="button" onClick="show_routes('tabroute-<?= $i ?>','shroutebut-<?= $i ?>')" value="<?php echo gettext("Show Routing Table"); ?>" /> - <?= gettext("Display OpenVPN's internal routing table for this server.") ?> -<br /><br /> + <input type="button" onClick="show_routes('tabroute-<?= $i ?>','shroutebut-<?= $i ?>')" value="<?php echo gettext("Show Routing Table"); ?>" /> - <?= gettext("Display OpenVPN's internal routing table for this server.") ?> + <br /><br /> </div> <table style="display: none; padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0" id="tabroute-<?= $i ?>" summary="routing table"> <tr> @@ -223,46 +231,55 @@ include("head.inc"); ?> <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" summary="results"> - <tr> - <td class="listhdrr"><?=gettext("Common Name"); ?></td> - <td class="listhdrr"><?=gettext("Real Address"); ?></td> - <td class="listhdrr"><?=gettext("Target Network"); ?></td> - <td class="listhdrr"><?=gettext("Last Used"); ?></td> - </tr> - - <?php foreach ($server['routes'] as $conn): ?> - <tr id="<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>"> - <td class="listlr"> - <?=$conn['common_name'];?> - </td> - <td class="listr"> - <?=$conn['remote_host'];?> - </td> - <td class="listr"> - <?=$conn['virtual_addr'];?> - </td> - <td class="listr"> - <?=$conn['last_time'];?> - </td> - </tr> - - <?php endforeach; ?> + <tr> + <td class="listhdrr"><?=gettext("Common Name"); ?></td> + <td class="listhdrr"><?=gettext("Real Address"); ?></td> + <td class="listhdrr"><?=gettext("Target Network"); ?></td> + <td class="listhdrr"><?=gettext("Last Used"); ?></td> + </tr> + +<?php + foreach ($server['routes'] as $conn): +?> + <tr id="<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>"> + <td class="listlr"> + <?=$conn['common_name'];?> + </td> + <td class="listr"> + <?=$conn['remote_host'];?> + </td> + <td class="listr"> + <?=$conn['virtual_addr'];?> + </td> + <td class="listr"> + <?=$conn['last_time'];?> + </td> + </tr> +<?php + endforeach; +?> <tfoot> - <tr> - <td colspan="6" class="list" height="12"><?= gettext("An IP address followed by C indicates a host currently connected through the VPN.") ?></td> - </tr> + <tr> + <td colspan="6" class="list" height="12"><?= gettext("An IP address followed by C indicates a host currently connected through the VPN.") ?></td> + </tr> </tfoot> - </table> + </table> </td> </tr> </table> -<?php endif; ?> +<?php + endif; +?> <br /> -<?php $i++; ?> -<?php endforeach; ?> +<?php + $i++; + endforeach; +?> <br /> -<?php if (!empty($sk_servers)) { ?> +<?php + if (!empty($sk_servers)) { +?> <table style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0" summary="peer to peer stats"> <tr> <td colspan="6" class="listtopic"> @@ -272,60 +289,68 @@ include("head.inc"); ?> <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" summary="results"> - <tr> - <td class="listhdrr"><?=gettext("Name"); ?></td> - <td class="listhdrr"><?=gettext("Status"); ?></td> - <td class="listhdrr"><?=gettext("Connected Since"); ?></td> - <td class="listhdrr"><?=gettext("Virtual Addr"); ?></td> - <td class="listhdrr"><?=gettext("Remote Host"); ?></td> - <td class="listhdrr"><?=gettext("Bytes Sent"); ?></td> - <td class="listhdrr"><?=gettext("Bytes Rcvd"); ?></td> - <td class="listhdrr"><?=gettext("Service"); ?></td> - </tr> - -<?php foreach ($sk_servers as $sk_server): ?> - <tr id="<?php echo "r:{$sk_server['port']}:{$sk_server['vpnid']}"; ?>"> - <td class="listlr"> - <?=$sk_server['name'];?> - </td> - <td class="listr"> - <?=$sk_server['status'];?> - </td> - <td class="listr"> - <?=$sk_server['connect_time'];?> - </td> - <td class="listr"> - <?=$sk_server['virtual_addr'];?> - </td> - <td class="listr"> - <?=$sk_server['remote_host'];?> - </td> - <td class="listr"> - <?=format_bytes($sk_server['bytes_sent']);?> - </td> - <td class="listr"> - <?=format_bytes($sk_server['bytes_recv']);?> - </td> - <td class="listr"> - <table> <tr> - <td><?php $ssvc = find_service_by_openvpn_vpnid($sk_server['vpnid']); ?> - <?= get_service_status_icon($ssvc, false, true); ?> - <?= get_service_control_links($ssvc, true); ?></td> + <td class="listhdrr"><?=gettext("Name"); ?></td> + <td class="listhdrr"><?=gettext("Status"); ?></td> + <td class="listhdrr"><?=gettext("Connected Since"); ?></td> + <td class="listhdrr"><?=gettext("Virtual Addr"); ?></td> + <td class="listhdrr"><?=gettext("Remote Host"); ?></td> + <td class="listhdrr"><?=gettext("Bytes Sent"); ?></td> + <td class="listhdrr"><?=gettext("Bytes Rcvd"); ?></td> + <td class="listhdrr"><?=gettext("Service"); ?></td> + </tr> + +<?php + foreach ($sk_servers as $sk_server): +?> + <tr id="<?php echo "r:{$sk_server['port']}:{$sk_server['vpnid']}"; ?>"> + <td class="listlr"> + <?=$sk_server['name'];?> + </td> + <td class="listr"> + <?=$sk_server['status'];?> + </td> + <td class="listr"> + <?=$sk_server['connect_time'];?> + </td> + <td class="listr"> + <?=$sk_server['virtual_addr'];?> + </td> + <td class="listr"> + <?=$sk_server['remote_host'];?> + </td> + <td class="listr"> + <?=format_bytes($sk_server['bytes_sent']);?> + </td> + <td class="listr"> + <?=format_bytes($sk_server['bytes_recv']);?> + </td> + <td class="listr"> + <table> + <tr> + <td><?php $ssvc = find_service_by_openvpn_vpnid($sk_server['vpnid']); ?> + <?= get_service_status_icon($ssvc, false, true); ?> + <?= get_service_control_links($ssvc, true); ?> + </td> + </tr> + </table> + </td> </tr> - </table> - </td> - </tr> -<?php endforeach; ?> +<?php + endforeach; +?> </table> </td> </tr> </table> <?php -} ?> + } +?> <br /> -<?php if (!empty($clients)) { ?> +<?php + if (!empty($clients)) { +?> <table style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0" summary="client stats"> <tr> <td colspan="6" class="listtopic"> @@ -335,66 +360,72 @@ include("head.inc"); ?> <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" summary="results"> - <tr> - <td class="listhdrr"><?=gettext("Name"); ?></td> - <td class="listhdrr"><?=gettext("Status"); ?></td> - <td class="listhdrr"><?=gettext("Connected Since"); ?></td> - <td class="listhdrr"><?=gettext("Virtual Addr"); ?></td> - <td class="listhdrr"><?=gettext("Remote Host"); ?></td> - <td class="listhdrr"><?=gettext("Bytes Sent"); ?></td> - <td class="listhdrr"><?=gettext("Bytes Rcvd"); ?></td> - <td class="listhdrr"><?=gettext("Service"); ?></td> - </tr> - -<?php foreach ($clients as $client): ?> - <tr id="<?php echo "r:{$client['port']}:{$client['vpnid']}"; ?>"> - <td class="listlr"> - <?=$client['name'];?> - </td> - <td class="listr"> - <?=$client['status'];?> - </td> - <td class="listr"> - <?=$client['connect_time'];?> - </td> - <td class="listr"> - <?=$client['virtual_addr'];?> - </td> - <td class="listr"> - <?=$client['remote_host'];?> - </td> - <td class="listr"> - <?=format_bytes($client['bytes_sent']);?> - </td> - <td class="listr"> - <?=format_bytes($client['bytes_recv']);?> - </td> - <td class="listr" height="12"> - <table> <tr> - <td><?php $ssvc = find_service_by_openvpn_vpnid($client['vpnid']); ?> - <?= get_service_status_icon($ssvc, false, true); ?> - <?= get_service_control_links($ssvc, true); ?></td> + <td class="listhdrr"><?=gettext("Name"); ?></td> + <td class="listhdrr"><?=gettext("Status"); ?></td> + <td class="listhdrr"><?=gettext("Connected Since"); ?></td> + <td class="listhdrr"><?=gettext("Virtual Addr"); ?></td> + <td class="listhdrr"><?=gettext("Remote Host"); ?></td> + <td class="listhdrr"><?=gettext("Bytes Sent"); ?></td> + <td class="listhdrr"><?=gettext("Bytes Rcvd"); ?></td> + <td class="listhdrr"><?=gettext("Service"); ?></td> </tr> - </table> - </td> - </tr> -<?php endforeach; ?> + +<?php + foreach ($clients as $client): +?> + <tr id="<?php echo "r:{$client['port']}:{$client['vpnid']}"; ?>"> + <td class="listlr"> + <?=$client['name'];?> + </td> + <td class="listr"> + <?=$client['status'];?> + </td> + <td class="listr"> + <?=$client['connect_time'];?> + </td> + <td class="listr"> + <?=$client['virtual_addr'];?> + </td> + <td class="listr"> + <?=$client['remote_host'];?> + </td> + <td class="listr"> + <?=format_bytes($client['bytes_sent']);?> + </td> + <td class="listr"> + <?=format_bytes($client['bytes_recv']);?> + </td> + <td class="listr" height="12"> + <table> + <tr> + <td> + <?php $ssvc = find_service_by_openvpn_vpnid($client['vpnid']); ?> + <?= get_service_status_icon($ssvc, false, true); ?> + <?= get_service_control_links($ssvc, true); ?> + </td> + </tr> + </table> + </td> + </tr> +<?php + endforeach; +?> </table> </td> </tr> </table> -<?php -} +<?php + } -if ($DisplayNote) { - echo "<br /><b>" . gettext("NOTE") . ":</b> " . gettext("If you have custom options that override the management features of OpenVPN on a client or server, they will cause that OpenVPN instance to not work correctly with this status page."); -} + if ($DisplayNote) { + echo "<br /><b>" . gettext("NOTE") . ":</b> " . gettext("If you have custom options that override the management features of OpenVPN on a client or server, they will cause that OpenVPN instance to not work correctly with this status page."); + } -if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))) { - echo gettext("No OpenVPN instances defined"); -} + if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))) { + echo gettext("No OpenVPN instances defined"); + } ?> </form> diff --git a/usr/local/www/status_queues.php b/usr/local/www/status_queues.php index 6b4be32..1f5e45d 100644 --- a/usr/local/www/status_queues.php +++ b/usr/local/www/status_queues.php @@ -42,9 +42,9 @@ ##|*MATCH=status_queues.php* ##|-PRIV -header("Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" ); -header("Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" ); -header("Cache-Control: no-cache, no-store, must-revalidate" ); // HTTP/1.1 +header("Last-Modified: " . gmdate("D, j M Y H:i:s") . " GMT"); +header("Expires: " . gmdate("D, j M Y H:i:s", time()) . " GMT"); +header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0 require("guiconfig.inc"); @@ -64,48 +64,55 @@ if (!file_exists("{$g['varrun_path']}/qstats.pid") || !isvalidpid("{$g['varrun_p sleep(1); } $fd = @fsockopen("unix://{$g['varrun_path']}/qstats"); - if (!$fd) { - $error = "Something wrong happened during comunication with stat gathering"; +if (!$fd) { + $error = "Something wrong happened during communication with stat gathering"; } else { $stats = ""; - while(!feof($fd)) + while(!feof($fd)) { $stats .= fread($fd, 4096); + } fclose($fd); @file_put_contents("{$g['tmp_path']}/qstats", $stats); $altqstats = @parse_xml_config("{$g['tmp_path']}/qstats", array("altqstats")); - if ($altqstats == -1) + if ($altqstats == -1) { $error = "No queue statistics could be read."; + } } if ($_REQUEST['getactivity']) { $statistics = array(); $bigger_stat = 0; $stat_type = $_REQUEST['stats']; /* build the queue stats. */ - foreach($altqstats['queue'] as $q) { + foreach ($altqstats['queue'] as $q) { statsQueues($q); } /* calculate the bigger amount of packets or bandwidth being moved through all queues. */ if ($stat_type == "0") { - foreach($statistics as $q) { - if ($bigger_stat < $q->pps) + foreach ($statistics as $q) { + if ($bigger_stat < $q->pps) { $bigger_stat = $q->pps; + } } } else { - foreach($statistics as $q) { - if ($bigger_stat < $q->bandwidth) + foreach ($statistics as $q) { + if ($bigger_stat < $q->bandwidth) { $bigger_stat = $q->bandwidth; + } } } $finscript = ""; - foreach($statistics as $q) { - if ($stat_type == "0") + foreach ($statistics as $q) { + if ($stat_type == "0") { $packet_s = round(150 * (1 - $q->pps / $bigger_stat), 0); - else + } else { $packet_s = round(150 * (1 - $q->bandwidth / $bigger_stat), 0); - if ($packet_s < 0) {$packet_s = 0;} + } + if ($packet_s < 0) { + $packet_s = 0; + } $finscript .= "jQuery('#queue{$q->queuename}widthb').width('{$packet_s}');"; $finscript .= "jQuery('#queue{$q->queuename}widtha').width('" . (150 - $packet_s) . "');"; $finscript .= "jQuery('#queue{$q->queuename}pps').val('" . number_format($q->pps,1) . "');"; @@ -127,11 +134,12 @@ include("head.inc"); <body link="#0000CC" vlink="#0000CC" alink="#0000CC"> <?php include("fbegin.inc"); ?> <?php -if(!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < 1) { +if (!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < 1) { echo gettext("Traffic shaping is not configured."); include("fend.inc"); echo "</body></html>"; - exit;} + exit; +} ?> <?php if (!$error): ?> <form action="status_queues.php" method="post"> @@ -151,7 +159,7 @@ if(!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < function activitycallback(transport) { setTimeout('getqueueactivity()', 5100); } - jQuery(document).ready(function(){ + jQuery(document).ready(function() { setTimeout('getqueueactivity()', 150); }); //]]> @@ -177,9 +185,10 @@ if(!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < <td class="listhdr" width="1%"><?=gettext("Drops"); ?></td> <td class="listhdr" width="1%"><?=gettext("Length"); ?></td> </tr> - <?php +<?php $if_queue_list = get_configured_interface_list_by_realif(false, true); - processQueues($altqstats, 0, "")?> + processQueues($altqstats, 0, "") +?> <?php endif; ?> </table> <p> @@ -190,11 +199,12 @@ if(!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < <script type="text/javascript"> //<![CDATA[ function StatsShowHide(classname) { - var firstrow = jQuery("." + classname).first(); - if (firstrow.is(':visible')) { - jQuery("." + classname).hide();} - else { - jQuery("." + classname).show();} + var firstrow = jQuery("." + classname).first(); + if (firstrow.is(':visible')) { + jQuery("." + classname).hide(); + } else { + jQuery("." + classname).show(); + } } //]]> </script> @@ -203,11 +213,13 @@ if(!is_array($config['shaper']['queue']) || count($config['shaper']['queue']) < </body> </html> <?php -function processQueues($altqstats, $level, $parent_name){ +function processQueues($altqstats, $level, $parent_name) { global $g; global $if_queue_list; $gray_value = 190 + $level * 10; - if ($gray_value > 250) $gray_value = 255; + if ($gray_value > 250) { + $gray_value = 255; + } $row_background = str_repeat(dechex($gray_value), 3); $parent_name = $parent_name . " queuerow" . $altqstats['name'] . $altqstats['interface']; $prev_if = $altqstats['interface']; @@ -223,43 +235,45 @@ function processQueues($altqstats, $level, $parent_name){ echo "<tr><td colspan=\"8\" style=\"padding: 2px;\"><b>Interface ". htmlspecialchars(convert_real_interface_to_friendly_descr($q['interface'])) . "</b></td></tr>"; $prev_if = $q['interface']; } - ?> +?> <tr class="<?php echo $parent_name?>"> <td bgcolor="#<?php echo $row_background?>" style="padding-left: <?php echo $level * 20?>px;"> <font color="#000000"> <? - if (strstr($q['name'], "root_")) + if (strstr($q['name'], "root_")) { echo "<a href=\"firewall_shaper.php?interface={$if_name}&queue={$if_name}&action=show\">Root queue</a>"; - else + } else { echo "<a href=\"firewall_shaper.php?interface={$if_name}&queue={$q['name']}&action=show\">" . htmlspecialchars($q['name']) . "</a>"; + } ?> </font> </td> - <?php - $cpuUsage = 0; - echo "<td class=\"nowrap\" width=\"1%\" bgcolor=\"#{$row_background}\">"; - echo "<img src='./themes/".$g['theme']."/images/misc/bar_left.gif' height='10' width='4' border='0' align='middle' alt='' />"; - echo "<img src='./themes/".$g['theme']."/images/misc/bar_blue.gif' height='10' name='queue{$q['name']}{$q['interface']}widtha' id='queue{$q['name']}{$q['interface']}widtha' width='" . $cpuUsage . "' border='0' align='middle' alt='" . htmlspecialchars($q['name']) . "' />"; - echo "<img src='./themes/".$g['theme']."/images/misc/bar_gray.gif' height='10' name='queue{$q['name']}{$q['interface']}widthb' id='queue{$q['name']}{$q['interface']}widthb' width='" . (150 - $cpuUsage) . "' border='0' align='middle' alt='" . htmlspecialchars($q['name']) . "' />"; - echo "<img src='./themes/".$g['theme']."/images/misc/bar_right.gif' height='10' width='5' border='0' align='middle' alt='' /> "; - if (is_array($q['queue'])) { - echo "<a href=\"#\" onclick=\"StatsShowHide('queuerow{$q['name']}{$q['interface']}');return false\">+/-</a> "; - } - echo " </td>"; - echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}pps' id='queue{$q['name']}{$q['interface']}pps' value='(" . gettext("Loading") . ")' align='left' /></td>"; - echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:80px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}bps' id='queue{$q['name']}{$q['interface']}bps' value='' align='right' /></td>"; - echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}borrows' id='queue{$q['name']}{$q['interface']}borrows' value='' align='right' /></td>"; - echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}suspends' id='queue{$q['name']}{$q['interface']}suspends' value='' align='right' /></td>"; - echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}drops' id='queue{$q['name']}{$q['interface']}drops' value='' align='right' /></td>"; - echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}length' id='queue{$q['name']}{$q['interface']}length' value='' align='right' /></td>"; - ?> +<?php + $cpuUsage = 0; + echo "<td class=\"nowrap\" width=\"1%\" bgcolor=\"#{$row_background}\">"; + echo "<img src='./themes/".$g['theme']."/images/misc/bar_left.gif' height='10' width='4' border='0' align='middle' alt='' />"; + echo "<img src='./themes/".$g['theme']."/images/misc/bar_blue.gif' height='10' name='queue{$q['name']}{$q['interface']}widtha' id='queue{$q['name']}{$q['interface']}widtha' width='" . $cpuUsage . "' border='0' align='middle' alt='" . htmlspecialchars($q['name']) . "' />"; + echo "<img src='./themes/".$g['theme']."/images/misc/bar_gray.gif' height='10' name='queue{$q['name']}{$q['interface']}widthb' id='queue{$q['name']}{$q['interface']}widthb' width='" . (150 - $cpuUsage) . "' border='0' align='middle' alt='" . htmlspecialchars($q['name']) . "' />"; + echo "<img src='./themes/".$g['theme']."/images/misc/bar_right.gif' height='10' width='5' border='0' align='middle' alt='' /> "; + if (is_array($q['queue'])) { + echo "<a href=\"#\" onclick=\"StatsShowHide('queuerow{$q['name']}{$q['interface']}');return false\">+/-</a> "; + } + echo " </td>"; + echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}pps' id='queue{$q['name']}{$q['interface']}pps' value='(" . gettext("Loading") . ")' align='left' /></td>"; + echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:80px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}bps' id='queue{$q['name']}{$q['interface']}bps' value='' align='right' /></td>"; + echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}borrows' id='queue{$q['name']}{$q['interface']}borrows' value='' align='right' /></td>"; + echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}suspends' id='queue{$q['name']}{$q['interface']}suspends' value='' align='right' /></td>"; + echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}drops' id='queue{$q['name']}{$q['interface']}drops' value='' align='right' /></td>"; + echo "<td width=\"1%\" bgcolor=\"#{$row_background}\"><input style='border: 0px solid white; background-color:#{$row_background}; color:#000000;width:70px;text-align:right;' size='10' name='queue{$q['name']}{$q['interface']}length' id='queue{$q['name']}{$q['interface']}length' value='' align='right' /></td>"; +?> </tr> - <?php - if (is_array($q['queue'])) +<?php + if (is_array($q['queue'])) { processQueues($q, $level + 1, $parent_name); + } }; } -function statsQueues($xml){ +function statsQueues($xml) { global $statistics; $current = new QueueStats(); @@ -272,7 +286,7 @@ function statsQueues($xml){ $current->suspends = intval($xml['suspends']); $current->drops = intval($xml['droppedpkts']); if (is_array($xml['queue'])) { - foreach($xml['queue'] as $q) { + foreach ($xml['queue'] as $q) { $child = statsQueues($q); $current->pps += $child->pps; $current->bandwidth += $child->bandwidth; diff --git a/usr/local/www/status_services.php b/usr/local/www/status_services.php index d78f8bb..e4402da 100755 --- a/usr/local/www/status_services.php +++ b/usr/local/www/status_services.php @@ -26,7 +26,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* +/* pfSense_BUILDER_BINARIES: /usr/local/sbin/openvpn /usr/bin/killall /bin/ps pfSense_MODULE: services */ @@ -43,8 +43,9 @@ require_once("service-utils.inc"); require_once("shortcuts.inc"); $service_name = ''; -if (isset($_GET['service'])) +if (isset($_GET['service'])) { $service_name = htmlspecialchars($_GET['service']); +} if (!empty($service_name)) { switch ($_GET['mode']) { @@ -62,8 +63,9 @@ if (!empty($service_name)) { } /* batch mode, allow other scripts to call this script */ -if($_GET['batch']) +if ($_GET['batch']) { exit; +} $pgtitle = array(gettext("Status"),gettext("Services")); include("head.inc"); @@ -93,19 +95,22 @@ $services = get_services(); if (count($services) > 0) { uasort($services, "service_name_compare"); - foreach($services as $service) { - if (empty($service['name'])) + foreach ($services as $service) { + if (empty($service['name'])) { continue; - if (empty($service['description'])) + } + if (empty($service['description'])) { $service['description'] = get_pkg_descr($service['name']); + } echo "<tr><td class=\"listlr\" width=\"20%\">" . $service['name'] . "</td>\n"; echo "<td class=\"listr\" width=\"55%\">" . $service['description'] . "</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, true, true) . "</td>\n"; echo "<td valign=\"middle\" class=\"list nowrap\">" . get_service_control_links($service); $scut = get_shortcut_by_service_name($service['name']); @@ -121,7 +126,7 @@ if (count($services) > 0) { } ?> -</tbody> + </tbody> </table> </div> </form> diff --git a/usr/local/www/status_upnp.php b/usr/local/www/status_upnp.php index 0d74690..296e384 100644 --- a/usr/local/www/status_upnp.php +++ b/usr/local/www/status_upnp.php @@ -64,8 +64,8 @@ include("head.inc"); <?php include("fbegin.inc"); ?> <?php if ($savemsg) print_info_box($savemsg); ?> <?php -if(!$config['installedpackages'] || !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] || - !$config['installedpackages']['miniupnpd']['config'][0]['enable']) { +if (!$config['installedpackages'] || !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] || + !$config['installedpackages']['miniupnpd']['config'][0]['enable']) { echo gettext("UPnP is currently disabled."); include("fend.inc"); exit; @@ -73,23 +73,23 @@ if(!$config['installedpackages'] || !$config['installedpackages']['miniupnpd'][' ?> <div id="mainlevel"> <table width="100%" border="0" cellpadding="0" cellspacing="0"> - <tr> - <td class="tabcont" > - <form action="status_upnp.php" method="post"> - <input type="submit" name="clear" id="clear" value="<?=gettext("Clear");?>" /> <?=gettext("all currently connected sessions");?>. - </form> - </td> - </tr> - <tr> - <td class="tabcont" > - <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont"> - <tr> - <td width="10%" class="listhdrr"><?=gettext("Port");?></td> - <td width="10%" class="listhdrr"><?=gettext("Protocol");?></td> - <td width="20%" class="listhdrr"><?=gettext("Internal IP");?></td> - <td width="10%" class="listhdrr"><?=gettext("Int. Port");?></td> - <td width="50%" class="listhdr"><?=gettext("Description");?></td> - </tr> + <tr> + <td class="tabcont" > + <form action="status_upnp.php" method="post"> + <input type="submit" name="clear" id="clear" value="<?=gettext("Clear");?>" /> <?=gettext("all currently connected sessions");?>. + </form> + </td> + </tr> + <tr> + <td class="tabcont" > + <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont"> + <tr> + <td width="10%" class="listhdrr"><?=gettext("Port");?></td> + <td width="10%" class="listhdrr"><?=gettext("Protocol");?></td> + <td width="20%" class="listhdrr"><?=gettext("Internal IP");?></td> + <td width="10%" class="listhdrr"><?=gettext("Int. Port");?></td> + <td width="50%" class="listhdr"><?=gettext("Description");?></td> + </tr> <?php foreach ($rdr_entries as $rdr_entry) { if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches)) { @@ -99,30 +99,30 @@ if(!$config['installedpackages'] || !$config['installedpackages']['miniupnpd'][' $rdr_ip = $matches[5]; $rdr_iport = $matches[6]; ?> - <tr> - <td class="listlr"> - <?php print $rdr_port;?> - </td> - <td class="listr"> - <?php print $rdr_proto;?> - </td> - <td class="listr"> - <?php print $rdr_ip;?> - </td> - <td class="listr"> - <?php print $rdr_iport;?> - </td> - <td class="listr"> - <?php print $rdr_label;?> - </td> - </tr> + <tr> + <td class="listlr"> + <?php print $rdr_port;?> + </td> + <td class="listr"> + <?php print $rdr_proto;?> + </td> + <td class="listr"> + <?php print $rdr_ip;?> + </td> + <td class="listr"> + <?php print $rdr_iport;?> + </td> + <td class="listr"> + <?php print $rdr_label;?> + </td> + </tr> <?php } } ?> - </table> - </td> - </tr> + </table> + </td> + </tr> </table> </div> <?php include("fend.inc"); ?> diff --git a/usr/local/www/status_wireless.php b/usr/local/www/status_wireless.php index e2f16e7..c727cb4 100644 --- a/usr/local/www/status_wireless.php +++ b/usr/local/www/status_wireless.php @@ -44,15 +44,16 @@ $shortcut_section = "wireless"; include("head.inc"); $if = $_POST['if']; -if($_GET['if'] <> "") +if ($_GET['if'] <> "") { $if = $_GET['if']; +} $ciflist = get_configured_interface_with_descr(); -if(empty($if)) { +if (empty($if)) { /* Find the first interface that is wireless */ - foreach($ciflist as $interface => $ifdescr) { - if(is_interface_wireless(get_real_interface($interface))) { + foreach ($ciflist as $interface => $ifdescr) { + if (is_interface_wireless(get_real_interface($interface))) { $if = $interface; break; } @@ -68,51 +69,53 @@ include("fbegin.inc"); <?php if ($savemsg) print_info_box($savemsg); ?> <table width="100%" border="0" cellpadding="0" cellspacing="0"> -<tr><td> + <tr><td> <?php -$tab_array = array(); -foreach($ciflist as $interface => $ifdescr) { - if (is_interface_wireless(get_real_interface($interface))) { - $enabled = false; - if($if == $interface) - $enabled = true; - $tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}"); + $tab_array = array(); + foreach ($ciflist as $interface => $ifdescr) { + if (is_interface_wireless(get_real_interface($interface))) { + $enabled = false; + if ($if == $interface) { + $enabled = true; + } + $tab_array[] = array(gettext("Status") . " ({$ifdescr})", $enabled, "status_wireless.php?if={$interface}"); + } } -} -$rwlif = get_real_interface($if); -if($_POST['rescanwifi'] <> "") { - mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1"); - $savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results."); -} -if ($savemsg) print_info_box($savemsg); -display_top_tabs($tab_array); + $rwlif = get_real_interface($if); + if ($_POST['rescanwifi'] <> "") { + mwexec_bg("/sbin/ifconfig {$rwlif} scan 2>&1"); + $savemsg = gettext("Rescan has been initiated in the background. Refresh this page in 10 seconds to see the results."); + } + if ($savemsg) print_info_box($savemsg); + display_top_tabs($tab_array); ?> -</td></tr> -<tr><td> -<div id="mainarea" class="tabcont"> -<input type="hidden" name="if" id="if" value="<?php echo htmlspecialchars($if); ?>"> -<b><input type="submit" name="rescanwifi" id="rescanwifi" value="Rescan"></b><br /><br /> -<b><?php echo gettext("Nearby access points or ad-hoc peers"); ?></b> -<table class="tabcont sortable" colspan="3" cellpadding="3" width="100%"> - <thead> - <tr bgcolor='#990000'> - <td><b><font color='#ffffff'>SSID</font></b></td> - <td><b><font color='#ffffff'>BSSID</font></b></td> - <td><b><font color='#ffffff'>CHAN</font></b></td> - <td><b><font color='#ffffff'>RATE</font></b></td> - <td><b><font color='#ffffff'>RSSI</font></b></td> - <td><b><font color='#ffffff'>INT</font></b></td> - <td><b><font color='#ffffff'>CAPS</font></b></td> - </tr> - </thead> - <tbody> + </td></tr> + <tr> + <td> + <div id="mainarea" class="tabcont"> + <input type="hidden" name="if" id="if" value="<?php echo htmlspecialchars($if); ?>"> + <b><input type="submit" name="rescanwifi" id="rescanwifi" value="Rescan"></b><br /><br /> + <b><?php echo gettext("Nearby access points or ad-hoc peers"); ?></b> + <table class="tabcont sortable" colspan="3" cellpadding="3" width="100%"> + <thead> + <tr bgcolor='#990000'> + <td><b><font color='#ffffff'>SSID</font></b></td> + <td><b><font color='#ffffff'>BSSID</font></b></td> + <td><b><font color='#ffffff'>CHAN</font></b></td> + <td><b><font color='#ffffff'>RATE</font></b></td> + <td><b><font color='#ffffff'>RSSI</font></b></td> + <td><b><font color='#ffffff'>INT</font></b></td> + <td><b><font color='#ffffff'>CAPS</font></b></td> + </tr> + </thead> + <tbody> <?php exec("/sbin/ifconfig {$rwlif} list scan 2>&1", $states, $ret); /* Skip Header */ array_shift($states); $counter=0; - foreach($states as $state) { + foreach ($states as $state) { /* Split by Mac address for the SSID Field */ $split = preg_split("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state); preg_match("/([0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f]\:[0-9a-f][[0-9a-f])/i", $state, $bssid); @@ -137,25 +140,25 @@ display_top_tabs($tab_array); print "</tr>\n"; } ?> - </tbody> -</table> -<b><?php echo gettext("Associated or ad-hoc peers"); ?></b><br /> -<table class="tabcont sortable" colspan="3" cellpadding="3" width="100%"> - <thead> - <tr bgcolor='#990000'> - <td><b><font color='#ffffff'>ADDR</font></b></td> - <td><b><font color='#ffffff'>AID</font></b></td> - <td><b><font color='#ffffff'>CHAN</font></b></td> - <td><b><font color='#ffffff'>RATE</font></b></td> - <td><b><font color='#ffffff'>RSSI</font></b></td> - <td><b><font color='#ffffff'>IDLE</font></b></td> - <td><b><font color='#ffffff'>TXSEQ</font></b></td> - <td><b><font color='#ffffff'>RXSEQ</font></b></td> - <td><b><font color='#ffffff'>CAPS</font></b></td> - <td><b><font color='#ffffff'>ERP</font></b></td> - </tr> - </thead> - <tbody> + </tbody> + </table> + <b><?php echo gettext("Associated or ad-hoc peers"); ?></b><br /> + <table class="tabcont sortable" colspan="3" cellpadding="3" width="100%"> + <thead> + <tr bgcolor='#990000'> + <td><b><font color='#ffffff'>ADDR</font></b></td> + <td><b><font color='#ffffff'>AID</font></b></td> + <td><b><font color='#ffffff'>CHAN</font></b></td> + <td><b><font color='#ffffff'>RATE</font></b></td> + <td><b><font color='#ffffff'>RSSI</font></b></td> + <td><b><font color='#ffffff'>IDLE</font></b></td> + <td><b><font color='#ffffff'>TXSEQ</font></b></td> + <td><b><font color='#ffffff'>RXSEQ</font></b></td> + <td><b><font color='#ffffff'>CAPS</font></b></td> + <td><b><font color='#ffffff'>ERP</font></b></td> + </tr> + </thead> + <tbody> <?php $states = array(); @@ -163,7 +166,7 @@ display_top_tabs($tab_array); array_shift($states); $counter=0; - foreach($states as $state) { + foreach ($states as $state) { $split = preg_split("/[ ]+/i", $state); /* Split the rest by using spaces for this line using the 2nd part */ print "<tr>"; @@ -183,13 +186,14 @@ display_top_tabs($tab_array); /* XXX: what stats to we get for adhoc mode? */ ?> - </tbody> -</table> -</div><br /> - <b>Flags:</b> A = authorized, E = Extended Rate (802.11g), P = Power save mode<br /> - <b>Capabilities:</b> E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), - S = Short preamble, s = Short slot time -</td></tr> + </tbody> + </table> + </div> + <br /> + <b>Flags:</b> A = authorized, E = Extended Rate (802.11g), P = Power save mode<br /> + <b>Capabilities:</b> E = ESS (infrastructure mode), I = IBSS (ad-hoc mode), P = privacy (WEP/TKIP/AES), S = Short preamble, s = Short slot time + </td> + </tr> </table> <?php include("fend.inc"); ?> |