From 8dea5588d9748673f0bf32738b8f9c6bccce487f Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Wed, 27 Dec 2023 03:18:48 -0700 Subject: [PATCH] Fix maintaining last article pulled from remote log. --- Rocksolid_Light/rocksolid/newsportal.php | 33 +++++++++++++++++++ Rocksolid_Light/rslight/scripts/spoolnews.php | 28 +++++++--------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index f6a24e6..bcf7598 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1762,6 +1762,39 @@ function get_poster_name($name) return ($thisposter); } +function save_config_value($configfile, $name, $value) { + $list = file($configfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + $saveconfig = fopen($configfile, 'w+'); + foreach ($list as $save) { + $name = explode(':', $save); + if (strcmp($name[0], $group) == 0) { + fputs($saveconfig, $group . ":" . $article . "\n"); + } else { + fputs($saveconfig, $save . "\n"); + } + } +} + +function get_config_file_value($configfile, $request) +{ + if ($configFileHandle = @fopen($configfile, 'r')) { + while (! feof($configFileHandle)) { + $buffer = fgets($configFileHandle); + if (strpos($buffer, $request . ':') !== FALSE) { + $dataline = $buffer; + fclose($configFileHandle); + $datafound = explode(':', $dataline); + return trim($datafound[1]); + } + } + fclose($configFileHandle); + return FALSE; + } else { + return FALSE; + } +} + +// This function is specific to user configuration values function get_config_value($configfile, $request) { global $config_dir; diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index 3b0e2f1..e7e93c4 100644 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -143,16 +143,17 @@ if ($CONFIG['remote_server'] != '') { file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Retrieving articles for: " . $name[0] . "...", FILE_APPEND); echo "\nRetrieving articles for: " . $name[0] . "..."; get_articles($ns, $name[0]); - +/* if ($enable_rslight == 1) { if ($timer) { if ($ns2) { file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Updating threads for: " . $name[0] . "...", FILE_APPEND); echo 'Use ns2: ' . $ns2 . "\n"; - // thread_load_newsserver($ns2, $name[0], 0); + thread_load_newsserver($ns2, $name[0], 0); } } } +*/ } nntp_close($ns2); nntp_close($ns); @@ -187,7 +188,6 @@ function get_articles($ns, $group) echo "\n" . $response; return (1); } - # Get config $grouplist = file($remote_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); foreach ($grouplist as $findgroup) { @@ -201,6 +201,7 @@ function get_articles($ns, $group) break; } } + if (isset($CONFIG['enable_nntp']) && $CONFIG['enable_nntp'] == true) { // Get next available article number for group $local = get_next_article_number($group); @@ -224,6 +225,7 @@ function get_articles($ns, $group) } else { $getlast = $detail[3]; } + fputs($ns, "xover " . $article . "-" . $getlast . "\r\n"); $response = line_read($ns); // and once more if ((substr($response, 0, 3) != "224")) { @@ -492,6 +494,8 @@ function get_articles($ns, $group) } } # Save config + $configfile = '/var/spool/rslight/rocksolid/test-config.txt'; + save_config_value($configfile, $name, $value); $grouplist = file($remote_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $saveconfig = fopen($remote_groupfile, 'w+'); foreach ($grouplist as $savegroup) { @@ -525,27 +529,17 @@ function create_spool_groups($in_groups, $out_groups) global $spooldir; $grouplist = file($in_groups, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $temp_file = tempnam($spooldir . "/tmp/", 'groupfile-'); - $groupout = fopen($out_groups, "a+"); foreach ($grouplist as $group) { if ($group[0] == ":") { continue; } $thisgroup = preg_split("/( |\t)/", $group, 2); - $found = 0; - while (($buffer = fgets($groupout)) !== false) { - $mod_buffer = explode(':', $buffer); - if (strcmp($thisgroup[0], $mod_buffer[0]) == 0) { - file_put_contents($temp_file, "$buffer", FILE_APPEND); - $found = 1; - break; - } - } - if ($found == 0) { - file_put_contents($temp_file, "$thisgroup[0]\n", FILE_APPEND); - continue; + if($val = get_config_file_value($out_groups, $thisgroup[0])) { + file_put_contents($temp_file, $thisgroup[0].":".$val."\n", FILE_APPEND); + } else { + file_put_contents($temp_file, $thisgroup[0]."\n", FILE_APPEND); } } - fclose($groupout); rename($temp_file, $out_groups); return; }