diff options
Diffstat (limited to 'files/common/www/service/cgi-bin/splash_click.html')
-rwxr-xr-x | files/common/www/service/cgi-bin/splash_click.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/files/common/www/service/cgi-bin/splash_click.html b/files/common/www/service/cgi-bin/splash_click.html new file mode 100755 index 0000000..59926d0 --- /dev/null +++ b/files/common/www/service/cgi-bin/splash_click.html @@ -0,0 +1,48 @@ +#!/bin/sh -e + +. $IPKG_INSTROOT/etc/functions.sh +. /etc/splash.sh +. /www/service/cgi-bin/common.sh + +# decode request params +#URL="http://$(sed 's/target_url=//g' | urldecode || true)" +URL="http://sotun.de/" +USER_MAC=$(grep ^$REMOTE_HOST </proc/net/arp \ + | awk 'BEGIN { FS = " " } ; { print $4 }') +[ -n "$USER_MAC" ] + +# check if user is already splashed; splash otherwise +lockSplash +ISSPLASHED=0 +config_load splash_users +is_mac() { + config_get mac "$1" mac + if [ "$mac" == "$USER_MAC" ]; then + ISSPLASHED=1 + fi +} +config_foreach is_mac user +if [ $ISSPLASHED -eq 0 ]; then + # user is now free to go + chain=$chain_prefix$chain_id + if have_internet; then + iptables -t nat -I $chain 1 -m mac --mac-source $USER_MAC -j ACCEPT + fi + + uci -q add splash_users user >/dev/null + uci -q set splash_users.@user[-1].mac=$USER_MAC + uci -q set splash_users.@user[-1].time=`date +%s` +fi +unlockSplash + +# send response (encode / to not confuse sed) + +echo -en "Status: 200 OK\r +Content-Type: text/html\r +\r +" +if have_internet; then + sed "s/targeturl/$(echo "$URL" | sed 's#/#\\/#g')/g" iframe.html +else + cat internet.html +fi |