Speed up duplicate checking in spoolnews.php. More accurate dates in main groups list.

This commit is contained in:
Retro_Guy 2023-05-28 06:39:52 -07:00
parent 73fd167566
commit 4e90577cfa
2 changed files with 18 additions and 11 deletions

View File

@ -626,7 +626,7 @@ function groups_show($gruppen) {
$groupdisplay.='</span><p class="np_group_desc">'; $groupdisplay.='</span><p class="np_group_desc">';
$groupdisplay.='<a class="np_group_desc" href="index.php?unsub='.$g->name.'">(unsubscribe)</a>'; $groupdisplay.='<a class="np_group_desc" href="index.php?unsub='.$g->name.'">(unsubscribe)</a>';
if($userdata[$g->name] < $lastarticleinfo['date']) { if($userdata[$g->name] < $lastarticleinfo['date']) {
$groupdisplay.='<a href="overboard.php?thisgroup='._rawurlencode($g->name).'&time='.$userdata[$g->name].'">(new)</a> '; $groupdisplay.='<a href="overboard.php?thisgroup='._rawurlencode($g->name).'&time='.$userdata[$g->name].'"><b>(new)</b></a> ';
} }
$groupdisplay.='</p'; $groupdisplay.='</p';
} }
@ -644,8 +644,7 @@ function groups_show($gruppen) {
/* Display latest article info */ /* Display latest article info */
$groupdisplay.='</td><td class="'.$lineclass.'"><div class="np_last_posted_date">'; $groupdisplay.='</td><td class="'.$lineclass.'"><div class="np_last_posted_date">';
// Handle newsportal errors in lastarticleinfo.dat // Look up last article info for group
if($lastarticleinfo['date'] == 0) {
$database = $spooldir.'/articles-overview.db3'; $database = $spooldir.'/articles-overview.db3';
$table = 'overview'; $table = 'overview';
$articles_dbh = rslight_db_open($database); $articles_dbh = rslight_db_open($database);
@ -676,7 +675,6 @@ function groups_show($gruppen) {
$lastarticleinfo['name'] = $fromoutput[0]; $lastarticleinfo['name'] = $fromoutput[0];
} }
} }
}
$groupdisplay.=get_date_interval(date("D, j M Y H:i T",$lastarticleinfo['date'])); $groupdisplay.=get_date_interval(date("D, j M Y H:i T",$lastarticleinfo['date']));
$groupdisplay.='<table><tr><td>'; $groupdisplay.='<table><tr><td>';
$groupdisplay.='<font class="np_last_posted_date">by: '; $groupdisplay.='<font class="np_last_posted_date">by: ';

View File

@ -192,7 +192,7 @@ function get_articles($ns, $group) {
$database = $spooldir.'/articles-overview.db3'; $database = $spooldir.'/articles-overview.db3';
$table = 'overview'; $table = 'overview';
$dbh = rslight_db_open($database, $table); $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); $stmt = $dbh->prepare($sql);
if($CONFIG['article_database'] == '1') { if($CONFIG['article_database'] == '1') {
$article_dbh = article_db_open($spooldir.'/'.$group.'-articles.db3'); $article_dbh = article_db_open($spooldir.'/'.$group.'-articles.db3');
@ -206,6 +206,19 @@ function get_articles($ns, $group) {
$overview_msgid = explode("\t", $group_overview); $overview_msgid = explode("\t", $group_overview);
$msgids[trim($overview_msgid[4])] = true; $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 # Pull articles and save them in our spool
@mkdir($grouppath,0755,'recursive'); @mkdir($grouppath,0755,'recursive');
$i=0; $i=0;
@ -217,11 +230,7 @@ function get_articles($ns, $group) {
if($CONFIG['enable_nntp'] != true){ if($CONFIG['enable_nntp'] != true){
$local = $article; $local = $article;
} }
// Check for duplicate msgid if($msgids[$server_msgids[$article]] == true) {
fputs($ns, "stat ".$article."\r\n");
$response = line_read($ns);
$this_msgid = explode(' ', $response);
if($msgids[trim($this_msgid[2])] == true) {
echo "\nDuplicate Message-ID for: ".$group.":".$article; 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); file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Duplicate Message-ID for: ".$group.":".$article, FILE_APPEND);
$article++; $article++;
@ -265,7 +274,7 @@ function get_articles($ns, $group) {
// Get overview data // Get overview data
if(stripos($response, "Message-ID: ") === 0) { if(stripos($response, "Message-ID: ") === 0) {
$mid=explode(': ', $response, 2); $mid=explode(': ', $response, 2);
$ref=0; $ref=0;
} }
if(stripos($response, "From: ") === 0) { if(stripos($response, "From: ") === 0) {
$from=explode(': ', $response, 2); $from=explode(': ', $response, 2);