diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2014-12-03 15:17:05 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-08 16:26:20 +0100 |
commit | 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 (patch) | |
tree | 35e16f100466e4e00657199b38bb3d87d52bf73f /applications/luci-app-splash/luasrc | |
parent | 9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4 (diff) |
Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names
* Make each LuCI module its own standalone package
* Deploy a shared luci.mk which is used by each module Makefile
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'applications/luci-app-splash/luasrc')
8 files changed, 803 insertions, 0 deletions
diff --git a/applications/luci-app-splash/luasrc/controller/splash/splash.lua b/applications/luci-app-splash/luasrc/controller/splash/splash.lua new file mode 100644 index 000000000..97d040082 --- /dev/null +++ b/applications/luci-app-splash/luasrc/controller/splash/splash.lua @@ -0,0 +1,151 @@ +module("luci.controller.splash.splash", package.seeall) + +local uci = luci.model.uci.cursor() +local util = require "luci.util" + +function index() + entry({"admin", "services", "splash"}, cbi("splash/splash"), _("Client-Splash"), 90) + entry({"admin", "services", "splash", "splashtext" }, form("splash/splashtext"), _("Splashtext"), 10) + + local e + + e = node("splash") + e.target = call("action_dispatch") + + node("splash", "activate").target = call("action_activate") + node("splash", "splash").target = template("splash_splash/splash") + node("splash", "blocked").target = template("splash/blocked") + + entry({"admin", "status", "splash"}, call("action_status_admin"), _("Client-Splash")) + + local page = node("splash", "publicstatus") + page.target = call("action_status_public") + page.leaf = true +end + +function action_dispatch() + local uci = luci.model.uci.cursor_state() + local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or "" + local access = false + + uci:foreach("luci_splash", "lease", function(s) + if s.mac and s.mac:lower() == mac then access = true end + end) + uci:foreach("luci_splash", "whitelist", function(s) + if s.mac and s.mac:lower() == mac then access = true end + end) + + if #mac > 0 and access then + luci.http.redirect(luci.dispatcher.build_url()) + else + luci.http.redirect(luci.dispatcher.build_url("splash", "splash")) + end +end + +function blacklist() + leased_macs = { } + uci:foreach("luci_splash", "blacklist", + function(s) leased_macs[s.mac:lower()] = true + end) + return leased_macs +end + +function action_activate() + local ip = luci.http.getenv("REMOTE_ADDR") or "127.0.0.1" + local mac = luci.sys.net.ip4mac(ip:match("^[\[::ffff:]*(%d+.%d+%.%d+%.%d+)\]*$")) + local uci_state = require "luci.model.uci".cursor_state() + local blacklisted = false + if mac and luci.http.formvalue("accept") then + uci:foreach("luci_splash", "blacklist", + function(s) if s.mac:lower() == mac or s.mac == mac then blacklisted = true end + end) + if blacklisted then + luci.http.redirect(luci.dispatcher.build_url("splash" ,"blocked")) + else + local redirect_url = uci:get("luci_splash", "general", "redirect_url") + if not redirect_url then + redirect_url = uci_state:get("luci_splash_locations", mac:gsub(':', ''):lower(), "location") + end + if not redirect_url then + redirect_url = luci.model.uci.cursor():get("freifunk", "community", "homepage") or 'http://www.freifunk.net' + end + remove_redirect(mac:gsub(':', ''):lower()) + os.execute("luci-splash lease "..mac.." >/dev/null 2>&1") + luci.http.redirect(redirect_url) + end + else + luci.http.redirect(luci.dispatcher.build_url()) + end +end + +function action_status_admin() + local uci = luci.model.uci.cursor_state() + local macs = luci.http.formvaluetable("save") + + local changes = { + whitelist = { }, + blacklist = { }, + lease = { }, + remove = { } + } + + for key, _ in pairs(macs) do + local policy = luci.http.formvalue("policy.%s" % key) + local mac = luci.http.protocol.urldecode(key) + + if policy == "whitelist" or policy == "blacklist" then + changes[policy][#changes[policy]+1] = mac + elseif policy == "normal" then + changes["lease"][#changes["lease"]+1] = mac + elseif policy == "kicked" then + changes["remove"][#changes["remove"]+1] = mac + end + end + + if #changes.whitelist > 0 then + os.execute("luci-splash whitelist %s >/dev/null" + % table.concat(changes.whitelist)) + end + + if #changes.blacklist > 0 then + os.execute("luci-splash blacklist %s >/dev/null" + % table.concat(changes.blacklist)) + end + + if #changes.lease > 0 then + os.execute("luci-splash lease %s >/dev/null" + % table.concat(changes.lease)) + end + + if #changes.remove > 0 then + os.execute("luci-splash remove %s >/dev/null" + % table.concat(changes.remove)) + end + + luci.template.render("admin_status/splash", { is_admin = true }) +end + +function action_status_public() + luci.template.render("admin_status/splash", { is_admin = false }) +end + +function remove_redirect(mac) + local mac = mac:lower() + mac = mac:gsub(":", "") + local uci = require "luci.model.uci".cursor_state() + local redirects = uci:get_all("luci_splash_locations") + --uci:load("luci_splash_locations") + uci:revert("luci_splash_locations") + -- For all redirects + for k, v in pairs(redirects) do + if v[".type"] == "redirect" then + if v[".name"] ~= mac then + -- Rewrite state + uci:section("luci_splash_locations", "redirect", v[".name"], { + location = v.location + }) + end + end + end + uci:save("luci_splash_redirects") +end diff --git a/applications/luci-app-splash/luasrc/model/cbi/splash/splash.lua b/applications/luci-app-splash/luasrc/model/cbi/splash/splash.lua new file mode 100644 index 000000000..206ef7053 --- /dev/null +++ b/applications/luci-app-splash/luasrc/model/cbi/splash/splash.lua @@ -0,0 +1,87 @@ +--[[ +LuCI - Lua Configuration Interface + +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.uci") + +m = Map("luci_splash", translate("Client-Splash"), translate("Client-Splash is a hotspot authentification system for wireless mesh networks.")) + +s = m:section(NamedSection, "general", "core", translate("General")) +s.addremove = false + +s:option(Value, "leasetime", translate("Clearance time"), translate("Clients that have accepted the splash are allowed to use the network for that many hours.")) +local redir = s:option(Value, "redirect_url", translate("Redirect target"), translate("Clients are redirected to this page after they have accepted the splash. If this is left empty they are redirected to the page they had requested.")) +redir.rmempty = true + +s:option(Value, "limit_up", translate("Upload limit"), translate("Clients upload speed is limited to this value (kbyte/s)")) +s:option(Value, "limit_down", translate("Download limit"), translate("Clients download speed is limited to this value (kbyte/s)")) + +s:option(DummyValue, "_tmp", "", + translate("Bandwidth limit for clients is only activated when both up- and download limit are set. " .. + "Use a value of 0 here to completely disable this limitation. Whitelisted clients are not limited.")) + +s = m:section(TypedSection, "iface", translate("Interfaces"), translate("Interfaces that are used for Splash.")) + +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true + +local uci = luci.model.uci.cursor() + +zone = s:option(ListValue, "zone", translate("Firewall zone"), + translate("Splash rules are integrated in this firewall zone")) + +uci:foreach("firewall", "zone", + function (section) + zone:value(section.name) + end) + +iface = s:option(ListValue, "network", translate("Network"), + translate("Intercept client traffic on this Interface")) + +uci:foreach("network", "interface", + function (section) + if section[".name"] ~= "loopback" then + iface:value(section[".name"]) + end + end) + +uci:foreach("network", "alias", + function (section) + iface:value(section[".name"]) + end) + + +s = m:section(TypedSection, "whitelist", translate("Whitelist"), + translate("MAC addresses of whitelisted clients. These do not need to accept the splash and are not bandwidth limited.")) + +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true +s:option(Value, "mac", translate ("MAC Address")) + + +s = m:section(TypedSection, "blacklist", translate("Blacklist"), + translate("MAC addresses in this list are blocked.")) + +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true +s:option(Value, "mac", translate ("MAC Address")) + +s = m:section(TypedSection, "subnet", translate("Allowed hosts/subnets"), + translate("Destination hosts and networks that are excluded from splashing, i.e. they are always allowed.")) + +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true +s:option(Value, "ipaddr", translate("IP Address")) +s:option(Value, "netmask", translate("Netmask"), translate("optional when using host addresses")).rmempty = true + +return m diff --git a/applications/luci-app-splash/luasrc/model/cbi/splash/splashtext.lua b/applications/luci-app-splash/luasrc/model/cbi/splash/splashtext.lua new file mode 100644 index 000000000..00c5aba94 --- /dev/null +++ b/applications/luci-app-splash/luasrc/model/cbi/splash/splashtext.lua @@ -0,0 +1,66 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> +Copyright 2010 Manuel Munz <freifunk@somakoma.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 +]]-- + +local fs = require "nixio.fs" + +local splashtextfile = "/usr/lib/luci-splash/splashtext.html" +local splashtextinclude = "/usr/lib/luci-splash/splashtextinclude.html" + + +f = SimpleForm("splashtext", translate("Edit the complete splash text"), + translate("You can enter your own text that is displayed to clients here.<br />" .. + "It is possible to use the following markers: " .. + "###COMMUNITY###, ###COMMUNITY_URL###, ###CONTACTURL###, ###LEASETIME###, ###LIMIT### and ###ACCEPT###.")) + +t = f:field(TextValue, "text") +t.rmempty = true +t.rows = 30 +function t.cfgvalue() + return fs.readfile(splashtextfile) or "" +end + +function f.handle(self, state, data) + if state == FORM_VALID then + if data.text then + fs.writefile(splashtextfile, data.text:gsub("\r\n", "\n")) + else + fs.unlink(splashtextfile) + end + end + return true +end + +g = SimpleForm("splashtextinclude", translate("Include your own text in the default splash"), + translate("As an alternative to editing the complete splash text you can also just include some custom text in the default splash page by entering it here.")) + +t = g:field(TextValue, "text") +t.rmempty = true +t.rows = 30 +function t.cfgvalue() + return fs.readfile(splashtextinclude) or "" +end + +function g.handle(self, state, data) + if state == FORM_VALID then + if data.text then + fs.writefile(splashtextinclude, data.text:gsub("\r\n", "\n")) + else + fs.unlink(splashtextinclude) + end + end + return true +end + + +return f, g diff --git a/applications/luci-app-splash/luasrc/view/admin_status/splash.htm b/applications/luci-app-splash/luasrc/view/admin_status/splash.htm new file mode 100644 index 000000000..61b32bab9 --- /dev/null +++ b/applications/luci-app-splash/luasrc/view/admin_status/splash.htm @@ -0,0 +1,294 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2009 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +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 + +$Id$ + +-%> + +<%- + +local utl = require "luci.util" +local ipt = require "luci.sys.iptparser".IptParser() +local uci = require "luci.model.uci".cursor_state() +local wat = require "luci.tools.webadmin" +local fs = require "nixio.fs" + +local clients = { } +local leasetime = tonumber(uci:get("luci_splash", "general", "leasetime") or 1) * 60 * 60 +local leasefile = "/tmp/dhcp.leases" + +uci:foreach("dhcp", "dnsmasq", + function(s) + if s.leasefile then leasefile = s.leasefile end + end) + + +uci:foreach("luci_splash_leases", "lease", + function(s) + if s.start and s.mac then + clients[s.mac:lower()] = { + start = tonumber(s.start), + limit = ( tonumber(s.start) + leasetime ), + mac = s.mac:upper(), + ipaddr = s.ipaddr, + policy = "normal", + packets = 0, + bytes = 0, + } + end + end) + +for _, r in ipairs(ipt:find({table="nat", chain="luci_splash_leases"})) do + if r.options and #r.options >= 2 and r.options[1] == "MAC" then + if not clients[r.options[2]:lower()] then + clients[r.options[2]:lower()] = { + start = 0, + limit = 0, + mac = r.options[2]:upper(), + policy = ( r.target == "RETURN" ) and "whitelist" or "blacklist", + packets = 0, + bytes = 0 + } + end + end +end + +for mac, client in pairs(clients) do + client.bytes_in = 0 + client.bytes_out = 0 + client.packets_in = 0 + client.packets_out = 0 + + if client.ipaddr then + local rin = ipt:find({table="mangle", chain="luci_splash_mark_in", destination=client.ipaddr}) + local rout = ipt:find({table="mangle", chain="luci_splash_mark_out", options={"MAC", client.mac:upper()}}) + + if rin and #rin > 0 then + client.bytes_in = rin[1].bytes + client.packets_in = rin[1].packets + end + + if rout and #rout > 0 then + client.bytes_out = rout[1].bytes + client.packets_out = rout[1].packets + end + end +end + +uci:foreach("luci_splash", "whitelist", + function(s) + if s.mac and clients[s.mac:lower()] then + clients[s.mac:lower()].policy="whitelist" + end + end) + +uci:foreach("luci_splash", "blacklist", + function(s) + if s.mac and clients[s.mac:lower()] then + clients[s.mac:lower()].policy=(s.kicked and "kicked" or "blacklist") + end + end) + +if fs.access(leasefile) then + for l in io.lines(leasefile) do + local time, mac, ip, name = l:match("^(%d+) (%S+) (%S+) (%S+)") + if time and mac and ip then + local c = clients[mac:lower()] + if c then + c.ip = ip + c.hostname = ( name ~= "*" ) and name or nil + end + end + end +end + +for i, a in ipairs(luci.sys.net.arptable()) do + local c = clients[a["HW address"]:lower()] + if c and not c.ip then + c.ip = a["IP address"] + end +end + +local function showmac(mac) + if not is_admin then + mac = mac:gsub("(%S%S:%S%S):%S%S:%S%S:(%S%S:%S%S)", "%1:XX:XX:%2") + end + return mac +end + +if luci.http.formvalue("status") == "1" then + local rv = {} + for _, c in utl.spairs(clients, + function(a,b) if clients[a].policy == clients[b].policy then + return (clients[a].start > clients[b].start) + else + return (clients[a].policy > clients[b].policy) + end + end) + do + if c.ip then + rv[#rv+1] = { + hostname = c.hostname or "?", + ip = c.ip or "?", + mac = showmac(c.mac) or "?", + timeleft = (c.limit >= os.time()) and wat.date_format(c.limit-os.time()) or (c.policy ~= "normal") and "-" or "expired", + trafficin = wat.byte_format(c.bytes_in) or "?", + trafficout = wat.byte_format(c.bytes_out) or "?", + policy = c.policy or "?" + } + end + end + luci.http.prepare_content("application/json") + luci.http.write_json(rv) + return +end +-%> + + + +<%+header%> + +<script type="text/javascript" src="<%=resource%>/cbi.js"></script> +<script type="text/javascript">//<![CDATA[ + + XHR.poll(10 , '<%=REQUEST_URI%>', { status: 1 }, + function(x, info) + { + var tbody = document.getElementById('splash_table'); + if (tbody) + { + var s = ''; + if (info.length == undefined) { + s += '<tr class="cbi-section-table-row"><td colspan="7" class="cbi-section-table-cell"><br /><em><%:No clients connected%></em><br /></td></tr>' + }; + for (var idx = 0; idx < info.length; idx++) + { + var splash = info[idx]; + s += String.format( + '<tr class="cbi-section-table-row cbi-rowstyle-'+(1 + (idx % 2))+'">' + + '<td class="cbi-section-table-cell">%s</td>' + + '<td class="cbi-section-table-cell">%s</td>' + + '<td class="cbi-section-table-cell">%s</td>' + + '<td class="cbi-section-table-cell">%s</td>' + + '<td class="cbi-section-table-cell">%s/%s</td>' + + '<td class="cbi-section-table-cell">', + splash.hostname, splash.ip, splash.mac, splash.timeleft, splash.trafficin, splash.trafficout); + + <% if is_admin then %> + s += String.format('<select name="policy.%s" style="width:200px">', splash.mac.toLowerCase()); + if (splash.policy == 'whitelist') { + s += '<option value="whitelist" selected="selected"><%:whitelisted%></option>' + } else { + s += '<option value="whitelist"><%:whitelisted%></option>' + }; + if (splash.policy == 'normal') { + s += '<option value="normal" selected="selected"><%:splashed%></option>'; + s += '<option value="kicked"><%:temporarily blocked%></option>' + } else { + s += '<option value="normal"><%:splashed%></option>' + }; + if (splash.policy == 'blacklist') { + s+= '<option value="blacklist" selected="selected"><%:blacklisted%></option>' + } else { + s += '<option value="blacklist"><%:blacklisted%></option>' + }; + s += String.format( + '</select>' + + '<input type="submit" class="cbi-button cbi-button-save" name="save.%s" value="<%:Save%>" />', + splash.mac.toLowerCase()); + <% else %> + s += String.format('%s', splash.policy); + <% end %> + s += '</td></tr>' + } + tbody.innerHTML = s; + } + } + ); +//]]></script> + + +<div id="cbi-splash-leases" class="cbi-map"> + <h2><a id="content" name="content"><%:Client-Splash%></a></h2> + <fieldset id="cbi-table-table" class="cbi-section"> + <legend><%:Active Clients%></legend> + <div class="cbi-section-node"> + <% if is_admin then %><form action="<%=REQUEST_URI%>" method="post"><% end %> + <table class="cbi-section-table"> + <thead> + <tr class="cbi-section-table-titles"> + <th class="cbi-section-table-cell"><%:Hostname%></th> + <th class="cbi-section-table-cell"><%:IP Address%></th> + <th class="cbi-section-table-cell"><%:MAC Address%></th> + <th class="cbi-section-table-cell"><%:Time remaining%></th> + <th class="cbi-section-table-cell"><%:Traffic in/out%></th> + <th class="cbi-section-table-cell"><%:Policy%></th> + </tr> + </thead> + <tbody id="splash_table"> + + <%- + local count = 0 + for _, c in utl.spairs(clients, + function(a,b) + if clients[a].policy == clients[b].policy then + return (clients[a].start > clients[b].start) + else + return (clients[a].policy > clients[b].policy) + end + end) + do + if c.ip then + count = count + 1 + -%> + <tr class="cbi-section-table-row cbi-rowstyle-<%=2-(count%2)%>"> + <td class="cbi-section-table-cell"><%=c.hostname or "<em>" .. translate("unknown") .. "</em>"%></td> + <td class="cbi-section-table-cell"><%=c.ip or "<em>" .. translate("unknown") .. "</em>"%></td> + <td class="cbi-section-table-cell"><%=showmac(c.mac)%></td> + <td class="cbi-section-table-cell"><%= + (c.limit >= os.time()) and wat.date_format(c.limit-os.time()) or + (c.policy ~= "normal") and "-" or "<em>" .. translate("expired") .. "</em>" + %></td> + <td class="cbi-section-table-cell"><%=wat.byte_format(c.bytes_in)%> / <%=wat.byte_format(c.bytes_out)%></td> + <td class="cbi-section-table-cell"> + <% if is_admin then %> + <select name="policy.<%=c.mac:lower()%>" style="width:200px"> + <option value="whitelist"<%=c.policy=="whitelist" and ' selected="selected"'%>><%:whitelisted%></option> + <option value="normal"<%=c.policy=="normal" and not c.kicked and ' selected="selected"'%>><%:splashed%></option> + <option value="blacklist"<%=c.policy=="blacklist" and ' selected="selected"'%>><%:blacklisted%></option> + <% if c.policy == "normal" then -%> + <option value="kicked"><%:temporarily blocked%></option> + <%- end %> + </select> + <input type="submit" class="cbi-button cbi-button-save" name="save.<%=c.mac:lower()%>" value="<%:Save%>" /> + <% else %> + <%=c.policy%> + <% end %> + </td> + </tr> + <%- + end + end + if count == 0 then + -%> + <tr class="cbi-section-table-row"> + <td colspan="7" class="cbi-section-table-cell"> + <br /><em><%:No clients connected%></em><br /> + </td> + </tr> + <%- end -%> + </tbody> + </table> + <% if is_admin then %></form><% end %> + </div> + </fieldset> +</div> + +<%+footer%> diff --git a/applications/luci-app-splash/luasrc/view/splash/blocked.htm b/applications/luci-app-splash/luasrc/view/splash/blocked.htm new file mode 100644 index 000000000..de61ecf01 --- /dev/null +++ b/applications/luci-app-splash/luasrc/view/splash/blocked.htm @@ -0,0 +1,25 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2011 Manuel Munz <freifunk at somakoma dot 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 +-%> +<% +local contacturl = luci.dispatcher.build_url("freifunk", "contact") +%> + +<%+header%> + +<h2><a id="content" name="content"><%:Blocked%></a></h2> + +<p><%:Your access to this network has been blocked, most likely because you did something that our rules explicitly forbid.%></p> +<p><%:To ask for the reason why you have been blocked or ask for access again you can try to contact the owner of this access point:%> <a href="<%=contacturl%>"><%:Contact%></a></p> + +<%+footer%> + + + diff --git a/applications/luci-app-splash/luasrc/view/splash/splash.htm b/applications/luci-app-splash/luasrc/view/splash/splash.htm new file mode 100644 index 000000000..2ebee273b --- /dev/null +++ b/applications/luci-app-splash/luasrc/view/splash/splash.htm @@ -0,0 +1,139 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> +Copyright 2011 Manuel Munz <freifunk at somakoma dot 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 +-%> +<% +local fs = require "luci.fs" +local has_custom_splash = fs.access("/usr/lib/luci-splash/splashtext.html") +local has_custom_splashinclude = fs.access("/usr/lib/luci-splash/splashtextinclude.html") + +function expand (e, R) + return (string.gsub(e, "###([A-Z_]+)###", R)) +end + +local community, homepage, leasetime, limit_up, limit_down + +local contacturl = luci.dispatcher.build_url("freifunk", "contact") + +local c = luci.model.uci.cursor():get_all("freifunk", "community") +if c and c.name then + name = luci.model.uci.cursor():get('profile_' .. c.name, 'profile', 'name') + if name then + community = name + else + community = c.name + end +else + community = "Freifunk" +end + +if c and c.homepage then + homepage = c.homepage +else + homepage = "http://freifunk.net" +end + +local s = luci.model.uci.cursor():get_all("luci_splash", "general") +if s then + leasetime = s.leasetime or "" + limit_up = s.limit_up or nil + limit_down = s.limit_down or nil +end + +local limit_text = "" +if limit_up and limit_down then + limit_text = "<p>" .. translate("Your bandwidth is limited to") .. " " .. limit_down .. "/" .. limit_up .. + " " .. translate("KB/s (Download/Upload). You may be able to remove this limit by actively contributing " .. + "to this project.") .. "</p>" +end + +local contact = translate('Get in %s with the operator of this access point.') +contact = contact % ('<a href="' .. contacturl .. '">' .. translatef('Contact') .. '</a>') + +local accepttext = translate('By accepting these rules you can use this network for %s hour(s). After this time you need to accept these rules again.') +accepttext = accepttext % leasetime + + +if has_custom_splash then + local R = { + COMMUNITY = community, + COMMUNITY_URL = homepage, + LEASETIME = leasetime, + ACCEPT = tostring(translate("Accept")), + LIMIT = limit_text, + CONTACTURL = contacturl + } + local splashtext = expand(fs.readfile("/usr/lib/luci-splash/splashtext.html"), R) + %> + <%=splashtext%> + +<% else %> + + <h2><a id="content" name="content"><%:Welcome%></a></h2> + + <p><%:You are now connected to the free wireless mesh network%> <a href="<%=homepage%>"><%=community%></a>. + <%:Please note that we are not an internet service provider but an experimental community network.%></p> + <p><%:Access to the internet might be possible nevertheless, because some activists of this project share their + private internet connections. These few connections are shared between all users. That means available bandwidth + is limited and because of this we ask you not to do any of the following:%></p> + <ul> + <li><%:use filesharing applications on this network%></li> + <li><%:waste bandwidth with unneccesary downloads or streams%></li> + <li><%:perform any kind of illegal activities%></li> + </ul> + <br /> + + <% if limit_up and limit_down then %> + <%=limit_text%> + <% end %> + + <p><%:If you use this network on a regular basis we ask for your support:%></p> + <ul> + <li><a href="<%=homepage%>"><%:Become an active member of this community and help by operating your own node%></a></li> + <li><%=contact%></li> + <li><%:Donate some money to help us keep this project alive.%></li> + <li><%:If you operate your own wifi equipment use channels different from ours.%></li> + </ul> + + <% + if has_custom_splashinclude then + local splashtextinclude = fs.readfile("/usr/lib/luci-splash/splashtextinclude.html") + %> + <%=splashtextinclude%> + <% end %> + + <h2><%:Usage Agreement%></h2> + <p> + <%:The open and free wireless network of volunteers ("Operators") provides the necessary equipment and Internet connections ("Infrastructure") at their own expense.%> + <%:These Terms of Use govern the use of the network by its participants' computer, PDA, or similar device ("Devices") within the network.%> + <%:Access to the network is not guaranteed. It can be interrupted at any time without notice for any reason, for certain devices, and/or may be blocked for certain users.%> + </p> + + <h3><%:Legally Prohibited Activities%></h3> + <p><%:The participant agrees to not perform any action and refrain from acts which may violate the law or infringe upon the rights of third parties.%></p> + + <h3><%:Legally Prohibited content%></h3> + <p><%:The participant agrees to not transfer content over the network which violates the law.%></p> + + <h3><%:Fair Use Policy%></h3> + <p><%:The participant agrees to not use the network in any way which will harm the infrastructure, the network itself, its operators or other participants.%></p> + + <h3><%:Safety%></h3> + <p><%:The network, like the Internet, is unencrypted and open. Each participant is responsible for the safety of their own connections and devices.%></p> + + <h3>Disclaimer</h3> + <p><%:The operator claims no liability for loss of data, unauthorized access/damage to devices, or financial losses that participants may suffer from the use of the network.%></p> + + <br /><p><b><%=accepttext%></b></p> +<% end %> + + + diff --git a/applications/luci-app-splash/luasrc/view/splash_splash/index.htm b/applications/luci-app-splash/luasrc/view/splash_splash/index.htm new file mode 100644 index 000000000..ab754913d --- /dev/null +++ b/applications/luci-app-splash/luasrc/view/splash_splash/index.htm @@ -0,0 +1,16 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +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 + +$Id$ + +-%> +<%+header%> +<%+footer%>
\ No newline at end of file diff --git a/applications/luci-app-splash/luasrc/view/splash_splash/splash.htm b/applications/luci-app-splash/luasrc/view/splash_splash/splash.htm new file mode 100644 index 000000000..8554913cd --- /dev/null +++ b/applications/luci-app-splash/luasrc/view/splash_splash/splash.htm @@ -0,0 +1,25 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net> + +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 + +$Id$ + +-%> +<%+header%> +<%+splash/splash%> + +<form method="get" action="<%=controller%>/splash/activate"> + <p> + <input type="submit" value="<%:Decline%>" /> + <input type="submit" name="accept" value="<%:Accept%>" /> + </p> +</form> + +<%+footer%> |