summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-11-24 16:13:57 +0200
committerTimo Teräs <timo.teras@iki.fi>2010-11-24 16:13:57 +0200
commita0ed0e6bc7809e88ee1272fa9516dd7e3c7e8d2d (patch)
treeb7503d54f52793a9d9c8c931f5fab2089c9db016
parent301047f944320fccef17df3431ddd0bd5d1455a0 (diff)
downloadsquark-a0ed0e6bc7809e88ee1272fa9516dd7e3c7e8d2d.tar.bz2
squark-a0ed0e6bc7809e88ee1272fa9516dd7e3c7e8d2d.tar.xz
www: add a set of example pages for block info and captive portalv0.1
Relatively simple set of pages done in haserl. Fixes #448.
-rw-r--r--Makefile5
-rw-r--r--www/Makefile7
-rw-r--r--www/README13
-rw-r--r--www/background.pngbin0 -> 976 bytes
-rwxr-xr-xwww/do-login.cgi19
-rwxr-xr-xwww/do-logout.cgi6
-rwxr-xr-xwww/do-override.cgi6
-rwxr-xr-xwww/info.cgi44
-rwxr-xr-xwww/login.cgi49
-rw-r--r--www/style.css113
-rwxr-xr-xwww/warning.cgi37
-rw-r--r--www/warning.pngbin0 -> 2748 bytes
-rw-r--r--www/worldmap.pngbin0 -> 42493 bytes
13 files changed, 297 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 676b01f..500282a 100644
--- a/Makefile
+++ b/Makefile
@@ -11,18 +11,19 @@ DESTDIR:=
BINDIR:=/usr/bin
SBINDIR:=/usr/sbin
CONFDIR:=/etc/$(PACKAGE)
+WWWDIR:=/usr/share/$(PACKAGE)/www
MANDIR:=/usr/share/man
DOCDIR:=/usr/share/doc/$(PACKAGE)
STATEDIR:=/var/run
LIBDIR:=/var/lib/$(PACKAGE)
LUALIBDIR:=/usr/lib/lua/5.1
-export DESTDIR BINDIR SBINDIR CONFDIR MANDIR DOCDIR STATEDIR LIBDIR LUALIBDIR
+export DESTDIR BINDIR SBINDIR CONFDIR WWWDIR MANDIR DOCDIR STATEDIR LIBDIR LUALIBDIR
##
# Top-level rules and targets
-targets := src/ man/
+targets := src/ man/ www/
##
# Include all rules and stuff
diff --git a/www/Makefile b/www/Makefile
new file mode 100644
index 0000000..e9dcac1
--- /dev/null
+++ b/www/Makefile
@@ -0,0 +1,7 @@
+CGIBIN_FILES = $(wildcard $(src)/*.cgi)
+STATIC_FILES = $(wildcard $(src)/*.png $(src)/*.css)
+
+install:
+ $(INSTALLDIR) $(DESTDIR)$(WWWDIR)/cgi-bin $(DESTDIR)$(WWWDIR)/static
+ $(INSTALL) $(CGIBIN_FILES) $(DESTDIR)$(WWWDIR)/cgi-bin
+ $(INSTALL) $(STATIC_FILES) $(DESTDIR)$(WWWDIR)/static
diff --git a/www/README b/www/README
new file mode 100644
index 0000000..588c574
--- /dev/null
+++ b/www/README
@@ -0,0 +1,13 @@
+Here is an example set of captive portal and warning page web pages.
+The haserl scripts and other contents in this directory are part of
+squark suite and licensed under the GPL with the below mentioned
+exceptions.
+
+warning.png
+ From Tango Icon library (Public Domain). Credits go to Tango Desktop
+ Project.
+
+worldmap.png
+ Slightly modified version of:
+ http://www.webresourcesdepot.com/wp-content/uploads/image/free-world-map-black-white.gif
+ Should be free to use.
diff --git a/www/background.png b/www/background.png
new file mode 100644
index 0000000..58baf13
--- /dev/null
+++ b/www/background.png
Binary files differ
diff --git a/www/do-login.cgi b/www/do-login.cgi
new file mode 100755
index 0000000..e4afce8
--- /dev/null
+++ b/www/do-login.cgi
@@ -0,0 +1,19 @@
+#!/usr/bin/haserl
+HTTP/1.0 302 Found
+Location: <?
+ok=no
+
+# fixed password
+[ "$POST_password" = "1234" ] && ok=yes
+
+# Radius authentication
+# echo -e "User-Name = \"$POST_username\"\nUser-Password = \"$POST_password\"\nNAS-IP-Address = $REMOTE_ADDR\n" | radclient -x RADIUS-SERVER-IP auth RADIUS-PASSWORD >& /dev/null && ok=yes
+
+if [ "$ok" = "yes" ]; then
+ squark-auth-ip -i $REMOTE_ADDR -u $POST_username -l
+ echo -n "info.cgi"
+else
+ echo -n "login.cgi?REASON=fail"
+fi ?>
+
+Moved.
diff --git a/www/do-logout.cgi b/www/do-logout.cgi
new file mode 100755
index 0000000..34a07e4
--- /dev/null
+++ b/www/do-logout.cgi
@@ -0,0 +1,6 @@
+#!/usr/bin/haserl
+HTTP/1.0 302 Found
+Location: login.cgi
+
+Moved.
+<? squark-auth-ip -i $REMOTE_ADDR -L ?>
diff --git a/www/do-override.cgi b/www/do-override.cgi
new file mode 100755
index 0000000..b5ad0f2
--- /dev/null
+++ b/www/do-override.cgi
@@ -0,0 +1,6 @@
+#!/usr/bin/haserl
+HTTP/1.0 302 Found
+Location: <? echo -n ${GET_DENIEDURL} ?>
+
+Moved.
+<? squark-auth-ip -i $REMOTE_ADDR -o ?>
diff --git a/www/info.cgi b/www/info.cgi
new file mode 100755
index 0000000..b2e86cf
--- /dev/null
+++ b/www/info.cgi
@@ -0,0 +1,44 @@
+#!/usr/bin/haserl
+Content-Type: text/html;charset=UTF-8
+Pragma: no-cache
+Cache-Control: no-cache
+
+<? eval `squark-auth-ip -i $REMOTE_ADDR -p` ?>
+<!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" xml:lang="en">
+ <head>
+ <title>Internet User Authentication Required</title>
+ <link rel="stylesheet" type="text/css" href="/static/style.css" />
+ </head>
+ <body>
+ <? squark-auth-ip -i $REMOTE_ADDR -r ?>
+ <div><img id="warning" src="/static/warning.png" alt="Warning sign" /></div>
+ <div id="outer_container">
+ <div id="inner_container">
+ <h1>Login Information</h1>
+ <p>
+ You are now logged in. You may wish to keep this page open in order to remain
+ logged in. Click the logout button below when you are finished.
+ </p>
+ <p>
+ Your Session Information:
+ </p>
+ <p>
+ <table>
+ <tr><td>IP-address:</td><td><? echo -n "$REMOTE_ADDR" ?></td></tr>
+ <tr><td>Username:</td><td><? echo -n "$squark_username" ?></td></tr>
+ <tr><td>Login time:</td><td><? echo -n "$squark_login_time" ?></td></tr>
+ <tr><td>Last Activity:</td><td><? echo -n "$squark_activity_time" ?></td></tr>
+ <tr><td>Last Override:</td><td><? echo -n "$squark_override_time" ?></td></tr>
+ </table>
+ </p>
+ <p>
+ <form action="do-logout.cgi" method="post">
+ <input type="submit" value="Logout" /><td/>
+ </form>
+ </p>
+ </div>
+ </div>
+ </body>
+</html>
+
diff --git a/www/login.cgi b/www/login.cgi
new file mode 100755
index 0000000..33be150
--- /dev/null
+++ b/www/login.cgi
@@ -0,0 +1,49 @@
+#!/usr/bin/haserl
+Content-Type: text/html;charset=UTF-8
+Pragma: no-cache
+Cache-Control: no-cache
+
+<!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" xml:lang="en">
+ <head>
+ <title>Internet User Authentication Required</title>
+ <link rel="stylesheet" type="text/css" href="/static/style.css" />
+ </head>
+ <body>
+ <div><img id="warning" src="/static/warning.png" alt="Warning sign" /></div>
+ <div id="outer_container">
+ <div id="inner_container">
+ <h1>Internet User Authentication Required</h1>
+ <p>
+ User authentication is required to access the Internet. Please,
+ provide your credentials to login.
+ </p>
+ <%
+ if [ "$GET_REASON" = "fail" ]; then
+ echo -n "<p><font color = "#990000">Incorrect user name or password. Please try again.</font></p>"
+ fi
+ %>
+ <p>
+ <form action="do-login.cgi" method="post">
+ <input type="hidden" name="DENIEDURL" value="<% echo -n "$GET_DENIEDURL" %>" />
+ <table>
+ <tr>
+ <td>User name:</td>
+ <td><input type="input" name="username" /></td>
+ </tr>
+ <tr>
+ <td>Password:</td>
+ <td><input type="password" name="password" /></td>
+ </tr>
+ <tr>
+ <td />
+ <td><input type="submit" value="Logon" method="get" /><td/>
+ </tr>
+ </table>
+ </form>
+ </p>
+ </div>
+ </div>
+ </body>
+</html>
+
diff --git a/www/style.css b/www/style.css
new file mode 100644
index 0000000..d2b9aba
--- /dev/null
+++ b/www/style.css
@@ -0,0 +1,113 @@
+* {
+ font-size: 100%;
+ margin: 0;
+ padding: 0;
+}
+
+body {
+ background-color: #D6D6D6;
+ background-image: url(background.png);
+ background-repeat: repeat-x;
+ font-family: verdana, sans-serif;
+ font-size: 0.8em;
+}
+
+#warning {
+ position: absolute;
+ left: 51px;
+ top: 15px;
+}
+
+h1 {
+ padding-bottom: 15px;
+ margin-bottom: 15px;
+ border-bottom: 1px solid #878787;
+ font-family: "Trajan Pro, serif";
+ font-size: 1.8em;
+ font-variant: small-caps;
+}
+
+h2 {
+ margin-top: 5px;
+ font-family: "Trajan Pro, serif";
+ font-size: 1.2em;
+ font-style: italic;
+ font-weight: bold;
+}
+
+p, dt {
+ margin-top: 12px;
+}
+
+dt {
+ font-style: italic;
+}
+
+dd {
+ margin-top: 6px;
+ margin-left: 6px;
+}
+
+
+.badword {
+ color: red;
+}
+
+.goodword {
+ color: green;
+}
+
+#blockedreason {
+ padding: 10px 10px 10px 10px;
+ margin: 10px 10px 10px 10px;
+ background-color: #ffaaaa;
+ font-weight: bold;
+}
+
+.deniedurl {
+ font-weight: bold;
+}
+
+#fulldeniedurl {
+ background-color: #D6D6D6;
+ padding: 10px 10px 10px 10px;
+ margin: 10px 10px 10px 10px;
+ display: none;
+}
+
+#toggleurl {
+ border-bottom: 1px solid;
+ font-size: 0.8em;
+ cursor: pointer;
+ color: blue;
+}
+
+#outer_container {
+ margin: 0% 80px 0% 80px;
+ background-color: white;
+ border-left-style: groove;
+ border-right-style: groove;
+ border-bottom-style: groove;
+ background-image: url(worldmap.png);
+ background-repeat: no-repeat;
+ background-position: top center;
+}
+
+#inner_container {
+ margin-left: 5%;
+ margin-right: 5%;
+ padding-top: 80px;
+ padding-bottom: 80px;
+ overflow: hidden;
+ /* It grows out of the "box" in IE */
+ word-wrap: break-word; /* Internet Explorer */
+}
+
+
+a {
+ text-decoration: none;
+}
+
+a:hover {
+ border-bottom: 1px solid;
+}
diff --git a/www/warning.cgi b/www/warning.cgi
new file mode 100755
index 0000000..5c73fa7
--- /dev/null
+++ b/www/warning.cgi
@@ -0,0 +1,37 @@
+#!/usr/bin/haserl
+Content-Type: text/html;charset=UTF-8
+Pragma: no-cache
+Cache-Control: no-cache
+
+<!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" xml:lang="en">
+ <head>
+ <title>Content Filter Warning</title>
+ <link rel="stylesheet" type="text/css" href="/static/style.css" />
+ </head>
+ <body>
+ <div><img id="warning" src="/static/warning.png" alt="Warning sign" /></div>
+ <div id="outer_container">
+ <div id="inner_container">
+ <h1>Content Filter Warning</h1>
+ <p>Access to
+ <span class="deniedurl"><? echo -n ${GET_DENIEDURL} | cut -d "/" -f1-3 ?></span>
+ has been denied in an attempt to protect you from harmful content.
+ </p>
+ <p>However, if you are sure that you were blocked in error, you may
+ override the warnings for a 15 minute period.
+ </p>
+ <p>Reason for block: <? echo -n $GET_REASON ?></p>
+ <p>User credentials: <? echo -n $GET_USER ?></p>
+ <p>User IP-address: <? echo -n $REMOTE_ADDR ?></p>
+ <p>
+ <form action="do-override.cgi">
+ <input type="hidden" name="DENIEDURL" value="<? echo -n ${GET_DENIEDURL} ?>" />
+ <input type="submit" value="Override block" method="get" />
+ </form>
+ </p>
+ </div>
+ </div>
+ </body>
+</html>
+
diff --git a/www/warning.png b/www/warning.png
new file mode 100644
index 0000000..c52e36e
--- /dev/null
+++ b/www/warning.png
Binary files differ
diff --git a/www/worldmap.png b/www/worldmap.png
new file mode 100644
index 0000000..be2c524
--- /dev/null
+++ b/www/worldmap.png
Binary files differ