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