diff options
author | Steven Barth <steven@midlink.org> | 2008-05-08 15:37:41 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-05-08 15:37:41 +0000 |
commit | aa9ccf77c6648515ba58c37b9345cdbd561028db (patch) | |
tree | b0270202d47b6c5e179f8475302bb3ef0d1c9402 /applications/luci-splash/root/usr | |
parent | a3a51464fd8cffa6d18fa3f18be9c699901abd0d (diff) |
* Mördercommit ;-)
* Major Repository Reorganisation
* API 0.4 Softfreeze to come
Diffstat (limited to 'applications/luci-splash/root/usr')
-rw-r--r-- | applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi | 52 | ||||
-rw-r--r-- | applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html | 10 |
2 files changed, 62 insertions, 0 deletions
diff --git a/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi new file mode 100644 index 0000000000..3bff85ee51 --- /dev/null +++ b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi @@ -0,0 +1,52 @@ +#!/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 net +local ip = ffluci.http.remote_addr() +for k, v in pairs(ffluci.model.uci.sections("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 + net = k + srv = v.ipaddr + break + end + end +end + +local stat = false +for k, v in pairs(ffluci.model.uci.sections("luci_splash")) do + if v[".type"] == "iface" and v.network == net then + stat = true + end +end + +if not srv then + ffluci.http.textheader() + return print("Unable to detect network settings!") +end + +if not stat then + ffluci.http.redirect("http://" .. srv) +end + +local action = "splash" + +local mac = ffluci.sys.net.ip4mac(ip) +if not mac then + action = "unknown" +end + +local status = ffluci.sys.execl("luci-splash status "..mac)[1] + +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/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html new file mode 100644 index 0000000000..58387a5fec --- /dev/null +++ b/applications/luci-splash/root/usr/lib/luci-splash/htdocs/index.html @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="refresh" content="0; URL=/cgi-bin/index.cgi" /> +</head> +<body style="background-color: black"> +<a style="color: white; text-decoration: none" href="/cgi-bin/index.cgi">FFLuCI - Freifunk Lua Configuration Interface</a> +</body> +</html>
\ No newline at end of file |