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