Merge branch 'devel' 0.9.159

This commit is contained in:
Retro_Guy 2024-10-16 16:03:18 -07:00
commit 2f13f8245a
9 changed files with 203 additions and 101 deletions

View File

@ -1 +1 @@
0.9.158
0.9.159

View File

@ -278,10 +278,11 @@ function message_read($id, $bodynum = 0, $group = "")
$line = line_read($ns);
if (substr($line, 0, 3) != "220") {
// requested article doesn't exist on the newsserver. Now we
// should check, if the thread stored in the spool-directory
// should check if the thread stored in the spool-directory
// also doesnt't contain that article...
thread_cache_removearticle($group, $id);
file_put_contents($debug_log, "\n" . logging_prefix() . " " . $config_name . " Unable to retrieve: " . $group . ":" . $id . " from local server. Removing...", FILE_APPEND);
// This is most likely a bot calling an old article, not a bug
// file_put_contents($debug_log, "\n" . logging_prefix() . " " . $config_name . " Unable to retrieve: " . $group . ":" . $id . " from local server. Removing...", FILE_APPEND);
return false;
} else {
}

View File

@ -596,8 +596,8 @@ function groups_show($gruppen)
$subs = array();
$nonsubs = array();
$user = null;
// Get registered user settings
// Get registered user settings
$cookie_mail_name = $_COOKIE['mail_name'];
if (isset($_COOKIE['mail_name']) && $_COOKIE['mail_name'] == $CONFIG['anonusername']) {
unset($cookie_mail_name);
@ -606,8 +606,15 @@ function groups_show($gruppen)
if ($userdata = get_user_mail_auth_data($cookie_mail_name)) {
$userfile = $spooldir . '/' . strtolower($cookie_mail_name) . '-articleviews.dat';
$user_config = unserialize(file_get_contents($config_dir . '/userconfig/' . strtolower($cookie_mail_name) . '.config'));
// User blocklist
$blocked_userfile = $spooldir . '/' . strtolower($_COOKIE['mail_name']) . '-blocked_posters.dat';
if (file_exists($blocked_userfile)) {
$blocked_user_config = unserialize(file_get_contents($blocked_userfile));
}
}
}
for ($i = 0; $i < $c; $i++) {
unset($groupdisplay);
$g = $gruppen[$i];
@ -793,9 +800,22 @@ function groups_show($gruppen)
$groupdisplay .= get_date_interval(date("D, j M Y H:i T", $lastarticleinfo['date']));
$groupdisplay .= '<table><tr><td>';
$groupdisplay .= '<font class="np_last_posted_date">by: ';
$groupdisplay .= create_name_link($lastarticleinfo['name'], $name_from);
$block = false;
foreach ($blocked_user_config as $key => $value) {
$blockme = '/' . addslashes($key) . '/';
if (preg_match($blockme, $name_from)) {
$block = true;
break;
}
}
$groupdisplay .= '<font class="np_last_posted_date">by: ';
if ($block) {
$groupdisplay .= "(blocked user)";
} else {
$groupdisplay .= create_name_link($lastarticleinfo['name'], $name_from);
}
$groupdisplay .= '</td></tr></table>';
} else {
unset($lastarticleinfo);
@ -1651,7 +1671,7 @@ function repair_broken_group($group)
$newsportal_start = explode(" ", $newsportal_info);
$rslight_start = explode(" ", $rslight_info);
if ($newsportal_start[0] != $rslight_start[0] || (($rslight_start[2] - $newsportal_start[2]) > 10)) {
file_put_contents($debug_log, "\n " . format_log_date() . " GROUP MISMATCH: " . $group . " rslight: " . $rslight_info . " newsportal: " . $newsportal_info . " Repairing...", FILE_APPEND);
file_put_contents($debug_log, "\n" . format_log_date() . " GROUP MISMATCH: " . $group . " rslight: " . $rslight_info . " newsportal: " . $newsportal_info . " Repairing...", FILE_APPEND);
wipe_newsportal_spool_info($group);
}
}
@ -3099,7 +3119,7 @@ function delete_message($messageid, $group = null, $overview_dbh = null)
// This function returns FALSE if article is OK
// Else returns a string with reason for failure
function check_article_integrity($rawmessage)
function check_article_integrity($rawmessage, $artdate = false)
{
global $CONFIG, $logfile, $config_name;
$returnval = false;
@ -3114,14 +3134,17 @@ function check_article_integrity($rawmessage)
// Parse the Header:
$message->header = parse_header($rawheader);
if (!$artdate) {
$artdate = $message->header->date;
}
// Check if date is in future (allow up to 60 seconds in future)
if ($message->header->date > (time() + 60)) {
$returnval = " Skipping message (date in future): " . $message->header->id . " (" . date('M d H:i:s', $message->header->date) . ")";
if ($artdate > (time() + 60)) {
$returnval = "437 401 Skipping message (date in future): " . $message->header->id . " (" . date('M d H:i:s', $artdate) . ")";
return $returnval;
}
// Date is probably 1 Jan 1970
if ($message->header->date < 100) {
$returnval = " Skipping message (date too old): " . $message->header->id . " (" . date('M d H:i:s', $message->header->date) . ")";
if ($artdate < 100) {
$returnval = "437 402 Skipping message (date too old): " . $message->header->id . " (" . date('M d H:i:s', $artdate) . ")";
return $returnval;
}
// Now we know if the message is a mime-multipart message:

View File

@ -27,67 +27,9 @@ if ((! isset($_POST['key']) || ! password_verify($CONFIG['thissitekey'], $_POST[
exit();
}
echo '<h1 class="np_thread_headline">';
echo '<a href="' . $file_index . '" target=' . $frame['menu'] . '>' . basename(getcwd()) . '</a> / ';
if ($search_group) {
echo '<a href="' . $file_thread . '?group=' . urlencode($search_group) . '" target=' . $frame['menu'] . '>' . $search_group . '</a> / ';
}
echo 'search</h1>';
echo '<table cellpadding="0" cellspacing="0" class="np_buttonbar"><tr>';
if (isset($search_group)) {
$searching = $search_group;
} else {
$searching = $config_name;
}
echo '<body>';
echo '<table width=100% border="0" align="center" cellpadding="0" cellspacing="1">';
echo '<tr>';
echo '<form name="form1" method="post" action="search.php">';
echo '<td>';
echo '<table width="100%" align="center" border="0" cellpadding="3" cellspacing="1">';
echo '<tr>';
echo '<td colspan="3">Searching <strong>' . $searching . '</strong></td>';
echo '</tr>';
echo '<tr>';
if (! isset($_REQUEST['data'])) {
echo '<td>Search Terms:&nbsp';
} else {
echo '<td>Search Poster:&nbsp';
}
if (isset($_GET['terms'])) {
echo '<input name="terms" type="text" id="terms" value="' . $_GET['terms'] . '"></td>';
} else {
echo '<input name="terms" type="text" id="terms"></td>';
}
echo '</tr><tr><td>';
if (isset($_GET['searchpoint']) && $_GET['searchpoint'] == 'Poster') {
if ($CONFIG['article_database'] == '1') {
echo '<input type="radio" name="searchpoint" value="body"/>Body&nbsp;';
}
echo '<input type="radio" name="searchpoint" value="subject"/>Subject&nbsp;';
echo '<input type="radio" name="searchpoint" value="name" checked="checked"/>Poster&nbsp;';
echo '<input type="radio" name="searchpoint" value="msgid"/>Message-ID';
} else {
if ($CONFIG['article_database'] == '1') {
echo '&nbsp;<input type="radio" name="searchpoint" value="body" checked="checked"/>Body&nbsp;';
}
echo '<input type="radio" name="searchpoint" value="subject"/>Subject&nbsp;';
echo '<input type="radio" name="searchpoint" value="name"/>Poster&nbsp;';
echo '<input type="radio" name="searchpoint" value="msgid"/>Message-ID';
}
echo '</td></tr>';
echo '<tr>';
echo '<td><input name="command" type="hidden" id="command" value="Search" readonly="readonly"></td>';
if (isset($search_group)) {
echo '<input type="hidden" name="group" value="' . urlencode($search_group) . '">';
}
echo '<input type="hidden" name="key" value="' . password_hash($CONFIG['thissitekey'], PASSWORD_DEFAULT) . '">';
if (isset($_GET['data'])) {
echo '<input type="hidden" name="data" value="' . $_GET['data'] . '">';
}
echo '</tr><tr>';
echo '<td><input type="submit" name="Submit" value="Search"></td>';
echo '</tr></table></td></form></tr></table>';
// Display search tools
display_search_tools();
// Block poster
if (isset($_COOKIE['mail_name'])) {
if (isset($_REQUEST['data'])) {
@ -140,16 +82,16 @@ if ((! isset($_POST['key']) || ! password_verify($CONFIG['thissitekey'], $_POST[
}
if (isset($frames_on) && $frames_on === true) {
?>
<script>
var contentURL=window.location.pathname+window.location.search+window.location.hash;
if ( window.self !== window.top ) {
/* Great! now we move along */
} else {
window.location.href = '../index.php?content='+encodeURIComponent(contentURL);
}
top.history.replaceState({}, 'Title', 'index.php?content='+encodeURIComponent(contentURL));
</script>
?>
<script>
var contentURL = window.location.pathname + window.location.search + window.location.hash;
if (window.self !== window.top) {
/* Great! now we move along */
} else {
window.location.href = '../index.php?content=' + encodeURIComponent(contentURL);
}
top.history.replaceState({}, 'Title', 'index.php?content=' + encodeURIComponent(contentURL));
</script>
<?php
}
@ -198,6 +140,9 @@ if (isset($_POST['block_poster'])) {
exit(0);
}
display_search_tools();
echo "<hr>";
ob_start();
if (isset($search_group)) {
echo '<h1 class="np_thread_headline">';
@ -296,8 +241,7 @@ foreach ($overview as $overviewline) {
$fromline = address_decode(headerDecode($overviewline['name']), "nowhere");
if (! isset($fromline[0]["personal"])) {
$lastname = $fromline[0]["mailbox"];
;
$lastname = $fromline[0]["mailbox"];;
} else {
$lastname = $fromline[0]["personal"];
}
@ -342,7 +286,7 @@ foreach ($overview as $overviewline) {
}
echo $snip;
echo '</td></tr>';
if ($results ++ > ($maxdisplay - 2))
if ($results++ > ($maxdisplay - 2))
break;
}
@ -359,10 +303,10 @@ echo $thispage;
function get_body_search($group, $terms)
{
GLOBAL $CONFIG, $config_name, $config_dir, $debug_log, $spooldir, $snippet_size;
global $CONFIG, $config_name, $config_dir, $debug_log, $spooldir, $snippet_size;
$terms = preg_replace("/'/", ' ', $terms);
$terms = trim($terms);
if ($terms[0] !== '"' || substr($terms, - 1) !== '"') {
if ($terms[0] !== '"' || substr($terms, -1) !== '"') {
$terms = preg_replace('/"/', '', $terms);
$terms = preg_replace("/\ /", '" "', $terms);
$terms = preg_replace('/"NEAR"/', 'NEAR', $terms);
@ -385,7 +329,7 @@ function get_body_search($group, $terms)
continue;
}
$dbh = article_db_open($database);
if(!$dbh) {
if (!$dbh) {
file_put_contents($debug_log, "\n" . format_log_date() . " " . $config_name . " Failed to open database: " . $database . " in search.php", FILE_APPEND);
continue;
}
@ -439,7 +383,7 @@ function show_search_sort_toggle()
function get_header_search($group, $terms)
{
GLOBAL $CONFIG, $config_name, $config_dir, $spooldir, $debug_log, $snippet_size;
global $CONFIG, $config_name, $config_dir, $spooldir, $debug_log, $snippet_size;
$terms = preg_replace('/\%/', '\%', $terms);
$searchterms = "%" . $terms . "%";
@ -464,7 +408,7 @@ function get_header_search($group, $terms)
continue;
}
$article_dbh = article_db_open($article_database);
if(!$article_dbh) {
if (!$article_dbh) {
file_put_contents($debug_log, "\n" . format_log_date() . " " . $config_name . " Failed to open database: " . $article_database . " in search.php", FILE_APPEND);
continue;
}
@ -512,6 +456,98 @@ function get_header_search($group, $terms)
return $overview;
}
function display_search_tools($home = true)
{
global $CONFIG, $config_name, $search_group, $file_index, $file_thread;
echo '<h1 class="np_thread_headline">';
echo '<a href="' . $file_index . '" target=' . $frame['menu'] . '>' . basename(getcwd()) . '</a> / ';
if ($search_group) {
echo '<a href="' . $file_thread . '?group=' . urlencode($search_group) . '" target=' . $frame['menu'] . '>' . $search_group . '</a> / ';
}
echo 'search</h1>';
echo '<table cellpadding="0" cellspacing="0" class="np_buttonbar"><tr>';
if (isset($search_group)) {
$searching = $search_group;
} else {
$searching = $config_name;
}
echo '<body>';
echo '<table width=100% border="0" align="center" cellpadding="0" cellspacing="1">';
echo '<tr>';
echo '<form name="form1" method="post" action="search.php">';
echo '<td>';
echo '<table width="100%" align="center" border="0" cellpadding="3" cellspacing="1">';
echo '<tr>';
echo '<td colspan="3">Searching <strong>' . $searching . '</strong></td>';
echo '</tr>';
echo '<tr>';
if (! isset($_REQUEST['data'])) {
echo '<td>Search Terms:&nbsp';
} else {
echo '<td>Search Poster:&nbsp';
}
if (isset($_REQUEST['terms'])) {
echo '<input name="terms" type="text" id="terms" value="' . $_REQUEST['terms'] . '"></td>';
} else {
echo '<input name="terms" type="text" id="terms"></td>';
}
echo '</tr><tr><td>';
// Create radio buttons (prefilled if available)
if (isset($_REQUEST['searchpoint'])) {
if ($_REQUEST['searchpoint'] == 'Poster' || $_REQUEST['searchpoint'] == 'name') {
if ($CONFIG['article_database'] == '1') {
echo '<input type="radio" name="searchpoint" value="body"/>Body&nbsp;';
}
echo '<input type="radio" name="searchpoint" value="subject"/>Subject&nbsp;';
echo '<input type="radio" name="searchpoint" value="name" checked="checked"/>Poster&nbsp;';
echo '<input type="radio" name="searchpoint" value="msgid"/>Message-ID';
} elseif ($_REQUEST['searchpoint'] == 'subject') {
if ($CONFIG['article_database'] == '1') {
echo '&nbsp;<input type="radio" name="searchpoint" value="body"/>Body&nbsp;';
}
echo '<input type="radio" name="searchpoint" value="subject" checked="checked"/>Subject&nbsp;';
echo '<input type="radio" name="searchpoint" value="name"/>Poster&nbsp;';
echo '<input type="radio" name="searchpoint" value="msgid"/>Message-ID';
} elseif ($_REQUEST['searchpoint'] == 'msgid') {
if ($CONFIG['article_database'] == '1') {
echo '&nbsp;<input type="radio" name="searchpoint" value="body"/>Body&nbsp;';
}
echo '<input type="radio" name="searchpoint" value="subject"/>Subject&nbsp;';
echo '<input type="radio" name="searchpoint" value="name"/>Poster&nbsp;';
echo '<input type="radio" name="searchpoint" value="msgid" checked="checked"/>Message-ID';
} else {
if ($CONFIG['article_database'] == '1') {
echo '&nbsp;<input type="radio" name="searchpoint" value="body" checked="checked"/>Body&nbsp;';
}
echo '<input type="radio" name="searchpoint" value="subject"/>Subject&nbsp;';
echo '<input type="radio" name="searchpoint" value="name"/>Poster&nbsp;';
echo '<input type="radio" name="searchpoint" value="msgid"/>Message-ID';
}
} else {
if ($CONFIG['article_database'] == '1') {
echo '&nbsp;<input type="radio" name="searchpoint" value="body" checked="checked"/>Body&nbsp;';
}
echo '<input type="radio" name="searchpoint" value="subject"/>Subject&nbsp;';
echo '<input type="radio" name="searchpoint" value="name"/>Poster&nbsp;';
echo '<input type="radio" name="searchpoint" value="msgid"/>Message-ID';
}
echo '</td></tr>';
echo '<tr>';
echo '<td><input name="command" type="hidden" id="command" value="Search" readonly="readonly"></td>';
if (isset($search_group)) {
echo '<input type="hidden" name="group" value="' . urlencode($search_group) . '">';
}
echo '<input type="hidden" name="key" value="' . password_hash($CONFIG['thissitekey'], PASSWORD_DEFAULT) . '">';
if (isset($_REQUEST['data'])) {
echo '<input type="hidden" name="data" value="' . $_REQUEST['data'] . '">';
}
echo '</tr><tr>';
echo '<td><input type="submit" name="Submit" value="Search"></td>';
echo '</tr></table></td></form></tr></table>';
}
function highlightStr($haystack, $needle)
{
preg_match_all("/$needle+/i", $haystack, $matches);
@ -524,4 +560,5 @@ function highlightStr($haystack, $needle)
}
?>
</body>
</html>

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

@ -24,6 +24,7 @@ if (isset($CONFIG['enable_nntp']) && $CONFIG['enable_nntp'] == true) {
$fp1 = $spooldir . "/" . $config_name . "/groups.txt";
unlink($fp1);
touch($fp1);
$group_exists = array();
foreach ($menulist as $menu) {
if (($menu[0] == '#') || trim($menu) == "") {
continue;
@ -35,8 +36,11 @@ if (isset($CONFIG['enable_nntp']) && $CONFIG['enable_nntp'] == true) {
if (($ok_group[0] == ':') || (trim($ok_group) == "")) {
continue;
}
$ok_group = preg_split("/( |\t)/", trim($ok_group), 2);
file_put_contents($fp1, $ok_group[0] . "\r\n", FILE_APPEND);
$entry = preg_split("/( |\t)/", trim($ok_group), 2);
if (!isset($group_exists[$entry[0]])) {
file_put_contents($fp1, $entry[0] . "\n", FILE_APPEND);
}
$group_exists[$entry[0]] = true;
}
}
}
@ -140,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");
@ -149,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

@ -143,14 +143,23 @@ function create_section($section = false)
$menuexists = false;
$menudata = file($config_dir . '/menu.conf');
$newmenu = array();
foreach ($menudata as $menuentry) {
if(trim($menuentry) == '') {
continue;
}
if (strpos($menuentry, $section) !== false) {
echo "Menu entry already exists for: " . $section . "\n";
$menuexists = true;
break;
}
$newmenu[] = $menuentry;
}
if (!$menuexists) {
file_put_contents($config_dir . '/menu.conf', $section . ":1:1", FILE_APPEND);
echo "Adding menu entry to " . $config_dir . "menu.conf\n";
$newmenu[] = $section . ":1:1\n";
$newmenu = implode($newmenu);
file_put_contents($config_dir . 'menu.conf', $newmenu);
}
echo 'Please now edit ' . $configsection . "/groups.txt to add groups to this section\n";
}

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,11 +447,12 @@ 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 for: " . $mid[1], FILE_APPEND);
file_put_contents($debug_log, "\n" . format_log_date() . " " . $config_name . " Used Injection-Date " . $artdate . " for: " . $mid[1], FILE_APPEND);
} else {
// file_put_contents($debug_log, "\n" . format_log_date() . " " . $config_name . " Used Date for: " . $mid[1], FILE_APPEND);
file_put_contents($debug_log, "\n" . format_log_date() . " " . $config_name . " Used Date " . $artdate . " for: " . $mid[1], FILE_APPEND);
}
// Check if date matches exactly another article and handle else sorting doesn't like it
@ -464,11 +465,11 @@ 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) {
file_put_contents($logfile, "\n" . format_log_date() . $integrity, FILE_APPEND);
file_put_contents($logfile, "\n" . format_log_date() . " " . $integrity, FILE_APPEND);
} elseif ($banned) {
file_put_contents($spamlog, "\n" . format_log_date() . " " . $banned . " :\tSPAM\t" . $mid[1] . "\t" . $groupnames[1] . "\t" . $from[1], FILE_APPEND);
}