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