#!/bin/sh export DATE="23.10.2007";SCRIPT=${0#/rom} export TITLE="Admin: DHCP Splash" . ${SCRIPT%/*}/cgi-bin-pre.sh cat<Admin: DHCP Splash EOF . /www/cgi-bin/dhcpsplash/functions.sh ## 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 splash_forcedvar ff_dhcpsplash_wifi && wifi_forced="yes" 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 splash_forcedvar ff_dhcpsplash_lan && lan_forced="yes" lan_mode=$(splash_getvar ff_dhcpsplash_lan) test "$lan_mode" != "off" -a "$lan_mode" != "net" && lan_mode="custom" lan_current=$(splash_lanrange) # agreement screen splash_forcedvar ff_dhcpsplash_ag && ag_forced="yes" ag_url=$(splash_getvar ff_dhcpsplash_agurl) ag_mode=$(splash_getvar ff_dhcpsplash_ag) test "$ag_mode" = "text" -a -r /etc/dhcpsplash/agreement && ag_mode="custom" # welcome screen splash_forcedvar ff_dhcpsplash_hp && hp_forced="yes" hp_url=$(splash_getvar ff_dhcpsplash_hpurl) hp_mode=$(splash_getvar ff_dhcpsplash_hp) test "$hp_mode" = "text" -a -r /etc/dhcpsplash/welcome && hp_mode="custom" # public services test -r /etc/dhcpsplash/public_services && ps_custom="custom" || ps_custom="no" # blocking splash_forcedvar ff_dhcpsplash_block && block_forced="yes" block_mode=$(splash_getvar ff_dhcpsplash_block) test -r /etc/dhcpsplash/blocked_message && block_custom="custom" || block_custom="no" 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 dhcpsplash_agreement agreement)
 

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 dhcpsplash_welcome welcome)
 

Unlocked services for freshly connected users

$(html_checkbox ff_dhcpsplash_allowlocal on $(splash_getvar ff_dhcpsplash_allowlocal)) Allow essential services on this router (DHCP, DNS, HTTP, HTTPS)
$(html_checkbox ff_dhcpsplash_allowuris on $(splash_getvar ff_dhcpsplash_allowuris)) Accept traffic to external sites hosting agreement-/welcome page (HTTP, HTTPS)
Additional Services
$(html_radio ps_custom no $ps_custom)Standard $(html_radio ps_custom custom $ps_custom)Custom values $(html_textarea dhcpsplash_public_services public_services)
 

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 dhcpsplash_blocked blocked 6 27) $(html_textarea dhcpsplash_preauth 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_block_custom no $block_custom)Standard text $(html_radio ff_dhcpsplash_block_custom custom $block_custom)Custom text: $(html_textarea dhcpsplash_blocked_message blocked_message)
 
         
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;unset IFS;eval $* DIRTY= if [ -n "$post_dhcpsplash_run" ]; then ## update variables for V in ff_dhcpsplash; do eval "C=\$$V" C=$(unescape $C) if [ "$C" != "$(nvram get $V)" ]; then DIRTY=1 nvram set $V="$C" fi done # /etc/init.d/S70dhcpsplash restart >/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; do nvram unset "$V" done rm -f /etc/dhcpsplash/agreement /etc/dhcpsplash/welcome /etc/dhcpsplash/blocked_message >/dev/null 2>&1 cat< The settings have been rolled back to standard values. EOF elif [ -n "$post_dhcpsplash" ]; then 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 echo "$(unescape $dhcpsplash_agreement)" > /etc/dhcpsplash/agreement ff_dhcpsplash_ag="text" else rm /etc/dhcpsplash/agreement >/dev/null 2>&1 fi if [ "$ff_dhcpsplash_hp" = "custom" ]; then echo "$(unescape $dhcpsplash_welcome)" > /etc/dhcpsplash/welcome ff_dhcpsplash_hp="text" else rm /etc/dhcpsplash/welcome >/dev/null 2>&1 fi echo "$(unescape $dhcpsplash_preauth)" | sed "s#[^0-9a-zA-Z:]##g" > /etc/dhcpsplash/preauth echo "$(unescape $dhcpsplash_blocked)" | sed "s#[^0-9a-zA-Z:]##g" > /etc/dhcpsplash/blocked if [ "$ff_dhcpsplash_block_custom" = "custom" ]; then echo "$(unescape $dhcpsplash_blocked_message)" > /etc/dhcpsplash/blocked_message else rm /etc/dhcpsplash/blocked_message >/dev/null 2>&1 fi if [ "$ps_custom" = "custom" ]; then echo "$(unescape $dhcpsplash_public_services)" | sed "s#[^- ,_0-9a-zA-Z:\.\#]##g" > /etc/dhcpsplash/public_services else rm /etc/dhcpsplash/public_services >/dev/null 2>&1 fi ## update variables for V in ff_dhcpsplash_wifi ff_dhcpsplash_lan ff_dhcpsplash_agurl ff_dhcpsplash_ag ff_dhcpsplash_hpurl ff_dhcpsplash_hp ff_dhcpsplash_block; do eval "C=\$$V" C=$(unescape $C) if [ "$C" != "$(nvram get $V)" ]; then DIRTY=1 nvram set $V="$C" fi done ## update iptables splash_update_iptables 2>/dev/null ## commit if required if [ -n "$DIRTY" ]; then nvram commit>/dev/null 2>&1 fi cat< The changed settings are committed. The settings are active now. EOF fi fi . ${SCRIPT%/*}/cgi-bin-post.sh