From 4e90577cfaab6b85b88150c2667a71cca99ccd2c Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Sun, 28 May 2023 06:39:52 -0700 Subject: [PATCH] Speed up duplicate checking in spoolnews.php. More accurate dates in main groups list. --- Rocksolid_Light/rocksolid/newsportal.php | 6 ++--- Rocksolid_Light/rslight/scripts/spoolnews.php | 23 +++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 2b30f5e..bcb8f84 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -626,7 +626,7 @@ function groups_show($gruppen) { $groupdisplay.='

'; $groupdisplay.='(unsubscribe)'; if($userdata[$g->name] < $lastarticleinfo['date']) { - $groupdisplay.='(new) '; + $groupdisplay.='(new) '; } $groupdisplay.='

'; -// Handle newsportal errors in lastarticleinfo.dat - if($lastarticleinfo['date'] == 0) { +// Look up last article info for group $database = $spooldir.'/articles-overview.db3'; $table = 'overview'; $articles_dbh = rslight_db_open($database); @@ -676,7 +675,6 @@ function groups_show($gruppen) { $lastarticleinfo['name'] = $fromoutput[0]; } } - } $groupdisplay.=get_date_interval(date("D, j M Y H:i T",$lastarticleinfo['date'])); $groupdisplay.='
'; $groupdisplay.='by: '; diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index dbb9ced..ef44c67 100755 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -192,7 +192,7 @@ function get_articles($ns, $group) { $database = $spooldir.'/articles-overview.db3'; $table = 'overview'; $dbh = rslight_db_open($database, $table); - $sql = 'INSERT INTO '.$table.'(newsgroup, number, msgid, date, name, subject) VALUES(?,?,?,?,?,?)'; + $sql = 'INSERT OR IGNORE INTO '.$table.'(newsgroup, number, msgid, date, name, subject) VALUES(?,?,?,?,?,?)'; $stmt = $dbh->prepare($sql); if($CONFIG['article_database'] == '1') { $article_dbh = article_db_open($spooldir.'/'.$group.'-articles.db3'); @@ -206,6 +206,19 @@ function get_articles($ns, $group) { $overview_msgid = explode("\t", $group_overview); $msgids[trim($overview_msgid[4])] = true; } +// Get overview from server + $server_overview = array(); + $re = false; + fputs($ns, "xover ".$article."-".$detail[3]."\r\n"); + $response=line_read($ns); // and once more + if ((substr($response,0,3) != "224")) { + file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Cannot get overview from ".$CONFIG['remote_server']." for ".$group, FILE_APPEND); + } + while(trim($response = line_read($ns)) !== '.') { + $ov = preg_split("/\t/", $response); + $server_msgids[$ov[0]] = $ov[4]; + } + # Pull articles and save them in our spool @mkdir($grouppath,0755,'recursive'); $i=0; @@ -217,11 +230,7 @@ function get_articles($ns, $group) { if($CONFIG['enable_nntp'] != true){ $local = $article; } -// Check for duplicate msgid - fputs($ns, "stat ".$article."\r\n"); - $response = line_read($ns); - $this_msgid = explode(' ', $response); - if($msgids[trim($this_msgid[2])] == true) { + if($msgids[$server_msgids[$article]] == true) { echo "\nDuplicate Message-ID for: ".$group.":".$article; file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Duplicate Message-ID for: ".$group.":".$article, FILE_APPEND); $article++; @@ -265,7 +274,7 @@ function get_articles($ns, $group) { // Get overview data if(stripos($response, "Message-ID: ") === 0) { $mid=explode(': ', $response, 2); - $ref=0; + $ref=0; } if(stripos($response, "From: ") === 0) { $from=explode(': ', $response, 2);