Merge branch 'devel'

This commit is contained in:
Retro_Guy 2024-07-14 04:24:39 -07:00
commit 11859f8734
11 changed files with 151 additions and 153 deletions

View File

@ -16,4 +16,3 @@ if (file_exists('mods/header.php')) {
}
echo '<hr>';
echo '</head>';

View File

@ -1,5 +1,3 @@
<html>
<head>
<?php
if (basename(getcwd()) == 'mods') {
$rootdir = "../../";
@ -64,10 +62,9 @@ if ((isset($_SESSION['theme'])) && file_exists($rootdir . 'common/themes/' . $_S
} else {
$header_image = $rootdir . 'common/images/rocksolidlight.png';
}
echo '</head><body textcolor="black" bgcolor="white">';
echo '<div id = "loading_indicator"> </div>';
?>
</head>
<body>
<div id = "loading_indicator"> </div>
<script>
document.addEventListener('readystatechange', e => {
@ -232,8 +229,3 @@ function head_mail_db_open($database, $table = 'messages')
to_hide TEXT)");
return ($dbh);
}
?>
</body>
</html>

View File

@ -1 +1 @@
0.9.138
0.9.139

View File

@ -171,8 +171,9 @@ if ($message) {
$thread_show["lastdate"] = false;
$thread_show["latest"] = false;
$thread_show["author"] = true;
// message_thread($message->header->id,$group,$thread,$pageids);
message_thread($message->header->id, $group, $thread, false);
if(isset($OVERRIDES['show_thread_tree']) && $OVERRIDES['show_thread_tree'] == true) {
message_thread($message->header->id, $group, $thread, false);
}
echo '<br>';
echo '<a name="start"></a>';
// navigation line

View File

@ -27,5 +27,4 @@ if (isset($frames_on) && $frames_on === false) {
include "../common/header.php";
}
}
echo '<hr></head>';
echo '<body textcolor="black" bgcolor="white">';
echo '<hr>';

View File

@ -68,51 +68,8 @@ function thread_pageselect($group, $article_count, $first)
function thread_cache_load($group)
{
global $spooldir, $config_dir, $logdir, $compress_spoolfiles;
if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/cache.inc.php';
}
// Check memcache
if ($enable_cache) {
$cache_key = $cache_key_prefix . '_' . 'thread_cache-' . $group;
$message_data = cache_get($cache_key, $memcacheD);
if ($message_data) {
if ($headers = unserialize(gzuncompress($message_data))) {
if ($enable_cache_logging) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache hit) $cache_key", FILE_APPEND);
}
return $headers;
}
}
}
$database = $spooldir . '/' . $group . '-data.db3';
$table = "threads";
if ($dbh = threads_db_open($database, $table)) {
$stmt = $dbh->prepare("SELECT * FROM $table");
$stmt->execute();
while ($row = $stmt->fetch()) {
$headers = unserialize($row['headers']);
break;
}
$dbh = null;
}
if ($enable_cache) {
$add_thread = gzcompress(serialize($headers), 9);
$thread_bytes = strlen($add_thread);
$too_big = false;
if ($thread_bytes < $cache_maxitemsize) {
$nicole = cache_add($cache_key, $add_thread, $cache_ttl, $memcacheD);
} else {
$nicole = false;
$too_big = true;
}
if ($nicole && $enable_cache_logging) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $cache_key (" . strlen($add_thread) . " bytes)", FILE_APPEND);
}
if ($too_big) {
file_put_contents($cache_log, "\n" . format_log_date() . " $cache_key too large (" . $thread_bytes . " bytes)", FILE_APPEND);
}
}
$headers = unserialize(file_get_contents($spooldir . '/' . $group . '-data.dat'));
return ($headers);
}
@ -125,56 +82,8 @@ function thread_cache_load($group)
function thread_cache_save($headers, $group)
{
global $spooldir, $compress_spoolfiles, $config_dir, $logdir, $config_name;
$logfile = $logdir . '/newsportal.log';
if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/cache.inc.php';
}
$database = $spooldir . '/' . $group . '-data.db3';
$table = "threads";
if ($dbh = threads_db_open($database, $table)) {
$drop = 'DROP TABLE IF EXISTS threads';
$drop_stmt = $dbh->prepare($drop);
$insert_sql = 'INSERT INTO ' . $table . '(headers) VALUES(?)';
$insert_stmt = $dbh->prepare($insert_sql);
$dbh->beginTransaction();
$drop_stmt->execute();
$dbh->exec("CREATE TABLE IF NOT EXISTS $table(
id INTEGER PRIMARY KEY,
headers TEXT,
unique (headers))");
$insert_stmt->execute([
serialize($headers)
]);
$dbh->commit();
$dbh = null;
if ($enable_cache) {
$cache_key = $cache_key_prefix . '_' . 'thread_cache-' . $group;
$del = cache_delete($cache_key, $memcacheD);
$add_thread = gzcompress(serialize($headers), 9);
$thread_bytes = strlen($add_thread);
$too_big = false;
if ($thread_bytes < $cache_maxitemsize) {
$nicole = cache_add($cache_key, $add_thread, $cache_ttl, $memcacheD);
} else {
$too_big = true;
$nicole = false;
}
if ($enable_cache_logging) {
if ($del) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache delete) $cache_key", FILE_APPEND);
}
if ($nicole) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) $cache_key (" . $thread_bytes . " bytes)", FILE_APPEND);
}
if ($too_big) {
file_put_contents($cache_log, "\n" . format_log_date() . " $cache_key too large (" . $thread_bytes . " bytes)", FILE_APPEND);
}
}
}
}
file_put_contents($spooldir . '/' . $group . '-data.dat', serialize($headers));
}
/*
@ -366,7 +275,7 @@ function thread_load_newsserver(&$ns, $groupname, $poll)
$maxfetch = 0;
$idstring = "0.36," . $server . "," . $compress_spoolfiles . "," . $maxarticles . "," . $maxarticles_extra . "," . $maxfetch . "," . $initialfetch . "," . $www_charset . ',' . $iconv_enable . ',' . $thread_show["replies"];
$overviewformat = thread_overview_read($ns);
$spoolfilename = $spooldir . '/' . $groupname . '-data.db3';
$spoolfilename = $spooldir . '/' . $groupname . '-data.dat';
fputs($ns, "GROUP $groupname\r\n"); // select a group
$response = line_read($ns);
$groupinfo = explode(" ", $response);
@ -893,7 +802,7 @@ function thread_format_lastmessage($c, $group = '')
$table = 'articles';
if (is_file($database)) {
$dbh = article_db_open($database, $table);
$stmt = $dbh->prepare("SELECT * FROM $table WHERE date=:date ORDER BY date DESC");
$stmt = $dbh->prepare("SELECT name,date,msgid,number FROM $table WHERE date=:date ORDER BY date DESC");
$stmt->bindParam(':date', $c->date_thread);
$stmt->execute();
if ($found = $stmt->fetch()) {
@ -907,7 +816,7 @@ function thread_format_lastmessage($c, $group = '')
$database = $spooldir . '/articles-overview.db3';
$table = 'overview';
$dbh = overview_db_open($database, $table);
$stmt = $dbh->prepare("SELECT * FROM $table WHERE newsgroup=:newsgroup AND date=:date ORDER BY date DESC");
$stmt = $dbh->prepare("SELECT name,date,msgid,number FROM $table WHERE newsgroup=:newsgroup AND date=:date ORDER BY date DESC");
$stmt->bindParam(':newsgroup', $group);
$stmt->bindParam(':date', $c->date_thread);
$stmt->execute();
@ -956,6 +865,8 @@ function thread_show_recursive(&$headers, &$liste, $depth, $tree, $group, $artic
global $file_article, $thread_maxSubject;
global $age_count, $age_time, $age_color, $spooldir;
global $frame_article;
global $last_thread;
global $debug_log;
$output = "";
if ($thread_treestyle == 3)
$output .= "\n<UL>\n";
@ -964,6 +875,16 @@ function thread_show_recursive(&$headers, &$liste, $depth, $tree, $group, $artic
$lineclass = "np_thread_line" . (($article_count % 2) + 1);
// read the first article
$c = $headers[$liste[$i]];
// Is a last message causing duplicates?
if(isset($last_thread) && $c->date_thread == $last_thread) {
// Seems we have more than one thread displayed for a single reply article
file_put_contents($debug_log, "\n" . format_log_date() . " " . $config_name . "Duplicate thread found in: " . $group . " msgid: " . $c->id, FILE_APPEND);
// This is hopefully temporary until date stuff is fixed
continue;
}
$last_thread = $c->date_thread;
// Avoid listing if error (fixme)
// if (preg_match('/\D/', $c->number)) {
if (! is_numeric($c->number) || ! isset($c->id) || $c->date < 1) {

View File

@ -2087,6 +2087,10 @@ function get_config_value($configfile, $request)
function disable_page_by_user_agent($client_device, $useragent, $script = "Page")
{
global $logdir, $config_name;
if (! $client_device) {
$client_device = get_client_user_agent_info();
}
$client_device = strtolower($client_device);
if ($client_device == $useragent) {
$logfile = $logdir . '/device.log';
file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " " . $script . " disabled for '" . $useragent . "' Exiting...", FILE_APPEND);
@ -2118,10 +2122,10 @@ function throttle_hits($client_device = null)
// Block by user-agent
if (isset($OVERRIDES['block_by_user_agent'])) {
$ua = strtolower($_SERVER["HTTP_USER_AGENT"]);
foreach ($OVERRIDES['block_by_user_agent'] as $user_agent) {
if (stripos($ua, $user_agent) !== false) {
file_put_contents($abuse_log, "\n" . format_log_date() . " [" . $_SERVER['REMOTE_ADDR'] . "] (blocking) '" . $user_agent . "' found in User-Agent block list", FILE_APPEND);
$this_ua = strtolower($_SERVER["HTTP_USER_AGENT"]);
foreach ($OVERRIDES['block_by_user_agent'] as $block_user_agent) {
if (stripos($this_ua, $block_user_agent) !== false) {
file_put_contents($abuse_log, "\n" . format_log_date() . " [" . $_SERVER['REMOTE_ADDR'] . "] (blocking) '" . $block_user_agent . "' found in User-Agent block list", FILE_APPEND);
$_SESSION['throttled'] = true;
header("HTTP/1.0 403 Forbidden");
exit();
@ -2132,15 +2136,15 @@ function throttle_hits($client_device = null)
if (isset($OVERRIDES['block_by_rdns'])) {
$ip = $_SERVER['REMOTE_ADDR'];
if (isset($rdns[$ip])) {
$ua = $rdns[$ip];
$this_rdns = $rdns[$ip];
} else {
$ua = gethostbyaddr($ip);
$rdns[$ip] = $ua;
$this_rdns = gethostbyaddr($ip);
$rdns[$ip] = $this_rdns;
file_put_contents($rdns_file, serialize($rdns));
}
foreach ($OVERRIDES['block_by_rdns'] as $user_agent) {
if (stripos($ua, $user_agent) !== false) {
file_put_contents($abuse_log, "\n" . format_log_date() . " [" . $_SERVER['REMOTE_ADDR'] . "] (blocking) '" . $user_agent . "' found in RDNS block list", FILE_APPEND);
foreach ($OVERRIDES['block_by_rdns'] as $block_rdns) {
if (stripos($this_rdns, $block_rdns) !== false) {
file_put_contents($abuse_log, "\n" . format_log_date() . " [" . $_SERVER['REMOTE_ADDR'] . "] (blocking) '" . $block_rdns . "' found in RDNS block list", FILE_APPEND);
$_SESSION['throttled'] = true;
header("HTTP/1.0 403 Forbidden");
exit();
@ -2181,7 +2185,7 @@ function throttle_hits($client_device = null)
function get_client_user_agent_info()
{
global $config_dir;
global $config_dir, $logdir;
// Try to get browser info to use for extra formatting of page
$ua = strtolower($_SERVER["HTTP_USER_AGENT"]);
$devices = array(
@ -2201,15 +2205,15 @@ function get_client_user_agent_info()
break;
}
}
if ($client_device == "spider") {
if ($client_device == "spider" || $client_device == "crawler") {
$client_device = "bot";
}
// Log client device if enabled by semaphore
if (file_exists($config_dir . '/devicelog.enable')) {
$client_ip = getenv("REMOTE_ADDR");
$logfile = $logdir . '/device.log';
file_put_contents($logfile, "\n" . date('M d H:i:s') . " " . $config_name . " Client: " . $client_ip . " browser: " . $client_device, FILE_APPEND);
file_put_contents($logfile, "\nFull UA: " . $ua, FILE_APPEND);
file_put_contents($logfile, "\n" . date('M d H:i:s') . " Client: " . $client_ip . " browser: " . $client_device, FILE_APPEND);
file_put_contents($logfile, "\n Full UA: " . $ua, FILE_APPEND);
}
return $client_device;
}
@ -2500,19 +2504,6 @@ function insert_article_from_array($this_article, $check_duplicates = true)
]);
unlink($grouppath . "/" . $this_article['local']);
$article_dbh = null;
/*
// Add to memcache
if (file_exists($config_dir . '/cache.inc.php')) {
include $config_dir . '/cache.inc.php';
}
if ($enable_cache) {
$article_key = $cache_key_prefix . '_' . 'article.db3-' . $group . ':' . $this_article['local'];
$nicole = cache_add($article_key, gzcompress($this_article['article']), $cache_ttl, $memcacheD);
if ($enable_cache_logging && $nicole) {
file_put_contents($cache_log, "\n" . format_log_date() . " (cache write) (new) $article_key", FILE_APPEND);
}
}
*/
} else {
if ($article_date > time())
$article_date = time();

View File

@ -67,6 +67,15 @@ if ($OVERRIDES['enable_post_log'] > 0) {
@$abspeichern = $_REQUEST["abspeichern"];
@$references = $_REQUEST["references"];
@$id = $_REQUEST["id"];
if($type == 'reply') {
$max_crosspost = 12;
$allow_ngs_edit = false;
} else {
$max_crosspost = 3;
$allow_ngs_edit = true;
}
if (! isset($group) && isset($newsgroups)) {
$group = $newsgroups;
}
@ -106,6 +115,15 @@ if ($_REQUEST['returngroup']) {
$returngroup = $thisgroup;
}
$linkgroups = preg_split("/[\s,]+/", $returngroup);
foreach($linkgroups as $linkgroup) {
$linkgroup = trim($linkgroup);
if (get_section_by_group($linkgroup)) {
$returngroup = $linkgroup;
break;
}
}
echo '<h1 class="np_thread_headline">';
echo '<a href="' . $file_index . '" target=' . $frame['menu'] . '>' . basename(getcwd()) . '</a> / ';
echo '<a href="' . $file_thread . '?group=' . rawurlencode($returngroup) . '" target=' . $frame["content"] . '>' . htmlspecialchars(group_display_name($returngroup)) . '</a>';
@ -219,7 +237,13 @@ if ($type == "post") {
$type = "retry";
$error = $text_post["missing_subject"];
}
if($allow_ngs_edit) {
$grouptotal = preg_split("/\,/", $newsgroups);
if(count($grouptotal) > $max_crosspost) {
$type = "retry";
$error = "Too many newsgroups";
}
}
// captcha-check
if (($post_captcha) && (captcha::check() == false)) {
$type = "retry";
@ -306,10 +330,32 @@ if ($type == "reply") {
} else {
$bodyzeile = $head->from;
}
// For Synchronet use
// For Synchronet use (deprecated)
$fromname = $bodyzeile;
$bodyzeile = $text_post["wrote_prefix"] . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
// Set quote reply format (On date somebody wrote:)
if(!isset($OVERRIDES['quote_head'])) {
$OVERRIDES['quote_head'] = 'date_name';
}
switch($OVERRIDES['quote_head']) {
case 'date_name':
$bodyzeile = "On " . date("D, j M Y G:i:s O,", $head->date) . " " . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
break;
case 'msgid_name':
$bodyzeile = "In " . $head->id . ", " . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
break;
case 'date_msgid_name':
$bodyzeile = "On " . date("D, j M Y G:i:s O,", $head->date) . " in " . $head->id . ", " . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
break;
case 'name':
$bodyzeile = $text_post["wrote_prefix"] . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
break;
default:
$bodyzeile = "On " . date("D, j M Y G:i:s O,", $head->date) . " " . $bodyzeile . $text_post["wrote_suffix"] . "\n\n";
break;
}
for ($i = 0; $i <= count($body) - 1; $i ++) {
if ((isset($cutsignature)) && ($cutsignature == true) && ($body[$i] == '-- ')) {
break;
@ -376,6 +422,7 @@ if ($show == 1) {
$ngroups = preg_split("/[\s,]+/", $newsgroups);
$found = false;
foreach ($ngroups as $group) {
$group = trim($group);
if (get_section_by_group($group)) {
$found = true;
break;
@ -419,6 +466,21 @@ if ($show == 1) {
echo '</td><td>';
echo '<label for="newsgroups">' . $head->newsgroups . '</label>';
echo '</tr><tr>';
} else {
if(!isset($OVERRIDES['disable_ngs_edit']) || $OVERRIDES['disable_ngs_edit'] == false) {
echo '<td align="right"><b>Newsgroups:</b></td>';
echo '<td>';
if($allow_ngs_edit) {
echo '<input tclass="post" type="text" name="fgroups" size="40" value="' . $newsgroups . '">';
echo "&nbsp;comma separated, max $max_crosspost groups";
} else {
echo '<input tclass="post" type="text" name="fgroups" size="40" value="' . $newsgroups . '" readonly>';
}
} else {
echo '<input tclass="post" type="hidden" name="fgroups" value="' . $newsgroups . '">';
}
echo '</td><td>';
echo '</tr><tr>';
}
echo '<td align="right"><b>' . $text_post["name"] . '</b></td>';

View File

@ -16,6 +16,11 @@ return [
// Display short view of headers (only subject, name, date)
'short_headers' => true,
// Set to true to disable display and edit of newsgroups
// header when posting
// Default is false (newsgroups will display)
'disable_ngs_edit' => false,
// Log posts?
'enable_post_log' => false,
@ -36,6 +41,10 @@ return [
// Must be 'show' or 'hide'
'hide_unsub' => 'hide',
// Show thread tree above articles in thread view
// Default is false
'show_thread_tree' => false,
// Reserved aliases
'reserved_names' => array("admin", "sysop", "rslight"),
@ -49,6 +58,13 @@ return [
// Default is true
'quote_blank_lines' => true,
// How to format 'who wrote' quoting in reply:
// 'On 4, Jan 2024, John Doe wrote:'
// Options are:
// 'date_name', 'msgid_name', 'date_msgid_name', or 'name'
// Default is 'date_name'
'quote_head' => 'date_name',
// Disable immediate post insertion (wait for remote server)
// for a SECTION. Comma separated list ex: 'rocksolid,section3,section5',
'insert_disable' => 'sectionONE, sectionTWO',

View File

@ -59,6 +59,10 @@ function post_articles($ns, $spooldir)
return "No messages to send\r\n";
}
$outgoing_dir = $spooldir . "/" . $config_name . "/outgoing/";
$fail_dir = $outgoing_dir . '/failed/';
if(!is_dir($fail_dir)) {
mkdir($fail_dir);
}
$messages = scandir($outgoing_dir);
foreach ($messages as $message) {
if (! is_file($outgoing_dir . $message)) {
@ -84,15 +88,16 @@ function post_articles($ns, $spooldir)
fputs($ns, ".\r\n");
fclose($message_fp);
$response = line_read($ns);
if (strcmp(substr($response, 0, 7), "441 435") == 0) {
$removed = unlink($outgoing_dir . $message);
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Response: " . $response, FILE_APPEND);
if (strcmp(substr($response, 0, 3), "441") == 0) {
rename($outgoing_dir . $message, $fail_dir . $message);
// $removed = unlink($outgoing_dir . $message);
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " POST Failed: " . $response, FILE_APPEND);
}
if (strcmp(substr($response, 0, 3), "240") == 0) {
$removed = unlink($outgoing_dir . $message);
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Posted: " . $message . ": " . $response, FILE_APPEND);
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " POSTED: " . $message . ": " . $response, FILE_APPEND);
} else {
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Failed to POST: " . $message . ": " . $response, FILE_APPEND);
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " POST Failed: " . $message . ": " . $response, FILE_APPEND);
continue;
}
}

View File

@ -173,7 +173,7 @@ echo "\nSpoolnews Done\n";
function get_articles($ns, $group)
{
global $enable_rslight, $rslight_gpg, $spooldir, $nocem_dir, $save_nocem_messages, $CONFIG, $OVERRIDES, $user_ban_file, $maxarticles_per_run, $maxfirstrequest, $workpath, $path, $remote_groupfile, $local_groupfile, $local, $logdir, $config_name, $spamlog, $logfile;
global $enable_rslight, $rslight_gpg, $spooldir, $nocem_dir, $save_nocem_messages, $CONFIG, $OVERRIDES, $user_ban_file, $maxarticles_per_run, $maxfirstrequest, $workpath, $path, $remote_groupfile, $local_groupfile, $local, $logdir, $config_name, $spamlog, $logfile, $debug_log;
if ($ns == false) {
file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Lost connection to " . $CONFIG['remote_server'] . ":" . $CONFIG['remote_port'], FILE_APPEND);
@ -262,6 +262,7 @@ function get_articles($ns, $group)
mkdir($grouppath, 0755, 'recursive');
}
$i = 0;
$dates_used = array();
// GET INDIVIDUAL ARTICLE
while ($article <= $detail[3]) {
if (! is_numeric($article)) {
@ -324,7 +325,18 @@ function get_articles($ns, $group)
// Find article date
if (stripos($response, "Date: ") === 0) {
$finddate = explode(': ', $response, 2);
$article_date = strtotime($finddate[1]);
// Here we try to handle an issue with exact same timestamps and
// newsportal tries to sort by these and messes up thread view if same
$artdate = strtotime($finddate[1]);
while(isset($dates_used[$artdate])) {
$artdate = $artdate + 1;
$finddate[1] = date("D, j M Y G:i:s (T)", $artdate);
file_put_contents($debug_log, "\n" . format_log_date() . " " . $config_name . " Rewrote date to: " . $artdate . " " . $finddate[1] . " for " . $group . ":" . $local, FILE_APPEND);
}
$article_date = $artdate;
$dates_used[$article_date] = true;
}
// Get overview data
if (stripos($response, "Message-ID: ") === 0) {