]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/netstatus.cgi
Samba vorbereitet fuer CUPS
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / netstatus.cgi
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 use strict;
11
12 # enable only the following on debugging purpose
13 #use warnings;
14 #use CGI::Carp 'fatalsToBrowser';
15
16 require '/var/ipfire/general-functions.pl';
17 require "${General::swroot}/lang.pl";
18 require "${General::swroot}/header.pl";
19
20 my %dhcpsettings=();
21 my %netsettings=();
22 my %dhcpinfo=();
23 my %pppsettings=();
24 my $output='';
25
26 &General::readhash("${General::swroot}/dhcp/settings", \%dhcpsettings);
27 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
28 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
29 &Header::showhttpheaders();
30 &Header::openpage($Lang::tr{'network status information'}, 1, '');
31
32 &Header::openbigbox('100%', 'left');
33
34 &Header::openbox('100%', 'left', $Lang::tr{'interfaces'});
35 $output = `/sbin/ip addr show`;
36 $output = &Header::cleanhtml($output,"y");
37
38 my @itfs = ('ORANGE','BLUE','GREEN');
39 foreach my $itf (@itfs) {
40 my $ColorName='';
41 my $lc_itf=lc($itf);
42 my $dev = $netsettings{"${itf}_DEV"};
43 if ($dev){
44 $ColorName = "${lc_itf}"; #dereference variable name...
45 $output =~ s/$dev/<b><font color="$ColorName">$dev<\/font><\/b>/ ;
46 }
47 }
48
49 if (open(REDIFACE, "${General::swroot}/red/iface")) {
50 my $lc_itf='red';
51 my $reddev = <REDIFACE>;
52 close(REDIFACE);
53 chomp $reddev;
54 $output =~ s/$reddev/<b><font color='red'>${reddev}<\/font><\/b>/;
55 }
56 print "<pre>$output</pre>\n";
57 &Header::closebox();
58
59
60 if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
61
62 print "<a name='reddhcp'/>\n";
63 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
64 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
65
66 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
67
68 my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
69 my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
70
71 my $lsetme=0;
72 my $leasetime="";
73 if ($dhcpinfo{'LEASETIME'} ne "") {
74 $lsetme=$dhcpinfo{'LEASETIME'};
75 $lsetme=($lsetme/60);
76 if ($lsetme > 59) {
77 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
78 } else {
79 $leasetime=$lsetme." Minute";
80 }
81 if ($lsetme > 1) {
82 $leasetime=$leasetime."s";
83 }
84 }
85 my $rentme=0;
86 my $rnwltime="";
87 if ($dhcpinfo{'RENEWALTIME'} ne "") {
88 $rentme=$dhcpinfo{'RENEWALTIME'};
89 $rentme=($rentme/60);
90 if ($rentme > 59){
91 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
92 } else {
93 $rnwltime=$rentme." Minute";
94 }
95 if ($rentme > 1){
96 $rnwltime=$rnwltime."s";
97 }
98 }
99 my $maxtme=0;
100 my $maxtime="";
101 if ($dhcpinfo{'REBINDTIME'} ne "") {
102 $maxtme=$dhcpinfo{'REBINDTIME'};
103 $maxtme=($maxtme/60);
104 if ($maxtme > 59){
105 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
106 } else {
107 $maxtime=$maxtme." Minute";
108 }
109 if ($maxtme > 1) {
110 $maxtime=$maxtime."s";
111 }
112 }
113
114 print "<table width='100%'>";
115 if ($dhcpinfo{'HOSTNAME'}) {
116 print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
117 } else {
118 print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
119 }
120 print <<END
121 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
122 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
123 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
124 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
125 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
126 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
127 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
128 </table>
129 END
130 ;
131 }
132 else
133 {
134 print "$Lang::tr{'no dhcp lease'}";
135 }
136 &Header::closebox();
137 }
138
139 if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
140
141 print "<a name='leases'/>";
142 &Header::CheckSortOrder;
143 &Header::PrintActualLeases;
144 }
145
146 &Header::openbox('100%', 'left', $Lang::tr{'routing table entries'});
147 $output = `/sbin/ip show show`;
148 $output = &Header::cleanhtml($output,"y");
149 print "<pre>$output</pre>\n";
150 &Header::closebox();
151
152 &Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
153 $output = `/sbin/ip neigh show`;
154 $output = &Header::cleanhtml($output,"y");
155 print "<pre>$output</pre>\n";
156 &Header::closebox();
157
158 &Header::closebigbox();
159
160 &Header::closepage();