Fix maintaining last article pulled from remote log.
This commit is contained in:
parent
8ecdbdae6f
commit
8dea5588d9
|
@ -1762,6 +1762,39 @@ function get_poster_name($name)
|
||||||
return ($thisposter);
|
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)
|
function get_config_value($configfile, $request)
|
||||||
{
|
{
|
||||||
global $config_dir;
|
global $config_dir;
|
||||||
|
|
|
@ -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);
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Retrieving articles for: " . $name[0] . "...", FILE_APPEND);
|
||||||
echo "\nRetrieving articles for: " . $name[0] . "...";
|
echo "\nRetrieving articles for: " . $name[0] . "...";
|
||||||
get_articles($ns, $name[0]);
|
get_articles($ns, $name[0]);
|
||||||
|
/*
|
||||||
if ($enable_rslight == 1) {
|
if ($enable_rslight == 1) {
|
||||||
if ($timer) {
|
if ($timer) {
|
||||||
if ($ns2) {
|
if ($ns2) {
|
||||||
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Updating threads for: " . $name[0] . "...", FILE_APPEND);
|
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Updating threads for: " . $name[0] . "...", FILE_APPEND);
|
||||||
echo 'Use ns2: ' . $ns2 . "\n";
|
echo 'Use ns2: ' . $ns2 . "\n";
|
||||||
// thread_load_newsserver($ns2, $name[0], 0);
|
thread_load_newsserver($ns2, $name[0], 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
nntp_close($ns2);
|
nntp_close($ns2);
|
||||||
nntp_close($ns);
|
nntp_close($ns);
|
||||||
|
@ -187,7 +188,6 @@ function get_articles($ns, $group)
|
||||||
echo "\n" . $response;
|
echo "\n" . $response;
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get config
|
# Get config
|
||||||
$grouplist = file($remote_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
$grouplist = file($remote_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
foreach ($grouplist as $findgroup) {
|
foreach ($grouplist as $findgroup) {
|
||||||
|
@ -201,6 +201,7 @@ function get_articles($ns, $group)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($CONFIG['enable_nntp']) && $CONFIG['enable_nntp'] == true) {
|
if (isset($CONFIG['enable_nntp']) && $CONFIG['enable_nntp'] == true) {
|
||||||
// Get next available article number for group
|
// Get next available article number for group
|
||||||
$local = get_next_article_number($group);
|
$local = get_next_article_number($group);
|
||||||
|
@ -224,6 +225,7 @@ function get_articles($ns, $group)
|
||||||
} else {
|
} else {
|
||||||
$getlast = $detail[3];
|
$getlast = $detail[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs($ns, "xover " . $article . "-" . $getlast . "\r\n");
|
fputs($ns, "xover " . $article . "-" . $getlast . "\r\n");
|
||||||
$response = line_read($ns); // and once more
|
$response = line_read($ns); // and once more
|
||||||
if ((substr($response, 0, 3) != "224")) {
|
if ((substr($response, 0, 3) != "224")) {
|
||||||
|
@ -492,6 +494,8 @@ function get_articles($ns, $group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Save config
|
# 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);
|
$grouplist = file($remote_groupfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
$saveconfig = fopen($remote_groupfile, 'w+');
|
$saveconfig = fopen($remote_groupfile, 'w+');
|
||||||
foreach ($grouplist as $savegroup) {
|
foreach ($grouplist as $savegroup) {
|
||||||
|
@ -525,27 +529,17 @@ function create_spool_groups($in_groups, $out_groups)
|
||||||
global $spooldir;
|
global $spooldir;
|
||||||
$grouplist = file($in_groups, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
$grouplist = file($in_groups, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||||
$temp_file = tempnam($spooldir . "/tmp/", 'groupfile-');
|
$temp_file = tempnam($spooldir . "/tmp/", 'groupfile-');
|
||||||
$groupout = fopen($out_groups, "a+");
|
|
||||||
foreach ($grouplist as $group) {
|
foreach ($grouplist as $group) {
|
||||||
if ($group[0] == ":") {
|
if ($group[0] == ":") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$thisgroup = preg_split("/( |\t)/", $group, 2);
|
$thisgroup = preg_split("/( |\t)/", $group, 2);
|
||||||
$found = 0;
|
if($val = get_config_file_value($out_groups, $thisgroup[0])) {
|
||||||
while (($buffer = fgets($groupout)) !== false) {
|
file_put_contents($temp_file, $thisgroup[0].":".$val."\n", FILE_APPEND);
|
||||||
$mod_buffer = explode(':', $buffer);
|
} else {
|
||||||
if (strcmp($thisgroup[0], $mod_buffer[0]) == 0) {
|
file_put_contents($temp_file, $thisgroup[0]."\n", FILE_APPEND);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose($groupout);
|
|
||||||
rename($temp_file, $out_groups);
|
rename($temp_file, $out_groups);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue