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