From: Jan Paul Tuecking Date: Thu, 16 Jul 2009 16:03:39 +0000 (+0200) Subject: Insert page to change mac address of red0. X-Git-Tag: v2.5-core29~36 X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=commitdiff_plain;h=ed7079a45157edac02446a5217482802016f894e Insert page to change mac address of red0. --- diff --git a/html/cgi-bin/mac.cgi b/html/cgi-bin/mac.cgi new file mode 100755 index 0000000000..30e47a9a4e --- /dev/null +++ b/html/cgi-bin/mac.cgi @@ -0,0 +1,123 @@ +#!/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{'RECONNECT'} eq "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(); +} + +# 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 +; + +&Header::closebox(); + +print "\n"; + +&Header::closebigbox(); + +&Header::closepage(); +