Merge branch 'devel'

This commit is contained in:
Retro_Guy 2024-10-12 07:27:31 -07:00
commit 8074d701a2
8 changed files with 116 additions and 117 deletions

View File

@ -1 +1 @@
0.9.157
0.9.158

View File

@ -124,35 +124,8 @@ if ($message) {
$thread = thread_load($group);
$subthread = thread_getsubthreadids($message->header->id, $thread);
if (! $subthread) {
$date_window = 86400;
$msg_log_file = $spooldir . '/admin_msg_log.dat';
echo '<center>Group is rebuilding... Please try again later</center>';
if (file_exists($msg_log_file)) {
$admin_msg_log = unserialize(file_get_contents($msg_log_file));
} else {
$admin_msg_log = array();
}
if (! isset($admin_msg_log[$group])) {
$admin_msg_log[$group] = 0;
}
if ($admin_msg_log[$group] < (time() - $date_window)) {
if ($admin_msg_log[$group] != 0) {
$msg_from = 'admin';
$msg_to = 'admin';
$msg_body = format_log_date() . " " . $config_name . " GROUP ERROR: " . $group . ":" . $message->header->number . " may need repair";
$msg_body_2 = "\n\nRun maintenance.php -import " . $group;
$msg_subject = "ERROR in $group";
if (isset($OVERRIDES['send_admin_debug_messages']) && $OVERRIDES['send_admin_debug_messages'] == true) {
send_admin_message($msg_to, $msg_from, $msg_subject, $msg_body . $msg_body_2);
send_internet_email($subject, $msg_subject, $msg_body . $msg_body_2);
}
file_put_contents($debug_log, "\n" . $msg_body, FILE_APPEND);
$admin_msg_log[$group] = 0;
} else {
$admin_msg_log[$group] = time();
}
}
file_put_contents($msg_log_file, serialize($admin_msg_log));
repair_broken_group($group);
exit();
}
if ($thread_articles == false) {

View File

@ -79,6 +79,17 @@ echo '<td width=100%></td></tr></table>';
flush();
// Subscribe to group
if (isset($_GET['subscribe'])) {
if (isset($_COOKIE['mail_name'])) {
if ($userdata = get_user_mail_auth_data($_COOKIE['mail_name'])) {
$userfile = $spooldir . '/' . strtolower($_COOKIE['mail_name']) . '-articleviews.dat';
$thisgroup = _rawurldecode($_GET['subscribe']);
$userdata[$thisgroup] = time();
file_put_contents($userfile, serialize($userdata));
}
}
}
// Unsubscribe from group
if (isset($_GET['unsub'])) {
if (isset($_COOKIE['mail_name'])) {
@ -91,7 +102,6 @@ if (isset($_GET['unsub'])) {
$newsubs[$key] = $usertime;
}
}
$userfile = $spooldir . '/' . strtolower($_COOKIE['mail_name']) . '-articleviews.dat';
file_put_contents($userfile, serialize($newsubs));
}
}

View File

@ -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 '<hr><p class=np_ob_posted_date>(message #' . $head->number . ' hidden by your blocklist)</p><hr>';
return "blocked";

View File

@ -751,6 +751,10 @@ function groups_show($gruppen)
} else {
if (isset($user_config['hide_unsub']) && $user_config['hide_unsub'] == 'hide') {
continue;
} else {
$groupdisplay .= '</span><p class="np_group_user_tools">';
$groupdisplay .= '<a class="np_group_user_tools" href="index.php?subscribe=' . urlencode($g->name) . '">(subscribe)</a>';
$groupdisplay .= '</p';
}
}
/* Display article count */
@ -1130,6 +1134,15 @@ 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 +1165,7 @@ function display_links_in_body($text)
$pattern = "!$pattern!";
$text = preg_replace($pattern, '<a href="' . $linkurl . '" rel="nofollow" target="_blank">' . $url . '</a>', $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 '</blockquote>';
@ -1168,6 +1178,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");
@ -1298,7 +1309,7 @@ function verify_logged_in($name)
$_SESSION['start_stamp'] = time();
}
if (! isset($_SESSION['start_address'])) {
if (! isset($_SESSION['start_address'])) {
$_SESSION['start_address'] = $_SERVER['REMOTE_ADDR'];
$ip_pass = true;
file_put_contents($auth_log, "\n" . logging_prefix() . " IP address SET for: " . $name, FILE_APPEND);
@ -2359,7 +2370,7 @@ function send_internet_email($subject, $body, $mail_to = false, $mail_from = fal
$mail = new PHPMailer\PHPMailer\PHPMailer();
}
if(!$mail) {
if (!$mail) {
return false;
}
@ -2416,6 +2427,10 @@ function send_internet_email($subject, $body, $mail_to = false, $mail_from = fal
}
}
/* get_user_mail_auth_data is poorly named but
* it retrieves newsgroup status per user info
* for subscribe/unsubscribe/read/unread
*/
function get_user_mail_auth_data($user)
{
global $spooldir;

View File

@ -32,16 +32,16 @@ if (! isset($_SESSION['last_access']) || (time() - $_SESSION['last_access']) > 6
}
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
}
@ -58,11 +58,11 @@ if (disable_page_by_user_agent($client_device, "bot", "Overboard")) {
exit();
}
$CONFIG = include ($config_file);
$CONFIG = include($config_file);
$logfile = $logdir . '/overboard.log';
$cookie_mail_name = $_COOKIE['mail_name'];
if(isset($_COOKIE['mail_name']) && $_COOKIE['mail_name'] == $CONFIG['anonusername']) {
if (isset($_COOKIE['mail_name']) && $_COOKIE['mail_name'] == $CONFIG['anonusername']) {
unset($cookie_mail_name);
}
@ -211,7 +211,7 @@ foreach ($grouplist as $findgroup) {
$ref = preg_split("/[\s]+/", $overviewline['refs']);
$this_overboard['threadlink'][$thismsgid] = $ref[0];
}
if ($results ++ > ($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,46 +350,46 @@ function display_threads($threads, $oldest)
} else {
$display .= '<tr class="np_result_line1"><td class="np_result_line1" style="word-wrap:break-word";>';
}
$display .= '<center>';
$url = $thissite . "/article-flat.php?id=" . $target_head['number'] . "&group=" . _rawurlencode($target_head['newsgroup']) . "#" . $target_head['number'];
$display .= '<p class=np_ob_subject>';
$display .= '<b><a href="' . $url . '"><span>' . headerDecode($target_head['subject']) . '</span></a></b></p>';
$display .= '<a href="thread.php?group=' . _rawurlencode($target_head['newsgroup']) . '">' . $target_head['newsgroup'] . '</a>';
$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 .= '<center>';
$url = $thissite . "/article-flat.php?id=" . $target_head['number'] . "&group=" . _rawurlencode($target_head['newsgroup']) . "#" . $target_head['number'];
$display .= '<p class=np_ob_subject>';
$display .= '<b><a href="' . $url . '"><span>' . headerDecode($target_head['subject']) . '</span></a></b></p>';
$display .= '<a href="thread.php?group=' . _rawurlencode($target_head['newsgroup']) . '">' . $target_head['newsgroup'] . '</a>';
$timetest = $oldest;
if ($newonly) {
$timetest = $userdata[$target_head['newsgroup']];
}
if ($block) {
$display .= '<br /><br />';
$display .= '<p class=np_ob_subject>';
$display .= '<b><span>(message #' . $target_head['number'] . ' hidden by your blocklist)</span></a></b>';
} else {
$display .= '<p class=np_ob_posted_date>Posted: ' . get_date_interval(date("D, j M Y H:i T", $target_head['date'])) . ' by: ' . create_name_link($poster['name'], $poster['from']) . '</p>';
if ($CONFIG['article_database'] == '1') {
$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');
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;
}
$display .= strip_tags(wordwrap(substr($text, 0, $snippetlength), ($snippetlength / 2), "<br />\n", true));
}
if ($block) {
$display .= '<br /><br />';
$display .= '<p class=np_ob_subject>';
$display .= '<b><span>(message #' . $target_head['number'] . ' hidden by your blocklist)</span></a></b>';
} else {
$display .= '<p class=np_ob_posted_date>Posted: ' . get_date_interval(date("D, j M Y H:i T", $target_head['date'])) . ' by: ' . create_name_link($poster['name'], $poster['from']) . '</p>';
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), "<br />\n", true));
}
}
$skip = $target_head['number'];
}
$skip = $target_head['number'];
$display .= '</center>';
$style++;
$nohead = false;
}
$display .= '</center>';
$style ++;
$nohead = false;
}
if ($skip != $target['number']) {
$poster = get_poster_name(mb_decode_mimeheader($target['name']));
@ -420,11 +420,9 @@ 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)));
// $display .= strip_tags(htmlentities(substr($text, 0, $snippetlength)));
}
if ($target['date'] < $expireme) {
unset($this_overboard['threads'][$target['date']]);
@ -544,13 +542,13 @@ function display_flat($threads, $oldest)
$display .= '</p>';
// 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 .= '<font class="np_ob_group"><a href="article-flat.php?id=' . $target_head['number'] . '&group=' . rawurlencode($target_head['newsgroup']) . '#' . $target_head['number'] . '"> (full thread)</a></font>';
}
}
@ -559,14 +557,12 @@ 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));
}
}
$results ++;
$results++;
if ($results > ($maxdisplay - 1)) {
break;
}

View File

@ -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 '</tr><tr>';
echo '<td align="right"><b>Followup-To:</b></td>';
echo '<td>';
echo '<input tclass="post" type="text" name="followupto" size="40" value="' . $followupto . '" maxlength="80" placeholder="name of group to redirect replies">';
echo '<input tclass="post" type="text" name="followupto" size="40" value="' . $followupto . '" maxlength="80" placeholder="name of one group to redirect replies">';
echo "&nbsp;(optional)";
} else {
echo '<input tclass="post" type="text" name="fgroups" size="40" value="' . $newsgroups . '" readonly>';
@ -603,7 +610,7 @@ if ($show == 1) {
echo '<br> <textarea cols="' . $wrap_width . '"';
echo 'class="postbody" id="postbody" cols="72"';
echo 'name="' . md5($fieldencrypt . "body") . '" wrap="soft">';
$bodyzeile = wrap_post($bodyzeile);
if ((isset($bodyzeile)) && ($post_autoquote))
echo htmlspecialchars(rtrim($bodyzeile) . "\n");

View File

@ -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 " . $CONFIG['remote_server'] . ":" . $CONFIG['remote_port'], 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);
}