X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=applications%2Fluci-splash%2Fluasrc%2Fcontroller%2Fsplash%2Fsplash.lua;h=6512ee5b1918c524f647440dbf2af76b75dfd6d3;hb=ee324cb3a70d39dc9522a1ee63af12137d433533;hp=617e0f877ce6bdddb428c6e5bf741c1b358fa0f5;hpb=4c7df626b2a27e9bea4793c96929de17f38e7bd2;p=project%2Fluci.git diff --git a/applications/luci-splash/luasrc/controller/splash/splash.lua b/applications/luci-splash/luasrc/controller/splash/splash.lua index 617e0f877..6512ee5b1 100644 --- a/applications/luci-splash/luasrc/controller/splash/splash.lua +++ b/applications/luci-splash/luasrc/controller/splash/splash.lua @@ -1,16 +1,23 @@ module("luci.controller.splash.splash", package.seeall) function index() - local page = node("admin", "services", "splash") - page.target = cbi("splash/splash") - page.title = "Client-Splash" + entry({"admin", "services", "splash"}, cbi("splash/splash"), "Client-Splash") + node("splash").target = call("action_dispatch") node("splash", "splash", "activate").target = call("action_activate") - node("splash", "splash", "allowed").target = call("action_allowed") - node("splash", "splash", "unknown").target = call("action_unknown") node("splash", "splash", "splash").target = template("splash_splash/splash") end +function action_dispatch() + local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) + local status = luci.sys.execl("luci-splash status "..mac)[1] + if 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 + function action_activate() local mac = luci.sys.net.ip4mac(luci.http.getenv("REMOTE_ADDR")) if mac and luci.http.formvalue("accept") then @@ -19,12 +26,4 @@ function action_activate() else luci.http.redirect(luci.dispatcher.build_url()) end -end - -function action_allowed() - luci.http.redirect(luci.dispatcher.build_url()) -end - -function action_unknown() - luci.http.redirect(luci.dispatcher.build_url()) end \ No newline at end of file