#!/bin/sh ### # # FreeWLAN Addons - http://www.freewlan.info # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA # # http://www.gnu.org/copyleft/gpl.html # ### . /usr/lib/webif/webif.sh tmp="/tmp/lineadddel_$$.tmp" split_query(){ OIFS=$IFS IFS='&' echo $1 IFS=$OIFS } addtofile(){ echo "$2">>$1 TEXT="$2 added." } delfromfile() { filetmp=/tmp/delfromfile_$$.tmp grep -v "$2" $1 >$filetmp cp $filetmp $1 rm $filetmp TEXT="$2 removed." } go_back() { cat < $TEXT EOF } GET=`split_query $QUERY_STRING` echo $GET >$tmp . $tmp rm $tmp # ACTION ADDDEL CONTENT if [ "x$ADDDEL" != "x" -a "x$ACTION" != "x" -a "x$CONTENT" != "x" ];then case $ACTION in macblock) textfile=/etc/blockmac case $ADDDEL in 1) addtofile $textfile $CONTENT save_setting blockmac main enable "1" commit_settings /etc/init.d/S41blockmac noclear >/dev/null 2>&1 ;; 2) delfromfile $textfile $CONTENT iwpriv=/usr/sbin/iwpriv $iwpriv ath0 maccmd 2 >/dev/null 2>&1 $iwpriv ath0 delmac $CONTENT /etc/init.d/S41blockmac noclear >/dev/null 2>&1 ;; esac ;; userblock) textfile=/etc/blockuser case $ADDDEL in 1) addtofile $textfile $CONTENT /etc/init.d/S41blockmac >/dev/null 2>&1 ;; 2) delfromfile $textfile $CONTENT /etc/init.d/S41blockmac >/dev/null 2>&1 ;; esac ;; uamallow) textfile=/etc/config/uamallow.txt chillifile=/etc/chilli.allowed case $ADDDEL in 1) addtofile $textfile $CONTENT ;; 2) delfromfile $textfile $CONTENT ;; esac >$chillifile cat $textfile|while read host;do echo "uamallowed $host" >>$chillifile done /etc/init.d/N50chillispot radconfig killall chilli ;; staticip) textfile=/etc/config/staticip.txt ethers=/etc/ethers case $ADDDEL in 1) addtofile $textfile "$CONTENT" ;; 2) delfromfile $textfile "$CONTENT" ;; esac >$ethers cat $textfile|while read string;do mac=`echo $string|cut -d'=' -f1` ip=`echo $string|cut -d'=' -f2` echo "$mac $ip" >>$ethers done lock -u /var/run/restart-services ;; ff) textfile=/etc/config/localusers.txt localusers=/etc/config/localusers case $ADDDEL in 1) addtofile $textfile "$CONTENT" ;; 2) delfromfile $textfile "$CONTENT" ;; esac cat $textfile > $localusers killall -HUP chilli 2>/dev/null ;; esac fi TEXT="" go_back 0