Avoid duplicate 'Duplicate' checking in spoolnews.php.

This commit is contained in:
Retro_Guy 2023-12-24 06:49:34 -07:00
parent 8baaf3322c
commit e37b1bc826
4 changed files with 44 additions and 33 deletions

View File

@ -29,9 +29,14 @@ $CONFIG = include ($config_file);
$OVERRIDES = include ($config_dir . '/overrides.inc.php'); $OVERRIDES = include ($config_dir . '/overrides.inc.php');
// Spool directory size and minimum in Gigabytes // Spool directory size and minimum in Gigabytes
$min_spool_disk_space = 2; if ($OVERRIDES['min_spool_disk_space'] > 0) {
$free_spool_disk_space = disk_free_space($spooldir)*9.313E-10; $min_spool_disk_space = $OVERRIDES['min_spool_disk_space'];
if($free_spool_disk_space < $min_spool_disk_space) { } else {
$min_spool_disk_space = 2;
}
$free_spool_disk_space = disk_free_space($spooldir) * 9.313E-10;
if ($free_spool_disk_space < $min_spool_disk_space) {
$low_spool_disk_space = true; $low_spool_disk_space = true;
} else { } else {
$low_spool_disk_space = false; $low_spool_disk_space = false;

View File

@ -1896,41 +1896,43 @@ function get_next_article_number($group)
return $local; return $local;
} }
function insert_article_from_array($this_article) function insert_article_from_array($this_article, $check_duplicates = true)
{ {
global $CONFIG, $config_name, $spooldir, $logdir; global $CONFIG, $config_name, $spooldir, $logdir;
$logfile = $logdir . '/spoolnews.log'; $logfile = $logdir . '/spoolnews.log';
$group = $this_article['group']; $group = $this_article['group'];
$grouppath = $path . preg_replace('/\./', '/', $group); $grouppath = $path . preg_replace('/\./', '/', $group);
// Create list of message-ids if ($check_duplicates) {
$database = $spooldir . '/articles-overview.db3'; // Create list of message-ids
$table = 'overview'; $database = $spooldir . '/articles-overview.db3';
$dbh = overview_db_open($database, $table); $table = 'overview';
$stmt = $dbh->prepare("SELECT msgid FROM $table WHERE newsgroup=:newsgroup"); $dbh = overview_db_open($database, $table);
$stmt->bindParam(':newsgroup', $group); $stmt = $dbh->prepare("SELECT msgid FROM $table WHERE newsgroup=:newsgroup");
$stmt->execute(); $stmt->bindParam(':newsgroup', $group);
while ($row = $stmt->fetch()) { $stmt->execute();
$msgids[$row['msgid']] = true; while ($row = $stmt->fetch()) {
} $msgids[$row['msgid']] = true;
$dbh = null; }
$dbh = null;
// Check history database for deleted message-ids // Check history database for deleted message-ids
$database = $spooldir . '/history.db3'; $database = $spooldir . '/history.db3';
$table = 'history'; $table = 'history';
$dbh = history_db_open($database, $table); $dbh = history_db_open($database, $table);
$stmt = $dbh->prepare("SELECT msgid FROM $table WHERE newsgroup=:newsgroup"); $stmt = $dbh->prepare("SELECT msgid FROM $table WHERE newsgroup=:newsgroup");
$stmt->bindParam(':newsgroup', $group); $stmt->bindParam(':newsgroup', $group);
$stmt->execute(); $stmt->execute();
while ($row = $stmt->fetch()) { while ($row = $stmt->fetch()) {
$msgids[$row['msgid']] = true; $msgids[$row['msgid']] = true;
} }
$dbh = null; $dbh = null;
if ($msgids[$this_article['mid']] == true) { if ($msgids[$this_article['mid']] == true) {
echo "\nDuplicate Message-ID for: " . $group . ":" . $this_article['local']; echo "\nDuplicate Message-ID for: " . $group . ":" . $this_article['local'];
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Duplicate Message-ID for: " . $group . ":" . $this_article['local'], FILE_APPEND); file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Duplicate Message-ID for: " . $group . ":" . $this_article['local'], FILE_APPEND);
return "441 Insert failed (duplicate)\r\n"; return "441 Insert failed (duplicate)\r\n";
}
} }
// Open articles Database // Open articles Database
if ($CONFIG['article_database'] == '1') { if ($CONFIG['article_database'] == '1') {

View File

@ -458,6 +458,10 @@ function get_articles($ns, $group)
$current_article['snippet'] = $this_snippet; $current_article['snippet'] = $this_snippet;
// Check Spam // Check Spam
if ($OVERRIDES['disable_spamassassin_spooling'] === true) {
$CONFIG['spamassassin'] = false;
$res = 0;
}
if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true)) { if (isset($CONFIG['spamassassin']) && ($CONFIG['spamassassin'] == true)) {
$spam_result_array = check_spam($subject[1], $from[1], $groupnames[1], $references, $body, $mid[1]); $spam_result_array = check_spam($subject[1], $from[1], $groupnames[1], $references, $body, $mid[1]);
$res = $spam_result_array['res']; $res = $spam_result_array['res'];
@ -482,10 +486,10 @@ function get_articles($ns, $group)
$current_article['group'] = $agroup; $current_article['group'] = $agroup;
if ($group == $agroup) { if ($group == $agroup) {
$current_article['local'] = $local; $current_article['local'] = $local;
insert_article_from_array($current_article); insert_article_from_array($current_article, false);
} else { } else {
$current_article['local'] = get_next_article_number($agroup); $current_article['local'] = get_next_article_number($agroup);
insert_article_from_array($current_article); insert_article_from_array($current_article, false);
} }
} }
} }

View File

@ -1 +1 @@
0.9.2 0.9.5