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