529061bf6a732ae1d18adb081f5652529ae9151e
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / updatexlrator.cgi
1 #!/usr/bin/perl
2 #
3 # IPCop CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) 2006 marco.s
8 #
9 # $Id: updatexlrator.cgi,v 1.0.0 2006/09/12 00:00:00 marco.s 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 use IO::Socket;
19
20 require '/var/ipfire/general-functions.pl';
21 require "${General::swroot}/lang.pl";
22 require "${General::swroot}/header.pl";
23
24 my $updxlratorversion = `cat ${General::swroot}/updatexlrator/version`;
25 my $sysupdflagfile = "${General::swroot}/updatexlrator/.up2date";
26
27 my %checked=();
28 my %selected=();
29 my %netsettings=();
30 my %mainsettings=();
31 my %proxysettings=();
32 my %xlratorsettings=();
33 my $id=0;
34 my $updatefile='';
35 my $shortname='';
36 my $vendor='';
37 my $time='';
38 my $filesize=0;
39 my $filedate='';
40 my $lastaccess='';
41 my $lastcheck='';
42
43 my $repository = "/srv/web/ipfire/html/updatecache";
44 my $hintcolour = '#FFFFCC';
45
46 my $sfNoSource='0';
47 my $sfOk='1';
48 my $sfOutdated='2';
49
50 my $not_accessed_last='';
51
52 my $errormessage='';
53
54 my @repositorylist=();
55 my @repositoryfiles=();
56
57 my @metadata=();
58
59 my $chk_cron_dly = "${General::swroot}/updatexlrator/autocheck/cron.daily";
60 my $chk_cron_wly = "${General::swroot}/updatexlrator/autocheck/cron.weekly";
61 my $chk_cron_mly = "${General::swroot}/updatexlrator/autocheck/cron.monthly";
62
63 my $latest=substr(&check4updates,0,length($updxlratorversion));
64
65 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
66 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
67 &General::readhash("${General::swroot}/proxy/settings", \%proxysettings);
68
69 $xlratorsettings{'ACTION'} = '';
70 $xlratorsettings{'ENABLE_LOG'} = 'off';
71 $xlratorsettings{'CHILDREN'} = '5';
72 $xlratorsettings{'PASSIVE_MODE'} = 'off';
73 $xlratorsettings{'MAX_DISK_USAGE'} = '75';
74 $xlratorsettings{'LOW_DOWNLOAD_PRIORITY'} = 'off';
75 $xlratorsettings{'ENABLE_AUTOCHECK'} = 'off';
76 $xlratorsettings{'FULL_AUTOSYNC'} = 'off';
77 $xlratorsettings{'NOT_ACCESSED_LAST'} = 'month1';
78
79 &Header::getcgihash(\%xlratorsettings);
80
81 if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr purge'})
82 {
83 if (($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on') || ($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') || ($xlratorsettings{'REMOVE_OUTDATED'} eq 'on'))
84 {
85 @repositorylist = <$repository/*>;
86 foreach (@repositorylist)
87 {
88 if (!-d $_)
89 {
90 $updatefile = substr($_,rindex($_,"/")+1);
91 if (-e "$repository/metadata/$updatefile")
92 {
93 open (FILE,"$repository/metadata/$updatefile");
94 @metadata = <FILE>;
95 close FILE;
96 chomp(@metadata);
97
98 if (($xlratorsettings{'REMOVE_NOSOURCE'} eq 'on') && ($metadata[2] == $sfNoSource))
99 {
100 unlink("$repository/$updatefile");
101 unlink("$repository/metadata/$updatefile");
102 }
103 if (($xlratorsettings{'REMOVE_OUTDATED'} eq 'on') && ($metadata[2] == $sfOutdated))
104 {
105 unlink("$repository/$updatefile");
106 unlink("$repository/metadata/$updatefile");
107 }
108 if ($xlratorsettings{'REMOVE_OBSOLETE'} eq 'on')
109 {
110 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'week') && ($metadata[-1] < (time - 604800)))
111 {
112 unlink("$repository/$updatefile");
113 unlink("$repository/metadata/$updatefile");
114 }
115 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month1') && ($metadata[-1] < (time - 2505600)))
116 {
117 unlink("$repository/$updatefile");
118 unlink("$repository/metadata/$updatefile");
119 }
120 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month3') && ($metadata[-1] < (time - 7516800)))
121 {
122 unlink("$repository/$updatefile");
123 unlink("$repository/metadata/$updatefile");
124 }
125 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'month6') && ($metadata[-1] < (time - 15033600)))
126 {
127 unlink("$repository/$updatefile");
128 unlink("$repository/metadata/$updatefile");
129 }
130 if (($xlratorsettings{'NOT_ACCESSED_LAST'} eq 'year') && ($metadata[-1] < (time - 31536000)))
131 {
132 unlink("$repository/$updatefile");
133 unlink("$repository/metadata/$updatefile");
134 }
135 }
136 }
137 }
138 }
139 }
140 }
141
142 if ($xlratorsettings{'ACTION'} eq $Lang::tr{'save'})
143 {
144 if (!($xlratorsettings{'CHILDREN'} =~ /^\d+$/) || ($xlratorsettings{'CHILDREN'} < 1))
145 {
146 $errormessage = $Lang::tr{'updxlrtr invalid num of children'};
147 goto ERROR;
148 }
149 if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/) || ($xlratorsettings{'MAX_DISK_USAGE'} < 1) || ($xlratorsettings{'MAX_DISK_USAGE'} > 100))
150 {
151 $errormessage = $Lang::tr{'updxlrtr invalid disk usage'};
152 goto ERROR;
153 }
154
155 &savesettings;
156 }
157
158 if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr save and restart'})
159 {
160 if (!($xlratorsettings{'CHILDREN'} =~ /^\d+$/) || ($xlratorsettings{'CHILDREN'} < 1))
161 {
162 $errormessage = $Lang::tr{'updxlrtr invalid num of children'};
163 goto ERROR;
164 }
165 if (!($xlratorsettings{'MAX_DISK_USAGE'} =~ /^\d+$/) || ($xlratorsettings{'MAX_DISK_USAGE'} < 1) || ($xlratorsettings{'MAX_DISK_USAGE'} > 100))
166 {
167 $errormessage = $Lang::tr{'updxlrtr invalid disk usage'};
168 goto ERROR;
169 }
170 if (!(-e "${General::swroot}/proxy/enable"))
171 {
172 $errormessage = $Lang::tr{'updxlrtr web proxy service required'};
173 goto ERROR;
174 }
175 if (!($proxysettings{'ENABLE_UPDXLRATOR'} eq 'on'))
176 {
177 $errormessage = $Lang::tr{'updxlrtr not enabled'};
178 goto ERROR;
179 }
180
181 &savesettings;
182
183 system('/usr/local/bin/restartsquid');
184 }
185
186 if ($xlratorsettings{'ACTION'} eq $Lang::tr{'updxlrtr remove file'})
187 {
188 $updatefile = $xlratorsettings{'ID'};
189 if (-e "$repository/$updatefile") { unlink("$repository/$updatefile"); }
190 $updatefile =~ s/^download\///i;
191 if (-e "$repository/metadata/$updatefile") { unlink("$repository/metadata/$updatefile"); }
192 }
193
194 ERROR:
195
196 $not_accessed_last = $xlratorsettings{'NOT_ACCESSED_LAST'};
197 undef($xlratorsettings{'NOT_ACCESSED_LAST'});
198
199 if (-e "${General::swroot}/updatexlrator/settings") { &General::readhash("${General::swroot}/updatexlrator/settings", \%xlratorsettings); }
200
201 if ($xlratorsettings{'NOT_ACCESSED_LAST'} eq '') { $xlratorsettings{'NOT_ACCESSED_LAST'} = $not_accessed_last; } ;
202
203
204 $checked{'ENABLE_LOG'}{'off'} = '';
205 $checked{'ENABLE_LOG'}{'on'} = '';
206 $checked{'ENABLE_LOG'}{$xlratorsettings{'ENABLE_LOG'}} = "checked='checked'";
207 $checked{'PASSIVE_MODE'}{'off'} = '';
208 $checked{'PASSIVE_MODE'}{'on'} = '';
209 $checked{'PASSIVE_MODE'}{$xlratorsettings{'PASSIVE_MODE'}} = "checked='checked'";
210 $checked{'LOW_DOWNLOAD_PRIORITY'}{'off'} = '';
211 $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} = '';
212 $checked{'LOW_DOWNLOAD_PRIORITY'}{$xlratorsettings{'LOW_DOWNLOAD_PRIORITY'}} = "checked='checked'";
213 $checked{'ENABLE_AUTOCHECK'}{'off'} = '';
214 $checked{'ENABLE_AUTOCHECK'}{'on'} = '';
215 $checked{'ENABLE_AUTOCHECK'}{$xlratorsettings{'ENABLE_AUTOCHECK'}} = "checked='checked'";
216 $checked{'FULL_AUTOSYNC'}{'off'} = '';
217 $checked{'FULL_AUTOSYNC'}{'on'} = '';
218 $checked{'FULL_AUTOSYNC'}{$xlratorsettings{'FULL_AUTOSYNC'}} = "checked='checked'";
219
220 $selected{'AUTOCHECK_SCHEDULE'}{$xlratorsettings{'AUTOCHECK_SCHEDULE'}} = "selected='selected'";
221 $selected{'NOT_ACCESSED_LAST'}{$xlratorsettings{'NOT_ACCESSED_LAST'}} = "selected='selected'";
222
223 # ----------------------------------------------------
224 # Settings dialog
225 # ----------------------------------------------------
226
227 &Header::showhttpheaders();
228
229 &Header::openpage($Lang::tr{'updxlrtr configuration'}, 1, '');
230
231 &Header::openbigbox('100%', 'left', '', $errormessage);
232
233 if ($errormessage) {
234 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
235 print "<font class='base'>$errormessage&nbsp;</font>\n";
236 &Header::closebox();
237 }
238
239 if (($updxlratorversion lt $latest) && (-e $sysupdflagfile)) { unlink($sysupdflagfile); }
240
241 if (!-e $sysupdflagfile) {
242 &Header::openbox('100%', 'left', $Lang::tr{'updxlrtr update notification'});
243 print "<table width='100%' cellpadding='5'>\n";
244 print "<tr>\n";
245 print "<td bgcolor='$hintcolour' class='base'>$Lang::tr{'updxlrtr update information'}</td>";
246 print "</tr>\n";
247 print "</table>\n";
248 &Header::closebox();
249 }
250
251 print "<form method='post' action='$ENV{'SCRIPT_NAME'}' enctype='multipart/form-data'>\n";
252
253 &Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr update accelerator'}");
254
255 print <<END
256 <table width='100%'>
257 <tr>
258 <td colspan='4'><b>$Lang::tr{'updxlrtr common settings'}</b></td>
259 </tr>
260 <tr>
261 <td class='base' width='25%'>$Lang::tr{'updxlrtr enable log'}:</td>
262 <td class='base' width='20%'><input type='checkbox' name='ENABLE_LOG' $checked{'ENABLE_LOG'}{'on'} /></td>
263 <td class='base' width='25%'>$Lang::tr{'updxlrtr children'}:</td>
264 <td class='base' width='30%'><input type='text' name='CHILDREN' value='$xlratorsettings{'CHILDREN'}' size='5' /></td>
265 </tr>
266 <tr>
267 <td class='base'>$Lang::tr{'updxlrtr passive mode'}:</td>
268 <td class='base'><input type='checkbox' name='PASSIVE_MODE' $checked{'PASSIVE_MODE'}{'on'} /></td>
269 <td class='base'>$Lang::tr{'updxlrtr max disk usage'}:</td>
270 <td class='base'><input type='text' name='MAX_DISK_USAGE' value='$xlratorsettings{'MAX_DISK_USAGE'}' size='1' /> %</td>
271 </tr>
272 <tr>
273 <td class='base'>$Lang::tr{'updxlrtr low download priority'}:</td>
274 <td class='base'><input type='checkbox' name='LOW_DOWNLOAD_PRIORITY' $checked{'LOW_DOWNLOAD_PRIORITY'}{'on'} /></td>
275 <td>&nbsp;</td>
276 <td>&nbsp;</td>
277 </tr>
278 </table>
279 <hr size='1'>
280 <table width='100%'>
281 <tr>
282 <td colspan='4'><b>$Lang::tr{'updxlrtr source checkup'}</b></td>
283 </tr>
284 <tr>
285 <td class='base' width='25%'>$Lang::tr{'updxlrtr enable autocheck'}:</td>
286 <td class='base' width='20%'><input type='checkbox' name='ENABLE_AUTOCHECK' $checked{'ENABLE_AUTOCHECK'}{'on'} /></td>
287 <td class='base' width='25%'>$Lang::tr{'updxlrtr source checkup schedule'}:</td>
288 <td class='base' width='30%'>
289 <select name='AUTOCHECK_SCHEDULE'>
290 <option value='daily' $selected{'AUTOCHECK_SCHEDULE'}{'daily'}>$Lang::tr{'updxlrtr daily'}</option>
291 <option value='weekly' $selected{'AUTOCHECK_SCHEDULE'}{'weekly'}>$Lang::tr{'updxlrtr weekly'}</option>
292 <option value='monthly' $selected{'AUTOCHECK_SCHEDULE'}{'monthly'}>$Lang::tr{'updxlrtr monthly'}</option>
293 </select>
294 </td>
295 </tr>
296 <tr>
297 <td class='base'>$Lang::tr{'updxlrtr full autosync'}:</td>
298 <td class='base'><input type='checkbox' name='FULL_AUTOSYNC' $checked{'FULL_AUTOSYNC'}{'on'} /></td>
299 <td>&nbsp;</td>
300 <td>&nbsp;</td>
301 </tr>
302 </table>
303 <hr size='1'>
304 <table width='100%'>
305 <tr>
306 <td colspan='6'><b>$Lang::tr{'updxlrtr maintenance'}</b></td>
307 </tr>
308 <tr>
309 <td class='base' colspan='3'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr purge'}' /> &nbsp;$Lang::tr{'updxlrtr all files'}</td>
310 <td class='base' width='25%'><input type='checkbox' name='REMOVE_OBSOLETE' $checked{'REMOVE_OBSOLETE'}{'on'} />&nbsp;$Lang::tr{'updxlrtr not accessed'}</td>
311 <td class='base' colspan='3'><select name='NOT_ACCESSED_LAST'>
312 <option value='week' $selected{'NOT_ACCESSED_LAST'}{'week'}>$Lang::tr{'updxlrtr week'}</option>
313 <option value='month1' $selected{'NOT_ACCESSED_LAST'}{'month1'}>$Lang::tr{'updxlrtr month'}</option>
314 <option value='month3' $selected{'NOT_ACCESSED_LAST'}{'month3'}>$Lang::tr{'updxlrtr 3 months'}</option>
315 <option value='month6' $selected{'NOT_ACCESSED_LAST'}{'month6'}>$Lang::tr{'updxlrtr 6 months'}</option>
316 <option value='year' $selected{'NOT_ACCESSED_LAST'}{'year'}>$Lang::tr{'updxlrtr year'}</option>
317 </select>
318 </td>
319 </tr>
320 <tr>
321 </tr>
322 <tr>
323 <td class='base' width='25%'><input type='checkbox' name='REMOVE_NOSOURCE' $checked{'REMOVE_NOSOURCE'}{'on'} />&nbsp;$Lang::tr{'updxlrtr marked as'}</td>
324 <td class='base' width='3%'><img src='/images/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
325 <td class='base' width='17%'>[<i>$Lang::tr{'updxlrtr condition nosource'}</i>]</td>
326 <td class='base' width='25%'><input type='checkbox' name='REMOVE_OUTDATED' $checked{'REMOVE_OUTDATED'}{'on'} />&nbsp;$Lang::tr{'updxlrtr marked as'}</td>
327 <td class='base' width='3%'><img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
328 <td class='base' width='27%'>[<i>$Lang::tr{'updxlrtr condition outdated'}</i>]</td>
329 </tr>
330 </table>
331 <hr size='1'>
332 <table width='100%'>
333 <tr>
334 <td>&nbsp;</td>
335 <td align='center' width='45%'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td>
336 <td align='center' width='45%'><input type='submit' name='ACTION' value='$Lang::tr{'updxlrtr save and restart'}' /></td>
337 <td>&nbsp;</td>
338 </tr>
339 </table>
340 <table width='100%'>
341 <tr>
342 <td align='right'>
343 <sup><small><a href='http://www.advproxy.net/update-accelerator/' target='_blank'>Update Accelerator $updxlratorversion</a></small></sup>
344 </td>
345 </tr>
346 </table>
347 END
348 ;
349
350 &Header::closebox();
351
352 print "</form>\n";
353
354 # ----------------------------------------------------
355 # File list dialog
356 # ----------------------------------------------------
357
358 &Header::openbox('100%', 'left', "$Lang::tr{'updxlrtr current files'}:");
359
360 @repositorylist = <$repository/download/*>;
361
362 undef @repositoryfiles;
363 foreach (@repositorylist)
364 {
365 if (!-d)
366 {
367 $updatefile = substr($_,rindex($_,"/")+1);
368 $updatefile = "download/$updatefile";
369 push(@repositoryfiles,$updatefile);
370 }
371 }
372
373 @repositorylist = <$repository/*>;
374
375 foreach (@repositorylist)
376 {
377 if (!-d) { push(@repositoryfiles,substr($_,rindex($_,"/")+1)); }
378 }
379
380 if (@repositoryfiles)
381 {
382 print <<END
383 <table width='100%'>
384 <colgroup span='2' width='2%'></colgroup>
385 <colgroup span='1' width='0*'></colgroup>
386 <colgroup span='4' width='5%'></colgroup>
387 <colgroup span='1' width='2%'></colgroup>
388 <tr>
389 <td class='base' align='center'>&nbsp;</td>
390 <td class='base' align='center'>&nbsp;</td>
391 <td class='base' align='center'><b>$Lang::tr{'updxlrtr filename'}</b></td>
392 <td class='base' align='center'><b>$Lang::tr{'updxlrtr filesize'}</b></td>
393 <td class='base' align='center'><b>$Lang::tr{'date'}</b></td>
394 <td class='base' align='center'><img src='/images/reload.gif' alt='$Lang::tr{'updxlrtr last access'}' /></td>
395 <td class='base' align='center'><img src='/images/floppy.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
396 <td class='base' align='center'>&nbsp;</td>
397 </tr>
398 END
399 ;
400 $id = 0;
401 foreach $updatefile (@repositoryfiles)
402 {
403 $id++;
404 if ($id % 2) {
405 print "<tr bgcolor='$Header::table1colour'>\n"; }
406 else {
407 print "<tr bgcolor='$Header::table2colour'>\n"; }
408 $filesize = (-s "$repository/$updatefile");
409 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;
410
411 my ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime(&getmtime("$repository/$updatefile"));
412 $DAYdt = sprintf ("%.02d",$DAYdt);
413 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
414 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
415 $filedate = $YEARdt."-".$MONTHdt."-".$DAYdt;
416
417 $lastaccess = "n/a";
418 $lastcheck = "n/a";
419 undef @metadata;
420
421 $shortname = $updatefile;
422 $shortname =~ s/^download\///i;
423
424 if (-e "$repository/metadata/$shortname")
425 {
426 open (FILE,"$repository/metadata/$shortname");
427 @metadata = <FILE>;
428 close(FILE);
429 chomp @metadata;
430
431 ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[-1]);
432 $DAYdt = sprintf ("%.02d",$DAYdt);
433 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
434 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
435 if (($metadata[-1] =~ /^\d+/) && ($metadata[-1] >= 1)) { $lastaccess = $YEARdt."-".$MONTHdt."-".$DAYdt; }
436
437 ($SECdt,$MINdt,$HOURdt,$DAYdt,$MONTHdt,$YEARdt) = localtime($metadata[3]);
438 $DAYdt = sprintf ("%.02d",$DAYdt);
439 $MONTHdt = sprintf ("%.02d",$MONTHdt+1);
440 $YEARdt = sprintf ("%.04d",$YEARdt+1900);
441 if (($metadata[3] =~ /^\d+/) && ($metadata[3] >= 1)) { $lastcheck = $YEARdt."-".$MONTHdt."-".$DAYdt; }
442 }
443
444 print "\t\t<td align='center' nowrap='nowrap'>&nbsp;";
445 if ($metadata[2] eq $sfNoSource)
446 {
447 print "<img src='/images/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' />&nbsp;</td>\n";
448 }
449 if ($metadata[2] eq $sfOk)
450 {
451 print "<img src='/images/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' />&nbsp;</td>\n";
452 }
453 if (($metadata[2] eq $sfOutdated) && (!($updatefile =~ /^download\//i)))
454 {
455 print "<img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' />&nbsp;</td>\n";
456 }
457 if (($metadata[2] eq $sfOutdated) && ($updatefile =~ /^download\//i))
458 {
459 print "<img src='/images/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' />&nbsp;</td>\n";
460 }
461 if ($metadata[2] eq '')
462 {
463 print "<img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' />&nbsp;</td>\n";
464 }
465
466 print "\t\t<td align='center' nowrap='nowrap'>&nbsp;";
467 if ($metadata[1] eq 'Adobe')
468 {
469 print "<img src='/images/updxl-src-adobe.gif' alt='Adobe'}' />&nbsp;</td>\n";
470 } elsif ($metadata[1] eq 'Microsoft')
471 {
472 print "<img src='/images/updxl-src-windows.gif' alt='Microsoft'}' />&nbsp;</td>\n";
473 } elsif ($metadata[1] eq 'Symantec')
474 {
475 print "<img src='/images/updxl-src-symantec.gif' alt='Symantec'}' />&nbsp;</td>\n";
476 } else
477 {
478 print "<img src='/images/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr unknown'}' />&nbsp;</td>\n";
479 }
480
481 $shortname = $updatefile;
482 $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/\1_*\2/i;
483 $shortname =~ s/^download\///i;
484
485 print <<END
486 <td class='base' align='left' title='$updatefile'>$shortname</td>
487 <td class='base' align='right' nowrap='nowrap'>&nbsp;$filesize&nbsp;</td>
488 <td class='base' align='center' nowrap='nowrap'>&nbsp;$filedate&nbsp;</td>
489 <td class='base' align='center' nowrap='nowrap'>&nbsp;$lastaccess&nbsp;</td>
490 <td class='base' align='center' nowrap='nowrap'>&nbsp;$lastcheck&nbsp;</td>
491 <td align='center'>
492 <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'>
493 <input type='image' name='$Lang::tr{'updxlrtr remove file'}' src='/images/delete.gif' title='$Lang::tr{'updxlrtr remove file'}' alt='$Lang::tr{'updxlrtr remove file'}' />
494 <input type='hidden' name='ID' value='$updatefile' />
495 <input type='hidden' name='ACTION' value='$Lang::tr{'updxlrtr remove file'}' />
496 </form>
497 </td>
498 </tr>
499 END
500 ;
501 }
502
503 print <<END
504 </table>
505 <br>
506 <table>
507 <tr>
508 <td class='boldbase'>&nbsp; <b>$Lang::tr{'legend'}:</b></td>
509 <td class='base'>&nbsp;</td>
510 <td><img src='/images/reload.gif' alt='$Lang::tr{'updxlrtr last access'}' /></td>
511 <td class='base'>$Lang::tr{'updxlrtr last access'}</td>
512 <td class='base'>&nbsp;</td>
513 <td><img src='/images/floppy.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td>
514 <td class='base'>$Lang::tr{'updxlrtr last checkup'}</td>
515 <td class='base'>&nbsp;</td>
516 <td><img src='/images/delete.gif' alt='$Lang::tr{'updxlrtr remove file'}' /></td>
517 <td class='base'>$Lang::tr{'updxlrtr remove file'}</td>
518 <td class='base'>&nbsp;</td>
519 <td class='base'>&nbsp;</td>
520 <td class='base'>&nbsp;</td>
521 </tr>
522 <tr>
523 <td colspan='13'></td>
524 </tr>
525 <tr>
526 <td class='base'>&nbsp; $Lang::tr{'status'}:</td>
527 <td class='base'>&nbsp;</td>
528 <td align='center'><img src='/images/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /></td>
529 <td class='base'>$Lang::tr{'updxlrtr condition ok'}</td>
530 <td class='base'>&nbsp;</td>
531 <td align='center'><img src='/images/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td>
532 <td class='base'>$Lang::tr{'updxlrtr condition nosource'}</td>
533 <td class='base'>&nbsp;</td>
534 <td align='center'><img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td>
535 <td class='base'>$Lang::tr{'updxlrtr condition outdated'}</td>
536 <td class='base'>&nbsp;</td>
537 <td align='center'><img src='/images/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' /></td>
538 <td class='base'>$Lang::tr{'updxlrtr condition download'}</td>
539 </tr>
540 <tr>
541 <td colspan='13'></td>
542 </tr>
543 <tr>
544 <td class='base'>&nbsp; $Lang::tr{'updxlrtr source'}:</td>
545 <td class='base'>&nbsp;</td>
546 <td align='center'><img src='/images/updxl-src-adobe.gif' alt='Adobe' /></td>
547 <td class='base'>Adobe</td>
548 <td class='base'>&nbsp;</td>
549 <td align='center'><img src='/images/updxl-src-windows.gif' alt='Microsoft' /></td>
550 <td class='base'>Microsoft</td>
551 <td class='base'>&nbsp;</td>
552 <td align='center'><img src='/images/updxl-src-symantec.gif' alt='Symantec' /></td>
553 <td class='base'>Symantec</td>
554 <td class='base'>&nbsp;</td>
555 <td align='center'><img src='/images/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr unknown'}' /></td>
556 <td class='base'>$Lang::tr{'updxlrtr unknown'}</td>
557 </tr>
558 </table>
559 END
560 ;
561 } else {
562
563 print "<i>$Lang::tr{'updxlrtr empty repository'}</i>\n";
564 }
565
566 print <<END
567 <hr>
568
569 <table>
570 <tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}:</b></td></tr>
571 </table>
572
573 <table cellpadding='3'>
574 END
575 ;
576 open(DF,"/bin/df -h $repository|");
577 while(<DF>)
578 {
579 if ($_ =~ m/^Filesystem/ )
580 {
581 print <<END
582 <tr>
583 <td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td>
584 <td align='center' class='base'><i>$Lang::tr{'size'}</i></td>
585 <td align='center' class='base'><i>$Lang::tr{'used'}</i></td>
586 <td align='center' class='base'><i>$Lang::tr{'free'}</i></td>
587 <td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td>
588 </tr>
589 END
590 ;
591 }
592 else
593 {
594 my ($device,$size,$used,$free,$percent,$mount) = split;
595 print <<END
596 <tr>
597 <td>[$repository]</td>
598 <td align='right'>$size</td>
599 <td align='right'>$used</td>
600 <td align='right'>$free</td>
601 <td>
602 END
603 ;
604 &percentbar($percent);
605 print <<END
606 </td>
607 <td align='right'>$percent</td>
608 </tr>
609 END
610 ;
611 }
612 }
613 close DF;
614 print "</table>\n";
615
616 &Header::closebox();
617
618 &Header::closebigbox();
619
620 &Header::closepage();
621
622 # -------------------------------------------------------------------
623
624 sub check4updates
625 {
626 if ((-e "${General::swroot}/red/active") && (-e $sysupdflagfile) && (int(-M $sysupdflagfile) > 7))
627 {
628 my @response=();;
629
630 my $remote = IO::Socket::INET->new(
631 PeerHost => 'www.advproxy.net',
632 PeerPort => 'http(80)',
633 Timeout => 1
634 );
635
636 if ($remote)
637 {
638 print $remote "GET http://www.advproxy.net/update-accelerator/version/ipcop/latest HTTP/1.0\n";
639 print $remote "User-Agent: Mozilla/4.0 (compatible; IPCop $General::version; $Lang::language; updatexlrator)\n\n";
640 while (<$remote>) { push(@response,$_); }
641 close $remote;
642 if ($response[0] =~ /^HTTP\/\d+\.\d+\s200\sOK\s*$/)
643 {
644 system("touch $sysupdflagfile");
645 return "$response[$#response]";
646 }
647 }
648 }
649 }
650
651 # -------------------------------------------------------------------
652
653 sub savesettings
654 {
655 if (-e $chk_cron_dly) { unlink($chk_cron_dly); }
656 if (-e $chk_cron_wly) { unlink($chk_cron_wly); }
657 if (-e $chk_cron_mly) { unlink($chk_cron_mly); }
658
659 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'daily'))
660 {
661 symlink("../bin/checkup",$chk_cron_dly)
662 } else {
663 symlink("/bin/false",$chk_cron_dly)
664 }
665 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'weekly'))
666 {
667 symlink("../bin/checkup",$chk_cron_wly)
668 } else {
669 symlink("/bin/false",$chk_cron_wly)
670 }
671 if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'monthly'))
672 {
673 symlink("../bin/checkup",$chk_cron_mly)
674 } else {
675 symlink("/bin/false",$chk_cron_mly)
676 }
677
678 delete($xlratorsettings{'REMOVE_OBSOLETE'});
679 delete($xlratorsettings{'REMOVE_NOSOURCE'});
680 delete($xlratorsettings{'REMOVE_OUTDATED'});
681
682 &General::writehash("${General::swroot}/updatexlrator/settings", \%xlratorsettings);
683 }
684
685 # -------------------------------------------------------------------
686
687 sub percentbar
688 {
689 my $percent = $_[0];
690 my $fg = '#a0a0a0';
691 my $bg = '#e2e2e2';
692
693 if ($percent =~ m/^(\d+)%$/ )
694 {
695 print <<END
696 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
697 <tr>
698 END
699 ;
700 if ($percent eq "100%") {
701 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
702 } elsif ($percent eq "0%") {
703 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
704 } else {
705 print "<td width='$percent' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'></td><td width='" . (100-$1) . "%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
706 }
707 print <<END
708 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
709 END
710 ;
711 }
712 }
713
714 # -------------------------------------------------------------------
715
716 sub getmtime
717 {
718 my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]);
719
720 return $mtime;
721 }
722
723 # -------------------------------------------------------------------