From 0105aaaceeef691d666d058421f3d0a78f4794a6 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Thu, 10 Oct 2024 05:03:44 -0700 Subject: [PATCH 01/11] Increment version to 0.9.158. --- Rocksolid_Light/common/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rocksolid_Light/common/version.txt b/Rocksolid_Light/common/version.txt index b13608b..1bc067b 100644 --- a/Rocksolid_Light/common/version.txt +++ b/Rocksolid_Light/common/version.txt @@ -1 +1 @@ -0.9.157 +0.9.158 From bc9001203ae4017fd51eaa376e78f09cc613b8f0 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Thu, 10 Oct 2024 05:04:24 -0700 Subject: [PATCH 02/11] Use function for rewrite_body. --- Rocksolid_Light/rocksolid/newsportal.php | 13 +++++++++---- Rocksolid_Light/rocksolid/overboard.php | 12 +++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index facdff3..70c4555 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1130,6 +1130,14 @@ function html_parse($text) return ($ntext); } +function rewrite_body($text) { + global $config_dir; + if (file_exists($config_dir . '/rewrite_body.inc.php')) { + include($config_dir . '/rewrite_body.inc.php'); + } + return $text; +} + function display_links_in_body($text) { global $config_dir; @@ -1152,10 +1160,7 @@ function display_links_in_body($text) $pattern = "!$pattern!"; $text = preg_replace($pattern, '' . $url . '', $text, 1); } - if (file_exists($config_dir . '/rewrite_body.inc.php')) { - include($config_dir . '/rewrite_body.inc.php'); - } - + $text = rewrite_body($text); echo $text; if ($isquote) { echo ''; diff --git a/Rocksolid_Light/rocksolid/overboard.php b/Rocksolid_Light/rocksolid/overboard.php index 71e117f..96d4085 100644 --- a/Rocksolid_Light/rocksolid/overboard.php +++ b/Rocksolid_Light/rocksolid/overboard.php @@ -379,9 +379,7 @@ function display_threads($threads, $oldest) $article = get_db_data_from_msgid($target_head['msgid'], $target_head['newsgroup'], 1); $text = $article['search_snippet']; - if (file_exists($config_dir . '/rewrite_body.inc.php')) { - include ($config_dir . '/rewrite_body.inc.php'); - } + $text = rewrite_body($text); $display .= strip_tags(wordwrap(substr($text, 0, $snippetlength), ($snippetlength / 2), "
\n", true)); } } @@ -420,9 +418,7 @@ function display_threads($threads, $oldest) if ($CONFIG['article_database'] == '1') { $article = get_db_data_from_msgid($target['msgid'], $target['newsgroup'], 1); $text = $article['search_snippet']; - if (file_exists($config_dir . '/rewrite_body.inc.php')) { - include ($config_dir . '/rewrite_body.inc.php'); - } + $text = rewrite_body($text); $display .= strip_tags(html_parse(text2html(substr($text, 0, $snippetlength)))); // $display .= strip_tags(htmlentities(substr($text, 0, $snippetlength))); } @@ -559,9 +555,7 @@ function display_flat($threads, $oldest) if ($CONFIG['article_database'] == '1') { $article = get_db_data_from_msgid($target['msgid'], $target['newsgroup'], 1); $text = $article['search_snippet']; - if (file_exists($config_dir . '/rewrite_body.inc.php')) { - include ($config_dir . '/rewrite_body.inc.php'); - } + $text = rewrite_body($text); $display .= strip_tags(html_parse(text2html(substr($text, 0, $snippetlength)))); //$display .= htmlentities(substr($text, 0, $snippetlength)); } From 2403c3fe11255c80ad380f0ca0b26950426db325 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Thu, 10 Oct 2024 15:07:20 -0700 Subject: [PATCH 03/11] Fix incorrect logging for failure to connect to internal server. --- Rocksolid_Light/rslight/scripts/spoolnews.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index a48cb38..2c99055 100644 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -158,7 +158,7 @@ if ($CONFIG['remote_server'] != '') { echo "\nOPENING $ns2: " . $ns2 . "\n"; } if (! $ns2) { - file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Failed to connect to " . $CONFIG['remote_server'] . ":" . $CONFIG['remote_port'], FILE_APPEND); + file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Failed to connect to local nntp server", FILE_APPEND); // exit(); } else { file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Updating threads for: " . $name[0] . "...", FILE_APPEND); From 07b8fa1397b3417a65c8d7c1ece960cf773faf13 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Fri, 11 Oct 2024 04:16:33 -0700 Subject: [PATCH 04/11] Change to to make spoolnews.php easier to read. --- Rocksolid_Light/rslight/scripts/spoolnews.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Rocksolid_Light/rslight/scripts/spoolnews.php b/Rocksolid_Light/rslight/scripts/spoolnews.php index 2c99055..8680d82 100644 --- a/Rocksolid_Light/rslight/scripts/spoolnews.php +++ b/Rocksolid_Light/rslight/scripts/spoolnews.php @@ -153,17 +153,17 @@ if ($CONFIG['remote_server'] != '') { $timer_file = $spooldir . '/tmp/' . $name[0] . '-thread-timer'; if (filemtime($timer_file) + 600 < time()) { touch($timer_file); - if (! $ns2) { - $ns2 = nntp_open(); - echo "\nOPENING $ns2: " . $ns2 . "\n"; + if (! $ns_local) { + $ns_local = nntp_open(); + echo "\nOPENING Local server: " . $ns_local . "\n"; } - if (! $ns2) { - file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Failed to connect to local nntp server", FILE_APPEND); + if (! $ns_local) { + file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Failed to connect to " . $CONFIG['local_server'] . ":" . $CONFIG['local_port'], FILE_APPEND); // exit(); } else { file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Updating threads for: " . $name[0] . "...", FILE_APPEND); try { - thread_load_newsserver($ns2, $name[0], 0); + thread_load_newsserver($ns_local, $name[0], 0); } catch (Exception $exc) { echo "\nFatal exception caught: " . $exc->getMessage(); } catch (Error $err) { @@ -174,8 +174,8 @@ if ($CONFIG['remote_server'] != '') { } } } - if ($ns2) { - nntp_close($ns2); + if ($ns_local) { + nntp_close($ns_local); } nntp_close($ns); } From df65eb7acbc29d6d48ea77964e548eb620f50ce9 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Fri, 11 Oct 2024 04:22:58 -0700 Subject: [PATCH 05/11] Add missing global in newsportal.php. --- Rocksolid_Light/rocksolid/newsportal.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Rocksolid_Light/rocksolid/newsportal.php b/Rocksolid_Light/rocksolid/newsportal.php index 70c4555..3aade43 100644 --- a/Rocksolid_Light/rocksolid/newsportal.php +++ b/Rocksolid_Light/rocksolid/newsportal.php @@ -1173,6 +1173,7 @@ function display_links_in_body($text) */ function readPlainHeader(&$ns, $group, $articleNumber) { + global $text_error; fputs($ns, "GROUP $group\r\n"); $line = line_read($ns); fputs($ns, "HEAD $articleNumber\r\n"); From 5ec58d7c5fb3689280184aff34f894693d665c2d Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Fri, 11 Oct 2024 04:46:06 -0700 Subject: [PATCH 06/11] Handle some warnings for . --- Rocksolid_Light/rocksolid/lib/message.inc.php | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Rocksolid_Light/rocksolid/lib/message.inc.php b/Rocksolid_Light/rocksolid/lib/message.inc.php index cad9e72..a83f57a 100644 --- a/Rocksolid_Light/rocksolid/lib/message.inc.php +++ b/Rocksolid_Light/rocksolid/lib/message.inc.php @@ -811,23 +811,21 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl $body = $article_data->body[$attachment]; if ($head) { // User blocklist + $blocked_user_config = array(); if ($userdata = get_user_mail_auth_data($_COOKIE['mail_name'])) { $userfile = $spooldir . '/' . strtolower($_COOKIE['mail_name']) . '-blocked_posters.dat'; if (file_exists($userfile)) { $blocked_user_config = unserialize(file_get_contents($userfile)); - } else { - $blocked_user_config = null; + } + $block = false; + foreach ($blocked_user_config as $key => $value) { + $blockme = '/' . addslashes($key) . '/'; + if (preg_match($blockme, $head->from)) { + $block = true; + break; + } } } - $block = false; - foreach ($blocked_user_config as $key => $value) { - $blockme = '/' . addslashes($key) . '/'; - if (preg_match($blockme, $head->from)) { - $block = true; - break; - } - } - if ($block == true) { echo '

(message #' . $head->number . ' hidden by your blocklist)


'; return "blocked"; From 3530768ceb4418d97d9815f1cf93c20af707bad6 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Fri, 11 Oct 2024 04:46:54 -0700 Subject: [PATCH 07/11] Handle warnings if is not set in overboard.php. --- Rocksolid_Light/rocksolid/overboard.php | 108 ++++++++++++------------ 1 file changed, 55 insertions(+), 53 deletions(-) diff --git a/Rocksolid_Light/rocksolid/overboard.php b/Rocksolid_Light/rocksolid/overboard.php index 96d4085..d63013a 100644 --- a/Rocksolid_Light/rocksolid/overboard.php +++ b/Rocksolid_Light/rocksolid/overboard.php @@ -32,16 +32,16 @@ if (! isset($_SESSION['last_access']) || (time() - $_SESSION['last_access']) > 6 } if (isset($frames_on) && $frames_on === true) { - ?> - +?> + ($maxdisplay - 2)) { + if ($results++ > ($maxdisplay - 2)) { break; } // } @@ -313,7 +313,7 @@ function display_threads($threads, $oldest) $style = 0; $results = 0; foreach ($nicole as $key => $value) { - if(isset($target_head)) { + if (isset($target_head)) { unset($target_head); } if (isset($this_overboard['msgids'][$key])) { @@ -342,7 +342,7 @@ function display_threads($threads, $oldest) } } } - $results ++; + $results++; $skip = ''; if ($nohead) { if (($style % 2) == 0) { @@ -350,44 +350,46 @@ function display_threads($threads, $oldest) } else { $display .= ''; } - $display .= '
'; - $url = $thissite . "/article-flat.php?id=" . $target_head['number'] . "&group=" . _rawurlencode($target_head['newsgroup']) . "#" . $target_head['number']; - $display .= '

'; - $display .= '' . headerDecode($target_head['subject']) . '

'; - $display .= '' . $target_head['newsgroup'] . ''; - $timetest = $oldest; - if ($newonly) { - $timetest = $userdata[$target_head['newsgroup']]; - } - if ((($target_head['date'] < $timetest) || $result_count > 10) && isset($target_head['date'])) { - $poster = get_poster_name(mb_decode_mimeheader($target_head['name'])); - $block = false; - foreach ($blocked_user_config as $bkey => $bvalue) { - $blockme = '/' . addslashes($bkey) . '/'; - if (preg_match($blockme, $target_head['name'])) { - $block = true; - break; - } + if ($target_head) { + $display .= '
'; + $url = $thissite . "/article-flat.php?id=" . $target_head['number'] . "&group=" . _rawurlencode($target_head['newsgroup']) . "#" . $target_head['number']; + $display .= '

'; + $display .= '' . headerDecode($target_head['subject']) . '

'; + $display .= '' . $target_head['newsgroup'] . ''; + $timetest = $oldest; + if ($newonly) { + $timetest = $userdata[$target_head['newsgroup']]; } - if ($block) { - $display .= '

'; - $display .= '

'; - $display .= '(message #' . $target_head['number'] . ' hidden by your blocklist)'; - } else { - $display .= '

Posted: ' . get_date_interval(date("D, j M Y H:i T", $target_head['date'])) . ' by: ' . create_name_link($poster['name'], $poster['from']) . '

'; - if ($CONFIG['article_database'] == '1') { - $article = get_db_data_from_msgid($target_head['msgid'], $target_head['newsgroup'], 1); - - $text = $article['search_snippet']; - $text = rewrite_body($text); - $display .= strip_tags(wordwrap(substr($text, 0, $snippetlength), ($snippetlength / 2), "
\n", true)); + if ((($target_head['date'] < $timetest) || $result_count > 10) && isset($target_head['date'])) { + $poster = get_poster_name(mb_decode_mimeheader($target_head['name'])); + $block = false; + foreach ($blocked_user_config as $bkey => $bvalue) { + $blockme = '/' . addslashes($bkey) . '/'; + if (preg_match($blockme, $target_head['name'])) { + $block = true; + break; + } } + if ($block) { + $display .= '

'; + $display .= '

'; + $display .= '(message #' . $target_head['number'] . ' hidden by your blocklist)'; + } else { + $display .= '

Posted: ' . get_date_interval(date("D, j M Y H:i T", $target_head['date'])) . ' by: ' . create_name_link($poster['name'], $poster['from']) . '

'; + if ($CONFIG['article_database'] == '1') { + $article = get_db_data_from_msgid($target_head['msgid'], $target_head['newsgroup'], 1); + + $text = $article['search_snippet']; + $text = rewrite_body($text); + $display .= strip_tags(wordwrap(substr($text, 0, $snippetlength), ($snippetlength / 2), "
\n", true)); + } + } + $skip = $target_head['number']; } - $skip = $target_head['number']; + $display .= '
'; + $style++; + $nohead = false; } - $display .= '
'; - $style ++; - $nohead = false; } if ($skip != $target['number']) { $poster = get_poster_name(mb_decode_mimeheader($target['name'])); @@ -420,7 +422,7 @@ function display_threads($threads, $oldest) $text = $article['search_snippet']; $text = rewrite_body($text); $display .= strip_tags(html_parse(text2html(substr($text, 0, $snippetlength)))); - // $display .= strip_tags(htmlentities(substr($text, 0, $snippetlength))); + // $display .= strip_tags(htmlentities(substr($text, 0, $snippetlength))); } if ($target['date'] < $expireme) { unset($this_overboard['threads'][$target['date']]); @@ -540,13 +542,13 @@ function display_flat($threads, $oldest) $display .= '

'; // link for (thread), if possible - if(isset($target_head)) { + if (isset($target_head)) { unset($target_head); } // Display 'full thread' link if available if (isset($this_overboard['threadlink'][$value])) { $target_head = get_data_from_msgid($this_overboard['threadlink'][$value]); - if ($target_head !== false) { + if ($target_head !== false) { $display .= ' (full thread)'; } } @@ -560,7 +562,7 @@ function display_flat($threads, $oldest) //$display .= htmlentities(substr($text, 0, $snippetlength)); } } - $results ++; + $results++; if ($results > ($maxdisplay - 1)) { break; } From 53a4033cd17bac4b63a06f988a6176aa28f4acd2 Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Fri, 11 Oct 2024 05:53:36 -0700 Subject: [PATCH 08/11] Add limit for added followup-to. Default is 1. --- Rocksolid_Light/rocksolid/post.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Rocksolid_Light/rocksolid/post.php b/Rocksolid_Light/rocksolid/post.php index c0e65d3..4ffc48e 100644 --- a/Rocksolid_Light/rocksolid/post.php +++ b/Rocksolid_Light/rocksolid/post.php @@ -59,6 +59,8 @@ if (isset($_REQUEST['followupto']) && trim($_REQUEST['followupto']) != '') { $followupto = null; } +$max_followupto = 1; + // Check some header strings for bad characters $newsgroups = sanitize_header($newsgroups); $subject = sanitize_header($subject); @@ -289,6 +291,11 @@ if ($type == "post") { $type = "retry"; $error = "Too many newsgroups"; } + $followuptotal = preg_split("/( |\,)/", $followupto); + if (count($followuptotal) > $max_followupto) { + $type = "retry"; + $error = "Too many groups in followup-to"; + } } // captcha-check if (($post_captcha) && (captcha::check() == false)) { @@ -530,7 +537,7 @@ if ($show == 1) { echo ''; echo 'Followup-To:'; echo ''; - echo ''; + echo ''; echo " (optional)"; } else { echo ''; @@ -603,7 +610,7 @@ if ($show == 1) { echo '