Use overview to provide news server article numbers info

This commit is contained in:
Retro_Guy 2020-12-18 22:22:03 -07:00
parent a865077390
commit 0ee48853a2
1 changed files with 12 additions and 31 deletions

View File

@ -699,7 +699,7 @@ function get_body($article, $nntp_group) {
} }
function get_listgroup($nntp_group, $msgsock) { function get_listgroup($nntp_group, $msgsock) {
global $path,$nntp_group,$groupconfig; global $spooldir,$path,$nntp_group,$groupconfig;
$grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$ok_group=false; $ok_group=false;
$count=0; $count=0;
@ -712,21 +712,14 @@ function get_listgroup($nntp_group, $msgsock) {
break; break;
} }
} }
$thisgroup = $path."/".preg_replace('/\./', '/', $nntp_group); $group_overviewfp=fopen($spooldir."/".$nntp_group."-overview", 'r');
if(!is_dir($thisgroup) || $ok_group === false) {
$msg.="411 no such news group\r\n";
$nntp_group="";
return $msg;
}
$articles = scandir($thisgroup);
$ok_article=array(); $ok_article=array();
foreach($articles as $article) { while($line = fgets($group_overviewfp)) {
if(!is_numeric($article)) { $art=explode("\t", $line);
continue; $ok_article[] = $art[0];
}
$ok_article[]=$article;
$count++; $count++;
} }
fclose($group_overviewfp);
sort($ok_article); sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))]; $last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
$first = $ok_article[0]; $first = $ok_article[0];
@ -745,7 +738,7 @@ function get_listgroup($nntp_group, $msgsock) {
} }
function get_group($nntp_group) { function get_group($nntp_group) {
global $path,$nntp_group,$groupconfig; global $spooldir,$path,$nntp_group,$groupconfig;
$grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$ok_group=false; $ok_group=false;
$count=0; $count=0;
@ -758,21 +751,14 @@ function get_group($nntp_group) {
break; break;
} }
} }
$thisgroup = $path."/".preg_replace('/\./', '/', $nntp_group); $group_overviewfp=fopen($spooldir."/".$nntp_group."-overview", 'r');
if(!is_dir($thisgroup) || $ok_group === false) {
$msg.="411 no such news group\r\n";
$nntp_group="";
return $msg;
}
$articles = scandir($thisgroup);
$ok_article=array(); $ok_article=array();
foreach($articles as $article) { while($line = fgets($group_overviewfp)) {
if(!is_numeric($article)) { $art=explode("\t", $line);
continue; $ok_article[] = $art[0];
}
$ok_article[]=$article;
$count++; $count++;
} }
fclose($group_overviewfp);
sort($ok_article); sort($ok_article);
$last = $ok_article[key(array_slice($ok_article, -1, 1, true))]; $last = $ok_article[key(array_slice($ok_article, -1, 1, true))];
$first = $ok_article[0]; $first = $ok_article[0];
@ -999,11 +985,6 @@ $date_i,$mid_i,$references_i,$bytes_i,$lines_i,$xref_i) {
fputs($overviewHandle, $local."\t".$subject_i."\t".$from_i."\t".$date_i."\t".$mid_i."\t".$references_i."\t".$bytes_i."\t".$lines_i."\t".$xref_i."\n"); fputs($overviewHandle, $local."\t".$subject_i."\t".$from_i."\t".$date_i."\t".$mid_i."\t".$references_i."\t".$bytes_i."\t".$lines_i."\t".$xref_i."\n");
fclose($overviewHandle); fclose($overviewHandle);
$references=""; $references="";
// overview for search (eventually this will not be used)
$overview_file=$spooldir."/".$section."-overview";
file_put_contents($overview_file,
$nntp_group."\t".$local."\t".$mid_i."\t".$article_date."\t".$from_i
."\t".$subject_i."\n", FILE_APPEND);
// End Overview // End Overview
reset($grouplist); reset($grouplist);
$saveconfig = fopen($local_groupfile, 'w+'); $saveconfig = fopen($local_groupfile, 'w+');