From e895253a9b6b165f94af3480de59020617b7117c Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 27 Apr 2008 11:10:09 +0000 Subject: * Fixed broken commit --- .../src/luci-splash/htdocs/cgi-bin/index.cgi | 39 ++++++++++++++++++++++ .../src/luci-splash/htdocs/index.html | 10 ++++++ 2 files changed, 49 insertions(+) create mode 100644 contrib/package/ffluci-splash/src/luci-splash/htdocs/cgi-bin/index.cgi create mode 100644 contrib/package/ffluci-splash/src/luci-splash/htdocs/index.html (limited to 'contrib/package/ffluci-splash/src/luci-splash/htdocs') 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 0000000000..4cbddc0c5b --- /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 diff --git a/contrib/package/ffluci-splash/src/luci-splash/htdocs/index.html b/contrib/package/ffluci-splash/src/luci-splash/htdocs/index.html new file mode 100644 index 0000000000..58387a5fec --- /dev/null +++ b/contrib/package/ffluci-splash/src/luci-splash/htdocs/index.html @@ -0,0 +1,10 @@ + + + + + + + +FFLuCI - Freifunk Lua Configuration Interface + + \ No newline at end of file -- cgit v1.2.3