]> git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/ddns.cgi
Merge branch 'master' of ssh://arne_f@git.ipfire.org/pub/git/ipfire-2.x
[ipfire-2.x.git] / html / cgi-bin / ddns.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2011 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 use strict;
23
24 # enable only the following on debugging purpose
25 #use warnings;
26 #use CGI::Carp 'fatalsToBrowser';
27
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31
32 #workaround to suppress a warning when a variable is used only once
33 my @dummy = ( ${Header::table2colour}, ${Header::colouryellow} );
34 undef (@dummy);
35
36 my $ddnsprefix = $Lang::tr{'ddns noip prefix'};
37 $ddnsprefix =~ s/%/$General::noipprefix/;
38
39 my %color = ();
40 my %mainsettings = ();
41 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
42 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
43
44 # Files used
45 my $setting = "${General::swroot}/ddns/settings";
46 our $datafile = "${General::swroot}/ddns/config";
47
48 my %settings=();
49 #Settings1
50 $settings{'BEHINDROUTER'} = 'RED_IP';
51 $settings{'MINIMIZEUPDATES'} = '';
52
53 #Settings2 for editing the multi-line list
54 #Must not be saved !
55 $settings{'HOSTNAME'} = '';
56 $settings{'DOMAIN'} = '';
57 $settings{'LOGIN'} = '';
58 $settings{'PASSWORD'} = '';
59 $settings{'PASSWORD2'} = '';
60 $settings{'ENABLED'} = '';
61 $settings{'PROXY'} = '';
62 $settings{'WILDCARDS'} = '';
63 $settings{'SERVICE'} = '';
64
65 my @nosaved=('HOSTNAME','DOMAIN','LOGIN','PASSWORD','PASSWORD2',
66 'ENABLED','PROXY','WILDCARDS','SERVICE'); # List here ALL setting2 fields. Mandatory
67
68 $settings{'ACTION'} = ''; # add/edit/remove
69 $settings{'KEY1'} = ''; # point record for ACTION
70 $settings{'KEY2'} = ''; # point record for ACTION
71
72 my $errormessage = '';
73 my $warnmessage = '';
74
75 &Header::showhttpheaders();
76
77 #Get GUI values
78 &Header::getcgihash(\%settings);
79
80 # Load multiline data
81 our @current = ();
82 if (open(FILE, "$datafile")) {
83 @current = <FILE>;
84 close (FILE);
85 }
86
87 #
88 # Check Settings1 first because they are needed before working on @current
89 #
90 if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
91 # No user input to check. !
92 #unless ($errormessage) { # Everything is ok, save settings
93 $settings{'BEHINDROUTERWAITLOOP'} = '-1'; # init & will update on next setddns.pl call
94 map (delete ($settings{$_}) ,(@nosaved,'ACTION','KEY1','KEY2'));# Must never be saved
95 &General::writehash($setting, \%settings); # Save good settings
96 $settings{'ACTION'} = $Lang::tr{'save'}; # Recreate 'ACTION'
97 map ($settings{$_}= '',(@nosaved,'KEY1','KEY2')); # and reinit var to empty
98 #}
99 } else {
100 &General::readhash($setting, \%settings); # Get saved settings and reset to good if needed
101 }
102
103 #
104 # Now manipulate the multi-line list with Settings2
105 #
106 # Toggle enable/disable field. Field is in second position
107 if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
108 #move out new line
109 chomp(@current[$settings{'KEY1'}]);
110 my @temp = split(/\,/,@current[$settings{'KEY1'}]);
111 my $K2=$settings{'KEY2'};
112 $temp[ $K2 ] = ( $temp[ $K2 ] eq 'on') ? '' : 'on'; # Toggle the field
113 @current[$settings{'KEY1'}] = join (',',@temp)."\n";
114 $settings{'KEY1'} = ''; # End edit mode
115 &General::log($Lang::tr{'ddns hostname modified'});
116
117 # Write changes to config file.
118 &WriteDataFile; # sort newly added/modified entry
119 }
120
121 if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
122 # Validate inputs
123
124 unless ($settings{'LOGIN'} ne '') {
125 $errormessage = $Lang::tr{'username not set'};
126 }
127
128 # list box returns 'service optional synonyms'
129 # keep only first name
130 $settings{'SERVICE'} =~ s/ .*$//;
131
132 # for freedns.afraid.org, only 'connect string' is mandatory
133 if ($settings{'SERVICE'} ne 'freedns.afraid.org') {
134 unless ($settings{'SERVICE'} eq 'regfish.com' || $settings{'PASSWORD'} ne '') {
135 $errormessage = $Lang::tr{'password not set'};
136 }
137 unless ($settings{'PASSWORD'} eq $settings{'PASSWORD2'}) {
138 $errormessage = $Lang::tr{'passwords do not match'};
139 }
140
141 # Permit an empty HOSTNAME for the nsupdate, regfish, dyndns, enom, ovh, zoneedit, no-ip, easydns
142 unless ($settings{'SERVICE'} eq 'zoneedit.com' || $settings{'SERVICE'} eq 'nsupdate' ||
143 $settings{'SERVICE'} eq 'dyndns-custom'|| $settings{'SERVICE'} eq 'regfish.com' ||
144 $settings{'SERVICE'} eq 'enom.com' || $settings{'SERVICE'} eq 'dnspark.com' ||
145 $settings{'SERVICE'} eq 'ovh.com' || $settings{'HOSTNAME'} ne '' ||
146 $settings{'SERVICE'} eq 'no-ip.com' || $settings{'SERVICE'} eq 'easydns.com' ) {
147 $errormessage = $Lang::tr{'hostname not set'};
148 }
149 unless ($settings{'HOSTNAME'} eq '' || $settings{'HOSTNAME'} =~ /^[a-zA-Z_0-9-]+$/) {
150 $errormessage = $Lang::tr{'invalid hostname'};
151 }
152 unless ($settings{'DOMAIN'} ne '') {
153 $errormessage = $Lang::tr{'domain not set'};
154 }
155 unless ($settings{'DOMAIN'} =~ /^[a-zA-Z_0-9.-]+$/) {
156 $errormessage = $Lang::tr{'invalid domain name'};
157 }
158 unless ($settings{'DOMAIN'} =~ /[.]/) {
159 $errormessage = $Lang::tr{'invalid domain name'};
160 }
161 }
162
163 # recheck service wich don't need too much fields
164 if ($settings{'SERVICE'} eq 'cjb.net') {
165 $errormessage = ''; # clear previous error
166 unless ($settings{'LOGIN'} ne '') {
167 $errormessage = $Lang::tr{'username not set'};
168 }
169 unless ($settings{'PASSWORD'} ne '') {
170 $errormessage = $Lang::tr{'password not set'};
171 }
172 unless ($settings{'PASSWORD'} eq $settings{'PASSWORD2'}) {
173 $errormessage = $Lang::tr{'passwords do not match'};
174 }
175 }
176
177 unless ($errormessage) {
178 if ($settings{'KEY1'} eq '') { #add or edit ?
179 unshift (@current, "$settings{'SERVICE'},$settings{'HOSTNAME'},$settings{'DOMAIN'},$settings{'PROXY'},$settings{'WILDCARDS'},$settings{'LOGIN'},$settings{'PASSWORD'},$settings{'ENABLED'}\n");
180 &General::log($Lang::tr{'ddns hostname added'});
181 } else {
182 @current[$settings{'KEY1'}] = "$settings{'SERVICE'},$settings{'HOSTNAME'},$settings{'DOMAIN'},$settings{'PROXY'},$settings{'WILDCARDS'},$settings{'LOGIN'},$settings{'PASSWORD'},$settings{'ENABLED'}\n";
183 $settings{'KEY1'} = ''; # End edit mode
184 &General::log($Lang::tr{'ddns hostname modified'});
185 }
186 map ($settings{$_}='' ,@nosaved); # Clear fields
187 # Write changes to config file.
188 &WriteDataFile; # sort newly added/modified entry
189 }
190 }
191
192 if ($settings{'ACTION'} eq $Lang::tr{'edit'}) {
193 #move out new line
194 my $line = @current[$settings{'KEY1'}]; # KEY1 is the index in current
195 chomp($line);
196 my @temp = split(/\,/, $line);
197 $settings{'SERVICE'} = $temp[0];
198 $settings{'HOSTNAME'} = $temp[1];
199 $settings{'DOMAIN'} = $temp[2];
200 $settings{'PROXY'} = $temp[3];
201 $settings{'WILDCARDS'} = $temp[4];
202 $settings{'LOGIN'} = $temp[5];
203 $settings{'PASSWORD'} = $settings{'PASSWORD2'} = $temp[6];
204 $settings{'ENABLED'} = $temp[7];
205 }
206
207 if ($settings{'ACTION'} eq $Lang::tr{'remove'}) {
208 splice (@current,$settings{'KEY1'},1); # Delete line
209 open(FILE, ">$datafile") or die 'ddns datafile error';
210 print FILE @current;
211 close(FILE);
212 $settings{'KEY1'} = ''; # End remove mode
213 &General::log($Lang::tr{'ddns hostname removed'});
214 # Write changes to config file.
215 &WriteDataFile;
216 }
217
218 if ($settings{'ACTION'} eq $Lang::tr{'instant update'}) {
219 system('/usr/local/bin/setddns.pl', '-f');
220 }
221
222
223 if ($settings{'ACTION'} eq '')
224 {
225 $settings{'SERVICE'} = 'dyndns.org';
226 $settings{'ENABLED'} = 'on';
227 }
228
229 &Header::openpage($Lang::tr{'dynamic dns'}, 1, '');
230 &Header::openbigbox('100%', 'left', '', $errormessage);
231
232 my %checked =(); # Checkbox manipulations
233 $checked{'SERVICE'}{'cjb.net'} = '';
234 $checked{'SERVICE'}{'dhs.org'} = '';
235 $checked{'SERVICE'}{'dnspark.com'} = '';
236 $checked{'SERVICE'}{'dtdns.com'} = '';
237 $checked{'SERVICE'}{'dyndns.org'} = '';
238 $checked{'SERVICE'}{'dyndns-custom'} = '';
239 $checked{'SERVICE'}{'dyndns-static'} = '';
240 $checked{'SERVICE'}{'dyns.cx'} = '';
241 $checked{'SERVICE'}{'dynu.ca'} = '';
242 $checked{'SERVICE'}{'easydns.com'} = '';
243 $checked{'SERVICE'}{'enom.com'} = '';
244 $checked{'SERVICE'}{'freedns.afraid.org'} = '';
245 $checked{'SERVICE'}{'hn.org'} = '';
246 $checked{'SERVICE'}{'mydyn.de'} = '';
247 $checked{'SERVICE'}{'no-ip.com'} = '';
248 $checked{'SERVICE'}{'nsupdate'} = '';
249 $checked{'SERVICE'}{'ovh.com'} = '';
250 $checked{'SERVICE'}{'regfish.com'} = '';
251 $checked{'SERVICE'}{'selfhost.de'} = '';
252 $checked{'SERVICE'}{'strato.com'} = '';
253 $checked{'SERVICE'}{'tzo.com'} = '';
254 $checked{'SERVICE'}{'zoneedit.com'} = '';
255 $checked{'SERVICE'}{$settings{'SERVICE'}} = "selected='selected'";
256
257 $checked{'BEHINDROUTER'}{'RED_IP'} = '';
258 $checked{'BEHINDROUTER'}{'FETCH_IP'} = '';
259 $checked{'BEHINDROUTER'}{$settings{'BEHINDROUTER'}} = "checked='checked'";
260 $checked{'MINIMIZEUPDATES'} = ($settings{'MINIMIZEUPDATES'} eq '' ) ? '' : "checked='checked'";
261
262 $checked{'PROXY'}{'on'} = ($settings{'PROXY'} eq '') ? '' : "checked='checked'";
263 $checked{'WILDCARDS'}{'on'} = ($settings{'WILDCARDS'} eq '') ? '' : "checked='checked'";
264 $checked{'ENABLED'}{'on'} = ($settings{'ENABLED'} eq '' ) ? '' : "checked='checked'";
265
266 if ($errormessage) {
267 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
268 print "<font class='base'>$errormessage&nbsp;</font>";
269 &Header::closebox();
270 }
271
272 if ($warnmessage) {
273 $warnmessage = "<font color=${Header::colourred}><b>$Lang::tr{'capswarning'}</b></font>: $warnmessage";
274 }
275 &Header::openbox('100%', 'left', $Lang::tr{'settings'});
276 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
277 print <<END
278 <table width='100%'>
279 <tr>
280 <td class='base'>$Lang::tr{'dyn dns source choice'}</td>
281 </tr><tr>
282 <td class='base'><input type='radio' name='BEHINDROUTER' value='RED_IP' $checked{'BEHINDROUTER'}{'RED_IP'} />
283 $Lang::tr{'use ipfire red ip'}</td>
284 </tr><tr>
285 <td class='base'><input type='radio' name='BEHINDROUTER' value='FETCH_IP' $checked{'BEHINDROUTER'}{'FETCH_IP'} />
286 $Lang::tr{'fetch ip from'} <img src='/blob.gif' alt='*' /></td>
287 </tr>
288 <tr>
289 <td class='base'><input type='checkbox' name='MINIMIZEUPDATES' $checked{'MINIMIZEUPDATES'} />
290 $Lang::tr{'ddns minimize updates'}</td>
291 </tr>
292 </table>
293 <br /><hr />
294 END
295 ;
296
297 print <<END
298 <table width='100%'>
299 <tr>
300 <td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
301 <td width='70%' class='base'>$Lang::tr{'avoid dod'}</td>
302 <td width='30%' align='center' class='base'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
303 </tr>
304 </table>
305 </form>
306 END
307 ;
308 &Header::closebox(); # end of Settings1
309
310
311 my $buttontext = $Lang::tr{'add'};
312 if ($settings{'KEY1'} ne '') {
313 $buttontext = $Lang::tr{'update'};
314 &Header::openbox('100%', 'left', $Lang::tr{'edit an existing host'});
315 } else {
316 &Header::openbox('100%', 'left', $Lang::tr{'add a host'});
317 }
318
319 #Edited line number (KEY1) passed until cleared by 'save' or 'remove'
320 print <<END
321 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
322 <input type='hidden' name='KEY1' value='$settings{'KEY1'}' />
323 <table width='100%'>
324 <tr>
325 <td width='25%' class='base'>$Lang::tr{'service'}:</td>
326 <td width='25%'><select size='1' name='SERVICE'>
327 <option $checked{'SERVICE'}{'cjb.net'}>cjb.net</option>
328 <option $checked{'SERVICE'}{'dhs.org'}>dhs.org</option>
329 <option $checked{'SERVICE'}{'dnspark.com'}>dnspark.com</option>
330 <option $checked{'SERVICE'}{'dtdns.com'}>dtdns.com</option>
331 <option $checked{'SERVICE'}{'dyndns.org'}>dyndns.org</option>
332 <option $checked{'SERVICE'}{'dyndns-custom'}>dyndns-custom</option>
333 <option $checked{'SERVICE'}{'dyndns-static'}>dyndns-static</option>
334 <option $checked{'SERVICE'}{'dyns.cx'}>dyns.cx</option>
335 <option $checked{'SERVICE'}{'dynu.ca'}>dynu.ca dyn.ee dynserv.(ca|org|net|com)</option>
336 <option $checked{'SERVICE'}{'easydns.com'}>easydns.com</option>
337 <option $checked{'SERVICE'}{'enom.com'}>enom.com</option>
338 <option $checked{'SERVICE'}{'freedns.afraid.org'}>freedns.afraid.org</option>
339 <option $checked{'SERVICE'}{'hn.org'}>hn.org</option>
340 <option $checked{'SERVICE'}{'mydyn.de'}>mydyn.de</option>
341 <option $checked{'SERVICE'}{'no-ip.com'}>no-ip.com</option>
342 <option $checked{'SERVICE'}{'nsupdate'}>nsupdate</option>
343 <option $checked{'SERVICE'}{'ovh.com'}>ovh.com</option>
344 <option $checked{'SERVICE'}{'regfish.com'}>regfish.com</option>
345 <option $checked{'SERVICE'}{'selfhost.de'}>selfhost.de</option>
346 <option $checked{'SERVICE'}{'strato.com'}>strato.com</option>
347 <!-- <option $checked{'SERVICE'}{'tzo.com'}>tzo.com</option> comment this service out until a working fix is developed -->
348 <option $checked{'SERVICE'}{'zoneedit.com'}>zoneedit.com</option>
349 </select></td>
350 <td width='20%' class='base'>$Lang::tr{'hostname'}:&nbsp;<img src='/blob.gif' alt='*' /></td>
351 <td width='30%'><input type='text' name='HOSTNAME' value='$settings{'HOSTNAME'}' /></td>
352 </tr><tr>
353 <td class='base'>$Lang::tr{'behind a proxy'}</td>
354 <td><input type='checkbox' name='PROXY' value='on' $checked{'PROXY'}{'on'} /></td>
355 <td class='base'>$Lang::tr{'domain'}:</td>
356 <td><input type='text' name='DOMAIN' value='$settings{'DOMAIN'}' /></td>
357 </tr><tr>
358 <td class='base'>$Lang::tr{'enable wildcards'}</td>
359 <td><input type='checkbox' name='WILDCARDS' value='on' $checked{'WILDCARDS'}{'on'} /></td>
360 <td class='base'>$Lang::tr{'username'}</td>
361 <td><input type='text' name='LOGIN' value='$settings{'LOGIN'}' /></td>
362 </tr><tr>
363 <td></td>
364 <td></td>
365 <td class='base'>$Lang::tr{'password'}</td>
366 <td><input type='password' name='PASSWORD' value='$settings{'PASSWORD'}' /></td>
367 </tr><tr>
368 <td class='base'>$Lang::tr{'enabled'}</td>
369 <td><input type='checkbox' name='ENABLED' value='on' $checked{'ENABLED'}{'on'} /></td>
370 <td class='base'>$Lang::tr{'again'}</td>
371 <td><input type='password' name='PASSWORD2' value='$settings{'PASSWORD2'}' /></td>
372 </tr>
373 </table>
374 <hr />
375 <table width='100%'>
376 <tr>
377 <td class='base' valign='top'><img src='/blob.gif' alt='*' /></td>
378 <td width='70%' class='base'>$ddnsprefix</td>
379
380 <td width='30%' align='center' class='base'>
381 <input type='hidden' name='ACTION' value='$Lang::tr{'add'}' />
382 <input type='submit' name='SUBMIT' value='$buttontext' /> </td>
383 </tr>
384 </table>
385 </form>
386 END
387 ;
388 &Header::closebox();
389
390 #
391 # Third box shows the list, in columns
392 #
393 &Header::openbox('100%', 'left', $Lang::tr{'current hosts'});
394 print <<END
395 <table width='100%'>
396 <tr>
397 <td width='15%' align='center' class='boldbase'><b>$Lang::tr{'service'}</b></td>
398 <td width='25%' align='center' class='boldbase'><b>$Lang::tr{'hostname'}</b></td>
399 <td width='30%' align='center' class='boldbase'><b>$Lang::tr{'domain'}</b></td>
400 <td width='10%' align='center' class='boldbase'><b>$Lang::tr{'proxy'}</b></td>
401 <td width='10%' align='center' class='boldbase'><b>$Lang::tr{'wildcards'}</b></td>
402 <td width='10%' colspan='3' class='boldbase' align='center'><b>$Lang::tr{'action'}</b></td>
403 </tr>
404 END
405 ;
406 my $ip = &General::GetDyndnsRedIP;
407 my $key = 0;
408 foreach my $line (@current) {
409 chomp($line); # remove newline
410 my @temp = split(/\,/,$line);
411
412 if ($temp[0] eq 'no-ip.com') {
413 $temp[1] =~ s!$General::noipprefix(.*)!<b>group:</b>$1 !;
414 }
415
416 #Choose icon for checkbox
417
418 my $gifproxy='';
419 my $descproxy='';
420 if ($temp[3] eq "on") {
421 $gifproxy = 'on.gif';
422 $descproxy = $Lang::tr{'click to disable'};
423 } else {
424 $gifproxy = 'off.gif';
425 $descproxy = $Lang::tr{'click to enable'};
426 }
427
428 my $gifwildcard='';
429 my $descwildcard='';
430 if ($temp[4] eq "on") {
431 $gifwildcard = 'on.gif';
432 $descwildcard = $Lang::tr{'click to disable'};
433 } else {
434 $gifwildcard = 'off.gif';
435 $descwildcard = $Lang::tr{'click to enable'};
436 }
437
438 my $sync = "<font color='blue'>";
439 my $gif = '';
440 my $gdesc = '';
441 if ($temp[7] eq "on") {
442 $gif = 'on.gif';
443 $gdesc = $Lang::tr{'click to disable'};
444 $sync = (&General::DyndnsServiceSync ($ip,$temp[1], $temp[2]) ? "<font color='green'>": "<font color='red'>") ;
445 } else {
446 $gif = 'off.gif';
447 $gdesc = $Lang::tr{'click to enable'};
448 }
449
450 #Colorize each line
451 if ($settings{'KEY1'} eq $key) {
452 print "<tr bgcolor='${Header::colouryellow}'>";
453 } elsif ($key % 2) {
454 print "<tr bgcolor='$color{'color22'}'>";
455 } else {
456 print "<tr bgcolor='$color{'color20'}'>";
457 }
458
459 #if a field is empty, replace it with a '---' to see colorized info!
460 $temp[1] = '---' if (!$temp[1]);
461 $temp[2] = '---' if (!$temp[2]);
462
463 print <<END
464 <td align='center'><a href='http://$temp[0]'>$temp[0]</a></td>
465 <td align='center'>$sync$temp[1]</td>
466 <td align='center'>$sync$temp[2]</td>
467
468 <td align='center'>
469 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
470 <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
471 <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gifproxy' alt='$descproxy' title='$descproxy' />
472 <input type='hidden' name='KEY1' value='$key' />
473 <input type='hidden' name='KEY2' value='3' />
474 </form>
475 </td>
476
477 <td align='center'>
478 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
479 <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
480 <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gifwildcard' alt='$descwildcard' title='$descwildcard' />
481 <input type='hidden' name='KEY1' value='$key' />
482 <input type='hidden' name='KEY2' value='4' />
483 </form>
484 </td>
485
486 <td align='center'>
487 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
488 <input type='hidden' name='ACTION' value='$Lang::tr{'toggle enable disable'}' />
489 <input type='image' name='$Lang::tr{'toggle enable disable'}' src='/images/$gif' alt='$gdesc' title='$gdesc' />
490 <input type='hidden' name='KEY1' value='$key' />
491 <input type='hidden' name='KEY2' value='7' />
492 </form>
493 </td>
494
495 <td align='center'>
496 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
497 <input type='hidden' name='ACTION' value='$Lang::tr{'edit'}' />
498 <input type='image' name='$Lang::tr{'edit'}' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
499 <input type='hidden' name='KEY1' value='$key' />
500 </form>
501 </td>
502
503 <td align='center'>
504 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
505 <input type='hidden' name='ACTION' value='$Lang::tr{'remove'}' />
506 <input type='image' name='$Lang::tr{'remove'}' src='/images/delete.gif' alt='$Lang::tr{'remove'}' title='$Lang::tr{'remove'}' />
507 <input type='hidden' name='KEY1' value='$key' />
508 </form>
509 </td>
510 </tr>
511 END
512 ;
513 $key++;
514 }
515 print "</table>";
516
517 # If table contains entries, print 'Key to action icons'
518 if ($key) {
519 print <<END
520 <table width='100%'>
521 <tr>
522 <td class='boldbase'>&nbsp;<b>$Lang::tr{'legend'}:&nbsp;</b></td>
523 <td><img src='/images/on.gif' alt='$Lang::tr{'click to disable'}' /></td>
524 <td class='base'>$Lang::tr{'click to disable'}</td>
525 <td>&nbsp;&nbsp;</td>
526 <td><img src='/images/off.gif' alt='$Lang::tr{'click to enable'}' /></td>
527 <td class='base'>$Lang::tr{'click to enable'}</td>
528 <td>&nbsp;&nbsp;</td>
529 <td><img src='/images/edit.gif' alt='$Lang::tr{'edit'}' /></td>
530 <td class='base'>$Lang::tr{'edit'}</td>
531 <td>&nbsp;&nbsp;</td>
532 <td><img src='/images/delete.gif' alt='$Lang::tr{'remove'}' /></td>
533 <td class='base'>$Lang::tr{'remove'}</td>
534 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
535 <td align='center' width='30%'><input type='submit' name='ACTION' value='$Lang::tr{'instant update'}' /></td>
536 </form>
537 </tr>
538 </table>
539 END
540 ;
541 }
542
543 &Header::closebox();
544 &Header::closebigbox();
545 &Header::closepage();
546
547 ## Ouf it's the end !
548
549
550 # write the "current" array
551 sub WriteDataFile {
552 #Save current
553 open(FILE, ">$datafile") or die 'ddns datafile error';
554 print FILE @current;
555 close (FILE);
556 }