add dhcp leases page for webif
authorFelix Fietkau <nbd@openwrt.org>
Tue, 17 Jan 2006 15:16:46 +0000 (15:16 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 17 Jan 2006 15:16:46 +0000 (15:16 +0000)
SVN-Revision: 3002

openwrt/package/webif/files/www/cgi-bin/webif/leases.sh [new file with mode: 0755]

diff --git a/openwrt/package/webif/files/www/cgi-bin/webif/leases.sh b/openwrt/package/webif/files/www/cgi-bin/webif/leases.sh
new file mode 100755 (executable)
index 0000000..ddf5065
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/haserl
+<? 
+. /usr/lib/webif/webif.sh
+header "Status" "DHCP" "DHCP leases"
+?>
+<table style="width: 90%; text-align: left;" border="0" cellpadding="2" cellspacing="2" align="center">
+<tbody>
+       <tr>
+               <th>MAC Address</th>
+               <th>IP Address</th>
+               <th>Name</th>
+               <th>Expires in</th>
+       </tr>
+<? [ -e /tmp/dhcp.leases ] && awk -vdate="$(date +%s)" '
+$1 > 0 {
+       print "<tr>"
+       print "<td>" $2 "</td>"
+       print "<td>" $3 "</td>"
+       print "<td>" $4 "</td>"
+       print "<td>"
+       t = $1 - date
+       h = int(t / 60 / 60)
+       if (h > 0) printf h "h "
+       m = int(t / 60 % 60)
+       if (m > 0) printf m "min "
+       s = int(t % 60)
+       printf s "sec "
+       printf "</td>"
+       print "</tr>"
+}
+' /tmp/dhcp.leases ?>
+</tbody>
+</table>
+
+<? footer ?>
+<!--
+##WEBIF:name:Status:2:DHCP
+-->