]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/network.cgi
Removed the old svn commands and started with git.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / network.cgi
CommitLineData
72fe12a9 1#!/usr/bin/perl
70df8302
MT
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###############################################################################
72fe12a9
MT
21
22use strict;
23
24# enable only the following on debugging purpose
cb5e9c6c
CS
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
72fe12a9
MT
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
350b52c5 31require "${General::swroot}/graphs.pl";
72fe12a9
MT
32
33my %cgiparams=();
34my %pppsettings=();
35my %netsettings=();
36my @cgiparams=();
37my @graphs=();
38my $iface='';
39my %dhcpsettings=();
40my %dhcpinfo=();
41my $output='';
42
43&Header::showhttpheaders();
44
45&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
46
47$ENV{'QUERY_STRING'} =~ s/&//g;
48@cgiparams = split(/network=/,$ENV{'QUERY_STRING'});
49$cgiparams[1] = '' unless defined $cgiparams[1];
50
51if ($cgiparams[1] =~ /red/) {
52 &Header::openpage($Lang::tr{'network traffic graphs external'}, 1, '');
a332b303 53 push (@graphs, ($netsettings{'RED_DEV'}));
8fb804b5 54 if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd") {push (@graphs, ("ipsec0"));}
a332b303
CS
55}elsif ($cgiparams[1] =~ /other/) {
56 &Header::openpage($Lang::tr{'network traffic graphs others'}, 1, '');
57 push (@graphs, ("lq"));
58 push (@graphs, ("fwhits"));
59}else {
72fe12a9 60 &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, '');
a332b303 61 push (@graphs, ($netsettings{'GREEN_DEV'}));
72fe12a9 62 if ($netsettings{'BLUE_DEV'}) {
a332b303 63 push (@graphs, ($netsettings{'BLUE_DEV'})); }
72fe12a9 64 if ($netsettings{'ORANGE_DEV'}) {
a332b303 65 push (@graphs, ($netsettings{'ORANGE_DEV'})); }
72fe12a9
MT
66}
67
68&Header::openbigbox('100%', 'left');
69
70foreach my $graphname (@graphs) {
71
b9e8554a 72 if ($graphname eq "lq" )
b05768be 73 { &Graphs::updatelqgraph("day"); }
a332b303
CS
74 elsif ($graphname eq "fwhits" )
75 { &Graphs::updatefwhitsgraph("day"); }
350b52c5 76 else
b05768be 77 { &Graphs::updateifgraph($graphname, "day"); }
350b52c5 78
72fe12a9
MT
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' />";
85 print "</a>";
86 } else {
87 print $Lang::tr{'no information available'};
88 }
89 print "<br />\n";
90 &Header::closebox();
91}
92
93if ($cgiparams[1] =~ /red/) {
94
cb5e9c6c 95 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
72fe12a9
MT
96
97 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
98 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
99
100 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
101
102 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
103 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
104
105 my $lsetme=0;
106 my $leasetime="";
107 if ($dhcpinfo{'LEASETIME'} ne "") {
108 $lsetme=$dhcpinfo{'LEASETIME'};
109 $lsetme=($lsetme/60);
110 if ($lsetme > 59) {
111 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
112 } else {
113 $leasetime=$lsetme." Minute";
114 }
115 if ($lsetme > 1) {
116 $leasetime=$leasetime."s";
117 }
118 }
119 my $rentme=0;
120 my $rnwltime="";
121 if ($dhcpinfo{'RENEWALTIME'} ne "") {
122 $rentme=$dhcpinfo{'RENEWALTIME'};
123 $rentme=($rentme/60);
124 if ($rentme > 59){
125 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
126 } else {
127 $rnwltime=$rentme." Minute";
128 }
129 if ($rentme > 1){
130 $rnwltime=$rnwltime."s";
131 }
132 }
133 my $maxtme=0;
134 my $maxtime="";
135 if ($dhcpinfo{'REBINDTIME'} ne "") {
136 $maxtme=$dhcpinfo{'REBINDTIME'};
137 $maxtme=($maxtme/60);
138 if ($maxtme > 59){
139 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
140 } else {
141 $maxtime=$maxtme." Minute";
142 }
143 if ($maxtme > 1) {
144 $maxtime=$maxtime."s";
145 }
146 }
147
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";
151 } else {
152 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
153 }
154 print <<END
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>
162 </table>
163END
164 ;
165 }
166 else
167 {
168 print "$Lang::tr{'no dhcp lease'}";
169 }
170 &Header::closebox();
171 }
172
173 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
174 &Header::CheckSortOrder;
175 &Header::PrintActualLeases;
176 }
177
178} else {
179
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";
184 &Header::closebox();
185
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";
190 &Header::closebox();
191
192}
193
194&Header::closebigbox();
195&Header::closepage();