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