]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/network.cgi
Noch zwei Netzwerkfixes...
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / network.cgi
CommitLineData
72fe12a9
MT
1#!/usr/bin/perl
2#
3# SmoothWall CGIs
4#
5# This code is distributed under the terms of the GPL
6#
7# (c) The SmoothWall Team
8#
9#
10
11use strict;
12
13# enable only the following on debugging purpose
14use warnings;
15use CGI::Carp 'fatalsToBrowser';
16
17require '/var/ipfire/general-functions.pl';
18require "${General::swroot}/lang.pl";
19require "${General::swroot}/header.pl";
350b52c5 20require "${General::swroot}/graphs.pl";
72fe12a9
MT
21
22my %cgiparams=();
23my %pppsettings=();
24my %netsettings=();
25my @cgiparams=();
26my @graphs=();
27my $iface='';
28my %dhcpsettings=();
29my %dhcpinfo=();
30my $output='';
31
32&Header::showhttpheaders();
33
34&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
35
36$ENV{'QUERY_STRING'} =~ s/&//g;
37@cgiparams = split(/network=/,$ENV{'QUERY_STRING'});
38$cgiparams[1] = '' unless defined $cgiparams[1];
39
40if ($cgiparams[1] =~ /red/) {
41 &Header::openpage($Lang::tr{'network traffic graphs external'}, 1, '');
42 push (@graphs, ("RED"));
43 push (@graphs, ('lq'));
44} else {
45 &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, '');
46 push (@graphs, ('GREEN'));
47 if ($netsettings{'BLUE_DEV'}) {
48 push (@graphs, ('BLUE')); }
49 if ($netsettings{'ORANGE_DEV'}) {
50 push (@graphs, ('ORANGE')); }
51}
52
53&Header::openbigbox('100%', 'left');
54
55foreach my $graphname (@graphs) {
56
b9e8554a 57 if ($graphname eq "lq" )
b05768be 58 { &Graphs::updatelqgraph("day"); }
350b52c5 59 else
b05768be 60 { &Graphs::updateifgraph($graphname, "day"); }
350b52c5 61
72fe12a9
MT
62 &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
63 if (-e "$Header::graphdir/${graphname}-day.png") {
64 my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]);
65 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
66 print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>";
67 print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />";
68 print "</a>";
69 } else {
70 print $Lang::tr{'no information available'};
71 }
72 print "<br />\n";
73 &Header::closebox();
74}
75
76if ($cgiparams[1] =~ /red/) {
77
78 if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
79
80 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
81 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
82
83 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
84
85 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
86 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
87
88 my $lsetme=0;
89 my $leasetime="";
90 if ($dhcpinfo{'LEASETIME'} ne "") {
91 $lsetme=$dhcpinfo{'LEASETIME'};
92 $lsetme=($lsetme/60);
93 if ($lsetme > 59) {
94 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
95 } else {
96 $leasetime=$lsetme." Minute";
97 }
98 if ($lsetme > 1) {
99 $leasetime=$leasetime."s";
100 }
101 }
102 my $rentme=0;
103 my $rnwltime="";
104 if ($dhcpinfo{'RENEWALTIME'} ne "") {
105 $rentme=$dhcpinfo{'RENEWALTIME'};
106 $rentme=($rentme/60);
107 if ($rentme > 59){
108 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
109 } else {
110 $rnwltime=$rentme." Minute";
111 }
112 if ($rentme > 1){
113 $rnwltime=$rnwltime."s";
114 }
115 }
116 my $maxtme=0;
117 my $maxtime="";
118 if ($dhcpinfo{'REBINDTIME'} ne "") {
119 $maxtme=$dhcpinfo{'REBINDTIME'};
120 $maxtme=($maxtme/60);
121 if ($maxtme > 59){
122 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
123 } else {
124 $maxtime=$maxtme." Minute";
125 }
126 if ($maxtme > 1) {
127 $maxtime=$maxtime."s";
128 }
129 }
130
131 print "<table width='100%'>";
132 if ($dhcpinfo{'HOSTNAME'}) {
133 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
134 } else {
135 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
136 }
137 print <<END
138 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
139 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
140 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
141 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
142 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
143 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
144 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
145 </table>
146END
147 ;
148 }
149 else
150 {
151 print "$Lang::tr{'no dhcp lease'}";
152 }
153 &Header::closebox();
154 }
155
156 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
157 &Header::CheckSortOrder;
158 &Header::PrintActualLeases;
159 }
160
161} else {
162
163 &Header::openbox('100%', 'left', $Lang::tr{'routing table entries'});
164 $output = `/sbin/ip route show`;
165 $output = &Header::cleanhtml($output,"y");
166 print "<pre>$output</pre>\n";
167 &Header::closebox();
168
169 &Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
170 $output = `/sbin/ip neigh show`;
171 $output = &Header::cleanhtml($output,"y");
172 print "<pre>$output</pre>\n";
173 &Header::closebox();
174
175}
176
177&Header::closebigbox();
178&Header::closepage();