Fix up the formatting of the Wake on LAN widget and change the code style so it isn't a bunch of echos. Fixes #5960

This commit is contained in:
jim-p 2016-03-07 11:47:57 -05:00
parent 4af2649f7f
commit b35edfe772

View File

@ -78,32 +78,39 @@ if (is_array($config['wol']['wolentry'])) {
</thead>
<tbody>
<?php
if (count($wolcomputers) > 0) {
foreach ($wolcomputers as $wolent) {
echo '<tr><td>' . $wolent['descr'] . '<br />' . $wolent['mac'] . '</td>' . "\n";
echo '<td>' . convert_friendly_interface_to_friendly_descr($wolent['interface']) . '</td>' . "\n";
if (count($wolcomputers) > 0):
foreach ($wolcomputers as $wolent):
$is_active = exec("/usr/sbin/arp -an |/usr/bin/grep {$wolent['mac']}| /usr/bin/wc -l|/usr/bin/awk '{print $1;}'");
$status = exec("/usr/sbin/arp -an | /usr/bin/awk '$4 == \"{$wolent['mac']}\" { print $7 }'");
if ($status == 'expires') {
echo '<i class="fa fa-arrow-right" data-toggle="tooltip" title="' . gettext("Online") . '"></i>';
} else if ($status == 'permanent') {
echo '<td class="text-center">' . "\n";
echo '<i class="fa fa-arrow-right" data-toggle="tooltip" title="' . gettext("Static ARP") . '"></i>';
} else {
echo '<td class="text-center">' . "\n";
echo '<i class="fa fa-ban" data-toggle="tooltip" title="' . gettext("Offline") . '"></i>';
}
echo "</td>\n<td>";
echo "<a href='services_wol.php?mac={$wolent['mac']}&amp;if={$wolent['interface']}'> ";
echo '<i class="fa fa-bed" data-toggle="tooltip" title="' . gettext("Wake up!") . '"></i></a>' . "\n";
echo "</td></tr>\n";
}
} else {
echo "<tr><td colspan=\"4\" class=\"text-center\">" . gettext("No saved WoL addresses") . ".</td></tr>\n";
}
?>
<tr>
<td>
<?= $wolent['descr'] ?><br />
<?= $wolent['mac'] ?>
</td>
<td>
<?= convert_friendly_interface_to_friendly_descr($wolent['interface']) ?>
</td>
<td class="text-center">
<?php if ($status == 'expires'): ?>
<i class="fa fa-arrow-right" data-toggle="tooltip" title="<?= gettext("Online") ?>"></i>
<?php elseif ($status == 'permanent'): ?>
<i class="fa fa-arrow-right" data-toggle="tooltip" title="<?= gettext("Static ARP") ?>"></i>
<?php else: ?>
<i class="fa fa-ban" data-toggle="tooltip" title="<?= gettext("Offline") ?>"></i>
<?php endif; ?>
</td>
<td>
<a href="services_wol.php?mac=<?= $wolent['mac'] ?>&amp;if=<?= $wolent['interface']?>">
<i class="fa fa-bed" data-toggle="tooltip" title="<?= gettext("Wake up!") ?>"></i>
</a>
</td>
</tr>
<?php endforeach;
else: ?>
<tr><td colspan="4" class="text-center"><?= gettext("No saved WoL addresses") ?></td></tr>
<?php
endif;
?>
</tbody>
</table>