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