Commit 49e65b7a authored by Franco Fichtner's avatar Franco Fichtner

src: going down in style test drive

This applies most of PSR2 to the login page, dashboard and widgets.
We do this in order to find out whether the style apply is consistent
and free of errors.  Let's see, shall we?  :)
parent 9ebe2b77
...@@ -34,8 +34,8 @@ include_once("priv.inc"); ...@@ -34,8 +34,8 @@ include_once("priv.inc");
/* Authenticate user - exit if failed */ /* Authenticate user - exit if failed */
if (!session_auth()) { if (!session_auth()) {
display_login_form(); display_login_form();
exit; exit;
} }
/* /*
...@@ -49,25 +49,25 @@ $allowedpages = getAllowedPages($_SESSION['Username']); ...@@ -49,25 +49,25 @@ $allowedpages = getAllowedPages($_SESSION['Username']);
* redirect to first allowed page if requesting a wrong url * redirect to first allowed page if requesting a wrong url
*/ */
if (!isAllowedPage($_SERVER['REQUEST_URI'])) { if (!isAllowedPage($_SERVER['REQUEST_URI'])) {
if (count($allowedpages) > 0) { if (count($allowedpages) > 0) {
$page = str_replace('*', '', $allowedpages[0]); $page = str_replace('*', '', $allowedpages[0]);
$_SESSION['Post_Login'] = true; $_SESSION['Post_Login'] = true;
require_once("functions.inc"); require_once("functions.inc");
redirectHeader("/{$page}"); redirectHeader("/{$page}");
$username = empty($_SESSION["Username"]) ? "(system)" : $_SESSION['Username']; $username = empty($_SESSION["Username"]) ? "(system)" : $_SESSION['Username'];
if (!empty($_SERVER['REMOTE_ADDR'])) { if (!empty($_SERVER['REMOTE_ADDR'])) {
$username .= '@' . $_SERVER['REMOTE_ADDR']; $username .= '@' . $_SERVER['REMOTE_ADDR'];
} }
log_error("{$username} attempted to access {$_SERVER['REQUEST_URI']} but does not have access to that page. Redirecting to {$page}."); log_error("{$username} attempted to access {$_SERVER['REQUEST_URI']} but does not have access to that page. Redirecting to {$page}.");
exit; exit;
} else { } else {
display_error_form("201", gettext("No page assigned to this user! Click here to logout.")); display_error_form("201", gettext("No page assigned to this user! Click here to logout."));
exit; exit;
} }
} else { } else {
$_SESSION['Post_Login'] = true; $_SESSION['Post_Login'] = true;
} }
/* /*
...@@ -75,10 +75,10 @@ if (!isAllowedPage($_SERVER['REQUEST_URI'])) { ...@@ -75,10 +75,10 @@ if (!isAllowedPage($_SERVER['REQUEST_URI'])) {
* taking action in reponse to a POST request * taking action in reponse to a POST request
*/ */
if (!$_SESSION['Post_Login']) { if (!$_SESSION['Post_Login']) {
$_SESSION['Post_Login'] = true; $_SESSION['Post_Login'] = true;
require_once("functions.inc"); require_once("functions.inc");
redirectHeader($_SERVER['REQUEST_URI']); redirectHeader($_SERVER['REQUEST_URI']);
exit; exit;
} }
/* /*
...@@ -92,12 +92,12 @@ session_write_close(); ...@@ -92,12 +92,12 @@ session_write_close();
*/ */
function display_error_form($http_code, $desc) function display_error_form($http_code, $desc)
{ {
global $config, $g; global $config, $g;
$g['theme'] = get_current_theme(); $g['theme'] = get_current_theme();
if(isAjax()) { if (isAjax()) {
printf(gettext('Error: %1$s Description: %2$s'), $http_code, $desc); printf(gettext('Error: %1$s Description: %2$s'), $http_code, $desc);
return; return;
} }
?><!doctype html> ?><!doctype html>
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]--> <!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
...@@ -138,73 +138,76 @@ function display_error_form($http_code, $desc) ...@@ -138,73 +138,76 @@ function display_error_form($http_code, $desc)
function display_login_form() function display_login_form()
{ {
require_once("globals.inc"); require_once("globals.inc");
global $config, $g; global $config, $g;
$g['theme'] = get_current_theme(); $g['theme'] = get_current_theme();
unset($input_errors); unset($input_errors);
if(isAjax()) { if (isAjax()) {
if (isset($_POST['login'])) { if (isset($_POST['login'])) {
if($_SESSION['Logged_In'] <> "True") { if ($_SESSION['Logged_In'] <> "True") {
isset($_SESSION['Login_Error']) ? $login_error = $_SESSION['Login_Error'] : $login_error = gettext("unknown reason"); isset($_SESSION['Login_Error']) ? $login_error = $_SESSION['Login_Error'] : $login_error = gettext("unknown reason");
printf("showajaxmessage('" . gettext("Invalid login (%s).") . "')", $login_error); printf("showajaxmessage('" . gettext("Invalid login (%s).") . "')", $login_error);
} }
if (file_exists('/tmp/webconfigurator.lock')) { if (file_exists('/tmp/webconfigurator.lock')) {
// TODO: add the IP from the user who did lock the device // TODO: add the IP from the user who did lock the device
$whom = file_get_contents('/tmp/webconfigurator.lock'); $whom = file_get_contents('/tmp/webconfigurator.lock');
printf("showajaxmessage('" . gettext("This device is currently being maintained by: %s.") . "');", $whom); printf("showajaxmessage('" . gettext("This device is currently being maintained by: %s.") . "');", $whom);
} }
} }
exit; exit;
} }
/* Check against locally configured IP addresses, which will catch when someone /* Check against locally configured IP addresses, which will catch when someone
port forwards WebGUI access from WAN to an internal IP on the router. */ port forwards WebGUI access from WAN to an internal IP on the router. */
global $FilterIflist, $nifty_background; global $FilterIflist, $nifty_background;
$local_ip = false; $local_ip = false;
if(strstr($_SERVER['HTTP_HOST'], ":")) { if (strstr($_SERVER['HTTP_HOST'], ":")) {
$http_host_port = explode(":", $_SERVER['HTTP_HOST']); $http_host_port = explode(":", $_SERVER['HTTP_HOST']);
$http_host = $http_host_port[0]; $http_host = $http_host_port[0];
} else { } else {
$http_host = $_SERVER['HTTP_HOST']; $http_host = $_SERVER['HTTP_HOST'];
} }
if (empty($FilterIflist)) { if (empty($FilterIflist)) {
require_once('filter.inc'); require_once('filter.inc');
require_once('shaper.inc'); require_once('shaper.inc');
filter_generate_optcfg_array(); filter_generate_optcfg_array();
} }
foreach ($FilterIflist as $iflist) { foreach ($FilterIflist as $iflist) {
if($iflist['ip'] == $http_host) if ($iflist['ip'] == $http_host) {
$local_ip = true; $local_ip = true;
if($iflist['ipv6'] == $http_host) }
$local_ip = true; if ($iflist['ipv6'] == $http_host) {
} $local_ip = true;
unset($FilterIflist); }
}
if($config['virtualip']) { unset($FilterIflist);
if($config['virtualip']['vip']) {
foreach($config['virtualip']['vip'] as $vip) { if ($config['virtualip']) {
if($vip['subnet'] == $http_host) if ($config['virtualip']['vip']) {
$local_ip = true; foreach ($config['virtualip']['vip'] as $vip) {
} if ($vip['subnet'] == $http_host) {
} $local_ip = true;
} }
if (isset($config['openvpn']['openvpn-server'])) { }
foreach ($config['openvpn']['openvpn-server'] as $ovpns) { }
if (is_ipaddrv4($http_host) && !empty($ovpns['tunnel_network']) && ip_in_subnet($http_host, $ovpns['tunnel_network'])) { }
$local_ip = true; if (isset($config['openvpn']['openvpn-server'])) {
break; foreach ($config['openvpn']['openvpn-server'] as $ovpns) {
} if (is_ipaddrv4($http_host) && !empty($ovpns['tunnel_network']) && ip_in_subnet($http_host, $ovpns['tunnel_network'])) {
$local_ip = true;
if (is_ipaddrv6($http_host) && !empty($ovpns['tunnel_networkv6']) && ip_in_subnet($http_host, $ovpns['tunnel_networkv6'])) { break;
$local_ip = true; }
break;
} if (is_ipaddrv6($http_host) && !empty($ovpns['tunnel_networkv6']) && ip_in_subnet($http_host, $ovpns['tunnel_networkv6'])) {
} $local_ip = true;
} break;
setcookie("cookie_test", time() + 3600); }
$have_cookies = isset($_COOKIE["cookie_test"]); }
}
setcookie("cookie_test", time() + 3600);
$have_cookies = isset($_COOKIE["cookie_test"]);
?><!doctype html> ?><!doctype html>
<!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]--> <!--[if IE 8 ]><html lang="en" class="ie ie8 lte9 lte8 no-js"><![endif]-->
...@@ -233,12 +236,12 @@ function display_login_form() ...@@ -233,12 +236,12 @@ function display_login_form()
<div class="container"> <div class="container">
<?php <?php
if(is_ipaddr($http_host) && !$local_ip && !isset($config['system']['webgui']['nohttpreferercheck'])) { if (is_ipaddr($http_host) && !$local_ip && !isset($config['system']['webgui']['nohttpreferercheck'])) {
$nifty_background = "#999"; $nifty_background = "#999";
print_info_box(gettext("You are accessing this router by an IP address not configured locally, which may be forwarded by NAT or other means. <br /><br />If you did not setup this forwarding, you may be the target of a man-in-the-middle attack.")); print_info_box(gettext("You are accessing this router by an IP address not configured locally, which may be forwarded by NAT or other means. <br /><br />If you did not setup this forwarding, you may be the target of a man-in-the-middle attack."));
} }
$loginautocomplete = isset($config['system']['webgui']['loginautocomplete']) ? '' : 'autocomplete="off"'; $loginautocomplete = isset($config['system']['webgui']['loginautocomplete']) ? '' : 'autocomplete="off"';
?> ?>
<main class="login-modal-container"> <main class="login-modal-container">
...@@ -249,9 +252,11 @@ function display_login_form() ...@@ -249,9 +252,11 @@ function display_login_form()
</header> </header>
<div class="login-modal-content"> <div class="login-modal-content">
<?php if (isset($_SESSION['Login_Error'])) { ?> <?php if (isset($_SESSION['Login_Error'])) {
?>
<div id="inputerrors" class="text-danger"><?=$_SESSION['Login_Error'];?></div><br /> <div id="inputerrors" class="text-danger"><?=$_SESSION['Login_Error'];?></div><br />
<?php unset($_SESSION['Login_Error']); } // endif ?> <?php unset($_SESSION['Login_Error']);
} // endif ?>
<form class="clearfix" id="iform" name="iform" method="post" <?= $loginautocomplete ?> action="<?=$_SERVER['REQUEST_URI'];?>"> <form class="clearfix" id="iform" name="iform" method="post" <?= $loginautocomplete ?> action="<?=$_SERVER['REQUEST_URI'];?>">
...@@ -271,12 +276,14 @@ function display_login_form() ...@@ -271,12 +276,14 @@ function display_login_form()
</form> </form>
<?php if (!$have_cookies && isset($_POST['login'])): ?> <?php if (!$have_cookies && isset($_POST['login'])) :
?>
<br /><br /> <br /><br />
<span class="text-danger"> <span class="text-danger">
<?= gettext("Your browser must support cookies to login."); ?> <?= gettext("Your browser must support cookies to login."); ?>
</span> </span>
<?php endif; ?> <?php
endif; ?>
</div> </div>
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
*/ */
// Turn on buffering to speed up rendering // Turn on buffering to speed up rendering
ini_set('output_buffering','true'); ini_set('output_buffering', 'true');
// Start buffering with a cache size of 100000 // Start buffering with a cache size of 100000
ob_start(null, "1000"); ob_start(null, "1000");
...@@ -40,14 +40,14 @@ require_once('functions.inc'); ...@@ -40,14 +40,14 @@ require_once('functions.inc');
require_once('guiconfig.inc'); require_once('guiconfig.inc');
require_once('notices.inc'); require_once('notices.inc');
if(isset($_REQUEST['closenotice'])){ if (isset($_REQUEST['closenotice'])) {
close_notice($_REQUEST['closenotice']); close_notice($_REQUEST['closenotice']);
echo get_menu_messages(); echo get_menu_messages();
exit; exit;
} }
if ($_REQUEST['act'] == 'alias_info_popup' && !preg_match("/\D/",$_REQUEST['aliasid'])){ if ($_REQUEST['act'] == 'alias_info_popup' && !preg_match("/\D/", $_REQUEST['aliasid'])) {
alias_info_popup($_REQUEST['aliasid']); alias_info_popup($_REQUEST['aliasid']);
exit; exit;
} }
##build list of widgets ##build list of widgets
...@@ -59,14 +59,16 @@ $widgetfiles = array(); ...@@ -59,14 +59,16 @@ $widgetfiles = array();
$widgetlist = array(); $widgetlist = array();
while (false !== ($filename = readdir($dirhandle))) { while (false !== ($filename = readdir($dirhandle))) {
$periodpos = strpos($filename, "."); $periodpos = strpos($filename, ".");
/* Ignore files not ending in .php */ /* Ignore files not ending in .php */
if (substr($filename, -4, 4) != ".php") if (substr($filename, -4, 4) != ".php") {
continue; continue;
$widgetname = substr($filename, 0, $periodpos); }
$widgetnames[] = $widgetname; $widgetname = substr($filename, 0, $periodpos);
if ($widgetname != "system_information") $widgetnames[] = $widgetname;
$widgetfiles[] = $filename; if ($widgetname != "system_information") {
$widgetfiles[] = $filename;
}
} }
##sort widgets alphabetically ##sort widgets alphabetically
...@@ -77,23 +79,21 @@ array_unshift($widgetfiles, "system_information.widget.php"); ...@@ -77,23 +79,21 @@ array_unshift($widgetfiles, "system_information.widget.php");
##if no config entry found, initialize config entry ##if no config entry found, initialize config entry
if (!is_array($config['widgets'])) { if (!is_array($config['widgets'])) {
$config['widgets'] = array(); $config['widgets'] = array();
} }
if ($_POST && $_POST['sequence']) { if ($_POST && $_POST['sequence']) {
$config['widgets']['sequence'] = $_POST['sequence'];
foreach ($widgetnames as $widget) {
if ($_POST[$widget . '-config']) {
$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
}
}
$config['widgets']['sequence'] = $_POST['sequence']; write_config(gettext("Widget configuration has been changed."));
header("Location: index.php");
foreach ($widgetnames as $widget){ exit;
if ($_POST[$widget . '-config']){
$config['widgets'][$widget . '-config'] = $_POST[$widget . '-config'];
}
}
write_config(gettext("Widget configuration has been changed."));
header("Location: index.php");
exit;
} }
## Load Functions Files ## Load Functions Files
...@@ -102,72 +102,72 @@ require_once('includes/functions.inc.php'); ...@@ -102,72 +102,72 @@ require_once('includes/functions.inc.php');
## Check to see if we have a swap space, ## Check to see if we have a swap space,
## if true, display, if false, hide it ... ## if true, display, if false, hide it ...
if (file_exists('/usr/sbin/swapinfo')) { if (file_exists('/usr/sbin/swapinfo')) {
$swapinfo = `/usr/sbin/swapinfo`; $swapinfo = `/usr/sbin/swapinfo`;
if (stristr($swapinfo,'%')) { if (stristr($swapinfo, '%')) {
$showswap = true; $showswap = true;
} }
} }
## Find out whether there's hardware encryption or not ## Find out whether there's hardware encryption or not
unset($hwcrypto); unset($hwcrypto);
$fd = fopen('/var/log/dmesg.boot', 'r'); $fd = fopen('/var/log/dmesg.boot', 'r');
if ($fd) { if ($fd) {
while (!feof($fd)) { while (!feof($fd)) {
$dmesgl = fgets($fd); $dmesgl = fgets($fd);
if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches) if (preg_match("/^hifn.: (.*?),/", $dmesgl, $matches)
or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches) or preg_match("/.*(VIA Padlock)/", $dmesgl, $matches)
or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches) or preg_match("/^safe.: (\w.*)/", $dmesgl, $matches)
or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches) or preg_match("/^ubsec.: (.*?),/", $dmesgl, $matches)
or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches) or preg_match("/^padlock.: <(.*?)>,/", $dmesgl, $matches)
or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches) or preg_match("/^glxsb.: (.*?),/", $dmesgl, $matches)
or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) { or preg_match("/^aesni.: (.*?),/", $dmesgl, $matches)) {
$hwcrypto = $matches[1]; $hwcrypto = $matches[1];
break; break;
} }
} }
fclose($fd); fclose($fd);
} }
##build widget saved list information ##build widget saved list information
if ($config['widgets'] && $config['widgets']['sequence'] != "") { if ($config['widgets'] && $config['widgets']['sequence'] != "") {
$pconfig['sequence'] = $config['widgets']['sequence']; $pconfig['sequence'] = $config['widgets']['sequence'];
$widgetlist = $pconfig['sequence']; $widgetlist = $pconfig['sequence'];
$colpos = array(); $colpos = array();
$savedwidgetfiles = array(); $savedwidgetfiles = array();
$widgetname = ""; $widgetname = "";
$widgetlist = explode(",",$widgetlist); $widgetlist = explode(",", $widgetlist);
##read the widget position and display information ##read the widget position and display information
foreach ($widgetlist as $widget){ foreach ($widgetlist as $widget) {
$dashpos = strpos($widget, "-"); $dashpos = strpos($widget, "-");
$widgetname = substr($widget, 0, $dashpos); $widgetname = substr($widget, 0, $dashpos);
$colposition = strpos($widget, ":"); $colposition = strpos($widget, ":");
$displayposition = strrpos($widget, ":"); $displayposition = strrpos($widget, ":");
$colpos[] = substr($widget,$colposition+1, $displayposition - $colposition-1); $colpos[] = substr($widget, $colposition+1, $displayposition - $colposition-1);
$displayarray[] = substr($widget,$displayposition+1); $displayarray[] = substr($widget, $displayposition+1);
$savedwidgetfiles[] = $widgetname . ".widget.php"; $savedwidgetfiles[] = $widgetname . ".widget.php";
} }
##add widgets that may not be in the saved configuration, in case they are to be displayed later ##add widgets that may not be in the saved configuration, in case they are to be displayed later
foreach ($widgetfiles as $defaultwidgets){ foreach ($widgetfiles as $defaultwidgets) {
if (!in_array($defaultwidgets, $savedwidgetfiles)){ if (!in_array($defaultwidgets, $savedwidgetfiles)) {
$savedwidgetfiles[] = $defaultwidgets; $savedwidgetfiles[] = $defaultwidgets;
} }
} }
##find custom configurations of a particular widget and load its info to $pconfig ##find custom configurations of a particular widget and load its info to $pconfig
foreach ($widgetnames as $widget){ foreach ($widgetnames as $widget) {
if ($config['widgets'][$widget . '-config']){ if ($config['widgets'][$widget . '-config']) {
$pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config']; $pconfig[$widget . '-config'] = $config['widgets'][$widget . '-config'];
} }
} }
$widgetlist = $savedwidgetfiles; $widgetlist = $savedwidgetfiles;
} else{ } else {
// no saved widget sequence found, build default list. // no saved widget sequence found, build default list.
$widgetlist = $widgetfiles; $widgetlist = $widgetfiles;
} }
...@@ -178,12 +178,13 @@ $directory = "/usr/local/www/widgets/include/"; ...@@ -178,12 +178,13 @@ $directory = "/usr/local/www/widgets/include/";
$dirhandle = opendir($directory); $dirhandle = opendir($directory);
$filename = ""; $filename = "";
while (false !== ($filename = readdir($dirhandle))) { while (false !== ($filename = readdir($dirhandle))) {
$phpincludefiles[] = $filename; $phpincludefiles[] = $filename;
} }
foreach($phpincludefiles as $includename) { foreach ($phpincludefiles as $includename) {
if(!stristr($includename, ".inc")) if (!stristr($includename, ".inc")) {
continue; continue;
include($directory . $includename); }
include($directory . $includename);
} }
##begin AJAX ##begin AJAX
...@@ -374,9 +375,10 @@ echo $jscriptstr; ...@@ -374,9 +375,10 @@ echo $jscriptstr;
?> ?>
<?php <?php
## If it is the first time webConfigurator has been ## If it is the first time webConfigurator has been
## accessed since initial install show this stuff. ## accessed since initial install show this stuff.
if (isset($config['trigger_initial_wizard'])) : ?> if (isset($config['trigger_initial_wizard'])) :
?>
<header class="page-content-head"> <header class="page-content-head">
<div class="container-fluid"> <div class="container-fluid">
<h1><?=gettext("Starting initial configuration"); ?>!</h1> <h1><?=gettext("Starting initial configuration"); ?>!</h1>
...@@ -390,16 +392,16 @@ echo $jscriptstr; ...@@ -390,16 +392,16 @@ echo $jscriptstr;
<div class="content-box" style="padding: 20px;"> <div class="content-box" style="padding: 20px;">
<div class="table-responsive"> <div class="table-responsive">
<?php <?php
echo "<img src=\"/themes/{$g['theme']}/assets/images/default-logo.png\" border=\"0\" alt=\"logo\" /><p>\n"; echo "<img src=\"/themes/{$g['theme']}/assets/images/default-logo.png\" border=\"0\" alt=\"logo\" /><p>\n";
?> ?>
<br /> <br />
<div class="content-box-main"> <div class="content-box-main">
<?php <?php
echo sprintf(gettext("Welcome to %s!\n"),$g['product_name']) . "<p>"; echo sprintf(gettext("Welcome to %s!\n"), $g['product_name']) . "<p>";
echo gettext("One moment while we start the initial setup wizard.") . "<p>\n"; echo gettext("One moment while we start the initial setup wizard.") . "<p>\n";
echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n"; echo gettext("Embedded platform users: Please be patient, the wizard takes a little longer to run than the normal GUI.") . "<p>\n";
echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."),$g['product_name']) . "\n"; echo sprintf(gettext("To bypass the wizard, click on the %s logo on the initial page."), $g['product_name']) . "\n";
?> ?>
</div> </div>
<div> <div>
</div> </div>
...@@ -409,7 +411,8 @@ echo $jscriptstr; ...@@ -409,7 +411,8 @@ echo $jscriptstr;
</section> </section>
<meta http-equiv="refresh" content="3;url=wizard.php?xml=setup_wizard.xml"> <meta http-equiv="refresh" content="3;url=wizard.php?xml=setup_wizard.xml">
<?php exit; ?> <?php exit; ?>
<?php endif; ?> <?php
endif; ?>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
...@@ -417,168 +420,177 @@ echo $jscriptstr; ...@@ -417,168 +420,177 @@ echo $jscriptstr;
<div class="row"> <div class="row">
<?php <?php
$crash_report = get_crash_report(); $crash_report = get_crash_report();
if ($crash_report != '') { if ($crash_report != '') {
print_info_box($crash_report); print_info_box($crash_report);
} }
$totalwidgets = count($widgetfiles); $totalwidgets = count($widgetfiles);
$halftotal = $totalwidgets / 2 - 2; $halftotal = $totalwidgets / 2 - 2;
$widgetcounter = 0; $widgetcounter = 0;
$directory = "/usr/local/www/widgets/widgets/"; $directory = "/usr/local/www/widgets/widgets/";
$printed = false; $printed = false;
$firstprint = false; $firstprint = false;
foreach($widgetlist as $widget) { foreach ($widgetlist as $widget) {
if (!stristr($widget, "widget.php")) {
if(!stristr($widget, "widget.php")) continue;
continue; }
$periodpos = strpos($widget, "."); $periodpos = strpos($widget, ".");
$widgetname = substr($widget, 0, $periodpos); $widgetname = substr($widget, 0, $periodpos);
if ($widgetname != ""){ if ($widgetname != "") {
$nicename = $widgetname; $nicename = $widgetname;
$nicename = str_replace("_", " ", $nicename); $nicename = str_replace("_", " ", $nicename);
//make the title look nice //make the title look nice
$nicename = ucwords($nicename); $nicename = ucwords($nicename);
} }
if ($config['widgets'] && $pconfig['sequence'] != ""){ if ($config['widgets'] && $pconfig['sequence'] != "") {
switch($displayarray[$widgetcounter]){ switch($displayarray[$widgetcounter]){
case "show": case "show":
$divdisplay = "block"; $divdisplay = "block";
$display = "block"; $display = "block";
$inputdisplay = "show"; $inputdisplay = "show";
$showWidget = "none"; $showWidget = "none";
$mindiv = "inline"; $mindiv = "inline";
break; break;
case "hide": case "hide":
$divdisplay = "block"; $divdisplay = "block";
$display = "none"; $display = "none";
$inputdisplay = "hide"; $inputdisplay = "hide";
$showWidget = "inline"; $showWidget = "inline";
$mindiv = "none"; $mindiv = "none";
break; break;
case "close": case "close":
$divdisplay = "none"; $divdisplay = "none";
$display = "block"; $display = "block";
$inputdisplay = "close"; $inputdisplay = "close";
$showWidget = "none"; $showWidget = "none";
$mindiv = "inline"; $mindiv = "inline";
break; break;
default: default:
$divdisplay = "none"; $divdisplay = "none";
$display = "block"; $display = "block";
$inputdisplay = "none"; $inputdisplay = "none";
$showWidget = "none"; $showWidget = "none";
$mindiv = "inline"; $mindiv = "inline";
break; break;
} }
} else { } else {
if ($firstprint == false){ if ($firstprint == false) {
$divdisplay = "block"; $divdisplay = "block";
$display = "block"; $display = "block";
$inputdisplay = "show"; $inputdisplay = "show";
$showWidget = "none"; $showWidget = "none";
$mindiv = "inline"; $mindiv = "inline";
$firstprint = true; $firstprint = true;
} else { } else {
switch ($widget) { switch ($widget) {
case "interfaces.widget.php": case "interfaces.widget.php":
case "traffic_graphs.widget.php": case "traffic_graphs.widget.php":
$divdisplay = "block"; $divdisplay = "block";
$display = "block"; $display = "block";
$inputdisplay = "show"; $inputdisplay = "show";
$showWidget = "none"; $showWidget = "none";
$mindiv = "inline"; $mindiv = "inline";
break; break;
default: default:
$divdisplay = "none"; $divdisplay = "none";
$display = "block"; $display = "block";
$inputdisplay = "close"; $inputdisplay = "close";
$showWidget = "none"; $showWidget = "none";
$mindiv = "inline"; $mindiv = "inline";
break; break;
} }
} }
} }
?> ?>
<section class="col-xs-12 col-md-6 widgetdiv" id="<?php echo $widgetname;?>" style="display:<?php echo $divdisplay; ?>;"> <section class="col-xs-12 col-md-6 widgetdiv" id="<?php echo $widgetname;?>" style="display:<?php echo $divdisplay; ?>;">
<div class="content-box"> <div class="content-box">
<form action="<?=$_SERVER['REQUEST_URI'];?>" method="post" id="iform"> <form action="<?=$_SERVER['REQUEST_URI'];?>" method="post" id="iform">
<input type="hidden" value="" name="sequence" id="sequence" /> <input type="hidden" value="" name="sequence" id="sequence" />
<header class="content-box-head container-fluid"> <header class="content-box-head container-fluid">
<ul class="list-inline __nomb"> <ul class="list-inline __nomb">
<li><h3> <li><h3>
<?php <?php
$widgettitle = $widgetname . "_title"; $widgettitle = $widgetname . "_title";
$widgettitlelink = $widgetname . "_title_link"; $widgettitlelink = $widgetname . "_title_link";
if ($$widgettitle != "") if ($$widgettitle != "") {
{ //only show link if defined
//only show link if defined if ($$widgettitlelink != "") {
if ($$widgettitlelink != "") {?> ?>
<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer"> <u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
<?php } <?php
//echo widget title }
echo $$widgettitle; //echo widget title
if ($$widgettitlelink != "") { ?> echo $$widgettitle;
</span></u> if ($$widgettitlelink != "") {
<?php } ?>
} </span></u>
else{ <?php
if ($$widgettitlelink != "") {?> }
<u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer"> } else {
<?php } if ($$widgettitlelink != "") {
echo $nicename; ?>
if ($$widgettitlelink != "") { ?> <u><span onclick="location.href='/<?php echo $$widgettitlelink;?>'" style="cursor:pointer">
</span></u> <?php
<?php } }
} echo $nicename;
?> if ($$widgettitlelink != "") {
?>
</span></u>
<?php
}
}
?>
</h3></li> </h3></li>
<li class="pull-right"> <li class="pull-right">
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-default btn-xs" title="minimize" id="<?php echo $widgetname;?>-min" onclick='return minimizeWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $mindiv; ?>;"><span class="glyphicon glyphicon-minus"></span></button> <button type="button" class="btn btn-default btn-xs" title="minimize" id="<?php echo $widgetname;?>-min" onclick='return minimizeWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $mindiv; ?>;"><span class="glyphicon glyphicon-minus"></span></button>
<button type="button" class="btn btn-default btn-xs" title="maximize" id="<?php echo $widgetname;?>-max" onclick='return showWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $mindiv == 'none' ? 'inline' : 'none'; ?>;"><span class="glyphicon glyphicon-plus"></span></button> <button type="button" class="btn btn-default btn-xs" title="maximize" id="<?php echo $widgetname;?>-max" onclick='return showWidget("<?php echo $widgetname;?>",true)' style="display:<?php echo $mindiv == 'none' ? 'inline' : 'none'; ?>;"><span class="glyphicon glyphicon-plus"></span></button>
<button type="button" class="btn btn-default btn-xs" title="remove widget" onclick='return closeWidget("<?php echo $widgetname;?>",true)'><span class="glyphicon glyphicon-remove"></span></button> <button type="button" class="btn btn-default btn-xs" title="remove widget" onclick='return closeWidget("<?php echo $widgetname;?>",true)'><span class="glyphicon glyphicon-remove"></span></button>
<button type="button" class="btn btn-default btn-xs" id="<?php echo $widgetname;?>-configure" onclick='return configureWidget("<?php echo $widgetname;?>")' style="display:none; cursor:pointer" ><span class="glyphicon glyphicon-pencil"></span></button> <button type="button" class="btn btn-default btn-xs" id="<?php echo $widgetname;?>-configure" onclick='return configureWidget("<?php echo $widgetname;?>")' style="display:none; cursor:pointer" ><span class="glyphicon glyphicon-pencil"></span></button>
</div> </div>
</li> </li>
</ul> </ul>
</header> </header>
</form> </form>
<div class="content-box-main collapse in" id="<?php echo $widgetname;?>-container" style="display:<?=$mindiv;?>"> <div class="content-box-main collapse in" id="<?php echo $widgetname;
?>-container" style="display:<?=$mindiv;?>">
<input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-config" name="<?php echo $widgetname;?>-config" /> <input type="hidden" value="<?php echo $inputdisplay;?>" id="<?php echo $widgetname;?>-config" name="<?php echo $widgetname;?>-config" />
<?php if ($divdisplay != "block") { ?> <?php if ($divdisplay != "block") {
?>
<div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;" align="center"> <div id="<?php echo $widgetname;?>-loader" style="display:<?php echo $display; ?>;" align="center">
<br /> <br />
<span class="glyphicon glyphicon-refresh"></span> <?=gettext("Loading selected widget"); ?> <span class="glyphicon glyphicon-refresh"></span> <?=gettext("Loading selected widget"); ?>
<br /> <br />
</div> <?php $display = "none"; } ?> </div> <?php $display = "none";
} ?>
<?php <?php
if ($divdisplay == "block") if ($divdisplay == "block") {
{ include($directory . $widget);
include($directory . $widget); }
} ?>
?>
<?php $widgetcounter++; ?> <?php $widgetcounter++; ?>
</div> </div>
</div> </div>
</section> </section>
<? } //end foreach ?> <?php
} //end foreach ?>
</div> </div>
</div> </div>
...@@ -587,20 +599,21 @@ echo $jscriptstr; ...@@ -587,20 +599,21 @@ echo $jscriptstr;
<?php <?php
//build list of javascript include files //build list of javascript include files
$jsincludefiles = array(); $jsincludefiles = array();
$directory = "widgets/javascript/"; $directory = "widgets/javascript/";
$dirhandle = opendir($directory); $dirhandle = opendir($directory);
$filename = ""; $filename = "";
while (false !== ($filename = readdir($dirhandle))) { while (false !== ($filename = readdir($dirhandle))) {
$jsincludefiles[] = $filename; $jsincludefiles[] = $filename;
} }
foreach($jsincludefiles as $jsincludename) { foreach ($jsincludefiles as $jsincludename) {
if(!preg_match('/\.js$/', $jsincludename)) if (!preg_match('/\.js$/', $jsincludename)) {
continue; continue;
echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n"; }
} echo "<script src='{$directory}{$jsincludename}' type='text/javascript'></script>\n";
}
?> ?>
<?php include("foot.inc"); ?> <?php include("foot.inc");
<?php <?php
$captive_portal_status_title = "Captive Portal Status"; $captive_portal_status_title = "Captive Portal Status";
$captive_portal_status_title_link = "status_captiveportal.php"; $captive_portal_status_title_link = "status_captiveportal.php";
?>
...@@ -3,5 +3,3 @@ ...@@ -3,5 +3,3 @@
//set variable for custom title //set variable for custom title
$carp_status_title = "Carp Status"; $carp_status_title = "Carp Status";
$carp_status_title_link = "carp_status.php"; $carp_status_title_link = "carp_status.php";
?>
...@@ -3,5 +3,3 @@ ...@@ -3,5 +3,3 @@
//set variable for custom title //set variable for custom title
$dyn_dns_status_title = "Dyn DNS Status"; $dyn_dns_status_title = "Dyn DNS Status";
$dyn_dns_status_title_link = "services_dyndns.php"; $dyn_dns_status_title_link = "services_dyndns.php";
?>
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
//set variable for custom title //set variable for custom title
$gateways_title = "Gateways"; $gateways_title = "Gateways";
$gateways_title_link = "status_gateways.php"; $gateways_title_link = "status_gateways.php";
?>
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
//set variable for custom title //set variable for custom title
$interface_statistics_title = "Interface Statistics"; $interface_statistics_title = "Interface Statistics";
$interface_statistics_title_link = "status_interfaces.php"; $interface_statistics_title_link = "status_interfaces.php";
?>
...@@ -2,5 +2,3 @@ ...@@ -2,5 +2,3 @@
//set variable for custom title //set variable for custom title
$interfaces_title = "Interfaces"; $interfaces_title = "Interfaces";
$interfaces_title_link = "status_interfaces.php"; $interfaces_title_link = "status_interfaces.php";
?>
<?php <?php
$ipsec_title = "IPsec"; $ipsec_title = "IPsec";
$ipsec_title_link = "diag_ipsec.php"; $ipsec_title_link = "diag_ipsec.php";
?>
<?php <?php
$load_balancer_status_title = "Load Balancer Status"; $load_balancer_status_title = "Load Balancer Status";
$load_balancer_status_title_link = "status_lb_pool.php"; $load_balancer_status_title_link = "status_lb_pool.php";
?>
...@@ -2,5 +2,3 @@ ...@@ -2,5 +2,3 @@
//set variable for custom title //set variable for custom title
$log_title = "Firewall Logs"; $log_title = "Firewall Logs";
$log_title_link = "diag_logs_filter.php"; $log_title_link = "diag_logs_filter.php";
?>
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
//set variable for custom title //set variable for custom title
$ntp_status_title = "NTP Status"; $ntp_status_title = "NTP Status";
$ntp_status_title_link = "status_ntpd.php"; $ntp_status_title_link = "status_ntpd.php";
?>
<?php <?php
$openvpn_title = "OpenVPN"; $openvpn_title = "OpenVPN";
$openvpn_title_link = "status_openvpn.php"; $openvpn_title_link = "status_openvpn.php";
?>
...@@ -3,5 +3,3 @@ ...@@ -3,5 +3,3 @@
//set variable for custom title //set variable for custom title
$services_status_title = "Services Status"; $services_status_title = "Services Status";
$services_status_title_link = "status_services.php"; $services_status_title_link = "status_services.php";
?>
...@@ -2,4 +2,3 @@ ...@@ -2,4 +2,3 @@
//set variable for custom title //set variable for custom title
$smart_status_title = "SMART Status"; $smart_status_title = "SMART Status";
$smart_status_title_link = "diag_smart.php"; $smart_status_title_link = "diag_smart.php";
?>
...@@ -17,11 +17,11 @@ $thermal_sensors_widget_title = "Thermal Sensors"; ...@@ -17,11 +17,11 @@ $thermal_sensors_widget_title = "Thermal Sensors";
//returns core temp data (from coretemp.ko or amdtemp.ko driver) as "|"-delimited string. //returns core temp data (from coretemp.ko or amdtemp.ko driver) as "|"-delimited string.
//NOTE: depends on proper cofing in System >> Advanced >> Miscellaneous tab >> Thermal Sensors section. //NOTE: depends on proper cofing in System >> Advanced >> Miscellaneous tab >> Thermal Sensors section.
function getThermalSensorsData() { function getThermalSensorsData()
{
$_gb = exec("/sbin/sysctl -a | grep temperature", $dfout); $_gb = exec("/sbin/sysctl -a | grep temperature", $dfout);
$thermalSensorsData = join("|", $dfout); $thermalSensorsData = join("|", $dfout);
return $thermalSensorsData; return $thermalSensorsData;
} }
?>
<?php <?php
$traffic_graphs_title = "Traffic Graphs"; $traffic_graphs_title = "Traffic Graphs";
$traffic_graphs_title_link = "status_graph.php"; $traffic_graphs_title_link = "status_graph.php";
?>
...@@ -3,5 +3,3 @@ ...@@ -3,5 +3,3 @@
//set variable for custom title //set variable for custom title
$wake_on_lan_title = "Wake On Lan"; $wake_on_lan_title = "Wake On Lan";
$wake_on_lan_title_link = "services_wol.php"; $wake_on_lan_title_link = "services_wol.php";
?>
...@@ -37,35 +37,41 @@ require_once("functions.inc"); ...@@ -37,35 +37,41 @@ require_once("functions.inc");
require_once("captiveportal.inc"); require_once("captiveportal.inc");
if (($_GET['act'] == "del") && (!empty($_GET['zone']))) { if (($_GET['act'] == "del") && (!empty($_GET['zone']))) {
$cpzone = $_GET['zone']; $cpzone = $_GET['zone'];
captiveportal_disconnect_client($_GET['id']); captiveportal_disconnect_client($_GET['id']);
} }
flush(); flush();
function clientcmp($a, $b) { function clientcmp($a, $b)
global $order; {
return strcmp($a[$order], $b[$order]); global $order;
return strcmp($a[$order], $b[$order]);
} }
if (!is_array($config['captiveportal'])) if (!is_array($config['captiveportal'])) {
$config['captiveportal'] = array(); $config['captiveportal'] = array();
}
$a_cp =& $config['captiveportal']; $a_cp =& $config['captiveportal'];
$cpdb_all = array(); $cpdb_all = array();
foreach ($a_cp as $cpzone => $cp) { foreach ($a_cp as $cpzone => $cp) {
$cpdb_handle = new OPNsense\CaptivePortal\DB($cpzone); $cpdb_handle = new OPNsense\CaptivePortal\DB($cpzone);
$order = ""; $order = "";
if ($_GET['order']) { if ($_GET['order']) {
if ($_GET['order'] == "ip") $order = "ip"; if ($_GET['order'] == "ip") {
else if ($_GET['order'] == "mac") $order = "mac"; $order = "ip";
else if ($_GET['order'] == "user") $order = "username"; } elseif ($_GET['order'] == "mac") {
$order = "mac";
} elseif ($_GET['order'] == "user") {
$order = "username";
} }
}
$cpdb = $cpdb_handle->listClients(array(),"and",array($order) ) ; $cpdb = $cpdb_handle->listClients(array(), "and", array($order)) ;
$cpdb_all[$cpzone] = $cpdb; $cpdb_all[$cpzone] = $cpdb;
} }
?> ?>
...@@ -73,25 +79,39 @@ foreach ($a_cp as $cpzone => $cp) { ...@@ -73,25 +79,39 @@ foreach ($a_cp as $cpzone => $cp) {
<tr> <tr>
<td class="listhdrr"><a href="?order=ip&amp;showact=<?=$_GET['showact'];?>"><b>IP address</b></a></td> <td class="listhdrr"><a href="?order=ip&amp;showact=<?=$_GET['showact'];?>"><b>IP address</b></a></td>
<td class="listhdrr"><a href="?order=mac&amp;showact=<?=$_GET['showact'];?>"><b>MAC address</b></a></td> <td class="listhdrr"><a href="?order=mac&amp;showact=<?=$_GET['showact'];?>"><b>MAC address</b></a></td>
<td class="listhdrr"><a href="?order=user&amp;showact=<?=$_GET['showact'];?>"><b><?=gettext("Username");?></b></a></td> <td class="listhdrr"><a href="?order=user&amp;showact=<?=$_GET['showact'];
<?php if ($_GET['showact']): ?> ?>"><b><?=gettext("Username");?></b></a></td>
<td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><b><?=gettext("Session start");?></b></a></td> <?php if ($_GET['showact']) :
<td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];?>"><b><?=gettext("Last activity");?></b></a></td> ?>
<?php endif; ?> <td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];
?>"><b><?=gettext("Session start");?></b></a></td>
<td class="listhdrr"><a href="?order=start&amp;showact=<?=$_GET['showact'];
?>"><b><?=gettext("Last activity");?></b></a></td>
<?php
endif; ?>
</tr> </tr>
<?php foreach ($cpdb_all as $cpzone=>$cpdb): ?> <?php foreach ($cpdb_all as $cpzone => $cpdb) :
<?php foreach ($cpdb as $cpent): ?> ?>
<?php foreach ($cpdb as $cpent) :
?>
<tr> <tr>
<td class="listlr"><?=$cpent->ip;?></td> <td class="listlr"><?=$cpent->ip;?></td>
<td class="listr"><?=$cpent->mac;?>&nbsp;</td> <td class="listr"><?=$cpent->mac;?>&nbsp;</td>
<td class="listr"><?=$cpent->username;?>&nbsp;</td> <td class="listr"><?=$cpent->username;?>&nbsp;</td>
<?php if ($_GET['showact']): ?> <?php if ($_GET['showact']) :
?>
<td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent->allow_time));?></td> <td class="listr"><?=htmlspecialchars(date("m/d/Y H:i:s", $cpent->allow_time));?></td>
<td class="listr">?</td> <td class="listr">?</td>
<?php endif; ?> <?php
endif; ?>
<td valign="middle" class="list nowrap"> <td valign="middle" class="list nowrap">
<a href="?order=<?=$_GET['order'];?>&amp;showact=<?=$_GET['showact'];?>&amp;act=del&amp;zone=<?=$cpzone;?>&amp;id=<?=$cpent->sessionid;?>" onclick="return confirm('Do you really want to disconnect this client?')"><span class="glyphicon glyphicon-remove"></span></a></td> <a href="?order=<?=$_GET['order'];
?>&amp;showact=<?=$_GET['showact'];
?>&amp;act=del&amp;zone=<?=$cpzone;
?>&amp;id=<?=$cpent->sessionid;?>" onclick="return confirm('Do you really want to disconnect this client?')"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr> </tr>
<?php endforeach; ?> <?php
<?php endforeach; ?> endforeach; ?>
<?php
endforeach; ?>
</table> </table>
...@@ -39,43 +39,49 @@ $carp_enabled = get_carp_status(); ...@@ -39,43 +39,49 @@ $carp_enabled = get_carp_status();
?> ?>
<table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="carp status"> <table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="carp status">
<?php <?php
if(is_array($config['virtualip']['vip'])) { if (is_array($config['virtualip']['vip'])) {
$carpint=0; $carpint=0;
foreach($config['virtualip']['vip'] as $carp) { foreach ($config['virtualip']['vip'] as $carp) {
if ($carp['mode'] != "carp") if ($carp['mode'] != "carp") {
continue; continue;
$ipaddress = $carp['subnet']; }
$password = $carp['password']; $ipaddress = $carp['subnet'];
$netmask = $carp['subnet_bits']; $password = $carp['password'];
$vhid = $carp['vhid']; $netmask = $carp['subnet_bits'];
$advskew = $carp['advskew']; $vhid = $carp['vhid'];
$status = get_carp_interface_status("{$carp['interface']}_vip{$vhid}"); $advskew = $carp['advskew'];
$status = get_carp_interface_status("{$carp['interface']}_vip{$vhid}");
?> ?>
<tr> <tr>
<td class="vncellt" width="35%"> <td class="vncellt" width="35%">
<span alt="cablenic" class="glyphicon glyphicon-transfer text-success"></span>&nbsp; <span alt="cablenic" class="glyphicon glyphicon-transfer text-success"></span>&nbsp;
<strong><a href="/system_hasync.php"> <strong><a href="/system_hasync.php">
<span><?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($carp['interface']) . "@{$vhid}");?></span></a></strong> <span><?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($carp['interface']) . "@{$vhid}");?></span></a></strong>
</td> </td>
<td width="65%" class="listr"> <td width="65%" class="listr">
<?php <?php
if($carp_enabled == false) { if ($carp_enabled == false) {
$status = "DISABLED"; $status = "DISABLED";
echo "<span class=\"glyphicon glyphicon-remove text-danger\" title=\"$status\" alt=\"$status\" ></span>"; echo "<span class=\"glyphicon glyphicon-remove text-danger\" title=\"$status\" alt=\"$status\" ></span>";
} else { } else {
if($status == "MASTER") { if ($status == "MASTER") {
echo "<span class=\"glyphicon glyphicon-play text-success\" title=\"$status\" alt=\"$status\" ></span>"; echo "<span class=\"glyphicon glyphicon-play text-success\" title=\"$status\" alt=\"$status\" ></span>";
} else if($status == "BACKUP") { } elseif ($status == "BACKUP") {
echo "<span class=\"glyphicon glyphicon-play text-muted\" title=\"$status\" alt=\"$status\" ></span>"; echo "<span class=\"glyphicon glyphicon-play text-muted\" title=\"$status\" alt=\"$status\" ></span>";
} else if($status == "INIT") { } elseif ($status == "INIT") {
echo "<span class=\"glyphicon glyphicon-info-sign\" title=\"$status\" alt=\"$status\" ></span>"; echo "<span class=\"glyphicon glyphicon-info-sign\" title=\"$status\" alt=\"$status\" ></span>";
} }
} }
if ($ipaddress){ ?> &nbsp; if ($ipaddress) {
<?=htmlspecialchars($status);?> &nbsp; ?> &nbsp;
<?=htmlspecialchars($ipaddress);}?> <?=htmlspecialchars($status);?> &nbsp;
</td></tr><?php } <?=htmlspecialchars($ipaddress);
} else { ?> }?>
</td></tr><?php
}
} else {
?>
<tr><td class="listr">No CARP Interfaces Defined. Click <a href="carp_status.php">here</a> to configure CARP.</td></tr> <tr><td class="listr">No CARP Interfaces Defined. Click <a href="carp_status.php">here</a> to configure CARP.</td></tr>
<?php } ?> <?php
} ?>
</table> </table>
...@@ -35,36 +35,39 @@ require_once("pfsense-utils.inc"); ...@@ -35,36 +35,39 @@ require_once("pfsense-utils.inc");
require_once("functions.inc"); require_once("functions.inc");
require_once("widgets/include/dyn_dns_status.inc"); require_once("widgets/include/dyn_dns_status.inc");
if (!is_array($config['dyndnses']['dyndns'])) if (!is_array($config['dyndnses']['dyndns'])) {
$config['dyndnses']['dyndns'] = array(); $config['dyndnses']['dyndns'] = array();
}
$a_dyndns = &$config['dyndnses']['dyndns']; $a_dyndns = &$config['dyndnses']['dyndns'];
if($_REQUEST['getdyndnsstatus']) { if ($_REQUEST['getdyndnsstatus']) {
$first_entry = true; $first_entry = true;
foreach ($a_dyndns as $dyndns) { foreach ($a_dyndns as $dyndns) {
if ($first_entry) if ($first_entry) {
$first_entry = false; $first_entry = false;
else } else {
// Put a vertical bar delimiter between the echoed HTML for each entry processed. // Put a vertical bar delimiter between the echoed HTML for each entry processed.
echo "|"; echo "|";
}
$filename = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache"; $filename = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
if (file_exists($filename)) { if (file_exists($filename)) {
$ipaddr = dyndnsCheckIP($dyndns['interface']); $ipaddr = dyndnsCheckIP($dyndns['interface']);
$cached_ip_s = split(":", file_get_contents($filename)); $cached_ip_s = split(":", file_get_contents($filename));
$cached_ip = $cached_ip_s[0]; $cached_ip = $cached_ip_s[0];
if ($ipaddr <> $cached_ip) if ($ipaddr <> $cached_ip) {
echo "<font color='red'>"; echo "<font color='red'>";
else } else {
echo "<font color='green'>"; echo "<font color='green'>";
echo htmlspecialchars($cached_ip); }
echo "</font>"; echo htmlspecialchars($cached_ip);
} else { echo "</font>";
echo "N/A " . date("H:i:s"); } else {
} echo "N/A " . date("H:i:s");
} }
exit; }
exit;
} }
?> ?>
...@@ -76,56 +79,62 @@ if($_REQUEST['getdyndnsstatus']) { ...@@ -76,56 +79,62 @@ if($_REQUEST['getdyndnsstatus']) {
<td width="20%" class="listhdrr"><b><?=gettext("Hostname");?></b></td> <td width="20%" class="listhdrr"><b><?=gettext("Hostname");?></b></td>
<td width="20%" class="listhdrr"><b><?=gettext("Cached IP");?></b></td> <td width="20%" class="listhdrr"><b><?=gettext("Cached IP");?></b></td>
</tr> </tr>
<?php $i = 0; foreach ($a_dyndns as $dyndns): ?> <?php $i = 0; foreach ($a_dyndns as $dyndns) :
?>
<tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'"> <tr ondblclick="document.location='services_dyndns_edit.php?id=<?=$i;?>'">
<td class="listlr"> <td class="listlr">
<?php $iflist = get_configured_interface_with_descr(); <?php $iflist = get_configured_interface_with_descr();
foreach ($iflist as $if => $ifdesc) { foreach ($iflist as $if => $ifdesc) {
if ($dyndns['interface'] == $if) { if ($dyndns['interface'] == $if) {
if (!isset($dyndns['enable'])) if (!isset($dyndns['enable'])) {
echo "<span class=\"gray\">{$ifdesc}</span>"; echo "<span class=\"gray\">{$ifdesc}</span>";
else } else {
echo "{$ifdesc}"; echo "{$ifdesc}";
break; }
} break;
} }
$groupslist = return_gateway_groups_array(); }
foreach ($groupslist as $if => $group) { $groupslist = return_gateway_groups_array();
if ($dyndns['interface'] == $if) { foreach ($groupslist as $if => $group) {
if (!isset($dyndns['enable'])) if ($dyndns['interface'] == $if) {
echo "<span class=\"gray\">{$if}</span>"; if (!isset($dyndns['enable'])) {
else echo "<span class=\"gray\">{$if}</span>";
echo "{$if}"; } else {
break; echo "{$if}";
} }
} break;
?> }
}
?>
</td> </td>
<td class="listr"> <td class="listr">
<?php <?php
$types = services_dyndns_list(); $types = services_dyndns_list();
if (isset($types[$dyndns['type']])) { if (isset($types[$dyndns['type']])) {
if (!isset($dyndns['enable'])) { if (!isset($dyndns['enable'])) {
echo '<span class="gray">' . htmlspecialchars($types[$dyndns['type']]) . '</span>'; echo '<span class="gray">' . htmlspecialchars($types[$dyndns['type']]) . '</span>';
} else { } else {
echo htmlspecialchars($types[$dyndns['type']]); echo htmlspecialchars($types[$dyndns['type']]);
} }
} }
?> ?>
</td> </td>
<td class="listr"> <td class="listr">
<?php <?php
if (!isset($dyndns['enable'])) if (!isset($dyndns['enable'])) {
echo "<span class=\"gray\">".htmlspecialchars($dyndns['host'])."</span>"; echo "<span class=\"gray\">".htmlspecialchars($dyndns['host'])."</span>";
else } else {
echo htmlspecialchars($dyndns['host']); echo htmlspecialchars($dyndns['host']);
?> }
?>
</td> </td>
<td class="listr"> <td class="listr">
<div id='dyndnsstatus<?php echo $i; ?>'><?php echo gettext("Checking ..."); ?></div> <div id='dyndnsstatus<?php echo $i; ?>'><?php echo gettext("Checking ..."); ?></div>
</td> </td>
</tr> </tr>
<?php $i++; endforeach; ?> <?php $i++;
endforeach; ?>
</table> </table>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
......
...@@ -48,7 +48,8 @@ $counter = 1; ...@@ -48,7 +48,8 @@ $counter = 1;
<td align="center"><b><?php echo gettext('Loss')?></b></td> <td align="center"><b><?php echo gettext('Loss')?></b></td>
<td align="center"><b><?php echo gettext('Status')?></b></td> <td align="center"><b><?php echo gettext('Status')?></b></td>
</tr> </tr>
<?php foreach ($a_gateways as $gname => $gateway) { ?> <?php foreach ($a_gateways as $gname => $gateway) {
?>
<tr> <tr>
<td class="h6" id="gateway<?php echo $counter; ?>" rowspan="2" align="center"> <td class="h6" id="gateway<?php echo $counter; ?>" rowspan="2" align="center">
<strong> <strong>
...@@ -59,69 +60,74 @@ $counter = 1; ...@@ -59,69 +60,74 @@ $counter = 1;
<td colspan="3" align="left"> <td colspan="3" align="left">
<div class="h6" id="gateway<?php echo $counter; ?>" style="display:inline"> <div class="h6" id="gateway<?php echo $counter; ?>" style="display:inline">
<?php <?php
$if_gw = ''; $if_gw = '';
if (is_ipaddr($gateway['gateway'])) if (is_ipaddr($gateway['gateway'])) {
$if_gw = htmlspecialchars($gateway['gateway']); $if_gw = htmlspecialchars($gateway['gateway']);
else { } else {
if($gateway['ipprotocol'] == "inet") if ($gateway['ipprotocol'] == "inet") {
$if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface'])); $if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
if($gateway['ipprotocol'] == "inet6") }
$if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface'])); if ($gateway['ipprotocol'] == "inet6") {
} $if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
echo ($if_gw == '' ? '~' : $if_gw); }
unset ($if_gw); }
$counter++; echo ($if_gw == '' ? '~' : $if_gw);
?> unset ($if_gw);
$counter++;
?>
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="center" id="gateway<?php echo $counter; ?>"> <td align="center" id="gateway<?php echo $counter; ?>">
<?php <?php
if ($gateways_status[$gname]) if ($gateways_status[$gname]) {
echo htmlspecialchars($gateways_status[$gname]['delay']); echo htmlspecialchars($gateways_status[$gname]['delay']);
else } else {
echo gettext("Pending"); echo gettext("Pending");
?> }
?>
<?php $counter++; ?> <?php $counter++; ?>
</td> </td>
<td align="center" id="gateway<?php echo $counter; ?>"> <td align="center" id="gateway<?php echo $counter; ?>">
<?php <?php
if ($gateways_status[$gname]) if ($gateways_status[$gname]) {
echo htmlspecialchars($gateways_status[$gname]['loss']); echo htmlspecialchars($gateways_status[$gname]['loss']);
else } else {
echo gettext("Pending"); echo gettext("Pending");
?> }
?>
<?php $counter++; ?> <?php $counter++; ?>
</td> </td>
<?php <?php
if ($gateways_status[$gname]) { if ($gateways_status[$gname]) {
if (stristr($gateways_status[$gname]['status'], "force_down")) { if (stristr($gateways_status[$gname]['status'], "force_down")) {
$online = "Offline (forced)"; $online = "Offline (forced)";
$class="danger"; $class="danger";
} elseif (stristr($gateways_status[$gname]['status'], "down")) { } elseif (stristr($gateways_status[$gname]['status'], "down")) {
$online = "Offline"; $online = "Offline";
$class="danger"; $class="danger";
} elseif (stristr($gateways_status[$gname]['status'], "loss")) { } elseif (stristr($gateways_status[$gname]['status'], "loss")) {
$online = "Packetloss"; $online = "Packetloss";
$class="warning"; $class="warning";
} elseif (stristr($gateways_status[$gname]['status'], "delay")) { } elseif (stristr($gateways_status[$gname]['status'], "delay")) {
$online = "Latency"; $online = "Latency";
$class="warning"; $class="warning";
} elseif ($gateways_status[$gname]['status'] == "none") { } elseif ($gateways_status[$gname]['status'] == "none") {
$online = "Online"; $online = "Online";
$class="success"; $class="success";
} elseif ($gateways_status[$gname]['status'] == "") { } elseif ($gateways_status[$gname]['status'] == "") {
$online = "Pending"; $online = "Pending";
$class="info"; $class="info";
} }
} else { } else {
$online = gettext("Unknown"); $online = gettext("Unknown");
$class="info"; $class="info";
} }
echo "<td class=\"$class\" align=\"center\">$online</td>\n"; echo "<td class=\"$class\" align=\"center\">$online</td>\n";
$counter++; $counter++;
?> ?>
</tr> </tr>
<?php } // foreach ?> <?php
} // foreach ?>
</table> </table>
...@@ -31,9 +31,9 @@ require_once("guiconfig.inc"); ...@@ -31,9 +31,9 @@ require_once("guiconfig.inc");
require_once("gmirror.inc"); require_once("gmirror.inc");
if ($_GET['textonly'] == "true") { if ($_GET['textonly'] == "true") {
header("Cache-Control: no-cache"); header("Cache-Control: no-cache");
echo gmirror_html_status(); echo gmirror_html_status();
exit; exit;
} }
?> ?>
<table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="gmirror status"> <table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="gmirror status">
......
...@@ -36,69 +36,97 @@ require_once("pfsense-utils.inc"); ...@@ -36,69 +36,97 @@ require_once("pfsense-utils.inc");
require_once("functions.inc"); require_once("functions.inc");
require_once("widgets/include/interfaces.inc"); require_once("widgets/include/interfaces.inc");
$i = 0; $i = 0;
$ifdescrs = get_configured_interface_with_descr(); $ifdescrs = get_configured_interface_with_descr();
?> ?>
<table class="table table-striped"> <table class="table table-striped">
<?php <?php
foreach ($ifdescrs as $ifdescr => $ifname) { foreach ($ifdescrs as $ifdescr => $ifname) {
$ifinfo = get_interface_info($ifdescr); $ifinfo = get_interface_info($ifdescr);
$iswireless = is_interface_wireless($ifdescr); $iswireless = is_interface_wireless($ifdescr);
?> ?>
<tr> <tr>
<td class="vncellt" > <td class="vncellt" >
<?php <?php
if($ifinfo['ppplink']) { if ($ifinfo['ppplink']) {
?> <span alt="3g" class="glyphicon glyphicon-phone text-success"></span> <?php ?> <span alt="3g" class="glyphicon glyphicon-phone text-success"></span> <?php
} else if($iswireless) { } elseif ($iswireless) {
if($ifinfo['status'] == "associated") { ?> if ($ifinfo['status'] == "associated") {
?>
<span alt="wlan" class="glyphicon glyphicon-signal text-success"></span> <span alt="wlan" class="glyphicon glyphicon-signal text-success"></span>
<?php } else { ?> <?php
} else {
?>
<span alt="wlan_d" class="glyphicon glyphicon-signal text-danger"></span> <span alt="wlan_d" class="glyphicon glyphicon-signal text-danger"></span>
<?php } ?> <?php
<?php } else { ?> } ?>
<?php if ($ifinfo['status'] == "up") { ?> <?php
} else {
?>
<?php if ($ifinfo['status'] == "up") {
?>
<span alt="cablenic" id="<?php echo $ifname . 'icon';?>" class="glyphicon glyphicon-transfer text-success"></span> <span alt="cablenic" id="<?php echo $ifname . 'icon';?>" class="glyphicon glyphicon-transfer text-success"></span>
<?php } else { ?> <?php
<span alt="cablenic" id="<?php echo $ifname . 'icon';?>" class="glyphicon glyphicon-transfer text-danger"></span> } else {
<?php } ?> ?>
<?php } ?>&nbsp; <span alt="cablenic" id="<?php echo $ifname . 'icon';?>" class="glyphicon glyphicon-transfer text-danger"></span>
<?php
} ?>
<?php
} ?>&nbsp;
<strong><u> <strong><u>
<span onclick="location.href='/interfaces.php?if=<?=$ifdescr; ?>'" style="cursor:pointer"> <span onclick="location.href='/interfaces.php?if=<?=$ifdescr; ?>'" style="cursor:pointer">
<?=htmlspecialchars($ifname);?></span></u></strong> <?=htmlspecialchars($ifname);?></span></u></strong>
<?php <?php
if ($ifinfo['dhcplink']) if ($ifinfo['dhcplink']) {
echo "&nbsp;(DHCP)"; echo "&nbsp;(DHCP)";
?> }
?>
</td> </td>
<?php if($ifinfo['status'] == "up" || $ifinfo['status'] == "associated") { ?> <?php if ($ifinfo['status'] == "up" || $ifinfo['status'] == "associated") {
?>
<td class="listr" align="center"> <td class="listr" align="center">
<span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-up text-success"></span> <span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-up text-success"></span>
</td> </td>
<?php } else if ($ifinfo['status'] == "no carrier") { ?> <?php
} elseif ($ifinfo['status'] == "no carrier") {
?>
<td class="listr" align="center"> <td class="listr" align="center">
<span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-down text-danger"></span> <span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-down text-danger"></span>
</td> </td>
<?php } else if ($ifinfo['status'] == "down") { ?> <?php
} elseif ($ifinfo['status'] == "down") {
?>
<td class="listr" align="center"> <td class="listr" align="center">
<span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-remove text-danger"></span> <span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-remove text-danger"></span>
</td> </td>
<?php } else { ?><?=htmlspecialchars($ifinfo['status']); }?> <?php
} else {
?><?=htmlspecialchars($ifinfo['status']);
}?>
<td class="listr"> <td class="listr">
<div id="<?php echo $ifname;?>" style="display:inline"><?=htmlspecialchars($ifinfo['media']);?></div> <div id="<?php echo $ifname;
?>" style="display:inline"><?=htmlspecialchars($ifinfo['media']);?></div>
</td> </td>
<td class="vncellt"> <td class="vncellt">
<?php if($ifinfo['ipaddr'] != "") { ?> <?php if ($ifinfo['ipaddr'] != "") {
<div id="<?php echo $ifname;?>-ip" style="display:inline"><?=htmlspecialchars($ifinfo['ipaddr']);?> </div> ?>
<div id="<?php echo $ifname;
?>-ip" style="display:inline"><?=htmlspecialchars($ifinfo['ipaddr']);?> </div>
<br /> <br />
<?php } <?php
if ($ifinfo['ipaddrv6'] != "") { ?> }
<div id="<?php echo $ifname;?>-ipv6" style="display:inline"><?=htmlspecialchars($ifinfo['ipaddrv6']);?> </div> if ($ifinfo['ipaddrv6'] != "") {
<?php } ?> ?>
<div id="<?php echo $ifname;
?>-ipv6" style="display:inline"><?=htmlspecialchars($ifinfo['ipaddrv6']);?> </div>
<?php
} ?>
</td> </td>
</tr> </tr>
<?php }//end for each ?> <?php
}//end for each ?>
</table> </table>
...@@ -49,27 +49,27 @@ $array_interrupt = array(); ...@@ -49,27 +49,27 @@ $array_interrupt = array();
$interfacecounter = 0; $interfacecounter = 0;
//build data arrays //build data arrays
foreach ($ifdescrs as $ifdescr => $ifname){ foreach ($ifdescrs as $ifdescr => $ifname) {
$ifinfo = get_interface_info($ifdescr); $ifinfo = get_interface_info($ifdescr);
$interfacecounter++; $interfacecounter++;
if ($ifinfo['status'] != "down"){ if ($ifinfo['status'] != "down") {
$array_in_packets[] = $ifinfo['inpkts']; $array_in_packets[] = $ifinfo['inpkts'];
$array_out_packets[] = $ifinfo['outpkts']; $array_out_packets[] = $ifinfo['outpkts'];
$array_in_bytes[] = format_bytes($ifinfo['inbytes']); $array_in_bytes[] = format_bytes($ifinfo['inbytes']);
$array_out_bytes[] = format_bytes($ifinfo['outbytes']); $array_out_bytes[] = format_bytes($ifinfo['outbytes']);
if (isset($ifinfo['inerrs'])){ if (isset($ifinfo['inerrs'])) {
$array_in_errors[] = $ifinfo['inerrs']; $array_in_errors[] = $ifinfo['inerrs'];
$array_out_errors[] = $ifinfo['outerrs']; $array_out_errors[] = $ifinfo['outerrs'];
} } else {
else{ $array_in_errors[] = "n/a";
$array_in_errors[] = "n/a"; $array_out_errors[] = "n/a";
$array_out_errors[] = "n/a"; }
} if (isset($ifinfo['collisions'])) {
if (isset($ifinfo['collisions'])) $array_collisions[] = htmlspecialchars($ifinfo['collisions']);
$array_collisions[] = htmlspecialchars($ifinfo['collisions']); } else {
else $array_collisions[] = "n/a";
$array_collisions[] = "n/a"; }
} }
}//end for }//end for
...@@ -106,102 +106,110 @@ foreach ($ifdescrs as $ifdescr => $ifname){ ...@@ -106,102 +106,110 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="the stats"> <table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="the stats">
<tr> <tr>
<?php <?php
$interface_names = array(); $interface_names = array();
foreach ($ifdescrs as $ifdescr => $ifname): foreach ($ifdescrs as $ifdescr => $ifname) :
$ifinfo = get_interface_info($ifdescr); $ifinfo = get_interface_info($ifdescr);
if ($ifinfo['status'] != "down"){ ?> if ($ifinfo['status'] != "down") {
<td class="widgetsubheader nowrap" style="height:25px"> ?>
<b><?=htmlspecialchars($ifname);?></b> <td class="widgetsubheader nowrap" style="height:25px">
</td> <b><?=htmlspecialchars($ifname);?></b>
<?php </td>
//build array of interface names <?php
$interface_names[] = $ifname; //build array of interface names
} $interface_names[] = $ifname;
endforeach; ?> }
endforeach; ?>
</tr> </tr>
<tr> <tr>
<?php <?php
$counter = 1; $counter = 1;
foreach ($array_in_packets as $data): ?> foreach ($array_in_packets as $data) :
?>
<td class="listr nowrap" id="stat<?php echo $counter?>" style="height:25px"> <td class="listr nowrap" id="stat<?php echo $counter?>" style="height:25px">
<?=htmlspecialchars($data);?> <?=htmlspecialchars($data);?>
</td> </td>
<?php <?php
$counter = $counter + 7; $counter = $counter + 7;
endforeach; ?> endforeach; ?>
</tr> </tr>
<tr> <tr>
<?php <?php
$counter = 2; $counter = 2;
foreach ($array_out_packets as $data): ?> foreach ($array_out_packets as $data) :
?>
<td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px">
<?=htmlspecialchars($data);?> <?=htmlspecialchars($data);?>
</td> </td>
<?php <?php
$counter = $counter + 7; $counter = $counter + 7;
endforeach; ?> endforeach; ?>
</tr> </tr>
<tr> <tr>
<?php <?php
$counter = 3; $counter = 3;
foreach ($array_in_bytes as $data): ?> foreach ($array_in_bytes as $data) :
?>
<td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px">
<?=htmlspecialchars($data);?> <?=htmlspecialchars($data);?>
</td> </td>
<?php <?php
$counter = $counter + 7; $counter = $counter + 7;
endforeach; ?> endforeach; ?>
</tr> </tr>
<tr> <tr>
<?php <?php
$counter = 4; $counter = 4;
foreach ($array_out_bytes as $data): ?> foreach ($array_out_bytes as $data) :
?>
<td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px">
<?=htmlspecialchars($data);?> <?=htmlspecialchars($data);?>
</td> </td>
<?php <?php
$counter = $counter + 7; $counter = $counter + 7;
endforeach; ?> endforeach; ?>
</tr> </tr>
<tr> <tr>
<?php <?php
$counter = 5; $counter = 5;
foreach ($array_in_errors as $data): ?> foreach ($array_in_errors as $data) :
?>
<td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px">
<?=htmlspecialchars($data);?> <?=htmlspecialchars($data);?>
</td> </td>
<?php <?php
$counter = $counter + 7; $counter = $counter + 7;
endforeach; ?> endforeach; ?>
</tr> </tr>
<tr> <tr>
<?php <?php
$counter = 6; $counter = 6;
foreach ($array_out_errors as $data): ?> foreach ($array_out_errors as $data) :
?>
<td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px">
<?=htmlspecialchars($data);?> <?=htmlspecialchars($data);?>
</td> </td>
<?php <?php
$counter = $counter + 7; $counter = $counter + 7;
endforeach; ?> endforeach; ?>
</tr> </tr>
<tr> <tr>
<?php <?php
$counter = 7; $counter = 7;
foreach ($array_collisions as $data): ?> foreach ($array_collisions as $data) :
?>
<td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px"> <td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px">
<?=htmlspecialchars($data);?> <?=htmlspecialchars($data);?>
</td> </td>
<?php <?php
$counter = $counter + 7; $counter = $counter + 7;
endforeach; ?> endforeach; ?>
</tr> </tr>
</table> </table>
</div> </div>
...@@ -34,58 +34,61 @@ require_once("guiconfig.inc"); ...@@ -34,58 +34,61 @@ require_once("guiconfig.inc");
require_once("functions.inc"); require_once("functions.inc");
require_once("ipsec.inc"); require_once("ipsec.inc");
if (isset($config['ipsec']['phase1'])){?> if (isset($config['ipsec']['phase1'])) {
?>
<div>&nbsp;</div> <div>&nbsp;</div>
<?php <?php
$tab_array = array(); $tab_array = array();
$tab_array[0] = array("Overview", true, "ipsec-Overview"); $tab_array[0] = array("Overview", true, "ipsec-Overview");
$tab_array[1] = array("Tunnels", false, "ipsec-tunnel"); $tab_array[1] = array("Tunnels", false, "ipsec-tunnel");
$tab_array[2] = array("Mobile", false, "ipsec-mobile"); $tab_array[2] = array("Mobile", false, "ipsec-mobile");
display_widget_tabs($tab_array); display_widget_tabs($tab_array);
$spd = ipsec_dump_spd(); $spd = ipsec_dump_spd();
$sad = ipsec_dump_sad(); $sad = ipsec_dump_sad();
$mobile = array(); // TODO: temporary disabled ( https://github.com/opnsense/core/issues/139 ) ipsec_dump_mobile(); $mobile = array(); // TODO: temporary disabled ( https://github.com/opnsense/core/issues/139 ) ipsec_dump_mobile();
$ipsec_status = ipsec_smp_dump_status(); $ipsec_status = ipsec_smp_dump_status();
$activecounter = 0; $activecounter = 0;
$inactivecounter = 0; $inactivecounter = 0;
$ipsec_detail_array = array(); $ipsec_detail_array = array();
foreach ($config['ipsec']['phase2'] as $ph2ent){ foreach ($config['ipsec']['phase2'] as $ph2ent) {
if ($ph2ent['remoteid']['type'] == "mobile") if ($ph2ent['remoteid']['type'] == "mobile") {
continue; continue;
ipsec_lookup_phase1($ph2ent,$ph1ent); }
$ipsecstatus = false; ipsec_lookup_phase1($ph2ent, $ph1ent);
$ipsecstatus = false;
$tun_disabled = "false";
$foundsrc = false; $tun_disabled = "false";
$founddst = false; $foundsrc = false;
$founddst = false;
if (isset($ph1ent['disabled']) || isset($ph2ent['disabled'])) {
$tun_disabled = "true"; if (isset($ph1ent['disabled']) || isset($ph2ent['disabled'])) {
continue; $tun_disabled = "true";
} continue;
if (isset($ipsec_status['query']['ikesalist']['ikesa']) && isset($ph1ent['ikeid']) && ipsec_phase1_status($ipsec_status['query']['ikesalist']['ikesa'], $ph1ent['ikeid'])) { }
/* tunnel is up */ if (isset($ipsec_status['query']['ikesalist']['ikesa']) && isset($ph1ent['ikeid']) && ipsec_phase1_status($ipsec_status['query']['ikesalist']['ikesa'], $ph1ent['ikeid'])) {
$iconfn = "true"; /* tunnel is up */
$activecounter++; $iconfn = "true";
} else { $activecounter++;
/* tunnel is down */ } else {
$iconfn = "false"; /* tunnel is down */
$inactivecounter++; $iconfn = "false";
} $inactivecounter++;
}
$ipsec_detail_array[] = array('src' => convert_friendly_interface_to_friendly_descr($ph1ent['interface']),
'dest' => $ph1ent['remote-gateway'], $ipsec_detail_array[] = array('src' => convert_friendly_interface_to_friendly_descr($ph1ent['interface']),
'remote-subnet' => ipsec_idinfo_to_text($ph2ent['remoteid']), 'dest' => $ph1ent['remote-gateway'],
'descr' => $ph2ent['descr'], 'remote-subnet' => ipsec_idinfo_to_text($ph2ent['remoteid']),
'status' => $iconfn, 'descr' => $ph2ent['descr'],
'disabled' => $tun_disabled); 'status' => $iconfn,
} 'disabled' => $tun_disabled);
}
} }
if (isset($config['ipsec']['phase2'])){ ?> if (isset($config['ipsec']['phase2'])) {
?>
<div id="ipsec-Overview" style="display:block;background-color:#EEEEEE;"> <div id="ipsec-Overview" style="display:block;background-color:#EEEEEE;">
<div> <div>
...@@ -98,7 +101,12 @@ if (isset($config['ipsec']['phase1'])){?> ...@@ -98,7 +101,12 @@ if (isset($config['ipsec']['phase1'])){?>
<tr> <tr>
<td><?php echo $activecounter; ?></td> <td><?php echo $activecounter; ?></td>
<td><?php echo $inactivecounter; ?></td> <td><?php echo $inactivecounter; ?></td>
<td><?php if (is_array($mobile['pool'])) echo htmlspecialchars($mobile['pool'][0]['usage']); else echo 0; ?></td> <td><?php if (is_array($mobile['pool'])) {
echo htmlspecialchars($mobile['pool'][0]['usage']);
} else {
echo 0;
} ?></td>
</tr> </tr>
</table> </table>
</div> </div>
...@@ -114,17 +122,15 @@ if (isset($config['ipsec']['phase1'])){?> ...@@ -114,17 +122,15 @@ if (isset($config['ipsec']['phase1'])){?>
</div> </div>
<div style="max-height:105px;overflow:auto;"> <div style="max-height:105px;overflow:auto;">
<?php <?php
foreach ($ipsec_detail_array as $ipsec) : foreach ($ipsec_detail_array as $ipsec) :
if ($ipsec['disabled'] == "true") {
$spans = "<span class=\"gray\">";
$spane = "</span>";
} else {
$spans = $spane = "";
}
if ($ipsec['disabled'] == "true"){ ?>
$spans = "<span class=\"gray\">";
$spane = "</span>";
}
else {
$spans = $spane = "";
}
?>
<div style="display:table-row;"> <div style="display:table-row;">
<div style="display:table-cell;width:39px"> <div style="display:table-cell;width:39px">
...@@ -141,19 +147,20 @@ if (isset($config['ipsec']['phase1'])){?> ...@@ -141,19 +147,20 @@ if (isset($config['ipsec']['phase1'])){?>
<div style="display:table-cell;width:37px" align="center"><?php echo $spans;?> <div style="display:table-cell;width:37px" align="center"><?php echo $spans;?>
<?php <?php
if($ipsec['status'] == "true") { if ($ipsec['status'] == "true") {
/* tunnel is up */ /* tunnel is up */
$iconfn = "text-success"; $iconfn = "text-success";
} else { } else {
/* tunnel is down */ /* tunnel is down */
$iconfn = "text-danger"; $iconfn = "text-danger";
} }
echo "<span class='glyphicon glyphicon-transfer ".$iconfn."' alt='Tunnel status'></span>"; echo "<span class='glyphicon glyphicon-transfer ".$iconfn."' alt='Tunnel status'></span>";
?><?php echo $spane;?></div> ?><?php echo $spane;?></div>
</div> </div>
<?php endforeach; ?> <?php
endforeach; ?>
</div> </div>
</div> </div>
</div> </div>
...@@ -166,10 +173,11 @@ if (isset($config['ipsec']['phase1'])){?> ...@@ -166,10 +173,11 @@ if (isset($config['ipsec']['phase1'])){?>
</div> </div>
<div style="max-height:105px;overflow:auto;"> <div style="max-height:105px;overflow:auto;">
<?php <?php
if (is_array($mobile['pool'])): if (is_array($mobile['pool'])) :
foreach ($mobile['pool'] as $pool): foreach ($mobile['pool'] as $pool) :
if (is_array($pool['lease'])): if (is_array($pool['lease'])) :
foreach ($pool['lease'] as $muser) : ?> foreach ($pool['lease'] as $muser) :
?>
<div style="display:table-row;"> <div style="display:table-row;">
<div class="listlr" style="display:table-cell;width:139px"> <div class="listlr" style="display:table-cell;width:139px">
<?php echo htmlspecialchars($muser['id']);?><br /> <?php echo htmlspecialchars($muser['id']);?><br />
...@@ -182,17 +190,18 @@ if (isset($config['ipsec']['phase1'])){?> ...@@ -182,17 +190,18 @@ if (isset($config['ipsec']['phase1'])){?>
</div> </div>
</div> </div>
<?php <?php
endforeach; endforeach;
endif; endif;
endforeach; endforeach;
endif; endif;
?> ?>
</div> </div>
</div> </div>
</div> </div>
<?php //end ipsec tunnel <?php //end ipsec tunnel
}//end if tunnels are configured, else show code below } //end if tunnels are configured, else show code below
else { ?> else {
?>
<div style="display:block"> <div style="display:block">
<table class="table table-striped" width="100%" border="0" cellpadding="0" cellspacing="0" summary="note"> <table class="table table-striped" width="100%" border="0" cellpadding="0" cellspacing="0" summary="note">
<tr> <tr>
...@@ -210,4 +219,5 @@ else { ?> ...@@ -210,4 +219,5 @@ else { ?>
</tr> </tr>
</table> </table>
</div> </div>
<?php } ?> <?php
}
...@@ -42,13 +42,13 @@ $now = time(); ...@@ -42,13 +42,13 @@ $now = time();
$year = date("Y"); $year = date("Y");
if (!is_array($config['load_balancer'])) { if (!is_array($config['load_balancer'])) {
$config['load_balancer'] = array(); $config['load_balancer'] = array();
} }
if (!is_array($config['load_balancer']['lbpool'])) { if (!is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array(); $config['load_balancer']['lbpool'] = array();
} }
if (!is_array($config['load_balancer']['virtual_server'])) { if (!is_array($config['load_balancer']['virtual_server'])) {
$config['load_balancer']['virtual_server'] = array(); $config['load_balancer']['virtual_server'] = array();
} }
$a_vs = &$config['load_balancer']['virtual_server']; $a_vs = &$config['load_balancer']['virtual_server'];
$a_pool = &$config['load_balancer']['lbpool']; $a_pool = &$config['load_balancer']['lbpool'];
...@@ -58,7 +58,7 @@ $relay_hosts = get_lb_summary(); ...@@ -58,7 +58,7 @@ $relay_hosts = get_lb_summary();
$lb_logfile = '/var/log/relayd.log'; $lb_logfile = '/var/log/relayd.log';
$nentries = $config['syslog']['nentries']; $nentries = $config['syslog']['nentries'];
if (!$nentries) { if (!$nentries) {
$nentries = 50; $nentries = 50;
} }
?> ?>
...@@ -69,23 +69,24 @@ if (!$nentries) { ...@@ -69,23 +69,24 @@ if (!$nentries) {
<td width="10%" class="listhdrr">Pool</td> <td width="10%" class="listhdrr">Pool</td>
<td width="30%" class="listhdr">Description</td> <td width="30%" class="listhdr">Description</td>
</thead> </thead>
<?php $i = 0; foreach ($a_vs as $vsent): ?> <?php $i = 0; foreach ($a_vs as $vsent) :
?>
<tr> <tr>
<?php <?php
switch (trim($rdr_a[$vsent['name']]['status'])) { switch (trim($rdr_a[$vsent['name']]['status'])) {
case 'active': case 'active':
$bgcolor = "#90EE90"; // lightgreen $bgcolor = "#90EE90"; // lightgreen
$rdr_a[$vsent['name']]['status'] = "Active"; $rdr_a[$vsent['name']]['status'] = "Active";
break; break;
case 'down': case 'down':
$bgcolor = "#F08080"; // lightcoral $bgcolor = "#F08080"; // lightcoral
$rdr_a[$vsent['name']]['status'] = "Down"; $rdr_a[$vsent['name']]['status'] = "Down";
break; break;
default: default:
$bgcolor = "#D3D3D3"; // lightgray $bgcolor = "#D3D3D3"; // lightgray
$rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?'; $rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?';
} }
?> ?>
<td class="listlr"> <td class="listlr">
<?=$vsent['name'];?><br /> <?=$vsent['name'];?><br />
<span style="background-color: <?=$bgcolor?>; display: block"><i><?=$rdr_a[$vsent['name']]['status']?></i></span> <span style="background-color: <?=$bgcolor?>; display: block"><i><?=$rdr_a[$vsent['name']]['status']?></i></span>
...@@ -94,52 +95,55 @@ if (!$nentries) { ...@@ -94,52 +95,55 @@ if (!$nentries) {
<td class="listr" align="center" > <td class="listr" align="center" >
<table border="0" cellpadding="0" cellspacing="2" summary="status"> <table border="0" cellpadding="0" cellspacing="2" summary="status">
<?php <?php
foreach ($a_pool as $pool) { foreach ($a_pool as $pool) {
if ($pool['name'] == $vsent['poolname']) { if ($pool['name'] == $vsent['poolname']) {
$pool_hosts=array(); $pool_hosts=array();
foreach ((array) $pool['servers'] as $server) { foreach ((array) $pool['servers'] as $server) {
$svr['ip']['addr']=$server; $svr['ip']['addr']=$server;
$svr['ip']['state']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['state']; $svr['ip']['state']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['state'];
$svr['ip']['avail']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['avail']; $svr['ip']['avail']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['avail'];
$pool_hosts[]=$svr; $pool_hosts[]=$svr;
} }
foreach ((array) $pool['serversdisabled'] as $server) { foreach ((array) $pool['serversdisabled'] as $server) {
$svr['ip']['addr']="$server"; $svr['ip']['addr']="$server";
$svr['ip']['state']='disabled'; $svr['ip']['state']='disabled';
$svr['ip']['avail']='disabled'; $svr['ip']['avail']='disabled';
$pool_hosts[]=$svr; $pool_hosts[]=$svr;
} }
asort($pool_hosts); asort($pool_hosts);
foreach ((array) $pool_hosts as $server) { foreach ((array) $pool_hosts as $server) {
if($server['ip']['addr']!="") { if ($server['ip']['addr']!="") {
switch ($server['ip']['state']) { switch ($server['ip']['state']) {
case 'up': case 'up':
$bgcolor = "#90EE90"; // lightgreen $bgcolor = "#90EE90"; // lightgreen
$checked = "checked"; $checked = "checked";
break; break;
case 'disabled': case 'disabled':
$bgcolor = "#FFFFFF"; // white $bgcolor = "#FFFFFF"; // white
$checked = ""; $checked = "";
break; break;
default: default:
$bgcolor = "#F08080"; // lightcoral $bgcolor = "#F08080"; // lightcoral
$checked = "checked"; $checked = "checked";
} }
echo "<tr>"; echo "<tr>";
echo "<td bgcolor=\"{$bgcolor}\">&nbsp;{$server['ip']['addr']}:{$pool['port']}&nbsp;</td><td bgcolor=\"{$bgcolor}\">&nbsp;"; echo "<td bgcolor=\"{$bgcolor}\">&nbsp;{$server['ip']['addr']}:{$pool['port']}&nbsp;</td><td bgcolor=\"{$bgcolor}\">&nbsp;";
if($server['ip']['avail']) if ($server['ip']['avail']) {
echo " ({$server['ip']['avail']}) "; echo " ({$server['ip']['avail']}) ";
echo "&nbsp;</td></tr>"; }
} echo "&nbsp;</td></tr>";
} }
} }
} }
?> }
?>
</table> </table>
</td> </td>
<td class="listbg" > <td class="listbg" >
<font color="#FFFFFF"><?=$vsent['descr'];?></font> <font color="#FFFFFF"><?=$vsent['descr'];?></font>
</td> </td>
</tr> </tr>
<?php $i++; endforeach; ?> <?php $i++;
endforeach; ?>
</table> </table>
...@@ -36,28 +36,36 @@ require_once("pfsense-utils.inc"); ...@@ -36,28 +36,36 @@ require_once("pfsense-utils.inc");
require_once("functions.inc"); require_once("functions.inc");
require_once("filter_log.inc"); require_once("filter_log.inc");
if(is_numeric($_POST['filterlogentries'])) { if (is_numeric($_POST['filterlogentries'])) {
$config['widgets']['filterlogentries'] = $_POST['filterlogentries']; $config['widgets']['filterlogentries'] = $_POST['filterlogentries'];
$acts = array(); $acts = array();
if ($_POST['actpass']) $acts[] = "Pass"; if ($_POST['actpass']) {
if ($_POST['actblock']) $acts[] = "Block"; $acts[] = "Pass";
if ($_POST['actreject']) $acts[] = "Reject"; }
if ($_POST['actblock']) {
if (!empty($acts)) $acts[] = "Block";
$config['widgets']['filterlogentriesacts'] = implode(" ", $acts); }
else if ($_POST['actreject']) {
unset($config['widgets']['filterlogentriesacts']); $acts[] = "Reject";
unset($acts); }
if( ($_POST['filterlogentriesinterfaces']) and ($_POST['filterlogentriesinterfaces'] != "All") ) if (!empty($acts)) {
$config['widgets']['filterlogentriesinterfaces'] = trim($_POST['filterlogentriesinterfaces']); $config['widgets']['filterlogentriesacts'] = implode(" ", $acts);
else } else {
unset($config['widgets']['filterlogentriesinterfaces']); unset($config['widgets']['filterlogentriesacts']);
}
write_config("Saved Filter Log Entries via Dashboard"); unset($acts);
Header("Location: /");
exit(0); if (($_POST['filterlogentriesinterfaces']) and ($_POST['filterlogentriesinterfaces'] != "All")) {
$config['widgets']['filterlogentriesinterfaces'] = trim($_POST['filterlogentriesinterfaces']);
} else {
unset($config['widgets']['filterlogentriesinterfaces']);
}
write_config("Saved Filter Log Entries via Dashboard");
Header("Location: /");
exit(0);
} }
$nentries = isset($config['widgets']['filterlogentries']) ? $config['widgets']['filterlogentries'] : 5; $nentries = isset($config['widgets']['filterlogentries']) ? $config['widgets']['filterlogentries'] : 5;
...@@ -68,8 +76,8 @@ $nentriesacts = isset($config['widgets']['filterlogentriesacts']) ? ...@@ -68,8 +76,8 @@ $nentriesacts = isset($config['widgets']['filterlogentriesacts']) ?
$nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ? $config['widgets']['filterlogentriesinterfaces'] : 'All'; $nentriesinterfaces = isset($config['widgets']['filterlogentriesinterfaces']) ? $config['widgets']['filterlogentriesinterfaces'] : 'All';
$filterfieldsarray = array( $filterfieldsarray = array(
"act" => $nentriesacts, "act" => $nentriesacts,
"interface" => $nentriesinterfaces "interface" => $nentriesinterfaces
); );
$filter_logfile = '/var/log/filter.log'; $filter_logfile = '/var/log/filter.log';
...@@ -91,10 +99,11 @@ var isPaused = false; ...@@ -91,10 +99,11 @@ var isPaused = false;
var nentries = <?php echo $nentries; ?>; var nentries = <?php echo $nentries; ?>;
<?php <?php
if(isset($config['syslog']['reverse'])) if (isset($config['syslog']['reverse'])) {
echo "var isReverse = true;\n"; echo "var isReverse = true;\n";
else } else {
echo "var isReverse = false;\n"; echo "var isReverse = false;\n";
}
?> ?>
/* Called by the AJAX updater */ /* Called by the AJAX updater */
...@@ -133,21 +142,33 @@ function format_log_line(row) { ...@@ -133,21 +142,33 @@ function format_log_line(row) {
<tr> <tr>
<td> <td>
<select name="filterlogentries" class="formfld unknown" id="filterlogentries"> <select name="filterlogentries" class="formfld unknown" id="filterlogentries">
<?php for ($i = 1; $i <= 20; $i++) { ?> <?php for ($i = 1; $i <= 20; $i++) {
<option value="<?php echo $i;?>" <?php if ($nentries == $i) echo "selected=\"selected\"";?>><?php echo $i;?></option> ?>
<?php } ?> <option value="<?php echo $i;?>" <?php if ($nentries == $i) {
echo "selected=\"selected\"";
}?>><?php echo $i;?></option>
<?php
} ?>
</select> </select>
</td> </td>
</tr> </tr>
<?php <?php
$Include_Act = explode(" ", $nentriesacts); $Include_Act = explode(" ", $nentriesacts);
if ($nentriesinterfaces == "All") $nentriesinterfaces = ""; if ($nentriesinterfaces == "All") {
$nentriesinterfaces = "";
}
?> ?>
<tr> <tr>
<td> <td>
<input id="actpass" name="actpass" type="checkbox" value="Pass" <?php if (in_arrayi('Pass', $Include_Act)) echo "checked=\"checked\""; ?> /> Pass <input id="actpass" name="actpass" type="checkbox" value="Pass" <?php if (in_arrayi('Pass', $Include_Act)) {
<input id="actblock" name="actblock" type="checkbox" value="Block" <?php if (in_arrayi('Block', $Include_Act)) echo "checked=\"checked\""; ?> /> Block echo "checked=\"checked\"";
<input id="actreject" name="actreject" type="checkbox" value="Reject" <?php if (in_arrayi('Reject', $Include_Act)) echo "checked=\"checked\""; ?> /> Reject } ?> /> Pass
<input id="actblock" name="actblock" type="checkbox" value="Block" <?php if (in_arrayi('Block', $Include_Act)) {
echo "checked=\"checked\"";
} ?> /> Block
<input id="actreject" name="actreject" type="checkbox" value="Reject" <?php if (in_arrayi('Reject', $Include_Act)) {
echo "checked=\"checked\"";
} ?> /> Reject
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -160,16 +181,18 @@ function format_log_line(row) { ...@@ -160,16 +181,18 @@ function format_log_line(row) {
<select id="filterlogentriesinterfaces" name="filterlogentriesinterfaces" class="formselect"> <select id="filterlogentriesinterfaces" name="filterlogentriesinterfaces" class="formselect">
<option value="All">ALL</option> <option value="All">ALL</option>
<?php <?php
$interfaces = get_configured_interface_with_descr(); $interfaces = get_configured_interface_with_descr();
foreach ($interfaces as $iface => $ifacename): foreach ($interfaces as $iface => $ifacename) :
?> ?>
<option value="<?=$iface;?>" <?php if ($nentriesinterfaces == $iface) echo "selected=\"selected\"";?>> <option value="<?=$iface;?>" <?php if ($nentriesinterfaces == $iface) {
<?=htmlspecialchars($ifacename);?> echo "selected=\"selected\"";
</option> }?>>
<?=htmlspecialchars($ifacename);?>
</option>
<?php <?php
endforeach; endforeach;
unset($interfaces); unset($interfaces);
unset($Include_Act); unset($Include_Act);
?> ?>
</select> </select>
</td> </td>
...@@ -203,31 +226,35 @@ function format_log_line(row) { ...@@ -203,31 +226,35 @@ function format_log_line(row) {
</thead> </thead>
<tbody id='filter-log-entries'> <tbody id='filter-log-entries'>
<?php <?php
$rowIndex = 0; $rowIndex = 0;
foreach ($filterlog as $filterent): foreach ($filterlog as $filterent) :
$evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
$rowIndex++; $rowIndex++;
?> ?>
<tr class="<?=$evenRowClass?>"> <tr class="<?=$evenRowClass?>">
<td class="listMRlr nowrap" align="center"> <td class="listMRlr nowrap" align="center">
<a href="#" onclick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);"> <a href="#" onclick="javascript:getURL('diag_logs_filter.php?getrulenum=<?php echo "{$filterent['rulenum']},{$filterent['act']}"; ?>', outputrule);">
<span class="<?php echo find_action_image($filterent['act']);?>" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" ></span> <span class="<?php echo find_action_image($filterent['act']);?>" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" ></span>
</a> </a>
</td> </td>
<td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['time']);?>"><?php echo substr(htmlspecialchars($filterent['time']),0,-3);?></td> <td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['time']);?>"><?php echo substr(htmlspecialchars($filterent['time']), 0, -3);?></td>
<td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['interface']);?>"><?php echo htmlspecialchars($filterent['interface']);?></td> <td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['interface']);?>"><?php echo htmlspecialchars($filterent['interface']);?></td>
<td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['src']);?>"> <td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['src']);?>">
<a href="#" onclick="javascript:getURL('diag_dns.php?host=<?php echo "{$filterent['srcip']}"; ?>&amp;dialog_output=true', outputrule);" title="<?=gettext("Reverse Resolve with DNS");?>"> <a href="#" onclick="javascript:getURL('diag_dns.php?host=<?php echo "{$filterent['srcip']}";
?>&amp;dialog_output=true', outputrule);" title="<?=gettext("Reverse Resolve with DNS");?>">
<?php echo htmlspecialchars($filterent['srcip']);?></a></td> <?php echo htmlspecialchars($filterent['srcip']);?></a></td>
<td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['dst']);?>"> <td class="listMRr ellipsis nowrap" title="<?php echo htmlspecialchars($filterent['dst']);?>">
<a href="#" onclick="javascript:getURL('diag_dns.php?host=<?php echo "{$filterent['dstip']}"; ?>&amp;dialog_output=true', outputrule);" title="<?=gettext("Reverse Resolve with DNS");?>"> <a href="#" onclick="javascript:getURL('diag_dns.php?host=<?php echo "{$filterent['dstip']}";
?>&amp;dialog_output=true', outputrule);" title="<?=gettext("Reverse Resolve with DNS");?>">
<?php echo htmlspecialchars($filterent['dstip']);?></a><?php echo ":" . htmlspecialchars($filterent['dstport']);?></td> <?php echo htmlspecialchars($filterent['dstip']);?></a><?php echo ":" . htmlspecialchars($filterent['dstport']);?></td>
<?php <?php
if ($filterent['proto'] == "TCP") if ($filterent['proto'] == "TCP") {
$filterent['proto'] .= ":{$filterent['tcpflags']}"; $filterent['proto'] .= ":{$filterent['tcpflags']}";
?> }
?>
</tr> </tr>
<?php endforeach; ?> <?php
endforeach; ?>
<tr style="display:none;"><td></td></tr> <tr style="display:none;"><td></td></tr>
</tbody> </tbody>
</table> </table>
......
...@@ -36,94 +36,94 @@ require_once("pfsense-utils.inc"); ...@@ -36,94 +36,94 @@ require_once("pfsense-utils.inc");
require_once("functions.inc"); require_once("functions.inc");
require_once("widgets/include/ntp_status.inc"); require_once("widgets/include/ntp_status.inc");
if($_REQUEST['updateme']) { if ($_REQUEST['updateme']) {
//this block displays only on ajax refresh //this block displays only on ajax refresh
exec("/usr/local/sbin/ntpq -pn | /usr/bin/tail +3", $ntpq_output); exec("/usr/local/sbin/ntpq -pn | /usr/bin/tail +3", $ntpq_output);
$ntpq_counter = 0; $ntpq_counter = 0;
foreach ($ntpq_output as $line) { foreach ($ntpq_output as $line) {
if (substr($line, 0, 1) == "*") { if (substr($line, 0, 1) == "*") {
//Active NTP Peer //Active NTP Peer
$line = substr($line, 1); $line = substr($line, 1);
$peerinfo = preg_split("/[\s\t]+/", $line); $peerinfo = preg_split("/[\s\t]+/", $line);
if ($peerinfo[2] == "1") { if ($peerinfo[2] == "1") {
$syncsource = $peerinfo[0] . " (stratum " . $peerinfo[2] . ", " . $peerinfo[1] . ")"; $syncsource = $peerinfo[0] . " (stratum " . $peerinfo[2] . ", " . $peerinfo[1] . ")";
} else { } else {
$syncsource = $peerinfo[0] . " (stratum " . $peerinfo[2] . ")"; $syncsource = $peerinfo[0] . " (stratum " . $peerinfo[2] . ")";
} }
$ntpq_counter++; $ntpq_counter++;
} elseif (substr($line, 0, 1) == "o") { } elseif (substr($line, 0, 1) == "o") {
//Local PPS Peer //Local PPS Peer
$line = substr($line, 1); $line = substr($line, 1);
$peerinfo = preg_split("/[\s\t]+/", $line); $peerinfo = preg_split("/[\s\t]+/", $line);
$syncsource = $peerinfo[1] . " (stratum " . $peerinfo[2] . ", PPS)"; $syncsource = $peerinfo[1] . " (stratum " . $peerinfo[2] . ", PPS)";
$ntpq_counter++; $ntpq_counter++;
} }
} }
exec("/usr/local/sbin/ntpq -c clockvar", $ntpq_clockvar_output); exec("/usr/local/sbin/ntpq -c clockvar", $ntpq_clockvar_output);
foreach ($ntpq_clockvar_output as $line) { foreach ($ntpq_clockvar_output as $line) {
if (substr($line, 0, 9) == "timecode=") { if (substr($line, 0, 9) == "timecode=") {
$tmp = explode('"', $line); $tmp = explode('"', $line);
$tmp = $tmp[1]; $tmp = $tmp[1];
if (substr($tmp, 0, 6) == '$GPRMC') { if (substr($tmp, 0, 6) == '$GPRMC') {
$gps_vars = explode(",", $tmp); $gps_vars = explode(",", $tmp);
$gps_ok = ($gps_vars[2] == "A"); $gps_ok = ($gps_vars[2] == "A");
$gps_lat_deg = substr($gps_vars[3], 0, 2); $gps_lat_deg = substr($gps_vars[3], 0, 2);
$gps_lat_min = substr($gps_vars[3], 2) / 60.0; $gps_lat_min = substr($gps_vars[3], 2) / 60.0;
$gps_lon_deg = substr($gps_vars[5], 0, 3); $gps_lon_deg = substr($gps_vars[5], 0, 3);
$gps_lon_min = substr($gps_vars[5], 3) / 60.0; $gps_lon_min = substr($gps_vars[5], 3) / 60.0;
$gps_lat = $gps_lat_deg + $gps_lat_min; $gps_lat = $gps_lat_deg + $gps_lat_min;
$gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1); $gps_lat = $gps_lat * (($gps_vars[4] == "N") ? 1 : -1);
$gps_lon = $gps_lon_deg + $gps_lon_min; $gps_lon = $gps_lon_deg + $gps_lon_min;
$gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1); $gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1);
$gps_la = $gps_vars[4]; $gps_la = $gps_vars[4];
$gps_lo = $gps_vars[6]; $gps_lo = $gps_vars[6];
}elseif (substr($tmp, 0, 6) == '$GPGGA') { } elseif (substr($tmp, 0, 6) == '$GPGGA') {
$gps_vars = explode(",", $tmp); $gps_vars = explode(",", $tmp);
$gps_ok = $gps_vars[6]; $gps_ok = $gps_vars[6];
$gps_lat_deg = substr($gps_vars[2], 0, 2); $gps_lat_deg = substr($gps_vars[2], 0, 2);
$gps_lat_min = substr($gps_vars[2], 2) / 60.0; $gps_lat_min = substr($gps_vars[2], 2) / 60.0;
$gps_lon_deg = substr($gps_vars[4], 0, 3); $gps_lon_deg = substr($gps_vars[4], 0, 3);
$gps_lon_min = substr($gps_vars[4], 3) / 60.0; $gps_lon_min = substr($gps_vars[4], 3) / 60.0;
$gps_lat = $gps_lat_deg + $gps_lat_min; $gps_lat = $gps_lat_deg + $gps_lat_min;
$gps_lat = $gps_lat * (($gps_vars[3] == "N") ? 1 : -1); $gps_lat = $gps_lat * (($gps_vars[3] == "N") ? 1 : -1);
$gps_lon = $gps_lon_deg + $gps_lon_min; $gps_lon = $gps_lon_deg + $gps_lon_min;
$gps_lon = $gps_lon * (($gps_vars[5] == "E") ? 1 : -1); $gps_lon = $gps_lon * (($gps_vars[5] == "E") ? 1 : -1);
$gps_alt = $gps_vars[9]; $gps_alt = $gps_vars[9];
$gps_alt_unit = $gps_vars[10]; $gps_alt_unit = $gps_vars[10];
$gps_sat = $gps_vars[7]; $gps_sat = $gps_vars[7];
$gps_la = $gps_vars[3]; $gps_la = $gps_vars[3];
$gps_lo = $gps_vars[5]; $gps_lo = $gps_vars[5];
}elseif (substr($tmp, 0, 6) == '$GPGLL') { } elseif (substr($tmp, 0, 6) == '$GPGLL') {
$gps_vars = explode(",", $tmp); $gps_vars = explode(",", $tmp);
$gps_ok = ($gps_vars[6] == "A"); $gps_ok = ($gps_vars[6] == "A");
$gps_lat_deg = substr($gps_vars[1], 0, 2); $gps_lat_deg = substr($gps_vars[1], 0, 2);
$gps_lat_min = substr($gps_vars[1], 2) / 60.0; $gps_lat_min = substr($gps_vars[1], 2) / 60.0;
$gps_lon_deg = substr($gps_vars[3], 0, 3); $gps_lon_deg = substr($gps_vars[3], 0, 3);
$gps_lon_min = substr($gps_vars[3], 3) / 60.0; $gps_lon_min = substr($gps_vars[3], 3) / 60.0;
$gps_lat = $gps_lat_deg + $gps_lat_min; $gps_lat = $gps_lat_deg + $gps_lat_min;
$gps_lat = $gps_lat * (($gps_vars[2] == "N") ? 1 : -1); $gps_lat = $gps_lat * (($gps_vars[2] == "N") ? 1 : -1);
$gps_lon = $gps_lon_deg + $gps_lon_min; $gps_lon = $gps_lon_deg + $gps_lon_min;
$gps_lon = $gps_lon * (($gps_vars[4] == "E") ? 1 : -1); $gps_lon = $gps_lon * (($gps_vars[4] == "E") ? 1 : -1);
$gps_la = $gps_vars[2]; $gps_la = $gps_vars[2];
$gps_lo = $gps_vars[4]; $gps_lo = $gps_vars[4];
} }
} }
} }
if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && (isset($gps_ok))) { 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 //GSV message is only enabled by init commands in services_ntpd_gps.php for SureGPS board
$gpsport = fopen("/dev/gps0", "r+"); $gpsport = fopen("/dev/gps0", "r+");
while($gpsport){ while ($gpsport) {
$buffer = fgets($gpsport); $buffer = fgets($gpsport);
if(substr($buffer, 0, 6)=='$GPGSV'){ if (substr($buffer, 0, 6)=='$GPGSV') {
//echo $buffer."\n"; //echo $buffer."\n";
$gpgsv = explode(',',$buffer); $gpgsv = explode(',', $buffer);
$gps_satview = $gpgsv[3]; $gps_satview = $gpgsv[3];
break; break;
} }
} }
} }
?> ?>
<table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="clock"> <table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="clock">
...@@ -131,41 +131,57 @@ if($_REQUEST['updateme']) { ...@@ -131,41 +131,57 @@ if($_REQUEST['updateme']) {
<tr> <tr>
<td width="40%" class="vncellt">Sync Source</td> <td width="40%" class="vncellt">Sync Source</td>
<td width="60%" class="listr"> <td width="60%" class="listr">
<?php if ($ntpq_counter == 0): ?> <?php if ($ntpq_counter == 0) :
?>
No active peers available No active peers available
<?php else: ?> <?php
else :
?>
<?php echo $syncsource; ?> <?php echo $syncsource; ?>
<?php endif; ?> <?php
endif; ?>
</td> </td>
</tr> </tr>
<?php if (($gps_ok) && ($gps_lat) && ($gps_lon)): ?> <?php if (($gps_ok) && ($gps_lat) && ($gps_lon)) :
?>
<tr> <tr>
<td width="40%" class="vncellt">Clock location</td> <td width="40%" class="vncellt">Clock location</td>
<td width="60%" class="listr"> <td width="60%" class="listr">
<a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>"> <a target="_gmaps" href="http://maps.google.com/?q=<?php echo $gps_lat; ?>,<?php echo $gps_lon; ?>">
<?php <?php
echo sprintf("%.5f", $gps_lat) . " " . $gps_la . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lo; ?> echo sprintf("%.5f", $gps_lat) . " " . $gps_la . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lo; ?>
</a> </a>
<?php if (isset($gps_alt)) {echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)";} ?> <?php if (isset($gps_alt)) {
echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)";
} ?>
</td> </td>
</tr> </tr>
<?php if (isset($gps_sat) || isset($gps_satview)): ?> <?php if (isset($gps_sat) || isset($gps_satview)) :
?>
<tr> <tr>
<td width="40%" class="vncellt">Satellites</td> <td width="40%" class="vncellt">Satellites</td>
<td width="60%" class="listr"> <td width="60%" class="listr">
<?php <?php
if (isset($gps_satview)) {echo 'in view ' . intval($gps_satview);} if (isset($gps_satview)) {
if (isset($gps_sat) && isset($gps_satview)) {echo ', ';} echo 'in view ' . intval($gps_satview);
if (isset($gps_sat)) {echo 'in use ' . $gps_sat;} }
?> if (isset($gps_sat) && isset($gps_satview)) {
echo ', ';
}
if (isset($gps_sat)) {
echo 'in use ' . $gps_sat;
}
?>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php
<?php endif; ?> endif; ?>
<?php
endif; ?>
</tbody> </tbody>
</table> </table>
<?php <?php
exit; exit;
} }
/*** Clock -- beginning of server-side support code /*** Clock -- beginning of server-side support code
...@@ -186,20 +202,23 @@ $gDate = time(); ...@@ -186,20 +202,23 @@ $gDate = time();
JavaScript client code's definition of clockShowsSeconds below to match. */ JavaScript client code's definition of clockShowsSeconds below to match. */
$gClockShowsSeconds = true; $gClockShowsSeconds = true;
function getServerDateItems($inDate) { function getServerDateItems($inDate)
return date('Y,n,j,G,',$inDate).intval(date('i',$inDate)).','.intval(date('s',$inDate)); {
// year (4-digit),month,day,hours (0-23),minutes,seconds return date('Y,n,j,G,', $inDate).intval(date('i', $inDate)).','.intval(date('s', $inDate));
// use intval to strip leading zero from minutes and seconds // year (4-digit),month,day,hours (0-23),minutes,seconds
// so JavaScript won't try to interpret them in octal // use intval to strip leading zero from minutes and seconds
// (use intval instead of ltrim, which translates '00' to '') // so JavaScript won't try to interpret them in octal
// (use intval instead of ltrim, which translates '00' to '')
} }
function clockDateString($inDate) { function clockDateString($inDate)
return date('Y. F j l',$inDate); // eg "Monday, January 1, 2002" {
return date('Y. F j l', $inDate); // eg "Monday, January 1, 2002"
} }
function clockTimeString($inDate, $showSeconds) { function clockTimeString($inDate, $showSeconds)
return date($showSeconds ? 'G:i:s' : 'g:i',$inDate).' '; {
return date($showSeconds ? 'G:i:s' : 'g:i', $inDate).' ';
} }
/*** Clock -- end of server-side support code ***/ /*** Clock -- end of server-side support code ***/
?> ?>
...@@ -453,7 +472,7 @@ function clockUpdate() ...@@ -453,7 +472,7 @@ function clockUpdate()
<td width="40%" class="vncellt">Server Time</td> <td width="40%" class="vncellt">Server Time</td>
<td width="60%" class="listr"> <td width="60%" class="listr">
<div id="ClockTime"> <div id="ClockTime">
<b><?php echo(clockTimeString($gDate,$gClockShowsSeconds));?></b> <b><?php echo(clockTimeString($gDate, $gClockShowsSeconds));?></b>
</div> </div>
</td> </td>
</tr> </tr>
......
...@@ -32,53 +32,56 @@ require_once("guiconfig.inc"); ...@@ -32,53 +32,56 @@ require_once("guiconfig.inc");
require_once("openvpn.inc"); require_once("openvpn.inc");
/* Handle AJAX */ /* Handle AJAX */
if($_GET['action']) { if ($_GET['action']) {
if($_GET['action'] == "kill") { if ($_GET['action'] == "kill") {
$port = $_GET['port']; $port = $_GET['port'];
$remipp = $_GET['remipp']; $remipp = $_GET['remipp'];
if (!empty($port) and !empty($remipp)) { if (!empty($port) and !empty($remipp)) {
$retval = kill_client($port, $remipp); $retval = kill_client($port, $remipp);
echo htmlentities("|{$port}|{$remipp}|{$retval}|"); echo htmlentities("|{$port}|{$remipp}|{$retval}|");
} else { } else {
echo gettext("invalid input"); echo gettext("invalid input");
} }
exit; exit;
} }
} }
function kill_client($port, $remipp) { function kill_client($port, $remipp)
global $g; {
global $g;
//$tcpsrv = "tcp://127.0.0.1:{$port}"; //$tcpsrv = "tcp://127.0.0.1:{$port}";
$tcpsrv = "unix:///var/etc/openvpn/{$port}.sock"; $tcpsrv = "unix:///var/etc/openvpn/{$port}.sock";
$errval; $errval;
$errstr; $errstr;
/* open a tcp connection to the management port of each server */ /* open a tcp connection to the management port of each server */
$fp = @stream_socket_client($tcpsrv, $errval, $errstr, 1); $fp = @stream_socket_client($tcpsrv, $errval, $errstr, 1);
$killed = -1; $killed = -1;
if ($fp) { if ($fp) {
stream_set_timeout($fp, 1); stream_set_timeout($fp, 1);
fputs($fp, "kill {$remipp}\n"); fputs($fp, "kill {$remipp}\n");
while (!feof($fp)) { while (!feof($fp)) {
$line = fgets($fp, 1024); $line = fgets($fp, 1024);
$info = stream_get_meta_data($fp); $info = stream_get_meta_data($fp);
if ($info['timed_out']) if ($info['timed_out']) {
break; break;
}
/* parse header list line */ /* parse header list line */
if (strpos($line, "INFO:") !== false) if (strpos($line, "INFO:") !== false) {
continue; continue;
if (strpos($line, "SUCCESS") !== false) { }
$killed = 0; if (strpos($line, "SUCCESS") !== false) {
} $killed = 0;
break; }
} break;
fclose($fp); }
} fclose($fp);
return $killed; }
return $killed;
} }
$servers = openvpn_get_active_servers(); $servers = openvpn_get_active_servers();
...@@ -117,7 +120,8 @@ $clients = openvpn_get_active_clients(); ...@@ -117,7 +120,8 @@ $clients = openvpn_get_active_clients();
} }
</script> </script>
<?php foreach ($servers as $server): ?> <?php foreach ($servers as $server) :
?>
<table class="table table-striped" style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0"> <table class="table table-striped" style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr> <tr>
...@@ -133,10 +137,10 @@ $clients = openvpn_get_active_clients(); ...@@ -133,10 +137,10 @@ $clients = openvpn_get_active_clients();
<td class="listhdrr">Real/Virtual IP</td> <td class="listhdrr">Real/Virtual IP</td>
</tr> </tr>
<?php $rowIndex = 0; <?php $rowIndex = 0;
foreach ($server['conns'] as $conn): foreach ($server['conns'] as $conn) :
$evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
$rowIndex++; $rowIndex++;
?> ?>
<tr name='<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>' class="<?=$evenRowClass?>"> <tr name='<?php echo "r:{$server['mgmt']}:{$conn['remote_host']}"; ?>' class="<?=$evenRowClass?>">
<td class="listMRlr"> <td class="listMRlr">
<?=$conn['common_name'];?> <?=$conn['common_name'];?>
...@@ -160,7 +164,8 @@ $clients = openvpn_get_active_clients(); ...@@ -160,7 +164,8 @@ $clients = openvpn_get_active_clients();
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php
endforeach; ?>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="6" class="list" height="12"></td> <td colspan="6" class="list" height="12"></td>
...@@ -171,8 +176,10 @@ $clients = openvpn_get_active_clients(); ...@@ -171,8 +176,10 @@ $clients = openvpn_get_active_clients();
</tr> </tr>
</table> </table>
<?php endforeach; ?> <?php
<?php if (!empty($sk_servers)) { ?> endforeach; ?>
<?php if (!empty($sk_servers)) {
?>
<table class="table table-striped" style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0"> <table class="table table-striped" style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr> <tr>
<td colspan="6" class="listtopic"> <td colspan="6" class="listtopic">
...@@ -186,7 +193,8 @@ $clients = openvpn_get_active_clients(); ...@@ -186,7 +193,8 @@ $clients = openvpn_get_active_clients();
<td class="listhdrr">Remote/Virtual IP</td> <td class="listhdrr">Remote/Virtual IP</td>
</tr> </tr>
<?php foreach ($sk_servers as $sk_server): ?> <?php foreach ($sk_servers as $sk_server) :
?>
<tr name='<?php echo "r:{$sk_server['port']}:{$sk_server['remote_host']}"; ?>'> <tr name='<?php echo "r:{$sk_server['port']}:{$sk_server['remote_host']}"; ?>'>
<td class="listlr"> <td class="listlr">
<?=$sk_server['name'];?> <?=$sk_server['name'];?>
...@@ -196,15 +204,15 @@ $clients = openvpn_get_active_clients(); ...@@ -196,15 +204,15 @@ $clients = openvpn_get_active_clients();
</td> </td>
<td rowspan="2" align="center"> <td rowspan="2" align="center">
<?php <?php
if ($sk_server['status'] == "up") { if ($sk_server['status'] == "up") {
/* tunnel is up */ /* tunnel is up */
$iconfn = "text-success"; $iconfn = "text-success";
} else { } else {
/* tunnel is down */ /* tunnel is down */
$iconfn = "text-danger"; $iconfn = "text-danger";
} }
echo "<span class='glyphicon glyphicon-transfer ".$iconfn."'></span>"; echo "<span class='glyphicon glyphicon-transfer ".$iconfn."'></span>";
?> ?>
</td> </td>
</tr> </tr>
<tr name='<?php echo "r:{$sk_server['port']}:{$sk_server['remote_host']}"; ?>'> <tr name='<?php echo "r:{$sk_server['port']}:{$sk_server['remote_host']}"; ?>'>
...@@ -215,14 +223,16 @@ $clients = openvpn_get_active_clients(); ...@@ -215,14 +223,16 @@ $clients = openvpn_get_active_clients();
<?=$sk_server['virtual_addr'];?> <?=$sk_server['virtual_addr'];?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php
endforeach; ?>
</table> </table>
</tr> </tr>
</table> </table>
<?php <?php
} ?> } ?>
<?php if (!empty($clients)) { ?> <?php if (!empty($clients)) {
?>
<table class="table table-striped" style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0"> <table class="table table-striped" style="padding-top:0px; padding-bottom:0px; padding-left:0px; padding-right:0px" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr> <tr>
<td colspan="6" class="listtopic"> <td colspan="6" class="listtopic">
...@@ -236,7 +246,8 @@ $clients = openvpn_get_active_clients(); ...@@ -236,7 +246,8 @@ $clients = openvpn_get_active_clients();
<td class="listhdrr">Remote/Virtual IP</td> <td class="listhdrr">Remote/Virtual IP</td>
</tr> </tr>
<?php foreach ($clients as $client): ?> <?php foreach ($clients as $client) :
?>
<tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'> <tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'>
<td class="listlr"> <td class="listlr">
<?=$client['name'];?> <?=$client['name'];?>
...@@ -246,15 +257,15 @@ $clients = openvpn_get_active_clients(); ...@@ -246,15 +257,15 @@ $clients = openvpn_get_active_clients();
</td> </td>
<td rowspan="2" align="center"> <td rowspan="2" align="center">
<?php <?php
if ($client['status'] == "up") { if ($client['status'] == "up") {
/* tunnel is up */ /* tunnel is up */
$iconfn = "text-success"; $iconfn = "text-success";
} else { } else {
/* tunnel is down */ /* tunnel is down */
$iconfn = "text-danger"; $iconfn = "text-danger";
} }
echo "<span class='glyphicon glyphicon-transfer ".$iconfn."'></span>"; echo "<span class='glyphicon glyphicon-transfer ".$iconfn."'></span>";
?> ?>
</td> </td>
</tr> </tr>
<tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'> <tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'>
...@@ -265,7 +276,8 @@ $clients = openvpn_get_active_clients(); ...@@ -265,7 +276,8 @@ $clients = openvpn_get_active_clients();
<?=$client['virtual_addr'];?> <?=$client['virtual_addr'];?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php
endforeach; ?>
</table> </table>
</tr> </tr>
</table> </table>
...@@ -274,10 +286,9 @@ $clients = openvpn_get_active_clients(); ...@@ -274,10 +286,9 @@ $clients = openvpn_get_active_clients();
} }
if ($DisplayNote) { if ($DisplayNote) {
echo "<br /><b>NOTE:</b> You need to bind each OpenVPN client to enable its management daemon: use 'Local port' setting in the OpenVPN client screen"; echo "<br /><b>NOTE:</b> You need to bind each OpenVPN client to enable its management daemon: use 'Local port' setting in the OpenVPN client screen";
} }
if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))) { if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))) {
echo "No OpenVPN instance defined"; echo "No OpenVPN instance defined";
} }
?>
...@@ -32,39 +32,40 @@ require_once("guiconfig.inc"); ...@@ -32,39 +32,40 @@ require_once("guiconfig.inc");
require_once("pfsense-utils.inc"); require_once("pfsense-utils.inc");
require_once("functions.inc"); require_once("functions.inc");
if($_GET['getpic']=="true") { if ($_GET['getpic']=="true") {
$pic_type_s = explode(".", $config['widgets']['picturewidget_filename']); $pic_type_s = explode(".", $config['widgets']['picturewidget_filename']);
$pic_type = $pic_type_s[1]; $pic_type = $pic_type_s[1];
if($config['widgets']['picturewidget']) if ($config['widgets']['picturewidget']) {
$data = base64_decode($config['widgets']['picturewidget']); $data = base64_decode($config['widgets']['picturewidget']);
header("Content-Disposition: inline; filename=\"{$config['widgets']['picturewidget_filename']}\""); }
header("Content-Type: image/{$pic_type}"); header("Content-Disposition: inline; filename=\"{$config['widgets']['picturewidget_filename']}\"");
header("Content-Length: " . strlen($data)); header("Content-Type: image/{$pic_type}");
echo $data; header("Content-Length: " . strlen($data));
exit; echo $data;
exit;
} }
if($_POST) { if ($_POST) {
if (is_uploaded_file($_FILES['pictfile']['tmp_name'])) { if (is_uploaded_file($_FILES['pictfile']['tmp_name'])) {
/* read the file contents */ /* read the file contents */
$fd_pic = fopen($_FILES['pictfile']['tmp_name'], "rb"); $fd_pic = fopen($_FILES['pictfile']['tmp_name'], "rb");
while ( ($buf=fread( $fd_pic, 8192 )) != '' ) { while (($buf=fread($fd_pic, 8192)) != '') {
// Here, $buf is guaranteed to contain data // Here, $buf is guaranteed to contain data
$data .= $buf; $data .= $buf;
} }
fclose($fd_pic); fclose($fd_pic);
if(!$data) { if (!$data) {
log_error("Warning, could not read file " . $_FILES['pictfile']['tmp_name']); log_error("Warning, could not read file " . $_FILES['pictfile']['tmp_name']);
die("Could not read temporary file"); die("Could not read temporary file");
} else { } else {
$picname = basename($_FILES['uploadedfile']['name']); $picname = basename($_FILES['uploadedfile']['name']);
$config['widgets']['picturewidget'] = base64_encode($data); $config['widgets']['picturewidget'] = base64_encode($data);
$config['widgets']['picturewidget_filename'] = $_FILES['pictfile']['name']; $config['widgets']['picturewidget_filename'] = $_FILES['pictfile']['name'];
write_config("Picture widget saved via Dashboard."); write_config("Picture widget saved via Dashboard.");
header("Location: /index.php"); header("Location: /index.php");
exit; exit;
} }
} }
} }
?> ?>
...@@ -89,13 +90,15 @@ if($_POST) { ...@@ -89,13 +90,15 @@ if($_POST) {
</div> </div>
<!-- hide picture if none is defined in the configuration --> <!-- hide picture if none is defined in the configuration -->
<?php if ( $config['widgets']['picturewidget_filename'] != "" ): ?> <?php if ($config['widgets']['picturewidget_filename'] != "") :
?>
<div id="picture-widgets" style="padding: 5px"> <div id="picture-widgets" style="padding: 5px">
<a href='/widgets/widgets/picture.widget.php?getpic=true' target='_blank'> <a href='/widgets/widgets/picture.widget.php?getpic=true' target='_blank'>
<img border="0" width="100%" height="100%" src="/widgets/widgets/picture.widget.php?getpic=true" alt="picture" /> <img border="0" width="100%" height="100%" src="/widgets/widgets/picture.widget.php?getpic=true" alt="picture" />
</a> </a>
</div> </div>
<?php endif ?> <?php
endif ?>
<!-- needed to show the settings widget icon --> <!-- needed to show the settings widget icon -->
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
......
...@@ -32,47 +32,54 @@ require_once("guiconfig.inc"); ...@@ -32,47 +32,54 @@ require_once("guiconfig.inc");
require_once("pfsense-utils.inc"); require_once("pfsense-utils.inc");
require_once("functions.inc"); require_once("functions.inc");
if($_POST['rssfeed']) { if ($_POST['rssfeed']) {
$config['widgets']['rssfeed'] = str_replace("\n", ",", htmlspecialchars($_POST['rssfeed'], ENT_QUOTES | ENT_HTML401)); $config['widgets']['rssfeed'] = str_replace("\n", ",", htmlspecialchars($_POST['rssfeed'], ENT_QUOTES | ENT_HTML401));
$config['widgets']['rssmaxitems'] = str_replace("\n", ",", htmlspecialchars($_POST['rssmaxitems'], ENT_QUOTES | ENT_HTML401)); $config['widgets']['rssmaxitems'] = str_replace("\n", ",", htmlspecialchars($_POST['rssmaxitems'], ENT_QUOTES | ENT_HTML401));
$config['widgets']['rsswidgetheight'] = htmlspecialchars($_POST['rsswidgetheight'], ENT_QUOTES | ENT_HTML401); $config['widgets']['rsswidgetheight'] = htmlspecialchars($_POST['rsswidgetheight'], ENT_QUOTES | ENT_HTML401);
$config['widgets']['rsswidgettextlength'] = htmlspecialchars($_POST['rsswidgettextlength'], ENT_QUOTES | ENT_HTML401); $config['widgets']['rsswidgettextlength'] = htmlspecialchars($_POST['rsswidgettextlength'], ENT_QUOTES | ENT_HTML401);
write_config("Saved RSS Widget feed via Dashboard"); write_config("Saved RSS Widget feed via Dashboard");
header("Location: /"); header("Location: /");
} }
// Use saved feed and max items // Use saved feed and max items
if($config['widgets']['rssfeed']) if ($config['widgets']['rssfeed']) {
$rss_feed_s = explode(",", $config['widgets']['rssfeed']); $rss_feed_s = explode(",", $config['widgets']['rssfeed']);
}
if($config['widgets']['rssmaxitems']) if ($config['widgets']['rssmaxitems']) {
$max_items = $config['widgets']['rssmaxitems']; $max_items = $config['widgets']['rssmaxitems'];
}
if(is_numeric($config['widgets']['rsswidgetheight'])) if (is_numeric($config['widgets']['rsswidgetheight'])) {
$rsswidgetheight = $config['widgets']['rsswidgetheight']; $rsswidgetheight = $config['widgets']['rsswidgetheight'];
}
if(is_numeric($config['widgets']['rsswidgettextlength'])) if (is_numeric($config['widgets']['rsswidgettextlength'])) {
$rsswidgettextlength = $config['widgets']['rsswidgettextlength']; $rsswidgettextlength = $config['widgets']['rsswidgettextlength'];
}
// Set a default feed if none exists // Set a default feed if none exists
if(!$rss_feed_s) { if (!$rss_feed_s) {
$rss_feed_s = "https://opnsense.org/feed/"; $rss_feed_s = "https://opnsense.org/feed/";
$config['widgets']['rssfeed'] = "https://opnsense.org/feed/"; $config['widgets']['rssfeed'] = "https://opnsense.org/feed/";
} }
if(!$max_items) if (!$max_items) {
$max_items = 10; $max_items = 10;
}
if(!$rsswidgetheight)
$rsswidgetheight = 300;
if(!$rsswidgettextlength) if (!$rsswidgetheight) {
$rsswidgettextlength = 140; // oh twitter, how do we love thee? $rsswidgetheight = 300;
}
if($config['widgets']['rssfeed']) if (!$rsswidgettextlength) {
$textarea_txt = str_replace(",", "\n", $config['widgets']['rssfeed']); $rsswidgettextlength = 140; // oh twitter, how do we love thee?
else }
$textarea_txt = ""; if ($config['widgets']['rssfeed']) {
$textarea_txt = str_replace(",", "\n", $config['widgets']['rssfeed']);
} else {
$textarea_txt = "";
}
?> ?>
...@@ -94,9 +101,10 @@ else ...@@ -94,9 +101,10 @@ else
<select name='rssmaxitems' id='rssmaxitems'> <select name='rssmaxitems' id='rssmaxitems'>
<option value='<?= $max_items ?>'><?= $max_items ?></option> <option value='<?= $max_items ?>'><?= $max_items ?></option>
<?php <?php
for($x=100; $x<5100; $x=$x+100) for ($x=100; $x<5100; $x=$x+100) {
echo "<option value='{$x}'>{$x}</option>\n"; echo "<option value='{$x}'>{$x}</option>\n";
?> }
?>
</select> </select>
</td> </td>
</tr> </tr>
...@@ -108,9 +116,10 @@ else ...@@ -108,9 +116,10 @@ else
<select name='rsswidgetheight' id='rsswidgetheight'> <select name='rsswidgetheight' id='rsswidgetheight'>
<option value='<?= $rsswidgetheight ?>'><?= $rsswidgetheight ?>px</option> <option value='<?= $rsswidgetheight ?>'><?= $rsswidgetheight ?>px</option>
<?php <?php
for($x=100; $x<5100; $x=$x+100) for ($x=100; $x<5100; $x=$x+100) {
echo "<option value='{$x}'>{$x}px</option>\n"; echo "<option value='{$x}'>{$x}px</option>\n";
?> }
?>
</select> </select>
</td> </td>
</tr> </tr>
...@@ -122,9 +131,10 @@ else ...@@ -122,9 +131,10 @@ else
<select name='rsswidgettextlength' id='rsswidgettextlength'> <select name='rsswidgettextlength' id='rsswidgettextlength'>
<option value='<?= $rsswidgettextlength ?>'><?= $rsswidgettextlength ?></option> <option value='<?= $rsswidgettextlength ?>'><?= $rsswidgettextlength ?></option>
<?php <?php
for($x=10; $x<5100; $x=$x+10) for ($x=10; $x<5100; $x=$x+10) {
echo "<option value='{$x}'>{$x}</option>\n"; echo "<option value='{$x}'>{$x}</option>\n";
?> }
?>
</select> </select>
</td> </td>
</tr> </tr>
...@@ -139,38 +149,41 @@ else ...@@ -139,38 +149,41 @@ else
<div id="rss-widgets" style="padding: 5px; height: <?=$rsswidgetheight?>px; overflow:scroll;"> <div id="rss-widgets" style="padding: 5px; height: <?=$rsswidgetheight?>px; overflow:scroll;">
<?php <?php
if(!is_dir("/tmp/simplepie")) { if (!is_dir("/tmp/simplepie")) {
mkdir("/tmp/simplepie"); mkdir("/tmp/simplepie");
mkdir("/tmp/simplepie/cache"); mkdir("/tmp/simplepie/cache");
} }
exec("chmod a+rw /tmp/simplepie/."); exec("chmod a+rw /tmp/simplepie/.");
exec("chmod a+rw /tmp/simplepie/cache/."); exec("chmod a+rw /tmp/simplepie/cache/.");
require_once("simplepie/simplepie.inc"); require_once("simplepie/simplepie.inc");
function textLimit($string, $length, $replacer = '...') { function textLimit($string, $length, $replacer = '...')
if(strlen($string) > $length) {
return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer; if (strlen($string) > $length) {
return $string; return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
} }
$feed = new SimplePie(); return $string;
$feed->set_cache_location("/tmp/simplepie/"); }
$feed->set_feed_url($rss_feed_s); $feed = new SimplePie();
$feed->init(); $feed->set_cache_location("/tmp/simplepie/");
$feed->set_output_encoding('latin-1'); $feed->set_feed_url($rss_feed_s);
$feed->handle_content_type(); $feed->init();
$counter = 1; $feed->set_output_encoding('latin-1');
foreach($feed->get_items() as $item) { $feed->handle_content_type();
$feed = $item->get_feed(); $counter = 1;
$feed->strip_htmltags(); foreach ($feed->get_items() as $item) {
echo "<a target='blank' href='" . $item->get_permalink() . "'>" . $item->get_title() . "</a><br />"; $feed = $item->get_feed();
$content = $item->get_content(); $feed->strip_htmltags();
$content = strip_tags($content); echo "<a target='blank' href='" . $item->get_permalink() . "'>" . $item->get_title() . "</a><br />";
echo textLimit($content, $rsswidgettextlength) . "<br />"; $content = $item->get_content();
echo "Source: <a target='_blank' href='" . $item->get_permalink() . "'>".$feed->get_title()."</a><br />"; $content = strip_tags($content);
$counter++; echo textLimit($content, $rsswidgettextlength) . "<br />";
if($counter > $max_items) echo "Source: <a target='_blank' href='" . $item->get_permalink() . "'>".$feed->get_title()."</a><br />";
break; $counter++;
echo "<hr/>"; if ($counter > $max_items) {
} break;
}
echo "<hr/>";
}
?> ?>
</div> </div>
......
...@@ -39,10 +39,10 @@ require_once("widgets/include/services_status.inc"); ...@@ -39,10 +39,10 @@ require_once("widgets/include/services_status.inc");
$services = get_services(); $services = get_services();
if(isset($_POST['servicestatusfilter'])) { if (isset($_POST['servicestatusfilter'])) {
$config['widgets']['servicestatusfilter'] = htmlspecialchars($_POST['servicestatusfilter'], ENT_QUOTES | ENT_HTML401); $config['widgets']['servicestatusfilter'] = htmlspecialchars($_POST['servicestatusfilter'], ENT_QUOTES | ENT_HTML401);
write_config("Saved Service Status Filter via Dashboard"); write_config("Saved Service Status Filter via Dashboard");
header("Location: ../../index.php"); header("Location: ../../index.php");
} }
?> ?>
<input type="hidden" id="services_status-config" name="services_status-config" value="" /> <input type="hidden" id="services_status-config" name="services_status-config" value="" />
...@@ -65,25 +65,26 @@ if(isset($_POST['servicestatusfilter'])) { ...@@ -65,25 +65,26 @@ if(isset($_POST['servicestatusfilter'])) {
$skipservices = explode(",", $config['widgets']['servicestatusfilter']); $skipservices = explode(",", $config['widgets']['servicestatusfilter']);
if (count($services) > 0) { if (count($services) > 0) {
uasort($services, "service_name_compare"); uasort($services, "service_name_compare");
foreach($services as $service) { foreach ($services as $service) {
if(!$service['name'] || in_array($service['name'], $skipservices)) { if (!$service['name'] || in_array($service['name'], $skipservices)) {
continue; continue;
} }
$service_desc = explode(".",$service['description']); $service_desc = explode(".", $service['description']);
echo "<tr><td class=\"listlr\">" . $service['name'] . "</td>\n"; echo "<tr><td class=\"listlr\">" . $service['name'] . "</td>\n";
echo "<td class=\"listr\">" . $service_desc[0] . "</td>\n"; echo "<td class=\"listr\">" . $service_desc[0] . "</td>\n";
// if service is running then listr else listbg // if service is running then listr else listbg
$bgclass = null; $bgclass = null;
if (get_service_status($service)) if (get_service_status($service)) {
$bgclass = "listr"; $bgclass = "listr";
else } else {
$bgclass = "listbg"; $bgclass = "listbg";
echo "<td class=\"" . $bgclass . "\" align=\"center\">" . str_replace('btn ','btn btn-xs ', get_service_status_icon($service, false, true)) . "</td>\n"; }
echo "<td valign=\"middle\" class=\"list nowrap\">" . str_replace('btn ','btn btn-xs ', get_service_control_links($service)) . "</td></tr>\n"; echo "<td class=\"" . $bgclass . "\" align=\"center\">" . str_replace('btn ', 'btn btn-xs ', get_service_status_icon($service, false, true)) . "</td>\n";
} echo "<td valign=\"middle\" class=\"list nowrap\">" . str_replace('btn ', 'btn btn-xs ', get_service_control_links($service)) . "</td></tr>\n";
}
} else { } else {
echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . " . </td></tr>\n"; echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . " . </td></tr>\n";
} }
?> ?>
</table> </table>
......
...@@ -46,31 +46,33 @@ $devs = array(); ...@@ -46,31 +46,33 @@ $devs = array();
## Get all adX, daX, and adaX (IDE, SCSI, and AHCI) devices currently installed ## Get all adX, daX, and adaX (IDE, SCSI, and AHCI) devices currently installed
exec("ls /dev | grep '^\(ad\|da\|ada\)[0-9]\{1,2\}$'", $devs); ## From SMART status page exec("ls /dev | grep '^\(ad\|da\|ada\)[0-9]\{1,2\}$'", $devs); ## From SMART status page
if(count($devs) > 0) { if (count($devs) > 0) {
foreach($devs as $dev) { ## for each found drive do foreach ($devs as $dev) {
$dev_ident = exec("diskinfo -v /dev/$dev | grep ident | awk '{print $1}'"); ## get identifier from drive ## for each found drive do
$dev_state = trim(exec("smartctl -H /dev/$dev | awk -F: '/^SMART overall-health self-assessment test result/ {print $2;exit} $dev_ident = exec("diskinfo -v /dev/$dev | grep ident | awk '{print $1}'"); ## get identifier from drive
$dev_state = trim(exec("smartctl -H /dev/$dev | awk -F: '/^SMART overall-health self-assessment test result/ {print $2;exit}
/^SMART Health Status/ {print $2;exit}'")); ## get SMART state from drive /^SMART Health Status/ {print $2;exit}'")); ## get SMART state from drive
switch ($dev_state) { switch ($dev_state) {
case "PASSED": case "PASSED":
case "OK": case "OK":
$color = "#90EE90"; $color = "#90EE90";
break; break;
case "": case "":
$dev_state = "Unknown"; $dev_state = "Unknown";
$color = "#C0B788"; $color = "#C0B788";
break; break;
default: default:
$color = "#F08080"; $color = "#F08080";
break; break;
} }
?> ?>
<tr> <tr>
<td class="listlr"><?php echo $dev; ?></td> <td class="listlr"><?php echo $dev; ?></td>
<td class="listr" align="center"><?php echo $dev_ident; ?></td> <td class="listr" align="center"><?php echo $dev_ident; ?></td>
<td class="listr" align="center"><span style="background-color:<?php echo $color; ?>">&nbsp;<?php echo $dev_state; ?>&nbsp;</span></td> <td class="listr" align="center"><span style="background-color:<?php echo $color; ?>">&nbsp;<?php echo $dev_state; ?>&nbsp;</span></td>
</tr> </tr>
<?php } <?php
}
} }
?> ?>
</table> </table>
...@@ -37,35 +37,34 @@ require_once("script/load_phalcon.php"); ...@@ -37,35 +37,34 @@ require_once("script/load_phalcon.php");
$file_pkg_status="/tmp/pkg_status.json"; $file_pkg_status="/tmp/pkg_status.json";
if($_POST['action'] == 'pkg_update') { if ($_POST['action'] == 'pkg_update') {
/* Setup Shell variables */ /* Setup Shell variables */
$shell_output = array(); $shell_output = array();
$shell = new OPNsense\Core\Shell(); $shell = new OPNsense\Core\Shell();
// execute shell command and collect (only valid) info into named array // execute shell command and collect (only valid) info into named array
$shell->exec("/usr/local/opnsense/scripts/pkg_updatecheck.sh",false,false,$shell_output); $shell->exec("/usr/local/opnsense/scripts/pkg_updatecheck.sh", false, false, $shell_output);
} }
if (file_exists($file_pkg_status)) { if (file_exists($file_pkg_status)) {
$json = file_get_contents($file_pkg_status);
$json = file_get_contents($file_pkg_status); $pkg_status = json_decode($json, true);
$pkg_status = json_decode($json,true);
} }
if($_REQUEST['getupdatestatus']) { if ($_REQUEST['getupdatestatus']) {
if (file_exists($file_pkg_status)) { if (file_exists($file_pkg_status)) {
if ($pkg_status["connection"]=="error") { if ($pkg_status["connection"]=="error") {
echo "<span class='text-danger'>".gettext("Connection Error")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to retry now")."</span>"; echo "<span class='text-danger'>".gettext("Connection Error")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to retry now")."</span>";
} elseif ($pkg_status["repository"]=="error") { } elseif ($pkg_status["repository"]=="error") {
echo "<span class='text-danger'>".gettext("Repository Problem")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to retry now")."</span>"; echo "<span class='text-danger'>".gettext("Repository Problem")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to retry now")."</span>";
} elseif ($pkg_status["updates"]=="0") { } elseif ($pkg_status["updates"]=="0") {
echo "<span class='text-info'>".gettext("At")." <small>".$pkg_status["last_check"]."</small>".gettext(" no updates found.")."<br/><span class='btn-link' onclick='checkupdate()'>Click to check now</span>"; echo "<span class='text-info'>".gettext("At")." <small>".$pkg_status["last_check"]."</small>".gettext(" no updates found.")."<br/><span class='btn-link' onclick='checkupdate()'>Click to check now</span>";
} else { } else {
echo "<span class='text-danger'>".gettext("A total of ").$pkg_status["updates"].gettext(" update(s) are available.")."<br/><span class='text-info'><small>(When last checked at: ".$pkg_status["last_check"]." )</small></span>"."</span><br/><a href='/system_firmware_check.php'>".gettext("Click to upgrade")."</a> | <span class='btn-link' onclick='checkupdate()'>Re-check now</span>"; echo "<span class='text-danger'>".gettext("A total of ").$pkg_status["updates"].gettext(" update(s) are available.")."<br/><span class='text-info'><small>(When last checked at: ".$pkg_status["last_check"]." )</small></span>"."</span><br/><a href='/system_firmware_check.php'>".gettext("Click to upgrade")."</a> | <span class='btn-link' onclick='checkupdate()'>Re-check now</span>";
} }
} else { } else {
echo "<span class='text-danger'>".gettext("Unknown")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to check now")."</span>"; echo "<span class='text-danger'>".gettext("Unknown")."</span><br/><span class='btn-link' onclick='checkupdate()'>".gettext("Click to check now")."</span>";
} }
exit; exit;
} }
$curcfg = $config['system']['firmware']; $curcfg = $config['system']['firmware'];
...@@ -82,16 +81,22 @@ $filesystems = get_mounted_filesystems(); ...@@ -82,16 +81,22 @@ $filesystems = get_mounted_filesystems();
jQuery("#memUsagePB").css( { width: '<?php echo mem_usage(); ?>%' } ); jQuery("#memUsagePB").css( { width: '<?php echo mem_usage(); ?>%' } );
<?PHP $d = 0; ?> <?PHP $d = 0; ?>
<?PHP foreach ($filesystems as $fs): ?> <?PHP foreach ($filesystems as $fs) :
?>
jQuery("#diskUsagePB<?php echo $d++; ?>").css( { width: '<?php echo $fs['percent_used']; ?>%' } ); jQuery("#diskUsagePB<?php echo $d++; ?>").css( { width: '<?php echo $fs['percent_used']; ?>%' } );
<?PHP endforeach; ?> <?PHP
endforeach; ?>
<?php if($showswap == true): ?> <?php if ($showswap == true) :
?>
jQuery("#swapUsagePB").css( { width: '<?php echo swap_usage(); ?>%' } ); jQuery("#swapUsagePB").css( { width: '<?php echo swap_usage(); ?>%' } );
<?php endif; ?> <?php
<?php if (get_temp() != ""): ?> endif; ?>
<?php if (get_temp() != "") :
?>
jQuery("#tempPB").css( { width: '<?php echo get_temp(); ?>%' } ); jQuery("#tempPB").css( { width: '<?php echo get_temp(); ?>%' } );
<?php endif; ?> <?php
endif; ?>
}); });
//]]> //]]>
</script> </script>
...@@ -106,15 +111,16 @@ $filesystems = get_mounted_filesystems(); ...@@ -106,15 +111,16 @@ $filesystems = get_mounted_filesystems();
<td width="25%" valign="top" class="vncellt"><?=gettext("Versions");?></td> <td width="25%" valign="top" class="vncellt"><?=gettext("Versions");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
<?php <?php
$pkgver = explode('-', trim(file_get_contents('/usr/local/opnsense/version/opnsense'))); $pkgver = explode('-', trim(file_get_contents('/usr/local/opnsense/version/opnsense')));
echo sprintf('%s %s-%s', $g['product_name'], $pkgver[0], php_uname('m')); echo sprintf('%s %s-%s', $g['product_name'], $pkgver[0], php_uname('m'));
?> ?>
<br /><?php echo php_uname('s') . ' ' . php_uname('r'); ?> <br /><?php echo php_uname('s') . ' ' . php_uname('r'); ?>
<br /><?php echo exec('/usr/local/bin/openssl version'); ?> <br /><?php echo exec('/usr/local/bin/openssl version'); ?>
</td> </td>
</tr> </tr>
<?php if(!isset($config['system']['firmware']['disablecheck'])): ?> <?php if (!isset($config['system']['firmware']['disablecheck'])) :
?>
<tr> <tr>
<td> <td>
Updates Updates
...@@ -123,27 +129,32 @@ $filesystems = get_mounted_filesystems(); ...@@ -123,27 +129,32 @@ $filesystems = get_mounted_filesystems();
<div id='updatestatus'><span class="text-info">Fetching status</span></div> <div id='updatestatus'><span class="text-info">Fetching status</span></div>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php
endif; ?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("CPU Type");?></td> <td width="25%" class="vncellt"><?=gettext("CPU Type");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
<?php <?php
echo (htmlspecialchars(get_single_sysctl("hw.model"))); echo (htmlspecialchars(get_single_sysctl("hw.model")));
?> ?>
<div id="cpufreq"><?= get_cpufreq(); ?></div> <div id="cpufreq"><?= get_cpufreq(); ?></div>
<?php $cpucount = get_cpu_count(); <?php $cpucount = get_cpu_count();
if ($cpucount > 1): ?> if ($cpucount > 1) :
?>
<div id="cpucount"> <div id="cpucount">
<?= htmlspecialchars($cpucount) ?> CPUs: <?= htmlspecialchars(get_cpu_count(true)); ?></div> <?= htmlspecialchars($cpucount) ?> CPUs: <?= htmlspecialchars(get_cpu_count(true)); ?></div>
<?php endif; ?> <?php
endif; ?>
</td> </td>
</tr> </tr>
<?php if ($hwcrypto): ?> <?php if ($hwcrypto) :
?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("Hardware crypto");?></td> <td width="25%" class="vncellt"><?=gettext("Hardware crypto");?></td>
<td width="75%" class="listr"><?=htmlspecialchars($hwcrypto);?></td> <td width="75%" class="listr"><?=htmlspecialchars($hwcrypto);?></td>
</tr> </tr>
<?php endif; ?> <?php
endif; ?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("Uptime");?></td> <td width="25%" class="vncellt"><?=gettext("Uptime");?></td>
<td width="75%" class="listr" id="uptime"><?= htmlspecialchars(get_uptime()); ?></td> <td width="75%" class="listr" id="uptime"><?= htmlspecialchars(get_uptime()); ?></td>
...@@ -158,32 +169,35 @@ $filesystems = get_mounted_filesystems(); ...@@ -158,32 +169,35 @@ $filesystems = get_mounted_filesystems();
<td width="30%" class="vncellt"><?=gettext("DNS server(s)");?></td> <td width="30%" class="vncellt"><?=gettext("DNS server(s)");?></td>
<td width="70%" class="listr"> <td width="70%" class="listr">
<?php <?php
$dns_servers = get_dns_servers(); $dns_servers = get_dns_servers();
foreach($dns_servers as $dns) { foreach ($dns_servers as $dns) {
echo "{$dns}<br />"; echo "{$dns}<br />";
} }
?> ?>
</td> </td>
</tr> </tr>
<?php if ($config['revision']): ?> <?php if ($config['revision']) :
?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("Last config change");?></td> <td width="25%" class="vncellt"><?=gettext("Last config change");?></td>
<td width="75%" class="listr"><?= htmlspecialchars(date("D M j G:i:s T Y", intval($config['revision']['time'])));?></td> <td width="75%" class="listr"><?= htmlspecialchars(date("D M j G:i:s T Y", intval($config['revision']['time'])));?></td>
</tr> </tr>
<?php endif; ?> <?php
endif; ?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("State table size");?></td> <td width="25%" class="vncellt"><?=gettext("State table size");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
<?php $pfstatetext = get_pfstate(); <?php $pfstatetext = get_pfstate();
$pfstateusage = get_pfstate(true); $pfstateusage = get_pfstate(true);
?> ?>
<div class="progress"> <div class="progress">
<div id="statePB" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"> <div id="statePB" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
<span class="sr-only"></span> <span class="sr-only"></span>
</div> </div>
</div> </div>
<span id="pfstateusagemeter"><?= $pfstateusage.'%'; ?></span> (<span id="pfstate"><?= htmlspecialchars($pfstatetext); ?></span>) <span id="pfstateusagemeter"><?= $pfstateusage.'%';
?></span> (<span id="pfstate"><?= htmlspecialchars($pfstatetext); ?></span>)
<br /> <br />
<a href="diag_dump_states.php"><?=gettext("Show states");?></a> <a href="diag_dump_states.php"><?=gettext("Show states");?></a>
</td> </td>
...@@ -192,9 +206,9 @@ $filesystems = get_mounted_filesystems(); ...@@ -192,9 +206,9 @@ $filesystems = get_mounted_filesystems();
<td width="25%" class="vncellt"><?=gettext("MBUF Usage");?></td> <td width="25%" class="vncellt"><?=gettext("MBUF Usage");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
<?php <?php
$mbufstext = get_mbuf(); $mbufstext = get_mbuf();
$mbufusage = get_mbuf(true); $mbufusage = get_mbuf(true);
?> ?>
<div class="progress"> <div class="progress">
<div id="mbufPB" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"> <div id="mbufPB" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
...@@ -204,7 +218,8 @@ $filesystems = get_mounted_filesystems(); ...@@ -204,7 +218,8 @@ $filesystems = get_mounted_filesystems();
<span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<span id="mbuf"><?= $mbufstext ?></span>) <span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<span id="mbuf"><?= $mbufstext ?></span>)
</td> </td>
</tr> </tr>
<?php if (get_temp() != ""): ?> <?php if (get_temp() != "") :
?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("Temperature");?></td> <td width="25%" class="vncellt"><?=gettext("Temperature");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
...@@ -218,7 +233,8 @@ $filesystems = get_mounted_filesystems(); ...@@ -218,7 +233,8 @@ $filesystems = get_mounted_filesystems();
<span id="tempmeter"><?= $temp."&#176;C"; ?></span> <span id="tempmeter"><?= $temp."&#176;C"; ?></span>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php
endif; ?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("Load average");?></td> <td width="25%" class="vncellt"><?=gettext("Load average");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
...@@ -246,10 +262,11 @@ $filesystems = get_mounted_filesystems(); ...@@ -246,10 +262,11 @@ $filesystems = get_mounted_filesystems();
<span class="sr-only"></span> <span class="sr-only"></span>
</div> </div>
</div> </div>
<span id="memusagemeter"><?= $memUsage.'%'; ?></span> used <?= sprintf("%.0f/%.0f", $memUsage/100.0 * get_single_sysctl('hw.physmem') / (1024*1024) ,get_single_sysctl('hw.physmem') / (1024*1024)) ?> MB <span id="memusagemeter"><?= $memUsage.'%'; ?></span> used <?= sprintf("%.0f/%.0f", $memUsage/100.0 * get_single_sysctl('hw.physmem') / (1024*1024), get_single_sysctl('hw.physmem') / (1024*1024)) ?> MB
</td> </td>
</tr> </tr>
<?php if($showswap == true): ?> <?php if ($showswap == true) :
?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("SWAP usage");?></td> <td width="25%" class="vncellt"><?=gettext("SWAP usage");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
...@@ -259,24 +276,29 @@ $filesystems = get_mounted_filesystems(); ...@@ -259,24 +276,29 @@ $filesystems = get_mounted_filesystems();
<span class="sr-only"></span> <span class="sr-only"></span>
</div> </div>
</div> </div>
<span id="swapusagemeter"><?= $swapusage.'%'; ?></span> used <?= sprintf("%.0f/%.0f",`/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $3;}'`, `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $2;}'`) ?> MB <span id="swapusagemeter"><?= $swapusage.'%'; ?></span> used <?= sprintf("%.0f/%.0f", `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $3;}'`, `/usr/sbin/swapinfo -m | /usr/bin/grep -v Device | /usr/bin/awk '{ print $2;}'`) ?> MB
</td> </td>
</tr> </tr>
<?php endif; ?> <?php
endif; ?>
<tr> <tr>
<td width="25%" class="vncellt"><?=gettext("Disk usage");?></td> <td width="25%" class="vncellt"><?=gettext("Disk usage");?></td>
<td width="75%" class="listr"> <td width="75%" class="listr">
<?PHP $d = 0; ?> <?PHP $d = 0; ?>
<?PHP foreach ($filesystems as $fs): ?> <?PHP foreach ($filesystems as $fs) :
?>
<div class="progress"> <div class="progress">
<div id="diskUsagePB<?php echo $d; ?>" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"> <div id="diskUsagePB<?php echo $d; ?>" class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
<span class="sr-only"></span> <span class="sr-only"></span>
</div> </div>
</div> </div>
<?PHP if (substr(basename($fs['device']), 0, 2) == "md") $fs['type'] .= " in RAM"; ?> <?PHP if (substr(basename($fs['device']), 0, 2) == "md") {
$fs['type'] .= " in RAM";
} ?>
<?PHP echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> used <?PHP echo $fs['used_size'] ."/". $fs['total_size'];?> <?PHP echo "{$fs['mountpoint']} ({$fs['type']})";?>: <span id="diskusagemeter<?php echo $d++ ?>"><?= $fs['percent_used'].'%'; ?></span> used <?PHP echo $fs['used_size'] ."/". $fs['total_size'];?>
<br /> <br />
<?PHP endforeach; ?> <?PHP
endforeach; ?>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -300,7 +322,8 @@ $filesystems = get_mounted_filesystems(); ...@@ -300,7 +322,8 @@ $filesystems = get_mounted_filesystems();
getstatus(); getstatus();
} }
<?php if(!isset($config['system']['firmware']['disablecheck'])): ?> <?php if (!isset($config['system']['firmware']['disablecheck'])) :
?>
function getstatus() { function getstatus() {
scroll(0,0); scroll(0,0);
var url = "/widgets/widgets/system_information.widget.php"; var url = "/widgets/widgets/system_information.widget.php";
...@@ -318,6 +341,7 @@ $filesystems = get_mounted_filesystems(); ...@@ -318,6 +341,7 @@ $filesystems = get_mounted_filesystems();
// to avoid this we set the innerHTML property // to avoid this we set the innerHTML property
jQuery('#updatestatus').prop('innerHTML',transport.responseText); jQuery('#updatestatus').prop('innerHTML',transport.responseText);
} }
<?php endif; ?> <?php
endif; ?>
//]]> //]]>
</script> </script>
...@@ -62,44 +62,45 @@ const MAX_THRESHOLD_VALUE = 100; //deg C ...@@ -62,44 +62,45 @@ const MAX_THRESHOLD_VALUE = 100; //deg C
//========================================================================= //=========================================================================
//save widget config settings on POST //save widget config settings on POST
if ($_POST) { if ($_POST) {
saveThresholdSettings($config, $_POST, "thermal_sensors_widget_zone_warning_threshold", "thermal_sensors_widget_zone_critical_threshold"); saveThresholdSettings($config, $_POST, "thermal_sensors_widget_zone_warning_threshold", "thermal_sensors_widget_zone_critical_threshold");
saveThresholdSettings($config, $_POST, "thermal_sensors_widget_core_warning_threshold", "thermal_sensors_widget_core_critical_threshold"); saveThresholdSettings($config, $_POST, "thermal_sensors_widget_core_warning_threshold", "thermal_sensors_widget_core_critical_threshold");
//handle checkboxes separately //handle checkboxes separately
saveGraphDisplaySettings($config, $_POST, "thermal_sensors_widget_show_raw_output"); saveGraphDisplaySettings($config, $_POST, "thermal_sensors_widget_show_raw_output");
saveGraphDisplaySettings($config, $_POST, "thermal_sensors_widget_show_full_sensor_name"); saveGraphDisplaySettings($config, $_POST, "thermal_sensors_widget_show_full_sensor_name");
saveGraphDisplaySettings($config, $_POST, "thermal_sensors_widget_pulsate_warning"); saveGraphDisplaySettings($config, $_POST, "thermal_sensors_widget_pulsate_warning");
saveGraphDisplaySettings($config, $_POST, "thermal_sensors_widget_pulsate_critical"); saveGraphDisplaySettings($config, $_POST, "thermal_sensors_widget_pulsate_critical");
//write settings to config file //write settings to config file
write_config("Saved thermal_sensors_widget settings via Dashboard."); write_config("Saved thermal_sensors_widget settings via Dashboard.");
header("Location: ../../index.php"); header("Location: ../../index.php");
} }
function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $criticalValueKey) { function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $criticalValueKey)
$warningValue = 0; {
$criticalValue = 0; $warningValue = 0;
$criticalValue = 0;
if (isset($postArray[$warningValueKey])) {
$warningValue = (int) $postArray[$warningValueKey]; if (isset($postArray[$warningValueKey])) {
} $warningValue = (int) $postArray[$warningValueKey];
}
if (isset($postArray[$criticalValueKey])) {
$criticalValue = (int) $postArray[$criticalValueKey]; if (isset($postArray[$criticalValueKey])) {
} $criticalValue = (int) $postArray[$criticalValueKey];
}
if (
($warningValue >= MIN_THRESHOLD_VALUE && $warningValue <= MAX_THRESHOLD_VALUE) && if (($warningValue >= MIN_THRESHOLD_VALUE && $warningValue <= MAX_THRESHOLD_VALUE) &&
($criticalValue >= MIN_THRESHOLD_VALUE && $criticalValue <= MAX_THRESHOLD_VALUE) && ($criticalValue >= MIN_THRESHOLD_VALUE && $criticalValue <= MAX_THRESHOLD_VALUE) &&
($warningValue < $criticalValue) ($warningValue < $criticalValue)
) { ) {
//all validated ok, save to config array //all validated ok, save to config array
$configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$warningValueKey] = $warningValue; $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$warningValueKey] = $warningValue;
$configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$criticalValueKey] = $criticalValue; $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$criticalValueKey] = $criticalValue;
} }
} }
function saveGraphDisplaySettings(&$configArray, &$postArray, $valueKey) { function saveGraphDisplaySettings(&$configArray, &$postArray, $valueKey)
{
$configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey] = isset($postArray[$valueKey]) ? 1 : 0; $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey] = isset($postArray[$valueKey]) ? 1 : 0;
} }
...@@ -116,32 +117,34 @@ $thermal_sensors_widget_showFullSensorName = getBoolValueFromConfig($config, "th ...@@ -116,32 +117,34 @@ $thermal_sensors_widget_showFullSensorName = getBoolValueFromConfig($config, "th
$thermal_sensors_widget_pulsateWarning = getBoolValueFromConfig($config, "thermal_sensors_widget_pulsate_warning", true); $thermal_sensors_widget_pulsateWarning = getBoolValueFromConfig($config, "thermal_sensors_widget_pulsate_warning", true);
$thermal_sensors_widget_pulsateCritical = getBoolValueFromConfig($config, "thermal_sensors_widget_pulsate_critical", true); $thermal_sensors_widget_pulsateCritical = getBoolValueFromConfig($config, "thermal_sensors_widget_pulsate_critical", true);
function getThresholdValueFromConfig(&$configArray, $valueKey, $defaultValue) { function getThresholdValueFromConfig(&$configArray, $valueKey, $defaultValue)
{
$thresholdValue = $defaultValue; $thresholdValue = $defaultValue;
if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey])) { if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey])) {
$thresholdValue = (int) $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey]; $thresholdValue = (int) $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey];
} }
if ($thresholdValue < MIN_THRESHOLD_VALUE || $thresholdValue > MAX_THRESHOLD_VALUE) { if ($thresholdValue < MIN_THRESHOLD_VALUE || $thresholdValue > MAX_THRESHOLD_VALUE) {
//set to default if not in allowed range //set to default if not in allowed range
$thresholdValue = $defaultValue; $thresholdValue = $defaultValue;
} }
return $thresholdValue; return $thresholdValue;
} }
function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) { function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue)
{
$boolValue = false; $boolValue = false;
if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey])) { if (isset($configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey])) {
$boolValue = (bool) $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey]; $boolValue = (bool) $configArray[WIDGETS_CONFIG_SECTION_KEY][THERMAL_SENSORS_WIDGET_SUBSECTION_KEY][$valueKey];
} else { } else {
//set to default if not in allowed range //set to default if not in allowed range
$boolValue = $defaultValue; $boolValue = $defaultValue;
} }
return $boolValue; return $boolValue;
} }
//========================================================================= //=========================================================================
...@@ -196,7 +199,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) { ...@@ -196,7 +199,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
<input type="checkbox" <input type="checkbox"
id="thermal_sensors_widget_show_raw_output" id="thermal_sensors_widget_show_raw_output"
name="thermal_sensors_widget_show_raw_output" name="thermal_sensors_widget_show_raw_output"
value="<?= $thermal_sensors_widget_showRawOutput; ?>" <?= ($thermal_sensors_widget_showRawOutput) ? " checked='checked'" : ""; ?> /> value="<?= $thermal_sensors_widget_showRawOutput;
?>" <?= ($thermal_sensors_widget_showRawOutput) ? " checked='checked'" : ""; ?> />
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -214,7 +218,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) { ...@@ -214,7 +218,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
<input type="checkbox" <input type="checkbox"
id="thermal_sensors_widget_show_full_sensor_name" id="thermal_sensors_widget_show_full_sensor_name"
name="thermal_sensors_widget_show_full_sensor_name" name="thermal_sensors_widget_show_full_sensor_name"
value="<?= $thermal_sensors_widget_showFullSensorName; ?>" <?= ($thermal_sensors_widget_showFullSensorName) ? " checked='checked'" : ""; ?> /> value="<?= $thermal_sensors_widget_showFullSensorName;
?>" <?= ($thermal_sensors_widget_showFullSensorName) ? " checked='checked'" : ""; ?> />
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -232,7 +237,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) { ...@@ -232,7 +237,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
<input type="checkbox" <input type="checkbox"
id="thermal_sensors_widget_pulsate_warning" id="thermal_sensors_widget_pulsate_warning"
name="thermal_sensors_widget_pulsate_warning" name="thermal_sensors_widget_pulsate_warning"
value="<?= $thermal_sensors_widget_pulsateWarning; ?>" <?= ($thermal_sensors_widget_pulsateWarning) ? " checked='checked'" : ""; ?> /> value="<?= $thermal_sensors_widget_pulsateWarning;
?>" <?= ($thermal_sensors_widget_pulsateWarning) ? " checked='checked'" : ""; ?> />
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -250,7 +256,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) { ...@@ -250,7 +256,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
<input type="checkbox" <input type="checkbox"
id="thermal_sensors_widget_pulsate_critical" id="thermal_sensors_widget_pulsate_critical"
name="thermal_sensors_widget_pulsate_critical" name="thermal_sensors_widget_pulsate_critical"
value="<?= $thermal_sensors_widget_pulsateCritical; ?>" <?= ($thermal_sensors_widget_pulsateCritical) ? " checked='checked'" : ""; ?> /> value="<?= $thermal_sensors_widget_pulsateCritical;
?>" <?= ($thermal_sensors_widget_pulsateCritical) ? " checked='checked'" : ""; ?> />
</td> </td>
</tr> </tr>
<tr> <tr>
......
...@@ -38,55 +38,55 @@ require_once("functions.inc"); ...@@ -38,55 +38,55 @@ require_once("functions.inc");
$first_time = false; $first_time = false;
if (!is_array($config["widgets"]["trafficgraphs"])) { if (!is_array($config["widgets"]["trafficgraphs"])) {
$first_time = true; $first_time = true;
$config["widgets"]["trafficgraphs"] = array(); $config["widgets"]["trafficgraphs"] = array();
} }
$a_config = &$config["widgets"]["trafficgraphs"]; $a_config = &$config["widgets"]["trafficgraphs"];
if (!is_array($a_config["shown"])) { if (!is_array($a_config["shown"])) {
$a_config["shown"] = array(); $a_config["shown"] = array();
} }
if (!is_array($a_config["shown"]["item"])) { if (!is_array($a_config["shown"]["item"])) {
$a_config["shown"]["item"] = array(); $a_config["shown"]["item"] = array();
} }
$ifdescrs = get_configured_interface_with_descr(); $ifdescrs = get_configured_interface_with_descr();
if (isset($config['ipsec']['enable'])) if (isset($config['ipsec']['enable'])) {
$ifdescrs['enc0'] = "IPsec"; $ifdescrs['enc0'] = "IPsec";
}
if ($_POST) { if ($_POST) {
if (isset($_POST["refreshinterval"])) {
if (isset($_POST["refreshinterval"])) { $a_config["refreshinterval"] = $_POST["refreshinterval"];
$a_config["refreshinterval"] = $_POST["refreshinterval"]; }
} if (isset($_POST["scale_type"])) {
if (isset($_POST["scale_type"])) { $a_config["scale_type"] = $_POST["scale_type"];
$a_config["scale_type"] = $_POST["scale_type"]; }
} $a_config["shown"]["item"] = array();
$a_config["shown"]["item"] = array(); foreach ($ifdescrs as $ifname => $ifdescr) {
foreach ($ifdescrs as $ifname => $ifdescr) { $state = $_POST["shown"][$ifname];
$state = $_POST["shown"][$ifname]; if ($state === "show") {
if ($state === "show") { $a_config["shown"]["item"][] = $ifname;
$a_config["shown"]["item"][] = $ifname; }
} }
} write_config("Updated traffic graph settings via dashboard.");
write_config("Updated traffic graph settings via dashboard."); header("Location: /");
header("Location: /"); exit(0);
exit(0);
} }
$shown = array(); $shown = array();
foreach ($a_config["shown"]["item"] as $if) { foreach ($a_config["shown"]["item"] as $if) {
$shown[$if] = true; $shown[$if] = true;
} }
if ($first_time) { if ($first_time) {
$keys = array_keys($ifdescrs); $keys = array_keys($ifdescrs);
$shown[$keys[0]] = true; $shown[$keys[0]] = true;
} }
if (isset($a_config["refreshinterval"])) { if (isset($a_config["refreshinterval"])) {
$refreshinterval = $a_config["refreshinterval"]; $refreshinterval = $a_config["refreshinterval"];
} else { } else {
$refreshinterval = 10; $refreshinterval = 10;
} }
if (isset($a_config["scale_type"])) { if (isset($a_config["scale_type"])) {
...@@ -100,9 +100,11 @@ if (isset($a_config["scale_type"])) { ...@@ -100,9 +100,11 @@ if (isset($a_config["scale_type"])) {
<div id="traffic_graphs-settings" class="widgetconfigdiv" style="display:none;"> <div id="traffic_graphs-settings" class="widgetconfigdiv" style="display:none;">
<form action="/widgets/widgets/traffic_graphs.widget.php" method="post" name="iform" id="iform"> <form action="/widgets/widgets/traffic_graphs.widget.php" method="post" name="iform" id="iform">
<?php foreach ($ifdescrs as $ifname => $ifdescr) { ?> <?php foreach ($ifdescrs as $ifname => $ifdescr) {
?>
<input type="hidden" name="shown[<?= $ifname ?>]" value="<?= $shown[$ifname] ? "show" : "hide" ?>" /> <input type="hidden" name="shown[<?= $ifname ?>]" value="<?= $shown[$ifname] ? "show" : "hide" ?>" />
<?php } ?> <?php
} ?>
<table class="table table-striped"> <table class="table table-striped">
<tbody> <tbody>
...@@ -113,20 +115,19 @@ if (isset($a_config["scale_type"])) { ...@@ -113,20 +115,19 @@ if (isset($a_config["scale_type"])) {
</td> </td>
</tr> </tr>
<?php <?php
$scale_type_up="checked=\"checked\""; $scale_type_up="checked=\"checked\"";
$scale_type_follow=""; $scale_type_follow="";
if (isset($config["widgets"]["trafficgraphs"]["scale_type"])) { if (isset($config["widgets"]["trafficgraphs"]["scale_type"])) {
$selected_radio = $config["widgets"]["trafficgraphs"]["scale_type"]; $selected_radio = $config["widgets"]["trafficgraphs"]["scale_type"];
if ($selected_radio == "up") { if ($selected_radio == "up") {
$scale_type_up = "checked=\"checked\""; $scale_type_up = "checked=\"checked\"";
$scale_type_follow=""; $scale_type_follow="";
} } elseif ($selected_radio == "follow") {
else if ($selected_radio == "follow") { $scale_type_up="";
$scale_type_up=""; $scale_type_follow = "checked=\"checked\"";
$scale_type_follow = "checked=\"checked\""; }
} }
} ?>
?>
<tr> <tr>
<td> <td>
<input name="scale_type" type="radio" id="scale_type_up" value="up" <?php echo $scale_type_up; ?> /> <?php echo gettext('Scale up')?> <input name="scale_type" type="radio" id="scale_type_up" value="up" <?php echo $scale_type_up; ?> /> <?php echo gettext('Scale up')?>
...@@ -137,9 +138,13 @@ if (isset($a_config["scale_type"])) { ...@@ -137,9 +138,13 @@ if (isset($a_config["scale_type"])) {
<input name="scale_type" type="radio" id="scale_type_follow" value="follow" <?php echo $scale_type_follow; ?> /> <?php echo gettext('Scale follow')?><br /><br /> <input name="scale_type" type="radio" id="scale_type_follow" value="follow" <?php echo $scale_type_follow; ?> /> <?php echo gettext('Scale follow')?><br /><br />
Refresh Interval: Refresh Interval:
<select name="refreshinterval" class="formfld" id="refreshinterval" > <select name="refreshinterval" class="formfld" id="refreshinterval" >
<?php for ($i = 1; $i <= 10; $i += 1) { ?> <?php for ($i = 1; $i <= 10; $i += 1) {
<option value="<?= $i ?>" <?php if ($refreshinterval == $i) echo "selected=\"selected\"";?>><?= $i ?></option> ?>
<?php } ?> <option value="<?= $i ?>" <?php if ($refreshinterval == $i) {
echo "selected=\"selected\"";
}?>><?= $i ?></option>
<?php
} ?>
</select>&nbsp; Seconds<br />&nbsp; &nbsp; &nbsp; <b>Note:</b> changing this setting will increase CPU utilization<br /><br /> </select>&nbsp; Seconds<br />&nbsp; &nbsp; &nbsp; <b>Note:</b> changing this setting will increase CPU utilization<br /><br />
</td> </td>
</tr> </tr>
...@@ -164,40 +169,47 @@ if (isset($a_config["scale_type"])) { ...@@ -164,40 +169,47 @@ if (isset($a_config["scale_type"])) {
<?php <?php
foreach ($ifdescrs as $ifname => $ifdescr) { foreach ($ifdescrs as $ifname => $ifdescr) {
$ifinfo = get_interface_info($ifname); $ifinfo = get_interface_info($ifname);
if ($shown[$ifname]) { if ($shown[$ifname]) {
$mingraphbutton = "inline"; $mingraphbutton = "inline";
$showgraphbutton = "none"; $showgraphbutton = "none";
$graphdisplay = "inline"; $graphdisplay = "inline";
$interfacevalue = "show"; $interfacevalue = "show";
} else { } else {
$mingraphbutton = "none"; $mingraphbutton = "none";
$showgraphbutton = "inline"; $showgraphbutton = "inline";
$graphdisplay = "none"; $graphdisplay = "none";
$interfacevalue = "hide"; $interfacevalue = "hide";
} }
if ($ifinfo['status'] != "down") { ?> if ($ifinfo['status'] != "down") {
?>
<div id="<?=$ifname;?>trafficdiv" style="padding: 5px"> <div id="<?=$ifname;?>trafficdiv" style="padding: 5px">
<div id="<?=$ifname;?>topic" class="widgetsubheader"> <div id="<?=$ifname;?>topic" class="widgetsubheader">
<div style="float:left;width:49%"> <div style="float:left;width:49%">
<span onclick="location.href='/status_graph.php?if=<?=$ifname;?>'" style="cursor:pointer">Current <?=$ifdescr;?> Traffic</span> <span onclick="location.href='/status_graph.php?if=<?=$ifname;
?>'" style="cursor:pointer">Current <?=$ifdescr;?> Traffic</span>
</div> </div>
<div align="right" style="float:right;width:49%"> <div align="right" style="float:right;width:49%">
<div id="<?=$ifname;?>graphdiv-min" onclick='return trafficminimizeDiv("<?= $ifname ?>", true);' <div id="<?=$ifname;?>graphdiv-min" onclick='return trafficminimizeDiv("<?= $ifname ?>", true);'
style="display:<?php echo $mingraphbutton;?>; cursor:pointer" ><span class="glyphicon glyphicon-minus" alt="Minimize <?=$ifname;?> traffic graph" /></span></div> style="display:<?php echo $mingraphbutton;
?>; cursor:pointer" ><span class="glyphicon glyphicon-minus" alt="Minimize <?=$ifname;?> traffic graph" /></span></div>
<div id="<?=$ifname;?>graphdiv-open" onclick='return trafficshowDiv("<?= $ifname ?>", true);' <div id="<?=$ifname;?>graphdiv-open" onclick='return trafficshowDiv("<?= $ifname ?>", true);'
style="display:<?php echo $showgraphbutton;?>; cursor:pointer" ><span class="glyphicon glyphicon-plus" alt="Show <?=$ifname;?> traffic graph" /></span></div> style="display:<?php echo $showgraphbutton;
?>; cursor:pointer" ><span class="glyphicon glyphicon-plus" alt="Show <?=$ifname;?> traffic graph" /></span></div>
</div> </div>
<div style="clear:both;"></div> <div style="clear:both;"></div>
</div> </div>
<div id="<?=$ifname;?>graphdiv" style="display:<?php echo $graphdisplay;?>"> <div id="<?=$ifname;?>graphdiv" style="display:<?php echo $graphdisplay;?>">
<object data="graph.php?ifnum=<?=$ifname;?>&amp;ifname=<?=rawurlencode($ifdescr);?>&amp;timeint=<?=$refreshinterval;?>&amp;initdelay=<?=($graphcounter+1) * 2;?>" height="100%" width="100%"> <object data="graph.php?ifnum=<?=$ifname;
?>&amp;ifname=<?=rawurlencode($ifdescr);
?>&amp;timeint=<?=$refreshinterval;
?>&amp;initdelay=<?=($graphcounter+1) * 2;?>" height="100%" width="100%">
<param name="id" value="graph" /> <param name="id" value="graph" />
<param name="type" value="image/svg+xml" /> <param name="type" value="image/svg+xml" />
<param name="pluginspage" value="http://www.adobe.com/svg/viewer/install/auto" /> <param name="pluginspage" value="http://www.adobe.com/svg/viewer/install/auto" />
</object> </object>
</div> </div>
</div> </div>
<?php } <?php
}
} }
?>
...@@ -31,47 +31,48 @@ $nocsrf = true; ...@@ -31,47 +31,48 @@ $nocsrf = true;
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("widgets/include/wake_on_lan.inc"); require_once("widgets/include/wake_on_lan.inc");
if (is_array($config['wol']['wolentry'])) if (is_array($config['wol']['wolentry'])) {
$wolcomputers = $config['wol']['wolentry']; $wolcomputers = $config['wol']['wolentry'];
else } else {
$wolcomputers = array(); $wolcomputers = array();
}
?> ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="wol status"> <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="wol status">
<tr> <tr>
<?php <?php
echo '<td class="widgetsubheader" align="center">' . gettext("Computer / Device") . '</td>'; echo '<td class="widgetsubheader" align="center">' . gettext("Computer / Device") . '</td>';
echo '<td class="widgetsubheader" align="center">' . gettext("Interface") . '</td>'; echo '<td class="widgetsubheader" align="center">' . gettext("Interface") . '</td>';
echo '<td class="widgetsubheader" align="center">' . gettext("Status") . '</td>'; echo '<td class="widgetsubheader" align="center">' . gettext("Status") . '</td>';
?> ?>
<td class="widgetsubheader">&nbsp;</td> <td class="widgetsubheader">&nbsp;</td>
</tr> </tr>
<?php <?php
if (count($wolcomputers) > 0) { if (count($wolcomputers) > 0) {
foreach($wolcomputers as $wolent) { foreach ($wolcomputers as $wolent) {
echo '<tr><td class="listlr">' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n"; echo '<tr><td class="listlr">' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n";
echo '<td class="listr">' . convert_friendly_interface_to_friendly_descr($wolent['interface']) . '</td>' . "\n"; echo '<td class="listr">' . convert_friendly_interface_to_friendly_descr($wolent['interface']) . '</td>' . "\n";
$is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'"); $is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'");
if($is_active == 1) { if ($is_active == 1) {
echo '<td class="listr" align="center">' . "\n"; echo '<td class="listr" align="center">' . "\n";
echo "<span class=\"glyphicon glyphicon-play text-success\" alt=\"pass\" ></span> " . gettext("Online") . "</td>\n"; echo "<span class=\"glyphicon glyphicon-play text-success\" alt=\"pass\" ></span> " . gettext("Online") . "</td>\n";
} else { } else {
echo '<td class="listbg" align="center">' . "\n"; echo '<td class="listbg" align="center">' . "\n";
echo "<span class=\"glyphicon glyphicon-remove text-danger\" alt=\"block\" ></span> " . gettext("Offline") . "</td>\n"; echo "<span class=\"glyphicon glyphicon-remove text-danger\" alt=\"block\" ></span> " . gettext("Offline") . "</td>\n";
} }
echo '<td valign="middle" class="list nowrap">'; echo '<td valign="middle" class="list nowrap">';
/*if($is_active) { */ /*if($is_active) { */
/* Will always show wake-up button even if the code thinks it is awake */ /* Will always show wake-up button even if the code thinks it is awake */
/* } else { */ /* } else { */
echo "<a href='services_wol.php?mac={$wolent['mac']}&amp;if={$wolent['interface']}'> "; echo "<a href='services_wol.php?mac={$wolent['mac']}&amp;if={$wolent['interface']}'> ";
echo "<span class='glyphicon glyphicon-flash' title='" . gettext("Wake Up") . "' border='0' alt='wol' ></span></a>\n"; echo "<span class='glyphicon glyphicon-flash' title='" . gettext("Wake Up") . "' border='0' alt='wol' ></span></a>\n";
/* } */ /* } */
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
} else { } else {
echo "<tr><td colspan=\"4\" align=\"center\">" . gettext("No saved WoL addresses") . ".</td></tr>\n"; echo "<tr><td colspan=\"4\" align=\"center\">" . gettext("No saved WoL addresses") . ".</td></tr>\n";
} }
?> ?>
</table> </table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment