luci/applications/luci-splash/luasrc/controller/splash/splash.lua

30 lines
1.1 KiB
Lua
Raw Normal View History

module("luci.controller.splash.splash", package.seeall)
2008-04-27 11:16:31 +00:00
2008-05-22 14:04:03 +00:00
function index()
entry({"admin", "services", "splash"}, cbi("splash/splash"), "Client-Splash")
2008-05-22 14:04:03 +00:00
node("splash").target = call("action_dispatch")
2008-05-27 20:39:48 +00:00
node("splash", "splash", "activate").target = call("action_activate")
2008-05-22 14:04:03 +00:00
node("splash", "splash", "splash").target = template("splash_splash/splash")
end
function action_dispatch()
2008-07-15 22:55:25 +00:00
local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) or ""
local status = luci.util.execl("luci-splash status "..mac)[1]
2008-07-15 22:55:25 +00:00
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", "splash"))
end
end
2008-04-27 11:16:31 +00:00
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")
2008-08-26 23:00:44 +00:00
luci.http.redirect(luci.model.uci.cursor():get("freifunk", "community", "homepage"))
else
luci.http.redirect(luci.dispatcher.build_url())
end
2008-07-15 22:55:25 +00:00
end