Allow disabling remote push in overrides.inc.php.

This commit is contained in:
Retro_Guy 2024-10-15 06:15:37 -07:00
parent 82ec577987
commit 8ff85b54e7
4 changed files with 31 additions and 3 deletions

View File

@ -81,6 +81,10 @@ return [
// for a SECTION. Comma separated list ex: 'rocksolid,section3,section5',
'insert_disable' => 'sectionONE, sectionTWO',
// Disable pushing articles to remote server for these sections
// (replace 'testsection...' with your choice of sections)
'disable_remote_push' => array("testsectionone", "testsectiontwo"),
// Disable posting attachments by section
// List section names to disable:
// array("sectionONE", "sectionTWO", "sectionETC"),

View File

@ -144,7 +144,18 @@ foreach ($menulist as $menu) {
}
$menuitem = explode(':', $menu);
chdir("../" . $menuitem[0]);
if ($CONFIG['remote_server'] !== '') {
$this_config_name = $menuitem[0];
if(file_exists($config_dir.$this_config_name.'.inc.php')) {
$config_file = $config_dir.$this_config_name.'.inc.php';
} else {
$config_file = $config_dir.'rslight.inc.php';
}
$this_CONFIG = include($config_file);
file_put_contents($debug_log, "\n" . format_log_date() . " Using " . $config_file . " for " . $menuitem[0], FILE_APPEND);
if ($this_CONFIG['remote_server'] !== '') {
# Send articles
echo "Sending articles\n";
echo exec($CONFIG['php_exec'] . " " . $config_dir . "/scripts/send.php");
@ -153,6 +164,8 @@ foreach ($menulist as $menu) {
exec($CONFIG['php_exec'] . " " . $config_dir . "/scripts/spoolnews.php");
echo "\nRefreshed spoolnews\n";
}
} else {
file_put_contents($debug_log, "\n" . format_log_date() . " Remote disabled for " . $menuitem[0] . " (no remote server)", FILE_APPEND);
}
# Expire articles
exec($CONFIG['php_exec'] . " " . $config_dir . "/scripts/expire.php");

View File

@ -54,7 +54,7 @@ echo "\nSend Done\r\n";
function post_articles($ns, $spooldir)
{
global $logfile, $config_name;
global $CONFIG, $OVERRIDES, $logfile, $debug_log, $config_name;
$outgoing_dir = $spooldir . "/" . $config_name . "/outgoing/";
$fail_dir = $outgoing_dir . '/failed/';
@ -66,6 +66,16 @@ function post_articles($ns, $spooldir)
return "No messages to send\r\n";
}
// Check overrides.inc.php if this section is disabled for remote push
if (isset($OVERRIDES['disable_remote_push'])) {
foreach ($OVERRIDES['disable_remote_push'] as $disable) {
if ($config_name == $disable) {
file_put_contents($debug_log, "\n" . format_log_date() . " Remote push disabled for " . $config_name . " by override", FILE_APPEND);
return "Remote push disabled for this section: " . $config_name;
}
}
}
$messages = scandir($outgoing_dir);
foreach ($messages as $message) {
if (! is_file($outgoing_dir . $message)) {

View File

@ -447,6 +447,7 @@ function get_articles($ns, $group)
$bytes = $bytes + ($lines * 2);
// Prefer Injection-Date to Date header
// Some newsreaders (PiaoHong) produce a Date header that php does not like
if (isset($injectiondate)) {
$artdate = $injectiondate;
file_put_contents($debug_log, "\n" . format_log_date() . " " . $config_name . " Used Injection-Date " . $artdate . " for: " . $mid[1], FILE_APPEND);
@ -464,7 +465,7 @@ function get_articles($ns, $group)
$dates_used[$article_date] = true;
// Don't spool article if $banned or fails integrity test
$integrity = check_article_integrity(file($articleHandle));
$integrity = check_article_integrity(file($articleHandle), $artdate);
if (($banned !== false) || ($integrity !== false)) {
unlink($articleHandle);
if ($integrity) {