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