]>
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 | # | |
fe6f676b | 24 | # id: wio.cgi, v1.3.2 2017/08/27 14:11:16 sfeddersen |
0d6cc79d SF |
25 | # |
26 | # This wio.cgi is based on the Code from the IPCop WIO Addon | |
27 | # and is extremly adapted to work with IPFire. | |
28 | # | |
29 | # Autor: Stephan Feddersen | |
30 | # Co-Autor: Alexander Marx | |
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'; | |
1bee37ba | 50 | require '/var/ipfire/network-functions.pl'; |
0d6cc79d SF |
51 | require '/var/ipfire/lang.pl'; |
52 | require '/var/ipfire/header.pl'; | |
53 | require '/usr/lib/wio/wio-lib.pl'; | |
54 | require '/usr/lib/wio/wio-graphs.pl'; | |
55 | ||
56 | my $logdir = "/var/log/wio"; | |
57 | ||
58 | my ( %mainsettings, %mailsettings, %wiosettings, %cgiparams, %netsettings, %ipshash, | |
59 | %vpnconfighash, %ovpnconfighash, %ovpnccdconfhash, %ovpnsettings, %checked, %selected, %color ) = (); | |
60 | ||
61 | &General::readhash('/var/ipfire/main/settings', \%mainsettings); | |
62 | &General::readhash('/var/ipfire/ethernet/settings', \%netsettings); | |
63 | &General::readhash('/var/ipfire/dma/mail.conf', \%mailsettings); | |
64 | &General::readhash('/var/ipfire/wio/wio.conf', \%wiosettings); | |
65 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
66 | &General::readhasharray('/var/ipfire/ovpn/ovpnconfig', \%ovpnconfighash); | |
67 | &General::readhash('/var/ipfire/ovpn/settings', \%ovpnsettings); | |
68 | &General::readhasharray('/var/ipfire/ovpn/ccd.conf', \%ovpnccdconfhash); | |
69 | &General::readhasharray('/var/ipfire/vpn/config', \%vpnconfighash); | |
70 | ||
71 | my $ipadrfile = "$logdir/wioips"; | |
72 | my $onoffip = "$logdir/wioscip"; | |
73 | my $wiosettings = "/var/ipfire/wio/wio.conf"; | |
74 | my $dyndnsconfig = "/var/ipfire/ddns/config"; | |
75 | my $importfile = "$logdir/importfile"; | |
76 | my $wiofile = "$logdir/wiofile"; | |
77 | my $editfile = "$logdir/editfile"; | |
78 | my $hostfile = "/var/ipfire/main/hosts"; | |
79 | my $dhcpfile = "/var/ipfire/dhcp/fixleases"; | |
80 | my $imgstatic = "/images/wio"; | |
81 | my $rrddir = "/var/log/rrd/wio"; | |
82 | my $refreshbox = '<meta http-equiv="refresh" content="0;url=/cgi-bin/wio.cgi">'; | |
83 | my $sortstring = '^IPADR|^HOST'; | |
84 | my $ovpnaddon = "/var/ipfire/ovpn"; | |
85 | my $ovpnpid = "/var/run/openvpn.pid"; | |
86 | my $vpnpid = "/var/run/charon.pid"; | |
87 | my $redactive = "/var/ipfire/red/active"; | |
88 | my $redip = '-'; | |
89 | my $now = strftime "%Y-%m-%d", localtime; | |
90 | ||
91 | if ( -e $redactive ) { | |
92 | open(IPADDR, "/var/ipfire/red/local-ipaddress"); | |
93 | $redip = <IPADDR>; | |
94 | close IPADDR; | |
95 | chomp($redip); | |
96 | } | |
97 | ||
98 | my $i = 0; | |
99 | my $idarp = 0; | |
100 | my $iddyndns = 0; | |
101 | my $idvpn = 0; | |
102 | my $idovpn = 0; | |
103 | my $idsort = 0; | |
104 | my $nr = 0; | |
105 | my $count = 0; | |
106 | my $showcount = 0; | |
107 | ||
108 | my ( $infomessage, $errormessage, $importmessage, $message ) = ''; | |
109 | ||
110 | my ( $buttontext, $host, $timestamp, $ipadr, $on, $remark, $dyndns, $dyndnsip, $sendemailon, $net, $dev, $iprange, $output, $write, $webinterface, | |
111 | $sendemailoff, $pingmethode, $online, $color, $bgcolor, $exitcode, $id, $line, $interface, $counter, $vpnn2nip, $vpnn2nmask, $ddns, $edc, | |
112 | $edd, $wmon, $wmoff, $ipfqdn, $http, $wioscan, $statustxt, $status, $key, $ic, $text, $image ) = (); | |
113 | ||
114 | my ( @temp, @dates, @ipaddresses, @names, @remark, @sendemailon, @sendemailoff, @current, @ddns, @match, @webinterface, @arpcache, @arpadd, @line, | |
115 | @hosts, @vpnstatus, @ovpnstatus, @activ, @dyndns, @pingmethode, @status, @id, @write, @log ); | |
116 | ||
117 | my @nosaved = ('ACTION','ID','CLIENTID','TIMESTAMP','IPADR','HOST','REMARK','DYNDNS','SENDEMAILON','SENDEMAILOFF','PINGMETHODE','ONLINE','WEBINTERFACE'); | |
118 | ||
119 | my @devs_color = ('GREEN','BLUE','ORANGE','RED'); | |
120 | my @devs_net = ('green0','blue0','orange0','red0'); | |
121 | my @devs_img = ('green.png','blue.png','orange.png','red.png'); | |
122 | my @devs_alt = ('green','blue','orange','red'); | |
123 | ||
124 | my %ifacecolor = ( GREEN => 'wio_run_green', BLUE => 'wio_run_blue', ORANGE => 'wio_run_orange'); | |
125 | ||
126 | &loadips(); | |
127 | ||
128 | ## some wio settings | |
129 | ||
130 | $wiosettings{'ACTION'} = ''; | |
131 | $wiosettings{'COUNT'} = ''; | |
132 | $wiosettings{'ID'} = ''; | |
133 | $wiosettings{'CLIENTID'} = ''; | |
134 | $wiosettings{'SORT'} = 'IPADR'; | |
135 | $wiosettings{'HOST'} = ''; | |
136 | $wiosettings{'IPADR'} = ''; | |
137 | $wiosettings{'EN'} = 'on'; | |
138 | $wiosettings{'REMARK'} = ''; | |
139 | $wiosettings{'DYNDNS'} = ''; | |
140 | $wiosettings{'CLIENTREMARK'} = ''; | |
141 | $wiosettings{'SENDEMAILON'} = ''; | |
142 | $wiosettings{'SENDEMAILOFF'} = ''; | |
143 | $wiosettings{'PINGMETHODE'} = 'ip'; | |
144 | $wiosettings{'WEBINTERFACE'} = '----'; | |
145 | $wiosettings{'TIMEOUT'} = '1'; | |
146 | $wiosettings{'TIMESTAMP'} = ''; | |
147 | $wiosettings{'ONLINE'} = 'off'; | |
148 | $wiosettings{'CRON'} = '15'; | |
149 | $wiosettings{'OVPNCRON'} = '5'; | |
150 | $wiosettings{'ENABLE'} = 'off'; | |
151 | $wiosettings{'LOGGING'} = 'off'; | |
152 | $wiosettings{'MAILREMARK'} = 'off'; | |
153 | $wiosettings{'MAILSTYLE'} = 'email'; | |
154 | $wiosettings{'OVPNRWMAIL'} = 'off'; | |
155 | $wiosettings{'SHUTDOWN'} = 'off'; | |
156 | ||
157 | &Header::getcgihash(\%wiosettings); | |
158 | &Header::getcgihash(\%mainsettings); | |
159 | &Header::getcgihash(\%mailsettings); | |
160 | &Header::getcgihash(\%netsettings); | |
161 | ||
162 | if ( $mailsettings{'USEMAIL'} eq 'on' ) { $wiosettings{'SENDEMAIL'} = 'on'; } | |
163 | else { $wiosettings{'SENDEMAIL'} = 'off'; } | |
164 | ||
165 | if ( -e $wiofile ) { goto WIOSCAN; } | |
166 | ||
167 | ## get network ips | |
168 | foreach (@devs_color) { | |
169 | if ( $netsettings{"${_}_DEV"} ne '' ) { | |
1bee37ba SF |
170 | $wiosettings{"${_}_IPLOW"} = &Network::find_next_ip_address($netsettings{"${_}_NETADDRESS"}, 1); |
171 | $wiosettings{"${_}_IPHIGH"} = &Network::find_next_ip_address($netsettings{"${_}_BROADCAST"}, -1); | |
0d6cc79d SF |
172 | } |
173 | } | |
174 | ||
175 | ## save wio settings | |
176 | ||
177 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_save'}.'1' ) { | |
178 | unless ( `ps -A | grep wio.pl` ) { | |
179 | $cgiparams{'SORT'} = $wiosettings{'SORT'}; | |
180 | $cgiparams{'CRON'} = $wiosettings{'CRON'}; | |
181 | $cgiparams{'OVPNCRON'} = $wiosettings{'OVPNCRON'}; | |
182 | $cgiparams{'ENABLE'} = $wiosettings{'ENABLE'}; | |
183 | $cgiparams{'LOGGING'} = $wiosettings{'LOGGING'}; | |
184 | $cgiparams{'TIMEOUT'} = $wiosettings{'TIMEOUT'}; | |
185 | $cgiparams{'ACTION'} = $wiosettings{'ACTION'}; | |
186 | $cgiparams{'CLIENTREMARK'} = $wiosettings{'CLIENTREMARK'}; | |
187 | $cgiparams{'MAILREMARK'} = $wiosettings{'MAILREMARK'}; | |
188 | $cgiparams{'MAILSTYLE'} = $wiosettings{'MAILSTYLE'}; | |
189 | $cgiparams{'OVPNRWMAIL'} = $wiosettings{'OVPNRWMAIL'}; | |
190 | $cgiparams{'SHUTDOWN'} = $wiosettings{'SHUTDOWN'}; | |
191 | ||
192 | &General::writehash($wiosettings, \%cgiparams); | |
193 | &General::readhash($wiosettings, \%wiosettings); | |
194 | ||
195 | if ( $wiosettings{'ENABLE'} eq 'off' ) { | |
196 | &WIO::clearfile($ipadrfile); | |
197 | unlink glob "$rrddir/*"; | |
198 | } | |
199 | } | |
200 | else { | |
201 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
202 | } | |
203 | } | |
204 | ||
205 | ## save imported clients | |
206 | ||
207 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_save'}.'2' ) { | |
208 | unless ( `ps -A | grep wio.pl` ) { | |
209 | while ( $count < $wiosettings{'COUNT'} ) { | |
210 | if ( defined($wiosettings{"USE$count"}) && $wiosettings{"USE$count"} eq 'on' ) { | |
211 | $wiosettings{'CLIENTID'} = $wiosettings{'CLIENTID$count'}; | |
212 | $wiosettings{'TIMESTAMP'} = $wiosettings{"TIMESTAMP$count"}; | |
213 | $wiosettings{'IPADR'} = $wiosettings{"IPADR$count"}; | |
214 | $wiosettings{'HOST'} = $wiosettings{"HOST$count"}; | |
215 | $wiosettings{'EN'} = $wiosettings{"EN$count"}; | |
216 | $wiosettings{'REMARK'} = $wiosettings{"REMARK$count"}; | |
217 | $wiosettings{'DYNDNS'} = $wiosettings{"DYNDNS$count"}; | |
218 | $wiosettings{'SENDEMAILON'} = $wiosettings{"SENDEMAILON$count"}; | |
219 | $wiosettings{'SENDEMAILOFF'} = $wiosettings{"SENDEMAILOFF$count"}; | |
220 | $wiosettings{'PINGMETHODE'} = $wiosettings{"PINGMETHODE$count"}; | |
221 | $wiosettings{'ONLINE'} = $wiosettings{"ONLINE$count"}; | |
222 | $wiosettings{'WEBINTERFACE'} = $wiosettings{"WEBINTERFACE$count"}; | |
223 | ||
224 | &validSave(); | |
225 | ||
226 | if ($errormessage) { | |
227 | open(FILE, ">> $editfile"); | |
228 | print FILE "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n"; | |
229 | close(FILE); | |
230 | $importmessage = $errormessage; | |
231 | } | |
232 | else { | |
233 | $wiosettings{'CLIENTID'} = &General::findhasharraykey (\%ipshash); | |
234 | unshift (@current, "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n"); | |
235 | &SortDataFile('',@current); | |
236 | } | |
237 | } | |
238 | $count++; | |
239 | } | |
240 | ||
241 | map ($wiosettings{$_} = '' ,@nosaved); | |
242 | unlink ($importfile); | |
243 | if ( -e "$editfile" ) { goto EDIT; } | |
244 | } | |
245 | else { | |
246 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
247 | } | |
248 | } | |
249 | ||
250 | ## add or update client | |
251 | ||
252 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_client_add'} ) { | |
253 | unless ( `ps -A | grep wio.pl` ) { | |
254 | &validSave(); | |
255 | ||
256 | unless ($errormessage) { | |
257 | if ( $wiosettings{'ID'} eq '' && $wiosettings{'ACTION'} ne $Lang::tr{'edit'} ) { | |
258 | $wiosettings{'CLIENTID'} = &General::findhasharraykey (\%ipshash); | |
259 | unshift (@current, "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n"); | |
260 | } | |
261 | else { | |
262 | @current[$wiosettings{'ID'}] = "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n"; | |
263 | } | |
264 | } | |
265 | else { goto ERROR; } | |
266 | ||
267 | map ($wiosettings{$_} = '' ,@nosaved); | |
268 | &SortDataFile('',@current); | |
269 | } | |
270 | else { | |
271 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
272 | } | |
273 | } | |
274 | ||
275 | ## add arp client | |
276 | ||
277 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_add'} ) { | |
278 | unless ( `ps -A | grep wio.pl` ) { | |
279 | open(FILE, "$logdir/.arpcache"); | |
280 | @arpadd = <FILE>; | |
281 | close (FILE); | |
282 | ||
283 | chomp(@arpadd[$wiosettings{'ID'}]); | |
284 | @temp = split (/\,/, @arpadd[$wiosettings{'ID'}]); | |
285 | ||
286 | $wiosettings{'CLIENTID'} = &General::findhasharraykey (\%ipshash); | |
287 | $wiosettings{'IPADR'} = $temp[1]; | |
288 | $wiosettings{'HOST'} = $temp[2]; | |
289 | $wiosettings{'EN'} = 'on'; | |
290 | ||
291 | $wiosettings{'PINGMETHODE'} = 'ip'; | |
292 | $wiosettings{'ONLINE'} = 'off'; | |
293 | ||
294 | open(FILE, ">> $editfile"); | |
295 | print FILE "$wiosettings{'CLIENTID'},$wiosettings{'TIMESTAMP'},$wiosettings{'IPADR'},$wiosettings{'HOST'},$wiosettings{'EN'},$wiosettings{'REMARK'},$wiosettings{'DYNDNS'},$wiosettings{'SENDEMAILON'},$wiosettings{'SENDEMAILOFF'},$wiosettings{'PINGMETHODE'},$wiosettings{'ONLINE'},$wiosettings{'WEBINTERFACE'}\n"; | |
296 | close(FILE); | |
297 | ||
298 | goto EDIT; | |
299 | } | |
300 | else { | |
301 | undef($wiosettings{'ID'}); | |
302 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
303 | } | |
304 | } | |
305 | ||
306 | ## enable / disabel client || enable / disable dyndns || enable / disable sendemailon || enable / disable sendemailoff || change ip / fqdn | |
307 | ||
308 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'enable disable client'} ) { $edc = 'on'; } | |
309 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'enable disable dyndns'} ) { $edd = 'on'; } | |
310 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_mail_online'} ) { $wmon = 'on'; } | |
311 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_mail_offline'} ) { $wmoff = 'on'; } | |
312 | if (( $wiosettings{'ACTION'} eq $Lang::tr{'wio_ip_on'} ) || ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_fqdn_on'} )) { $ipfqdn = 'on'; } | |
313 | ||
314 | if ( defined($edc) || defined($edd) || defined($wmon) || defined($wmoff) || defined($ipfqdn) ) { | |
315 | unless ( `ps -A | grep wio.pl` ) { | |
316 | chomp(@current[$wiosettings{'ID'}]); | |
317 | @temp = split (/\,/, @current[$wiosettings{'ID'}]); | |
318 | ||
319 | if ( $edc eq 'on' ) { | |
320 | $temp[4] = $temp[4] ne '' ? '' : 'on'; | |
321 | $temp[10] = ''; | |
322 | $temp[11] = ''; | |
323 | $temp[1] = ''; | |
324 | unlink "$rrddir/$temp[0].rrd"; | |
325 | } | |
326 | elsif ( $edd eq 'on' ) { $temp[6] = $temp[6] ne '' ? '' : 'on'; } | |
327 | elsif ( $wmon eq 'on' ) { $temp[7] = $temp[7] ne '' ? '' : 'on'; } | |
328 | elsif ( $wmoff eq 'on' ) { $temp[8] = $temp[8] ne '' ? '' : 'on'; } | |
329 | elsif ( $ipfqdn eq 'on' ) { $temp[9] = $temp[9] eq 'fqdn' ? 'ip' : 'fqdn'; } | |
330 | ||
331 | @current[$wiosettings{'ID'}] = join (',', @temp)."\n"; | |
332 | undef($wiosettings{'ID'}); | |
333 | ||
334 | &writeips(); | |
335 | } | |
336 | else { | |
337 | undef($wiosettings{'ID'}); | |
338 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
339 | } | |
340 | } | |
341 | ||
342 | ## refresh wio status || refresh single client status | |
343 | ||
344 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_refresh'} || $wiosettings{'ACTION'} eq $Lang::tr{'wio_sc_refresh'} ) { | |
345 | ||
346 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_sc_refresh'} ) { | |
347 | open(FILE, "> $onoffip"); | |
348 | print FILE @current[$wiosettings{'ID'}]; | |
349 | close(FILE); | |
350 | ||
351 | undef($wiosettings{'ID'}); | |
352 | } | |
353 | ||
354 | unless ( `ps -A | grep wio.pl` ) { | |
355 | ||
356 | &Header::showhttpheaders(); | |
357 | &Header::openpage($Lang::tr{'wio'}, 1, $refreshbox); | |
358 | &Header::openbigbox('100%', 'left', ''); | |
359 | &Header::openbox('100%', 'left', $Lang::tr{'wio_info'}); | |
360 | ||
361 | print" | |
362 | <table align='center' width='100%'> | |
363 | <tr><td align='center'>$Lang::tr{'wio_msg'}</td></tr> | |
364 | <tr><td> </td></tr> | |
365 | <tr><td align='center'><img align='middle' src='/images/indicator.gif' /></td></tr> | |
366 | </table> | |
367 | "; | |
368 | ||
369 | &Header::closebox(); | |
370 | &Header::closebigbox(); | |
371 | &Header::closepage(); | |
372 | ||
373 | while ( system("/usr/local/bin/wiohelper", "&") ) {} | |
374 | ||
375 | exit 0; | |
376 | } | |
377 | else { | |
378 | $infomessage = "$Lang::tr{'wio_already_running'}"; | |
379 | } | |
380 | ||
381 | } | |
382 | ||
383 | ## refresh dyndns ip | |
384 | ||
385 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_dyndns_refresh'} ) { | |
386 | unless ( `ps -A | grep wio.pl` ) { | |
387 | chomp(@current[$wiosettings{'ID'}]); | |
388 | @temp = split (/\,/, @current[$wiosettings{'ID'}]); | |
389 | ||
390 | ($temp[2], $infomessage) = &WIO::getdyndnsip($temp[2], $temp[3]); | |
391 | ||
392 | @current[$wiosettings{'ID'}] = join (',', @temp)."\n"; | |
393 | ||
394 | &writeips(); | |
395 | ||
396 | undef($wiosettings{'ID'}); | |
397 | } | |
398 | else { | |
399 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
400 | } | |
401 | } | |
402 | ||
403 | ## edit client | |
404 | ||
405 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'edit'} ) { | |
406 | unless ( `ps -A | grep wio.pl` ) { | |
407 | chomp(@current[$wiosettings{'ID'}]); | |
408 | @temp = split (/\,/, @current[$wiosettings{'ID'}]); | |
409 | ||
410 | $wiosettings{'CLIENTID'} = $temp[0]; | |
411 | $wiosettings{'TIMESTAMP'} = $temp[1]; | |
412 | $wiosettings{'IPADR'} = $temp[2]; | |
413 | $wiosettings{'HOST'} = $temp[3]; | |
414 | $wiosettings{'EN'} = $temp[4]; | |
415 | $wiosettings{'REMARK'} = $temp[5]; | |
416 | $wiosettings{'DYNDNS'} = $temp[6]; | |
417 | $wiosettings{'SENDEMAILON'} = $temp[7]; | |
418 | $wiosettings{'SENDEMAILOFF'} = $temp[8]; | |
419 | $wiosettings{'PINGMETHODE'} = $temp[9]; | |
420 | $wiosettings{'ONLINE'} = $temp[10]; | |
421 | $wiosettings{'WEBINTERFACE'} = $temp[11]; | |
422 | } | |
423 | else { | |
424 | undef($wiosettings{'ACTION'}); | |
425 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
426 | } | |
427 | } | |
428 | ||
429 | ## remove client | |
430 | ||
431 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_remove_client'} ) { | |
432 | unless ( `ps -A | grep wio.pl` ) { | |
433 | chomp(@current[$wiosettings{'ID'}]); | |
434 | ||
435 | @temp = split (/\,/, @current[$wiosettings{'ID'}]); | |
436 | ||
437 | unlink "$rrddir/$temp[0].rrd"; | |
438 | ||
439 | splice (@current,$wiosettings{'ID'},1); | |
440 | ||
441 | &writeips(); | |
442 | ||
443 | undef($wiosettings{'ID'}); | |
444 | } | |
445 | else { | |
446 | undef($wiosettings{'ID'}); | |
447 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
448 | } | |
449 | } | |
450 | ||
451 | ## remove all clients | |
452 | ||
453 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_remove_all'} ) { | |
454 | unless ( `ps -A | grep wio.pl` ) { | |
455 | &WIO::clearfile($ipadrfile); | |
456 | unlink glob "$rrddir/*"; | |
457 | undef(@current); | |
458 | } | |
459 | else { | |
460 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
461 | } | |
462 | } | |
463 | ||
464 | ## back function | |
465 | ||
466 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_back'} ) { | |
467 | if ( -e "$importfile" ) { unlink ($importfile); } | |
468 | map ($wiosettings{$_} = '' ,@nosaved); | |
469 | undef($errormessage); | |
470 | } | |
471 | ||
472 | ## import hosts, fixleases or csv file || scan networks (green/blue/orange) | |
473 | ||
474 | if ( $wiosettings{'ACTION'} eq 'wio_run_green' || | |
475 | $wiosettings{'ACTION'} eq 'wio_run_blue' || | |
476 | $wiosettings{'ACTION'} eq 'wio_run_orange') { $wioscan = 'on'; } | |
477 | ||
478 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'1' || | |
479 | $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' || | |
480 | $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'3' || | |
481 | defined($wioscan) || defined($importmessage) ) { | |
482 | ||
483 | unless ( `ps -A | grep wio.pl` ) { | |
484 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'1' && $importmessage eq '' ) { | |
485 | ||
486 | &Header::getcgihash(\%wiosettings, {'wantfile' => 1, 'filevar' => 'CSVFILE'}); | |
487 | ||
488 | if ( $wiosettings{'CSVFILE'} eq '' ) { | |
489 | $errormessage = $Lang::tr{'wio_no_file_selected'}; | |
490 | $message = 2; goto ERROR; | |
491 | } | |
492 | ||
493 | if ( $wiosettings{'CSVFILE'} =~ /[^a-z0-9A-Z\ \.\-\_\:\\]+/ ) { | |
494 | $errormessage = $Lang::tr{'wio_no_csv_error'}; | |
495 | $message = 2; goto ERROR; | |
496 | } | |
497 | ||
498 | if ( !($wiosettings{'CSVFILE'} =~ /.csv$/) ) { | |
499 | $errormessage = $Lang::tr{'wio_no_csv'}; | |
500 | $message = 2; goto ERROR; | |
501 | } | |
502 | ||
503 | if (copy($wiosettings{'CSVFILE'}, "$logdir/importfile") != 1) { | |
504 | $errormessage = $!; | |
505 | $message = 2; goto ERROR; | |
506 | } | |
507 | } | |
508 | ||
509 | EDIT: | |
510 | ||
511 | &General::readhash($wiosettings, \%wiosettings); | |
512 | ||
513 | &Header::showhttpheaders(); | |
514 | &Header::openpage($Lang::tr{'wio'}, 1, ''); | |
515 | &Header::openbigbox('100%', 'left'); | |
516 | ||
517 | if ($importmessage) { | |
518 | &Header::openbox('100%', 'left', $Lang::tr{'wio_error'}, 'error'); | |
519 | print" <table width='100%'><tr><td><font class='base'>$importmessage</font></td></tr></table>"; | |
520 | &Header::closebox(); | |
521 | } | |
522 | ||
523 | if ( -e "$editfile" ) { | |
524 | open(FILE, "< $editfile" ); } | |
525 | elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'1' ) { | |
526 | open(FILE, "< $importfile" ); } | |
527 | elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ) { | |
528 | open(FILE, "< $hostfile" ); } | |
529 | elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'3' ) { | |
530 | open(FILE, "< $dhcpfile" ); } | |
531 | elsif ( $wioscan eq 'on' ) { | |
532 | ||
533 | foreach (keys(%ifacecolor)) { | |
534 | if ( $netsettings{"${_}_DEV"} eq $wiosettings{'ID'} ) { | |
535 | $dev = $netsettings{"${_}_DEV"}; | |
536 | $iprange = $wiosettings{"${_}_IPLOW"} . "-" . $wiosettings{"${_}_IPHIGH"}; | |
537 | ||
538 | if ( $_ eq 'GREEN' ) { $color = "$Header::colourgreen"; $net = $Lang::tr{'wio_msg_green'}; } | |
539 | elsif ( $_ eq 'BLUE' ) { $color = "$Header::colourblue"; $net = $Lang::tr{'wio_msg_blue'}; } | |
540 | else { $color = "$Header::colourorange"; $net = $Lang::tr{'wio_msg_orange'}; } | |
541 | } | |
542 | } | |
543 | ||
544 | &Header::openbox('100%', 'left', $Lang::tr{'wio_info'}); | |
545 | print"<table width='100%'> | |
546 | <tr><td align='center'><font class='base'>$Lang::tr{'wio_msg_left'} </font><font class='base' color='$color'><b>$net</b></font> $Lang::tr{'wio_msg_center'} <font class='base' color='$color'><b>$dev</b></font><font class='base'> $Lang::tr{'wio_msg_right'} $Lang::tr{'wio_msg_hint'}</font></td></tr> | |
547 | <tr><td> </td></tr> | |
548 | <tr><td align='center'><img align='middle' src='/images/indicator.gif' /></td></tr> | |
549 | </table>"; | |
550 | &Header::closebox(); | |
551 | &Header::closebigbox(); | |
552 | ||
553 | open(FILE, "/usr/local/bin/wioscan -wsa $dev $iprange |" ); | |
554 | ||
555 | } | |
556 | ||
557 | @hosts = <FILE>; | |
558 | close(FILE); | |
559 | ||
560 | if ( $wioscan ne 'on' && ! -e $wiofile ) { @hosts = sort @hosts; } | |
561 | else { | |
562 | open(FILE, "> $wiofile"); | |
563 | print FILE @hosts; | |
564 | close(FILE); | |
565 | ||
566 | print"<meta http-equiv=\"refresh\" content=\"0; URL=$ENV{'SCRIPT_NAME'}\">"; | |
567 | exit 0; | |
568 | } | |
569 | ||
570 | WIOSCAN: | |
571 | ||
572 | if ( -e $wiofile ) { | |
573 | open(FILE, "< $wiofile"); | |
574 | @hosts = <FILE>; | |
575 | close (FILE); | |
576 | ||
577 | &General::readhash($wiosettings, \%wiosettings); | |
578 | ||
579 | &Header::showhttpheaders(); | |
580 | &Header::openpage($Lang::tr{'wio'}, 1, ''); | |
581 | &Header::openbigbox('100%', 'left'); | |
582 | } | |
583 | ||
584 | foreach (@hosts) { | |
585 | chomp; | |
586 | ||
587 | @line = split (/\,/, $_); | |
588 | ||
589 | if ( -e $editfile || -e $importfile ) { | |
590 | $wiosettings{'CLIENTID$count'} = $line[0]; | |
591 | $wiosettings{'TIMESTAMP$count'} = $line[1]; | |
592 | $wiosettings{'IPADR$count'} = $line[2]; | |
593 | $wiosettings{'HOST$count'} = $line[3]; | |
594 | $wiosettings{'EN$count'} = $line[4]; | |
595 | $wiosettings{'REMARK$count'} = $line[5]; | |
596 | $wiosettings{'DYNDNS$count'} = $line[6]; | |
597 | $wiosettings{'SENDEMAILON$count'} = $line[7]; | |
598 | $wiosettings{'SENDEMAILOFF$count'} = $line[8]; | |
599 | $wiosettings{'PINGMETHODE$count'} = $line[9]; | |
600 | $wiosettings{'ONLINE$count'} = $line[10]; | |
601 | $wiosettings{'WEBINTERFACE$count'} = $line[11]; | |
602 | $wiosettings{'USE$count'} = 'on'; | |
603 | } | |
604 | else { | |
605 | $wiosettings{'IPADR$count'} = $line[1]; | |
606 | $wiosettings{'EN$count'} = 'on'; | |
607 | $wiosettings{'PINGMETHODE$count'} = 'ip'; | |
608 | $wiosettings{'USE$count'} = 'on'; | |
609 | ||
610 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ) { | |
611 | $wiosettings{'HOST$count'} = $line[2]; | |
612 | $wiosettings{'DOM$count'} = $line[3]; | |
613 | $wiosettings{'REMARK$count'} = ''; | |
614 | } | |
615 | elsif ( $wioscan eq 'on' || -e $wiofile ) { | |
616 | $wiosettings{'HOST$count'} = gethostbyaddr(inet_aton($line[1]), AF_INET); | |
617 | if ($wiosettings{'HOST$count'} eq '') { $wiosettings{'HOST$count'} = $line[1]; } | |
618 | $wiosettings{'REMARK$count'} = ''; | |
619 | $wiosettings{'WEBINTERFACE$count'} = ''; | |
620 | } | |
621 | else { | |
622 | $wiosettings{'HOST$count'} = $line[7]; | |
623 | $wiosettings{'REMARK$count'} = $line[6]; | |
624 | } | |
625 | } | |
626 | ||
627 | $checked{'EN$count'}{'on'} = ($wiosettings{'EN$count'} eq '' ) ? '' : "checked='checked'"; | |
628 | ||
629 | $checked{'DYNDNS$count'}{'on'} = ($wiosettings{'DYNDNS$count'} eq '' ) ? '' : "checked='checked'"; | |
630 | $checked{'SENDEMAILON$count'}{'on'} = ($wiosettings{'SENDEMAILON$count'} eq '' ) ? '' : "checked='checked'"; | |
631 | $checked{'SENDEMAILOFF$count'}{'on'} = ($wiosettings{'SENDEMAILOFF$count'} eq '' ) ? '' : "checked='checked'"; | |
632 | ||
633 | $checked{'PINGMETHODE$count'}{'ip'} = $checked{'PINGMETHODE$count'}{'fqdn'} = ''; | |
634 | $checked{'PINGMETHODE$count'}{$wiosettings{'PINGMETHODE$count'}} = "checked='checked'"; | |
635 | ||
636 | $checked{'USE$count'}{'on'} = ($wiosettings{'USE$count'} eq '' ) ? '' : "checked='checked'"; | |
637 | ||
638 | $selected{'WEBINTERFACE$count'}{'----'} = ''; | |
639 | $selected{'WEBINTERFACE$count'}{'HTTP'} = ''; | |
640 | $selected{'WEBINTERFACE$count'}{'HTTPS'} = ''; | |
641 | $selected{'WEBINTERFACE$count'}{$wiosettings{'WEBINTERFACE$count'}} = "selected='selected'"; | |
642 | ||
643 | if (! &WIO::checkinto($wiosettings{'IPADR$count'}, $wiosettings{'HOST$count'}, @current) ) { | |
644 | ||
645 | if ( $importmessage ) { | |
646 | &Header::openbox('100%', 'left', "$Lang::tr{'wio_import_data'}'$wiosettings{'HOST$count'}'$Lang::tr{'wio_import_data1'}"); | |
647 | } | |
648 | elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'1' || $wioscan eq 'on' || -e $wiofile || -e $editfile ) { | |
649 | &Header::openbox('100%', 'left', "$Lang::tr{'wio_import_data'}'$wiosettings{'HOST$count'}'$Lang::tr{'wio_import_data2'}"); | |
650 | } | |
651 | elsif ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ) { | |
652 | &Header::openbox('100%', 'left', "$Lang::tr{'wio_import_data'}'$wiosettings{'HOST$count'}.$wiosettings{'DOM$count'}'$Lang::tr{'wio_import_data2'}"); | |
653 | } | |
654 | else { | |
655 | &Header::openbox('100%', 'left', $Lang::tr{'wio_import_leases'}); | |
656 | } | |
657 | ||
658 | print" | |
659 | <form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'> | |
660 | <input type='hidden' name='ONLINE$count' value='$wiosettings{'ONLINE$count'}' /> | |
661 | ||
662 | <table width='100%'> | |
663 | <tr> | |
664 | <td>$Lang::tr{'wio_use'}</td> | |
665 | <td><input type='checkbox' name='USE$count' $checked{'USE$count'}{'on'} /></td> | |
666 | </tr> | |
667 | <tr> | |
668 | <td>$Lang::tr{'wio_client_enable'}</td> | |
669 | <td><input type='checkbox' name='EN$count' $checked{'EN$count'}{'on'} /></td> | |
670 | </tr> | |
671 | <tr> | |
672 | <td>$Lang::tr{'host ip'}:</td> | |
673 | <td><input type='text' name='IPADR$count' value='$wiosettings{'IPADR$count'}' size='18' /></td> | |
674 | <td>$Lang::tr{'hostname'}:</td> | |
675 | "; | |
676 | ||
677 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'wio_import'}.'2' ) { | |
678 | print"<td><input type='text' name='HOST$count' size='18' value='$wiosettings{'HOST$count'}.$wiosettings{'DOM$count'}' /></td>"; | |
679 | } | |
680 | else { | |
681 | print"<td><input type='text' name='HOST$count' size='18' value='$wiosettings{'HOST$count'}' /></td>"; | |
682 | } | |
683 | ||
684 | print" | |
685 | <td>$Lang::tr{'remark'}:</td> | |
686 | <td><input type='text' name='REMARK$count' value='$wiosettings{'REMARK$count'}' size='18' /></td> | |
687 | </tr> | |
688 | <tr> | |
689 | <td class='base'>$Lang::tr{'wio_ping_send'}:</td> | |
690 | <td align='left'><input type='radio' name='PINGMETHODE$count' value='ip' $checked{'PINGMETHODE$count'}{'ip'} /> IP <input type='radio' name='PINGMETHODE$count' value='fqdn' $checked{'PINGMETHODE$count'}{'fqdn'} /> FQDN</td> | |
691 | <td>$Lang::tr{'wio_dyndns'}:</td> | |
692 | <td><input type='checkbox' name='DYNDNS$count' $checked{'DYNDNS$count'}{'on'} /></td> | |
693 | "; | |
694 | ||
695 | if ( $wiosettings{'SENDEMAIL'} eq 'on' ) { | |
696 | print"<td>$Lang::tr{'wio_sendemail'}:</td> | |
697 | <td><input type='checkbox' name='SENDEMAILON$count' $checked{'SENDEMAILON$count'}{'on'} /> $Lang::tr{'wio_online'} <input type='checkbox' name='SENDEMAILOFF$count' $checked{'SENDEMAILOFF$count'}{'on'} /> $Lang::tr{'wio_offline'}</td>"; | |
698 | } | |
699 | else { | |
700 | print"<td colspan='2'> </td>"; | |
701 | } | |
702 | ||
703 | print" | |
704 | </tr> | |
705 | <tr> | |
1bee37ba | 706 | <td height='30'>$Lang::tr{'wio_link_open'}:</td> |
0d6cc79d SF |
707 | <td align='left' colspan='5'> |
708 | <select size='1' name='WEBINTERFACE$count' width='80' style='width: 80px'> | |
709 | <option value='----' $selected{'WEBINTERFACE$count'}{'----'}>----</option> | |
710 | <option value='HTTP' $selected{'WEBINTERFACE$count'}{'HTTP'}>HTTP</option> | |
711 | <option value='HTTPS' $selected{'WEBINTERFACE$count'}{'HTTPS'}>HTTPS</option> | |
712 | </select> | |
713 | </td> | |
714 | </tr> | |
715 | </table> | |
716 | "; | |
717 | ||
718 | &Header::closebox(); | |
719 | $showcount++; | |
720 | } | |
721 | $count++; | |
722 | } | |
723 | ||
724 | if ( $showcount gt 0 ) { | |
725 | &Header::openbox('100%', 'left', $Lang::tr{'wio_import_infos'}); | |
726 | ||
727 | print" | |
728 | <table width='100%'> | |
729 | <tr> | |
730 | "; | |
731 | ||
732 | if ($importmessage) { print"<td> </td>"; } | |
733 | else { print"<td><font color='$color{'color11'}'>$Lang::tr{'wio_import_infos_csv'}</font></td>"; } | |
734 | ||
735 | print" | |
736 | </tr> | |
737 | <tr><td colspan='4'> </td></tr> | |
738 | </table> | |
739 | <table width='100%'> | |
740 | <tr> | |
741 | <td width='25%'> </td> | |
742 | <td width='25%'><input type='hidden' name='COUNT' value='$count' /><input type='hidden' name='ACTION' value='$Lang::tr{'wio_save'}2' /><input type='submit' name='SUBMIT' value='$Lang::tr{'wio_save'}' /></form></td> | |
743 | <td width='25%'><form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'><input type='submit' name='ACTION' value='$Lang::tr{'wio_back'}' /></form></td> | |
744 | <td width='25%'> </td> | |
745 | </tr> | |
746 | </table> | |
747 | "; | |
748 | ||
749 | &Header::closebox(); | |
750 | &Header::closebigbox(); | |
751 | &Header::closepage(); | |
752 | } | |
753 | else { | |
754 | print"<meta http-equiv=\"refresh\" content=\"0; URL=$ENV{'SCRIPT_NAME'}?INFO\">"; | |
755 | } | |
756 | ||
757 | if ( -e "$editfile" ) { unlink ($editfile); } | |
758 | if ( -e "$wiofile" ) { unlink($wiofile); } | |
759 | exit 0; | |
760 | } | |
761 | else { | |
762 | $infomessage = "$Lang::tr{'wio_error_function'}"; | |
763 | } | |
764 | } | |
765 | ||
766 | ## skript function | |
767 | ||
768 | if ($ENV{'QUERY_STRING'} =~ /$sortstring/ ) { | |
769 | my $string = $ENV{'QUERY_STRING'}; | |
770 | ||
771 | if ( $string eq 'INFO' ) { | |
772 | $infomessage = $Lang::tr{'wio_import_info_csv'}; | |
773 | } | |
774 | else { | |
775 | &General::readhash($wiosettings, \%wiosettings); | |
776 | ||
777 | my $actual = $wiosettings{'SORT'}; | |
778 | ||
779 | if ($actual =~ $string) { | |
780 | my $Rev = ''; | |
781 | if ($actual !~ 'Rev') { $Rev = 'Rev'; } | |
782 | $string.=$Rev; | |
783 | } | |
784 | ||
785 | system("/bin/sed -i 's#$wiosettings{'SORT'}#$string#g' $wiosettings"); | |
786 | ||
787 | $wiosettings{'SORT'} = $string; | |
788 | map ($wiosettings{$_} = '' ,@nosaved); | |
789 | &SortDataFile('',@current); | |
790 | } | |
791 | } | |
792 | ||
793 | ## main part | |
794 | ||
795 | ERROR: | |
796 | ||
797 | unless($message == 1) { &General::readhash($wiosettings, \%wiosettings); } | |
798 | ||
799 | for ($i=5; $i<=60; $i+=5) { $selected{'CRON'}{$i} = ''; } | |
800 | ||
801 | $selected{'CRON'}{$wiosettings{'CRON'}} = "selected='selected'"; | |
802 | ||
803 | for ($i=1; $i<=15; $i++) { | |
804 | $selected{'TIMEOUT'}{$i} = ''; | |
805 | $selected{'OVPNCRON'}{$i} = ''; | |
806 | } | |
807 | ||
808 | $selected{'TIMEOUT'}{$wiosettings{'TIMEOUT'}} = "selected='selected'"; | |
809 | $selected{'OVPNCRON'}{$wiosettings{'OVPNCRON'}} = "selected='selected'"; | |
810 | ||
811 | $checked{'ENABLE'}{'off'} = $checked{'ENABLE'}{'on'} = ''; | |
812 | $checked{'ENABLE'}{$wiosettings{'ENABLE'}} = "checked='checked'"; | |
813 | ||
814 | $checked{'LOGGING'}{'off'} = $checked{'LOGGING'}{'on'} = ''; | |
815 | $checked{'LOGGING'}{$wiosettings{'LOGGING'}} = "checked='checked'"; | |
816 | ||
817 | $checked{'CLIENTREMARK'}{'off'} = $checked{'CLIENTREMARK'}{'on'} = ''; | |
818 | $checked{'CLIENTREMARK'}{$wiosettings{'CLIENTREMARK'}} = "checked='checked'"; | |
819 | ||
820 | $checked{'MAILREMARK'}{'off'} = $checked{'MAILREMARK'}{'on'} = ''; | |
821 | $checked{'MAILREMARK'}{$wiosettings{'MAILREMARK'}} = "checked='checked'"; | |
822 | ||
823 | $checked{'OVPNRWMAIL'}{'off'} = $checked{'OVPNRWMAIL'}{'on'} = ''; | |
824 | $checked{'OVPNRWMAIL'}{$wiosettings{'OVPNRWMAIL'}} = "checked='checked'"; | |
825 | ||
826 | $checked{'SHUTDOWN'}{'off'} = $checked{'SHUTDOWN'}{'on'} = ''; | |
827 | $checked{'SHUTDOWN'}{$wiosettings{'SHUTDOWN'}} = "checked='checked'"; | |
828 | ||
829 | $checked{'MAILSTYLE'}{'smail'} = $checked{'MAILSTYLE'}{'email'} = ''; | |
830 | $checked{'MAILSTYLE'}{$wiosettings{'MAILSTYLE'}} = "checked='checked'"; | |
831 | ||
832 | &Header::showhttpheaders(); | |
833 | &Header::openpage($Lang::tr{'wio'}, 1, "<meta http-equiv='expires' content='-1'><meta http-equiv='cache-control' content='no-store, no-cache, must-revalidate'><meta http-equiv='pragma' content='no-cache'>"); | |
834 | &Header::openbigbox('100%', 'left', ''); | |
835 | ||
836 | ## DEBUG / ERROR / INFO / UPDATE | |
837 | ||
838 | if ( $debug ) { | |
839 | &Header::openbox('100%', 'left', 'DEBUG', 'warning'); | |
840 | ||
841 | print"errormessage: $errormessage<br />\n"; | |
842 | print"infomessage: $infomessage<br />\n"; | |
843 | ||
844 | &hrline(); | |
845 | ||
846 | my $wiodebug = 0; | |
847 | foreach (sort keys %wiosettings) { | |
848 | print"$_ = $wiosettings{$_}<br />\n"; | |
849 | $wiodebug++; | |
850 | } | |
851 | ||
852 | &hrline(); | |
853 | ||
854 | my $netdebug = 0; | |
855 | foreach (sort keys %netsettings) { | |
856 | print"$_ = $netsettings{$_}<br />\n"; | |
857 | $netdebug++; | |
858 | } | |
859 | &Header::closebox(); | |
860 | } | |
861 | ||
862 | if ( $errormessage ) { | |
863 | &Header::openbox('100%', 'left', $Lang::tr{'wio_error'}, 'error'); | |
864 | print"<table width='100%'><tr><td><font class='base'><b>$errormessage</b></font></td></tr></table>"; | |
865 | &Header::closebox(); | |
866 | } | |
867 | ||
868 | if ( $infomessage ) { | |
869 | &Header::openbox('100%', 'left', $Lang::tr{'wio_info'}, 'warning'); | |
870 | print"<table width='100%'><tr><td><font class='base'><b>$infomessage</b></font></td></tr></table>"; | |
871 | &Header::closebox(); | |
872 | } | |
873 | ||
874 | ## wio configuration | |
875 | ||
876 | if ( $wiosettings{'ACTION'} eq $Lang::tr{'edit'}.'1' || $message == 1 || $wiosettings{'ENABLE'} eq 'off' ) { | |
877 | ||
878 | &Header::openbox('100%', 'left', $Lang::tr{'wio settings'}); | |
879 | ||
880 | print" | |
881 | <form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'> | |
882 | <table width='100%'> | |
883 | <tr> | |
884 | <td width='45%' bgcolor='$color{'color20'}' align='left' height='20'><b> $Lang::tr{'wio_settings_msg'}</b></td> | |
885 | <td width='2%'> </td> | |
886 | <td width='53%'> </td> | |
887 | </tr> | |
888 | <tr><td colspan='3'> </td></tr> | |
889 | <tr> | |
890 | <td colspan='3'>$Lang::tr{'wio_settings_msg_hint'}</td> | |
891 | </tr> | |
892 | <tr><td colspan='3'> </td></tr> | |
893 | <tr> | |
894 | <td align='right'>$Lang::tr{'wio enabled'}</td> | |
895 | "; | |
896 | ||
897 | print"<td> </td>"; | |
898 | ||
899 | if ( $wiosettings{'ENABLE'} eq 'on' ) { | |
900 | print"<td align='left'><input type='checkbox' onClick=\"return confirm('$Lang::tr{'wio_disable_hint'}')\" name='ENABLE' $checked{'ENABLE'}{'on'} /></td>"; | |
901 | } | |
902 | else { | |
903 | print"<td align='left'><input type='checkbox' name='ENABLE' $checked{'ENABLE'}{'on'} /></td>"; | |
904 | } | |
905 | print" | |
906 | </tr> | |
907 | <tr><td colspan='3'> </td></tr> | |
908 | <tr> | |
909 | <td align='right'>$Lang::tr{'wio_shutdown'}</td> | |
910 | <td> </td> | |
911 | <td align='left'><input type='checkbox' name='SHUTDOWN' $checked{'SHUTDOWN'}{'on'} /></td> | |
912 | </tr> | |
913 | <tr><td colspan='3'> </td></tr> | |
914 | <tr> | |
915 | <td align='right'>$Lang::tr{'wio cron'}</td> | |
916 | <td> </td> | |
917 | <td align='left'><select size='1' name='CRON' size='5'> | |
918 | "; | |
919 | ||
fe6f676b SF |
920 | for ($i=5; $i<=60; $i+=5) { |
921 | $_ = sprintf("%02s",$i); | |
922 | print "<option $selected{'CRON'}{$_}>$_</option>\n"; | |
923 | } | |
0d6cc79d SF |
924 | |
925 | print" | |
926 | </select> $Lang::tr{'wio min'}</td> | |
927 | </tr> | |
928 | <tr><td colspan='3'> </td></tr> | |
929 | <tr> | |
930 | <td align='right'>$Lang::tr{'wio timeout'}</td> | |
931 | <td> </td> | |
932 | <td align='left'><select size='1' name='TIMEOUT' size='5'> | |
933 | "; | |
934 | ||
fe6f676b SF |
935 | for ($i=1; $i<=15; $i++) { |
936 | $_ = sprintf("%02s",$i); | |
937 | print "<option $selected{'TIMEOUT'}{$_}>$_</option>\n"; | |
938 | } | |
0d6cc79d SF |
939 | |
940 | print" | |
941 | </select> $Lang::tr{'wio sec'}</td> | |
942 | </tr> | |
943 | <tr><td colspan='3'> </td></tr> | |
944 | <tr> | |
945 | <td align='right'>$Lang::tr{'wio_logging'}</td> | |
946 | <td> </td> | |
947 | <td align='left'><input type='checkbox' name='LOGGING' $checked{'LOGGING'}{'on'} /></td> | |
948 | </tr> | |
949 | <tr><td colspan='3'> </td></tr> | |
950 | <tr> | |
951 | <td align='right'>$Lang::tr{'wio_clientremark'}</td> | |
952 | <td> </td> | |
953 | <td align='left'><input type='checkbox' name='CLIENTREMARK' $checked{'CLIENTREMARK'}{'on'} /></td> | |
954 | </tr> | |
955 | <tr><td colspan='3'> </td></tr> | |
956 | ||
957 | "; | |
958 | ||
959 | if ( $wiosettings{'SENDEMAIL'} eq 'on' ) { | |
960 | print" | |
961 | <tr> | |
962 | <td align='right'>$Lang::tr{'wio_mail_style'}:</td> | |
963 | <td> </td> | |
964 | <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> | |
965 | </tr> | |
966 | <tr><td colspan='3'> </td></tr> | |
967 | <tr> | |
968 | <td align='right'>$Lang::tr{'wio_mailremark_enabled'}</td> | |
969 | <td> </td> | |
970 | <td align='left'><input type='checkbox' name='MAILREMARK' $checked{'MAILREMARK'}{'on'}></td> | |
971 | </tr> | |
972 | <tr><td colspan='3'> </td></tr> | |
973 | "; | |
974 | } | |
975 | if ( -e "$ovpnaddon" || ! -z "/var/ipfire/vpn/config" ) { | |
976 | print" | |
977 | <tr> | |
978 | <td align='right'>$Lang::tr{'wio_mail_ovpnrw'}</td> | |
979 | <td> </td> | |
980 | <td align='left'><input type='checkbox' name='OVPNRWMAIL' $checked{'OVPNRWMAIL'}{'on'}></td> | |
981 | </tr> | |
982 | <tr><td colspan='3'> </td></tr> | |
983 | <tr> | |
984 | <td align='right'>$Lang::tr{'wio_ovpn_cron'}</td> | |
985 | <td> </td> | |
986 | <td align='left'><select size='1' name='OVPNCRON' size='5'> | |
987 | "; | |
988 | ||
fe6f676b SF |
989 | for ($i=1; $i<=15; $i++) { |
990 | $_ = sprintf("%02s",$i); | |
991 | print "<option $selected{'OVPNCRON'}{$_}>$_</option>\n"; | |
992 | } | |
0d6cc79d SF |
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> | |
1bee37ba | 1716 | <td height='30'>$Lang::tr{'wio_link_open'}:</td> |
0d6cc79d SF |
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 | 1958 | <td colspan='2' align='right'></td> |
fe6f676b SF |
1959 | "; |
1960 | ||
1961 | if ( $wiosettings{'LOGGING'} eq 'on' ) { | |
1962 | print"<td width='10%' align='right'><form method='post' action='/cgi-bin/logs.cgi/log.dat' enctype='multipart/form-data'><input type='hidden' name='SECTION' value='wio' /><input type='submit' name='SUBMIT' value='$Lang::tr{'system logs'}' /></form></td>"; | |
1963 | } | |
1964 | ||
1965 | print" | |
f539ff6d | 1966 | <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 |
1967 | </tr> |
1968 | </table> | |
1969 | "; | |
1970 | } | |
1971 | ||
1972 | &Header::closebox(); | |
1973 | } | |
1974 | ||
1975 | &Header::closebigbox(); | |
1976 | &Header::closepage(); | |
1977 | ||
1978 | ############################################################################################################################ | |
1979 | ||
1980 | sub SortDataFile { | |
1981 | my ($data,@checkfile) = @_; | |
1982 | my $idsort = 0; | |
1983 | our %entries = (); | |
1984 | ||
1985 | sub sortips { | |
1986 | my $qs = ''; | |
1987 | ||
1988 | if (rindex ($wiosettings{'SORT'},'Rev') != -1) { | |
1989 | $qs = substr ($wiosettings{'SORT'},0,length($wiosettings{'SORT'})-3); | |
1990 | ||
1991 | if ($qs eq 'IPADR') { | |
1992 | my @a = split (/\./,$entries{$a}->{$qs}); | |
1993 | my @b = split (/\./,$entries{$b}->{$qs}); | |
1994 | ($b[0]<=>$a[0]) || | |
1995 | ($b[1]<=>$a[1]) || | |
1996 | ($b[2]<=>$a[2]) || | |
1997 | ($b[3]<=>$a[3]); | |
1998 | } | |
1999 | else { | |
2000 | $entries{$b}->{$qs} cmp $entries{$a}->{$qs}; | |
2001 | } | |
2002 | } | |
2003 | else { | |
2004 | $qs = $wiosettings{'SORT'}; | |
2005 | ||
2006 | if ($qs eq 'IPADR') { | |
2007 | my @a = split (/\./,$entries{$a}->{$qs}); | |
2008 | my @b = split (/\./,$entries{$b}->{$qs}); | |
2009 | ($a[0]<=>$b[0]) || | |
2010 | ($a[1]<=>$b[1]) || | |
2011 | ($a[2]<=>$b[2]) || | |
2012 | ($a[3]<=>$b[3]); | |
2013 | } | |
2014 | else { | |
2015 | $entries{$a}->{$qs} cmp $entries{$b}->{$qs}; | |
2016 | } | |
2017 | } | |
2018 | } | |
2019 | ||
2020 | if ($data eq 'arpcache') { | |
2021 | foreach (@checkfile) { | |
2022 | chomp; | |
2023 | @temp = split (',', $_); | |
2024 | ||
2025 | my @record = ('KEY',$idsort++,'MAC',$temp[0],'IPADR',$temp[1],'HOST',$temp[2],'REMARK',$temp[3],'IFACE',$temp[4]); | |
2026 | my $record = (); | |
2027 | %{$record} = @record; | |
2028 | $entries{$record->{KEY}} = $record; | |
2029 | } | |
2030 | ||
2031 | open(FILE, "> $logdir/.arpcache"); | |
2032 | ||
2033 | foreach (sort sortips keys %entries) { | |
2034 | print FILE "$entries{$_}->{MAC},$entries{$_}->{IPADR},$entries{$_}->{HOST},$entries{$_}->{REMARK},$entries{$_}->{IFACE},$entries{$_}->{HW}\n"; | |
2035 | } | |
2036 | ||
2037 | close(FILE); | |
2038 | ||
2039 | open (FILE, "$logdir/.arpcache"); | |
2040 | @arpcache = <FILE>; | |
2041 | close (FILE); | |
2042 | } | |
2043 | else { | |
2044 | foreach (@checkfile) { | |
2045 | chomp; | |
2046 | @temp = split (',', $_); | |
2047 | ||
2048 | 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]); | |
2049 | my $record = (); | |
2050 | %{$record} = @record; | |
2051 | $entries{$record->{KEY}} = $record; | |
2052 | } | |
2053 | ||
2054 | open(FILE, "> $ipadrfile"); | |
2055 | ||
2056 | foreach (sort sortips keys %entries) { | |
2057 | 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"; | |
2058 | } | |
2059 | ||
2060 | close(FILE); | |
2061 | ||
2062 | &loadips(); | |
2063 | } | |
2064 | } | |
2065 | ||
2066 | ############################################################################################################################ | |
2067 | ||
2068 | sub hrline { | |
2069 | ||
2070 | print"<table width='100%'><tr><td colspan='2' height='35'><hr></td></tr></table>"; | |
2071 | ||
2072 | } | |
2073 | ||
2074 | ############################################################################################################################ | |
2075 | ||
2076 | sub back { | |
2077 | ||
2078 | 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>"; | |
2079 | ||
2080 | } | |
2081 | ||
2082 | ############################################################################################################################ | |
2083 | ||
2084 | sub loadips { | |
2085 | ||
2086 | &General::readhasharray($ipadrfile, \%ipshash); | |
2087 | ||
2088 | open(FILE, "< $ipadrfile"); | |
2089 | @current = <FILE>; | |
2090 | close (FILE); | |
2091 | ||
2092 | } | |
2093 | ||
2094 | ############################################################################################################################ | |
2095 | ||
2096 | sub writeips { | |
2097 | ||
2098 | open(FILE, "> $ipadrfile"); | |
2099 | if ( defined($write) ) { print FILE @write; } | |
2100 | else { print FILE @current; } | |
2101 | close(FILE); | |
2102 | ||
2103 | } | |
2104 | ||
2105 | ############################################################################################################################ | |
2106 | ||
2107 | sub SortByTunnelName | |
2108 | { | |
2109 | if ($vpnconfighash{$a}[1] lt $vpnconfighash{$b}[1]) { | |
2110 | return -1; | |
2111 | } | |
2112 | elsif ($vpnconfighash{$a}[1] gt $vpnconfighash{$b}[1]) { | |
2113 | return 1; | |
2114 | } | |
2115 | else { | |
2116 | return 0; | |
2117 | } | |
2118 | } | |
2119 | ||
2120 | ############################################################################################################################ | |
2121 | ||
2122 | sub validSave | |
2123 | { | |
2124 | if ( $wiosettings{'IPADR'} eq '' && $wiosettings{'PINGMETHODE'} eq 'ip' && $wiosettings{'DYNDNS'} eq '' ) { | |
2125 | $errormessage = $Lang::tr{'wio_ip_empty'}; | |
2126 | } | |
2127 | ||
2128 | if ( $wiosettings{'IPADR'} ne '' && (! &General::validip($wiosettings{'IPADR'})) ) { | |
2129 | $errormessage = $Lang::tr{'wio_ip_error'}; | |
2130 | } | |
2131 | ||
2132 | if ( $wiosettings{'HOST'} eq '' && $wiosettings{'PINGMETHODE'} eq 'fqdn' ) { | |
2133 | $errormessage = $Lang::tr{'wio_host_empty'}; | |
2134 | } | |
2135 | ||
2136 | if ( $wiosettings{'HOST'} ne '' && (! &General::validdomainname($wiosettings{'HOST'})) ) { | |
2137 | $errormessage = $Lang::tr{'wio_host_error'}; | |
2138 | } | |
2139 | ||
2140 | if ( $wiosettings{'DYNDNS'} eq 'on' && (! defined($errormessage)) ) { | |
2141 | unless(&General::validfqdn($wiosettings{'HOST'})) { $errormessage = $Lang::tr{'wio_fqdn_error'}; } | |
2142 | ( $wiosettings{'IPADR'}, $infomessage ) = &WIO::getdyndnsip($wiosettings{'IPADR'}, $wiosettings{'HOST'}); | |
2143 | $wiosettings{'PINGMETHODE'} = 'fqdn'; | |
2144 | } | |
2145 | ||
2146 | if ( $wiosettings{'ID'} eq '' && ! defined($errormessage) ) { $errormessage = &WIO::checkinto($wiosettings{'IPADR'}, $wiosettings{'HOST'}, @current); } | |
2147 | ||
2148 | if ( $wiosettings{'REMARK'} ne '' ) { $wiosettings{'REMARK'} =~ s/,/,/g; } | |
2149 | } |