From ee324cb3a70d39dc9522a1ee63af12137d433533 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 29 Jun 2008 14:42:53 +0000 Subject: * applications/luci-splash: Rewrote luci-splash using an own daemon implementation * Minor tweaks in luci.dispatcher --- .../luasrc/controller/splash/splash.lua | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'applications/luci-splash/luasrc/controller') 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 -- cgit v1.2.3