<commit_before>#!/usr/bin/perl

use strict;
use warnings;
use LWP;
use Time::Local;

my $url = "http://www.slackware.com/lists/archive/"
."list.php?l=slackware-security&y=YYY";
my $baseURL = 'http://www.slackware.com/lists/archive/viewer.php';
my $outDir = '/mnt/tmp/search.slack/news/';

my ($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = 
	localtime(time);
$year = 1900 + $year;
my $yearStop = $year - 1;

my $browser = LWP::UserAgent->new;
my $newsCount = 0;
my $printOut = '';

while ($year >= $yearStop) {
	my $link = $url;
	$link =~ s/YYY/$year/;
	my $response = $browser->get( $link ) 
		or die("Unable to get URL '$link'");
	die ("Unable to get URL '$link'.") if ($response->is_error());
	for my $htmlLine ( split(/\n/, $response->content) ) {
		chomp($htmlLine);
		$htmlLine =~ s/^\s+//;
		$htmlLine =~ s/\s+$//;
		if ($htmlLine =~ /viewer\.php/) {
			$htmlLine = substr($htmlLine, index($htmlLine, $year."-"), 
				length($htmlLine));
			$htmlLine =~ s/\[slackware-security\]//;
			$htmlLine =~ s/A HREF/a href/;
			$htmlLine =~ s/&/&#38;/g;
			$htmlLine =~ s/viewer\.php/$baseURL/;
			$newsCount++;
			$printOut.= sprintf("\t\t\t\t\t\t<li>%s</a></li>\n", $htmlLine);
		}
		if ($newsCount >= 10) {
			$year = 0;
			last;
		}
	} # for my $htmlLine
	$year--;
}

exit 2 if ($newsCount == 0);

unless ( -e $outDir ) {
	exit 254;
}

my $outFile = sprintf(">%s/slack-news.htm", $outDir);

open(FILE, $outFile) or die("Unable to write to file.");
print FILE "\t\t\t<div class=\"remoteNews-left\">\n";
print FILE "\t\t\t\t<fieldset>\n";
print FILE "\t\t\t\t\t<label>Slackware security warnings</label>\n";
print FILE "\t\t\t\t\t<ul>\n";
print FILE $printOut;
print FILE "\t\t\t\t\t</ul>\n";
print FILE "\t\t\t\t</fieldset>\n";
print FILE "\t\t\t</div>\n";
close(FILE);
<commit_msg>ADD: slackw-get-sec ~ add source<commit_after>#!/usr/bin/perl

use strict;
use warnings;
use LWP;
use Time::Local;

my $url = "http://www.slackware.com/lists/archive/"
."list.php?l=slackware-security&y=YYY";
my $baseURL = 'http://www.slackware.com/lists/archive/viewer.php';
my $outDir = '/mnt/tmp/search.slack/news/';

my ($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = 
	localtime(time);
$year = 1900 + $year;
my $yearStop = $year - 1;

my $browser = LWP::UserAgent->new;
my $newsCount = 0;
my $printOut = '';

while ($year >= $yearStop) {
	my $link = $url;
	$link =~ s/YYY/$year/;
	my $response = $browser->get( $link ) 
		or die("Unable to get URL '$link'");
	die ("Unable to get URL '$link'.") if ($response->is_error());
	for my $htmlLine ( split(/\n/, $response->content) ) {
		chomp($htmlLine);
		$htmlLine =~ s/^\s+//;
		$htmlLine =~ s/\s+$//;
		if ($htmlLine =~ /viewer\.php/) {
			$htmlLine = substr($htmlLine, index($htmlLine, $year."-"), 
				length($htmlLine));
			$htmlLine =~ s/\[slackware-security\]//;
			$htmlLine =~ s/A HREF/a href/;
			$htmlLine =~ s/&/&#38;/g;
			$htmlLine =~ s/viewer\.php/$baseURL/;
			$newsCount++;
			$printOut.= sprintf("\t\t\t\t\t\t<li>%s</a></li>\n", $htmlLine);
		}
		if ($newsCount >= 10) {
			$year = 0;
			last;
		}
	} # for my $htmlLine
	$year--;
}

exit 2 if ($newsCount == 0);

unless ( -e $outDir ) {
	exit 254;
}

my $outFile = sprintf(">%s/slack-news.htm", $outDir);

open(FILE, $outFile) or die("Unable to write to file.");
print FILE "\t\t\t<div class=\"remoteNews-left\">\n";
print FILE "\t\t\t\t<fieldset>\n";
print FILE "\t\t\t\t\t<legend>Slackware security warnings</legend>\n";
print FILE "\t\t\t\t\t<ul>\n";
print FILE $printOut;
print FILE "\t\t\t\t\t</ul>\n";
print FILE "\t\t\t\t\t<div class=\"remoteNews-source\">\n";
print FILE "\t\t\t\t\t\t--source <a href=\"http://www.slackware.com/security/\">slackware.com</a>\n";
print FILE "\t\t\t\t\t</div>\n";
print FILE "\t\t\t\t</fieldset>\n";
print FILE "\t\t\t</div>\n";
close(FILE);

{'fraction_non_alphanumeric': 0.24921052631578947, 'fraction_numerical': 0.008421052631578947, 'mean_word_length': 3.482311320754717, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 5, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3803015', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1606, 'n_words': 325}