#!/bin/sh ##------------------------------------------------------------------------------ ## c3Surf - login for services __FLI4LVER__ ## ## Creation: 07.01.2008 Frank Saurbier - c3Surf@arcor.de ## Last Update: $Id$ ## ## Copyright (c) 2008-2010/04 Frank Saurbier - c3surf@arcor.de ## Copyright (c) 2010/05- Frank Saurbier, fli4l-Team - team@fli4l.de ## ## Licence and conditions look at ~/config/c3surf.txt ##------------------------------------------------------------------------------- . /srv/www/include/cgi-helper . /var/run/c3surf.conf # language # Thx to Wieland Große for helping if [ -f $C3SURF_READ_PATH/c3surf-lang.overwrite ] then . $C3SURF_READ_PATH/c3surf-lang.overwrite if [ -f /srv/www/lang/c3surf.$c3surf_admin_lang ] then . /srv/www/lang/c3surf.$c3surf_admin_lang fi fi # fix for fli4l v.3.3.0 and higher versions if [ -f /var/run/dhcp_leases_dir ] then . /var/run/dhcp_leases_dir fi # (fs) 20080317 dnsdhcp leases file c3surf_leases_file="$DHCP_LEASES_DIR/dnsmasq.leases" c3surf_tab_virgin=true ################################### simple_output () { htmlspecialchars | while read line do case $FORM_subaction in $log_file1) #login fsstamp=`echo $line | cut -d "|" -f 1` fsip=`echo $line | cut -d "|" -f 2` fsid=`echo $line | cut -d "|" -f 3` fsvorname=`echo $line | cut -d "|" -f 4` fsname=`echo $line | cut -d "|" -f 5` fsmail=`echo $line | cut -d "|" -f 6` fsmac=`echo $line | cut -d "|" -f 7` fsaction=`echo $line | cut -d "|" -f 8` echo "\ $fsstamp\ $fsip\ $fsid\ $fsvorname\ $fsname\ $fsmail\ $fsmac\ $fsaction\ " ;; $log_file2) #invalid fsstamp=`echo $line | cut -d "|" -f 1` fsmac=`echo $line | cut -d "|" -f 2` fserror=`echo $line | cut -d "|" -f 3` fsip=`echo $line | cut -d "|" -f 4` fsparms=`echo $line | cut -d "|" -f 5` echo "\ $fsstamp\ $fsmac\ $fserror\ $fsip\ $fsparms\ " ;; $log_file3) #page fsstamp=`echo $line | cut -d "|" -f 1` fsip=`echo $line | cut -d "|" -f 2` fsbrowser=`echo $line | cut -d "|" -f 3` fsany=`echo $line | cut -d "|" -f 4` echo "\ $fsstamp\ $fsip\ $fsbrowser\ $fsany\ " ;; *) # generischer Teil für alles andere echo "$line" esac done } # ########################################### # Rechte checken (im Moment nur c3surf:admin) # ########################################### check_rights "c3surf" "admin" # TAB: show lockme if system is locked if [ "$FORM_action" = "" ] then if test -f $C3SURF_SYSLOCK_FILE then FORM_action="lockme" fi fi # hack for proper tab-selection, inspired by pf.cgi : ${FORM_action:=online} : ${FORM_work:=} # #################################################### # beginne mit der Arbeit, dann klappt auch der refresh # #################################################### case $FORM_action in online) case $FORM_work in addtime) /usr/local/bin/c3surf_worker.sh "addIPTime" "$FORM_host" "$FORM_adtime" myrefresh="yes" ;; block) /usr/local/bin/c3surf_worker.sh "addTimeBlock" "$FORM_host" "240" myrefresh="yes" ;; logout) /usr/local/bin/c3surf_worker.sh "doAdminNCLogout" "$FORM_host" myrefresh="yes" ;; blacklist) /usr/local/bin/c3surf_blacklist.sh "$FORM_mac" "add" "$FORM_host" /usr/local/bin/c3surf_worker.sh "doAdminLogout" "$FORM_host" myrefresh="yes" ;; esac ;; userdata) case $FORM_work in usr_quotareset) # remove quota file rm -f "$C3SURF_TMP_PATH/$FORM_uid.quota" # better use c3surf_worker.sh "removeTimeBlock" "" "$FORM_uid" # remove block file [ -f $C3SURF_TMP_PATH/$FORM_uid.block ] && rm -f "$C3SURF_TMP_PATH/$FORM_uid.block" myrefresh="yes" ;; usr_add) # call the c3surf_worker() # it does all checks an error logs /usr/local/bin/c3surf_worker.sh "doAdminUser" \ "$FORM_pw" "$FORM_id" \ "$FORM_vorname" "$FORM_name" "$FORM_mail" \ "$FORM_time" "$FORM_blocktime" "$FORM_counter" \ "$FORM_curfew" if [ -n "$FORM_id" ] then myrefresh="yes" else myrefresh="no" fi # myrefresh="yes" ;; usr_save) # call the c3surf_worker() # it does all checks an error logs /usr/local/bin/c3surf_worker.sh "doAdminUser" \ "$FORM_pw" "$FORM_id" \ "$FORM_vorname" "$FORM_name" "$FORM_mail" \ "$FORM_time" "$FORM_blocktime" "$FORM_counter" \ "$FORM_curfew" if [ -n "$FORM_id" ] then myrefresh="yes" else myrefresh="no" fi # myrefresh="yes" ;; usr_esc) myrefresh="yes" ;; usr_del) if [ -n "$FORM_id" ] then /usr/local/bin/c3surf_worker.sh "doUserDelete" "-" "$FORM_id" "-" "-" "-" fi myrefresh="yes" ;; esac ;; voucher) case $FORM_work in vch_del) if [ -n "$FORM_id" ] then /usr/local/bin/c3surf_worker.sh "doUserDelete" "-" "$FORM_id" "-" "voucher" "-" fi myrefresh="yes" ;; vch_downprint) # download the print-file http_header download "ctype=text/plain;filename=print_voucher.txt" /bin/cat "$C3SURF_VOUCHER_PRINTFILE" exit 0 ;; vch_delprint) # delete the print-file /bin/rm -f "$C3SURF_VOUCHER_PRINTFILE" 2>/dev/null myrefresh="yes" ;; vch_print) # ---- is obsolete ---- # print the print-file myrefresh="yes" ;; button) case "$FORM_cmd" in "$_vch_cmd_refresh") if [ -n "$FORM_filter" ] then FORM_action="$FORM_action&filter=$FORM_filter" fi myrefresh="yes" ;; "$_vch_cmd_gen") # generate vouchers, as much as defined in config /usr/local/bin/c3surf_voucher_gen.sh myrefresh="yes" ;; "$_vch_cmd_clean") # remove expired vouchers /usr/local/bin/c3surf_voucher_del.sh myrefresh="yes" ;; "$_vch_cmd_force") # ask to remove all vouchers first myrefresh="no" ;; "$_vch_cmd_force_yes") # remove all vouchers /usr/local/bin/c3surf_voucher_del.sh "force" myrefresh="yes" ;; *) myrefresh="yes" ;; esac ;; vch_esc) myrefresh="yes" ;; esac ;; blocklist) case $FORM_work in unblock) /usr/local/bin/c3surf_worker.sh "removeTimeBlock" "$FORM_host" "$FORM_id" myrefresh="yes" ;; blacklist) /usr/local/bin/c3surf_blacklist.sh "$FORM_mac" "add" "$FORM_host" /usr/local/bin/c3surf_worker.sh "removeTimeBlock" "$FORM_host" "$FORM_id" myrefresh="yes" ;; esac ;; blacklist) if [ "$FORM_work" = "remove" ] then /usr/local/bin/c3surf_blacklist.sh "$FORM_mac" "remove" myrefresh="yes" fi ;; arplist) case $FORM_work in adm_login) /usr/local/bin/c3surf_worker.sh "doAdminLogin" "$FORM_host" myrefresh="yes" ;; blacklist) /usr/local/bin/c3surf_blacklist.sh "$FORM_mac" "add" "$FORM_host" myrefresh="yes" ;; esac ;; leaseslist) case $FORM_work in adm_login) /usr/local/bin/c3surf_worker.sh "doAdminLogin" "$FORM_host" myrefresh="yes" ;; blacklist) /usr/local/bin/c3surf_blacklist.sh "$FORM_mac" "add" "$FORM_host" myrefresh="yes" ;; esac ;; lockme) case $FORM_work in langselect) # select language if [ -n $FORM_language ] then if [ "$FORM_language" = "httpgui" then rm -f $C3SURF_PERSISTENT_PATH/c3surf-lang.overwrite 2>/dev/null if [ "$C3SURF_WORKON_TMP" = "yes" ] then rm -f $C3SURF_TMP_PATH/c3surf-lang.overwrite 2>/dev/null fi else echo "c3surf_admin_lang=\"$FORM_language\"" > $C3SURF_PERSISTENT_PATH/c3surf-lang.overwrite # copy from persistent path to work path if [ "$C3SURF_WORKON_TMP" = "yes" ] then cp -f $C3SURF_PERSISTENT_PATH/c3surf-lang.overwrite $C3SURF_TMP_PATH/c3surf-lang.overwrite fi fi fi myrefresh="yes" ;; lock_logout) # lock the system first echo "$_lck_msg_system_to_user" > $C3SURF_PERSISTENT_PATH/c3surf.lock # copy from persistent path to work path if [ "$C3SURF_WORKON_TMP" = "yes" ] then cp -f $C3SURF_PERSISTENT_PATH/c3surf.lock $C3SURF_SYSLOCK_FILE fi # logout all users for f in $C3SURF_TMP_PATH/*.time do # schließe den Abfrage-String aus if [ ! "$f" = "$C3SURF_TMP_PATH/*.time" ] then /usr/local/bin/c3surf_worker.sh "doSyslockLogout" `basename $f .time` fi done myrefresh="yes" ;; lock_only) echo "$_lck_msg_system_to_user" > $C3SURF_PERSISTENT_PATH/c3surf.lock if [ "$C3SURF_WORKON_TMP" = "yes" ] then cp -f $C3SURF_PERSISTENT_PATH/c3surf.lock $C3SURF_SYSLOCK_FILE fi myrefresh="yes" ;; unlock) rm -f $C3SURF_PERSISTENT_PATH/c3surf.lock if [ "$C3SURF_WORKON_TMP" = "yes" ] then rm -f $C3SURF_SYSLOCK_FILE fi myrefresh="yes" ;; esac ;; logview) if [ -n "$FORM_clearlog_yes" -a -n "$FORM_subaction" ] then # -------------------------------------- not good for httpd.log # rm -f $C3SURF_LOG_PATH/$FORM_subaction # -------------------------------------- > $C3SURF_LOG_PATH/$FORM_subaction # -------------------------------------- # unset FORM_subaction # -------------------------------------- FORM_subaction="" myrefresh="yes" fi if [ -n "$FORM_download" -a -n "$FORM_subaction" ] then http_header download "ctype=text/plain;filename=$FORM_subaction" /bin/cat "$C3SURF_LOG_PATH"/"$FORM_subaction" exit 0 fi ;; esac # #################################################### # mache eine Refresh, damit die get-Parameter aus dem Browser verschwinden # #################################################### if [ "$myrefresh" = "yes" ] then echo "Location: $myname?action=$FORM_action" echo exit fi # nur die "online" Seite aktualisieren if [ "$FORM_action" = "online" ] then show_html_header "c3Surf $C3SURF_VERSION" "refresh=60;url=$myname?action=$FORM_action" else show_html_header "c3Surf $C3SURF_VERSION" fi echo "

c3Surf Admin   → $_login_page_link ←

" echo "
" # Jetzt in lang/c3surf.de # _online="Wer ist online" # _blocklist="IP Blocklist" # _blacklist="MAC Blacklist" # _arplist="ARP Tabelle" # _lockme="Deny all Logins" # _logview="Logdatei" # ################################# # Tabs ausgeben ################################# # show the leases tab if we have a valid leases file if [ -f "$c3surf_leases_file" ] then have_lease=yes else have_lease=no fi # for use with fli4l < 2.3.0, show voucher tab # [ -z "$OPT_C3SURF_VOUCHER" ] && OPT_C3SURF_VOUCHER="no" : ${OPT_C3SURF_VOUCHER:=no} case $have_lease$OPT_LOGINUSR$OPT_C3SURF_VOUCHER in yesyesyes) show_tab_header "$_online" "$myname?action=online" \ "$_userdata" "$myname?action=userdata" \ "$_voucher" "$myname?action=voucher" \ "$_blocklist" "$myname?action=blocklist" \ "$_blacklist" "$myname?action=blacklist" \ "$_arplist" "$myname?action=arplist" \ "$_leaseslist" "$myname?action=leaseslist" \ "$_lockme" "$myname?action=lockme" \ "$_logview" "$myname?action=logview" ;; yesyesno) show_tab_header "$_online" "$myname?action=online" \ "$_userdata" "$myname?action=userdata" \ "$_blocklist" "$myname?action=blocklist" \ "$_blacklist" "$myname?action=blacklist" \ "$_arplist" "$myname?action=arplist" \ "$_leaseslist" "$myname?action=leaseslist" \ "$_lockme" "$myname?action=lockme" \ "$_logview" "$myname?action=logview" ;; yesnono) show_tab_header "$_online" "$myname?action=online" \ "$_blocklist" "$myname?action=blocklist" \ "$_blacklist" "$myname?action=blacklist" \ "$_arplist" "$myname?action=arplist" \ "$_leaseslist" "$myname?action=leaseslist" \ "$_lockme" "$myname?action=lockme" \ "$_logview" "$myname?action=logview" ;; noyesyes) show_tab_header "$_online" "$myname?action=online" \ "$_userdata" "$myname?action=userdata" \ "$_voucher" "$myname?action=voucher" \ "$_blocklist" "$myname?action=blocklist" \ "$_blacklist" "$myname?action=blacklist" \ "$_arplist" "$myname?action=arplist" \ "$_lockme" "$myname?action=lockme" \ "$_logview" "$myname?action=logview" ;; noyesno) show_tab_header "$_online" "$myname?action=online" \ "$_userdata" "$myname?action=userdata" \ "$_blocklist" "$myname?action=blocklist" \ "$_blacklist" "$myname?action=blacklist" \ "$_arplist" "$myname?action=arplist" \ "$_lockme" "$myname?action=lockme" \ "$_logview" "$myname?action=logview" ;; *) show_tab_header "$_online" "$myname?action=online" \ "$_blocklist" "$myname?action=blocklist" \ "$_blacklist" "$myname?action=blacklist" \ "$_arplist" "$myname?action=arplist" \ "$_lockme" "$myname?action=lockme" \ "$_logview" "$myname?action=logview" ;; esac case $FORM_action in ################################# ### TAB: Wer ist online ### ################################# online) echo "" # Angemeldete suchen for f in $C3SURF_TMP_PATH/*.time do # schließe den Abfrage-String aus if [ "$f" = "$C3SURF_TMP_PATH/*.time" ] then show_info "$_gen_info_head" "$_onl_info_nobody_txt" else { read c3surf_time c3surf_count c3surf_id c3surf_ip c3surf_mac c3surf_vorname c3surf_name c3surf_mail c3surf_curfew } < $f # Restzeit berechnen # if [ "$c3surf_id" = "-" ] if [ $c3surf_time -eq 0 ] then show_time="∞" else c3surf_now=`date +%s` c3surf_time=`/usr/bin/expr $c3surf_time - $c3surf_now` c3surf_time=`/usr/bin/expr $c3surf_time / 60` if [ $c3surf_time -le 1 ] then show_time=" ≤1" else show_time=$c3surf_time fi fi # Ausgabe der Header (einmalig) if [ $c3surf_tab_virgin = true ] then cat <<-EOF EOF c3surf_tab_virgin=false fi if [ -z "$c3surf_mail" -o "$c3surf_mail" = "none" -o "$c3surf_mail" = "-" ] then mymail="" else mymail="$c3surf_mail" fi # Ausgabe der Inhalte cat <<-EOF " fi echo "\ " # Ende else fi done # Tabelle schließen echo "
$_gen_h_ip
$_gen_h_mac
$_gen_h_id
$_gen_h_forename
$_gen_h_surname
$_gen_h_mail
$_gen_h_time
($_gen_h_minutes)
$_gen_h_prolong
($_gen_h_minutes)
$_gen_h_reduce
($_gen_h_minutes)
$_gen_h_command
$c3surf_ip
$c3surf_mac
$c3surf_id
$c3surf_vorname
$c3surf_name
$mymail
$show_time
EOF # if [ ! "$c3surf_id" = "-" ] if [ ! $c3surf_time -eq 0 ] then cat <<-EOF  +15  +30  +60
 +120  +240 
 -15  -30  -60
 -120  -240  EOF else echo "
 $_onl_cmd_logout " if [ ! "$c3surf_id" = "-" ] # if [ ! $c3surf_time -eq 0 ] then echo "
\  $_onl_cmd_blockip 240 min 
\  $_onl_cmd_macblack " fi echo "
" ################################# ### ende TAB: Wer ist online ### ################################# ;; ################################# ### TAB: Accounts ### ################################# userdata) # --------------------------- # Arbeitsbereich Benutzer neu anlegen, editiern und löschen # --------------------------- # init vars my_cmd="$_usr_cmd_add" my_work="usr_add" my_esc="" if [ "$FORM_work" = "usr_edit" ] then if [ -f "$C3SURF_READ_PATH/$FORM_uid.data" ] then . "$C3SURF_READ_PATH/$FORM_uid.data" my_cmd="$_usr_cmd_save" my_work="usr_save" my_esc="$_usr_cmd_esc" fi fi if [ "$FORM_work" = "usr_delete" ] then if [ -f "$C3SURF_READ_PATH/$FORM_uid.data" ] then . "$C3SURF_READ_PATH/$FORM_uid.data" my_cmd="$_usr_cmd_del" my_work="usr_del" my_esc="$_usr_cmd_esc" fi fi # Form cat <<-EOF
$_gen_h_workingarea
$_gen_h_id
$_gen_h_forename
$_gen_h_surname
$_gen_h_mail
$_gen_h_password
$_gen_h_time
$_gen_h_minutes
$_gen_h_blocktime
$_gen_h_minutes
$_gen_h_counter
$_gen_h_command
$_usr_h_defaultvals
$C3SURF_TIME
$C3SURF_BLOCKTIME
$C3SURF_COUNTER
$my_esc
$_usr_h_curfew

EOF # --------------------------- # Anzeigebereich Benutzer # --------------------------- if [ -z "$FORM_work"] then echo "" # Userdaten suchen for f in "$C3SURF_READ_PATH"/*.data do # schließe den Abfrage-String aus if [ "$f" = "$C3SURF_READ_PATH/*.data" ] then show_info "$_gen_info_head" "$_usr_info_noaccount_txt" else . "$f" # # Userdaten ggf. auf Default setzen # # do work if user has no module signature # ---- Voucher addon (signature) ----- # need this after activateVoucher in c3surf_worker if [ -z "$fsmodule"] then # C3SURF_TIME if [ -z "$fssecs" ] then fstime=$C3SURF_TIME fssecs=$C3SURF_SECS else # compatibility with older c3surf version if [ -z "$fstime" ] then fstime=$(expr "$fssecs" \/ "60") fi fi # C3SURF_BLOCKTIME if [ -z "$fsblocksecs" ] then fsblocktime=$C3SURF_BLOCKTIME fsblocksecs=$C3SURF_BLOCKSECS else # compatibility with older c3surf version if [ -z "$fsblocktime" ] then if [ $fsblocksecs -gt 0 ] then fsblocktime=$(expr "$fsblocksecs" \/ "60") else fsblocktime=$fsblocksecs fi fi fi # C3SURF_COUNTER if [ -z "$fscounter" ] then fscounter=$C3SURF_COUNTER fi # # Lese die Quota Daten # if [ -f "$C3SURF_TMP_PATH/$fsid.quota" ] then { read c3surf_quota_ts c3surf_quota_time c3surf_quota_maxtime c3surf_quota_count c3surf_quota_maxcount } < "$C3SURF_TMP_PATH/$fsid.quota" # noch für Anzeige berechnen # # --- hier noch berechnen # # ggf. die aktuellen Zahlen ermitteln - Rechenzeit? # # --- hier noch berechnen # else c3surf_quota_ts="-" c3surf_quota_time="-" c3surf_quota_maxtime="-" c3surf_quota_count="-" c3surf_quota_maxcount="$fscounter" fi # special display for negative c3surf_quota_maxcount case $c3surf_quota_maxcount in -2) c3surf_quota_maxcount="*" ;; -1) c3surf_quota_maxcount="-" ;; esac if [ $c3surf_quota_maxtime -eq 0 ] ; then c3surf_quota_time="∞" ; fi # Ausgabe der Header (einmalig) if [ $c3surf_tab_virgin = true ] then cat <<-EOF EOF c3surf_tab_virgin=false fi if [ -z "$fsmail" -o "$fsmail" = "none" -o "$fsmail" = "-" ] then mymail="" else mymail="$fsmail" fi my_bgcolor="" if [ -f $C3SURF_TMP_PATH/$fsid.online ] then my_bgcolor=" bgcolor=\"lightgreen\"" fi if [ -f $C3SURF_TMP_PATH/$fsid.block ] then my_bgcolor=" bgcolor=\"lightcoral\"" fi # ################### #if [ -n "$fscurfew" ] #then # mymail="$mymail
$fscurfew" #fi # ################### # Ausgabe der Inhalte cat <<-EOF
$fsid
EOF else # unset the voucher data unset fsmodule fsvalid fi # end if -z fsmodule # unset the module-tag unset fsid fspw fsname fsvorname fsmail fssecs fsblocksecs fscounter fstime fsblocktime fscurfew # End else read user.data file fi done # Tabelle schließen echo "
$_gen_h_id
$_gen_h_forename
$_gen_h_surname
$_gen_h_mail
$_gen_h_curfew
$_gen_h_time
$_gen_h_minutes

($_gen_h_seconds)
$_gen_h_blocktime
$_gen_h_minutes

($_gen_h_seconds)
$_gen_h_counter
$_gen_h_quota
$_gen_h_command
$_gen_h_time
$_gen_h_seconds
$_gen_h_counter / $_gen_h_max
$fsvorname
$fsname
$mymail
$fscurfew
$fstime
($fssecs)
$fsblocktime
($fsblocksecs)
$fscounter
$c3surf_quota_time
$c3surf_quota_count / $c3surf_quota_maxcount
$_usr_cmd_userprefix $_usr_cmd_edit $_usr_cmd_del $_usr_cmd_quotaprefix $_usr_cmd_quotareset
" fi # check FORM_work ################################# ### ende TAB: Accounts ### ################################# ;; ################################# ### TAB: Voucher ### ################################# voucher) # init vars # for expire date calculation v_now=$(/bin/date +%s) # : ${FORM_filter:=*} if [ -n "$FORM_filter" ] then filter_option="" fi filter_option="$filter_option " for idx in `seq 1 $C3SURF_VOUCHER_N` do filter_option="$filter_option " done # --------------------------- # Arbeitsbereich Voucher # --------------------------- # init vars # my_cmd="$_usr_cmd_add" # my_work="usr_add" # my_esc="" if [ -s "$C3SURF_VOUCHER_PRINTFILE" ] then select other languages myLangSelect="" for f in /srv/www/lang/c3surf.* do # schließe den Abfrage-String und die selektierte Sprache aus if [ "$f" != "/srv/www/lang/c3surf.*" ] then otherLang=${f#*.} myLangSelect="$myLangSelect ‹$otherLang›" fi done if [ -n "$myLangSelect" ] then myLangSelect="$_vch_cmd_print$myLangSelect  " else myLangSelect="$_vch_cmd_print" fi cat <<-EOF
$_gen_h_printfile
$_gen_h_workfile   $myLangSelect   $_vch_cmd_downprint   $_vch_cmd_delprint
EOF fi #if [ -n "$FORM_clearlog" ] if [ "$FORM_cmd" = "$_vch_cmd_force" ] then vch_ask="→" fi cat <<-EOF
              $vch_ask EOF if [ "$FORM_cmd" = "$_vch_cmd_force" ] then show_info "$_vch_force_titel" "$_vch_force_question" fi # --------------------------- # Anzeigebereich Voucher # --------------------------- if [ -z "$FORM_work"] then echo "" # Userdaten suchen for f in "$C3SURF_READ_PATH"/$FORM_filter*.data-voucher do # schließe den Abfrage-String aus if [ "$f" = "$C3SURF_READ_PATH/$FORM_filter*.data-voucher" ] then show_info "$_gen_info_head" "$_vch_info_noaccount_txt" else . "$f" # valid and valid thru if [ $fsvalid -eq 0 ] then v_valid="ultimo" v_status="valid" else # need datediff in loop summer/winter difference v_datediff=`/bin/date -d "1970.1.1-0:0:$fsvalid" +%z` v_datediff=`/usr/bin/expr $v_datediff "*" 36` v_valid=`/usr/bin/expr $fsvalid "+" $v_datediff` v_valid=`/bin/date -d "1970.1.1-0:0:$v_valid" +%d.%m.%Y-%H:%M:%S` if [ $fsvalid -eq 0 -o $fsvalid -gt $v_now ] then v_status="good" else v_status="expired" fi fi # # Checke Quota Daten # if [ -f "$C3SURF_TMP_PATH/$fsid.quota" ] then { read c3surf_quota_ts c3surf_quota_time c3surf_quota_maxtime c3surf_quota_count c3surf_quota_maxcount } < "$C3SURF_TMP_PATH/$fsid.quota" if [ $c3surf_quota_maxtime -eq 0 ] then # unlimited gibt es nocht nicht v_status="$v_status ($c3surf_quota_count)" else # das hier gibt es my_left=`/usr/bin/expr $c3surf_quota_time "/" 60` if [ $my_left -lt 1 ] then my_left="<1" fi v_status="$v_status ($c3surf_quota_count)" fstime="$my_left⁄$fstime" fi fi case $fslives in -1) v_lives=$_lives_date ;; 0) v_lives=$_lives_once ;; *) v_lives="$fslives $_lives_hour" ;; esac my_bgcolor="" if [ -f $C3SURF_TMP_PATH/$fsid.online ] then my_bgcolor=" bgcolor=\"lightgreen\"" fi if [ -f $C3SURF_TMP_PATH/$fsid.block ] then my_bgcolor=" bgcolor=\"lightcoral\"" fi # Ausgabe der Header (einmalig) if [ $c3surf_tab_virgin = true ] then cat <<-EOF EOF c3surf_tab_virgin=false fi # Ausgabe der Inhalte cat <<-EOF
$fsid
EOF unset fsid fspw fsname fsvorname fsmail fssecs fsblocksecs fscounter fstime fsblocktime fscurfew fscreated fsmodule fsvalid fslives unset c3surf_quota_ts c3surf_quota_time c3surf_quota_maxtime c3surf_quota_count c3surf_quota_maxcount fi # End else read .data-voucher files done # Tabelle schließen echo "
$_gen_h_id
$_gen_h_time
$_gen_h_minutes
$_gen_h_expiredate
$_gen_h_lives
$_gen_h_status
$_gen_h_created
$_gen_h_command
$fstime
$v_valid
$v_lives
$v_status
$fscreated
$_vch_cmd_del
" fi # check FORM_work ################################# ### ende TAB: Voucher ### ################################# ;; ################################# ### anfang TAB: IP/UID-Blocklist ### ################################# blocklist) echo "" # Angemeldete suchen for f in $C3SURF_TMP_PATH/*.block do # schließe den Abfrage-String aus if [ "$f" = "$C3SURF_TMP_PATH/*.block" ] then show_info "$_gen_info_head" "$_blo_info_noblock_txt" else { read c3surf_time c3surf_mac c3surf_id c3surf_ip } < $f # Restzeit berechnen c3surf_now=`date +%s` c3surf_time=`/usr/bin/expr $c3surf_time - $c3surf_now` c3surf_time=`/usr/bin/expr $c3surf_time / 60` if [ $c3surf_time -le 1 ] then c3surf_time=" ≤1" fi # Ausgabe der Header (einmalig) if [ $c3surf_tab_virgin = true ] then echo "\ \ \ \ \ \ " c3surf_tab_virgin=false fi # Ausgabe der Inhalte echo "\ \ \ \ \ " # Ende else fi done # Tabelle schließen echo "
$_gen_h_id
$_gen_h_ip
$_gen_h_mac
$_gen_h_timelock
(Minuten)
$_gen_h_command
$c3surf_id
$c3surf_ip
$c3surf_mac
$c3surf_time
 $_blo_cmd_unlock " if [ ! "$c3surf_mac" = "" ] then echo "
 $_onl_cmd_macblack " fi echo "
" ################################# ### ende TAB: IP-Blocklist ### ################################# ;; ################################# ### anfang TAB: MAC-Blacklist ### ################################# blacklist) echo "" # Blacklist prüfen if [ -s $C3SURF_BLACKLIST_FILE ] then # schreibe den header echo "\ \ \ \ \ \ " # hole die Daten des Surfers { while read c3surf_mac c3surf_vorname c3surf_name c3surf_mail do # schreibe raus echo "\ \ \ \ \ \ " done } < $C3SURF_BLACKLIST_FILE else # Keine Blacklist vorhanden show_info "$_gen_info_head" "$_blk_info_noblock_txt" fi # Tabelle schließen echo "
$_gen_h_mac
$_gen_h_forename
$_gen_h_surname
$_gen_h_mail
$_gen_h_command
 $c3surf_mac 
 $c3surf_vorname 
 $c3surf_name 
 $c3surf_mail 
 $_blk_cmd_remove 
" # Ende TAB:blaclist [action=blacklist] ################################# ### ende TAB: Blacklist ### ################################# ;; ################################# ### anfang TAB: ARP-list ### ################################# arplist) echo "" # ARP-List lesen { read c3surf_header while read c3surf_ip c3surf_hwtype c3surf_flags c3surf_mac c3surf_mask c3surf_device do # Ausgabe der Header (einmalig) if [ $c3surf_tab_virgin = true ] then echo "\ \ \ \ \ " c3surf_tab_virgin=false fi # Ausgabe der Inhalte echo "\ \ \ \ " done } < /proc/net/arp if [ $c3surf_tab_virgin = true ] then # Keine ARP Einträge vorhanden show_info "$_gen_info_head" "$_arp_info_noarp_txt" fi # Tabelle schließen echo "
$_gen_h_ip
$_gen_h_mac
$_gen_h_device
$_gen_h_command
$c3surf_ip
$c3surf_mac
$c3surf_device
 $_arp_cmd_allow_forever " if [ -n "$c3surf_mac" ] then echo " $_onl_cmd_macblack " fi echo "
" # Ende TAB:arplist [action=arplist] ################################# ### ende TAB: ARP-list ### ################################# ;; ################################### ### anfang TAB: LEASES-list ### ################################### leaseslist) echo "" # LEASES lesen if [ -s $c3surf_leases_file ] then # LEASE Ende Berechnung vorbereiten (Konstante aus der Schleife ziehen) c3surf_datediff=`date +%z` c3surf_datediff=`expr $c3surf_datediff "*" 36` { while read c3surf_leaseend c3surf_mac c3surf_ip c3surf_hostname c3surf_fix do # LEASE Ende berechnen if [ $c3surf_leaseend -eq 0 ] then c3surf_leaseend=$_lease_neverends else c3surf_leaseend=`expr $c3surf_leaseend "+" $c3surf_datediff` c3surf_leaseend=`date -d "1970.1.1-0:0:$c3surf_leaseend" +%d.%m.%Y' '%H:%M:%S` fi # Ausgabe der Header (einmalig) if [ $c3surf_tab_virgin = true ] then echo "\ \ \ \ \ \ " c3surf_tab_virgin=false fi # Ausgabe der Inhalte echo "\ \ \ \ \ " done } < $c3surf_leases_file fi if [ $c3surf_tab_virgin = true ] then # Keine LEASE Einträge vorhanden show_info "$_gen_info_head" "$_lease_info_nolease_txt" fi # Tabelle schließen echo "
$_gen_h_ip
$_gen_h_mac
$_gen_h_hostname
$_gen_h_leaseend
$_gen_h_command
$c3surf_ip
$c3surf_mac
$c3surf_hostname
$c3surf_leaseend
 $_lease_cmd_allow_forever " if [ -n "$c3surf_mac" ] then echo " $_onl_cmd_macblack " fi echo "
" # Ende TAB:leaseslist [action=leaseslist] ################################# ### ende TAB: LEASES-list ### ################################# ;; ################################# ### anfang TAB: Lock c3Surf ### ################################# lockme) # select other languages myLangSelect="" for f in /srv/www/lang/c3surf.* do # schließe den Abfrage-String und die selektierte Sprache aus # if [ "$f" != "/srv/www/lang/c3surf.*" -a "$f" != "/srv/www/lang/c3surf.$c3surf_admin_lang" ] if [ "$f" != "/srv/www/lang/c3surf.*" ] then otherLang=${f#*.} if [ "$otherLang" = "$c3surf_admin_lang" ] then myLangSelect="$myLangSelect ‹$otherLang›" else myLangSelect="$myLangSelect ‹$otherLang›" fi fi done if [ -n "$myLangSelect" ] then if [ "$c3surf_admin_lang" = "httpgui" -o -z "$c3surf_admin_lang" ] then myLangSelect=" $_select_default$myLangSelect" else myLangSelect=" $_select_default$myLangSelect" fi cat <<-EOF  $_select_language: $myLangSelect
EOF fi # check System Status if test -f $C3SURF_SYSLOCK_FILE then show_error "$_lck_msg_header" "$_lck_msg_system_is_locked" echo "" echo "
" echo "\ \ " else if [ "$OPT_LOGINUSR" = "yes" ] then show_info "$_lck_msg_header" "$_lck_msg_system_is_unlocked_for_login" else show_info "$_lck_msg_header" "$_lck_msg_system_is_unlocked_for_free" fi echo "
  $_lck_action_unlock  
" echo "
" echo "\ \ \ " fi # Tabelle schließen echo "
 $_lck_action_lock_only 
 $_lck_action_lock_logout 
" echo "
" # Ende TAB:online [main=lockme] ################################# ### ende TAB: Lock 3surf ### ################################# ;; ################################# ### anfang TAB: Logview ### ################################# logview) # some constants (basename of log) = sort order of logfiles log_file1="c3surf_login.log" log_file2="c3surf_invalid.log" log_file3="c3surf_page.log" log_file4="c3surf_httpd.log" log_file5="c3surf_worker.log" _log_sort_normal_idx="1" _log_sort_reverse_idx="2" # some defaults : ${FORM_log_lines:=30} : ${FORM_log_sort:=$_log_sort_reverse_idx} : ${FORM_showall:=} ################################# # Tabs generieren ################################# fs_tabs="" for f in "$log_file1" "$log_file2" "$log_file3" "$log_file4" "$log_file5" do # teste ob Datei da ist # if test -f $C3SURF_LOG_PATH/$f # teste ob Datei mit Inhalt da ist if test -s $C3SURF_LOG_PATH/$f then : ${FORM_subaction:=$f} if [ $FORM_subaction = $f ] then fs_tabs=$(echo "$fs_tabs" "$f" "no") else fs_tabs=$(echo "$fs_tabs" "$f" "$myname?action=logview&subaction=$f&log_sort=$FORM_log_sort&log_lines=$FORM_log_lines") fi fi done ################################# # Tabs ausgeben ################################# if [ -n "$fs_tabs" ] then # prepare select field for sort log_sorta_idx=$FORM_log_sort if [ $log_sorta_idx -eq $_log_sort_reverse_idx ] then log_sortb_idx=$_log_sort_normal_idx log_sortb_txt=$_log_sort_normal_txt log_sorta_txt=$_log_sort_reverse_txt else log_sortb_idx=$_log_sort_reverse_idx log_sortb_txt=$_log_sort_reverse_txt log_sorta_txt=$_log_sort_normal_txt fi # formular Auswahl cat <<-EOF
         EOF if [ -n "$FORM_clearlog" ] then cat <<-EOF → EOF fi cat <<-EOF
EOF if [ -n "$FORM_clearlog" ] then show_info "$FORM_subaction" "$_log_clear_question" else show_tab_header $fs_tabs # table header echo "" if [ $c3surf_tab_virgin = true ] then case $FORM_subaction in $log_file1) echo "\ \ \ \ \ \ \ \ \ " ;; $log_file2) echo "\ \ \ \ \ \ " ;; $log_file3) echo "\ \ \ \ \ " ;; *) echo "\ \ " esac c3surf_tab_virgin=false fi # generischer Teil if [ -n "$FORM_showall" ] then if [ $FORM_log_sort -eq $_log_sort_reverse_idx ] then cat $C3SURF_LOG_PATH/$FORM_subaction | sed '1!G;h;$!d' | simple_output else cat $C3SURF_LOG_PATH/$FORM_subaction | simple_output fi else if [ $FORM_log_sort -eq $_log_sort_reverse_idx ] then cat $C3SURF_LOG_PATH/$FORM_subaction | do_tail $FORM_log_lines | sed '1!G;h;$!d' | simple_output else cat $C3SURF_LOG_PATH/$FORM_subaction | do_tail $FORM_log_lines | simple_output fi fi # Tabelle schließen echo "
$_gen_h_timestamp
$_gen_h_ip
$_gen_h_id
$_gen_h_forename
$_gen_h_surname
$_gen_h_mail
$_gen_h_mac
$_gen_h_action
$_gen_h_timestamp
$_gen_h_mac
$_gen_h_error
$_gen_h_ip
$_gen_h_parms
$_gen_h_timestamp
$_gen_h_ip
$_gen_h_browser
$_gen_h_any
$_gen_h_generic
" show_tab_footer fi # Löschen Bestätigen else show_info "$_gen_info_head" "$_log_info_txt" fi # Ende TAB:logview [main=logview] ################################# ### ende TAB: Logview ### ################################# ;; *) show_error "$_tab_gen_err_title" "$_tab_gen_err_unknowntab_text" esac # show_tab_footer # show_html_footer