<%#
Opennet Firmware

Copyright 2015 Lars Kruse <devel@sumpfralle.de>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

-%>

<%
	require("luci.model.opennet.funcs")
	require("luci.model.opennet.urls") 
%>
<%+header%>

<h2><a id="content" name="content"><%:Public Hotspot%></a></h2>
<%= html_display_message_list(on_errors, "error") %>


<div class="cbi-map">
<div class="cbi-map-descr">
	<p><%:You may want to run a public hotspot in your area.%></p>
	<p><%:This requires a working VPN connection:%>
		<a href="<%= on_url("mig_openvpn") %>"><%:VPN Tunnel%></a></p>
	<p><%:Disable the Hotspot feature by removing the physical device from the 'free' network interface.%></p>
	<p><%:Users do not need to authenticate themselves.%></p>
</div>

<%# list of hotspot clients %>
<fieldset class="cbi-section">
	<legend><%:Hotspot Clients%></legend>
	<div class="cbi-section-descr">
		<%:The hotspot client list is only available locally.%>
	</div>
	<table class="cbi-section-table">
		<tr class="cbi-section-table-titles">
			<th><%:Number%></th>
			<th><%:Local IP Address%></th>
			<th><%:Client MAC Address%></th>
			<th><%:Connected since%></th>
			<th><%:Download (Packets)%></th>
			<th><%:Upload (Packets)%></th>
		</tr>
		<% for index, client_info in ipairs(line_split(on_function("get_captive_portal_clients"))) do %>
		<tr class="cbi-section-table-row">
			<td class="cbi-value-field"><%=index%></td>
			<% local details = tab_split(client_info) %>
			<%# IP-Adresse %>
			<td class="cbi-value-field"><%= details[1] %></td>
			<%# MAC-Adresse %>
			<td class="cbi-value-field"><%= details[2] %></td>
			<%# Verbindungsbeginn %>
			<td class="cbi-value-field"><%= luci.util.pcdata(get_timestamp_age_string(tonumber(details[3]))) %></td>
			<%# Download %>
			<td class="cbi-value-field"><%= details[4] %></td>
			<%# Upload %>
			<td class="cbi-value-field"><%= details[5] %></td>
		</tr>
		<% end %>
	</table>
</fieldset>
</div>

<%+footer%>
