~vcs-imports/ipfire/ipfire-2.x

« back to all changes in this revision

Viewing changes to html/cgi-bin/netstatus.cgi

  • Committer: ipfire
  • Date: 2006-02-15 21:15:54 UTC
  • Revision ID: git-v1:cd1a2927226c734d96478e12bb768256fb64a06a


git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
# $Id: netstatus.cgi,v 1.9.2.20 2005/11/05 15:46:25 gespinasse Exp $
 
10
#
 
11
 
 
12
use strict;
 
13
 
 
14
# enable only the following on debugging purpose
 
15
#use warnings;
 
16
#use CGI::Carp 'fatalsToBrowser';
 
17
 
 
18
require 'CONFIG_ROOT/general-functions.pl';
 
19
require "${General::swroot}/lang.pl";
 
20
require "${General::swroot}/header.pl";
 
21
 
 
22
my %dhcpsettings=();
 
23
my %netsettings=();
 
24
my %dhcpinfo=();
 
25
my %pppsettings=();
 
26
my $output='';
 
27
 
 
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, '');
 
33
 
 
34
&Header::openbigbox('100%', 'left');
 
35
 
 
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";
 
41
}
 
42
if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
 
43
    print "<a href='#leases'>$Lang::tr{'current dynamic leases'}</a> |\n";
 
44
}
 
45
if ($pppsettings{'TYPE'} =~ /^(bewanadsl|alcatelusbk|conexantpciadsl|eagleusbadsl)$/) {
 
46
    print "<a href='#adsl'>$Lang::tr{'adsl settings'}</a> |\n";
 
47
}
 
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";
 
51
 
 
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");
 
56
 
 
57
my @itfs = ('ORANGE','BLUE','GREEN');
 
58
foreach my $itf (@itfs) {
 
59
    my $ColorName='';
 
60
    my $lc_itf=lc($itf);
 
61
    my $dev = $netsettings{"${itf}_DEV"};
 
62
    if ($dev){
 
63
        $ColorName = "${lc_itf}"; #dereference variable name...
 
64
        $output =~ s/$dev/<b><font color="$ColorName">$dev<\/font><\/b>/ ;
 
65
    }
 
66
}
 
67
 
 
68
if (open(REDIFACE, "${General::swroot}/red/iface")) {
 
69
    my $lc_itf='red';
 
70
    my $reddev = <REDIFACE>;
 
71
    close(REDIFACE);
 
72
    chomp $reddev;
 
73
    $output =~ s/$reddev/<b><font color='red'>${reddev}<\/font><\/b>/;
 
74
}
 
75
print "<pre>$output</pre>\n";
 
76
&Header::closebox();
 
77
 
 
78
 
 
79
if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/  && $netsettings{'RED_TYPE'} eq "DHCP") {
 
80
 
 
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") {
 
84
 
 
85
                &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
 
86
 
 
87
                my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`;
 
88
                my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`;
 
89
 
 
90
                my $lsetme=0;
 
91
                my $leasetime="";
 
92
                if ($dhcpinfo{'LEASETIME'} ne "") {
 
93
                        $lsetme=$dhcpinfo{'LEASETIME'};
 
94
                        $lsetme=($lsetme/60);
 
95
                        if ($lsetme > 59) {
 
96
                                $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
 
97
                        } else {
 
98
                        $leasetime=$lsetme." Minute"; 
 
99
                        }
 
100
                        if ($lsetme > 1) {
 
101
                                $leasetime=$leasetime."s";
 
102
                        }
 
103
                }
 
104
                my $rentme=0;
 
105
                my $rnwltime="";
 
106
                if ($dhcpinfo{'RENEWALTIME'} ne "") {
 
107
                        $rentme=$dhcpinfo{'RENEWALTIME'};
 
108
                        $rentme=($rentme/60);
 
109
                        if ($rentme > 59){
 
110
                                $rentme=($rentme/60); $rnwltime=$rentme." Hour";
 
111
                        } else {
 
112
                                $rnwltime=$rentme." Minute";
 
113
                        }
 
114
                        if ($rentme > 1){
 
115
                                $rnwltime=$rnwltime."s";
 
116
                        }
 
117
                }
 
118
                my $maxtme=0;
 
119
                my $maxtime="";
 
120
                if ($dhcpinfo{'REBINDTIME'} ne "") {
 
121
                        $maxtme=$dhcpinfo{'REBINDTIME'};
 
122
                        $maxtme=($maxtme/60);
 
123
                        if ($maxtme > 59){
 
124
                                $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
 
125
                        } else {
 
126
                                $maxtime=$maxtme." Minute";
 
127
                        }
 
128
                        if ($maxtme > 1) {
 
129
                                $maxtime=$maxtime."s";
 
130
                        }
 
131
                }
 
132
 
 
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";
 
136
                } else {
 
137
                        print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n";
 
138
                }
 
139
                print <<END
 
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>
 
147
    </table>
 
148
END
 
149
    ;
 
150
        }
 
151
        else
 
152
        {
 
153
                print "$Lang::tr{'no dhcp lease'}";
 
154
        }
 
155
        &Header::closebox();
 
156
}
 
157
 
 
158
if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') {
 
159
 
 
160
        print "<a name='leases'/>";
 
161
        &Header::CheckSortOrder;
 
162
        &Header::PrintActualLeases;
 
163
}
 
164
 
 
165
if ( $netsettings{'CONFIG_TYPE'} =~ /^(0|1|4|5)$/  && (exists($pppsettings{'TYPE'})) ) {
 
166
 
 
167
my $output1='';
 
168
my $output2='';
 
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";
 
177
        &Header::closebox();
 
178
}
 
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";
 
185
        &Header::closebox();
 
186
}
 
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";
 
193
        &Header::closebox();
 
194
}
 
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";
 
201
        &Header::closebox();
 
202
}
 
203
 
 
204
}
 
205
 
 
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";
 
211
&Header::closebox();
 
212
 
 
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";
 
218
&Header::closebox();
 
219
 
 
220
&Header::closebigbox();
 
221
 
 
222
&Header::closepage();