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');
// Spool directory size and minimum in Gigabytes
$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) {
if ($OVERRIDES['min_spool_disk_space'] > 0) {
$min_spool_disk_space = $OVERRIDES['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;
} else {
$low_spool_disk_space = false;

View File

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

View File

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