#!/usr/bin/perl ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2007 Michael Tremer & Christian Schmidt # # # # 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 3 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, see . # # # ############################################################################### use strict; # enable only the following on debugging purpose #use warnings; #use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my %macsettings=(); my $errormessage = ''; &Header::showhttpheaders(); &General::readhash("${General::swroot}/mac/settings", \%macsettings); &Header::getcgihash(\%macsettings); &Header::openpage($Lang::tr{'mac address title'}, 1, ); &Header::openbigbox('100%', 'left', '', $errormessage); if ($macsettings{'ACTION'} eq $Lang::tr{'save'}) { $macsettings{'MAC'} =~ s/\-/:/g; my @mac = split(/:/,$macsettings{"MAC"}); if ($#mac == 5) { if (($mac[0] eq "00")||($mac[0] eq "0")){ foreach (@mac) { unless ($_ =~ /^[a-fA-F0-9]{1,2}$/) { $errormessage = $Lang::tr{'mac address error not valid'}; last; } } } else { $errormessage = $Lang::tr{'mac address error not 00'}; } if ($errormessage eq "") { $macsettings{'MAC'} =~ s/\:/-/g; &General::writehash("${General::swroot}/mac/settings", \%macsettings); &Header::openbox('100%', 'left', $Lang::tr{'mac address saved'}); print "$Lang::tr{'mac address saved txt'}\n"; &Header::closebox(); } } else { $errormessage = $Lang::tr{'mac address error not valid'}; } } if ($macsettings{'ACTION'} eq $Lang::tr{'reconnect'}) { system("/usr/local/bin/redctrl restart >/dev/null 2>&1 &"); &Header::openbox('100%', 'left', $Lang::tr{'mac address recon'} ); print "$Lang::tr{'mac address done'}\n"; &Header::closebox(); } if ($macsettings{'ACTION'} eq $Lang::tr{'delete'} ) { system("cat /dev/null > ${General::swroot}/mac/settings &"); &Header::openbox('100%', 'left', $Lang::tr{'mac address deleted'} ); print "$Lang::tr{'mac address deleted txt'}\n"; &Header::closebox(); } if ($macsettings{'ACTION'} eq $Lang::tr{'reboot'}) { &General::log($Lang::tr{'rebooting ipfire'}); system("/usr/local/bin/ipfirereboot boot"); &Header::openbox('100%', 'left', $Lang::tr{'rebooting ipfire'} ); print "  

"; print ""; &Header::closebox(); } # DPC move error message to top so it is seen! if ($errormessage) { &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); print "$errormessage \n"; &Header::closebox(); } print "
\n"; &Header::openbox('100%', 'left', $Lang::tr{'mac address header'}); print < $Lang::tr{'mac desc'}   $Lang::tr{'mac new'}  END ; if ($macsettings{'ACTION'} eq $Lang::tr{'delete'} ) { print < END ; } else { print < END ; } print <
END ; if ($macsettings{'ACTION'} eq $Lang::tr{'delete'} ) { print <           END ; } elsif ($macsettings{'ACTION'} eq $Lang::tr{'save'} && $errormessage eq "") { print <           END ; } elsif ($macsettings{'ACTION'} eq $Lang::tr{'save'}) { print < END ; } else { print <      END ; } print < END ; &Header::closebox(); print "\n"; &Header::closebigbox(); &Header::closepage();