]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/network.cgi
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";
31 require "${General::swroot}/graphs.pl";
43 &Header
::showhttpheaders
();
45 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
47 $ENV{'QUERY_STRING'} =~ s/&//g;
48 @cgiparams = split(/network=/,$ENV{'QUERY_STRING'});
49 $cgiparams[1] = '' unless defined $cgiparams[1];
51 if ($cgiparams[1] =~ /red/) {
52 &Header
::openpage
($Lang::tr
{'network traffic graphs external'}, 1, '');
53 push (@graphs, ($netsettings{'RED_DEV'}));
54 push (@graphs, ("ipsec0"));
55 }elsif ($cgiparams[1] =~ /other/) {
56 &Header
::openpage
($Lang::tr
{'network traffic graphs others'}, 1, '');
57 push (@graphs, ("lq"));
58 push (@graphs, ("fwhits"));
60 &Header
::openpage
($Lang::tr
{'network traffic graphs internal'}, 1, '');
61 push (@graphs, ($netsettings{'GREEN_DEV'}));
62 if ($netsettings{'BLUE_DEV'}) {
63 push (@graphs, ($netsettings{'BLUE_DEV'})); }
64 if ($netsettings{'ORANGE_DEV'}) {
65 push (@graphs, ($netsettings{'ORANGE_DEV'})); }
68 &Header
::openbigbox
('100%', 'left');
70 foreach my $graphname (@graphs) {
72 if ($graphname eq "lq" )
73 { &Graphs
::updatelqgraph
("day"); }
74 elsif ($graphname eq "fwhits" )
75 { &Graphs
::updatefwhitsgraph
("day"); }
77 { &Graphs
::updateifgraph
($graphname, "day"); }
79 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
80 if (-e
"$Header::graphdir/${graphname}-day.png") {
81 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
82 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
83 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
84 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
87 print $Lang::tr
{'no information available'};
93 if ($cgiparams[1] =~ /red/) {
95 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
97 &Header
::openbox
('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
98 if (-s
"${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
100 &General
::readhash
("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \
%dhcpinfo);
102 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
103 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
107 if ($dhcpinfo{'LEASETIME'} ne "") {
108 $lsetme=$dhcpinfo{'LEASETIME'};
109 $lsetme=($lsetme/60);
111 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
113 $leasetime=$lsetme." Minute";
116 $leasetime=$leasetime."s";
121 if ($dhcpinfo{'RENEWALTIME'} ne "") {
122 $rentme=$dhcpinfo{'RENEWALTIME'};
123 $rentme=($rentme/60);
125 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
127 $rnwltime=$rentme." Minute";
130 $rnwltime=$rnwltime."s";
135 if ($dhcpinfo{'REBINDTIME'} ne "") {
136 $maxtme=$dhcpinfo{'REBINDTIME'};
137 $maxtme=($maxtme/60);
139 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
141 $maxtime=$maxtme." Minute";
144 $maxtime=$maxtime."s";
148 print "<table width='100%'>";
149 if ($dhcpinfo{'HOSTNAME'}) {
150 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
152 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
155 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
156 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
157 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
158 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
159 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
160 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
161 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
168 print "$Lang::tr{'no dhcp lease'}";
173 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
174 &Header
::CheckSortOrder
;
175 &Header
::PrintActualLeases
;
180 &Header
::openbox
('100%', 'left', $Lang::tr
{'routing table entries'});
181 $output = `/sbin/ip route show`;
182 $output = &Header
::cleanhtml
($output,"y");
183 print "<pre>$output</pre>\n";
186 &Header
::openbox
('100%', 'left', $Lang::tr
{'arp table entries'});
187 $output = `/sbin/ip neigh show`;
188 $output = &Header
::cleanhtml
($output,"y");
189 print "<pre>$output</pre>\n";
194 &Header
::closebigbox
();
195 &Header
::closepage
();