blob: 5731efc8ca5b6aed2767f09fb2a483cb3b20762a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
module("luci.controller.splash.splash", package.seeall)
function index()
entry({"admin", "services", "splash"}, cbi("splash/splash"), "Client-Splash")
node("splash").target = call("action_dispatch")
node("splash", "activate").target = call("action_activate")
node("splash", "splash").target = template("splash_splash/splash")
end
function action_dispatch()
local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or ""
local status = luci.util.execl("luci-splash status "..mac)[1]
if #mac > 0 and ( status == "whitelisted" or status == "lease" ) then
luci.http.redirect(luci.dispatcher.build_url())
else
luci.http.redirect(luci.dispatcher.build_url("splash", "splash"))
end
end
function action_activate()
local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR"))
if mac and luci.http.formvalue("accept") then
os.execute("luci-splash add "..mac.." >/dev/null 2>&1")
luci.http.redirect(luci.model.uci.cursor():get("freifunk", "community", "homepage"))
else
luci.http.redirect(luci.dispatcher.build_url())
end
end
|