From 045d9c1942146eb971609b637029911e4802a2e9 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sun, 11 May 2008 10:29:45 +0000 Subject: * DHCP-Splash fixes #1 --- .../usr/lib/luci-splash/htdocs/cgi-bin/index.cgi | 38 ++++++++++------------ .../luci-splash/root/www/cgi-bin/luci-splash | 4 +++ .../luci-splash/root/www/cgi-bin/luci_splash.cgi | 4 --- .../luci-splash/src/controller/controller.lua | 19 ----------- .../luci-splash/src/controller/splash/splash.lua | 19 +++++++++++ .../luci-splash/src/model/v/splash/splash.htm | 31 ++++++++++++++++++ .../src/model/v/splash_splash/index.htm | 2 ++ .../src/model/v/splash_splash/splash.htm | 7 ++++ .../luci-splash/src/model/view/splash/splash.htm | 31 ------------------ .../src/model/view/splash_splash/index.htm | 2 -- .../src/model/view/splash_splash/splash.htm | 7 ---- contrib/package/ffluci/Makefile | 1 + 12 files changed, 82 insertions(+), 83 deletions(-) create mode 100644 applications/luci-splash/root/www/cgi-bin/luci-splash delete mode 100644 applications/luci-splash/root/www/cgi-bin/luci_splash.cgi delete mode 100644 applications/luci-splash/src/controller/controller.lua create mode 100644 applications/luci-splash/src/controller/splash/splash.lua create mode 100644 applications/luci-splash/src/model/v/splash/splash.htm create mode 100644 applications/luci-splash/src/model/v/splash_splash/index.htm create mode 100644 applications/luci-splash/src/model/v/splash_splash/splash.htm delete mode 100644 applications/luci-splash/src/model/view/splash/splash.htm delete mode 100644 applications/luci-splash/src/model/view/splash_splash/index.htm delete mode 100644 applications/luci-splash/src/model/view/splash_splash/splash.htm 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 index 341aaa4b5..11430f0ac 100644 --- 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 @@ -29,24 +29,22 @@ end if not srv then ffluci.http.prepare_content("text/plain") - return print("Unable to detect network settings!") -end - -if not stat then + print("Unable to detect network settings!") +elseif 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 +else + 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) +end \ No newline at end of file diff --git a/applications/luci-splash/root/www/cgi-bin/luci-splash b/applications/luci-splash/root/www/cgi-bin/luci-splash new file mode 100644 index 000000000..188ad7aa0 --- /dev/null +++ b/applications/luci-splash/root/www/cgi-bin/luci-splash @@ -0,0 +1,4 @@ +#!/bin/sh +echo "Status: 302 Found" +echo "Location: /cgi-bin/ffluci/splash/splash$PATH_INFO" +echo \ No newline at end of file diff --git a/applications/luci-splash/root/www/cgi-bin/luci_splash.cgi b/applications/luci-splash/root/www/cgi-bin/luci_splash.cgi deleted file mode 100644 index 188ad7aa0..000000000 --- a/applications/luci-splash/root/www/cgi-bin/luci_splash.cgi +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -echo "Status: 302 Found" -echo "Location: /cgi-bin/ffluci/splash/splash$PATH_INFO" -echo \ No newline at end of file diff --git a/applications/luci-splash/src/controller/controller.lua b/applications/luci-splash/src/controller/controller.lua deleted file mode 100644 index 62088be52..000000000 --- a/applications/luci-splash/src/controller/controller.lua +++ /dev/null @@ -1,19 +0,0 @@ -module("ffluci.controller.splash.splash", package.seeall) - -function action_activate() - local mac = ffluci.sys.net.ip4mac(ffluci.http.env.REMOTE_ADDR) - if mac and ffluci.http.formvalue("accept") then - os.execute("luci-splash add "..mac.." >/dev/null 2>&1") - ffluci.http.redirect(ffluci.model.uci.get("freifunk", "community", "homepage")) - else - ffluci.http.redirect(ffluci.dispatcher.build_url()) - end -end - -function action_accepted() - ffluci.http.redirect(ffluci.dispatcher.build_url()) -end - -function action_unknown() - ffluci.http.redirect(ffluci.dispatcher.build_url()) -end \ No newline at end of file diff --git a/applications/luci-splash/src/controller/splash/splash.lua b/applications/luci-splash/src/controller/splash/splash.lua new file mode 100644 index 000000000..62088be52 --- /dev/null +++ b/applications/luci-splash/src/controller/splash/splash.lua @@ -0,0 +1,19 @@ +module("ffluci.controller.splash.splash", package.seeall) + +function action_activate() + local mac = ffluci.sys.net.ip4mac(ffluci.http.env.REMOTE_ADDR) + if mac and ffluci.http.formvalue("accept") then + os.execute("luci-splash add "..mac.." >/dev/null 2>&1") + ffluci.http.redirect(ffluci.model.uci.get("freifunk", "community", "homepage")) + else + ffluci.http.redirect(ffluci.dispatcher.build_url()) + end +end + +function action_accepted() + ffluci.http.redirect(ffluci.dispatcher.build_url()) +end + +function action_unknown() + ffluci.http.redirect(ffluci.dispatcher.build_url()) +end \ No newline at end of file diff --git a/applications/luci-splash/src/model/v/splash/splash.htm b/applications/luci-splash/src/model/v/splash/splash.htm new file mode 100644 index 000000000..db4bd0f78 --- /dev/null +++ b/applications/luci-splash/src/model/v/splash/splash.htm @@ -0,0 +1,31 @@ +

<%:welcome Willkommen%>!

+

+Du bist jetzt mit dem freien Funknetz +<%~freifunk.community.name%> verbunden.
+Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter. +

+ +

+Ein Zugang ins Internet ist trotzdem möglich, +da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen. +Diese Zugänge müssen sich hier alle teilen. +Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend: +

+

+ +

+Wenn Du unsere Idee gut findest, kannst Du uns unterstützen: +

+

+ +

+Mit einem Klick auf <%:accept Annehmen%> kannst du für <%~luci_splash.general.leasetime%> Stunden +über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren. +

\ No newline at end of file diff --git a/applications/luci-splash/src/model/v/splash_splash/index.htm b/applications/luci-splash/src/model/v/splash_splash/index.htm new file mode 100644 index 000000000..75aa02658 --- /dev/null +++ b/applications/luci-splash/src/model/v/splash_splash/index.htm @@ -0,0 +1,2 @@ +<%+header%> +<%+footer%> \ No newline at end of file diff --git a/applications/luci-splash/src/model/v/splash_splash/splash.htm b/applications/luci-splash/src/model/v/splash_splash/splash.htm new file mode 100644 index 000000000..9c165802f --- /dev/null +++ b/applications/luci-splash/src/model/v/splash_splash/splash.htm @@ -0,0 +1,7 @@ +<%+header%> +<%+splash/splash%> +
+ + +
+<%+footer%> \ No newline at end of file diff --git a/applications/luci-splash/src/model/view/splash/splash.htm b/applications/luci-splash/src/model/view/splash/splash.htm deleted file mode 100644 index db4bd0f78..000000000 --- a/applications/luci-splash/src/model/view/splash/splash.htm +++ /dev/null @@ -1,31 +0,0 @@ -

<%:welcome Willkommen%>!

-

-Du bist jetzt mit dem freien Funknetz -<%~freifunk.community.name%> verbunden.
-Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter. -

- -

-Ein Zugang ins Internet ist trotzdem möglich, -da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen. -Diese Zugänge müssen sich hier alle teilen. -Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend: -

-

- -

-Wenn Du unsere Idee gut findest, kannst Du uns unterstützen: -

-

- -

-Mit einem Klick auf <%:accept Annehmen%> kannst du für <%~luci_splash.general.leasetime%> Stunden -über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren. -

\ No newline at end of file diff --git a/applications/luci-splash/src/model/view/splash_splash/index.htm b/applications/luci-splash/src/model/view/splash_splash/index.htm deleted file mode 100644 index 75aa02658..000000000 --- a/applications/luci-splash/src/model/view/splash_splash/index.htm +++ /dev/null @@ -1,2 +0,0 @@ -<%+header%> -<%+footer%> \ No newline at end of file diff --git a/applications/luci-splash/src/model/view/splash_splash/splash.htm b/applications/luci-splash/src/model/view/splash_splash/splash.htm deleted file mode 100644 index 9c165802f..000000000 --- a/applications/luci-splash/src/model/view/splash_splash/splash.htm +++ /dev/null @@ -1,7 +0,0 @@ -<%+header%> -<%+splash/splash%> -
- - -
-<%+footer%> \ No newline at end of file diff --git a/contrib/package/ffluci/Makefile b/contrib/package/ffluci/Makefile index af17aa57a..8f1d7f0aa 100644 --- a/contrib/package/ffluci/Makefile +++ b/contrib/package/ffluci/Makefile @@ -156,6 +156,7 @@ define Package/ffluci-app-splash/install $(INSTALL_BIN) $(PKG_BUILD_DIR)/applications/luci-splash/dist/etc/init.d/luci_splash $(1)/etc/init.d $(INSTALL_BIN) $(PKG_BUILD_DIR)/applications/luci-splash/dist/etc/cron.minutely/luci_splash $(1)/etc/cron.minutely $(INSTALL_BIN) $(PKG_BUILD_DIR)/applications/luci-splash/dist/usr/lib/luci-splash/htdocs/cgi-bin/index.cgi $(1)/usr/lib/luci-splash/htdocs/cgi-bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/applications/luci-splash/dist/www/cgi-bin/luci-splash $(1)/www/cgi-bin/luci-splash endef -- cgit v1.2.3