]>
Commit | Line | Data |
---|---|---|
72fe12a9 | 1 | #!/usr/bin/perl |
70df8302 MT |
2 | ############################################################################### |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
72fe12a9 MT |
21 | |
22 | use strict; | |
23 | ||
24 | # enable only the following on debugging purpose | |
cb5e9c6c CS |
25 | #use warnings; |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
72fe12a9 MT |
27 | |
28 | require '/var/ipfire/general-functions.pl'; | |
29 | require "${General::swroot}/lang.pl"; | |
30 | require "${General::swroot}/header.pl"; | |
350b52c5 | 31 | require "${General::swroot}/graphs.pl"; |
72fe12a9 MT |
32 | |
33 | my %cgiparams=(); | |
34 | my %pppsettings=(); | |
35 | my %netsettings=(); | |
36 | my @cgiparams=(); | |
37 | my @graphs=(); | |
38 | my $iface=''; | |
39 | my %dhcpsettings=(); | |
40 | my %dhcpinfo=(); | |
41 | my $output=''; | |
42 | ||
43 | &Header::showhttpheaders(); | |
44 | ||
45 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); | |
46 | ||
47 | $ENV{'QUERY_STRING'} =~ s/&//g; | |
48 | @cgiparams = split(/network=/,$ENV{'QUERY_STRING'}); | |
49 | $cgiparams[1] = '' unless defined $cgiparams[1]; | |
50 | ||
51 | if ($cgiparams[1] =~ /red/) { | |
52 | &Header::openpage($Lang::tr{'network traffic graphs external'}, 1, ''); | |
d1a80921 AF |
53 | if ($netsettings{'RED_TYPE'} ne 'PPPOE') { |
54 | if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}) { | |
55 | push (@graphs, ($netsettings{'RED_DEV'})); | |
56 | } | |
57 | } else { | |
58 | push (@graphs, "ppp0"); | |
59 | } | |
8fb804b5 | 60 | if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd") {push (@graphs, ("ipsec0"));} |
a332b303 CS |
61 | }elsif ($cgiparams[1] =~ /other/) { |
62 | &Header::openpage($Lang::tr{'network traffic graphs others'}, 1, ''); | |
63 | push (@graphs, ("lq")); | |
64 | push (@graphs, ("fwhits")); | |
65 | }else { | |
72fe12a9 | 66 | &Header::openpage($Lang::tr{'network traffic graphs internal'}, 1, ''); |
a332b303 | 67 | push (@graphs, ($netsettings{'GREEN_DEV'})); |
72fe12a9 | 68 | if ($netsettings{'BLUE_DEV'}) { |
a332b303 | 69 | push (@graphs, ($netsettings{'BLUE_DEV'})); } |
72fe12a9 | 70 | if ($netsettings{'ORANGE_DEV'}) { |
a332b303 | 71 | push (@graphs, ($netsettings{'ORANGE_DEV'})); } |
72fe12a9 MT |
72 | } |
73 | ||
74 | &Header::openbigbox('100%', 'left'); | |
75 | ||
76 | foreach my $graphname (@graphs) { | |
77 | ||
b9e8554a | 78 | if ($graphname eq "lq" ) |
b05768be | 79 | { &Graphs::updatelqgraph("day"); } |
a332b303 CS |
80 | elsif ($graphname eq "fwhits" ) |
81 | { &Graphs::updatefwhitsgraph("day"); } | |
350b52c5 | 82 | else |
b05768be | 83 | { &Graphs::updateifgraph($graphname, "day"); } |
350b52c5 | 84 | |
72fe12a9 MT |
85 | &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}"); |
86 | if (-e "$Header::graphdir/${graphname}-day.png") { | |
87 | my $ftime = localtime((stat("$Header::graphdir/${graphname}-day.png"))[9]); | |
88 | print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n"; | |
89 | print "<a href='/cgi-bin/graphs.cgi?graph=$graphname'>"; | |
90 | print "<img alt='' src='/graphs/${graphname}-day.png' border='0' />"; | |
91 | print "</a>"; | |
92 | } else { | |
93 | print $Lang::tr{'no information available'}; | |
94 | } | |
95 | print "<br />\n"; | |
96 | &Header::closebox(); | |
97 | } | |
98 | ||
99 | if ($cgiparams[1] =~ /red/) { | |
100 | ||
cb5e9c6c | 101 | if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP") { |
72fe12a9 MT |
102 | |
103 | &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}"); | |
104 | if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") { | |
105 | ||
106 | &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo); | |
107 | ||
108 | my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`; | |
109 | my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`; | |
110 | ||
111 | my $lsetme=0; | |
112 | my $leasetime=""; | |
113 | if ($dhcpinfo{'LEASETIME'} ne "") { | |
114 | $lsetme=$dhcpinfo{'LEASETIME'}; | |
115 | $lsetme=($lsetme/60); | |
116 | if ($lsetme > 59) { | |
117 | $lsetme=($lsetme/60); $leasetime=$lsetme." Hour"; | |
118 | } else { | |
119 | $leasetime=$lsetme." Minute"; | |
120 | } | |
121 | if ($lsetme > 1) { | |
122 | $leasetime=$leasetime."s"; | |
123 | } | |
124 | } | |
125 | my $rentme=0; | |
126 | my $rnwltime=""; | |
127 | if ($dhcpinfo{'RENEWALTIME'} ne "") { | |
128 | $rentme=$dhcpinfo{'RENEWALTIME'}; | |
129 | $rentme=($rentme/60); | |
130 | if ($rentme > 59){ | |
131 | $rentme=($rentme/60); $rnwltime=$rentme." Hour"; | |
132 | } else { | |
133 | $rnwltime=$rentme." Minute"; | |
134 | } | |
135 | if ($rentme > 1){ | |
136 | $rnwltime=$rnwltime."s"; | |
137 | } | |
138 | } | |
139 | my $maxtme=0; | |
140 | my $maxtime=""; | |
141 | if ($dhcpinfo{'REBINDTIME'} ne "") { | |
142 | $maxtme=$dhcpinfo{'REBINDTIME'}; | |
143 | $maxtme=($maxtme/60); | |
144 | if ($maxtme > 59){ | |
145 | $maxtme=($maxtme/60); $maxtime=$maxtme." Hour"; | |
146 | } else { | |
147 | $maxtime=$maxtme." Minute"; | |
148 | } | |
149 | if ($maxtme > 1) { | |
150 | $maxtime=$maxtime."s"; | |
151 | } | |
152 | } | |
153 | ||
154 | print "<table width='100%'>"; | |
155 | if ($dhcpinfo{'HOSTNAME'}) { | |
156 | print "<tr><td width='30%'>$Lang::tr{'hostname'}</td><td>$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}</td></tr>\n"; | |
157 | } else { | |
158 | print "<tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'DOMAIN'}</td></tr>\n"; | |
159 | } | |
160 | print <<END | |
161 | <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'GATEWAY'}</td></tr> | |
162 | <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr> | |
163 | <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr> | |
164 | <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'DHCPSIADDR'}</td></tr> | |
165 | <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr> | |
166 | <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr> | |
167 | <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr> | |
168 | </table> | |
169 | END | |
170 | ; | |
171 | } | |
172 | else | |
173 | { | |
174 | print "$Lang::tr{'no dhcp lease'}"; | |
175 | } | |
176 | &Header::closebox(); | |
177 | } | |
178 | ||
179 | if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') { | |
180 | &Header::CheckSortOrder; | |
181 | &Header::PrintActualLeases; | |
182 | } | |
183 | ||
184 | } else { | |
185 | ||
186 | &Header::openbox('100%', 'left', $Lang::tr{'routing table entries'}); | |
187 | $output = `/sbin/ip route show`; | |
188 | $output = &Header::cleanhtml($output,"y"); | |
189 | print "<pre>$output</pre>\n"; | |
190 | &Header::closebox(); | |
191 | ||
192 | &Header::openbox('100%', 'left', $Lang::tr{'arp table entries'}); | |
193 | $output = `/sbin/ip neigh show`; | |
194 | $output = &Header::cleanhtml($output,"y"); | |
195 | print "<pre>$output</pre>\n"; | |
196 | &Header::closebox(); | |
197 | ||
198 | } | |
199 | ||
200 | &Header::closebigbox(); | |
201 | &Header::closepage(); |