]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/outgoinggrp.cgi
Fixed qos device detection on connection type change.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / outgoinggrp.cgi
CommitLineData
fdeaa057
CS
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
75842d01 5# Copyright (C) 2005-2010 IPFire Team #
fdeaa057
CS
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# enable only the following on debugging purpose
24#use warnings;
25#use CGI::Carp 'fatalsToBrowser';
26
27require '/var/ipfire/general-functions.pl';
28require "${General::swroot}/lang.pl";
29require "${General::swroot}/header.pl";
30
31my %outgrpsettings = ();
32my %netsettings = ();
33my %selected= () ;
34my $errormessage = "";
35
36my $configpath = "/var/ipfire/outgoing/groups/";
37my $servicefile = "/var/ipfire/outgoing/defaultservices";
38
39my %color = ();
40my %mainsettings = ();
41&General::readhash("${General::swroot}/main/settings", \%mainsettings);
42&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
43
44&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
45
46&Header::showhttpheaders();
47
48### Values that have to be initialized
49$outgrpsettings{'ACTION'} = '';
50$outgrpsettings{'ipgroup'} = 'none';
51$outgrpsettings{'portgroup'} = 'none';
52
53&Header::getcgihash(\%outgrpsettings);
54delete $outgrpsettings{'__CGI__'};delete $outgrpsettings{'x'};delete $outgrpsettings{'y'};
55
56$selected{'ipgroup'}{$outgrpsettings{'ipgroup'}} = "selected='selected'";
57$selected{'portgroup'}{$outgrpsettings{'portgroup'}} = "selected='selected'";
58
59&Header::openpage($Lang::tr{'outgoing firewall groups'}, 1, '');
60&Header::openbigbox('100%', 'left', '', $errormessage);
61
62###############
63# DEBUG DEBUG
64# &Header::openbox('100%', 'left', 'DEBUG');
65# my $debugCount = 0;
66# foreach my $line (sort keys %outgrpsettings) {
67# print "$line = $outgrpsettings{$line}<br />\n";
68 # $debugCount++;
69# }
70# print "&nbsp;Count: $debugCount\n";
71# &Header::closebox();
72# DEBUG DEBUG
73###############
74
75############################################################################################################################
76############################################################################################################################
77
78if ($errormessage)
79{
80 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
81 print "<class name='base'>$errormessage\n";
82 print "&nbsp;</class>\n";
83 &Header::closebox();
84}
85
86if ($outgrpsettings{'ACTION'} eq 'newipgroup')
87{
88 &newipgroup();
89} elsif ($outgrpsettings{'ACTION'} eq 'deleteipgroup' ) {
90 unlink("$configpath/ipgroups/$outgrpsettings{'ipgroup'}");
91} elsif ($outgrpsettings{'ACTION'} eq 'addipgroup') {
92 open (FILE, ">$configpath/ipgroups/$outgrpsettings{'ipgroup'}") or die "Can't save $outgrpsettings{'ipgroup'} settings $!";
93 flock (FILE, 2);
94 print FILE $outgrpsettings{'ipgroupcontent'}."\n";
95 close FILE;
96}
97
98############################################################################################################################
99############################################################################################################################
100
101my @ipgroups = qx(ls $configpath/ipgroups/);
102if ($outgrpsettings{'ipgroup'} eq "none" and $#ipgroups >= 0 ){ $outgrpsettings{'ipgroup'} = $ipgroups[0];}
103
104my $ipgroupcontent = `cat $configpath/ipgroups/$outgrpsettings{'ipgroup'} 2>/dev/null`;
105$ipgroupcontent =~ s/\n/<br \/>/g;
106
107&Header::openbox('100%', 'center', $Lang::tr{'outgoing firewall ip groups'});
108
109print <<END
fdeaa057
CS
110<br />
111<form method='post' action='$ENV{'SCRIPT_NAME'}#outgoing showipgroup'>
112<table width='95%' cellspacing='0'>
113 <tr>
114 <td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'outgoing firewall ip groups'}</b></td>
115 </tr>
116 <tr>
117 <td colspan='3' align='left'><br /></td>
118 </tr>
119 <tr>
120 <td align='left' colspan='2'><select name='ipgroup' style="width: 200px">
121END
122;
123foreach my $member (@ipgroups) {chomp $member;print" <option value='$member' $selected{'ipgroup'}{$member}>$member</option>\n";}
124print <<END
125 </select></td>
126 <td align='left'>
127 <input type='hidden' name='ACTION' value='showipgroup' />
128 <input type='image' alt='$Lang::tr{'outgoing firewall view group'}' title='$Lang::tr{'outgoing firewall view group'}' src='/images/format-justify-fill.png' />
129 </td>
130 </tr>
131 <tr>
132 <td colspan='3' align='left'><br /></td>
133 </tr>
134 <tr>
135 <td colspan='3' align='left'><font size=1>$ipgroupcontent</font></td>
136 </tr>
137 <tr>
138 <td colspan='3' align='left'><br /></td>
139 </tr>
140 <tr>
141 <td colspan='3' align='center'><font size=1>$Lang::tr{'outgoing firewall ip groups'} - $outgrpsettings{'ipgroup'}</font></td>
142 </tr>
143</table>
144</form>
145<table width='10%' cellspacing='0'>
146<tr>
147 <td align='center'>
148 <form method='post' action='$ENV{'SCRIPT_NAME'}#outgoing showipgroup'>
149 <input type='hidden' name='ACTION' value='newipgroup' />
150 <input type='image' alt='$Lang::tr{'new'}' title='$Lang::tr{'new'}' src='/images/list-add.png' />
151 </form>
152 </td>
153 <td align='center'>
154 <form method='post' action='$ENV{'SCRIPT_NAME'}#outgoing showipgroup'>
155 <input type='hidden' name='ACTION' value='saveipgroup' />
156 <input type='hidden' name='ipgroup' value='$outgrpsettings{'ipgroup'}' />
157 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' />
158 </form>
159 </td>
160 <td align='center'>
161 <form method='post' action='$ENV{'SCRIPT_NAME'}#outgoing showipgroup'>
162 <input type='hidden' name='ACTION' value='deleteipgroup' />
163 <input type='hidden' name='ipgroup' value='$outgrpsettings{'ipgroup'}' />
164 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/user-trash.png' />
165 </form>
166 </td>
167</tr>
168</table>
169
170END
171;
172&Header::closebox();
173
174&Header::closebigbox();
175&Header::closepage();
176
177sub newipgroup
178{
179 &Header::openbox('100%', 'center', $Lang::tr{'outgoing firewall add ip group'});
180
181print <<END
182 <form method='post' action='$ENV{'SCRIPT_NAME'}#outgoing showipgroup'>
183 <table width='95%' cellspacing='0'>
184 <tr>
185 <td bgcolor='$color{'color20'}' colspan='3' align='left'><b>$Lang::tr{'outgoing firewall add ip group'}</b></td>
186 </tr>
187 <tr>
188 <td colspan='3' align='left'><br /></td>
189 </tr>
190 <tr>
191 <td align='left' colspan='2'>
192 <input type='text' name='ipgroup' value='newgroup' size="30" />
193 </td>
194 <td align='left'>
195 <input type='hidden' name='ACTION' value='addipgroup' />
196 <input type='image' alt='$Lang::tr{'save'}' title='$Lang::tr{'save'}' src='/images/media-floppy.png' />
197 </td>
198 </tr>
199 <tr>
200 <td align='left' colspan='3'>
6411b32c 201 <textarea name="ipgroupcontent" cols="20" rows="5" Wrap="off">192.168.1.0/24\n192.168.3.0/255.255.255.0\n192.168.0.1\n192.168.0.2\n</textarea>
fdeaa057
CS
202 </td>
203 </tr>
204 </table>
205 </form>
206END
207;
208 &Header::closebox();
209 &Header::closebigbox();
210 &Header::closepage();
211 exit 0;
d47236e0 212}