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