6 my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
7 my @days = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
10 my $scan_dir = '/xxxxxxxxxxxxxxxxxxxxxx/sf-download/';
11 my $base_dlurl = 'https://www.privoxy.org/sf-download-mirror/';
12 my $save_rss_file ='/xxxxxxxxxxxxxxxxxxxxxx/release.xml'; # e.g., release.rss
35 # 1st & 2nd directory should NOT contain ANY 'FILES'. (expecting only 'Directory')
37 opendir(D1, $scan_dir) or die "Can't open 1st directory! /";
38 while (my $fi1 = readdir(D1)) {
39 next if ($fi1 =~ m/^\./);
41 opendir(D2, $scan_dir . $fi1 . '/')
42 or die "Can't open 2nd directory! /$fi1";
43 while (my $fi2 = readdir(D2)) {
44 next if ($fi2 =~ m/^\./);
46 ## start listing /OS/Version/FILE
47 opendir(D3, $scan_dir . $fi1 . '/' . $fi2 . '/')
48 or die "Can't open 3rd directory! /$fi1/$fi2";
49 while (my $fi3 = readdir(D3)) {
50 next if ($fi3 =~ m/^\./);
51 $target = $scan_dir . $fi1 . '/' . $fi2 . '/' . $fi3;
52 next if (!-e $target); # skip if file is not exist
56 unless (open $filedata, $target) { next; }
57 my $sha1 = Digest::SHA1->new;
58 $sha1->addfile($filedata);
60 $target_sha1 = $sha1->hexdigest;
63 $target_uri = $fi1 . '/' . $fi2 . '/' . $fi3;
64 $target_time = (stat $target)[9];
68 '<item><title><![CDATA[' . $target_uri . ']]></title>';
70 '<description><![CDATA['
74 . ')]]></description>';
83 $target_line .= '<pubDate>';
84 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
87 "$days[$wday], $mday $months[$mon] "
89 . " $hour:$min:$sec GMT";
90 $target_line .= '</pubDate></item>';
93 $Array[$i] = ([$target_time, $target_line]);
95 die "maxlimit $maxlimit reached!" unless ($i < $maxlimit);
98 ## end listing /OS/Version/FILE
106 # Result = Full XML Codes
108 '<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0"><channel><title>Privoxy Releases</title><link>https://www.privoxy.org/announce.txt</link><description><![CDATA[Privoxy Releases RSS feed]]></description><pubDate>';
109 ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime();
111 "$days[$wday], $mday $months[$mon] "
113 . " $hour:$min:$sec GMT";
114 $result .= '</pubDate>';
117 my @resArray = sort { @$a[0] <=> @$b[0] } @Array;
119 while ($i >= 0) { $result .= $resArray[$i][1]; $i--; }
120 $result .= '</channel></rss>';
123 open(XMLF, "> $save_rss_file") or die "Failed to write XML file";