#!/bin/sh export DATE="28.3.2006";SCRIPT=${0#/rom} export TITLE="Verwaltung: Nutzer" . ${SCRIPT%/*}/cgi-bin-pre.sh . /usr/lib/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 "" } # STATUS DLEASES="/var/run/dhcp.leases" SLEASES="/var/run/dhcpsplash.leases" LTIMEOUT="$(($(date +%s)-$(($(splash_getvar ff_dhcpsplash_time)*3600))))" ARPCACHE=$(cat /proc/net/arp | sed -ne '/^IP/d;s/^\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).\+\(..:..:..:..:..:..\).\+/\2 \1/p') getleasestate() { case $(splash_getleasestate $1 $2) in preauth) leasestate='dauerhaft' ;; blocked) leasestate='nicht möglich' ;; tmpaccess) hours=$(($(($LTIME-$LTIMEOUT))/3600)) min=$(($(($(($LTIME-$LTIMEOUT))%3600))/60)) if [ "$hours" != "0" ]; then leasestate="noch $hours h und $min minnoch $min min" fi ;; expaccess) leasestate='abgelaufen' ;; access) leasestate='freigeschaltet' ;; noaccess) leasestate='nicht freigeschaltet' ;; nosplash) leasestate='nicht notwendig' ;; esac } cat<Verwaltung: Nutzer EOF 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" && ( test -r /etc/dhcpsplash/agreement && ag_mode="custom" ) timeout=$(splash_getvar ff_dhcpsplash_time) # 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" && ( test -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" ## display mac address x=$(splash_getmac "$REMOTE_ADDR") if [ -n "$x" ] && splash_insplashrange "$REMOTE_ADDR";then macrow="MAC Adresse deines Computers: $x" fi cat<
EOF if splash_running; then cat < $macrow

Schnittstellen

IP-Bereich für die WIFI Schnittstelle
$(html_radio ff_dhcpsplash_wifi off $wifi_mode)DHCPSPLASH auf WIFI deaktivieren
$(html_radio ff_dhcpsplash_wifi dhcp $wifi_mode)OLSR-DHCP Bereich verwenden
$(html_radio ff_dhcpsplash_wifi custom $wifi_mode)Eigener Wert:
IP-Bereich für die LAN Schnittstelle
$(html_radio ff_dhcpsplash_lan off $lan_mode)DHCPSPLASH auf LAN deaktivieren
$(html_radio ff_dhcpsplash_lan net $lan_mode)LAN Bereich $(splash_ifrange lan)
$(html_radio ff_dhcpsplash_lan custom $lan_mode)Eigener Wert:
 
 

Freischaltung-Seite

$(html_radio ff_dhcpsplash_ag off $ag_mode)Freischaltung-Seite deaktivieren
$(html_radio ff_dhcpsplash_ag text $ag_mode)Standardtext $(html_radio ff_dhcpsplash_ag custom $ag_mode)Eigener Text: $(html_textarea dhcpsplash_agreement agreement)
Zeit bis zur erneuten Feischaltung:  Stunde(n)
 
 

Willkommen-Seite

$(html_radio ff_dhcpsplash_hp off $hp_mode)Willkommens-Seite deaktivieren
$(html_radio ff_dhcpsplash_hp url $hp_mode)URL verwenden:

Der Nutzer kann nach erfolgreicher Freischaltung auf eine eigene Willkommen-Seite umgeleitet werden. Die URL sollte relativ zu /www/ sein oder fest angegbeben werden (zB. "http://server/welcome.html")
Geplant ist hier ein kleines Gästebuch zu integrieren, auf welcher die Nutzer jede Menge Nettigkeiten hinterlassen können
 
 

Behandlung von Nutzern

$(html_radio ff_dhcpsplash_block on $block_mode)Alle ausser freigeschaltete sperren:
$(html_radio ff_dhcpsplash_block acl $block_mode)Auswahl sperren:
Gesperrte MAC-Adressen:Freigeschaltete MAC-Adressen:
$(html_textarea dhcpsplash_blocked blocked 6 27) $(html_textarea dhcpsplash_preauth preauth 6 27)
Verbundene Geräte:
EOF echo "" if [ -s "$DLEASES" ]; then while read LINE; do MAC=$(echo "$LINE" | cut -d " " -f2 | sed y/abcdef/ABCDEF/) IP=$(echo "$LINE" | cut -d " " -f3) NAME=$(echo "$LINE" | cut -d " " -f4) LTIME="$(grep -is $MAC $SLEASES | cut -d ' ' -f1)" getleasestate $MAC $IP echo "$leasestate" done < $DLEASES else dhcp=0 fi if [ -n "$ARPCACHE" ]; then cat /proc/net/arp | sed -ne '/^IP/d;s/^\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).\+\(..:..:..:..:..:..\).\+/\2 \1/p' | while read LINE; do MAC=$(echo "$LINE" | cut -d " " -f1) IP=$(echo "$LINE" | cut -d " " -f2) NAME=$(cat /etc/hosts | sed -ne "s/^$IP[[:space:]]\(.\+\)[[:space:]]#.\+/\1/p") test -z $NAME && NAME='*' LTIME="$(grep -is $MAC $SLEASES | cut -d ' ' -f1)" if ! grep -iqs " $IP " $DLEASES; then getleasestate $MAC $IP echo "$leasestate" fi done else static=0 fi test "$dhcp" = "0" && echo '' test "$static" = "0" && echo '' cat< EOF fi echo "
Typ:IP-Adresse:Hostname:MAC-Adresse:Freischaltung:
DHCP$IP$NAME$MAC
statisch$IP$NAME$MAC
- keine DHCP-Nutzer verbunden -
- keine sonstigen Geräte verbunden -
 
$(html_radio ff_dhcpsplash_block_custom no $block_custom)Standardtext $(html_radio ff_dhcpsplash_block_custom custom $block_custom)Eigener Text: $(html_textarea dhcpsplash_blocked_message blocked_message)
 
 
          
" 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/S98dhcpsplash restart >/dev/null 2>&1 cat<
DHCP Splash wurde neu gestartet. Ein Neustart des Routers ist nicht nötig.
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_time; do nvram unset "$V" done rm -f /etc/dhcpsplash/agreement /etc/dhcpsplash/welcome /etc/dhcpsplash/blocked_message /etc/dhcpsplash/public_services >/dev/null 2>&1 cat<Die Einstellungen wurden auf ihre Standardwerte zurückgesetzt. Es ist kein Neustart nötig. 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 else rm /etc/dhcpsplash/agreement >/dev/null 2>&1 fi if [ "$ff_dhcpsplash_hp" = "custom" ]; then echo "$(unescape $dhcpsplash_welcome)" > /etc/dhcpsplash/welcome else rm /etc/dhcpsplash/welcome >/dev/null 2>&1 fi test -L /etc/dhcpsplash/preauth && rm /etc/dhcpsplash/preauth echo "$(unescape $dhcpsplash_preauth)" | sed ' s# #_#g s#^\(..:..:..:..:..:..\)\(.\+\)$#\1,\2# s#[^,_0-9a-zA-Z:]##g s#,\|,_# # ' > /etc/dhcpsplash/preauth test -L /etc/dhcpsplash/blocked && rm /etc/dhcpsplash/blocked echo "$(unescape $dhcpsplash_blocked)" | sed ' s# #_#g s#^\(..:..:..:..:..:..\)\(.\+\)$#\1,\2# s#[^,_0-9a-zA-Z:]##g s#,\|,_# # ' > /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 ff_dhcpsplash_time; 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<Die geänderten Einstellungen wurden übernommen. Es ist kein Neustart nötig. EOF fi fi . ${SCRIPT%/*}/cgi-bin-post.sh