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,13 +811,11 @@ 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) {
@ -827,7 +825,7 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl
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");
@ -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

@ -350,6 +350,7 @@ function display_threads($threads, $oldest)
} else {
$display .= '<tr class="np_result_line1"><td class="np_result_line1" style="word-wrap:break-word";>';
}
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>';
@ -379,9 +380,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), "<br />\n", true));
}
}
@ -391,6 +390,7 @@ function display_threads($threads, $oldest)
$style++;
$nohead = false;
}
}
if ($skip != $target['number']) {
$poster = get_poster_name(mb_decode_mimeheader($target['name']));
$block = false;
@ -420,9 +420,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 +557,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));
}

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>';

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);
}