#!/bin/sh export DATE="9.5.2010";SCRIPT=${0#/rom} export TITLE="Admin: DHCP Splash" . ${SCRIPT%/*}/cgi-bin-pre.sh cat<Admin: DHCP Splash EOF . /www/cgi-bin/dhcpsplash/admin.sh . /www/cgi-bin/dhcpsplash/clients.sh . /www/cgi-bin/dhcpsplash/clients-admin.sh . /www/cgi-bin/dhcpsplash/defaults.sh . /www/cgi-bin/dhcpsplash/ranges.sh . /www/cgi-bin/dhcpsplash/vars.sh . /etc/functions.sh get_netparam ## some html helper functions # ARGS: name value default_value html_radio() { cat<  EOF } # ARGS: name value default_value html_checkbox() { cat<  EOF } # ARGS: name textfile rows cols html_textarea() { echo "" } if [ "$REQUEST_METHOD" = "POST" ]; then read QUERY_STRING fi if [ -z "$QUERY_STRING" ]; then # wifi iprange wifi_mode=$(splash_getvar ff_dhcpsplash_wifi) test "$wifi_mode" != "off" -a "$wifi_mode" != "dhcp" -a "$wifi_mode" != "net" && wifi_mode="custom" wifi_current=$(splash_wifirange) # lan iprange lan_mode=$(splash_getvar ff_dhcpsplash_lan) test "$lan_mode" != "off" -a "$lan_mode" != "net" && lan_mode="custom" lan_current=$(splash_lanrange) # agreement screen ag_url=$(splash_getvar ff_dhcpsplash_agurl) ag_mode=$(splash_getvar ff_dhcpsplash_ag) # welcome screen hp_url=$(splash_getvar ff_dhcpsplash_hpurl) hp_mode=$(splash_getvar ff_dhcpsplash_hp) # public services publicsrv_cust=$(splash_getvar ff_dhcpsplash_publicsrv_cust) # blocking block_mode=$(splash_getvar ff_dhcpsplash_block) blockedmsg_cust=$(splash_getvar ff_dhcpsplash_blockedmsg_cust) if splash_running; then cat<

Interfaces

IP range for WIFI interface
$(html_radio ff_dhcpsplash_wifi off $wifi_mode)Off
$(html_radio ff_dhcpsplash_wifi dhcp $wifi_mode)OLSR-DHCP
$(html_radio ff_dhcpsplash_wifi net $wifi_mode)Network
$(html_radio ff_dhcpsplash_wifi custom $wifi_mode)Custom value:
IP range for LAN interface
$(html_radio ff_dhcpsplash_lan off $lan_mode)Off
$(html_radio ff_dhcpsplash_lan net $lan_mode)Network
$(html_radio ff_dhcpsplash_lan custom $lan_mode)Custom Value:
 

Agreement

$(html_radio ff_dhcpsplash_ag off $ag_mode)Off
$(html_radio ff_dhcpsplash_ag url $ag_mode)Use URL
<wifiip> <wifimac> <clientip> <clientmac> are placeholders which will be substituted by their respective value
$(html_radio ff_dhcpsplash_ag text $ag_mode)Standard text $(html_radio ff_dhcpsplash_ag custom $ag_mode)Custom text: $(html_textarea agtext)
 

Welcome Page

$(html_radio ff_dhcpsplash_hp off $hp_mode)Off
$(html_radio ff_dhcpsplash_hp url $hp_mode)Use URL
<wifiip> <wifimac> <clientip> <clientmac> are placeholders which will be substituted by their respective value
$(html_radio ff_dhcpsplash_hp text $hp_mode)Standard text $(html_radio ff_dhcpsplash_hp custom $hp_mode)Custom text$(html_textarea hptext)
 

Unlocked services for freshly connected users

$(html_radio ff_dhcpsplash_publicmode on $(splash_getvar ff_dhcpsplash_publicmode)) Allow all connections. All services beside HTTP which is used for presenting the splash page are open for everyone at any time.
$(html_radio ff_dhcpsplash_publicmode off $(splash_getvar ff_dhcpsplash_publicmode))Allow only essential connections to external sites hosting the agreement-/welcome page if any (HTTP, HTTPS)
Additional Services
$(html_radio ff_dhcpsplash_publicsrv_cust no $publicsrv_cust) Standard $(html_radio ff_dhcpsplash_publicsrv_cust custom $publicsrv_cust) Custom values $(html_textarea publicsrv)
 

Treatment of freshly connected users

$(html_radio ff_dhcpsplash_block all $block_mode)Block all except allowed users
$(html_radio ff_dhcpsplash_block acl $block_mode)Block only selected users
Blocked MAC addresses Allowed MAC adresses
$(html_textarea blocked 6 27)$(html_textarea preauth 6 27) EOF ## display mac address x=$(splash_getmac "$REMOTE_ADDR") if [ -n "$x" ];then cat<
MAC address of your computer $x
EOF fi cat<
$(html_radio ff_dhcpsplash_blockedmsg_cust no $blockedmsg_cust)Standard text $(html_radio ff_dhcpsplash_blockedmsg_cust custom $blockedmsg_cust)Custom text: $(html_textarea blockedmsg)
 
         
EOF else cat<
DHCP-Splash is not active. Please restart your router.
 
$(html_checkbox ff_dhcpsplash on $(splash_getvar ff_dhcpsplash))DHCP Splash activated
 
EOF fi else IFS=\&;set ${QUERY_STRING%%[^%&=+-:@-_a-z~]*};unset IFS;eval $* DIRTY= if [ -n "$post_dhcpsplash_run" ]; then ## update variables DIRTY=1 if [ -z "${ff_dhcpsplash%%on}" -a -n "$ff_dhcpsplash" ]; then nvram set ff_dhcpsplash="on" else nvram unset ff_dhcpsplash fi nvram commit>/dev/null 2>&1 cat<The changed settings are committed. The settings are active after the next Restart. EOF elif [ -n "$post_dhcpsplash_reset" ]; then for V in ff_dhcpsplash_wifi ff_dhcpsplash_lan ff_dhcpsplash_agurl ff_dhcpsplash_ag ff_dhcpsplash_hpurl ff_dhcpsplash_hp ff_dhcpsplash_block ff_dhcpsplash_publicmode ff_dhcpsplash_preauth ff_dhcpsplash_blocked ff_dhcpsplash_agtext ff_dhcpsplash_hptext ff_dhcpsplash_blockedmsg ff_dhcpsplash_publicsrv ff_dhcpsplash_publicsrv_cust ff_dhcpsplash_blockedmsg_cust; do nvram unset "$V" DIRTY=1 done ## commit if required if [ -n "$DIRTY" ]; then nvram commit>/dev/null 2>&1 ## update iptables splash_update_iptables 2>/dev/null fi cat<The settings have been rolled back to standard values. EOF elif [ -n "$post_dhcpsplash" ]; then vars="ff_dhcpsplash_wifi ff_dhcpsplash_lan ff_dhcpsplash_agurl ff_dhcpsplash_ag ff_dhcpsplash_hpurl ff_dhcpsplash_hp ff_dhcpsplash_block ff_dhcpsplash_publicmode ff_dhcpsplash_publicsrv_cust ff_dhcpsplash_blockedmsg_cust" texts="ff_dhcpsplash_preauth ff_dhcpsplash_blocked" if [ "$ff_dhcpsplash_wifi" = "custom" ]; then ff_dhcpsplash_wifi="$ff_dhcpsplash_wifi_custom" fi if [ "$ff_dhcpsplash_lan" = "custom" ]; then ff_dhcpsplash_lan="$ff_dhcpsplash_lan_custom" fi if [ "$ff_dhcpsplash_ag" = "custom" ]; then texts="$texts ff_dhcpsplash_agtext" else nvram unset ff_dhcpsplash_agtext fi if [ "$ff_dhcpsplash_hp" = "custom" ]; then texts="$texts ff_dhcpsplash_hptext" else nvram unset ff_dhcpsplash_hptext fi if [ "$ff_dhcpsplash_blockedmsg_cust" = "custom" ]; then texts="$texts ff_dhcpsplash_blockedmsg" else nvram unset ff_dhcpsplash_blockedmsg fi if [ "$ff_dhcpsplash_publicsrv_cust" = "custom" ]; then texts="$texts ff_dhcpsplash_publicsrv" else nvram unset ff_dhcpsplash_publicsrv fi ## update variables for V in $vars; do eval "C=\$$V" C=$(httpd -d $C) if [ "$C" != "$(nvram get $V)" ]; then DIRTY=1 nvram set $V="$C" fi done ## update texts for T in $texts; do eval "C=\$$T" if [ "$C" != "$(nvram get $T)" ]; then DIRTY=1 nvram set $T="$C" fi done ## commit if required if [ -n "$DIRTY" ]; then nvram commit>/dev/null 2>&1 ## update iptables splash_update_iptables 2>/dev/null fi cat<The changed settings are committed. The settings are active now. EOF fi fi . ${SCRIPT%/*}/cgi-bin-post.sh