#!/usr/bin/webif-page >|max=10|$FORM_submit EOF . /usr/lib/webif/advanced.sh textfile=/etc/config/uamallow.txt tmpfile=/tmp/uamallow.txt chillifile=/etc/chilli.allowed touch $textfile touch $tmpfile lines=0 initbutton=1 actiondone=0 freewlan_check=1 check_freewlan() { testurl=`cat $textfile | grep -i "freewlan.info"` if [ "$testurl" = "" ]; then echo "freewlan.info" >>$textfile fi } sep() { OIFS=$IFS IFS=',' for i in $*;do echo $i; done IFS=$OIFS } reset_list_to_chilli_defaults() { get_default enable main enable save_setting uamallow main enable "0" commit_settings /etc/init.d/N50chillispot radconfig save_setting uamallow main enable "1" commit_settings FORM_enable="1" grep ^uamallowed /etc/chilli.conf |while read s;do sep $s done|grep -v uamallowed |sort -r >$textfile } config_load uamallow empty "$FORM_delete" || { cp $textfile $tmpfile FORM_enable=1 FORM_submit=1 FORM_newentry="" initbutton=0 resetbutton=1 appendbutton=0 actiondone=1 freewlan_check=1 } empty "$FORM_init" || { cp $textfile $tmpfile reset_list_to_chilli_defaults FORM_enable=1 FORM_submit=1 initbutton=0 resetbutton=1 appendbutton=1 actiondone=1 freewlan_check=0 } empty "$FORM_reset" || { cp $tmpfile $textfile FORM_enable=1 FORM_submit=1 initbutton=1 resetbutton=0 appendbutton=0 actiondone=0 freewlan_check=0 } empty "$FORM_append" || { cat $tmpfile $textfile >/tmp/uamallow_append.txt mv /tmp/uamallow_append.txt $textfile FORM_enable=1 FORM_submit=1 initbutton=0 resetbutton=1 appendbutton=0 actiondone=1 freewlan_check=0 } if empty "$FORM_submit"; then get_default enable main enable else enabled $FORM_enable || { >$chillifile #>$textfile } c=0; if enabled $FORM_enable;then save=1 if [ "x$FORM_newentry" != "x" ];then validate <>|required|$FORM_newentry EOF if [ $? = 0 ];then echo $FORM_newentry >>$textfile FORM_newentry="" fi else ## checking number of lines c=`cat $textfile | wc -l`; c=${c##* } ## checking lines to delete while [ $c != "0" ]; do eval FORM="\$FORM_uam$c" if [ "$FORM" = "checked" ]; then sed -e "${c}D" -i $textfile lines=$((lines-1)) fi c=$((c-1)) done fi [ $save = 1 -a $FORM_enable = 1 ] && lines=$((lines+1)) fi if [ "$actiondone" = "0" ]; then test -f "$tmpfile" && rm -f "$tmpfile" fi fi # FORM_submit empty "$FORM_submit" || { save_setting uamallow main enable "$FORM_enable" commit_settings SAVED=1 } if [ "$freewlan_check" = "1" ]; then check_freewlan fi enabled $FORM_enable && { lines=`wc -l $textfile`; lines=${lines% *}; } header "Additional Hostnames" cat < EOF display_form <> start_select_cell|enable|$FORM_enable|tableTextSelect|enablechange option|0|@TR<> option|1|@TR<> end_select_cell end_row end_table start_table|0|10|5 add_row add_button_cell|submit|@TR<>|tableTextButton end_row end_table start_div|enabled start_div|buttons start_table|0|10|5 add_row EOF display_form <>: end_row EOF c=0; if [ $lines != 0 ];then for string in `cat $textfile`;do c=$((c+1)) display_form <> $c: add_normal_cell|$string add_checkbox_cell|uam$c||checked end_row EOF done fi display_form <>: add_input_cell|newentry|$FORM_newentry|tableTextButton end_row end_table start_table|0|10|5 add_row add_button_cell|submit|@TR<>|tableTextButton add_label_cell add_label_cell add_button_cell|delete|@TR<>|tableTextButton end_row end_table end_div help|uamallow call_js|enablechange EOF [ "$SAVED" = "1" ] && { >$chillifile if enabled $FORM_enable;then cat $textfile|while read host;do echo "uamallowed $host" >>$chillifile done fi /etc/init.d/N50chillispot reload >/dev/null 2>/dev/null } enabled $FORM_enable || { >$chillifile } footer ?>