#!/usr/bin/perl

use strict;
use CWeb::GetVars;
use CWeb::TemplProc;
use CWeb::Tools;
use Config::Sh;
use Config::Security;
use Config::List;

my $gv = new CWeb::GetVars;
my $get = $gv->{FORM};
my $p = new CWeb::TemplProc;
my $conf_sec = new Config::Security;

# ------------------------- command: delete address  -------------------------
	
if ( $get->{ 'cmd' } eq 'del_addr' ) {

	$conf_sec->mac_edit( 'delmacallow' , $get->{'acl_list'} ) ;
	$conf_sec->mac_edit( 'delmacdeny' , $get->{'acl_list'} ) ;
	
	$conf_sec->sec_mode( 'acl' , $get->{ 'acl' } );
	$conf_sec->write();
}

# ------------------------ command: add address -----------------------------

elsif ( $get->{ 'cmd' } eq 'add_addr' ) {

	if ( $get->{'acl_list_add'} eq 'allow' ) {
		$conf_sec->mac_edit( 'addmacallow' , $get->{'mac_new'} ) ;
	}
	elsif ( $get->{'acl_list_add'} eq 'deny' ) {
		$conf_sec->mac_edit( 'addmacdeny' , $get->{'mac_new'} ) ;
	}
	$conf_sec->sec_mode( 'acl' , $get->{ 'acl' } );
	$conf_sec->write();
}

# ------------------------ command: ok button ------------------------------

if ( $get->{ 'cmd' } eq 'ok' ) {
	
	$conf_sec->sec_mode( 'acl' , $get->{ 'acl' } );
	$conf_sec->write();
}	

my $sec_val = $conf_sec->values_get();
#$sec_val->{FW_SETTINGS} = $fw->{VARS};
$p->process_template( "templates/security_wlanaddrfilter.html", $sec_val );
