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
......@@ -94,7 +94,7 @@ function display_error_form($http_code, $desc)
{
global $config, $g;
$g['theme'] = get_current_theme();
if(isAjax()) {
if (isAjax()) {
printf(gettext('Error: %1$s Description: %2$s'), $http_code, $desc);
return;
}
......@@ -144,9 +144,9 @@ function display_login_form()
unset($input_errors);
if(isAjax()) {
if (isAjax()) {
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");
printf("showajaxmessage('" . gettext("Invalid login (%s).") . "')", $login_error);
}
......@@ -163,7 +163,7 @@ function display_login_form()
port forwards WebGUI access from WAN to an internal IP on the router. */
global $FilterIflist, $nifty_background;
$local_ip = false;
if(strstr($_SERVER['HTTP_HOST'], ":")) {
if (strstr($_SERVER['HTTP_HOST'], ":")) {
$http_host_port = explode(":", $_SERVER['HTTP_HOST']);
$http_host = $http_host_port[0];
} else {
......@@ -175,21 +175,24 @@ function display_login_form()
filter_generate_optcfg_array();
}
foreach ($FilterIflist as $iflist) {
if($iflist['ip'] == $http_host)
if ($iflist['ip'] == $http_host) {
$local_ip = true;
if($iflist['ipv6'] == $http_host)
}
if ($iflist['ipv6'] == $http_host) {
$local_ip = true;
}
}
unset($FilterIflist);
if($config['virtualip']) {
if($config['virtualip']['vip']) {
foreach($config['virtualip']['vip'] as $vip) {
if($vip['subnet'] == $http_host)
if ($config['virtualip']) {
if ($config['virtualip']['vip']) {
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'])) {
......@@ -233,7 +236,7 @@ function display_login_form()
<div class="container">
<?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";
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."));
}
......@@ -249,9 +252,11 @@ function display_login_form()
</header>
<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 />
<?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'];?>">
......@@ -271,12 +276,14 @@ function display_login_form()
</form>
<?php if (!$have_cookies && isset($_POST['login'])): ?>
<?php if (!$have_cookies && isset($_POST['login'])) :
?>
<br /><br />
<span class="text-danger">
<?= gettext("Your browser must support cookies to login."); ?>
</span>
<?php endif; ?>
<?php
endif; ?>
</div>
......
This diff is collapsed.
<?php
$captive_portal_status_title = "Captive Portal Status";
$captive_portal_status_title_link = "status_captiveportal.php";
?>
......@@ -3,5 +3,3 @@
//set variable for custom title
$carp_status_title = "Carp Status";
$carp_status_title_link = "carp_status.php";
?>
......@@ -3,5 +3,3 @@
//set variable for custom title
$dyn_dns_status_title = "Dyn DNS Status";
$dyn_dns_status_title_link = "services_dyndns.php";
?>
......@@ -2,4 +2,3 @@
//set variable for custom title
$gateways_title = "Gateways";
$gateways_title_link = "status_gateways.php";
?>
......@@ -2,4 +2,3 @@
//set variable for custom title
$interface_statistics_title = "Interface Statistics";
$interface_statistics_title_link = "status_interfaces.php";
?>
......@@ -2,5 +2,3 @@
//set variable for custom title
$interfaces_title = "Interfaces";
$interfaces_title_link = "status_interfaces.php";
?>
<?php
$ipsec_title = "IPsec";
$ipsec_title_link = "diag_ipsec.php";
?>
<?php
$load_balancer_status_title = "Load Balancer Status";
$load_balancer_status_title_link = "status_lb_pool.php";
?>
......@@ -2,5 +2,3 @@
//set variable for custom title
$log_title = "Firewall Logs";
$log_title_link = "diag_logs_filter.php";
?>
......@@ -2,4 +2,3 @@
//set variable for custom title
$ntp_status_title = "NTP Status";
$ntp_status_title_link = "status_ntpd.php";
?>
<?php
$openvpn_title = "OpenVPN";
$openvpn_title_link = "status_openvpn.php";
?>
......@@ -3,5 +3,3 @@
//set variable for custom title
$services_status_title = "Services Status";
$services_status_title_link = "status_services.php";
?>
......@@ -2,4 +2,3 @@
//set variable for custom title
$smart_status_title = "SMART Status";
$smart_status_title_link = "diag_smart.php";
?>
......@@ -17,11 +17,11 @@ $thermal_sensors_widget_title = "Thermal Sensors";
//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.
function getThermalSensorsData() {
function getThermalSensorsData()
{
$_gb = exec("/sbin/sysctl -a | grep temperature", $dfout);
$thermalSensorsData = join("|", $dfout);
return $thermalSensorsData;
}
?>
<?php
$traffic_graphs_title = "Traffic Graphs";
$traffic_graphs_title_link = "status_graph.php";
?>
......@@ -3,5 +3,3 @@
//set variable for custom title
$wake_on_lan_title = "Wake On Lan";
$wake_on_lan_title_link = "services_wol.php";
?>
......@@ -43,13 +43,15 @@ if (($_GET['act'] == "del") && (!empty($_GET['zone']))) {
flush();
function clientcmp($a, $b) {
function clientcmp($a, $b)
{
global $order;
return strcmp($a[$order], $b[$order]);
}
if (!is_array($config['captiveportal']))
if (!is_array($config['captiveportal'])) {
$config['captiveportal'] = array();
}
$a_cp =& $config['captiveportal'];
$cpdb_all = array();
......@@ -59,12 +61,16 @@ foreach ($a_cp as $cpzone => $cp) {
$order = "";
if ($_GET['order']) {
if ($_GET['order'] == "ip") $order = "ip";
else if ($_GET['order'] == "mac") $order = "mac";
else if ($_GET['order'] == "user") $order = "username";
if ($_GET['order'] == "ip") {
$order = "ip";
} 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;
}
......@@ -73,25 +79,39 @@ foreach ($a_cp as $cpzone => $cp) {
<tr>
<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=user&amp;showact=<?=$_GET['showact'];?>"><b><?=gettext("Username");?></b></a></td>
<?php if ($_GET['showact']): ?>
<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; ?>
<td class="listhdrr"><a href="?order=user&amp;showact=<?=$_GET['showact'];
?>"><b><?=gettext("Username");?></b></a></td>
<?php if ($_GET['showact']) :
?>
<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>
<?php foreach ($cpdb_all as $cpzone=>$cpdb): ?>
<?php foreach ($cpdb as $cpent): ?>
<?php foreach ($cpdb_all as $cpzone => $cpdb) :
?>
<?php foreach ($cpdb as $cpent) :
?>
<tr>
<td class="listlr"><?=$cpent->ip;?></td>
<td class="listr"><?=$cpent->mac;?>&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">?</td>
<?php endif; ?>
<?php
endif; ?>
<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>
<?php endforeach; ?>
<?php endforeach; ?>
<?php
endforeach; ?>
<?php
endforeach; ?>
</table>
......@@ -39,11 +39,12 @@ $carp_enabled = get_carp_status();
?>
<table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="carp status">
<?php
if(is_array($config['virtualip']['vip'])) {
if (is_array($config['virtualip']['vip'])) {
$carpint=0;
foreach($config['virtualip']['vip'] as $carp) {
if ($carp['mode'] != "carp")
foreach ($config['virtualip']['vip'] as $carp) {
if ($carp['mode'] != "carp") {
continue;
}
$ipaddress = $carp['subnet'];
$password = $carp['password'];
$netmask = $carp['subnet_bits'];
......@@ -52,30 +53,35 @@ $carp_enabled = get_carp_status();
$status = get_carp_interface_status("{$carp['interface']}_vip{$vhid}");
?>
<tr>
<td class="vncellt" width="35%">
<td class="vncellt" width="35%">
<span alt="cablenic" class="glyphicon glyphicon-transfer text-success"></span>&nbsp;
<strong><a href="/system_hasync.php">
<span><?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($carp['interface']) . "@{$vhid}");?></span></a></strong>
</td>
<td width="65%" class="listr">
</td>
<td width="65%" class="listr">
<?php
if($carp_enabled == false) {
if ($carp_enabled == false) {
$status = "DISABLED";
echo "<span class=\"glyphicon glyphicon-remove text-danger\" title=\"$status\" alt=\"$status\" ></span>";
} else {
if($status == "MASTER") {
} else {
if ($status == "MASTER") {
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>";
} else if($status == "INIT") {
} elseif ($status == "INIT") {
echo "<span class=\"glyphicon glyphicon-info-sign\" title=\"$status\" alt=\"$status\" ></span>";
}
}
if ($ipaddress){ ?> &nbsp;
}
if ($ipaddress) {
?> &nbsp;
<?=htmlspecialchars($status);?> &nbsp;
<?=htmlspecialchars($ipaddress);}?>
</td></tr><?php }
} else { ?>
<?=htmlspecialchars($ipaddress);
}?>
</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>
<?php } ?>
<?php
} ?>
</table>
......@@ -35,29 +35,32 @@ require_once("pfsense-utils.inc");
require_once("functions.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();
}
$a_dyndns = &$config['dyndnses']['dyndns'];
if($_REQUEST['getdyndnsstatus']) {
if ($_REQUEST['getdyndnsstatus']) {
$first_entry = true;
foreach ($a_dyndns as $dyndns) {
if ($first_entry)
if ($first_entry) {
$first_entry = false;
else
} else {
// Put a vertical bar delimiter between the echoed HTML for each entry processed.
echo "|";
}
$filename = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
if (file_exists($filename)) {
$ipaddr = dyndnsCheckIP($dyndns['interface']);
$cached_ip_s = split(":", file_get_contents($filename));
$cached_ip = $cached_ip_s[0];
if ($ipaddr <> $cached_ip)
if ($ipaddr <> $cached_ip) {
echo "<font color='red'>";
else
} else {
echo "<font color='green'>";
}
echo htmlspecialchars($cached_ip);
echo "</font>";
} else {
......@@ -76,26 +79,29 @@ if($_REQUEST['getdyndnsstatus']) {
<td width="20%" class="listhdrr"><b><?=gettext("Hostname");?></b></td>
<td width="20%" class="listhdrr"><b><?=gettext("Cached IP");?></b></td>
</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;?>'">
<td class="listlr">
<?php $iflist = get_configured_interface_with_descr();
foreach ($iflist as $if => $ifdesc) {
if ($dyndns['interface'] == $if) {
if (!isset($dyndns['enable']))
if (!isset($dyndns['enable'])) {
echo "<span class=\"gray\">{$ifdesc}</span>";
else
} else {
echo "{$ifdesc}";
}
break;
}
}
$groupslist = return_gateway_groups_array();
foreach ($groupslist as $if => $group) {
if ($dyndns['interface'] == $if) {
if (!isset($dyndns['enable']))
if (!isset($dyndns['enable'])) {
echo "<span class=\"gray\">{$if}</span>";
else
} else {
echo "{$if}";
}
break;
}
}
......@@ -115,17 +121,20 @@ if($_REQUEST['getdyndnsstatus']) {
</td>
<td class="listr">
<?php
if (!isset($dyndns['enable']))
if (!isset($dyndns['enable'])) {
echo "<span class=\"gray\">".htmlspecialchars($dyndns['host'])."</span>";
else
} else {
echo htmlspecialchars($dyndns['host']);
}
?>
</td>
<td class="listr">
<div id='dyndnsstatus<?php echo $i; ?>'><?php echo gettext("Checking ..."); ?></div>
</td>
</tr>
<?php $i++; endforeach; ?>
<?php $i++;
endforeach; ?>
</table>
<script type="text/javascript">
//<![CDATA[
......
......@@ -48,7 +48,8 @@ $counter = 1;
<td align="center"><b><?php echo gettext('Loss')?></b></td>
<td align="center"><b><?php echo gettext('Status')?></b></td>
</tr>
<?php foreach ($a_gateways as $gname => $gateway) { ?>
<?php foreach ($a_gateways as $gname => $gateway) {
?>
<tr>
<td class="h6" id="gateway<?php echo $counter; ?>" rowspan="2" align="center">
<strong>
......@@ -60,14 +61,16 @@ $counter = 1;
<div class="h6" id="gateway<?php echo $counter; ?>" style="display:inline">
<?php
$if_gw = '';
if (is_ipaddr($gateway['gateway']))
if (is_ipaddr($gateway['gateway'])) {
$if_gw = htmlspecialchars($gateway['gateway']);
else {
if($gateway['ipprotocol'] == "inet")
} else {
if ($gateway['ipprotocol'] == "inet") {
$if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
if($gateway['ipprotocol'] == "inet6")
}
if ($gateway['ipprotocol'] == "inet6") {
$if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
}
}
echo ($if_gw == '' ? '~' : $if_gw);
unset ($if_gw);
$counter++;
......@@ -78,19 +81,21 @@ $counter = 1;
<tr>
<td align="center" id="gateway<?php echo $counter; ?>">
<?php
if ($gateways_status[$gname])
if ($gateways_status[$gname]) {
echo htmlspecialchars($gateways_status[$gname]['delay']);
else
} else {
echo gettext("Pending");
}
?>
<?php $counter++; ?>
</td>
<td align="center" id="gateway<?php echo $counter; ?>">
<?php
if ($gateways_status[$gname])
if ($gateways_status[$gname]) {
echo htmlspecialchars($gateways_status[$gname]['loss']);
else
} else {
echo gettext("Pending");
}
?>
<?php $counter++; ?>
</td>
......@@ -123,5 +128,6 @@ $counter = 1;
$counter++;
?>
</tr>
<?php } // foreach ?>
<?php
} // foreach ?>
</table>
......@@ -49,56 +49,84 @@ require_once("widgets/include/interfaces.inc");
<tr>
<td class="vncellt" >
<?php
if($ifinfo['ppplink']) {
if ($ifinfo['ppplink']) {
?> <span alt="3g" class="glyphicon glyphicon-phone text-success"></span> <?php
} else if($iswireless) {
if($ifinfo['status'] == "associated") { ?>
} elseif ($iswireless) {
if ($ifinfo['status'] == "associated") {
?>
<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>
<?php } ?>
<?php } else { ?>
<?php if ($ifinfo['status'] == "up") { ?>
<?php
} ?>
<?php
} else {
?>
<?php if ($ifinfo['status'] == "up") {
?>
<span alt="cablenic" id="<?php echo $ifname . 'icon';?>" class="glyphicon glyphicon-transfer text-success"></span>
<?php } else { ?>
<?php
} else {
?>
<span alt="cablenic" id="<?php echo $ifname . 'icon';?>" class="glyphicon glyphicon-transfer text-danger"></span>
<?php } ?>
<?php } ?>&nbsp;
<?php
} ?>
<?php
} ?>&nbsp;
<strong><u>
<span onclick="location.href='/interfaces.php?if=<?=$ifdescr; ?>'" style="cursor:pointer">
<?=htmlspecialchars($ifname);?></span></u></strong>
<?php
if ($ifinfo['dhcplink'])
if ($ifinfo['dhcplink']) {
echo "&nbsp;(DHCP)";
}
?>
</td>
<?php if($ifinfo['status'] == "up" || $ifinfo['status'] == "associated") { ?>
<?php if ($ifinfo['status'] == "up" || $ifinfo['status'] == "associated") {
?>
<td class="listr" align="center">
<span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-up text-success"></span>
</td>
<?php } else if ($ifinfo['status'] == "no carrier") { ?>
<?php
} elseif ($ifinfo['status'] == "no carrier") {
?>
<td class="listr" align="center">
<span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-down text-danger"></span>
</td>
<?php } else if ($ifinfo['status'] == "down") { ?>
<?php
} elseif ($ifinfo['status'] == "down") {
?>
<td class="listr" align="center">
<span id="<?php echo $ifname;?>" class="glyphicon glyphicon-arrow-remove text-danger"></span>
</td>
<?php } else { ?><?=htmlspecialchars($ifinfo['status']); }?>
<?php
} else {
?><?=htmlspecialchars($ifinfo['status']);
}?>
<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 class="vncellt">
<?php if($ifinfo['ipaddr'] != "") { ?>
<div id="<?php echo $ifname;?>-ip" style="display:inline"><?=htmlspecialchars($ifinfo['ipaddr']);?> </div>
<?php if ($ifinfo['ipaddr'] != "") {
?>
<div id="<?php echo $ifname;
?>-ip" style="display:inline"><?=htmlspecialchars($ifinfo['ipaddr']);?> </div>
<br />
<?php }
if ($ifinfo['ipaddrv6'] != "") { ?>
<div id="<?php echo $ifname;?>-ipv6" style="display:inline"><?=htmlspecialchars($ifinfo['ipaddrv6']);?> </div>
<?php } ?>
<?php
}
if ($ifinfo['ipaddrv6'] != "") {
?>
<div id="<?php echo $ifname;
?>-ipv6" style="display:inline"><?=htmlspecialchars($ifinfo['ipaddrv6']);?> </div>
<?php
} ?>
</td>
</tr>
<?php }//end for each ?>
<?php
}//end for each ?>
</table>
......@@ -49,27 +49,27 @@ $array_interrupt = array();
$interfacecounter = 0;
//build data arrays
foreach ($ifdescrs as $ifdescr => $ifname){
foreach ($ifdescrs as $ifdescr => $ifname) {
$ifinfo = get_interface_info($ifdescr);
$interfacecounter++;
if ($ifinfo['status'] != "down"){
if ($ifinfo['status'] != "down") {
$array_in_packets[] = $ifinfo['inpkts'];
$array_out_packets[] = $ifinfo['outpkts'];
$array_in_bytes[] = format_bytes($ifinfo['inbytes']);
$array_out_bytes[] = format_bytes($ifinfo['outbytes']);
if (isset($ifinfo['inerrs'])){
if (isset($ifinfo['inerrs'])) {
$array_in_errors[] = $ifinfo['inerrs'];
$array_out_errors[] = $ifinfo['outerrs'];
}
else{
} else {
$array_in_errors[] = "n/a";
$array_out_errors[] = "n/a";
}
if (isset($ifinfo['collisions']))
if (isset($ifinfo['collisions'])) {
$array_collisions[] = htmlspecialchars($ifinfo['collisions']);
else
} else {
$array_collisions[] = "n/a";
}
}
}//end for
......@@ -107,9 +107,10 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<tr>
<?php
$interface_names = array();
foreach ($ifdescrs as $ifdescr => $ifname):
foreach ($ifdescrs as $ifdescr => $ifname) :
$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>
......@@ -123,7 +124,8 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<tr>
<?php
$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">
<?=htmlspecialchars($data);?>
</td>
......@@ -135,7 +137,8 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<tr>
<?php
$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">
<?=htmlspecialchars($data);?>
</td>
......@@ -147,7 +150,8 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<tr>
<?php
$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">
<?=htmlspecialchars($data);?>
</td>
......@@ -159,7 +163,8 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<tr>
<?php
$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">
<?=htmlspecialchars($data);?>
</td>
......@@ -171,7 +176,8 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<tr>
<?php
$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">
<?=htmlspecialchars($data);?>
</td>
......@@ -183,7 +189,8 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<tr>
<?php
$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">
<?=htmlspecialchars($data);?>
</td>
......@@ -195,7 +202,8 @@ foreach ($ifdescrs as $ifdescr => $ifname){
<tr>
<?php
$counter = 7;
foreach ($array_collisions as $data): ?>
foreach ($array_collisions as $data) :
?>
<td class="listr nowrap" id="stat<?php echo $counter;?>" style="height:25px">
<?=htmlspecialchars($data);?>
</td>
......
......@@ -34,7 +34,8 @@ require_once("guiconfig.inc");
require_once("functions.inc");
require_once("ipsec.inc");
if (isset($config['ipsec']['phase1'])){?>
if (isset($config['ipsec']['phase1'])) {
?>
<div>&nbsp;</div>
<?php
$tab_array = array();
......@@ -52,10 +53,11 @@ if (isset($config['ipsec']['phase1'])){?>
$inactivecounter = 0;
$ipsec_detail_array = array();
foreach ($config['ipsec']['phase2'] as $ph2ent){
if ($ph2ent['remoteid']['type'] == "mobile")
foreach ($config['ipsec']['phase2'] as $ph2ent) {
if ($ph2ent['remoteid']['type'] == "mobile") {
continue;
ipsec_lookup_phase1($ph2ent,$ph1ent);
}
ipsec_lookup_phase1($ph2ent, $ph1ent);
$ipsecstatus = false;
$tun_disabled = "false";
......@@ -85,7 +87,8 @@ if (isset($config['ipsec']['phase1'])){?>
}
}
if (isset($config['ipsec']['phase2'])){ ?>
if (isset($config['ipsec']['phase2'])) {
?>
<div id="ipsec-Overview" style="display:block;background-color:#EEEEEE;">
<div>
......@@ -98,7 +101,12 @@ if (isset($config['ipsec']['phase1'])){?>
<tr>
<td><?php echo $activecounter; ?></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>
</table>
</div>
......@@ -115,12 +123,10 @@ if (isset($config['ipsec']['phase1'])){?>
<div style="max-height:105px;overflow:auto;">
<?php
foreach ($ipsec_detail_array as $ipsec) :
if ($ipsec['disabled'] == "true"){
if ($ipsec['disabled'] == "true") {
$spans = "<span class=\"gray\">";
$spane = "</span>";
}
else {
} else {
$spans = $spane = "";
}
......@@ -141,7 +147,7 @@ if (isset($config['ipsec']['phase1'])){?>
<div style="display:table-cell;width:37px" align="center"><?php echo $spans;?>
<?php
if($ipsec['status'] == "true") {
if ($ipsec['status'] == "true") {
/* tunnel is up */
$iconfn = "text-success";
} else {
......@@ -153,7 +159,8 @@ if (isset($config['ipsec']['phase1'])){?>
?><?php echo $spane;?></div>
</div>
<?php endforeach; ?>
<?php
endforeach; ?>
</div>
</div>
</div>
......@@ -166,10 +173,11 @@ if (isset($config['ipsec']['phase1'])){?>
</div>
<div style="max-height:105px;overflow:auto;">
<?php
if (is_array($mobile['pool'])):
foreach ($mobile['pool'] as $pool):
if (is_array($pool['lease'])):
foreach ($pool['lease'] as $muser) : ?>
if (is_array($mobile['pool'])) :
foreach ($mobile['pool'] as $pool) :
if (is_array($pool['lease'])) :
foreach ($pool['lease'] as $muser) :
?>
<div style="display:table-row;">
<div class="listlr" style="display:table-cell;width:139px">
<?php echo htmlspecialchars($muser['id']);?><br />
......@@ -185,14 +193,15 @@ if (isset($config['ipsec']['phase1'])){?>
endforeach;
endif;
endforeach;
endif;
endif;
?>
</div>
</div>
</div>
</div>
<?php //end ipsec tunnel
}//end if tunnels are configured, else show code below
else { ?>
} //end if tunnels are configured, else show code below
else {
?>
<div style="display:block">
<table class="table table-striped" width="100%" border="0" cellpadding="0" cellspacing="0" summary="note">
<tr>
......@@ -210,4 +219,5 @@ else { ?>
</tr>
</table>
</div>
<?php } ?>
<?php
}
......@@ -69,7 +69,8 @@ if (!$nentries) {
<td width="10%" class="listhdrr">Pool</td>
<td width="30%" class="listhdr">Description</td>
</thead>
<?php $i = 0; foreach ($a_vs as $vsent): ?>
<?php $i = 0; foreach ($a_vs as $vsent) :
?>
<tr>
<?php
switch (trim($rdr_a[$vsent['name']]['status'])) {
......@@ -111,7 +112,7 @@ if (!$nentries) {
}
asort($pool_hosts);
foreach ((array) $pool_hosts as $server) {
if($server['ip']['addr']!="") {
if ($server['ip']['addr']!="") {
switch ($server['ip']['state']) {
case 'up':
$bgcolor = "#90EE90"; // lightgreen
......@@ -127,8 +128,9 @@ if (!$nentries) {
}
echo "<tr>";
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 "&nbsp;</td></tr>";
}
}
......@@ -141,5 +143,7 @@ if (!$nentries) {
<font color="#FFFFFF"><?=$vsent['descr'];?></font>
</td>
</tr>
<?php $i++; endforeach; ?>
<?php $i++;
endforeach; ?>
</table>
......@@ -36,24 +36,32 @@ require_once("pfsense-utils.inc");
require_once("functions.inc");
require_once("filter_log.inc");
if(is_numeric($_POST['filterlogentries'])) {
if (is_numeric($_POST['filterlogentries'])) {
$config['widgets']['filterlogentries'] = $_POST['filterlogentries'];
$acts = array();
if ($_POST['actpass']) $acts[] = "Pass";
if ($_POST['actblock']) $acts[] = "Block";
if ($_POST['actreject']) $acts[] = "Reject";
if ($_POST['actpass']) {
$acts[] = "Pass";
}
if ($_POST['actblock']) {
$acts[] = "Block";
}
if ($_POST['actreject']) {
$acts[] = "Reject";
}
if (!empty($acts))
if (!empty($acts)) {
$config['widgets']['filterlogentriesacts'] = implode(" ", $acts);
else
} else {
unset($config['widgets']['filterlogentriesacts']);
}
unset($acts);
if( ($_POST['filterlogentriesinterfaces']) and ($_POST['filterlogentriesinterfaces'] != "All") )
if (($_POST['filterlogentriesinterfaces']) and ($_POST['filterlogentriesinterfaces'] != "All")) {
$config['widgets']['filterlogentriesinterfaces'] = trim($_POST['filterlogentriesinterfaces']);
else
} else {
unset($config['widgets']['filterlogentriesinterfaces']);
}
write_config("Saved Filter Log Entries via Dashboard");
Header("Location: /");
......@@ -91,10 +99,11 @@ var isPaused = false;
var nentries = <?php echo $nentries; ?>;
<?php
if(isset($config['syslog']['reverse']))
if (isset($config['syslog']['reverse'])) {
echo "var isReverse = true;\n";
else
} else {
echo "var isReverse = false;\n";
}
?>
/* Called by the AJAX updater */
......@@ -133,21 +142,33 @@ function format_log_line(row) {
<tr>
<td>
<select name="filterlogentries" class="formfld unknown" id="filterlogentries">
<?php for ($i = 1; $i <= 20; $i++) { ?>
<option value="<?php echo $i;?>" <?php if ($nentries == $i) echo "selected=\"selected\"";?>><?php echo $i;?></option>
<?php } ?>
<?php for ($i = 1; $i <= 20; $i++) {
?>
<option value="<?php echo $i;?>" <?php if ($nentries == $i) {
echo "selected=\"selected\"";
}?>><?php echo $i;?></option>
<?php
} ?>
</select>
</td>
</tr>
<?php
$Include_Act = explode(" ", $nentriesacts);
if ($nentriesinterfaces == "All") $nentriesinterfaces = "";
if ($nentriesinterfaces == "All") {
$nentriesinterfaces = "";
}
?>
<tr>
<td>
<input id="actpass" name="actpass" type="checkbox" value="Pass" <?php if (in_arrayi('Pass', $Include_Act)) echo "checked=\"checked\""; ?> /> Pass
<input id="actblock" name="actblock" type="checkbox" value="Block" <?php if (in_arrayi('Block', $Include_Act)) echo "checked=\"checked\""; ?> /> Block
<input id="actreject" name="actreject" type="checkbox" value="Reject" <?php if (in_arrayi('Reject', $Include_Act)) echo "checked=\"checked\""; ?> /> Reject
<input id="actpass" name="actpass" type="checkbox" value="Pass" <?php if (in_arrayi('Pass', $Include_Act)) {
echo "checked=\"checked\"";
} ?> /> Pass
<input id="actblock" name="actblock" type="checkbox" value="Block" <?php if (in_arrayi('Block', $Include_Act)) {
echo "checked=\"checked\"";
} ?> /> Block
<input id="actreject" name="actreject" type="checkbox" value="Reject" <?php if (in_arrayi('Reject', $Include_Act)) {
echo "checked=\"checked\"";
} ?> /> Reject
</td>
</tr>
<tr>
......@@ -161,13 +182,15 @@ function format_log_line(row) {
<option value="All">ALL</option>
<?php
$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) {
echo "selected=\"selected\"";
}?>>
<?=htmlspecialchars($ifacename);?>
</option>
<?php
endforeach;
endforeach;
unset($interfaces);
unset($Include_Act);
?>
......@@ -204,7 +227,7 @@ function format_log_line(row) {
<tbody id='filter-log-entries'>
<?php
$rowIndex = 0;
foreach ($filterlog as $filterent):
foreach ($filterlog as $filterent) :
$evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
$rowIndex++;
?>
......@@ -214,20 +237,24 @@ function format_log_line(row) {
<span class="<?php echo find_action_image($filterent['act']);?>" alt="<?php echo $filterent['act'];?>" title="<?php echo $filterent['act'];?>" ></span>
</a>
</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['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>
<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
if ($filterent['proto'] == "TCP")
if ($filterent['proto'] == "TCP") {
$filterent['proto'] .= ":{$filterent['tcpflags']}";
}
?>
</tr>
<?php endforeach; ?>
<?php
endforeach; ?>
<tr style="display:none;"><td></td></tr>
</tbody>
</table>
......
......@@ -36,7 +36,7 @@ require_once("pfsense-utils.inc");
require_once("functions.inc");
require_once("widgets/include/ntp_status.inc");
if($_REQUEST['updateme']) {
if ($_REQUEST['updateme']) {
//this block displays only on ajax refresh
exec("/usr/local/sbin/ntpq -pn | /usr/bin/tail +3", $ntpq_output);
$ntpq_counter = 0;
......@@ -78,7 +78,7 @@ if($_REQUEST['updateme']) {
$gps_lon = $gps_lon * (($gps_vars[6] == "E") ? 1 : -1);
$gps_la = $gps_vars[4];
$gps_lo = $gps_vars[6];
}elseif (substr($tmp, 0, 6) == '$GPGGA') {
} elseif (substr($tmp, 0, 6) == '$GPGGA') {
$gps_vars = explode(",", $tmp);
$gps_ok = $gps_vars[6];
$gps_lat_deg = substr($gps_vars[2], 0, 2);
......@@ -94,7 +94,7 @@ if($_REQUEST['updateme']) {
$gps_sat = $gps_vars[7];
$gps_la = $gps_vars[3];
$gps_lo = $gps_vars[5];
}elseif (substr($tmp, 0, 6) == '$GPGLL') {
} elseif (substr($tmp, 0, 6) == '$GPGLL') {
$gps_vars = explode(",", $tmp);
$gps_ok = ($gps_vars[6] == "A");
$gps_lat_deg = substr($gps_vars[1], 0, 2);
......@@ -114,11 +114,11 @@ if($_REQUEST['updateme']) {
if (isset($config['ntpd']['gps']['type']) && ($config['ntpd']['gps']['type'] == 'SureGPS') && (isset($gps_ok))) {
//GSV message is only enabled by init commands in services_ntpd_gps.php for SureGPS board
$gpsport = fopen("/dev/gps0", "r+");
while($gpsport){
while ($gpsport) {
$buffer = fgets($gpsport);
if(substr($buffer, 0, 6)=='$GPGSV'){
if (substr($buffer, 0, 6)=='$GPGSV') {
//echo $buffer."\n";
$gpgsv = explode(',',$buffer);
$gpgsv = explode(',', $buffer);
$gps_satview = $gpgsv[3];
break;
}
......@@ -131,14 +131,19 @@ if($_REQUEST['updateme']) {
<tr>
<td width="40%" class="vncellt">Sync Source</td>
<td width="60%" class="listr">
<?php if ($ntpq_counter == 0): ?>
<?php if ($ntpq_counter == 0) :
?>
No active peers available
<?php else: ?>
<?php
else :
?>
<?php echo $syncsource; ?>
<?php endif; ?>
<?php
endif; ?>
</td>
</tr>
<?php if (($gps_ok) && ($gps_lat) && ($gps_lon)): ?>
<?php if (($gps_ok) && ($gps_lat) && ($gps_lon)) :
?>
<tr>
<td width="40%" class="vncellt">Clock location</td>
<td width="60%" class="listr">
......@@ -146,22 +151,33 @@ if($_REQUEST['updateme']) {
<?php
echo sprintf("%.5f", $gps_lat) . " " . $gps_la . ", " . sprintf("%.5f", $gps_lon) . " " . $gps_lo; ?>
</a>
<?php if (isset($gps_alt)) {echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)";} ?>
<?php if (isset($gps_alt)) {
echo " (" . $gps_alt . " " . $gps_alt_unit . " alt.)";
} ?>
</td>
</tr>
<?php if (isset($gps_sat) || isset($gps_satview)): ?>
<?php if (isset($gps_sat) || isset($gps_satview)) :
?>
<tr>
<td width="40%" class="vncellt">Satellites</td>
<td width="60%" class="listr">
<?php
if (isset($gps_satview)) {echo 'in view ' . intval($gps_satview);}
if (isset($gps_sat) && isset($gps_satview)) {echo ', ';}
if (isset($gps_sat)) {echo 'in use ' . $gps_sat;}
if (isset($gps_satview)) {
echo 'in view ' . intval($gps_satview);
}
if (isset($gps_sat) && isset($gps_satview)) {
echo ', ';
}
if (isset($gps_sat)) {
echo 'in use ' . $gps_sat;
}
?>
</td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php
endif; ?>
<?php
endif; ?>
</tbody>
</table>
<?php
......@@ -186,20 +202,23 @@ $gDate = time();
JavaScript client code's definition of clockShowsSeconds below to match. */
$gClockShowsSeconds = true;
function getServerDateItems($inDate) {
return date('Y,n,j,G,',$inDate).intval(date('i',$inDate)).','.intval(date('s',$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
// use intval to strip leading zero from minutes and seconds
// so JavaScript won't try to interpret them in octal
// (use intval instead of ltrim, which translates '00' to '')
}
function clockDateString($inDate) {
return date('Y. F j l',$inDate); // eg "Monday, January 1, 2002"
function clockDateString($inDate)
{
return date('Y. F j l', $inDate); // eg "Monday, January 1, 2002"
}
function clockTimeString($inDate, $showSeconds) {
return date($showSeconds ? 'G:i:s' : 'g:i',$inDate).' ';
function clockTimeString($inDate, $showSeconds)
{
return date($showSeconds ? 'G:i:s' : 'g:i', $inDate).' ';
}
/*** Clock -- end of server-side support code ***/
?>
......@@ -453,7 +472,7 @@ function clockUpdate()
<td width="40%" class="vncellt">Server Time</td>
<td width="60%" class="listr">
<div id="ClockTime">
<b><?php echo(clockTimeString($gDate,$gClockShowsSeconds));?></b>
<b><?php echo(clockTimeString($gDate, $gClockShowsSeconds));?></b>
</div>
</td>
</tr>
......
......@@ -32,8 +32,8 @@ require_once("guiconfig.inc");
require_once("openvpn.inc");
/* Handle AJAX */
if($_GET['action']) {
if($_GET['action'] == "kill") {
if ($_GET['action']) {
if ($_GET['action'] == "kill") {
$port = $_GET['port'];
$remipp = $_GET['remipp'];
if (!empty($port) and !empty($remipp)) {
......@@ -47,7 +47,8 @@ if($_GET['action']) {
}
function kill_client($port, $remipp) {
function kill_client($port, $remipp)
{
global $g;
//$tcpsrv = "tcp://127.0.0.1:{$port}";
......@@ -65,12 +66,14 @@ function kill_client($port, $remipp) {
$line = fgets($fp, 1024);
$info = stream_get_meta_data($fp);
if ($info['timed_out'])
if ($info['timed_out']) {
break;
}
/* parse header list line */
if (strpos($line, "INFO:") !== false)
if (strpos($line, "INFO:") !== false) {
continue;
}
if (strpos($line, "SUCCESS") !== false) {
$killed = 0;
}
......@@ -117,7 +120,8 @@ $clients = openvpn_get_active_clients();
}
</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">
<tr>
......@@ -133,7 +137,7 @@ $clients = openvpn_get_active_clients();
<td class="listhdrr">Real/Virtual IP</td>
</tr>
<?php $rowIndex = 0;
foreach ($server['conns'] as $conn):
foreach ($server['conns'] as $conn) :
$evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
$rowIndex++;
?>
......@@ -160,7 +164,8 @@ $clients = openvpn_get_active_clients();
</td>
</tr>
<?php endforeach; ?>
<?php
endforeach; ?>
<tfoot>
<tr>
<td colspan="6" class="list" height="12"></td>
......@@ -171,8 +176,10 @@ $clients = openvpn_get_active_clients();
</tr>
</table>
<?php endforeach; ?>
<?php if (!empty($sk_servers)) { ?>
<?php
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">
<tr>
<td colspan="6" class="listtopic">
......@@ -186,7 +193,8 @@ $clients = openvpn_get_active_clients();
<td class="listhdrr">Remote/Virtual IP</td>
</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']}"; ?>'>
<td class="listlr">
<?=$sk_server['name'];?>
......@@ -215,14 +223,16 @@ $clients = openvpn_get_active_clients();
<?=$sk_server['virtual_addr'];?>
</td>
</tr>
<?php endforeach; ?>
<?php
endforeach; ?>
</table>
</tr>
</table>
<?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">
<tr>
<td colspan="6" class="listtopic">
......@@ -236,7 +246,8 @@ $clients = openvpn_get_active_clients();
<td class="listhdrr">Remote/Virtual IP</td>
</tr>
<?php foreach ($clients as $client): ?>
<?php foreach ($clients as $client) :
?>
<tr name='<?php echo "r:{$client['port']}:{$client['remote_host']}"; ?>'>
<td class="listlr">
<?=$client['name'];?>
......@@ -265,7 +276,8 @@ $clients = openvpn_get_active_clients();
<?=$client['virtual_addr'];?>
</td>
</tr>
<?php endforeach; ?>
<?php
endforeach; ?>
</table>
</tr>
</table>
......@@ -280,4 +292,3 @@ if ($DisplayNote) {
if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))) {
echo "No OpenVPN instance defined";
}
?>
......@@ -32,11 +32,12 @@ require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
require_once("functions.inc");
if($_GET['getpic']=="true") {
if ($_GET['getpic']=="true") {
$pic_type_s = explode(".", $config['widgets']['picturewidget_filename']);
$pic_type = $pic_type_s[1];
if($config['widgets']['picturewidget'])
if ($config['widgets']['picturewidget']) {
$data = base64_decode($config['widgets']['picturewidget']);
}
header("Content-Disposition: inline; filename=\"{$config['widgets']['picturewidget_filename']}\"");
header("Content-Type: image/{$pic_type}");
header("Content-Length: " . strlen($data));
......@@ -44,16 +45,16 @@ if($_GET['getpic']=="true") {
exit;
}
if($_POST) {
if ($_POST) {
if (is_uploaded_file($_FILES['pictfile']['tmp_name'])) {
/* read the file contents */
$fd_pic = fopen($_FILES['pictfile']['tmp_name'], "rb");
while ( ($buf=fread( $fd_pic, 8192 )) != '' ) {
while (($buf=fread($fd_pic, 8192)) != '') {
// Here, $buf is guaranteed to contain data
$data .= $buf;
}
fclose($fd_pic);
if(!$data) {
if (!$data) {
log_error("Warning, could not read file " . $_FILES['pictfile']['tmp_name']);
die("Could not read temporary file");
} else {
......@@ -89,13 +90,15 @@ if($_POST) {
</div>
<!-- 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">
<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" />
</a>
</div>
<?php endif ?>
<?php
endif ?>
<!-- needed to show the settings widget icon -->
<script type="text/javascript">
//<![CDATA[
......
......@@ -32,7 +32,7 @@ require_once("guiconfig.inc");
require_once("pfsense-utils.inc");
require_once("functions.inc");
if($_POST['rssfeed']) {
if ($_POST['rssfeed']) {
$config['widgets']['rssfeed'] = str_replace("\n", ",", htmlspecialchars($_POST['rssfeed'], ENT_QUOTES | ENT_HTML401));
$config['widgets']['rssmaxitems'] = str_replace("\n", ",", htmlspecialchars($_POST['rssmaxitems'], ENT_QUOTES | ENT_HTML401));
$config['widgets']['rsswidgetheight'] = htmlspecialchars($_POST['rsswidgetheight'], ENT_QUOTES | ENT_HTML401);
......@@ -42,37 +42,44 @@ if($_POST['rssfeed']) {
}
// Use saved feed and max items
if($config['widgets']['rssfeed'])
if ($config['widgets']['rssfeed']) {
$rss_feed_s = explode(",", $config['widgets']['rssfeed']);
}
if($config['widgets']['rssmaxitems'])
if ($config['widgets']['rssmaxitems']) {
$max_items = $config['widgets']['rssmaxitems'];
}
if(is_numeric($config['widgets']['rsswidgetheight']))
if (is_numeric($config['widgets']['rsswidgetheight'])) {
$rsswidgetheight = $config['widgets']['rsswidgetheight'];
}
if(is_numeric($config['widgets']['rsswidgettextlength']))
if (is_numeric($config['widgets']['rsswidgettextlength'])) {
$rsswidgettextlength = $config['widgets']['rsswidgettextlength'];
}
// Set a default feed if none exists
if(!$rss_feed_s) {
if (!$rss_feed_s) {
$rss_feed_s = "https://opnsense.org/feed/";
$config['widgets']['rssfeed'] = "https://opnsense.org/feed/";
}
if(!$max_items)
if (!$max_items) {
$max_items = 10;
}
if(!$rsswidgetheight)
if (!$rsswidgetheight) {
$rsswidgetheight = 300;
}
if(!$rsswidgettextlength)
if (!$rsswidgettextlength) {
$rsswidgettextlength = 140; // oh twitter, how do we love thee?
if($config['widgets']['rssfeed'])
}
if ($config['widgets']['rssfeed']) {
$textarea_txt = str_replace(",", "\n", $config['widgets']['rssfeed']);
else
} else {
$textarea_txt = "";
}
?>
......@@ -94,8 +101,9 @@ else
<select name='rssmaxitems' id='rssmaxitems'>
<option value='<?= $max_items ?>'><?= $max_items ?></option>
<?php
for($x=100; $x<5100; $x=$x+100)
for ($x=100; $x<5100; $x=$x+100) {
echo "<option value='{$x}'>{$x}</option>\n";
}
?>
</select>
</td>
......@@ -108,8 +116,9 @@ else
<select name='rsswidgetheight' id='rsswidgetheight'>
<option value='<?= $rsswidgetheight ?>'><?= $rsswidgetheight ?>px</option>
<?php
for($x=100; $x<5100; $x=$x+100)
for ($x=100; $x<5100; $x=$x+100) {
echo "<option value='{$x}'>{$x}px</option>\n";
}
?>
</select>
</td>
......@@ -122,8 +131,9 @@ else
<select name='rsswidgettextlength' id='rsswidgettextlength'>
<option value='<?= $rsswidgettextlength ?>'><?= $rsswidgettextlength ?></option>
<?php
for($x=10; $x<5100; $x=$x+10)
for ($x=10; $x<5100; $x=$x+10) {
echo "<option value='{$x}'>{$x}</option>\n";
}
?>
</select>
</td>
......@@ -139,18 +149,20 @@ else
<div id="rss-widgets" style="padding: 5px; height: <?=$rsswidgetheight?>px; overflow:scroll;">
<?php
if(!is_dir("/tmp/simplepie")) {
if (!is_dir("/tmp/simplepie")) {
mkdir("/tmp/simplepie");
mkdir("/tmp/simplepie/cache");
}
}
exec("chmod a+rw /tmp/simplepie/.");
exec("chmod a+rw /tmp/simplepie/cache/.");
require_once("simplepie/simplepie.inc");
function textLimit($string, $length, $replacer = '...') {
if(strlen($string) > $length)
function textLimit($string, $length, $replacer = '...')
{
if (strlen($string) > $length) {
return (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
return $string;
}
return $string;
}
$feed = new SimplePie();
$feed->set_cache_location("/tmp/simplepie/");
$feed->set_feed_url($rss_feed_s);
......@@ -158,7 +170,7 @@ else
$feed->set_output_encoding('latin-1');
$feed->handle_content_type();
$counter = 1;
foreach($feed->get_items() as $item) {
foreach ($feed->get_items() as $item) {
$feed = $item->get_feed();
$feed->strip_htmltags();
echo "<a target='blank' href='" . $item->get_permalink() . "'>" . $item->get_title() . "</a><br />";
......@@ -167,10 +179,11 @@ else
echo textLimit($content, $rsswidgettextlength) . "<br />";
echo "Source: <a target='_blank' href='" . $item->get_permalink() . "'>".$feed->get_title()."</a><br />";
$counter++;
if($counter > $max_items)
if ($counter > $max_items) {
break;
echo "<hr/>";
}
echo "<hr/>";
}
?>
</div>
......
......@@ -39,7 +39,7 @@ require_once("widgets/include/services_status.inc");
$services = get_services();
if(isset($_POST['servicestatusfilter'])) {
if (isset($_POST['servicestatusfilter'])) {
$config['widgets']['servicestatusfilter'] = htmlspecialchars($_POST['servicestatusfilter'], ENT_QUOTES | ENT_HTML401);
write_config("Saved Service Status Filter via Dashboard");
header("Location: ../../index.php");
......@@ -66,21 +66,22 @@ $skipservices = explode(",", $config['widgets']['servicestatusfilter']);
if (count($services) > 0) {
uasort($services, "service_name_compare");
foreach($services as $service) {
if(!$service['name'] || in_array($service['name'], $skipservices)) {
foreach ($services as $service) {
if (!$service['name'] || in_array($service['name'], $skipservices)) {
continue;
}
$service_desc = explode(".",$service['description']);
$service_desc = explode(".", $service['description']);
echo "<tr><td class=\"listlr\">" . $service['name'] . "</td>\n";
echo "<td class=\"listr\">" . $service_desc[0] . "</td>\n";
// if service is running then listr else listbg
$bgclass = null;
if (get_service_status($service))
if (get_service_status($service)) {
$bgclass = "listr";
else
} else {
$bgclass = "listbg";
echo "<td class=\"" . $bgclass . "\" align=\"center\">" . 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 {
echo "<tr><td colspan=\"3\" align=\"center\">" . gettext("No services found") . " . </td></tr>\n";
......
......@@ -46,8 +46,9 @@ $devs = array();
## 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
if(count($devs) > 0) {
foreach($devs as $dev) { ## for each found drive do
if (count($devs) > 0) {
foreach ($devs as $dev) {
## for each found drive do
$dev_ident = exec("diskinfo -v /dev/$dev | grep ident | awk '{print $1}'"); ## get identifier from drive
$dev_state = trim(exec("smartctl -H /dev/$dev | awk -F: '/^SMART overall-health self-assessment test result/ {print $2;exit}
/^SMART Health Status/ {print $2;exit}'")); ## get SMART state from drive
......@@ -70,7 +71,8 @@ if(count($devs) > 0) {
<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>
</tr>
<?php }
<?php
}
}
?>
</table>
......@@ -37,21 +37,20 @@ require_once("script/load_phalcon.php");
$file_pkg_status="/tmp/pkg_status.json";
if($_POST['action'] == 'pkg_update') {
if ($_POST['action'] == 'pkg_update') {
/* Setup Shell variables */
$shell_output = array();
$shell = new OPNsense\Core\Shell();
// 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)) {
$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 ($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>";
......@@ -82,16 +81,22 @@ $filesystems = get_mounted_filesystems();
jQuery("#memUsagePB").css( { width: '<?php echo mem_usage(); ?>%' } );
<?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']; ?>%' } );
<?PHP endforeach; ?>
<?PHP
endforeach; ?>
<?php if($showswap == true): ?>
<?php if ($showswap == true) :
?>
jQuery("#swapUsagePB").css( { width: '<?php echo swap_usage(); ?>%' } );
<?php endif; ?>
<?php if (get_temp() != ""): ?>
<?php
endif; ?>
<?php if (get_temp() != "") :
?>
jQuery("#tempPB").css( { width: '<?php echo get_temp(); ?>%' } );
<?php endif; ?>
<?php
endif; ?>
});
//]]>
</script>
......@@ -114,7 +119,8 @@ $filesystems = get_mounted_filesystems();
</td>
</tr>
<?php if(!isset($config['system']['firmware']['disablecheck'])): ?>
<?php if (!isset($config['system']['firmware']['disablecheck'])) :
?>
<tr>
<td>
Updates
......@@ -123,7 +129,8 @@ $filesystems = get_mounted_filesystems();
<div id='updatestatus'><span class="text-info">Fetching status</span></div>
</td>
</tr>
<?php endif; ?>
<?php
endif; ?>
<tr>
<td width="25%" class="vncellt"><?=gettext("CPU Type");?></td>
<td width="75%" class="listr">
......@@ -132,18 +139,22 @@ $filesystems = get_mounted_filesystems();
?>
<div id="cpufreq"><?= get_cpufreq(); ?></div>
<?php $cpucount = get_cpu_count();
if ($cpucount > 1): ?>
if ($cpucount > 1) :
?>
<div id="cpucount">
<?= htmlspecialchars($cpucount) ?> CPUs: <?= htmlspecialchars(get_cpu_count(true)); ?></div>
<?php endif; ?>
<?php
endif; ?>
</td>
</tr>
<?php if ($hwcrypto): ?>
<?php if ($hwcrypto) :
?>
<tr>
<td width="25%" class="vncellt"><?=gettext("Hardware crypto");?></td>
<td width="75%" class="listr"><?=htmlspecialchars($hwcrypto);?></td>
</tr>
<?php endif; ?>
<?php
endif; ?>
<tr>
<td width="25%" class="vncellt"><?=gettext("Uptime");?></td>
<td width="75%" class="listr" id="uptime"><?= htmlspecialchars(get_uptime()); ?></td>
......@@ -159,18 +170,20 @@ $filesystems = get_mounted_filesystems();
<td width="70%" class="listr">
<?php
$dns_servers = get_dns_servers();
foreach($dns_servers as $dns) {
foreach ($dns_servers as $dns) {
echo "{$dns}<br />";
}
?>
</td>
</tr>
<?php if ($config['revision']): ?>
<?php if ($config['revision']) :
?>
<tr>
<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>
</tr>
<?php endif; ?>
<?php
endif; ?>
<tr>
<td width="25%" class="vncellt"><?=gettext("State table size");?></td>
<td width="75%" class="listr">
......@@ -183,7 +196,8 @@ $filesystems = get_mounted_filesystems();
</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 />
<a href="diag_dump_states.php"><?=gettext("Show states");?></a>
</td>
......@@ -204,7 +218,8 @@ $filesystems = get_mounted_filesystems();
<span id="mbufusagemeter"><?= $mbufusage.'%'; ?></span> (<span id="mbuf"><?= $mbufstext ?></span>)
</td>
</tr>
<?php if (get_temp() != ""): ?>
<?php if (get_temp() != "") :
?>
<tr>
<td width="25%" class="vncellt"><?=gettext("Temperature");?></td>
<td width="75%" class="listr">
......@@ -218,7 +233,8 @@ $filesystems = get_mounted_filesystems();
<span id="tempmeter"><?= $temp."&#176;C"; ?></span>
</td>
</tr>
<?php endif; ?>
<?php
endif; ?>
<tr>
<td width="25%" class="vncellt"><?=gettext("Load average");?></td>
<td width="75%" class="listr">
......@@ -246,10 +262,11 @@ $filesystems = get_mounted_filesystems();
<span class="sr-only"></span>
</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>
</tr>
<?php if($showswap == true): ?>
<?php if ($showswap == true) :
?>
<tr>
<td width="25%" class="vncellt"><?=gettext("SWAP usage");?></td>
<td width="75%" class="listr">
......@@ -259,24 +276,29 @@ $filesystems = get_mounted_filesystems();
<span class="sr-only"></span>
</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>
</tr>
<?php endif; ?>
<?php
endif; ?>
<tr>
<td width="25%" class="vncellt"><?=gettext("Disk usage");?></td>
<td width="75%" class="listr">
<?PHP $d = 0; ?>
<?PHP foreach ($filesystems as $fs): ?>
<?PHP foreach ($filesystems as $fs) :
?>
<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%;">
<span class="sr-only"></span>
</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'];?>
<br />
<?PHP endforeach; ?>
<?PHP
endforeach; ?>
</td>
</tr>
</tbody>
......@@ -300,7 +322,8 @@ $filesystems = get_mounted_filesystems();
getstatus();
}
<?php if(!isset($config['system']['firmware']['disablecheck'])): ?>
<?php if (!isset($config['system']['firmware']['disablecheck'])) :
?>
function getstatus() {
scroll(0,0);
var url = "/widgets/widgets/system_information.widget.php";
......@@ -318,6 +341,7 @@ $filesystems = get_mounted_filesystems();
// to avoid this we set the innerHTML property
jQuery('#updatestatus').prop('innerHTML',transport.responseText);
}
<?php endif; ?>
<?php
endif; ?>
//]]>
</script>
......@@ -76,7 +76,8 @@ if ($_POST) {
header("Location: ../../index.php");
}
function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $criticalValueKey) {
function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $criticalValueKey)
{
$warningValue = 0;
$criticalValue = 0;
......@@ -88,8 +89,7 @@ function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $cr
$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) &&
($warningValue < $criticalValue)
) {
......@@ -99,7 +99,8 @@ function saveThresholdSettings(&$configArray, &$postArray, $warningValueKey, $cr
}
}
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;
}
......@@ -116,7 +117,8 @@ $thermal_sensors_widget_showFullSensorName = getBoolValueFromConfig($config, "th
$thermal_sensors_widget_pulsateWarning = getBoolValueFromConfig($config, "thermal_sensors_widget_pulsate_warning", 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;
......@@ -131,7 +133,8 @@ function getThresholdValueFromConfig(&$configArray, $valueKey, $defaultValue) {
return $thresholdValue;
}
function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue)
{
$boolValue = false;
......@@ -196,7 +199,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
<input type="checkbox"
id="thermal_sensors_widget_show_raw_output"
name="thermal_sensors_widget_show_raw_output"
value="<?= $thermal_sensors_widget_showRawOutput; ?>" <?= ($thermal_sensors_widget_showRawOutput) ? " checked='checked'" : ""; ?> />
value="<?= $thermal_sensors_widget_showRawOutput;
?>" <?= ($thermal_sensors_widget_showRawOutput) ? " checked='checked'" : ""; ?> />
</td>
</tr>
<tr>
......@@ -214,7 +218,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
<input type="checkbox"
id="thermal_sensors_widget_show_full_sensor_name"
name="thermal_sensors_widget_show_full_sensor_name"
value="<?= $thermal_sensors_widget_showFullSensorName; ?>" <?= ($thermal_sensors_widget_showFullSensorName) ? " checked='checked'" : ""; ?> />
value="<?= $thermal_sensors_widget_showFullSensorName;
?>" <?= ($thermal_sensors_widget_showFullSensorName) ? " checked='checked'" : ""; ?> />
</td>
</tr>
<tr>
......@@ -232,7 +237,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
<input type="checkbox"
id="thermal_sensors_widget_pulsate_warning"
name="thermal_sensors_widget_pulsate_warning"
value="<?= $thermal_sensors_widget_pulsateWarning; ?>" <?= ($thermal_sensors_widget_pulsateWarning) ? " checked='checked'" : ""; ?> />
value="<?= $thermal_sensors_widget_pulsateWarning;
?>" <?= ($thermal_sensors_widget_pulsateWarning) ? " checked='checked'" : ""; ?> />
</td>
</tr>
<tr>
......@@ -250,7 +256,8 @@ function getBoolValueFromConfig(&$configArray, $valueKey, $defaultValue) {
<input type="checkbox"
id="thermal_sensors_widget_pulsate_critical"
name="thermal_sensors_widget_pulsate_critical"
value="<?= $thermal_sensors_widget_pulsateCritical; ?>" <?= ($thermal_sensors_widget_pulsateCritical) ? " checked='checked'" : ""; ?> />
value="<?= $thermal_sensors_widget_pulsateCritical;
?>" <?= ($thermal_sensors_widget_pulsateCritical) ? " checked='checked'" : ""; ?> />
</td>
</tr>
<tr>
......
......@@ -51,11 +51,11 @@ if (!is_array($a_config["shown"]["item"])) {
}
$ifdescrs = get_configured_interface_with_descr();
if (isset($config['ipsec']['enable']))
if (isset($config['ipsec']['enable'])) {
$ifdescrs['enc0'] = "IPsec";
}
if ($_POST) {
if (isset($_POST["refreshinterval"])) {
$a_config["refreshinterval"] = $_POST["refreshinterval"];
}
......@@ -100,9 +100,11 @@ if (isset($a_config["scale_type"])) {
<div id="traffic_graphs-settings" class="widgetconfigdiv" style="display:none;">
<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" ?>" />
<?php } ?>
<?php
} ?>
<table class="table table-striped">
<tbody>
......@@ -120,8 +122,7 @@ if (isset($a_config["scale_type"])) {
if ($selected_radio == "up") {
$scale_type_up = "checked=\"checked\"";
$scale_type_follow="";
}
else if ($selected_radio == "follow") {
} elseif ($selected_radio == "follow") {
$scale_type_up="";
$scale_type_follow = "checked=\"checked\"";
}
......@@ -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 />
Refresh Interval:
<select name="refreshinterval" class="formfld" id="refreshinterval" >
<?php for ($i = 1; $i <= 10; $i += 1) { ?>
<option value="<?= $i ?>" <?php if ($refreshinterval == $i) echo "selected=\"selected\"";?>><?= $i ?></option>
<?php } ?>
<?php for ($i = 1; $i <= 10; $i += 1) {
?>
<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 />
</td>
</tr>
......@@ -176,28 +181,35 @@ foreach ($ifdescrs as $ifname => $ifdescr) {
$graphdisplay = "none";
$interfacevalue = "hide";
}
if ($ifinfo['status'] != "down") { ?>
if ($ifinfo['status'] != "down") {
?>
<div id="<?=$ifname;?>trafficdiv" style="padding: 5px">
<div id="<?=$ifname;?>topic" class="widgetsubheader">
<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 align="right" style="float:right;width:49%">
<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);'
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 style="clear:both;"></div>
</div>
<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="type" value="image/svg+xml" />
<param name="pluginspage" value="http://www.adobe.com/svg/viewer/install/auto" />
</object>
</div>
</div>
<?php }
<?php
}
}
?>
......@@ -31,10 +31,11 @@ $nocsrf = true;
require_once("guiconfig.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'];
else
} else {
$wolcomputers = array();
}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="wol status">
......@@ -49,12 +50,12 @@ else
<?php
if (count($wolcomputers) > 0) {
foreach($wolcomputers as $wolent) {
foreach ($wolcomputers as $wolent) {
echo '<tr><td class="listlr">' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n";
echo '<td class="listr">' . convert_friendly_interface_to_friendly_descr($wolent['interface']) . '</td>' . "\n";
$is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'");
if($is_active == 1) {
if ($is_active == 1) {
echo '<td class="listr" align="center">' . "\n";
echo "<span class=\"glyphicon glyphicon-play text-success\" alt=\"pass\" ></span> " . gettext("Online") . "</td>\n";
} else {
......
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