summaryrefslogtreecommitdiffhomepage
path: root/contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-04-27 11:04:48 +0000
committerSteven Barth <steven@midlink.org>2008-04-27 11:04:48 +0000
commit706da44cf275dc20426a55a4d01ed79026d3eb80 (patch)
treef0cfced76009f7548a79d211a84fcb171079f028 /contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi
parentf917c0bb6445794cc94ff895f430db84a9e77ea2 (diff)
* Reworked Luci-Splash
* Created ffluci-system-addons package for Kamikaze addons
Diffstat (limited to 'contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi')
-rw-r--r--contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi39
1 files changed, 39 insertions, 0 deletions
diff --git a/contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi b/contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi
new file mode 100644
index 000000000..4cbddc0c5
--- /dev/null
+++ b/contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi
@@ -0,0 +1,39 @@
+#!/usr/bin/haserl --shell=luac
+package.path = "/usr/lib/lua/?.lua;/usr/lib/lua/?/init.lua;" .. package.path
+package.cpath = "/usr/lib/lua/?.so;" .. package.cpath
+
+require("ffluci.http")
+require("ffluci.sys")
+require("ffluci.model.uci")
+
+local srv
+local ip = ffluci.http.remote_addr()
+for k, v in pairs(ffluci.model.uci.show("network").network) do
+ if v[".type"] == "interface" and v.ipaddr then
+ local p = ffluci.sys.net.mask4prefix(v.netmask)
+ if ffluci.sys.net.belongs(ip, v.ipaddr, p) then
+ srv = v.ipaddr
+ break
+ end
+ end
+end
+
+if not srv then
+ ffluci.http.textheader()
+ return print("Unable to detect network settings!")
+end
+
+local action = "splash"
+
+local mac = ffluci.sys.net.ip4mac(ip)
+if not mac then
+ action = "unknown"
+end
+
+local status = ffluci.sys.exec("luci-splash status "..mac)
+
+if status == "whitelisted" or status == "lease" then
+ action = "allowed"
+end
+
+ffluci.http.redirect("http://" .. srv .. "/cgi-bin/luci-splash/" .. action) \ No newline at end of file