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