]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/network.cgi
Ein Paar Dateien fuer die GPLv3 angepasst.
[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, '');
53 push (@graphs, ("RED"));
54 push (@graphs, ('lq'));
55} else {
56 &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, '');
57 push (@graphs, ('GREEN'));
58 if ($netsettings{'BLUE_DEV'}) {
59 push (@graphs, ('BLUE')); }
60 if ($netsettings{'ORANGE_DEV'}) {
61 push (@graphs, ('ORANGE')); }
62}
63
64&Header::openbigbox('100%', 'left');
65
66foreach my $graphname (@graphs) {
67
b9e8554a 68 if ($graphname eq "lq" )
b05768be 69 { &Graphs::updatelqgraph("day"); }
350b52c5 70 else
b05768be 71 { &Graphs::updateifgraph($graphname, "day"); }
350b52c5 72
72fe12a9
MT
73 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
74 if (-e "$Header::graphdir/${graphname}-day.png") {
75 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
76 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
77 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
78 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
79 print "</a>";
80 } else {
81 print $Lang::tr{'no information available'};
82 }
83 print "<br />\n";
84 &Header::closebox();
85}
86
87if ($cgiparams[1] =~ /red/) {
88
cb5e9c6c 89 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
72fe12a9
MT
90
91 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
92 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
93
94 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
95
96 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
97 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
98
99 my $lsetme=0;
100 my $leasetime="";
101 if ($dhcpinfo{'LEASETIME'} ne "") {
102 $lsetme=$dhcpinfo{'LEASETIME'};
103 $lsetme=($lsetme/60);
104 if ($lsetme > 59) {
105 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
106 } else {
107 $leasetime=$lsetme." Minute";
108 }
109 if ($lsetme > 1) {
110 $leasetime=$leasetime."s";
111 }
112 }
113 my $rentme=0;
114 my $rnwltime="";
115 if ($dhcpinfo{'RENEWALTIME'} ne "") {
116 $rentme=$dhcpinfo{'RENEWALTIME'};
117 $rentme=($rentme/60);
118 if ($rentme > 59){
119 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
120 } else {
121 $rnwltime=$rentme." Minute";
122 }
123 if ($rentme > 1){
124 $rnwltime=$rnwltime."s";
125 }
126 }
127 my $maxtme=0;
128 my $maxtime="";
129 if ($dhcpinfo{'REBINDTIME'} ne "") {
130 $maxtme=$dhcpinfo{'REBINDTIME'};
131 $maxtme=($maxtme/60);
132 if ($maxtme > 59){
133 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
134 } else {
135 $maxtime=$maxtme." Minute";
136 }
137 if ($maxtme > 1) {
138 $maxtime=$maxtime."s";
139 }
140 }
141
142 print "<table width='100%'>";
143 if ($dhcpinfo{'HOSTNAME'}) {
144 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
145 } else {
146 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
147 }
148 print <<END
149 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
150 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
151 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
152 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
153 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
154 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
155 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
156 </table>
157END
158 ;
159 }
160 else
161 {
162 print "$Lang::tr{'no dhcp lease'}";
163 }
164 &Header::closebox();
165 }
166
167 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
168 &Header::CheckSortOrder;
169 &Header::PrintActualLeases;
170 }
171
172} else {
173
174 &Header::openbox('100%', 'left', $Lang::tr{'routing table entries'});
175 $output = `/sbin/ip route show`;
176 $output = &Header::cleanhtml($output,"y");
177 print "<pre>$output</pre>\n";
178 &Header::closebox();
179
180 &Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
181 $output = `/sbin/ip neigh show`;
182 $output = &Header::cleanhtml($output,"y");
183 print "<pre>$output</pre>\n";
184 &Header::closebox();
185
186}
187
188&Header::closebigbox();
189&Header::closepage();