Commit a31f377d authored by Ad Schellevis's avatar Ad Schellevis

(dashboard/widgets) code cleanup carp_status.widget.php

parent 50c22a27
<?php <?php
/* /*
Copyright (C) 2014 Deciso B.V. Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2007 Sam Wenham Copyright (C) 2007 Sam Wenham
All rights reserved. All rights reserved.
...@@ -27,61 +27,60 @@ ...@@ -27,61 +27,60 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
$nocsrf = true;
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("pfsense-utils.inc"); require_once("pfsense-utils.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
require_once("widgets/include/carp_status.inc");
$carp_enabled = (get_single_sysctl('net.inet.carp.allow') > 0); if (!isset($config['virtualip']['vip'])) {
$config['virtualip']['vip'] = array();
}
?> ?>
<table class="table table-striped" width="100%" border="0" cellspacing="0" cellpadding="0" summary="carp status"> <table class="table table-striped">
<?php <?php
if (isset($config['virtualip']['vip'])) { foreach ($config['virtualip']['vip'] as $carp):
$carpint=0;
foreach ($config['virtualip']['vip'] as $carp) {
if ($carp['mode'] != "carp") { if ($carp['mode'] != "carp") {
continue; continue;
} }
$ipaddress = $carp['subnet']; $status = get_carp_interface_status("{$carp['interface']}_vip{$carp['vhid']}");?>
$password = $carp['password']; <tr>
$netmask = $carp['subnet_bits']; <td>
$vhid = $carp['vhid']; <span class="glyphicon glyphicon-transfer text-success"></span>&nbsp;
$advskew = $carp['advskew']; <strong>
$status = get_carp_interface_status("{$carp['interface']}_vip{$vhid}"); <a href="/system_hasync.php">
?> <span><?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($carp['interface']) . "@{$carp['vhid']}");?></span>
<tr> </a>
<td class="vncellt" width="35%"> </strong>
<span alt="cablenic" class="glyphicon glyphicon-transfer text-success"></span>&nbsp; </td>
<strong><a href="/system_hasync.php"> <td>
<span><?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($carp['interface']) . "@{$vhid}");?></span></a></strong>
</td>
<td width="65%" class="listr">
<?php <?php
if ($carp_enabled == false) { if (get_single_sysctl('net.inet.carp.allow') <= 0 ) {
$status = gettext("DISABLED"); $status = gettext("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 { } elseif ($status == gettext("MASTER")) {
if ($status == gettext("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>";
} elseif ($status == gettext("BACKUP")) { } elseif ($status == gettext("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>";
} elseif ($status == gettext("INIT")) { } elseif ($status == gettext("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 (!empty($carp['subnet'])):?>
if ($ipaddress) { &nbsp;
?> &nbsp;
<?=htmlspecialchars($status);?> &nbsp; <?=htmlspecialchars($status);?> &nbsp;
<?=htmlspecialchars($ipaddress); <?=htmlspecialchars($carp['subnet']);?>
}?> <?php
</td></tr><?php endif;?>
} </td>
} else { </tr>
?> <?php
<tr><td class="listr"><?= sprintf(gettext('No CARP Interfaces Defined. Click %shere%s to configure CARP.'), '<a href="carp_status.php">', '</a>'); ?></td></tr> endforeach;
if (count($config['virtualip']['vip']) == 0):?>
<tr>
<td>
<?= sprintf(gettext('No CARP Interfaces Defined. Click %shere%s to configure CARP.'), '<a href="carp_status.php">', '</a>'); ?>
</td>
</tr>
<?php <?php
} ?> endif;?>
</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