Index: /branches/releng-10/nanobsd/files/usr/local/bin/http302
===================================================================
--- /branches/releng-10/nanobsd/files/usr/local/bin/http302	(revision 13055)
+++ /branches/releng-10/nanobsd/files/usr/local/bin/http302	(revision 13056)
@@ -3,5 +3,5 @@
 # Only purpose is to send somebody to the Captive Portal
 #
-URL=${URL:-http://172.31.255.1/wlportal}
+URL=${URL:-http://welcome.wleiden.net/portal}
 
 # Send information to client
Index: /branches/releng-10/nanobsd/files/usr/local/www/index.html
===================================================================
--- /branches/releng-10/nanobsd/files/usr/local/www/index.html	(revision 13055)
+++ /branches/releng-10/nanobsd/files/usr/local/www/index.html	(revision 13056)
@@ -2,5 +2,5 @@
 <html>
 <head>
-	<meta http-equiv="refresh" content="5; url=/wlportal/portal.html">
+	<meta http-equiv="refresh" content="5; url=/portal/">
 	<title>Redirecting...</title>
 </head>
Index: /branches/releng-10/nanobsd/files/usr/local/www/portal/index.cgi
===================================================================
--- /branches/releng-10/nanobsd/files/usr/local/www/portal/index.cgi	(revision 13056)
+++ /branches/releng-10/nanobsd/files/usr/local/www/portal/index.cgi	(revision 13056)
@@ -0,0 +1,28 @@
+#!/bin/sh 
+#
+# CGI which process the request of the user _before_ he/she has pressed continue
+#
+# Rick van der Zwet <info@rickvanderzwet.nl>
+#
+PATH=$PATH:/usr/sbin:/usr/bin:/sbin
+DB=/tmp/authenticated.txt
+AUTOLOGIN_DB=/tmp/autologin.txt
+
+REMOTE_MAC=`arp -n $REMOTE_ADDR | awk '{print $4}'`
+
+
+# Check user state
+if grep -q $REMOTE_MAC $DB; then
+  # User has already been here (ones) continue authention directly
+  ./login/index.cgi
+elif grep -q $REMOTE_MAC $AUTOLOGIN_DB; then
+  # Device is marked as special, continue with autologin
+  ./login/index.cgi
+else
+  echo 'HTTP 1.0 302 Found'
+  echo ''
+  # User is new, present welcome page
+  sed -e "s/\$REMOTE_ADDR/$REMOTE_ADDR/" \
+      -e "s/\$REMOTE_MAC/$REMOTE_MAC/" \
+  	`dirname $0`/index.html.tmpl
+fi
Index: /branches/releng-10/nanobsd/files/usr/local/www/portal/index.html.tmpl
===================================================================
--- /branches/releng-10/nanobsd/files/usr/local/www/portal/index.html.tmpl	(revision 13056)
+++ /branches/releng-10/nanobsd/files/usr/local/www/portal/index.html.tmpl	(revision 13056)
@@ -0,0 +1,5 @@
+<html>
+Welcome to wireless Leiden
+<a href="/portal/login">login</a>
+</html>
+
Index: /branches/releng-10/nanobsd/files/usr/local/www/portal/login/index.cgi
===================================================================
--- /branches/releng-10/nanobsd/files/usr/local/www/portal/login/index.cgi	(revision 13056)
+++ /branches/releng-10/nanobsd/files/usr/local/www/portal/login/index.cgi	(revision 13056)
@@ -0,0 +1,26 @@
+#!/bin/sh 
+#
+# CGI which process the request of the user _after_ he/she has pressed continue
+#
+# Rick van der Zwet <info@rickvanderzwet.nl>
+#
+PATH=$PATH:/usr/sbin:/usr/bin:/sbin
+DB=/tmp/authenticated.txt
+
+REMOTE_MAC=`arp -n $REMOTE_ADDR | awk '{print $4}'`
+
+# Place to store which MAC was authenticated against which IP address
+grep -v $REMOTE_MAC $DB >> $DB.new
+mv $DB.new $DB
+echo `date "+%s"` $REMOTE_ADDR $REMOTE_MAC >> $DB
+
+# Add entry to authorized list
+pfctl -q -t wlportal -T add $REMOTE_ADDR
+
+# Redirect to proper page
+echo 'HTTP 1.0 200 OK'
+echo 'Refresh: 0; url=http://www.wirelessleiden.nl'
+echo ''
+sed -e "s/\$REMOTE_ADDR/$REMOTE_ADDR/" \
+    -e "s/\$REMOTE_MAC/$REMOTE_MAC/" \
+    `dirname $0`/index.html.tmpl
Index: /branches/releng-10/nanobsd/files/usr/local/www/portal/login/index.html.tmpl
===================================================================
--- /branches/releng-10/nanobsd/files/usr/local/www/portal/login/index.html.tmpl	(revision 13056)
+++ /branches/releng-10/nanobsd/files/usr/local/www/portal/login/index.html.tmpl	(revision 13056)
@@ -0,0 +1,3 @@
+<html>
+Welcome to Wireless Leiden, you are now logged in
+</html>
Index: /branches/releng-10/nanobsd/files/usr/local/www/portal/logout/index.cgi
===================================================================
--- /branches/releng-10/nanobsd/files/usr/local/www/portal/logout/index.cgi	(revision 13056)
+++ /branches/releng-10/nanobsd/files/usr/local/www/portal/logout/index.cgi	(revision 13056)
@@ -0,0 +1,21 @@
+#!/bin/sh 
+#
+# CGI which process the request of the user _after_ he/she has pressed continue
+#
+# Rick van der Zwet <info@rickvanderzwet.nl>
+#
+PATH=$PATH:/usr/sbin:/usr/bin:/sbin
+DB=/tmp/authenticated.txt
+
+REMOTE_MAC=`arp -n $REMOTE_ADDR | awk '{print $4}'`
+
+# Add entry to authorized list
+pfctl -q -t wlportal -T delete $REMOTE_ADDR
+
+# Redirect to proper page
+echo 'HTTP 1.0 200 OK'
+echo 'Refresh: 60; url=/portal/login'
+echo ''
+sed -e "s/\$REMOTE_ADDR/$REMOTE_ADDR/" \
+    -e "s/\$REMOTE_MAC/$REMOTE_MAC/" \
+    `dirname $0`/index.html.tmpl
Index: /branches/releng-10/nanobsd/files/usr/local/www/portal/logout/index.html.tmpl
===================================================================
--- /branches/releng-10/nanobsd/files/usr/local/www/portal/logout/index.html.tmpl	(revision 13056)
+++ /branches/releng-10/nanobsd/files/usr/local/www/portal/logout/index.html.tmpl	(revision 13056)
@@ -0,0 +1,3 @@
+<html>
+You are now logged out
+</html>
