diff options
Diffstat (limited to 'files/common/www')
-rwxr-xr-x | files/common/www/service/cgi-bin/splash | 7 | ||||
-rwxr-xr-x | files/common/www/service/cgi-bin/splash_click | 44 | ||||
-rw-r--r-- | files/common/www/service/iframe.html | 2 |
3 files changed, 26 insertions, 27 deletions
diff --git a/files/common/www/service/cgi-bin/splash b/files/common/www/service/cgi-bin/splash index ee907d6..086fa82 100755 --- a/files/common/www/service/cgi-bin/splash +++ b/files/common/www/service/cgi-bin/splash @@ -2,7 +2,6 @@ echo -en "Status: 200 OK\r\n" echo -en "Content-Type: text/html\r\n" echo -en "\r\n" -#targeturl=$(echo $QUERY_STRING) -#targeturl=$(echo $QUERY_STRING | sed -f /etc/urlencode.sed) -targeturl=`echo $QUERY_STRING` -sed "s/targeturl/"$targeturl"/g" /www/splash.html + +targeturl="$(echo "$QUERY_STRING" | tr -d '/')" +sed "s/targeturl/"$targeturl"/g" splash.html diff --git a/files/common/www/service/cgi-bin/splash_click b/files/common/www/service/cgi-bin/splash_click index d08af6a..d7e3f2f 100755 --- a/files/common/www/service/cgi-bin/splash_click +++ b/files/common/www/service/cgi-bin/splash_click @@ -1,14 +1,19 @@ -#!/bin/sh +#!/bin/sh -e +. $IPKG_INSTROOT/etc/functions.sh +. /etc/splash.sh + echo -en "Status: 200 OK\r\n" echo -en "Content-Type: text/html\r\n" echo -en "\r\n" -TEST=`cat ` -TEST=`echo $TEST | sed 's/'target_url='/''/g'` -TEST=`/bin/urldecode "$TEST"` -TEST=`echo $TEST | sed 's/%2F/\//g'` -USER_MAC=`cat /proc/net/arp | grep $REMOTE_HOST | awk 'BEGIN { FS = " " } ; { print $4 }'` -. $IPKG_INSTROOT/etc/functions.sh +# decode request params +# url is decoded twice, as it is encoded by the browser and once by us +URL="http://$(sed 's/target_url=//g' | urldecode)" +USER_MAC=$(grep ^$REMOTE_HOST </proc/net/arp \ + | awk 'BEGIN { FS = " " } ; { print $4 }') + +# check if user is already splashed; splash otherwise +lockSplash ISSPLASHED=0 config_load splash_users is_mac() { @@ -17,22 +22,17 @@ is_mac() { ISSPLASHED=1 fi } -#check if user is alredy splashed config_foreach is_mac user -sed 's/targeturl/'"$(echo $TEST| sed 's#/#\\/#g')"'/g' /www/iframe.html +if [ $ISSPLASHED -eq 0 ]; then + # user is now free to go + chain=$chain_prefix$chain_id + iptables -t nat -I $chain 1 -m mac --mac-source $USER_MAC -j ACCEPT -if [ $ISSPLASHED -eq 1 ]; then - exit + 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 -#User is now free to go -iptables -t nat -I ffj_splash 1 -m --mac-source $USER_MAC -j ACCEPT - -uci -q add splash_users user -uci -q set splash_users.@user[-1].mac=$USER_MAC -uci -q set splash_users.@user[-1].time=`date +%s` - -exit 0 - - - +unlockSplash +# send response +sed "s/targeturl/$(echo "$URL" | sed 's#/#\\/#g')/g" iframe.html diff --git a/files/common/www/service/iframe.html b/files/common/www/service/iframe.html index cdee514..02d6112 100644 --- a/files/common/www/service/iframe.html +++ b/files/common/www/service/iframe.html @@ -14,7 +14,7 @@ </head> <body style="margin:0px;"> -<!-- <div style="width:100%;padding:0px;background-color: #E5E5E5;text-align: center"><a href="targeturl">Weiter zur gesuchten Seite...</a></div>/--> + <div style="width:100%;padding:0px;background-color: #E5E5E5;text-align: center"><a href="targeturl">Weiter zur gesuchten Seite...</a></div> <iframe src="http://www.freifunk-jena.de/" width="100%" height="1000px"></iframe> </body> </html> |