5
# This code is distributed under the terms of the GPL
7
# (c) The SmoothWall Team
9
# $Id: netstatus.cgi,v 1.9.2.20 2005/11/05 15:46:25 gespinasse Exp $
14
# enable only the following on debugging purpose
16
#use CGI::Carp 'fatalsToBrowser';
18
require 'CONFIG_ROOT/general-functions.pl';
19
require "${General::swroot}/lang.pl";
20
require "${General::swroot}/header.pl";
28
&General::readhash("${General::swroot}/dhcp/settings", \%dhcpsettings);
29
&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
30
&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
31
&Header::showhttpheaders();
32
&Header::openpage($Lang::tr{'network status information'}, 1, '');
34
&Header::openbigbox('100%', 'left');
36
print "<table width='100%' cellspacing='0' cellpadding='5'border='0'>\n";
37
print "<tr><td style='background-color: #EAE9EE;' align='left'>\n";
38
print "<a href='#interfaces'>$Lang::tr{'interfaces'}</a> |\n";
39
if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
40
print "<a href='#reddhcp'>RED $Lang::tr{'dhcp configuration'}</a> |\n";
42
if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
43
print "<a href='#leases'>$Lang::tr{'current dynamic leases'}</a> |\n";
45
if ($pppsettings{'TYPE'} =~ /^(bewanadsl|alcatelusbk|conexantpciadsl|eagleusbadsl)$/) {
46
print "<a href='#adsl'>$Lang::tr{'adsl settings'}</a> |\n";
48
print "<a href='#routing'>$Lang::tr{'routing table entries'}</a> |\n";
49
print "<a href='#arp'> $Lang::tr{'arp table entries'}</a>\n";
50
print "</td></tr></table>\n";
52
print "<a name='interfaces'/>\n";
53
&Header::openbox('100%', 'left', $Lang::tr{'interfaces'});
54
$output = `/sbin/ifconfig -a`;
55
$output = &Header::cleanhtml($output,"y");
57
my @itfs = ('ORANGE','BLUE','GREEN');
58
foreach my $itf (@itfs) {
61
my $dev = $netsettings{"${itf}_DEV"};
63
$ColorName = "${lc_itf}"; #dereference variable name...
64
$output =~ s/$dev/<b><font color="$ColorName">$dev<\/font><\/b>/ ;
68
if (open(REDIFACE, "${General::swroot}/red/iface")) {
70
my $reddev = <REDIFACE>;
73
$output =~ s/$reddev/<b><font color='red'>${reddev}<\/font><\/b>/;
75
print "<pre>$output</pre>\n";
79
if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") {
81
print "<a name='reddhcp'/>\n";
82
&Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
83
if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
85
&General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
87
my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
88
my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
92
if ($dhcpinfo{'LEASETIME'} ne "") {
93
$lsetme=$dhcpinfo{'LEASETIME'};
96
$lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
98
$leasetime=$lsetme." Minute";
101
$leasetime=$leasetime."s";
106
if ($dhcpinfo{'RENEWALTIME'} ne "") {
107
$rentme=$dhcpinfo{'RENEWALTIME'};
108
$rentme=($rentme/60);
110
$rentme=($rentme/60); $rnwltime=$rentme." Hour";
112
$rnwltime=$rentme." Minute";
115
$rnwltime=$rnwltime."s";
120
if ($dhcpinfo{'REBINDTIME'} ne "") {
121
$maxtme=$dhcpinfo{'REBINDTIME'};
122
$maxtme=($maxtme/60);
124
$maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
126
$maxtime=$maxtme." Minute";
129
$maxtime=$maxtime."s";
133
print "<table width='100%'>";
134
if ($dhcpinfo{'HOSTNAME'}) {
135
print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n";
137
print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
140
<tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr>
141
<tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
142
<tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
143
<tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr>
144
<tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
145
<tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
146
<tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
153
print "$Lang::tr{'no dhcp lease'}";
158
if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
160
print "<a name='leases'/>";
161
&Header::CheckSortOrder;
162
&Header::PrintActualLeases;
165
if ( $netsettings{'CONFIG_TYPE'} =~ /^(0|1|4|5)$/ && (exists($pppsettings{'TYPE'})) ) {
169
if ($pppsettings{'TYPE'} eq 'bewanadsl') {
170
print "<a name='adsl'/>\n";
171
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
172
$output1 = `/usr/bin/unicorn_status`;
173
$output1 = &Header::cleanhtml($output1,"y");
174
$output2 = `/bin/cat /proc/net/atm/UNICORN:*`;
175
$output2 = &Header::cleanhtml($output2,"y");
176
print "<pre>$output1$output2</pre>\n";
179
if ($pppsettings{'TYPE'} eq 'alcatelusbk') {
180
print "<a name='adsl'/>\n";
181
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
182
$output = `/bin/cat /proc/net/atm/speedtch:*`;
183
$output = &Header::cleanhtml($output,"y");
184
print "<pre>$output</pre>\n";
187
if ($pppsettings{'TYPE'} eq 'conexantpciadsl') {
188
print "<a name='adsl'/>\n";
189
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
190
$output = `/bin/cat /proc/net/atm/CnxAdsl:*`;
191
$output = &Header::cleanhtml($output,"y");
192
print "<pre>$output</pre>\n";
195
if ($pppsettings{'TYPE'} eq 'eagleusbadsl') {
196
print "<a name='adsl'/>\n";
197
&Header::openbox('100%', 'left', $Lang::tr{'adsl settings'});
198
$output = `/usr/sbin/eaglestat`;
199
$output = &Header::cleanhtml($output,"y");
200
print "<pre>$output</pre>\n";
206
print "<a name='routing'/>\n";
207
&Header::openbox('100%', 'left', $Lang::tr{'routing table entries'});
208
$output = `/sbin/route -n`;
209
$output = &Header::cleanhtml($output,"y");
210
print "<pre>$output</pre>\n";
213
print "<a name='arp'/>\n";
214
&Header::openbox('100%', 'left', $Lang::tr{'arp table entries'});
215
$output = `/sbin/arp -n`;
216
$output = &Header::cleanhtml($output,"y");
217
print "<pre>$output</pre>\n";
220
&Header::closebigbox();
222
&Header::closepage();