]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/netexternal.cgi
linux: Fix grsecurity-related crash on Intel Haswell CPUs.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / netexternal.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2005-2010 IPFire Team #
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 ###############################################################################
21
22 use strict;
23
24 # enable only the following on debugging purpose
25 #use warnings;
26 #use CGI::Carp 'fatalsToBrowser';
27
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31 require "${General::swroot}/graphs.pl";
32
33 my %color = ();
34 my %mainsettings = ();
35 my %netsettings=();
36 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
37 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
38 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
39
40 my @graphs=();
41 my %dhcpinfo=();
42
43 my @querry = split(/\?/,$ENV{'QUERY_STRING'});
44 $querry[0] = '' unless defined $querry[0];
45 $querry[1] = 'hour' unless defined $querry[1];
46
47 if ( $querry[0] ne~ ""){
48 print "Content-type: image/png\n\n";
49 binmode(STDOUT);
50 &Graphs::updateifgraph($querry[0],$querry[1]);
51 }else{
52
53 &Header::showhttpheaders();
54 &Header::openpage($Lang::tr{'network traffic graphs external'}, 1, '');
55 &Header::openbigbox('100%', 'left');
56
57 if ($netsettings{'RED_TYPE'} ne 'PPPOE'){
58 if ($netsettings{'RED_DEV'} ne $netsettings{'GREEN_DEV'}){
59 push (@graphs, ($netsettings{'RED_DEV'}));
60 }
61 }else{
62 push (@graphs, "ppp0");
63 }
64
65 if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-ipsec0.rrd"){
66 push (@graphs, ("ipsec0"));
67 }
68
69 if (-e "/var/log/rrd/collectd/localhost/interface/if_octets-tun0.rrd"){
70 push (@graphs, ("tun0"));
71 }
72
73 foreach (@graphs) {
74 &Header::openbox('100%', 'center', "$_ $Lang::tr{'graph'}");
75 &Graphs::makegraphbox("netexternal.cgi",$_,"day");
76 &Header::closebox();
77 }
78
79 if ( $netsettings{'CONFIG_TYPE'} =~ /^(1|2|3|4)$/ && $netsettings{'RED_TYPE'} eq "DHCP"){
80
81 &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}");
82 if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") {
83
84 &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo);
85
86 my $DNS1=`echo $dhcpinfo{'domain_name_servers'} | cut -f 1 -d ,`;
87 my $DNS2=`echo $dhcpinfo{'domain_name_servers'} | cut -f 2 -d ,`;
88
89 my $lsetme=0;
90 my $leasetime="";
91 if ($dhcpinfo{'dhcp_lease_time'} ne "") {
92 $lsetme=$dhcpinfo{'dhcp_lease_time'};
93 $lsetme=($lsetme/60);
94
95 if ($lsetme > 59) {
96 $lsetme=($lsetme/60); $leasetime=$lsetme." Hour";
97 }else{
98 $leasetime=$lsetme." Minute";
99 }
100
101 if ($lsetme > 1) {
102 $leasetime=$leasetime."s";
103 }
104 }
105
106 my $rentme=0;
107 my $rnwltime="";
108
109 if ($dhcpinfo{'dhcp_renewal_time'} ne "") {
110 $rentme=$dhcpinfo{'dhcp_renewal_time'};
111 $rentme=($rentme/60);
112
113 if ($rentme > 59){
114 $rentme=($rentme/60); $rnwltime=$rentme." Hour";
115 }else{
116 $rnwltime=$rentme." Minute";
117 }
118
119 if ($rentme > 1){
120 $rnwltime=$rnwltime."s";
121 }
122 }
123
124 my $maxtme=0;
125 my $maxtime="";
126
127 if ($dhcpinfo{'dhcp_rebinding_time'} ne "") {
128 $maxtme=$dhcpinfo{'dhcp_rebinding_time'};
129 $maxtme=($maxtme/60);
130
131 if ($maxtme > 59){
132 $maxtme=($maxtme/60); $maxtime=$maxtme." Hour";
133 } else {
134 $maxtime=$maxtme." Minute";
135 }
136
137 if ($maxtme > 1) {
138 $maxtime=$maxtime."s";
139 }
140 }
141
142
143 print <<END
144 <table width='100%'>
145 <tr><td width='30%'>$Lang::tr{'domain'}</td><td>$dhcpinfo{'domain_name'}</td></tr>
146 <tr><td>$Lang::tr{'gateway'}</td><td>$dhcpinfo{'routers'}</td></tr>
147 <tr><td>$Lang::tr{'primary dns'}</td><td>$DNS1</td></tr>
148 <tr><td>$Lang::tr{'secondary dns'}</td><td>$DNS2</td></tr>
149 <tr><td>$Lang::tr{'dhcp server'}</td><td>$dhcpinfo{'dhcp_server_identifier'}</td></tr>
150 <tr><td>$Lang::tr{'def lease time'}</td><td>$leasetime</td></tr>
151 <tr><td>$Lang::tr{'default renewal time'}</td><td>$rnwltime</td></tr>
152 <tr><td>$Lang::tr{'max renewal time'}</td><td>$maxtime</td></tr>
153 </table>
154 END
155 ;
156 }else{
157 print "$Lang::tr{'no dhcp lease'}";
158 }
159 &Header::closebox();
160 }
161
162 &Header::closebigbox();
163 &Header::closepage();
164 }