* Rewrote Luci to be coroutine-safe allowing the use of non-forking webservers
[project/luci.git] / applications / luci-splash / luasrc / controller / splash / splash.lua
1 module("luci.controller.splash.splash", package.seeall)
2
3 function index()
4 local page = node("admin", "services", "splash")
5 page.target = cbi("splash/splash")
6 page.title = "Client-Splash"
7
8 node("splash", "splash", "activate").target = call("action_activate")
9 node("splash", "splash", "allowed").target = call("action_allowed")
10 node("splash", "splash", "unknown").target = call("action_unknown")
11 node("splash", "splash", "splash").target = template("splash_splash/splash")
12 end
13
14 function action_activate()
15 local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR"))
16 if mac and luci.http.formvalue("accept") then
17 os.execute("luci-splash add "..mac.." >/dev/null 2>&1")
18 luci.http.redirect(luci.model.uci.get("freifunk", "community", "homepage"))
19 else
20 luci.http.redirect(luci.dispatcher.build_url())
21 end
22 end
23
24 function action_allowed()
25 luci.http.redirect(luci.dispatcher.build_url())
26 end
27
28 function action_unknown()
29 luci.http.redirect(luci.dispatcher.build_url())
30 end