]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/wio/wio.cgi
wio-1.3.2-7: fixed bug with arp client import
[people/pmueller/ipfire-2.x.git] / src / wio / wio.cgi
CommitLineData
0d6cc79d
SF
1#!/usr/bin/perl
2#
3###############################################################################
4# #
5# IPFire.org - A linux based firewall #
83596e70 6# Copyright (C) 2017-2019 Stephan Feddersen <sfeddersen@ipfire.org> #
0d6cc79d
SF
7# All Rights Reserved. #
8# #
9# This program is free software: you can redistribute it and/or modify #
10# it under the terms of the GNU General Public License as published by #
11# the Free Software Foundation, either version 3 of the License, or #
12# (at your option) any later version. #
13# #
14# This program is distributed in the hope that it will be useful, #
15# but WITHOUT ANY WARRANTY; without even the implied warranty of #
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
17# GNU General Public License for more details. #
18# #
19# You should have received a copy of the GNU General Public License #
20# along with this program. If not, see <http://www.gnu.org/licenses/>. #
21# #
22###############################################################################
23#
83596e70 24# Version: 2019/11/08 14:35:23
0d6cc79d
SF
25#
26# This wio.cgi is based on the Code from the IPCop WIO Addon
27# and is extremly adapted to work with IPFire.
28#
29# Autor: Stephan Feddersen
30# Co-Autor: Alexander Marx
83596e70 31# Co-Autor: Frank Mainz (for some Code for the IPCop WIO Addon)
0d6cc79d
SF
32#
33
34use strict;
35
36# enable only the following on debugging purpose
37#use warnings;
38#no warnings 'once';
39#use CGI::Carp 'fatalsToBrowser';
40
41my $debug = 0;
42
43use Socket;
44use POSIX qw(strftime);
45use File::Copy;
46use Fatal qw/ open /;
47use Net::Telnet;
48
49require '/var/ipfire/general-functions.pl';
1bee37ba 50require '/var/ipfire/network-functions.pl';
0d6cc79d
SF
51require '/var/ipfire/lang.pl';
52require '/var/ipfire/header.pl';
53require '/usr/lib/wio/wio-lib.pl';
54require '/usr/lib/wio/wio-graphs.pl';
55
56my $logdir = "/var/log/wio";
57
58my ( %mainsettings, %mailsettings, %wiosettings, %cgiparams, %netsettings, %ipshash,
59 %vpnconfighash, %ovpnconfighash, %ovpnccdconfhash, %ovpnsettings, %checked, %selected, %color ) = ();
60
61&General::readhash('/var/ipfire/main/settings', \%mainsettings);
62&General::readhash('/var/ipfire/ethernet/settings', \%netsettings);
63&General::readhash('/var/ipfire/dma/mail.conf', \%mailsettings);
64&General::readhash('/var/ipfire/wio/wio.conf', \%wiosettings);
65&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
66&General::readhasharray('/var/ipfire/ovpn/ovpnconfig', \%ovpnconfighash);
67&General::readhash('/var/ipfire/ovpn/settings', \%ovpnsettings);
68&General::readhasharray('/var/ipfire/ovpn/ccd.conf', \%ovpnccdconfhash);
69&General::readhasharray('/var/ipfire/vpn/config', \%vpnconfighash);
70
71my $ipadrfile = "$logdir/wioips";
72my $onoffip = "$logdir/wioscip";
73my $wiosettings = "/var/ipfire/wio/wio.conf";
74my $dyndnsconfig = "/var/ipfire/ddns/config";
75my $importfile = "$logdir/importfile";
76my $wiofile = "$logdir/wiofile";
77my $editfile = "$logdir/editfile";
78my $hostfile = "/var/ipfire/main/hosts";
79my $dhcpfile = "/var/ipfire/dhcp/fixleases";
80my $imgstatic = "/images/wio";
81my $rrddir = "/var/log/rrd/wio";
82my $refreshbox = '<meta http-equiv="refresh" content="0;url=/cgi-bin/wio.cgi">';
83my $sortstring = '^IPADR|^HOST';
84my $ovpnaddon = "/var/ipfire/ovpn";
85my $ovpnpid = "/var/run/openvpn.pid";
86my $vpnpid = "/var/run/charon.pid";
87my $redactive = "/var/ipfire/red/active";
88my $redip = '-';
89my $now = strftime "%Y-%m-%d", localtime;
90
91if ( -e $redactive ) {
92 open(IPADDR, "/var/ipfire/red/local-ipaddress");
93 $redip = <IPADDR>;
94 close IPADDR;
95 chomp($redip);
96}
97
98my $i = 0;
99my $idarp = 0;
100my $iddyndns = 0;
101my $idvpn = 0;
102my $idovpn = 0;
103my $idsort = 0;
104my $nr = 0;
105my $count = 0;
106my $showcount = 0;
107
a25c95b3 108my $arpbuttontext = "$Lang::tr{'wio_show_table_on'}";
c1fc92a9
SFD
109my $clientimportbuttontext = "$Lang::tr{'wio_show_table_on'}";
110my $networksearchbuttontext = "$Lang::tr{'wio_show_table_on'}";
a25c95b3 111
c1fc92a9 112my ( $message, $infomessage, $errormessage, $importmessage ) = '';
0d6cc79d
SF
113
114my ( $buttontext, $host, $timestamp, $ipadr, $on, $remark, $dyndns, $dyndnsip, $sendemailon, $net, $dev, $iprange, $output, $write, $webinterface,
115 $sendemailoff, $pingmethode, $online, $color, $bgcolor, $exitcode, $id, $line, $interface, $counter, $vpnn2nip, $vpnn2nmask, $ddns, $edc,
116 $edd, $wmon, $wmoff, $ipfqdn, $http, $wioscan, $statustxt, $status, $key, $ic, $text, $image ) = ();
117
118my ( @temp, @dates, @ipaddresses, @names, @remark, @sendemailon, @sendemailoff, @current, @ddns, @match, @webinterface, @arpcache, @arpadd, @line,
119 @hosts, @vpnstatus, @ovpnstatus, @activ, @dyndns, @pingmethode, @status, @id, @write, @log );
120
121my @nosaved = ('ACTION','ID','CLIENTID','TIMESTAMP','IPADR','HOST','REMARK','DYNDNS','SENDEMAILON','SENDEMAILOFF','PINGMETHODE','ONLINE','WEBINTERFACE');
122
123my @devs_color = ('GREEN','BLUE','ORANGE','RED');
124my @devs_net = ('green0','blue0','orange0','red0');
125my @devs_img = ('green.png','blue.png','orange.png','red.png');
126my @devs_alt = ('green','blue','orange','red');
127
128my %ifacecolor = ( GREEN => 'wio_run_green', BLUE => 'wio_run_blue', ORANGE => 'wio_run_orange');
129
130&loadips();
131
132## some wio settings
133
134$wiosettings{'ACTION'} = '';
135$wiosettings{'COUNT'} = '';
136$wiosettings{'ID'} = '';
137$wiosettings{'CLIENTID'} = '';
138$wiosettings{'SORT'} = 'IPADR';
139$wiosettings{'HOST'} = '';
140$wiosettings{'IPADR'} = '';
141$wiosettings{'EN'} = 'on';
142$wiosettings{'REMARK'} = '';
143$wiosettings{'DYNDNS'} = '';
144$wiosettings{'CLIENTREMARK'} = '';
145$wiosettings{'SENDEMAILON'} = '';
146$wiosettings{'SENDEMAILOFF'} = '';
147$wiosettings{'PINGMETHODE'} = 'ip';
148$wiosettings{'WEBINTERFACE'} = '----';
149$wiosettings{'TIMEOUT'} = '1';
150$wiosettings{'TIMESTAMP'} = '';
151$wiosettings{'ONLINE'} = 'off';
152$wiosettings{'CRON'} = '15';
153$wiosettings{'OVPNCRON'} = '5';
154$wiosettings{'ENABLE'} = 'off';
155$wiosettings{'LOGGING'} = 'off';
156$wiosettings{'MAILREMARK'} = 'off';
157$wiosettings{'MAILSTYLE'} = 'email';
158$wiosettings{'OVPNRWMAIL'} = 'off';
159$wiosettings{'SHUTDOWN'} = 'off';
a25c95b3
SFD
160$wiosettings{'WIOGUISHOWARPTABLE'} = '';
161$wiosettings{'WIOGUISHOWCLIENTIMPORTTABLE'} = '';
162$wiosettings{'WIOGUISHOWNETWORKSEARCHTABLE'} = '';
0d6cc79d
SF
163
164&Header::getcgihash(\%wiosettings);
165&Header::getcgihash(\%mainsettings);
166&Header::getcgihash(\%mailsettings);
167&Header::getcgihash(\%netsettings);
168
169if ( $mailsettings{'USEMAIL'} eq 'on' ) { $wiosettings{'SENDEMAIL'} = 'on'; }
170else { $wiosettings{'SENDEMAIL'} = 'off'; }
171
172if ( -e $wiofile ) { goto WIOSCAN; }
173
174## get network ips
175foreach (@devs_color) {
176 if ( $netsettings{"${_}_DEV"} ne '' ) {
1bee37ba
SF
177 $wiosettings{"${_}_IPLOW"} = &Network::find_next_ip_address($netsettings{"${_}_NETADDRESS"}, 1);
178 $wiosettings{"${_}_IPHIGH"} = &Network::find_next_ip_address($netsettings{"${_}_BROADCAST"}, -1);
0d6cc79d
SF
179 }
180}
181
182## save wio settings
183
184if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_save'}.'1' ) {
185 unless ( `ps -A | grep wio.pl` ) {
186 $cgiparams{'SORT'} = $wiosettings{'SORT'};
187 $cgiparams{'CRON'} = $wiosettings{'CRON'};
188 $cgiparams{'OVPNCRON'} = $wiosettings{'OVPNCRON'};
189 $cgiparams{'ENABLE'} = $wiosettings{'ENABLE'};
190 $cgiparams{'LOGGING'} = $wiosettings{'LOGGING'};
191 $cgiparams{'TIMEOUT'} = $wiosettings{'TIMEOUT'};
192 $cgiparams{'ACTION'} = $wiosettings{'ACTION'};
193 $cgiparams{'CLIENTREMARK'} = $wiosettings{'CLIENTREMARK'};
194 $cgiparams{'MAILREMARK'} = $wiosettings{'MAILREMARK'};
195 $cgiparams{'MAILSTYLE'} = $wiosettings{'MAILSTYLE'};
196 $cgiparams{'OVPNRWMAIL'} = $wiosettings{'OVPNRWMAIL'};
197 $cgiparams{'SHUTDOWN'} = $wiosettings{'SHUTDOWN'};
198
199 &General::writehash($wiosettings, \%cgiparams);
200 &General::readhash($wiosettings, \%wiosettings);
201
202 if ( $wiosettings{'ENABLE'} eq 'off' ) {
203 &WIO::clearfile($ipadrfile);
204 unlink glob "$rrddir/*";
205 }
206 }
207 else {
208 $infomessage = "$Lang::tr{'wio_error_function'}";
209 }
210}
211
212## save imported clients
213
214if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_save'}.'2' ) {
215 unless ( `ps -A | grep wio.pl` ) {
216 while ( $count < $wiosettings{'COUNT'} ) {
217 if ( defined($wiosettings{"USE$count"}) && $wiosettings{"USE$count"} eq 'on' ) {
83596e70 218 $wiosettings{'CLIENTID'} = $wiosettings{"CLIENTID$count"};
0d6cc79d
SF
219 $wiosettings{'TIMESTAMP'} = $wiosettings{"TIMESTAMP$count"};
220 $wiosettings{'IPADR'} = $wiosettings{"IPADR$count"};
221 $wiosettings{'HOST'} = $wiosettings{"HOST$count"};
222 $wiosettings{'EN'} = $wiosettings{"EN$count"};
223 $wiosettings{'REMARK'} = $wiosettings{"REMARK$count"};
224 $wiosettings{'DYNDNS'} = $wiosettings{"DYNDNS$count"};
225 $wiosettings{'SENDEMAILON'} = $wiosettings{"SENDEMAILON$count"};
226 $wiosettings{'SENDEMAILOFF'} = $wiosettings{"SENDEMAILOFF$count"};
227 $wiosettings{'PINGMETHODE'} = $wiosettings{"PINGMETHODE$count"};
228 $wiosettings{'ONLINE'} = $wiosettings{"ONLINE$count"};
83596e70 229 $wiosettings{'WEBINTERFACE'} = $wiosettings{"WEBINTERFACE$count"};
0d6cc79d
SF
230
231 &validSave();
232
233 if ($errormessage) {
234 open(FILE, ">> $editfile");
235 print FILE "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n";
236 close(FILE);
237 $importmessage = $errormessage;
238 }
239 else {
240 $wiosettings{'CLIENTID'} = &General::findhasharraykey (\%ipshash);
241 unshift (@current, "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n");
242 &SortDataFile('',@current);
243 }
244 }
245 $count++;
246 }
247
248 map ($wiosettings{$_} = '' ,@nosaved);
249 unlink ($importfile);
250 if ( -e "$editfile" ) { goto EDIT; }
251 }
252 else {
253 $infomessage = "$Lang::tr{'wio_error_function'}";
254 }
255}
256
257## add or update client
258
259if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_client_add'} ) {
260 unless ( `ps -A | grep wio.pl` ) {
261 &validSave();
262
263 unless ($errormessage) {
264 if ( $wiosettings{'ID'} eq '' && $wiosettings{'ACTION'} ne $Lang::tr{'edit'} ) {
265 $wiosettings{'CLIENTID'} = &General::findhasharraykey (\%ipshash);
266 unshift (@current, "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n");
267 }
268 else {
269 @current[$wiosettings{'ID'}] = "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n";
270 }
271 }
272 else { goto ERROR; }
273
274 map ($wiosettings{$_} = '' ,@nosaved);
275 &SortDataFile('',@current);
276 }
277 else {
278 $infomessage = "$Lang::tr{'wio_error_function'}";
279 }
280}
281
a25c95b3
SFD
282## show / hide arptable
283
c1fc92a9 284if ( $wiosettings{'WIOGUISHOWARPTABLE'} eq 'arptable' ) {
83596e70
SF
285 unless ( `ps -A | grep wio.pl` ) {
286 if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_show_table_off'} ) {
287 $wiosettings{'WIOGUISHOWARPTABLE'} = 'off';
288 $arpbuttontext = "$Lang::tr{'wio_show_table_on'}";
289 }
290 else {
291 $wiosettings{'WIOGUISHOWARPTABLE'} = 'on';
292 $arpbuttontext = "$Lang::tr{'wio_show_table_off'}";
293 }
a25c95b3
SFD
294 }
295 else {
83596e70 296 $infomessage = "$Lang::tr{'wio_error_function'}";
a25c95b3
SFD
297 }
298}
299
300## show / hide clientimporttable
301
302if ( $wiosettings{'WIOGUISHOWCLIENTIMPORTTABLE'} eq 'clientimport' ) {
83596e70
SF
303 unless ( `ps -A | grep wio.pl` ) {
304 if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_show_table_off'} ) {
305 $wiosettings{'WIOGUISHOWCLIENTIMPORTTABLE'} = 'off';
306 $clientimportbuttontext = "$Lang::tr{'wio_show_table_on'}";
307 }
308 else {
309 $wiosettings{'WIOGUISHOWCLIENTIMPORTTABLE'} = 'on';
310 $clientimportbuttontext = "$Lang::tr{'wio_show_table_off'}";
311 }
a25c95b3
SFD
312 }
313 else {
83596e70 314 $infomessage = "$Lang::tr{'wio_error_function'}";
a25c95b3
SFD
315 }
316}
317
318## show / hide networksearchtable
319
320if ( $wiosettings{'WIOGUISHOWNETWORKSEARCHTABLE'} eq 'networksearch' ) {
83596e70
SF
321 unless ( `ps -A | grep wio.pl` ) {
322 if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_show_table_off'} ) {
323 $wiosettings{'WIOGUISHOWNETWORKSEARCHTABLE'} = 'off';
324 $networksearchbuttontext = "$Lang::tr{'wio_show_table_on'}";
325 }
326 else {
327 $wiosettings{'WIOGUISHOWNETWORKSEARCHTABLE'} = 'on';
328 $networksearchbuttontext = "$Lang::tr{'wio_show_table_off'}";
329 }
a25c95b3
SFD
330 }
331 else {
83596e70 332 $infomessage = "$Lang::tr{'wio_error_function'}";
a25c95b3
SFD
333 }
334}
335
0d6cc79d
SF
336## add arp client
337
338if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_add'} ) {
339 unless ( `ps -A | grep wio.pl` ) {
340 open(FILE, "$logdir/.arpcache");
341 @arpadd = <FILE>;
342 close (FILE);
343
344 chomp(@arpadd[$wiosettings{'ID'}]);
345 @temp = split (/\,/, @arpadd[$wiosettings{'ID'}]);
346
347 $wiosettings{'CLIENTID'} = &General::findhasharraykey (\%ipshash);
348 $wiosettings{'IPADR'} = $temp[1];
349 $wiosettings{'HOST'} = $temp[2];
350 $wiosettings{'EN'} = 'on';
351
352 $wiosettings{'PINGMETHODE'} = 'ip';
353 $wiosettings{'ONLINE'} = 'off';
354
355 open(FILE, ">> $editfile");
356 print FILE "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n";
357 close(FILE);
358
359 goto EDIT;
360 }
361 else {
362 undef($wiosettings{'ID'});
363 $infomessage = "$Lang::tr{'wio_error_function'}";
364 }
365}
366
c1fc92a9 367## enable / disable client || enable / disable dyndns || enable / disable sendemailon || enable / disable sendemailoff || change ip / fqdn
0d6cc79d
SF
368
369if ( $wiosettings{'ACTION'} eq $Lang::tr{'enable disable client'} ) { $edc = 'on'; }
370if ( $wiosettings{'ACTION'} eq $Lang::tr{'enable disable dyndns'} ) { $edd = 'on'; }
371if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_mail_online'} ) { $wmon = 'on'; }
372if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_mail_offline'} ) { $wmoff = 'on'; }
373if (( $wiosettings{'ACTION'} eq $Lang::tr{'wio_ip_on'} ) || ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_fqdn_on'} )) { $ipfqdn = 'on'; }
374
375if ( defined($edc) || defined($edd) || defined($wmon) || defined($wmoff) || defined($ipfqdn) ) {
376 unless ( `ps -A | grep wio.pl` ) {
377 chomp(@current[$wiosettings{'ID'}]);
378 @temp = split (/\,/, @current[$wiosettings{'ID'}]);
379
380 if ( $edc eq 'on' ) {
381 $temp[4] = $temp[4] ne '' ? '' : 'on';
382 $temp[10] = '';
383 $temp[11] = '';
384 $temp[1] = '';
385 unlink "$rrddir/$temp[0].rrd";
386 }
387 elsif ( $edd eq 'on' ) { $temp[6] = $temp[6] ne '' ? '' : 'on'; }
388 elsif ( $wmon eq 'on' ) { $temp[7] = $temp[7] ne '' ? '' : 'on'; }
389 elsif ( $wmoff eq 'on' ) { $temp[8] = $temp[8] ne '' ? '' : 'on'; }
390 elsif ( $ipfqdn eq 'on' ) { $temp[9] = $temp[9] eq 'fqdn' ? 'ip' : 'fqdn'; }
391
392 @current[$wiosettings{'ID'}] = join (',', @temp)."\n";
393 undef($wiosettings{'ID'});
394
395 &writeips();
396 }
397 else {
398 undef($wiosettings{'ID'});
399 $infomessage = "$Lang::tr{'wio_error_function'}";
400 }
401}
402
403## refresh wio status || refresh single client status
404
405if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_refresh'} || $wiosettings{'ACTION'} eq $Lang::tr{'wio_sc_refresh'} ) {
406
83596e70
SF
407unless ( `ps -A | grep wio.pl` ) {
408
0d6cc79d
SF
409 if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_sc_refresh'} ) {
410 open(FILE, "> $onoffip");
411 print FILE @current[$wiosettings{'ID'}];
412 close(FILE);
413
414 undef($wiosettings{'ID'});
415 }
416
0d6cc79d
SF
417&Header::showhttpheaders();
418&Header::openpage($Lang::tr{'wio'}, 1, $refreshbox);
419&Header::openbigbox('100%', 'left', '');
420&Header::openbox('100%', 'left', $Lang::tr{'wio_info'});
421
422print"
423<table align='center' width='100%'>
424 <tr><td align='center'>$Lang::tr{'wio_msg'}</td></tr>
425 <tr><td>&nbsp;</td></tr>
426 <tr><td align='center'><img align='middle' src='/images/indicator.gif' /></td></tr>
427</table>
428";
429
430&Header::closebox();
431&Header::closebigbox();
432&Header::closepage();
433
434while ( system("/usr/local/bin/wiohelper", "&") ) {}
435
83596e70 436exit 0;
0d6cc79d
SF
437}
438else {
439 $infomessage = "$Lang::tr{'wio_already_running'}";
a25c95b3 440 unlink($onoffip);
0d6cc79d
SF
441}
442
443}
444
445## refresh dyndns ip
446
447if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_dyndns_refresh'} ) {
448 unless ( `ps -A | grep wio.pl` ) {
449 chomp(@current[$wiosettings{'ID'}]);
450 @temp = split (/\,/, @current[$wiosettings{'ID'}]);
451
452 ($temp[2], $infomessage) = &WIO::getdyndnsip($temp[2], $temp[3]);
453
454 @current[$wiosettings{'ID'}] = join (',', @temp)."\n";
455
456 &writeips();
457
458 undef($wiosettings{'ID'});
459 }
460 else {
461 $infomessage = "$Lang::tr{'wio_error_function'}";
462 }
463}
464
465## edit client
466
467if ( $wiosettings{'ACTION'} eq $Lang::tr{'edit'} ) {
468 unless ( `ps -A | grep wio.pl` ) {
469 chomp(@current[$wiosettings{'ID'}]);
470 @temp = split (/\,/, @current[$wiosettings{'ID'}]);
471
472 $wiosettings{'CLIENTID'} = $temp[0];
473 $wiosettings{'TIMESTAMP'} = $temp[1];
474 $wiosettings{'IPADR'} = $temp[2];
475 $wiosettings{'HOST'} = $temp[3];
476 $wiosettings{'EN'} = $temp[4];
477 $wiosettings{'REMARK'} = $temp[5];
478 $wiosettings{'DYNDNS'} = $temp[6];
479 $wiosettings{'SENDEMAILON'} = $temp[7];
480 $wiosettings{'SENDEMAILOFF'} = $temp[8];
481 $wiosettings{'PINGMETHODE'} = $temp[9];
482 $wiosettings{'ONLINE'} = $temp[10];
483 $wiosettings{'WEBINTERFACE'} = $temp[11];
484 }
485 else {
486 undef($wiosettings{'ACTION'});
487 $infomessage = "$Lang::tr{'wio_error_function'}";
488 }
489}
490
491## remove client
492
493if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_remove_client'} ) {
494 unless ( `ps -A | grep wio.pl` ) {
495 chomp(@current[$wiosettings{'ID'}]);
496
497 @temp = split (/\,/, @current[$wiosettings{'ID'}]);
498
499 unlink "$rrddir/$temp[0].rrd";
500
501 splice (@current,$wiosettings{'ID'},1);
502
503 &writeips();
504
505 undef($wiosettings{'ID'});
506 }
507 else {
508 undef($wiosettings{'ID'});
509 $infomessage = "$Lang::tr{'wio_error_function'}";
510 }
511}
512
513## remove all clients
514
515if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_remove_all'} ) {
516 unless ( `ps -A | grep wio.pl` ) {
517 &WIO::clearfile($ipadrfile);
518 unlink glob "$rrddir/*";
519 undef(@current);
520 }
521 else {
522 $infomessage = "$Lang::tr{'wio_error_function'}";
523 }
524}
525
526## back function
527
528if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_back'} ) {
529 if ( -e "$importfile" ) { unlink ($importfile); }
530 map ($wiosettings{$_} = '' ,@nosaved);
531 undef($errormessage);
532}
533
534## import hosts, fixleases or csv file || scan networks (green/blue/orange)
535
536if ( $wiosettings{'ACTION'} eq 'wio_run_green' ||
537 $wiosettings{'ACTION'} eq 'wio_run_blue' ||
538 $wiosettings{'ACTION'} eq 'wio_run_orange') { $wioscan = 'on'; }
539
540if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'1' ||
541 $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ||
542 $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'3' ||
543 defined($wioscan) || defined($importmessage) ) {
544
545unless ( `ps -A | grep wio.pl` ) {
546 if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'1' && $importmessage eq '' ) {
547
548 &Header::getcgihash(\%wiosettings, {'wantfile' => 1, 'filevar' => 'CSVFILE'});
549
550 if ( $wiosettings{'CSVFILE'} eq '' ) {
551 $errormessage = $Lang::tr{'wio_no_file_selected'};
552 $message = 2; goto ERROR;
553 }
554
555 if ( $wiosettings{'CSVFILE'} =~ /[^a-z0-9A-Z\ \.\-\_\:\\]+/ ) {
556 $errormessage = $Lang::tr{'wio_no_csv_error'};
557 $message = 2; goto ERROR;
558 }
559
560 if ( !($wiosettings{'CSVFILE'} =~ /.csv$/) ) {
561 $errormessage = $Lang::tr{'wio_no_csv'};
562 $message = 2; goto ERROR;
563 }
564
565 if (copy($wiosettings{'CSVFILE'}, "$logdir/importfile") != 1) {
566 $errormessage = $!;
567 $message = 2; goto ERROR;
568 }
569 }
570
571EDIT:
572
573&General::readhash($wiosettings, \%wiosettings);
574
575&Header::showhttpheaders();
576&Header::openpage($Lang::tr{'wio'}, 1, '');
577&Header::openbigbox('100%', 'left');
578
579if ($importmessage) {
580 &Header::openbox('100%', 'left', $Lang::tr{'wio_error'}, 'error');
581 print" <table width='100%'><tr><td><font class='base'>$importmessage</font></td></tr></table>";
582 &Header::closebox();
583}
584
585if ( -e "$editfile" ) {
586 open(FILE, "< $editfile" ); }
587elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'1' ) {
588 open(FILE, "< $importfile" ); }
589elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ) {
590 open(FILE, "< $hostfile" ); }
591elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'3' ) {
592 open(FILE, "< $dhcpfile" ); }
593elsif ( $wioscan eq 'on' ) {
594
595 foreach (keys(%ifacecolor)) {
596 if ( $netsettings{"${_}_DEV"} eq $wiosettings{'ID'} ) {
597 $dev = $netsettings{"${_}_DEV"};
598 $iprange = $wiosettings{"${_}_IPLOW"} . "-" . $wiosettings{"${_}_IPHIGH"};
599
600 if ( $_ eq 'GREEN' ) { $color = "$Header::colourgreen"; $net = $Lang::tr{'wio_msg_green'}; }
601 elsif ( $_ eq 'BLUE' ) { $color = "$Header::colourblue"; $net = $Lang::tr{'wio_msg_blue'}; }
602 else { $color = "$Header::colourorange"; $net = $Lang::tr{'wio_msg_orange'}; }
603 }
604 }
605
606&Header::openbox('100%', 'left', $Lang::tr{'wio_info'});
607 print"<table width='100%'>
608 <tr><td align='center'><font class='base'>$Lang::tr{'wio_msg_left'} </font><font class='base' color='$color'><b>$net</b></font> $Lang::tr{'wio_msg_center'} <font class='base' color='$color'><b>$dev</b></font><font class='base'> $Lang::tr{'wio_msg_right'} $Lang::tr{'wio_msg_hint'}</font></td></tr>
609 <tr><td>&nbsp;</td></tr>
610 <tr><td align='center'><img align='middle' src='/images/indicator.gif' /></td></tr>
611 </table>";
612&Header::closebox();
613&Header::closebigbox();
614
615 open(FILE, "/usr/local/bin/wioscan -wsa $dev $iprange |" );
616
617}
618
619@hosts = <FILE>;
620close(FILE);
621
622if ( $wioscan ne 'on' && ! -e $wiofile ) { @hosts = sort @hosts; }
623else {
624 open(FILE, "> $wiofile");
625 print FILE @hosts;
626 close(FILE);
627
628 print"<meta http-equiv=\"refresh\" content=\"0; URL=$ENV{'SCRIPT_NAME'}\">";
629 exit 0;
630}
631
632WIOSCAN:
633
634if ( -e $wiofile ) {
635 open(FILE, "< $wiofile");
636 @hosts = <FILE>;
637 close (FILE);
638
639 &General::readhash($wiosettings, \%wiosettings);
640
641 &Header::showhttpheaders();
642 &Header::openpage($Lang::tr{'wio'}, 1, '');
643 &Header::openbigbox('100%', 'left');
644}
645
646foreach (@hosts) {
647 chomp;
648
649 @line = split (/\,/, $_);
650
651 if ( -e $editfile || -e $importfile ) {
652 $wiosettings{'CLIENTID$count'} = $line[0];
653 $wiosettings{'TIMESTAMP$count'} = $line[1];
654 $wiosettings{'IPADR$count'} = $line[2];
655 $wiosettings{'HOST$count'} = $line[3];
656 $wiosettings{'EN$count'} = $line[4];
657 $wiosettings{'REMARK$count'} = $line[5];
658 $wiosettings{'DYNDNS$count'} = $line[6];
659 $wiosettings{'SENDEMAILON$count'} = $line[7];
660 $wiosettings{'SENDEMAILOFF$count'} = $line[8];
661 $wiosettings{'PINGMETHODE$count'} = $line[9];
662 $wiosettings{'ONLINE$count'} = $line[10];
663 $wiosettings{'WEBINTERFACE$count'} = $line[11];
664 $wiosettings{'USE$count'} = 'on';
665 }
666 else {
667 $wiosettings{'IPADR$count'} = $line[1];
668 $wiosettings{'EN$count'} = 'on';
669 $wiosettings{'PINGMETHODE$count'} = 'ip';
670 $wiosettings{'USE$count'} = 'on';
671
672 if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ) {
673 $wiosettings{'HOST$count'} = $line[2];
674 $wiosettings{'DOM$count'} = $line[3];
675 $wiosettings{'REMARK$count'} = '';
676 }
677 elsif ( $wioscan eq 'on' || -e $wiofile ) {
678 $wiosettings{'HOST$count'} = gethostbyaddr(inet_aton($line[1]), AF_INET);
679 if ($wiosettings{'HOST$count'} eq '') { $wiosettings{'HOST$count'} = $line[1]; }
680 $wiosettings{'REMARK$count'} = '';
0d6cc79d
SF
681 }
682 else {
683 $wiosettings{'HOST$count'} = $line[7];
684 $wiosettings{'REMARK$count'} = $line[6];
685 }
686 }
687
688 $checked{'EN$count'}{'on'} = ($wiosettings{'EN$count'} eq '' ) ? '' : "checked='checked'";
689
690 $checked{'DYNDNS$count'}{'on'} = ($wiosettings{'DYNDNS$count'} eq '' ) ? '' : "checked='checked'";
691 $checked{'SENDEMAILON$count'}{'on'} = ($wiosettings{'SENDEMAILON$count'} eq '' ) ? '' : "checked='checked'";
692 $checked{'SENDEMAILOFF$count'}{'on'} = ($wiosettings{'SENDEMAILOFF$count'} eq '' ) ? '' : "checked='checked'";
693
694 $checked{'PINGMETHODE$count'}{'ip'} = $checked{'PINGMETHODE$count'}{'fqdn'} = '';
695 $checked{'PINGMETHODE$count'}{$wiosettings{'PINGMETHODE$count'}} = "checked='checked'";
696
697 $checked{'USE$count'}{'on'} = ($wiosettings{'USE$count'} eq '' ) ? '' : "checked='checked'";
698
699 $selected{'WEBINTERFACE$count'}{'----'} = '';
700 $selected{'WEBINTERFACE$count'}{'HTTP'} = '';
701 $selected{'WEBINTERFACE$count'}{'HTTPS'} = '';
702 $selected{'WEBINTERFACE$count'}{$wiosettings{'WEBINTERFACE$count'}} = "selected='selected'";
703
704if (! &WIO::checkinto($wiosettings{'IPADR$count'}, $wiosettings{'HOST$count'}, @current) ) {
705
706if ( $importmessage ) {
707 &Header::openbox('100%', 'left', "$Lang::tr{'wio_import_data'}'$wiosettings{'HOST$count'}'$Lang::tr{'wio_import_data1'}");
708}
709elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'1' || $wioscan eq 'on' || -e $wiofile || -e $editfile ) {
710 &Header::openbox('100%', 'left', "$Lang::tr{'wio_import_data'}'$wiosettings{'HOST$count'}'$Lang::tr{'wio_import_data2'}");
711}
712elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ) {
713 &Header::openbox('100%', 'left', "$Lang::tr{'wio_import_data'}'$wiosettings{'HOST$count'}.$wiosettings{'DOM$count'}'$Lang::tr{'wio_import_data2'}");
714}
715else {
716 &Header::openbox('100%', 'left', $Lang::tr{'wio_import_leases'});
717}
718
719print"
720<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
721<input type='hidden' name='ONLINE$count' value='$wiosettings{'ONLINE$count'}' />
722
723<table width='100%'>
724<tr>
725 <td>$Lang::tr{'wio_use'}</td>
726 <td><input type='checkbox' name='USE$count' $checked{'USE$count'}{'on'} /></td>
727</tr>
728<tr>
729 <td>$Lang::tr{'wio_client_enable'}</td>
730 <td><input type='checkbox' name='EN$count' $checked{'EN$count'}{'on'} /></td>
731</tr>
732<tr>
733 <td>$Lang::tr{'host ip'}:</td>
734 <td><input type='text' name='IPADR$count' value='$wiosettings{'IPADR$count'}' size='18' /></td>
735 <td>$Lang::tr{'hostname'}:</td>
736";
737
738if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ) {
739 print"<td><input type='text' name='HOST$count' size='18' value='$wiosettings{'HOST$count'}.$wiosettings{'DOM$count'}' /></td>";
740}
741else {
742 print"<td><input type='text' name='HOST$count' size='18' value='$wiosettings{'HOST$count'}' /></td>";
743}
744
745print"
746 <td>$Lang::tr{'remark'}:</td>
747 <td><input type='text' name='REMARK$count' value='$wiosettings{'REMARK$count'}' size='18' /></td>
748</tr>
749<tr>
750 <td class='base'>$Lang::tr{'wio_ping_send'}:</td>
751 <td align='left'><input type='radio' name='PINGMETHODE$count' value='ip' $checked{'PINGMETHODE$count'}{'ip'} />&nbsp;IP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='radio' name='PINGMETHODE$count' value='fqdn' $checked{'PINGMETHODE$count'}{'fqdn'} />&nbsp;FQDN</td>
752 <td>$Lang::tr{'wio_dyndns'}:</td>
753 <td><input type='checkbox' name='DYNDNS$count' $checked{'DYNDNS$count'}{'on'} /></td>
754";
755
756if ( $wiosettings{'SENDEMAIL'} eq 'on' ) {
757 print"<td>$Lang::tr{'wio_sendemail'}:</td>
758 <td><input type='checkbox' name='SENDEMAILON$count' $checked{'SENDEMAILON$count'}{'on'} />&nbsp;$Lang::tr{'wio_online'}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' name='SENDEMAILOFF$count' $checked{'SENDEMAILOFF$count'}{'on'} />&nbsp;$Lang::tr{'wio_offline'}</td>";
759}
760else {
761 print"<td colspan='2'>&nbsp;</td>";
762}
763
764print"
765</tr>
766<tr>
1bee37ba 767 <td height='30'>$Lang::tr{'wio_link_open'}:</td>
0d6cc79d
SF
768 <td align='left' colspan='5'>
769 <select size='1' name='WEBINTERFACE$count' width='80' style='width: 80px'>
770 <option value='----' $selected{'WEBINTERFACE$count'}{'----'}>----</option>
771 <option value='HTTP' $selected{'WEBINTERFACE$count'}{'HTTP'}>HTTP</option>
772 <option value='HTTPS' $selected{'WEBINTERFACE$count'}{'HTTPS'}>HTTPS</option>
773 </select>
774 </td>
775</tr>
776</table>
777";
778
779&Header::closebox();
780$showcount++;
781}
782$count++;
783}
784
785if ( $showcount gt 0 ) {
786&Header::openbox('100%', 'left', $Lang::tr{'wio_import_infos'});
787
788print"
789<table width='100%'>
790<tr>
791";
792
793if ($importmessage) { print"<td>&nbsp;</td>"; }
794else { print"<td><font color='$color{'color11'}'>$Lang::tr{'wio_import_infos_csv'}</font></td>"; }
795
796print"
797</tr>
798<tr><td colspan='4'>&nbsp;</td></tr>
799</table>
800<table width='100%'>
801<tr>
802 <td width='25%'>&nbsp;</td>
803 <td width='25%'><input type='hidden' name='COUNT' value='$count' /><input type='hidden' name='ACTION' value='$Lang::tr{'wio_save'}2' /><input type='submit' name='SUBMIT' value='$Lang::tr{'wio_save'}' /></form></td>
804 <td width='25%'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'><input type='submit' name='ACTION' value='$Lang::tr{'wio_back'}' /></form></td>
805 <td width='25%'>&nbsp;</td>
806</tr>
807</table>
808";
809
810&Header::closebox();
811&Header::closebigbox();
812&Header::closepage();
813}
814else {
815 print"<meta http-equiv=\"refresh\" content=\"0; URL=$ENV{'SCRIPT_NAME'}?INFO\">";
816}
817
818if ( -e "$editfile" ) { unlink ($editfile); }
819if ( -e "$wiofile" ) { unlink($wiofile); }
820exit 0;
821}
822else {
823 $infomessage = "$Lang::tr{'wio_error_function'}";
824}
825}
826
827## skript function
828
829if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) {
830 my $string = $ENV{'QUERY_STRING'};
831
832 if ( $string eq 'INFO' ) {
833 $infomessage = $Lang::tr{'wio_import_info_csv'};
834 }
835 else {
836 &General::readhash($wiosettings, \%wiosettings);
837
838 my $actual = $wiosettings{'SORT'};
839
840 if ($actual =~ $string) {
841 my $Rev = '';
842 if ($actual !~ 'Rev') { $Rev = 'Rev'; }
843 $string.=$Rev;
844 }
845
846 system("/bin/sed -i 's#$wiosettings{'SORT'}#$string#g' $wiosettings");
847
848 $wiosettings{'SORT'} = $string;
849 map ($wiosettings{$_} = '' ,@nosaved);
850 &SortDataFile('',@current);
851 }
852}
853
854## main part
855
856ERROR:
857
858unless($message == 1) { &General::readhash($wiosettings, \%wiosettings); }
859
860for ($i=5; $i<=60; $i+=5) { $selected{'CRON'}{$i} = ''; }
861
862$selected{'CRON'}{$wiosettings{'CRON'}} = "selected='selected'";
863
864for ($i=1; $i<=15; $i++) {
865 $selected{'TIMEOUT'}{$i} = '';
866 $selected{'OVPNCRON'}{$i} = '';
867}
868
869$selected{'TIMEOUT'}{$wiosettings{'TIMEOUT'}} = "selected='selected'";
870$selected{'OVPNCRON'}{$wiosettings{'OVPNCRON'}} = "selected='selected'";
871
872$checked{'ENABLE'}{'off'} = $checked{'ENABLE'}{'on'} = '';
873$checked{'ENABLE'}{$wiosettings{'ENABLE'}} = "checked='checked'";
874
875$checked{'LOGGING'}{'off'} = $checked{'LOGGING'}{'on'} = '';
876$checked{'LOGGING'}{$wiosettings{'LOGGING'}} = "checked='checked'";
877
878$checked{'CLIENTREMARK'}{'off'} = $checked{'CLIENTREMARK'}{'on'} = '';
879$checked{'CLIENTREMARK'}{$wiosettings{'CLIENTREMARK'}} = "checked='checked'";
880
881$checked{'MAILREMARK'}{'off'} = $checked{'MAILREMARK'}{'on'} = '';
882$checked{'MAILREMARK'}{$wiosettings{'MAILREMARK'}} = "checked='checked'";
883
884$checked{'OVPNRWMAIL'}{'off'} = $checked{'OVPNRWMAIL'}{'on'} = '';
885$checked{'OVPNRWMAIL'}{$wiosettings{'OVPNRWMAIL'}} = "checked='checked'";
886
887$checked{'SHUTDOWN'}{'off'} = $checked{'SHUTDOWN'}{'on'} = '';
888$checked{'SHUTDOWN'}{$wiosettings{'SHUTDOWN'}} = "checked='checked'";
889
890$checked{'MAILSTYLE'}{'smail'} = $checked{'MAILSTYLE'}{'email'} = '';
891$checked{'MAILSTYLE'}{$wiosettings{'MAILSTYLE'}} = "checked='checked'";
892
893&Header::showhttpheaders();
894&Header::openpage($Lang::tr{'wio'}, 1, "<meta http-equiv='expires' content='-1'><meta http-equiv='cache-control' content='no-store, no-cache, must-revalidate'><meta http-equiv='pragma' content='no-cache'>");
895&Header::openbigbox('100%', 'left', '');
896
897## DEBUG / ERROR / INFO / UPDATE
898
899if ( $debug ) {
900 &Header::openbox('100%', 'left', 'DEBUG', 'warning');
901
902 print"errormessage: $errormessage<br />\n";
903 print"infomessage: $infomessage<br />\n";
904
905 &hrline();
a25c95b3 906
0d6cc79d
SF
907 my $wiodebug = 0;
908 foreach (sort keys %wiosettings) {
909 print"$_ = $wiosettings{$_}<br />\n";
910 $wiodebug++;
911 }
912
913 &hrline();
914
915 my $netdebug = 0;
916 foreach (sort keys %netsettings) {
917 print"$_ = $netsettings{$_}<br />\n";
918 $netdebug++;
919 }
920 &Header::closebox();
921}
922
923if ( $errormessage ) {
924 &Header::openbox('100%', 'left', $Lang::tr{'wio_error'}, 'error');
925 print"<table width='100%'><tr><td><font class='base'><b>$errormessage</b></font></td></tr></table>";
926 &Header::closebox();
927}
928
929if ( $infomessage ) {
930 &Header::openbox('100%', 'left', $Lang::tr{'wio_info'}, 'warning');
931 print"<table width='100%'><tr><td><font class='base'><b>$infomessage</b></font></td></tr></table>";
932 &Header::closebox();
933}
934
935## wio configuration
936
937if ( $wiosettings{'ACTION'} eq $Lang::tr{'edit'}.'1' || $message == 1 || $wiosettings{'ENABLE'} eq 'off' ) {
938
939&Header::openbox('100%', 'left', $Lang::tr{'wio settings'});
940
941print"
942<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
943<table width='100%'>
944<tr>
a25c95b3 945 <td width='55%' bgcolor='$color{'color20'}' align='left' height='20'><b>&nbsp;$Lang::tr{'wio_settings_msg'}</b></td>
0d6cc79d 946 <td width='2%'>&nbsp;</td>
a25c95b3 947 <td width='43%'>&nbsp;</td>
0d6cc79d
SF
948</tr>
949<tr><td colspan='3'>&nbsp;</td></tr>
950<tr>
951 <td colspan='3'>$Lang::tr{'wio_settings_msg_hint'}</td>
952</tr>
953<tr><td colspan='3'>&nbsp;</td></tr>
954<tr>
955 <td align='right'>$Lang::tr{'wio enabled'}</td>
956";
957
958print"<td>&nbsp;</td>";
959
960if ( $wiosettings{'ENABLE'} eq 'on' ) {
961 print"<td align='left'><input type='checkbox' onClick=\"return confirm('$Lang::tr{'wio_disable_hint'}')\" name='ENABLE' $checked{'ENABLE'}{'on'} /></td>";
962}
963else {
964 print"<td align='left'><input type='checkbox' name='ENABLE' $checked{'ENABLE'}{'on'} /></td>";
965}
966print"
967</tr>
968<tr><td colspan='3'>&nbsp;</td></tr>
969<tr>
970 <td align='right'>$Lang::tr{'wio_shutdown'}</td>
971 <td>&nbsp;</td>
972 <td align='left'><input type='checkbox' name='SHUTDOWN' $checked{'SHUTDOWN'}{'on'} /></td>
973</tr>
974<tr><td colspan='3'>&nbsp;</td></tr>
975<tr>
976 <td align='right'>$Lang::tr{'wio cron'}</td>
977 <td>&nbsp;</td>
978 <td align='left'><select size='1' name='CRON' size='5'>
979";
980
fe6f676b
SF
981for ($i=5; $i<=60; $i+=5) {
982 $_ = sprintf("%02s",$i);
983 print "<option $selected{'CRON'}{$_}>$_</option>\n";
984}
0d6cc79d
SF
985
986print"
987 </select>&nbsp;$Lang::tr{'wio min'}</td>
988</tr>
989<tr><td colspan='3'>&nbsp;</td></tr>
990<tr>
991 <td align='right'>$Lang::tr{'wio timeout'}</td>
992 <td>&nbsp;</td>
993 <td align='left'><select size='1' name='TIMEOUT' size='5'>
994";
995
fe6f676b
SF
996for ($i=1; $i<=15; $i++) {
997 $_ = sprintf("%02s",$i);
998 print "<option $selected{'TIMEOUT'}{$_}>$_</option>\n";
999}
0d6cc79d 1000
c1fc92a9 1001print"
0d6cc79d
SF
1002 </select>&nbsp;$Lang::tr{'wio sec'}</td>
1003</tr>
1004<tr><td colspan='3'>&nbsp;</td></tr>
1005<tr>
1006 <td align='right'>$Lang::tr{'wio_logging'}</td>
1007 <td>&nbsp;</td>
1008 <td align='left'><input type='checkbox' name='LOGGING' $checked{'LOGGING'}{'on'} /></td>
1009</tr>
1010<tr><td colspan='3'>&nbsp;</td></tr>
1011<tr>
1012 <td align='right'>$Lang::tr{'wio_clientremark'}</td>
1013 <td>&nbsp;</td>
1014 <td align='left'><input type='checkbox' name='CLIENTREMARK' $checked{'CLIENTREMARK'}{'on'} /></td>
1015</tr>
1016<tr><td colspan='3'>&nbsp;</td></tr>
0d6cc79d
SF
1017";
1018
1019if ( $wiosettings{'SENDEMAIL'} eq 'on' ) {
1020print"
1021<tr>
1022 <td align='right'>$Lang::tr{'wio_mail_style'}:</td>
1023 <td>&nbsp;</td>
1024 <td align='left'><input type='radio' name='MAILSTYLE' value='smail' $checked{'MAILSTYLE'}{'smail'} />&nbsp;$Lang::tr{'wio_mail_smail'}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='radio' name='MAILSTYLE' value='email' $checked{'MAILSTYLE'}{'email'} />&nbsp;$Lang::tr{'wio_mail_email'}</td>
1025</tr>
1026<tr><td colspan='3'>&nbsp;</td></tr>
1027<tr>
1028 <td align='right'>$Lang::tr{'wio_mailremark_enabled'}</td>
1029 <td>&nbsp;</td>
1030 <td align='left'><input type='checkbox' name='MAILREMARK' $checked{'MAILREMARK'}{'on'}></td>
1031</tr>
1032<tr><td colspan='3'>&nbsp;</td></tr>
1033";
1034}
1035if ( -e "$ovpnaddon" || ! -z "/var/ipfire/vpn/config" ) {
1036print"
1037<tr>
1038 <td align='right'>$Lang::tr{'wio_mail_ovpnrw'}</td>
1039 <td>&nbsp;</td>
1040 <td align='left'><input type='checkbox' name='OVPNRWMAIL' $checked{'OVPNRWMAIL'}{'on'}></td>
1041</tr>
1042<tr><td colspan='3'>&nbsp;</td></tr>
1043<tr>
1044 <td align='right'>$Lang::tr{'wio_ovpn_cron'}</td>
1045 <td>&nbsp;</td>
1046 <td align='left'><select size='1' name='OVPNCRON' size='5'>
1047";
1048
fe6f676b
SF
1049for ($i=1; $i<=15; $i++) {
1050 $_ = sprintf("%02s",$i);
1051 print "<option $selected{'OVPNCRON'}{$_}>$_</option>\n";
1052}
0d6cc79d
SF
1053
1054print"
1055 </select>&nbsp;$Lang::tr{'wio min'}</td>
1056</tr>
1057<tr><td colspan='3'>&nbsp;</td></tr>
1058";
1059}
1060print"
1061<tr><td colspan='3'>&nbsp;</td></tr>
1062<tr>
1063 <td colspan='2'>&nbsp;</td>
1064 <td align='left'><input type='hidden' name='ACTION' value='$Lang::tr{'wio_save'}1' /><input type='submit' name='submit' value='$Lang::tr{'wio_save'}' />"
1065 .($wiosettings{'ENABLE'} ne 'off' ? "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' onClick='location.href=\"/cgi-bin/wio.cgi\"' value='$Lang::tr{'wio_back'}'>" : "")
1066 ."</td>
1067</tr>
1068</table>
1069</form>
1070";
1071
1072&Header::closebox();
1073&Header::closebigbox();
1074&Header::closepage();
1075exit 0;
1076}
1077
1078## wio client status
1079
1080if ( $wiosettings{'ENABLE'} eq 'on') {
1081 if ( !$errormessage && $wiosettings{'ACTION'} ne $Lang::tr{'edit'} || $message == 2 ) {
1082 &Header::openbox('100%', 'left', $Lang::tr{'wio stat'});
1083
1084 foreach (@current) {
1085 chomp;
1086
1087 ($id,$timestamp,$ipadr,$host,$on,$remark,$dyndns,$sendemailon,$sendemailoff,$pingmethode,$online,$webinterface) = split (/\,/, $_);
1088
1089 if ( defined($dyndns) && ( $dyndns =~ 'on' ) ) {
1090 ($dyndnsip, $infomessage) = &WIO::getdyndnsip($ipadr, $host);
1091
1092 if ( $dyndnsip ne $ipadr ) {
1093 $ipadr = $dyndnsip;
1094 $write = 'on';
1095 }
1096 }
1097
1098 push (@id,($id));
1099
1100 if ( $on eq 'on' ) { push (@dates,($timestamp)); }
1101 else { push (@dates,('-')); }
1102
1103 push (@ipaddresses,($ipadr));
1104 push (@names,($host));
1105 push (@activ,($on));
1106 push (@remark,($remark));
1107 push (@dyndns,($dyndns));
1108 push (@sendemailon,($sendemailon));
1109 push (@sendemailoff,($sendemailoff));
1110 push (@pingmethode,($pingmethode));
1111 push (@status,($online));
1112 push (@webinterface,($webinterface));
1113
1114 push (@write, "$id,$timestamp,$ipadr,$host,$on,$remark,$dyndns,$sendemailon,$sendemailoff,$pingmethode,$online,$webinterface\n");
1115
1116 $nr++;
1117 }
1118
1119 if ( defined($write) ) { &writeips(); }
1120
1121## wan connection
1122
1123print"
1124<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
a25c95b3
SFD
1125<tr height='25'>
1126 <td width='33%' bgcolor='$color{'color20'}' align='left'><b>&nbsp;$Lang::tr{'wio_wan_con'}</b></td>
1127 <td width='67%' align='right'>&nbsp;</td>
0d6cc79d
SF
1128</tr>
1129<tr><td colspan='2'>&nbsp;</td></tr>
1130</table>
1131
1132<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1133<tr bgcolor='$color{'color20'}' height='20'>
1134 <td width='3%' align='center'><b>$Lang::tr{'wio_id'}</b></td>
1135 <td width='15%' align='center'><b>$Lang::tr{'wio ipadress'}</b></td>
1136 <td width='3%' align='center'><b>$Lang::tr{'wio network'}</b></td>
1137 <td width='15%' align='center'><b>$Lang::tr{'wio_lanname'}</b></td>
1138 <td width='15%' align='center'><b>$Lang::tr{'wio_wanname'}</b></td>
1139 <td width='24%' align='center'><b>$Lang::tr{'wio_dyndns_hosts'}</b></td>
1140 <td width='11%' align='center'><b>$Lang::tr{'wio image'}</b></td>
c1fc92a9 1141 <td width='14%' align='center'><b>$Lang::tr{'wio_connected'}</b></td>
0d6cc79d
SF
1142</tr>
1143<tr bgcolor='$color{'color22'}' height='20'>
1144 <td align='center'>01</td>
1145 <td align='center'><font color='$Header::colourred'>$redip</b></font></td>
1146 <td align='center'><img align='middle' src='$imgstatic/red.png' alt='$Lang::tr{'internet'}' title='$Lang::tr{'internet'}' /></td>
1147 <td align='center'><font color='$Header::colourgreen'>".$mainsettings{'HOSTNAME'}.".".$mainsettings{'DOMAINNAME'}."</font></td>
1148 <td align='center'><font color='$Header::colourred'>".( $redip ne '-' ? (gethostbyaddr(pack("C4", split (/\./, $redip)), 2))[0] : '-' )."</font></td>
1149 <td align='center'>
1150";
1151
1152if ( -s "$dyndnsconfig" ) {
1153
1154open(FILE, "< $dyndnsconfig");
1155@ddns = <FILE>;
1156close (FILE);
1157
1158$ddns = @ddns;
1159$bgcolor = "blue";
1160
1161 foreach (@ddns) {
1162 chomp;
1163
1164 @temp = split (/\,/, $_);
1165
1166 if ( $temp[7] eq "on" ) { $bgcolor = ( &General::DyndnsServiceSync (&General::GetDyndnsRedIP,$temp[1],$temp[2]) ? "$Header::colourgreen" : "$Header::colourred" ); }
1167
1168 print"<font color='$bgcolor'>$temp[1].$temp[2]</font>";
1169
1170 if ( $iddyndns++ ne ($ddns-1) ) { print"<b>, </b>"; }
1171 }
1172}
1173else { print"<b> - </b>"; }
1174
1175print"
1176 </td>
1177 <td align='center'>
1178 <table bgcolor='".( -e $redactive ? "${Header::colourgreen}" : "${Header::colourred}" )."' cellpadding='2' cellspacing='0' width='100%'>
1179 <tr height='20'>
1180 <td align='center'><font color='white'><b>".( -e $redactive ? $Lang::tr{'wio_wan_up'} : $Lang::tr{'wio_wan_down'} )."</b></font></td>
1181 </tr>
1182 </table>
1183 </td>
1184 <td align='center'><font color='$Header::colourred'>".( -e "$redactive" ? &General::age("$redactive") : '-' )."</font></td>
1185</tr>
1186<tr height='1'><td colspan='9' bgcolor='#696565'></td></tr>
1187</table>
1188";
1189
1190&hrline();
1191
1192## vpn connection(s)
1193
1194if ( -e "$vpnpid" ) {
1195
1196@vpnstatus = `/usr/local/bin/ipsecctrl I`;
1197
1198print"
1199<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
a25c95b3
SFD
1200<tr height='25'>
1201 <td width='33%' bgcolor='$color{'color20'}' align='left'><b>&nbsp;$Lang::tr{'wio_vpn_con'}</b></td>
1202 <td width='67%'>&nbsp;</td>
0d6cc79d
SF
1203</tr>
1204<tr><td colspan='2'>&nbsp;</td></tr>
1205</table>
1206<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1207<tr bgcolor='$color{'color20'}' height='20'>
1208 <td width='3%' align='center'><b>$Lang::tr{'wio_id'}</b></td>
1209 <td width='19%' align='center'><b>$Lang::tr{'wio checked'}</b></td>
1210 <td width='20%' align='center'><b>$Lang::tr{'name'}</b></td>
1211 <td width='8%' align='center'><b>$Lang::tr{'type'}</b></td>
1212 <td width='25%' align='center'><b>$Lang::tr{'wio_common_name'}</b></td>
1213 <td width='11%' align='center'><b>$Lang::tr{'wio image'}</b></td>
c1fc92a9 1214 <td width='14%' align='center'><b>$Lang::tr{'wio_connected'}</b></td>
0d6cc79d
SF
1215</tr>
1216";
1217
1218foreach $key (sort SortByTunnelName (keys(%vpnconfighash))) {
1219
1220my $vpncheck = '';
1221
1222if ( -e '/var/log/wio/.vpncache' ) {
1223 $vpncheck = strftime("%d.%m.%Y - %H:%M:%S",localtime(((stat('/var/log/wio/.vpncache'))[9])));
1224}
1225
1226$status = "bgcolor='${Header::colourred}'";
1227$statustxt = "$Lang::tr{'capsclosed'}";
1228
1229 if ($vpnconfighash{$key}[0] eq 'off') {
1230 $status = "bgcolor='${Header::colourblue}'";
1231 $statustxt = "$Lang::tr{'capsclosed'}";
1232 }
1233
1234 foreach (@vpnstatus) {
1235 if ($_ =~ /$vpnconfighash{$key}[1]\{.*INSTALLED/) {
1236 $status = "bgcolor='${Header::colourgreen}'";
1237 $statustxt = "$Lang::tr{'capsopen'}";
1238 last;
1239 }
1240 }
1241
1242 print"<tr".($idvpn % 2?" bgcolor='$color{'color20'}'":" bgcolor='$color{'color22'}'")." height='20'>";
1243
1244 my $vpnnr = $idvpn+1;
1245
1246 printf ("<td align='center'> %02d</td>", $vpnnr);
1247
1248 print"<td align='center'>$vpncheck</td>
1249 <td align='center'>$vpnconfighash{$key}[1]</td>
1250 <td align='center'><img align='middle' src='$imgstatic/".( $vpnconfighash{$key}[3] eq 'host' ? "vpnrw.png' alt='$Lang::tr{'wio_rw'}' title='$Lang::tr{'wio_rw'}'" : "vpnn2n.png' alt='$Lang::tr{'wio_n2n'}' title='$Lang::tr{'wio_n2n'}'")." /></td>
1251 <td align='center'>".($vpnconfighash{$key}[2] eq '%auth-dn' ? "$vpnconfighash{$key}[9]" : ($vpnconfighash{$key}[4] eq 'cert' ? "$vpnconfighash{$key}[2]" : ($vpnconfighash{$key}[8] ne '' ? "$vpnconfighash{$key}[10]" : "&nbsp;")))."</td>
1252 <td align='center'>
1253 <table $status cellpadding='2' cellspacing='0' width='100%'>
1254 <tr height='20'>
1255 <td align='center'><font color='white'><b>$statustxt</b></font></td>
1256 </tr>
1257 </table>
1258 </td>
1259 <td align='center' height='20'>&nbsp;</td>
1260 </tr>
1261";
c1fc92a9 1262
0d6cc79d
SF
1263if ($vpnconfighash{$key}[25] && $wiosettings{'CLIENTREMARK'} eq 'on') {
1264 print"<tr".($idvpn % 2?" bgcolor='$color{'color20'}'":" bgcolor='$color{'color22'}'")." height='20'><td>&nbsp;</td><td colspan='16' align='left'>$vpnconfighash{$key}[25]</td></tr>";
1265}
1266 print"<tr height='1'><td colspan='7' bgcolor='#696565'></td></tr>";
1267 $idvpn++
1268}
1269
1270print"</table>";
1271&hrline();
1272}
1273
1274## openvpn connection(s)
1275
1276if ( -e "$ovpnpid" ) {
1277
1278@ovpnstatus = `cat /var/run/ovpnserver.log`;
1279
1280print"
1281<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
a25c95b3
SFD
1282<tr height='25'>
1283 <td width='33%' bgcolor='$color{'color20'}' align='left'><b>&nbsp;$Lang::tr{'wio_ovpn_con'}</b></td>
1284 <td width='67%'>&nbsp;</td>
0d6cc79d
SF
1285</tr>
1286<tr><td colspan='2'>&nbsp;</td></tr>
1287</table>
1288<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1289<tr bgcolor='$color{'color20'}' height='20'>
1290 <td width='3%' align='center'><b>$Lang::tr{'wio_id'}</b></td>
1291 <td width='19%' align='center'><b>$Lang::tr{'wio checked'}</b></td>
1292 <td width='20%' align='center'><b>$Lang::tr{'wio ipadress'}</b></td>
1293 <td width='8%' align='center'><b>$Lang::tr{'type'}</b></td>
1294 <td width='25%' align='center'><b>$Lang::tr{'common name'}</b></td>
1295 <td width='11%' align='center'><b>$Lang::tr{'wio image'}</b></td>
c1fc92a9 1296 <td width='14%' align='center'><b>$Lang::tr{'wio_connected'}</b></td>
0d6cc79d
SF
1297</tr>
1298";
1299
1300 foreach $key (keys %ovpnconfighash) {
1301
1302 my ( $ovpnclt, $ovpntime, $ovpnrwip, $ovpncheck ) = '';
1303
1304 if ( -e '/var/log/wio/.ovpncache' ) {
1305 $ovpncheck = strftime("%d.%m.%Y - %H:%M:%S",localtime(((stat('/var/log/wio/.ovpncache'))[9])));
1306 }
1307
1308 print"<tr".($idovpn % 2?" bgcolor='$color{'color20'}'":" bgcolor='$color{'color22'}'")." height='20'>";
1309
1310 my $ovpnnr = $idovpn+1;
1311
1312 printf ("<td align='center' height='20'> %02d</td>", $ovpnnr);
1313
1314 if ($ovpnconfighash{$key}[3] eq 'net') {
1315 $image = "$imgstatic/ovpnn2n.png";
1316 $text = "$Lang::tr{'wio_n2n'}";
1317 }
1318 else {
1319 $image = "$imgstatic/ovpnrw.png";
1320 $text = "$Lang::tr{'wio_rw'}";
1321 }
1322
1323 if ( $ovpnconfighash{$key}[0] eq 'off' ) {
1324 $status = "${Header::colourblue}";
1325 $statustxt = "$Lang::tr{'capsclosed'}";
1326 }
1327 else {
0d6cc79d
SF
1328 if ($ovpnconfighash{$key}[3] eq 'net') {
1329 if (-e "/var/run/$ovpnconfighash{$key}[1]n2n.pid") {
1330 my @output = "";
1331 my @tustate = "";
1332 my $tport = $ovpnconfighash{$key}[22];
1333 my $tnet = new Net::Telnet ( Timeout=>5, Errmode=>'return', Port=>$tport);
1334 if ($tport ne '') {
1335 $tnet->open('127.0.0.1');
1336 @output = $tnet->cmd(String => 'state', Prompt => '/(END.*\n|ERROR:.*\n)/');
1337 @tustate = split(/\,/, $output[1]);
1338 $ovpntime = &WIO::contime(scalar localtime($tustate[0]));
1339
1340 if (($tustate[1] eq 'CONNECTED')) {
1341 $status = "${Header::colourgreen}";
1342 $statustxt = "$Lang::tr{'capsopen'}";
1343 }else {
1344 $status = "${Header::colourred}";
1345 $statustxt = "$tustate[1]";
1346 }
1347 }
1348 }
1349 }
1350 else {
1351 foreach (@ovpnstatus) {
1352 if ( $_ =~ /^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/ ) {
1353 @match = split (m/^(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(\d+),(\d+),(.+)/, $_);
1354 $match[1] =~ s/[_]/ /g;
1355 }
1356
1357 if ( $match[1] ne "Common Name" && ($match[1] eq $ovpnconfighash{$key}[2]) ) {
1358 $ovpnclt = $match[1];
1359 $ovpntime = &WIO::contime($match[5]);
1360 }
1361
1362 if ( $_ =~ /^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/ ) {
1363 @match = split(m/^(\d+\.\d+\.\d+\.\d+),(.+),(\d+\.\d+\.\d+\.\d+\:\d+),(.+)/, $_);
1364 }
1365
1366 if ( $match[1] ne "Virtual Address" && $match[2] eq $ovpnclt ) {
1367 $ovpnrwip = $match[1];
1368 $ovpncheck = &WIO::statustime($match[4]);
1369 }
1370
1371 if ( $ovpnclt eq $ovpnconfighash{$key}[2] ) {
1372 $status = "${Header::colourgreen}";
1373 $statustxt = "$Lang::tr{'capsopen'}";
1374 }
1375 else {
1376 $status = "${Header::colourred}";
1377 $statustxt = "$Lang::tr{'capsclosed'}";
1378 }
1379 }
1380 }
1381}
1382
1383 print"
1384 <td align='center'>$ovpncheck</td>
1385 <td align='center'>".( defined($ovpnrwip)? "$ovpnrwip" : "&nbsp;")."</td>
1386 <td align='center'><img align='middle' src='$image' alt='$text' title='$text' /></td>
1387 <td align='center'>".($ovpnconfighash{$key}[2] eq '%auth-dn' ? "$ovpnconfighash{$key}[9]" : ($ovpnconfighash{$key}[4] eq 'cert' ? "$ovpnconfighash{$key}[2]": "&nbsp;"))."</td>
1388 <td align='center'><table bgcolor='$status' cellpadding='2' cellspacing='0' width='100%'><tr height='20'><td align='center'><font color='white'><b>$statustxt</b></font></td></tr></table></td>
1389 <td align='center'>".(defined($ovpntime)? "$ovpntime" : "&nbsp;")."</td>
1390</tr>
1391";
1392 if ($ovpnconfighash{$key}[25] && $wiosettings{'CLIENTREMARK'} eq 'on') {
1393 print"<tr".($idovpn % 2?" bgcolor='$color{'color20'}'":" bgcolor='$color{'color22'}'")." height='20'><td>&nbsp;</td><td colspan='16' align='left'>$ovpnconfighash{$key}[25]</td></tr>";
1394 }
c1fc92a9 1395
0d6cc79d
SF
1396 print"<tr height='1'><td colspan='17' bgcolor='#696565'></td></tr>";
1397 $idovpn++
1398 }
1399 print"</table>";
1400 &hrline();
1401}
1402#}
1403
1404## client status
1405
1406print"
1407<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
a25c95b3
SFD
1408<tr height='25'>
1409 <td width='33%' bgcolor='$color{'color20'}' align='left'><b>&nbsp;$Lang::tr{'wio_clients'}</b></td>
1410 <td width='67%'>&nbsp;</td>
0d6cc79d
SF
1411</tr>
1412<tr><td colspan='2'>&nbsp;</td></tr>
1413</table>
1414
1415<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1416<tr bgcolor='$color{'color20'}' height='20'>
1417 <td width='3%' align='center'><b>$Lang::tr{'wio_id'}</b></td>
1418 <td width='4%' align='center'><b>$Lang::tr{'wio_activ'}</b></td>
1419 <td width='5%' align='center'><b>$Lang::tr{'wio_check'}</b></td>
1420 <td width='15%' align='center'><b>$Lang::tr{'wio checked'}</b></td>
1421 <td width='4%' align='center'><b>$Lang::tr{'wio_webinterface'}</b></td>
1422 <td width='11%' align='center'><a href='$ENV{'SCRIPT_NAME'}?IPADR'><b>$Lang::tr{'wio ipadress'}</b></a></td>
1423 <td width='5%' align='center'><b>$Lang::tr{'wio network'}</b></td>
1424 <td width='20%' align='center'><a href='$ENV{'SCRIPT_NAME'}?HOST'><b>$Lang::tr{'wio name'}</b></a></td>
1425 <td width='11%' align='center'><b>$Lang::tr{'wio image'}</b></td>
1426 <td width='4%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'><input type='hidden' name='ACTION' value='$Lang::tr{'wio_refresh'}' /><input type='image' name='$Lang::tr{'wio_refresh'}' src='$imgstatic/refresh.png' align='middle' alt='$Lang::tr{'wio_refresh'}' title='$Lang::tr{'wio_refresh'}' /></form></td>
1427 <td width='4%' colspan='2' align='center'><b>$Lang::tr{'wio_dyndns'}</b></td>
1428 <td width='12%' colspan='4' align='center'><b>$Lang::tr{'action'}</b></td>
1429 <td width='3%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'><input type='hidden' name='ACTION' value='$Lang::tr{'wio_remove_all'}' /><input type='image' name='$Lang::tr{'wio_remove_all'}' src='/images/delete.gif' align='middle' alt='$Lang::tr{'wio_remove_all'}' title='$Lang::tr{'wio_remove_all'}' onClick=\"return confirm('$Lang::tr{'wio_remove_all_hint'}')\"/></form></td>
1430</tr>
1431";
1432
1433for (my $a=0; $a<$nr; $a++) {
1434
1435my $gif = 'off.gif';
1436my $gdesc = $Lang::tr{'wio_client_off'};
1437my $dyndnsimg = 'on.gif';
1438my $dyndnsimgtxt = $Lang::tr{'wio_dyndns_on'};
1439my $mailonimg = 'wio/mailgreenon.png';
1440my $mailonimgtxt = $Lang::tr{'wio_mail_online_on'};
1441my $mailoffimg = 'wio/mailredon.png';
1442my $mailoffimgtxt = $Lang::tr{'wio_mail_offline_on'};
1443my $pingimg = '';
1444my $pingtxt = '';
1445my $webimg = '';
1446
1447if ( $activ[$a] eq 'on' ) {
1448 $gif = 'on.gif';
1449 $gdesc = $Lang::tr{'wio_client_on'};
1450}
1451
1452if ( $dyndns[$a] ne 'on' ) {
1453 $dyndnsimg = 'off.gif';
1454 $dyndnsimgtxt = $Lang::tr{'wio_dyndns_off'};
1455}
1456
1457if ( $sendemailon[$a] ne 'on' ) {
1458 $mailonimg = 'wio/mailgreenoff.png';
1459 $mailonimgtxt = $Lang::tr{'wio_mail_online_off'};
1460}
1461
1462if ( $sendemailoff[$a] ne 'on' ) {
1463 $mailoffimg = 'wio/mailredoff.png';
1464 $mailoffimgtxt = $Lang::tr{'wio_mail_offline_off'};
1465}
1466
1467if ( $webinterface[$a] eq 'HTTP' ) {
1468 $webimg = 'wio/http.png';
1469}
1470elsif ( $webinterface[$a] eq 'HTTPS' ) {
1471 $webimg = 'wio/https.png';
1472}
1473else {
1474 $webimg = 'wio/none.png';
1475}
1476
1477$bgcolor = $status[$a] eq "on" ? "${Header::colourgreen}" : ($status[$a] eq "off" && $dates[$a] eq "") ? "${Header::colourblue}" : "${Header::colourred}";
1478$statustxt = $status[$a] eq "on" ? "$Lang::tr{'wio up'}" : ($status[$a] eq "off" && $dates[$a] eq "") ? "$Lang::tr{'wio_no_image'}" : "$Lang::tr{'wio down'}";
1479
1480print"<tr".($a % 2?" bgcolor='$color{'color20'}'":" bgcolor='$color{'color22'}'")." height='20'>";
1481printf ("<td align='center'> %02d</td>", $a+1);
1482
1483print"<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1484 <input type='hidden' name='ACTION' value='$Lang::tr{'enable disable client'}' />
1485 <input type='image' name='$Lang::tr{'enable disable client'}' src='/images/$gif' align='middle' alt='$gdesc' title='$gdesc' />
1486 <input type='hidden' name='ID' value='$a' /></form></td>";
1487
1488if ( $pingmethode[$a] eq 'ip') {
1489 print"<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1490 <input type='hidden' name='ACTION' value='$Lang::tr{'wio_ip_on'}' />
1491 <input type='image' name='$Lang::tr{'wio_ip_on'}' src='/images/wio/ip.png' align='middle' alt='$Lang::tr{'wio_ip_on'}' title='$Lang::tr{'wio_ip_on'}' />
1492 <input type='hidden' name='ID' value='$a' /></form></td>";
1493}
1494else {
1495 print"<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1496 <input type='hidden' name='ACTION' value='$Lang::tr{'wio_fqdn_on'}' />
1497 <input type='image' name='$Lang::tr{'wio_fqdn_on'}' src='/images/wio/fqdn.png' align='middle' alt='$Lang::tr{'wio_fqdn_on'}' title='$Lang::tr{'wio_fqdn_on'}' />
1498 <input type='hidden' name='ID' value='$a' /></form></td>";
1499}
1500
1501print"<td align='center'>$dates[$a]</td>";
1502
1503print"<td align='center'><img align='middle' src='/images/$webimg' /></td>";
1504
1505if ( $webinterface[$a] eq 'HTTP' ) {
1506 print"<td align='center'><a title=\"$Lang::tr{'wio_webinterface_link'}\" href=\"http://$ipaddresses[$a]\" target=\"_blank\">$ipaddresses[$a]</a></td>";
1507}
1508elsif ( $webinterface[$a] eq 'HTTPS' ) {
1509 print"<td align='center'><a title=\"$Lang::tr{'wio_webinterface_link'}\" href=\"https://$ipaddresses[$a]\" target=\"_blank\">$ipaddresses[$a]</a></td>";
1510}
1511else {
1512 print"<td align='center'>$ipaddresses[$a]</td>";
1513}
1514
1515my $dotip = length($ipaddresses[$a]) - rindex($ipaddresses[$a],'.');
1516 SWITCH: {
1517 foreach (@devs_color) {
1518 my $in = 0;
1519 $ic = "${_}";
1520
1521 foreach $interface (@devs_net) {
f928cc5a 1522 next if ( $netsettings{"$ic"."_DEV"} eq 'red0' && $netsettings{"RED_TYPE"} eq 'PPPOE');
0d6cc79d
SF
1523 if ( $netsettings{"$ic"."_DEV"} eq $interface ) {
1524 if ( &General::IpInSubnet($ipaddresses[$a], $netsettings{"$ic"."_NETADDRESS"}, $netsettings{"$ic"."_NETMASK"}) ) {
1525 print"<td align='center' height='20'><img src='$imgstatic/$devs_img[$in]' alt='$Lang::tr{$devs_alt[$in]}' title='$Lang::tr{$devs_alt[$in]}' /></td>";
1526 last SWITCH;
1527 }
1528 }
1529 $in++;
1530 }
1531 }
1532
0d6cc79d
SF
1533 if ( -e "$vpnpid" ) {
1534 foreach $key (keys(%vpnconfighash)) {
1535 next unless ($vpnconfighash{$key}[3] eq 'net');
c1fc92a9 1536
0d6cc79d 1537 my $convertip = &General::ipcidr2msk($vpnconfighash{$key}[11]);
a25c95b3 1538
0d6cc79d
SF
1539 my @net = split ("/", $convertip);
1540
1541 $vpnn2nip = $net[0];
1542 $vpnn2nmask = length($net[1]) - rindex($net[1],'.');
1543
1544 if (substr($ipaddresses[$a],0,length($ipaddresses[$a])-$dotip) eq substr($vpnn2nip,0,length($vpnn2nip)-$vpnn2nmask)) {
1545 print"<td align='center'><img align='middle' src='$imgstatic/vpn.png' alt='IPSec' title='IPSec' /></td>";
1546 last SWITCH;
1547 }
1548 }
1549 }
1550
1551 if ( $ovpnsettings{'DOVPN_SUBNET'} ne '' ) {
1552 @match = split ("/", $ovpnsettings{'DOVPN_SUBNET'});
1553
1554 if ( &General::IpInSubnet($ipaddresses[$a], $match[0], $match[1]) ) {
c1fc92a9
SFD
1555 print"<td align='center'><img src='$imgstatic/ovpn.png' alt='OpenVPN' title='OpenVPN' /></td>";
1556 last SWITCH;
0d6cc79d
SF
1557 }
1558 }
1559
1560 if ( %ovpnccdconfhash ne '' ) {
1561 foreach $key (keys(%ovpnccdconfhash)) {
c1fc92a9 1562
0d6cc79d 1563 my $convertip = &General::ipcidr2msk($ovpnccdconfhash{$key}[1]);
0d6cc79d
SF
1564 my @net = split ("/", $convertip);
1565
1566 $vpnn2nip = $net[0];
1567 $vpnn2nmask = length($net[1]) - rindex($net[1],'.');
1568
1569 if (substr($ipaddresses[$a],0,length($ipaddresses[$a])-$dotip) eq substr($vpnn2nip,0,length($vpnn2nip)-$vpnn2nmask)) {
1570 print"<td align='center'><img align='middle' src='$imgstatic/ovpn.png' alt='OpenVPN' title='OpenVPN' /></td>";
1571 last SWITCH;
1572 }
0d6cc79d
SF
1573 }
1574 }
a25c95b3 1575
f928cc5a 1576 if ( $netsettings{"RED_TYPE"} eq 'PPPOE' ) {
a25c95b3
SFD
1577 my $redipadr = qx'ip addr | grep red0 | grep inet | awk "{print \$2}"';
1578 my @rednet = split ("/", $redipadr);
1579 chomp ($rednet[1]);
1580 my $red_netmask = General::iporsubtodec($rednet[1]);
1581 my $red_netaddress = Network::get_netaddress("$rednet[0]/$red_netmask");
c1fc92a9 1582
a25c95b3
SFD
1583 if ( &General::IpInSubnet($ipaddresses[$a], $red_netaddress, $red_netmask) ) {
1584 print"<td align='center' height='20'><img src='$imgstatic/red.png' alt='$Lang::tr{'wio_red_lan'}' title='$Lang::tr{'wio_red_lan'}' /></td>";
1585 last SWITCH;
1586 }
f928cc5a
SF
1587 }
1588 else {
a25c95b3
SFD
1589 print"<td align='center'><img align='middle' src='$imgstatic/white.png' alt='$Lang::tr{'wio_unknown_lan'}' title='$Lang::tr{'wio_unknown_lan'}' /></td>";
1590 last SWITCH;
a25c95b3 1591 }
0d6cc79d
SF
1592 }
1593
1594if ( $webinterface[$a] eq 'HTTP' ) {
1595 print"<td align='center'><a title=\"$Lang::tr{'wio_webinterface_link'}\" href=\"http://$names[$a]\" target=\"_blank\">$names[$a]</a></td>";
1596}
1597elsif ( $webinterface[$a] eq 'HTTPS' ) {
1598 print"<td align='center'><a title=\"$Lang::tr{'wio_webinterface_link'}\" href=\"https://$names[$a]\" target=\"_blank\">$names[$a]</a></td>";
1599}
1600else {
1601 print"<td align='center'>$names[$a]</td>";
1602}
1603
1604print"
1605 <td>
1606 <table bgcolor='$bgcolor' cellpadding='2' cellspacing='0' width='100%'>
1607 <tr height='20'>
1608 <td align='center'><font color='$color{'color21'}'><b>$statustxt</b></font></td>
1609 </tr>
1610 </table>
1611 </td>
1612
1613 <td width='3%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1614 <input type='hidden' name='ACTION' value='$Lang::tr{'wio_sc_refresh'}' />
1615 <input type='image' name='$Lang::tr{'wio_sc_refresh'}' src='$imgstatic/refresh.png' align='middle' alt='$Lang::tr{'wio_sc_refresh'}' title='$Lang::tr{'wio_sc_refresh'}' />
1616 <input type='hidden' name='ID' value='$a' /></form></td>
1617
1618 <td width='3%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1619 <input type='hidden' name='ACTION' value='$Lang::tr{'enable disable dyndns'}' />
1620 <input type='image' name='$Lang::tr{'enable disable dyndns'}' src='/images/$dyndnsimg' align='middle' alt='$dyndnsimgtxt' title='$dyndnsimgtxt' />
1621 <input type='hidden' name='ID' value='$a' /></form></td>";
1622
1623if ( defined($dyndns[$a]) && ($dyndns[$a] eq 'on') ) {
1624 print"<td width='3%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1625 <input type='hidden' name='ACTION' value='$Lang::tr{'wio_dyndns_refresh'}' />
1626 <input type='image' name='$Lang::tr{'wio_dyndns_refresh'}' src='/images/reload.gif' align='middle' alt='$Lang::tr{'wio_dyndns_refresh'}' title='$Lang::tr{'wio_dyndns_refresh'}' />
1627 <input type='hidden' name='ID' value='$a' /></form></td>";
1628}
1629else {
1630 print"<td width='3%' align='center'>-</td>";
1631}
1632
1633if ( -e "/var/log/rrd/wio/$id[$a].rrd" ) {
1634 print"
1635 <td width='3%' align='center'><form method='post' action='/cgi-bin/wiographs.cgi' enctype='multipart/form-data'>
1636 <input type='image' name='$Lang::tr{'wio_graphs'}' src='$imgstatic/graph.png' align='middle' alt='$Lang::tr{'wio_graphs'}' title='$Lang::tr{'wio_graphs'}' />
1637 <input type='hidden' name='HOSTID' value='$id[$a]' /><input type='hidden' name='HOSTNAME' value='$names[$a]' /></form></td>
1638 ";
1639}
1640else {
1641 print "<td width='3%' align='center'><img src='$imgstatic/no_graph.png' align='middle' alt='$Lang::tr{'wio_no_graphs'}' title='$Lang::tr{'wio_no_graphs'}' /></td>";
1642}
1643
1644if ( $wiosettings{'SENDEMAIL'} eq 'on') {
1645 print"<td width='3%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1646 <input type='hidden' name='ACTION' value='$Lang::tr{'wio_mail_online'}' />
1647 <input type='image' name='$Lang::tr{'wio_mail_online'}' src='/images/$mailonimg' align='middle' alt='$mailonimgtxt' title='$mailonimgtxt' />
1648 <input type='hidden' name='ID' value='$a' /></form></td>
1649 <td width='3%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1650 <input type='hidden' name='ACTION' value='$Lang::tr{'wio_mail_offline'}' />
1651 <input type='image' name='$Lang::tr{'wio_mail_offline'}' src='/images/$mailoffimg' align='middle' alt='$mailoffimgtxt' title='$mailoffimgtxt' />
1652 <input type='hidden' name='ID' value='$a' /></form></td>";
1653}
1654else {
1655 print"<td width='3%' align='center'>-</td>
1656 <td width='3%' align='center'>-</td>";
1657}
1658
1659print"
1660 <td width='3%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1661 <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
1662 <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
1663 <input type='hidden' name='ID' value='$a' /></form></td>
1664
1665 <td width='3%' align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1666 <input type='hidden' name='ACTION' value='$Lang::tr{'wio_remove_client'}' />
1667 <input type='image' name='$Lang::tr{'wio_remove_client'}' src='/images/delete.gif' align='middle' alt='$Lang::tr{'wio_remove_client'}' title='$Lang::tr{'wio_remove_client'}' onClick=\"return confirm('$Lang::tr{'wio_remove_client_hint'}')\" />
1668 <input type='hidden' name='ID' value='$a' /></form></td></tr>
1669";
1670
1671if ($remark[$a] && $wiosettings{'CLIENTREMARK'} eq 'on') {
1672 print"<tr".($a % 2?" bgcolor='$color{'color20'}'":" bgcolor='$color{'color22'}'")." height='20'><td>&nbsp;</td><td colspan='16' align='left'>$remark[$a]</td></tr>";
1673}
1674 print"<tr height='1'><td colspan='17' bgcolor='#696565'></td></tr>";
1675}
1676
1677print"</table>";
1678
1679&Header::closebox();
1680
1681}
1682
1683## add / modify client
1684
1685$checked{'EN'}{'on'} = ($wiosettings{'EN'} eq '' ) ? '' : "checked='checked'";
1686
1687$checked{'DYNDNS'}{'off'} = $checked{'DYNDNS'}{'on'} = '';
1688$checked{'DYNDNS'}{$wiosettings{'DYNDNS'}} = "checked='checked'";
1689
1690$checked{'SENDEMAILON'}{'off'} = $checked{'SENDEMAILON'}{'on'} = '';
1691$checked{'SENDEMAILON'}{$wiosettings{'SENDEMAILON'}} = "checked='checked'";
1692
1693$checked{'SENDEMAILOFF'}{'off'} = $checked{'SENDEMAILOFF'}{'on'} = '';
1694$checked{'SENDEMAILOFF'}{$wiosettings{'SENDEMAILOFF'}} = "checked='checked'";
1695
1696if (! defined($errormessage) && $wiosettings{'ACTION'} ne $Lang::tr{'edit'} ) {
1697 $wiosettings{'PINGMETHODE'} = 'ip';
1698}
1699
1700$checked{'PINGMETHODE'}{'ip'} = $checked{'PINGMETHODE'}{'fqdn'} = '';
1701$checked{'PINGMETHODE'}{$wiosettings{'PINGMETHODE'}} = "checked='checked'";
1702
1703$selected{'WEBINTERFACE'}{'----'} = '';
1704$selected{'WEBINTERFACE'}{'HTTP'} = '';
1705$selected{'WEBINTERFACE'}{'HTTPS'} = '';
1706$selected{'WEBINTERFACE'}{$wiosettings{'WEBINTERFACE'}} = "selected='selected'";
1707
1708$buttontext = $Lang::tr{'wio_client_add'};
1709
1710if ( $wiosettings{'ACTION'} eq $Lang::tr{'edit'} || defined($errormessage) && ! defined($message) ) {
1711 &Header::openbox('100%', 'left', $Lang::tr{'wio_edit_client'});
1712 $buttontext = $Lang::tr{'update'};
1713}
1714else {
1715 &Header::openbox('100%', 'left', $Lang::tr{'wio_edit_settings'});
1716}
1717
1718if (! defined($errormessage) && $wiosettings{'ACTION'} ne $Lang::tr{'edit'} ) {
1719print"
1720<table width='100%' border='0' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1721<tr>
a25c95b3
SFD
1722 <td width='33%' bgcolor='$color{'color20'}' align='left' height='25'><b>&nbsp;$Lang::tr{'wio_add'}</b></td>
1723 <td width='67%' align='right'>&nbsp;</td>
0d6cc79d
SF
1724</tr>
1725<tr>
1726 <td>&nbsp;</td>
1727</tr>
1728</table>
1729";
1730}
1731
1732print"
1733<form method='post' action='$ENV{'SCRIPT_NAME'}'>
1734<input type='hidden' name='ID' value='$wiosettings{'ID'}' />
1735<input type='hidden' name='CLIENTID' value='$wiosettings{'CLIENTID'}' />
1736<input type='hidden' name='ONLINE' value='$wiosettings{'ONLINE'}' />
1737<input type='hidden' name='TIMESTAMP' value='$wiosettings{'TIMESTAMP'}' />
1738";
1739
1740print"
1741<table width='100%' border='0' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1742<tr>
1743 <td height='30'>$Lang::tr{'wio_client_enable'}</td>
1744 <td align='left'><input type='checkbox' name='EN' $checked{'EN'}{'on'} /></td>
1745 <td colspan='4'>&nbsp;</td>
1746</tr>
1747<tr>
1748 <td height='30'>$Lang::tr{'wio ipadress'}:</td>
1749 <td align='left'><input type='text' name='IPADR' value='$wiosettings{'IPADR'}' size='25' /></td>
1750 <td>$Lang::tr{'wio name'}:</td>
1751 <td align='left'><input type='text' name='HOST' value='$wiosettings{'HOST'}' size='25' /></td>
1752 <td>$Lang::tr{'remark'}:</td>
1753 <td align='left'><input type='text' name='REMARK' value='$wiosettings{'REMARK'}' size='30'></td>
1754</tr>
1755<tr>
1756 <td height='30'>$Lang::tr{'wio_ping_send'}:</td>
1757 <td align='left'><input type='radio' name='PINGMETHODE' value='ip' $checked{'PINGMETHODE'}{'ip'} />&nbsp;IP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='radio' name='PINGMETHODE' value='fqdn' $checked{'PINGMETHODE'}{'fqdn'} />&nbsp;FQDN</td>
1758 <td>$Lang::tr{'wio_dyndns'}:</td>
1759 <td align='left'><input type='checkbox' name='DYNDNS' $checked{'DYNDNS'}{'on'} /></td>
1760";
1761
1762if ( $wiosettings{'SENDEMAIL'} eq 'on' ) {
1763 print"<td>$Lang::tr{'wio_sendemail'}:</td>
1764 <td><input type='checkbox' name='SENDEMAILON' $checked{'SENDEMAILON'}{'on'} />&nbsp;$Lang::tr{'wio_online'}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='checkbox' name='SENDEMAILOFF' $checked{'SENDEMAILOFF'}{'on'} />&nbsp;$Lang::tr{'wio_offline'}</td>";
1765}
1766else {
1767 print"<td colspan='2'>&nbsp;</td>";
1768}
1769
1770print"
1771</tr>
1772<tr>
1bee37ba 1773 <td height='30'>$Lang::tr{'wio_link_open'}:</td>
0d6cc79d
SF
1774 <td align='left' colspan='5'>
1775 <select size='1' name='WEBINTERFACE' width='80' style='width: 80px'>
1776 <option value='----' $selected{'WEBINTERFACE'}{'----'}>----</option>
1777 <option value='HTTP' $selected{'WEBINTERFACE'}{'HTTP'}>HTTP</option>
1778 <option value='HTTPS' $selected{'WEBINTERFACE'}{'HTTPS'}>HTTPS</option>
1779 </select>
1780 </td>
1781</tr>
1782</table>
1783<table width='100%' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1784<tr>
1785 <td width='20%' align='center'>&nbsp;</td>
1786";
1787
1788if ( $buttontext eq $Lang::tr{'update'} && ( defined($errormessage) || $wiosettings{'ACTION'} eq $Lang::tr{'edit'}) && ! defined($message) ) {
1789 print"<td width='20%' align='center'>&nbsp;</td>
1790 <td width='20%' align='center'>&nbsp;</td>
1791 <td width='20%' align='center'><input type='hidden' name='ACTION' value='$Lang::tr{'wio_client_add'}' /><input type='submit' name='SUBMIT' value='$buttontext' /></td>
1792 <td width='20%' align='center'><input type='button' onClick='location.href=\"/cgi-bin/wio.cgi\"' value='$Lang::tr{'wio_back'}'></form></td>";
1793}
1794else {
1795 print"<td width='20%' align='center'>&nbsp;</td>
1796 <td width='20%' align='center'>&nbsp;</td>
1797 <td width='20%' align='center'>&nbsp;</td>
1798 <td width='20%' align='right'><input type='hidden' name='ACTION' value='$Lang::tr{'wio_client_add'}' /><input type='submit' name='SUBMIT' value='$buttontext' /></form></td>";
1799}
1800
1801print"
1802</tr>
1803</table>
1804";
1805
1806if ( $wiosettings{'ENABLE'} eq 'on' && !$errormessage && $wiosettings{'ACTION'} ne $Lang::tr{'edit'} || $message == 2 ) {
1807
1808&hrline();
1809
1810## arp table entries
1811
1812print"
1813<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1814<tr>
a25c95b3
SFD
1815 <td width='33%' bgcolor='$color{'color20'}' align='left' height='25'><b>&nbsp;$Lang::tr{'wio_arp_table_entries'}</b></td>
1816 <td width='67%' align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='WIOGUISHOWARPTABLE' value='arptable' /><input type='submit' name='ACTION' value='$arpbuttontext' /></form></td>
0d6cc79d 1817</tr>
0d6cc79d 1818</table>
a25c95b3
SFD
1819";
1820
1821if ( $wiosettings{'WIOGUISHOWARPTABLE'} eq 'on' ) {
0d6cc79d 1822
a25c95b3 1823print"
0d6cc79d 1824<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
a25c95b3 1825<tr><td colspan='2'>&nbsp;</td></tr>
0d6cc79d
SF
1826<tr bgcolor='$color{'color20'}'>
1827 <td width='5%' align='center' height='20'><b>$Lang::tr{'wio_id'}</b></td>
1828 <td width='20%' align='center' height='20'><b>$Lang::tr{'wio_hwaddress'}</b></td>
1829 <td width='20%' align='center' height='20'><b>$Lang::tr{'wio ipadress'}</b></td>
1830 <td width='15%' align='center' height='20'><b>$Lang::tr{'wio network'}</b></td>
1831 <td width='20%' align='center' height='20'><b>$Lang::tr{'wio name'}</b></td>
1832 <td width='15%' align='center' height='20'><b>$Lang::tr{'wio_iface'}</b></td>
1833 <td width='5%' align='center' height='20'><b>$Lang::tr{'action'}</b></td>
1834</tr>
1835";
1836
1837$output = `/sbin/ip neigh list`;
1838$output = &Header::cleanhtml($output,"y");
1839
1840my $arpcnt = 0;
1841
1842foreach $line (split(/\n/, $output))
1843{
1844 if ($line =~ m/^(.*) dev ([^ ]+) lladdr ([0-9a-f:]*) (.*)$/) {
1845 my $arphost = gethostbyaddr(inet_aton($1), AF_INET);
1846 if ( $arphost eq 'localhost' ) { $arphost = ''; }
1847 push (@arpcache, "$3,$1,$arphost,$2\n");
1848 }
1849 elsif ($line =~ m/^(.*) dev ([^ ]+) (.*)$/) {
1850 my $arphost = gethostbyaddr(inet_aton($1), AF_INET);
1851 if ( $arphost eq 'localhost' ) { $arphost = ''; }
1852 push (@arpcache, ",$1,$arphost,$2\n");
1853 }
1854
1855 $arpcnt++;
1856}
1857
1858&SortDataFile('arpcache',@arpcache);
1859
1860foreach (@arpcache) {
1861 chomp;
1862
1863 @line = split (/\,/, $_);
1864
1865 print"<tr".($idarp % 2?" bgcolor='$color{'color20'}'":" bgcolor='$color{'color22'}'")." height='20'>";
1866 printf ("<td align='center'> %02d</td>", $idarp+1);
1867 print"<td align='center'>$line[0]</td>
1868 <td align='center'>$line[1]</td>";
1869
1870SWITCH: {
1871
1872 foreach (@devs_color) {
1873 my $in = 0;
1874 $ic = "${_}";
1875
1876 foreach $interface (@devs_net) {
1877 next if ( $netsettings{"$ic"."_DEV"} eq 'red0' && ($netsettings{"RED_TYPE"} eq 'DHCP' || $netsettings{"RED_TYPE"} eq 'PPPOE'));
1878
1879 if ($netsettings{"$ic"."_DEV"} eq $interface) {
1880 if ( &General::IpInSubnet($line[1], $netsettings{"$ic"."_NETADDRESS"}, $netsettings{"$ic"."_NETMASK"}) ) {
1881 print"<td align='center'><img src='$imgstatic/$devs_img[$in]' alt='$Lang::tr{$devs_alt[$in]}' title='$Lang::tr{$devs_alt[$in]}' /></td>";
1882 last SWITCH;
1883 }
1884 }
1885
1886 $in++;
1887 }
1888 }
1889
f928cc5a 1890 if ($netsettings{"RED_TYPE"} eq 'DHCP' || $netsettings{"RED_TYPE"} eq 'PPPOE' || $netsettings{"RED_TYPE"} eq 'STATIC') {
0d6cc79d
SF
1891 my $redipadr = qx'ip addr | grep red0 | grep inet | awk "{print \$2}"';
1892 my @rednet = split ("/", $redipadr);
1893 chomp ($rednet[1]);
1894 my $red_netmask = General::iporsubtodec($rednet[1]);
1895 my $red_netaddress = Network::get_netaddress("$rednet[0]/$red_netmask");
1896
1897 if ( &General::IpInSubnet($line[1], $red_netaddress, $red_netmask) ) {
1898 print"<td align='center' height='20'><img src='$imgstatic/red.png' alt='$Lang::tr{'wio_red_lan'}' title='$Lang::tr{'wio_red_lan'}' /></td>";
1899 last SWITCH;
1900 }
1901 else {
1902 print"<td align='center'><img align='middle' src='$imgstatic/white.png' alt='$Lang::tr{'wio_unknown_lan'}' title='$Lang::tr{'wio_unknown_lan'}' /></td>";
1903 last SWITCH;
1904 }
1905 }
1906}
1907
1908 print"<td align='center'>$line[2]</td>
1909 <td align='center'>".&WIO::color_devices($line[3])."</td>";
1910
1911 unless (&WIO::checkinto($line[1], '', @current)) {
1912 print"<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>
1913 <input type='hidden' name='ACTION' value='$Lang::tr{'wio_add'}' />
1914 <input type='image' name='$Lang::tr{'wio_add'}' src='/images/add.gif' align='middle' alt='$Lang::tr{'wio_add'}' title='$Lang::tr{'wio_add'}' />
1915 <input type='hidden' name='ID' value='$idarp' /></form></td>";
1916 }
1917 else {
1918 print"<td align='center'><img src='$imgstatic/add.png' align='middle' alt='$Lang::tr{'wio_no_add'}' title='$Lang::tr{'wio_no_add'}' /></td>";
1919 }
1920
1921print"</tr>";
1922print"<tr height='1'><td colspan='17' bgcolor='#696565'></td></tr>";
1923$idarp++
1924}
1925
1926print"
1927</table>
1928";
a25c95b3 1929}
0d6cc79d
SF
1930
1931&hrline();
1932
1933print"
1934<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1935<tr>
a25c95b3
SFD
1936 <td width='33%' bgcolor='$color{'color20'}' align='left' height='25'><b>&nbsp;$Lang::tr{'wio_import_file'}</b></td>
1937 <td width='67%' align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='WIOGUISHOWCLIENTIMPORTTABLE' value='clientimport' /><input type='submit' name='ACTION' value='$clientimportbuttontext' /></form></td>
0d6cc79d 1938</tr>
0d6cc79d 1939</table>
a25c95b3
SFD
1940";
1941
1942if ( $wiosettings{'WIOGUISHOWCLIENTIMPORTTABLE'} eq 'on' ) {
1943
1944print"
0d6cc79d 1945<table width='100%' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
a25c95b3 1946<tr><td colspan='3'>&nbsp;</td></tr>
0d6cc79d
SF
1947<tr bgcolor='$color{'color22'}'>
1948 <form method='post' action='/cgi-bin/wio.cgi' enctype='multipart/form-data'>
1949 <td width='35%' align='right'>$Lang::tr{'wio_import_csv'}&nbsp;</td>
1950 <td width='40%' align='center'><input type='file' name='CSVFILE' size='30' /></td>
1951 <td width='25%' align='right'><input type='hidden' name='ACTION' value='$Lang::tr{'wio_import'}1' /><input type='submit' name='SUBMIT' value='$Lang::tr{'wio_import'}' /></td>
1952 </form>
1953</tr>
1954<tr><td colspan='3'>&nbsp;</td></tr>
1955<tr bgcolor='$color{'color22'}'>
1956 <form method='post' action='/cgi-bin/wio.cgi' enctype='multipart/form-data'>
1957 <td width='35%' align='right'>$Lang::tr{'wio_import_hosts'}&nbsp;</td>
1958 <td width='40%' align='center'>&nbsp;</td>
1959 <td width='25%' align='right'><input type='hidden' name='ACTION' value='$Lang::tr{'wio_import'}2' /><input type='submit' name='SUBMIT' value='$Lang::tr{'wio_import'}' /></td>
1960 </form>
1961</tr>
1962<tr><td colspan='3'>&nbsp;</td></tr>
1963<tr bgcolor='$color{'color22'}'>
1964 <form method='post' action='/cgi-bin/wio.cgi' enctype='multipart/form-data'>
1965 <td width='35%' align='right'>$Lang::tr{'wio_import_fixleases'}&nbsp;</td>
1966 <td width='40%' align='center'>&nbsp;</td>
1967 <td width='25%' align='right'><input type='hidden' name='ACTION' value='$Lang::tr{'wio_import'}3' /><input type='submit' name='SUBMIT' value='$Lang::tr{'wio_import'}' /></td>
1968 </form>
1969</tr>
1970</table>
1971";
a25c95b3 1972}
0d6cc79d
SF
1973
1974&hrline;
1975
1976print"
1977<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1978<tr>
a25c95b3
SFD
1979 <td width='33%' bgcolor='$color{'color20'}' align='left' height='25'><b>&nbsp;$Lang::tr{'wio_net_scan'}</b></td>
1980 <td width='67%' align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='WIOGUISHOWNETWORKSEARCHTABLE' value='networksearch' /><input type='submit' name='ACTION' value='$networksearchbuttontext' /></form></td>
0d6cc79d
SF
1981</tr>
1982</table>
a25c95b3
SFD
1983";
1984
1985if ( $wiosettings{'WIOGUISHOWNETWORKSEARCHTABLE'} eq 'on' ) {
1986
1987print"
0d6cc79d
SF
1988<table width='100%' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
1989<tr>
1990 <td colspan='3'>&nbsp;</td>
1991</tr>
1992";
1993
1994foreach (keys(%ifacecolor)) {
1995 if ( $_ eq 'GREEN' ) { $color = "$Header::colourgreen"; $net = $Lang::tr{'wio_net_scan_green'}; }
1996 elsif ( $_ eq 'BLUE' ) { $color = "$Header::colourblue"; $net = $Lang::tr{'wio_net_scan_blue'}; }
1997 else { $color = "$Header::colourorange"; $net = $Lang::tr{'wio_net_scan_orange'}; }
1998
1999 if ( $netsettings{"${_}_DEV"} eq 'disabled' || $netsettings{"${_}_DEV"} eq '' || $netsettings{"${_}_ADDRESS"} eq '' ) { next; }
2000 else {
2001 print <<END;
2002
2003 <tr bgcolor='$color{'color22'}'>
2004 <td width='35%' align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>$Lang::tr{'wio_net_scan_vl'} <font color='$color'><b>$net</b></font> $Lang::tr{'wio_net_scan_l'}<font color='$color'><b> $netsettings{"${_}_DEV"} </b></font>$Lang::tr{'wio_net_scan_r'}</td>
2005 <td width='40%' align='center'><input type='text' name='${_}_IPLOW' value='$wiosettings{"${_}_IPLOW"}' size='14' STYLE='background-color:$color; text-align: center; color:white' /> - <input type='text' name='${_}_IPHIGH' value='$wiosettings{"${_}_IPHIGH"}' size='14' STYLE='background-color:$color; text-align: center; color:white' /></td>
2006 <td width='25%' align='right'><input type='hidden' name='ACTION' value='$ifacecolor{$_}' /><input type='hidden' name='ID' value='$netsettings{"${_}_DEV"}' /><input type='submit' name='SUBMIT' value='$Lang::tr{'wio_net_scan_run'}'></form></td>
2007 </tr>
2008 <tr>
2009 <td colspan='3'>&nbsp;</td>
2010 </tr>
2011END
2012 }
2013}
2014
2015print"
2016</tr>
2017</table>
2018</form>
2019";
a25c95b3 2020}
0d6cc79d
SF
2021&Header::closebox();
2022}
2023
2024if ( $wiosettings{'ENABLE'} eq 'on' && !$errormessage && $wiosettings{'ACTION'} ne $Lang::tr{'edit'} || $message == 2 ) {
2025
2026&Header::openbox('100%', 'left', $Lang::tr{'wio_service'});
2027
2028print"
2029<table border='0' width='100%' bordercolor='$Header::bordercolour' cellspacing='0' cellpadding='0' style='border-collapse: collapse'>
2030<tr bgcolor='$color{'color22'}'>
f539ff6d 2031 <td colspan='2' align='right'></td>
fe6f676b
SF
2032";
2033
2034if ( $wiosettings{'LOGGING'} eq 'on' ) {
2035 print"<td width='10%' align='right'><form method='post' action='/cgi-bin/logs.cgi/log.dat' enctype='multipart/form-data'><input type='hidden' name='SECTION' value='wio' /><input type='submit' name='SUBMIT' value='$Lang::tr{'system logs'}' /></form></td>";
2036}
2037
2038print"
f539ff6d 2039 <td width='10%' align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'><input type='hidden' name='ACTION' value='$Lang::tr{'edit'}1' /><input type='submit' name='SUBMIT' value='$Lang::tr{'wio_edit_set'}' /></form></td>
0d6cc79d
SF
2040</tr>
2041</table>
2042";
2043}
2044
2045&Header::closebox();
2046}
2047
2048&Header::closebigbox();
2049&Header::closepage();
2050
2051############################################################################################################################
2052
2053sub SortDataFile {
2054my ($data,@checkfile) = @_;
2055 my $idsort = 0;
2056 our %entries = ();
2057
2058 sub sortips {
2059 my $qs = '';
2060
2061 if (rindex ($wiosettings{'SORT'},'Rev') != -1) {
2062 $qs = substr ($wiosettings{'SORT'},0,length($wiosettings{'SORT'})-3);
2063
2064 if ($qs eq 'IPADR') {
2065 my @a = split (/\./,$entries{$a}->{$qs});
2066 my @b = split (/\./,$entries{$b}->{$qs});
2067 ($b[0]<=>$a[0]) ||
2068 ($b[1]<=>$a[1]) ||
2069 ($b[2]<=>$a[2]) ||
2070 ($b[3]<=>$a[3]);
2071 }
2072 else {
2073 $entries{$b}->{$qs} cmp $entries{$a}->{$qs};
2074 }
2075 }
2076 else {
2077 $qs = $wiosettings{'SORT'};
2078
2079 if ($qs eq 'IPADR') {
2080 my @a = split (/\./,$entries{$a}->{$qs});
2081 my @b = split (/\./,$entries{$b}->{$qs});
2082 ($a[0]<=>$b[0]) ||
2083 ($a[1]<=>$b[1]) ||
2084 ($a[2]<=>$b[2]) ||
2085 ($a[3]<=>$b[3]);
2086 }
2087 else {
2088 $entries{$a}->{$qs} cmp $entries{$b}->{$qs};
2089 }
2090 }
2091 }
2092
2093 if ($data eq 'arpcache') {
2094 foreach (@checkfile) {
2095 chomp;
2096 @temp = split (',', $_);
2097
2098 my @record = ('KEY',$idsort++,'MAC',$temp[0],'IPADR',$temp[1],'HOST',$temp[2],'REMARK',$temp[3],'IFACE',$temp[4]);
2099 my $record = ();
2100 %{$record} = @record;
2101 $entries{$record->{KEY}} = $record;
2102 }
2103
2104 open(FILE, "> $logdir/.arpcache");
2105
2106 foreach (sort sortips keys %entries) {
2107 print FILE "$entries{$_}->{MAC},$entries{$_}->{IPADR},$entries{$_}->{HOST},$entries{$_}->{REMARK},$entries{$_}->{IFACE},$entries{$_}->{HW}\n";
2108 }
2109
2110 close(FILE);
2111
2112 open (FILE, "$logdir/.arpcache");
2113 @arpcache = <FILE>;
2114 close (FILE);
2115 }
2116 else {
2117 foreach (@checkfile) {
2118 chomp;
2119 @temp = split (',', $_);
2120
2121 my @record = ('KEY',$idsort++,'CLIENTID',$temp[0],'TIMESTAMP',$temp[1],'IPADR',$temp[2],'HOST',$temp[3],'EN',$temp[4],'REMARK',$temp[5],'DYNDNS',$temp[6],'SENDEMAILON',$temp[7],'SENDEMAILOFF',$temp[8],'PINGMETHODE',$temp[9],'ONLINE',$temp[10],'WEBINTERFACE',$temp[11]);
2122 my $record = ();
2123 %{$record} = @record;
2124 $entries{$record->{KEY}} = $record;
2125 }
2126
2127 open(FILE, "> $ipadrfile");
2128
2129 foreach (sort sortips keys %entries) {
2130 print FILE "$entries{$_}->{CLIENTID},$entries{$_}->{TIMESTAMP},$entries{$_}->{IPADR},$entries{$_}->{HOST},$entries{$_}->{EN},$entries{$_}->{REMARK},$entries{$_}->{DYNDNS},$entries{$_}->{SENDEMAILON},$entries{$_}->{SENDEMAILOFF},$entries{$_}->{PINGMETHODE},$entries{$_}->{ONLINE},$entries{$_}->{WEBINTERFACE}\n";
2131 }
2132
2133 close(FILE);
2134
2135 &loadips();
2136 }
2137}
2138
2139############################################################################################################################
2140
2141sub hrline {
2142
2143print"<table width='100%'><tr><td colspan='2' height='35'><hr></td></tr></table>";
2144
2145}
2146
2147############################################################################################################################
2148
2149sub back {
2150
2151print"<table width='100%'><tr><td width='10%'><a href='/cgi-bin/wio.cgi'><img src='/images/wio/back.png' alt='$Lang::tr{'wio_back'}' title='$Lang::tr{'wio_back'}' /></a></td><td>&nbsp;</td></tr></table>";
2152
2153}
2154
2155############################################################################################################################
2156
2157sub loadips {
2158
2159&General::readhasharray($ipadrfile, \%ipshash);
2160
2161open(FILE, "< $ipadrfile");
2162@current = <FILE>;
2163close (FILE);
2164
2165}
2166
2167############################################################################################################################
2168
2169sub writeips {
2170
2171open(FILE, "> $ipadrfile");
2172if ( defined($write) ) { print FILE @write; }
2173else { print FILE @current; }
2174close(FILE);
2175
2176}
2177
2178############################################################################################################################
2179
c1fc92a9
SFD
2180sub SortByTunnelName {
2181
2182 if ($vpnconfighash{$a}[1] lt $vpnconfighash{$b}[1]) {
2183 return -1;
2184 }
2185 elsif ($vpnconfighash{$a}[1] gt $vpnconfighash{$b}[1]) {
2186 return 1;
2187 }
2188 else {
2189 return 0;
2190 }
2191
0d6cc79d
SF
2192}
2193
2194############################################################################################################################
2195
c1fc92a9
SFD
2196sub validSave {
2197
0d6cc79d
SF
2198 if ( $wiosettings{'IPADR'} eq '' && $wiosettings{'PINGMETHODE'} eq 'ip' && $wiosettings{'DYNDNS'} eq '' ) {
2199 $errormessage = $Lang::tr{'wio_ip_empty'};
2200 }
2201
2202 if ( $wiosettings{'IPADR'} ne '' && (! &General::validip($wiosettings{'IPADR'})) ) {
2203 $errormessage = $Lang::tr{'wio_ip_error'};
2204 }
2205
2206 if ( $wiosettings{'HOST'} eq '' && $wiosettings{'PINGMETHODE'} eq 'fqdn' ) {
2207 $errormessage = $Lang::tr{'wio_host_empty'};
2208 }
2209
2210 if ( $wiosettings{'HOST'} ne '' && (! &General::validdomainname($wiosettings{'HOST'})) ) {
2211 $errormessage = $Lang::tr{'wio_host_error'};
2212 }
2213
2214 if ( $wiosettings{'DYNDNS'} eq 'on' && (! defined($errormessage)) ) {
2215 unless(&General::validfqdn($wiosettings{'HOST'})) { $errormessage = $Lang::tr{'wio_fqdn_error'}; }
2216 ( $wiosettings{'IPADR'}, $infomessage ) = &WIO::getdyndnsip($wiosettings{'IPADR'}, $wiosettings{'HOST'});
2217 $wiosettings{'PINGMETHODE'} = 'fqdn';
2218 }
2219
2220 if ( $wiosettings{'ID'} eq '' && ! defined($errormessage) ) { $errormessage = &WIO::checkinto($wiosettings{'IPADR'}, $wiosettings{'HOST'}, @current); }
2221
2222 if ( $wiosettings{'REMARK'} ne '' ) { $wiosettings{'REMARK'} =~ s/,/&#44;/g; }
c1fc92a9 2223
0d6cc79d 2224}