]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/network.cgi
Updated samba to stable 30
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / network.cgi
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
22 use strict;
23
24 # enable only the following on debugging purpose
25 #use warnings;
26 #use CGI::Carp 'fatalsToBrowser';
27
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";
32
33 my %cgiparams=();
34 my %pppsettings=();
35 my %netsettings=();
36 my @cgiparams=();
37 my @graphs=();
38 my @pings=();
39 my $iface='';
40 my %dhcpsettings=();
41 my %dhcpinfo=();
42 my $output='';
43
44 &Header::showhttpheaders();
45
46 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
47
48 $ENV{'QUERY_STRING'} =~ s/&//g;
49 @cgiparams = split(/network=/,$ENV{'QUERY_STRING'});
50 $cgiparams[1] = '' unless defined $cgiparams[1];
51
52 if ($cgiparams[1] =~ /red/) {
53 &Header::openpage($Lang::tr{'network traffic graphs external'}, 1, '');
54 push (@graphs, ($netsettings{'RED_DEV'}));
55 if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd") {push (@graphs, ("ipsec0"));}
56 }elsif ($cgiparams[1] =~ /other/) {
57 &Header::openpage($Lang::tr{'network traffic graphs others'}, 1, '');
58 my @pinggraphs = `ls -dA /var/log/rrd/collectd/localhost/ping/*`;
59 foreach (@pinggraphs){
60 $_ =~ /(.*)\/ping\/ping-(.*)\.rrd/;
61 push(@pings,$2);
62 }
63 push (@graphs, ("fwhits"));
64 }else {
65 &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, '');
66 push (@graphs, ($netsettings{'GREEN_DEV'}));
67 if ($netsettings{'BLUE_DEV'}) {
68 push (@graphs, ($netsettings{'BLUE_DEV'})); }
69 if ($netsettings{'ORANGE_DEV'}) {
70 push (@graphs, ($netsettings{'ORANGE_DEV'})); }
71 }
72
73 &Header::openbigbox('100%', 'left');
74
75 foreach my $graphname (@pings) {
76
77 if ($graphname eq "gateway" )
78 { &Graphs::updatepinggraph("day","gateway"); }
79 else
80 { &Graphs::updatepinggraph("day","$graphname"); }
81
82 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
83 if (-e "$Header::graphdir/${graphname}-day.png") {
84 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
85 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
86 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname&graph=ping'>";
87 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
88 print "</a>";
89 } else {
90 print $Lang::tr{'no information available'};
91 }
92 print "<br />\n";
93 &Header::closebox();
94 }
95
96 foreach my $graphname (@graphs) {
97
98 if ($graphname eq "fwhits" )
99 { &Graphs::updatefwhitsgraph("day"); }
100 else
101 { &Graphs::updateifgraph($graphname, "day"); }
102
103 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
104 if (-e "$Header::graphdir/${graphname}-day.png") {
105 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
106 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
107 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
108 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
109 print "</a>";
110 } else {
111 print $Lang::tr{'no information available'};
112 }
113 print "<br />\n";
114 &Header::closebox();
115 }
116
117 if ($cgiparams[1] =~ /red/) {
118
119 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
120
121 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
122 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
123
124 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
125
126 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
127 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
128
129 my $lsetme=0;
130 my $leasetime="";
131 if ($dhcpinfo{'LEASETIME'} ne "") {
132 $lsetme=$dhcpinfo{'LEASETIME'};
133 $lsetme=($lsetme/60);
134 if ($lsetme > 59) {
135 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
136 } else {
137 $leasetime=$lsetme." Minute";
138 }
139 if ($lsetme > 1) {
140 $leasetime=$leasetime."s";
141 }
142 }
143 my $rentme=0;
144 my $rnwltime="";
145 if ($dhcpinfo{'RENEWALTIME'} ne "") {
146 $rentme=$dhcpinfo{'RENEWALTIME'};
147 $rentme=($rentme/60);
148 if ($rentme > 59){
149 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
150 } else {
151 $rnwltime=$rentme." Minute";
152 }
153 if ($rentme > 1){
154 $rnwltime=$rnwltime."s";
155 }
156 }
157 my $maxtme=0;
158 my $maxtime="";
159 if ($dhcpinfo{'REBINDTIME'} ne "") {
160 $maxtme=$dhcpinfo{'REBINDTIME'};
161 $maxtme=($maxtme/60);
162 if ($maxtme > 59){
163 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
164 } else {
165 $maxtime=$maxtme." Minute";
166 }
167 if ($maxtme > 1) {
168 $maxtime=$maxtime."s";
169 }
170 }
171
172 print "<table width='100%'>";
173 if ($dhcpinfo{'HOSTNAME'}) {
174 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
175 } else {
176 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
177 }
178 print <<END
179 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
180 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
181 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
182 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
183 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
184 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
185 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
186 </table>
187 END
188 ;
189 }
190 else
191 {
192 print "$Lang::tr{'no dhcp lease'}";
193 }
194 &Header::closebox();
195 }
196
197 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
198 &Header::CheckSortOrder;
199 &Header::PrintActualLeases;
200 }
201
202 } else {
203
204 &Header::openbox('100%', 'left', $Lang::tr{'routing table entries'});
205 $output = `/sbin/ip route show`;
206 $output = &Header::cleanhtml($output,"y");
207 print "<pre>$output</pre>\n";
208 &Header::closebox();
209
210 &Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
211 $output = `/sbin/ip neigh show`;
212 $output = &Header::cleanhtml($output,"y");
213 print "<pre>$output</pre>\n";
214 &Header::closebox();
215
216 }
217
218 &Header::closebigbox();
219 &Header::closepage();