]>
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 | # | |
46c01c09 MT |
9 | |
10 | use strict; | |
11 | ||
12 | # enable only the following on debugging purpose | |
9fb25b1c MT |
13 | use warnings; |
14 | use CGI::Carp 'fatalsToBrowser'; | |
46c01c09 MT |
15 | |
16 | use IO::Socket; | |
17 | ||
18 | require '/var/ipfire/general-functions.pl'; | |
19 | require "${General::swroot}/lang.pl"; | |
20 | require "${General::swroot}/header.pl"; | |
21 | ||
fe6cda92 | 22 | my %color = (); |
46c01c09 MT |
23 | my %checked=(); |
24 | my %selected=(); | |
25 | my %netsettings=(); | |
26 | my %mainsettings=(); | |
27 | my %proxysettings=(); | |
28 | my %xlratorsettings=(); | |
29 | my $id=0; | |
30 | my $updatefile=''; | |
31 | my $shortname=''; | |
32 | my $vendor=''; | |
33 | my $time=''; | |
34 | my $filesize=0; | |
35 | my $filedate=''; | |
36 | my $lastaccess=''; | |
37 | my $lastcheck=''; | |
38 | ||
39 | my $repository = "/srv/web/ipfire/html/updatecache"; | |
40 | my $hintcolour = '#FFFFCC'; | |
41 | ||
42 | my $sfNoSource='0'; | |
43 | my $sfOk='1'; | |
44 | my $sfOutdated='2'; | |
45 | ||
46 | my $not_accessed_last=''; | |
47 | ||
48 | my $errormessage=''; | |
49 | ||
50 | my @repositorylist=(); | |
51 | my @repositoryfiles=(); | |
52 | ||
53 | my @metadata=(); | |
54 | ||
55 | my $chk_cron_dly = "${General::swroot}/updatexlrator/autocheck/cron.daily"; | |
56 | my $chk_cron_wly = "${General::swroot}/updatexlrator/autocheck/cron.weekly"; | |
57 | my $chk_cron_mly = "${General::swroot}/updatexlrator/autocheck/cron.monthly"; | |
58 | ||
46c01c09 MT |
59 | &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); |
60 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
61 | &General::readhash("${General::swroot}/proxy/settings", \%proxysettings); | |
fe6cda92 | 62 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); |
46c01c09 MT |
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 | ||
7d3af7f7 | 178 | system('/usr/local/bin/squidctrl restart >/dev/null 2>&1'); |
46c01c09 MT |
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 </font>\n"; | |
231 | &Header::closebox(); | |
232 | } | |
233 | ||
46c01c09 MT |
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> </td> | |
259 | <td> </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> </td> | |
283 | <td> </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'}' /> $Lang::tr{'updxlrtr all files'}</td> | |
293 | <td class='base' width='25%'><input type='checkbox' name='REMOVE_OBSOLETE' $checked{'REMOVE_OBSOLETE'}{'on'} /> $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'} /> $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'} /> $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> </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> </td> | |
321 | </tr> | |
322 | </table> | |
323 | <table width='100%'> | |
324 | <tr> | |
325 | <td align='right'> | |
9fb25b1c | 326 | |
46c01c09 MT |
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'> </td> | |
373 | <td class='base' align='center'> </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'> </td> | |
380 | </tr> | |
381 | END | |
382 | ; | |
383 | $id = 0; | |
384 | foreach $updatefile (@repositoryfiles) | |
385 | { | |
386 | $id++; | |
387 | if ($id % 2) { | |
fe6cda92 | 388 | print "<tr bgcolor='$color{'color20'}'>\n"; } |
46c01c09 | 389 | else { |
fe6cda92 | 390 | print "<tr bgcolor='$color{'color22'}'>\n"; } |
46c01c09 MT |
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'> "; | |
428 | if ($metadata[2] eq $sfNoSource) | |
429 | { | |
430 | print "<img src='/images/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /> </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'}' /> </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'}' /> </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'}' /> </td>\n"; | |
443 | } | |
444 | if ($metadata[2] eq '') | |
445 | { | |
446 | print "<img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /> </td>\n"; | |
447 | } | |
448 | ||
449 | print "\t\t<td align='center' nowrap='nowrap'> "; | |
450 | if ($metadata[1] eq 'Adobe') | |
451 | { | |
452 | print "<img src='/images/updxl-src-adobe.gif' alt='Adobe'}' /> </td>\n"; | |
453 | } elsif ($metadata[1] eq 'Microsoft') | |
454 | { | |
455 | print "<img src='/images/updxl-src-windows.gif' alt='Microsoft'}' /> </td>\n"; | |
456 | } elsif ($metadata[1] eq 'Symantec') | |
457 | { | |
458 | print "<img src='/images/updxl-src-symantec.gif' alt='Symantec'}' /> </td>\n"; | |
5b2a12ff MT |
459 | } elsif ($metadata[1] eq 'Avira') |
460 | { | |
461 | print "<img src='/images/updxl-src-avira.gif' alt='Avira'}' /> </td>\n"; | |
462 | } elsif ($metadata[1] eq 'Avast') | |
463 | { | |
464 | print "<img src='/images/updxl-src-avast.gif' alt='Avast'}' /> </td>\n"; | |
186e3d2c MT |
465 | } elsif ($metadata[1] eq 'IPFire') |
466 | { | |
a2d5130f | 467 | print "<img src='/images/IPFire.png' width='18' height='18' alt='IPFire'}' /> </td>\n"; |
186e3d2c MT |
468 | } elsif ($metadata[1] eq 'Linux') |
469 | { | |
a2d5130f | 470 | print "<img src='/images/tux.png' alt='Linux'}' /> </td>\n"; |
46c01c09 MT |
471 | } else |
472 | { | |
473 | print "<img src='/images/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr unknown'}' /> </td>\n"; | |
474 | } | |
475 | ||
476 | $shortname = $updatefile; | |
477 | $shortname =~ s/(.*)_[\da-f]*(\.(exe|cab|psf)$)/\1_*\2/i; | |
478 | $shortname =~ s/^download\///i; | |
479 | ||
480 | print <<END | |
481 | <td class='base' align='left' title='$updatefile'>$shortname</td> | |
482 | <td class='base' align='right' nowrap='nowrap'> $filesize </td> | |
483 | <td class='base' align='center' nowrap='nowrap'> $filedate </td> | |
484 | <td class='base' align='center' nowrap='nowrap'> $lastaccess </td> | |
485 | <td class='base' align='center' nowrap='nowrap'> $lastcheck </td> | |
486 | <td align='center'> | |
487 | <form method='post' name='frma$id' action='$ENV{'SCRIPT_NAME'}'> | |
488 | <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'}' /> | |
489 | <input type='hidden' name='ID' value='$updatefile' /> | |
490 | <input type='hidden' name='ACTION' value='$Lang::tr{'updxlrtr remove file'}' /> | |
491 | </form> | |
492 | </td> | |
493 | </tr> | |
494 | END | |
495 | ; | |
496 | } | |
497 | ||
498 | print <<END | |
499 | </table> | |
500 | <br> | |
501 | <table> | |
502 | <tr> | |
503 | <td class='boldbase'> <b>$Lang::tr{'legend'}:</b></td> | |
504 | <td class='base'> </td> | |
505 | <td><img src='/images/reload.gif' alt='$Lang::tr{'updxlrtr last access'}' /></td> | |
506 | <td class='base'>$Lang::tr{'updxlrtr last access'}</td> | |
507 | <td class='base'> </td> | |
508 | <td><img src='/images/floppy.gif' alt='$Lang::tr{'updxlrtr last checkup'}' /></td> | |
509 | <td class='base'>$Lang::tr{'updxlrtr last checkup'}</td> | |
510 | <td class='base'> </td> | |
511 | <td><img src='/images/delete.gif' alt='$Lang::tr{'updxlrtr remove file'}' /></td> | |
512 | <td class='base'>$Lang::tr{'updxlrtr remove file'}</td> | |
513 | <td class='base'> </td> | |
514 | <td class='base'> </td> | |
515 | <td class='base'> </td> | |
516 | </tr> | |
517 | <tr> | |
518 | <td colspan='13'></td> | |
519 | </tr> | |
520 | <tr> | |
521 | <td class='base'> $Lang::tr{'status'}:</td> | |
522 | <td class='base'> </td> | |
523 | <td align='center'><img src='/images/updxl-led-green.gif' alt='$Lang::tr{'updxlrtr condition ok'}' /></td> | |
524 | <td class='base'>$Lang::tr{'updxlrtr condition ok'}</td> | |
525 | <td class='base'> </td> | |
526 | <td align='center'><img src='/images/updxl-led-yellow.gif' alt='$Lang::tr{'updxlrtr condition nosource'}' /></td> | |
527 | <td class='base'>$Lang::tr{'updxlrtr condition nosource'}</td> | |
528 | <td class='base'> </td> | |
529 | <td align='center'><img src='/images/updxl-led-red.gif' alt='$Lang::tr{'updxlrtr condition outdated'}' /></td> | |
530 | <td class='base'>$Lang::tr{'updxlrtr condition outdated'}</td> | |
531 | <td class='base'> </td> | |
532 | <td align='center'><img src='/images/updxl-led-blue.gif' alt='$Lang::tr{'updxlrtr condition download'}' /></td> | |
533 | <td class='base'>$Lang::tr{'updxlrtr condition download'}</td> | |
534 | </tr> | |
535 | <tr> | |
536 | <td colspan='13'></td> | |
537 | </tr> | |
538 | <tr> | |
539 | <td class='base'> $Lang::tr{'updxlrtr source'}:</td> | |
540 | <td class='base'> </td> | |
541 | <td align='center'><img src='/images/updxl-src-adobe.gif' alt='Adobe' /></td> | |
542 | <td class='base'>Adobe</td> | |
543 | <td class='base'> </td> | |
544 | <td align='center'><img src='/images/updxl-src-windows.gif' alt='Microsoft' /></td> | |
545 | <td class='base'>Microsoft</td> | |
546 | <td class='base'> </td> | |
547 | <td align='center'><img src='/images/updxl-src-symantec.gif' alt='Symantec' /></td> | |
548 | <td class='base'>Symantec</td> | |
549 | <td class='base'> </td> | |
186e3d2c MT |
550 | <td align='center'><img src='/images/updxl-src-avira.gif' alt='Avira' /></td> |
551 | <td class='base'>Avira</td> | |
46c01c09 | 552 | </tr> |
5b2a12ff MT |
553 | <tr> |
554 | <td class='base' colspan='2'> </td> | |
a2d5130f | 555 | <td align='center'><img src='/images/IPFire.png' width='18' height='18' alt='IPFire' /></td> |
186e3d2c MT |
556 | <td class='base'>IPFire</td> |
557 | <td class='base'> </td> | |
a2d5130f | 558 | <td align='center'><img src='/images/tux.png' alt='Linux' /></td> |
186e3d2c MT |
559 | <td class='base'>Linux</td> |
560 | <td class='base'> </td> | |
5b2a12ff MT |
561 | <td align='center'><img src='/images/updxl-src-avast.gif' alt='Avast' /></td> |
562 | <td class='base'>Avast</td> | |
563 | <td class='base'> </td> | |
186e3d2c MT |
564 | <td align='center'><img src='/images/updxl-src-unknown.gif' alt='$Lang::tr{'updxlrtr unknown'}' /></td> |
565 | <td class='base'>$Lang::tr{'updxlrtr unknown'}</td> | |
5b2a12ff | 566 | </tr> |
46c01c09 MT |
567 | </table> |
568 | END | |
569 | ; | |
570 | } else { | |
571 | ||
572 | print "<i>$Lang::tr{'updxlrtr empty repository'}</i>\n"; | |
573 | } | |
574 | ||
575 | print <<END | |
576 | <hr> | |
577 | ||
578 | <table> | |
579 | <tr><td class='boldbase'><b>$Lang::tr{'updxlrtr disk usage'}:</b></td></tr> | |
580 | </table> | |
581 | ||
582 | <table cellpadding='3'> | |
583 | END | |
584 | ; | |
585 | open(DF,"/bin/df -h $repository|"); | |
586 | while(<DF>) | |
587 | { | |
588 | if ($_ =~ m/^Filesystem/ ) | |
589 | { | |
590 | print <<END | |
591 | <tr> | |
592 | <td align='left' class='base'><i>$Lang::tr{'updxlrtr cache dir'}</i></td> | |
593 | <td align='center' class='base'><i>$Lang::tr{'size'}</i></td> | |
594 | <td align='center' class='base'><i>$Lang::tr{'used'}</i></td> | |
595 | <td align='center' class='base'><i>$Lang::tr{'free'}</i></td> | |
596 | <td align='left' class='base' colspan='2'><i>$Lang::tr{'percentage'}</i></td> | |
597 | </tr> | |
598 | END | |
599 | ; | |
600 | } | |
601 | else | |
602 | { | |
603 | my ($device,$size,$used,$free,$percent,$mount) = split; | |
604 | print <<END | |
605 | <tr> | |
606 | <td>[$repository]</td> | |
607 | <td align='right'>$size</td> | |
608 | <td align='right'>$used</td> | |
609 | <td align='right'>$free</td> | |
610 | <td> | |
611 | END | |
612 | ; | |
613 | &percentbar($percent); | |
614 | print <<END | |
615 | </td> | |
616 | <td align='right'>$percent</td> | |
617 | </tr> | |
618 | END | |
619 | ; | |
620 | } | |
621 | } | |
622 | close DF; | |
623 | print "</table>\n"; | |
624 | ||
625 | &Header::closebox(); | |
626 | ||
627 | &Header::closebigbox(); | |
628 | ||
629 | &Header::closepage(); | |
630 | ||
631 | # ------------------------------------------------------------------- | |
632 | ||
46c01c09 MT |
633 | sub savesettings |
634 | { | |
635 | if (-e $chk_cron_dly) { unlink($chk_cron_dly); } | |
636 | if (-e $chk_cron_wly) { unlink($chk_cron_wly); } | |
637 | if (-e $chk_cron_mly) { unlink($chk_cron_mly); } | |
638 | ||
639 | if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'daily')) | |
640 | { | |
641 | symlink("../bin/checkup",$chk_cron_dly) | |
642 | } else { | |
643 | symlink("/bin/false",$chk_cron_dly) | |
644 | } | |
645 | if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'weekly')) | |
646 | { | |
647 | symlink("../bin/checkup",$chk_cron_wly) | |
648 | } else { | |
649 | symlink("/bin/false",$chk_cron_wly) | |
650 | } | |
651 | if (($xlratorsettings{'ENABLE_AUTOCHECK'} eq 'on') && ($xlratorsettings{'AUTOCHECK_SCHEDULE'} eq 'monthly')) | |
652 | { | |
653 | symlink("../bin/checkup",$chk_cron_mly) | |
654 | } else { | |
655 | symlink("/bin/false",$chk_cron_mly) | |
656 | } | |
657 | ||
658 | delete($xlratorsettings{'REMOVE_OBSOLETE'}); | |
659 | delete($xlratorsettings{'REMOVE_NOSOURCE'}); | |
660 | delete($xlratorsettings{'REMOVE_OUTDATED'}); | |
661 | ||
662 | &General::writehash("${General::swroot}/updatexlrator/settings", \%xlratorsettings); | |
663 | } | |
664 | ||
665 | # ------------------------------------------------------------------- | |
666 | ||
667 | sub percentbar | |
668 | { | |
669 | my $percent = $_[0]; | |
670 | my $fg = '#a0a0a0'; | |
671 | my $bg = '#e2e2e2'; | |
672 | ||
673 | if ($percent =~ m/^(\d+)%$/ ) | |
674 | { | |
675 | print <<END | |
676 | <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'> | |
677 | <tr> | |
678 | END | |
679 | ; | |
680 | if ($percent eq "100%") { | |
681 | print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>" | |
682 | } elsif ($percent eq "0%") { | |
683 | print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>" | |
684 | } else { | |
685 | 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'>" | |
686 | } | |
687 | print <<END | |
688 | <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table> | |
689 | END | |
690 | ; | |
691 | } | |
692 | } | |
693 | ||
694 | # ------------------------------------------------------------------- | |
695 | ||
696 | sub getmtime | |
697 | { | |
698 | my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($_[0]); | |
699 | ||
700 | return $mtime; | |
701 | } | |
702 | ||
703 | # ------------------------------------------------------------------- |