]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/mac.cgi
7c00cc334289d328bc389b818827975093e06540
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 use CGI
::Carp
'fatalsToBrowser';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
33 my $errormessage = '';
35 &Header
::showhttpheaders
();
37 &General
::readhash
("${General::swroot}/mac/settings", \
%macsettings);
39 &Header
::getcgihash
(\
%macsettings);
41 &Header
::openpage
($Lang::tr
{'mac address title'}, 1, );
43 &Header
::openbigbox
('100%', 'left', '', $errormessage);
45 if ($macsettings{'ACTION'} eq $Lang::tr
{'save'}) {
46 $macsettings{'MAC'} =~ s/\-/:/g;
47 my @mac = split(/:/,$macsettings{"MAC"});
50 unless ($_ =~ /^[a-fA-F0-9]{1,2}$/) {
51 $errormessage = $Lang::tr
{'mac address error not valid'};
56 $errormessage = $Lang::tr
{'mac address error not valid'};
58 $macsettings{'MAC2'} =~ s/\-/:/g;
59 my @mac = split(/:/,$macsettings{"MAC2"});
62 unless ($_ =~ /^[a-fA-F0-9]{1,2}$/) {
63 $errormessage = $Lang::tr
{'mac address error not valid'};
68 $errormessage = $Lang::tr
{'mac address error not valid'};
70 if ($errormessage eq "") {
71 $macsettings{'MAC'} =~ s/\:/-/g;
72 $macsettings{'MAC2'} =~ s/\:/-/g;
73 &General
::writehash
("${General::swroot}/mac/settings", \
%macsettings);
74 &Header
::openbox
('100%', 'left', $Lang::tr
{'mac address saved'});
75 print "<font class='base'>$Lang::tr{'mac address saved txt'}</font>\n";
79 if ($macsettings{'ACTION'} eq $Lang::tr
{'reconnect'}) {
80 system("/usr/local/bin/redctrl restart >/dev/null 2>&1 &");
81 &Header
::openbox
('100%', 'left', $Lang::tr
{'mac address recon'} );
82 print "<font class='base'>$Lang::tr{'mac address done'}</font>\n";
85 if ($macsettings{'ACTION'} eq $Lang::tr
{'delete'} ) {
86 system("cat /dev/null > ${General::swroot}/mac/settings &");
87 &Header
::openbox
('100%', 'left', $Lang::tr
{'mac address deleted'} );
88 print "<font class='base'>$Lang::tr{'mac address deleted txt'}</font>\n";
91 if ($macsettings{'ACTION'} eq $Lang::tr
{'reboot'}) {
92 &General
::log($Lang::tr
{'rebooting ipfire'});
93 system("/usr/local/bin/ipfirereboot boot");
94 &Header
::openbox
('100%', 'left', $Lang::tr
{'rebooting ipfire'} );
95 print " <img src='/images/indicator.gif' /><br /><br />";
96 print "<meta http-equiv='refresh' content='120;'>";
100 # DPC move error message to top so it is seen!
102 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
103 print "<font class='base'>$errormessage </font>\n";
107 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
109 &Header
::openbox
('100%', 'left', $Lang::tr
{'mac address header'});
112 <table border="0" width='100%'>
114 <td colspan=2><font class='base'>$Lang::tr{'mac desc'}</font></td>
117 <td colspan=2> </td><td> </td>
120 <td><font class='base'>$Lang::tr{'mac new'} </font></td><td>
123 if ($macsettings{'ACTION'} eq $Lang::tr
{'delete'} ) {
125 <input type="text" name="MAC" maxlength="17" value=''/></td>
130 <input type="text" name="MAC" maxlength="17" value='$macsettings{"MAC"}'/></td>
137 <td colspan=2> </td><td> </td>
140 <td><font class='base'>$Lang::tr{'mac2 new'} </font></td><td>
143 if ($macsettings{'ACTION'} eq $Lang::tr
{'delete'} ) {
145 <input type="text" name="MAC2" maxlength="17" value=''/></td>
150 <input type="text" name="MAC2" maxlength="17" value='$macsettings{"MAC2"}'/></td>
157 <td colspan=2> </td><td> </td>
160 <td colspan=2><hr /></td>
163 <td colspan=2><div align="center">
166 if ($macsettings{'ACTION'} eq $Lang::tr
{'delete'} ) {
168 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
169
170 <input type='submit' name='ACTION' value='$Lang::tr{'delete'}' />
171
172 <input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' />
175 } elsif ($macsettings{'ACTION'} eq $Lang::tr
{'save'} && $errormessage eq "") {
177 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
178
179 <input type='submit' name='ACTION' value='$Lang::tr{'delete'}' />
180
181 <input type='submit' name='ACTION' value='$Lang::tr{'reconnect'}' />
184 } elsif ($macsettings{'ACTION'} eq $Lang::tr
{'save'}) {
186 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
191 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
192
193 <input type='submit' name='ACTION' value='$Lang::tr{'delete'}' />
211 &Header
::closebigbox
();
213 &Header
::closepage
();