From 953b20322622a5be78cbebec2cf5b1f5e4319bc4 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Thu, 18 Feb 2021 22:10:43 -0700 Subject: [PATCH] Some changes to use -overview less in favor of .db3 --- Rocksolid_Light/rocksolid/newsportal.php | 4 +-- .../rslight/scripts/rslight-lib.php | 25 ++++++++++--------- Rocksolid_Light/rslight/scripts/spoolnews.php | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 58b2a0d..12c2c0a 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1279,7 +1279,7 @@ function rslight_db_open($database, $table='overview') { id INTEGER PRIMARY KEY, newsgroup TEXT, number TEXT, - msgid TEXT UNIQUE, + msgid TEXT, date TEXT, name TEXT, subject TEXT)"); @@ -1304,7 +1304,7 @@ function article_db_open($database) { $dbh->exec("CREATE TABLE IF NOT EXISTS articles( id INTEGER PRIMARY KEY, newsgroup TEXT, - number TEXT, + number TEXT UNIQUE, msgid TEXT UNIQUE, date TEXT, name TEXT, diff --git a/Rocksolid_Light/rslight/scripts/rslight-lib.php b/Rocksolid_Light/rslight/scripts/rslight-lib.php index b44557c..1eca0d7 100755 --- a/Rocksolid_Light/rslight/scripts/rslight-lib.php +++ b/Rocksolid_Light/rslight/scripts/rslight-lib.php @@ -687,7 +687,7 @@ function get_db_article($article, $group) { $msg2=""; $ok_article = 0; $database = $spooldir.'/'.$nntp_group.'-articles.db3'; - $dbh = article_db_open($database); + $dbh = rslight_db_open($database); // Use article pointer if(!isset($article) && is_numeric($nntp_article)) { $article = $nntp_article; @@ -1136,16 +1136,17 @@ $date_i,$mid_i,$references_i,$bytes_i,$lines_i,$xref_i) { } function get_article_list($thisgroup) { - global $spooldir; - $group_overviewfp=fopen($spooldir."/".$thisgroup."-overview", 'r'); - $ok_article=array(); - while($line = fgets($group_overviewfp)) { - $art=explode("\t", $line); - if(is_numeric($art[0])) { - $ok_article[] = $art[0]; - } - } - fclose($group_overviewfp); - return($ok_article); + global $spooldir; + $database = $spooldir."/articles-overview.db3"; + $table = 'overview'; + $dbh = rslight_db_open($database, $table); + $stmt = $dbh->prepare("SELECT * FROM overview WHERE newsgroup=:thisgroup ORDER BY number"); + $stmt->execute(['thisgroup' => $thisgroup]); + $ok_article=array(); + while($found = $stmt->fetch()) { + $ok_article[] = $found['number']; + } + $dbh = null; + return(array_unique($ok_article)); } ?> diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index 8261521..5ff98c2 100755 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -91,7 +91,7 @@ $enable_rslight=0; } $ns=nntp2_open($CONFIG['remote_server'], $CONFIG['remote_port']); $ns2=nntp_open(); -if($ns == false) { +if(!$ns) { file_put_contents($logfile, "\n".format_log_date()." ".$config_name." Failed to connect to ".$CONFIG['remote_server'].":".$CONFIG['remote_port'], FILE_APPEND); exit(); }