]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/dial/index.cgi
kleine fixes am nettraffic
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / dial / index.cgi
CommitLineData
e3a8510a
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
10use strict;
11
12# enable only the following on debugging purpose
13#use warnings;
14#use CGI::Carp 'fatalsToBrowser';
15
16require '/var/ipfire/general-functions.pl';
17require "${General::swroot}/lang.pl";
18require "${General::swroot}/header.pl";
19
20my %cgiparams=();
21my %pppsettings=();
22my %modemsettings=();
23my %netsettings=();
24my %ddnssettings=();
25my $warnmessage = '';
26my $refresh = '';
27my $ipaddr='';
28
29&Header::showhttpheaders();
30
31$cgiparams{'ACTION'} = '';
32&Header::getcgihash(\%cgiparams);
33$pppsettings{'VALID'} = '';
34$pppsettings{'PROFILENAME'} = 'None';
35&General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
36&General::readhash("${General::swroot}/modem/settings", \%modemsettings);
37&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
38&General::readhash("${General::swroot}/ddns/settings", \%ddnssettings);
39my $death = 0;
40my $rebirth = 0;
41
42if ($cgiparams{'ACTION'} eq $Lang::tr{'shutdown'}) {
43 $death = 1;
44 &General::log($Lang::tr{'shutting down ipfire'});
45 system '/usr/local/bin/ipfirereboot down';
46} elsif ($cgiparams{'ACTION'} eq $Lang::tr{'reboot'}) {
47 $rebirth = 1;
48 &General::log($Lang::tr{'rebooting ipfire'});
49 system '/usr/local/bin/ipfirereboot boot';
50}
51
52my $connstate = &Header::connectionstatus();
53if ($connstate =~ /$Lang::tr{'dod waiting'}/ || -e "${General::swroot}/main/refreshindex") {
54 $refresh = "<meta http-equiv='refresh' content='30;'>";
55} elsif ($connstate =~ /$Lang::tr{'connecting'}/) {
56 $refresh = "<meta http-equiv='refresh' content='5;'>";
57}
58
59my $c;
60my $maxprofiles = 5;
61my @profilenames = ();
62
63for ($c = 1; $c <= $maxprofiles; $c++)
64{
65 my %temppppsettings = ();
66 $temppppsettings{'PROFILENAME'} = '';
67 &General::readhash("${General::swroot}/ppp/settings-$c", \%temppppsettings);
68 $profilenames[$c] = $temppppsettings{'PROFILENAME'};
69}
70my %selected;
71for ($c = 1; $c <= $maxprofiles; $c++) {
72 $selected{'PROFILE'}{$c} = '';
73}
74$selected{'PROFILE'}{$pppsettings{'PROFILE'}} = "selected='selected'";
75my $dialButtonDisabled = "disabled='disabled'";
76
77
78&Header::openpagewithoutmenu($Lang::tr{'main page'}, 1, $refresh);
79&Header::openbigbox('', 'center');
80&Header::openbox('100%', 'center', &Header::cleanhtml(`/bin/uname -n`,"y"));
81
82if ( ( $pppsettings{'VALID'} eq 'yes' && $modemsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ )) {
83 if (open(IPADDR,"${General::swroot}/ddns/ipcache")) {
84 $ipaddr = <IPADDR>;
85 close IPADDR;
86 chomp ($ipaddr);
87 }
88 if (open(IPADDR,"${General::swroot}/red/local-ipaddress")) {
89 my $ipaddr = <IPADDR>;
90 close IPADDR;
91 chomp ($ipaddr);
92 }
93} elsif ($modemsettings{'VALID'} eq 'no') {
94 print "$Lang::tr{'modem settings have errors'}\n </b></font>\n";
95} else {
96 print "$Lang::tr{'profile has errors'}\n </b></font>\n";
97}
98
99if ( $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) {
100 $ipaddr = $netsettings{'RED_ADDRESS'};
101}
102
103print <<END;
104<table border='0'>
105<tr>
106 <td align='center'><form method='post' action="$ENV{'SCRIPT_NAME'}">
107 <input type='submit' name='ACTION' value='$Lang::tr{'refresh'}' />
108 </form></td>
109</tr></table>
110
111<!-- Table of networks -->
112<table border='0' width=80%>
113 <tr> <th bgcolor='lightgrey'>$Lang::tr{'network'}
114 <th bgcolor='lightgrey'>IP
115 <th bgcolor='lightgrey'>$Lang::tr{'status'}
116 <tr> <td bgcolor='$Header::colourred' width='25%'><font size='2' color='white'><b>$Lang::tr{'internet'}:</b></font><br>
117 <td width='30%'>$ipaddr
118 <td width='45%'>$connstate
119 <tr><td colspan='2'>
120 <form method='post' action='/cgi-bin/dial/dial.cgi'>$Lang::tr{'profile'}:
121 <select name='PROFILE'>
122END
123 for ($c = 1; $c <= $maxprofiles; $c++)
124 {
125 if ($profilenames[$c] ne '') {
126 $dialButtonDisabled = "";
127 print "\t<option value='$c' $selected{'PROFILE'}{$c}>$c. $profilenames[$c]</option>\n";
128 }
129 }
130 $dialButtonDisabled = "disabled='disabled'" if (-e '/var/run/ppp-ipcop.pid' || -e "${General::swroot}/red/active");
131 if ( ( $pppsettings{'VALID'} eq 'yes' ) || ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} =~ /^(DHCP|STATIC)$/ ) ) {
132 print <<END;
133 </select>
134 <input type='submit' name='ACTION' value='$Lang::tr{'dial profile'}' $dialButtonDisabled />
135 </form>
136 <td align='center'>
137 <table width='100%' border='0'>
138 <tr>
139 <td width='50%' align='right'> <form method='post' action='/cgi-bin/dial/dial.cgi'>
140 <input type='submit' name='ACTION' value='$Lang::tr{'dial'}'>
141 </form>
142 <td width='50%' align='left'> <form method='post' action='/cgi-bin/dial/dial.cgi'>
143 <input type='submit' name='ACTION' value='$Lang::tr{'hangup'}'>
144 </form>
145 </table>
146END
147 } else {
148 print "$Lang::tr{'profile has errors'}\n </b></font>\n";
149 }
150
151 if ( $netsettings{'GREEN_DEV'} ) { print <<END;
152 <tr><td bgcolor='$Header::colourgreen' width='25%'><font size='2' color='white'><b>$Lang::tr{'lan'}:</b></font>
153 <td width='30%'>$netsettings{'GREEN_ADDRESS'}
154 <td width='45%'>
155END
156 if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE=on` ) {
157 print "Proxy an";
158 if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT=on` ) { print " (transparent)"; }
159 } else { print "Proxy aus"; }
160 }
161 if ( $netsettings{'BLUE_DEV'} ) { print <<END;
162 <tr><td bgcolor='$Header::colourblue' width='25%'><font size='2' color='white'><b>$Lang::tr{'wireless'}:</b></font><br>
163 <td width='30%'>$netsettings{'BLUE_ADDRESS'}
164 <td width='45%'>
165END
166 if ( `cat /var/ipfire/proxy/advanced/settings | grep ^ENABLE_BLUE=on` ) {
167 print "Proxy an";
168 if ( `cat /var/ipfire/proxy/advanced/settings | grep ^TRANSPARENT_BLUE=on` ) { print " (transparent)"; }
169 } else { print "Proxy aus"; }
170 }
171 if ( $netsettings{'ORANGE_DEV'} ) { print <<END;
172 <tr><td bgcolor='$Header::colourorange' width='25%'><font size='2' color='white'><b>$Lang::tr{'dmz'}:</b></font><br>
173 <td width='30%'>$netsettings{'ORANGE_ADDRESS'}
174 <td width='45%'><font color=$Header::colourgreen>Online</font>
175END
176 }
177 if ( `cat /var/ipfire/vpn/settings | grep ^ENABLED=on` ||
178 `cat /var/ipfire/vpn/settings | grep ^ENABLED_BLUE=on` ) {
179 my $ipsecip = `cat /var/ipfire/vpn/settings | grep ^VPN_IP= | cut -c 8-`;
180 print <<END;
181 <tr><td bgcolor='$Header::colourvpn' width='25%'><font size='2' color='white'><b>$Lang::tr{'vpn'}:</b></font><br>
182 <td width='30%'>$ipsecip
183 <td width='45%'><font color=$Header::colourgreen>Online</font>
184END
185 }
186 if ( `cat /var/ipfire/ovpn/settings | grep ^ENABLED=on` ||
187 `cat /var/ipfire/ovpn/settings | grep ^ENABLED_BLUE=on` ||
188 `cat /var/ipfire/ovpn/settings | grep ^ENABLED_ORANGE=on`) {
189 my $ovpnip = `cat /var/ipfire/ovpn/settings | grep ^DOVPN_SUBNET= | cut -c 14- | sed -e 's\/\\/255.255.255.0\/\/'`;
190 print <<END;
191 <tr><td bgcolor='$Header::colourovpn' width='25%'><font size='2' color='white'><b>OpenVPN:</b></font><br>
192 <td width='30%'>$ovpnip
193 <td width='45%'><font color=$Header::colourgreen>Online</font>
194END
195 }
196 if ( $netsettings{'DNS1'} ) { print <<END;
197 <tr><td>DNS-Server: <td>$netsettings{'DNS1'}
198END
199 }
200 if ( $netsettings{'DNS2'} ) { print <<END;
201 <td>$netsettings{'DNS2'}
202END
203 }
204print <<END;
205</table>
206END
207
208&Header::closebox();
209
210&Header::openbox('100%', 'left', $Lang::tr{'shutdown2'});
211
212if ($death == 0 && $rebirth == 0) {
213 print <<END
214 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
215 <table width='100%'>
216 <tr>
217 <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'reboot'}' /></td>
218 <td width='50%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'shutdown'}' /></td>
219 </tr>
220 </table>
221 </form>
222END
223;
224} else {
225 my $message='';
226 my $title='';
227 if ($death) {
228 $title = $Lang::tr{'shutting down'};
229 $message = $Lang::tr{'ipfire has now shutdown'};
230 } else {
231 $title = $Lang::tr{'rebooting'};
232 $message = $Lang::tr{'ipfire has now rebooted'};
233 }
234 print <<END
235 <font size='6'><center>$message</center></font>
236END
237;
238}
239
240&Header::closebox();
241
242&Header::closebigbox();
243
244&Header::closepage();