]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/mac.cgi
Don't remove old kernel version at update of linux-xen
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / mac.cgi
CommitLineData
ed7079a4
JPT
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6# #
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. #
11# #
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. #
16# #
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/>. #
19# #
20###############################################################################
21
22use strict;
23
24# enable only the following on debugging purpose
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
31
32my %macsettings=();
33my $errormessage = '';
34
35&Header::showhttpheaders();
36
37&General::readhash("${General::swroot}/mac/settings", \%macsettings);
38
39&Header::getcgihash(\%macsettings);
40
41&Header::openpage($Lang::tr{'mac address title'}, 1, );
42
43&Header::openbigbox('100%', 'left', '', $errormessage);
44
45if ($macsettings{'ACTION'} eq $Lang::tr{'save'}) {
46 $macsettings{'MAC'} =~ s/\-/:/g;
47 my @mac = split(/:/,$macsettings{"MAC"});
48 if ($#mac == 5) {
49 if (($mac[0] eq "00")||($mac[0] eq "0")){
50 foreach (@mac) {
51 unless ($_ =~ /^[a-fA-F0-9]{1,2}$/) {
52 $errormessage = $Lang::tr{'mac address error not valid'};
53 last;
54 }
55 }
56 } else {
57 $errormessage = $Lang::tr{'mac address error not 00'};
58 }
59 if ($errormessage eq "") {
60 $macsettings{'MAC'} =~ s/\:/-/g;
61 &General::writehash("${General::swroot}/mac/settings", \%macsettings);
62 &Header::openbox('100%', 'left', $Lang::tr{'mac address saved'});
63 print "<font class='base'>$Lang::tr{'mac address saved txt'}</font>\n";
64 &Header::closebox();
65 }
66 } else {
67 $errormessage = $Lang::tr{'mac address error not valid'};
68 }
69}
9ed70c0e 70if ($macsettings{'RECONNECT'} eq $Lang::tr{'reconnect'}) {
ed7079a4
JPT
71 system("/usr/local/bin/redctrl restart >/dev/null 2>&1 &");
72 &Header::openbox('100%', 'left', $Lang::tr{'mac address recon'} );
73 print "<font class='base'>$Lang::tr{'mac address done'}</font>\n";
74 &Header::closebox();
75}
958a98a2
JPT
76if ($macsettings{'DELETE'} eq $Lang::tr{'delete'} ) {
77 system("cat /dev/null > ${General::swroot}/mac/settings &");
78 &Header::openbox('100%', 'left', $Lang::tr{'mac address deleted'} );
79 print "<font class='base'>$Lang::tr{'mac address deleted txt'}</font>\n";
80 &Header::closebox();
81}
ed7079a4
JPT
82
83# DPC move error message to top so it is seen!
84if ($errormessage) {
85 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
86 print "<font class='base'>$errormessage&nbsp;</font>\n";
87 &Header::closebox();
88}
89
90print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
91
92&Header::openbox('100%', 'left', $Lang::tr{'mac address header'});
93print <<END
94
95<table border="0" width='100%'>
96 <tr>
13c13410 97 <td><font class='base'>$Lang::tr{'mac desc'}</font></td>
ed7079a4
JPT
98 </tr>
99 <tr>
13c13410 100 <td>&nbsp;</td>
ed7079a4
JPT
101 </tr>
102 <tr>
13c13410
JPT
103 <td><font class='base'>$Lang::tr{'mac new'}&nbsp;</font>
104 <input type="text" name="MAC" maxlength="17" value='$macsettings{"MAC"}'/></td>
ed7079a4
JPT
105 </tr>
106 <tr>
13c13410 107 <td><hr /></td>
ed7079a4
JPT
108 </tr>
109 <tr>
13c13410
JPT
110 <td><div align="center">
111 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
112 &nbsp;&nbsp;&nbsp;&nbsp;
958a98a2
JPT
113 <input type='submit' name='DELETE' value='$Lang::tr{'delete'}' />
114 &nbsp;&nbsp;&nbsp;&nbsp;
9ed70c0e 115 <input type='submit' name='RECONNECT' value='$Lang::tr{'reconnect'}' />
13c13410 116 </div></td>
ed7079a4
JPT
117 </tr>
118</table>
119
120END
121;
122
123&Header::closebox();
124
125print "</form>\n";
126
127&Header::closebigbox();
128
129&Header::closepage();
130