Restrict user's overboard to current section more strictly.

This commit is contained in:
Retro_Guy 2024-05-03 03:36:34 -07:00
parent 168011042e
commit c6573eec19
2 changed files with 40 additions and 50 deletions

View File

@ -27,20 +27,27 @@ include "head.inc";
echo '<h1 class="np_thread_headline">' . basename(getcwd()) . '</h1>'; echo '<h1 class="np_thread_headline">' . basename(getcwd()) . '</h1>';
echo '<table cellpadding="0" cellspacing="0" class="np_buttonbar"><tr>'; echo '<table cellpadding="0" cellspacing="0" class="np_buttonbar"><tr>';
// If logged in: button for new only // If logged in: button for new only
/*
if (isset($_COOKIE['mail_name'])) { if (isset($_COOKIE['mail_name'])) {
if ($userdata = get_user_mail_auth_data($_COOKIE['mail_name'])) { if (isset($OVERRIDES['overboard_disable_new_link']) && $OVERRIDES['overboard_disable_new_link'] === true) {
if (isset($overboard) && ($overboard == true)) { $newlink = false;
echo '<td>'; } else {
echo '<form target="' . $frame['content'] . '" action="overboard.php">'; $newlink = true;
echo '<button class="np_button_link" type="submit">new articles</button>'; }
echo '<input name="new" type="hidden" id="new" value="true">'; if ($newlink) {
echo '</form>'; if ($userdata = get_user_mail_auth_data($_COOKIE['mail_name'])) {
echo '</td>'; if (isset($overboard) && ($overboard == true)) {
echo '<td>';
echo '<form target="' . $frame['content'] . '" action="overboard.php">';
echo '<button class="np_button_link" type="submit">new articles</button>';
echo '<input name="new" type="hidden" id="new" value="true">';
echo '</form>';
echo '</td>';
}
} }
} }
} }
*/
// View Latest button // View Latest button
if (isset($overboard) && ($overboard == true)) { if (isset($overboard) && ($overboard == true)) {
echo '<td>'; echo '<td>';

View File

@ -309,32 +309,17 @@ function display_threads($threads, $oldest)
$results = 0; $results = 0;
foreach ($nicole as $key => $value) { foreach ($nicole as $key => $value) {
// Skip if not in registered users sub list // Skip if not in registered users sub list
if (! check_group_for_user($key, $userdata, $user_config)) { if (! $foundgroup_head = check_group_for_user($key, $userdata, $user_config, true)) {
continue; continue;
} }
$target_head = $this_overboard['msgids'][$key]; $target_head = $this_overboard['msgids'][$key];
if (! isset($target_head['msgid'])) { if (! isset($target_head['msgid'])) {
$target_head = get_data_from_msgid($key); $target_head = get_data_from_msgid($key);
} }
// Check if only displaying new posts in section
if ($newonly) {
$allgroups = get_group_array_from_msgid($key);
foreach ($allgroups as $onegroup) {
if (isset($userdata[$onegroup])) {
$infofilename = $spooldir . "/" . $onegroup . "-lastarticleinfo.dat";
$lastarticleinfo = unserialize(file_get_contents($infofilename));
if ($userdata[$onegroup] > $lastarticleinfo['date']) {
continue 2;
}
}
}
}
$nohead = true; $nohead = true;
$result_count = count($value); $result_count = count($value);
foreach ($value as $new) { foreach ($value as $new) {
// Skip if not in registered users sub list if (! $foundgroup = check_group_for_user($new, $userdata, $user_config, true)) {
if (! check_group_for_user($new, $userdata, $user_config)) {
continue; continue;
} }
$target = $this_overboard['msgids'][$new]; $target = $this_overboard['msgids'][$new];
@ -344,15 +329,10 @@ function display_threads($threads, $oldest)
if ($target['date'] < $oldest) { if ($target['date'] < $oldest) {
continue; continue;
} }
// Check if only displaying new posts in section
if ($newonly) { if ($newonly) {
$allgroups = get_group_array_from_msgid($new); if ($foundgroup && $foundgroup != '') {
foreach ($allgroups as $onegroup) { if ($target['date'] < $userdata[$foundgroup]) {
if (isset($userdata[$onegroup])) { continue;
if ($userdata[$onegroup] > $target['date']) {
continue 2;
}
} }
} }
} }
@ -421,7 +401,6 @@ function display_threads($threads, $oldest)
$display .= '<br /><br />'; $display .= '<br /><br />';
$display .= '<p class=np_ob_subject>'; $display .= '<p class=np_ob_subject>';
$display .= '<b><a href="' . $url . '"><span>' . headerDecode($target['subject']) . '</span></a></b>'; $display .= '<b><a href="' . $url . '"><span>' . headerDecode($target['subject']) . '</span></a></b>';
$display .= '</p>'; $display .= '</p>';
$display .= '<p class=np_ob_body>'; $display .= '<p class=np_ob_body>';
$display .= 'by: <b><i><span class="visited">' . create_name_link($poster['name'], $poster['from']) . '</span></i></b>'; $display .= 'by: <b><i><span class="visited">' . create_name_link($poster['name'], $poster['from']) . '</span></i></b>';
@ -487,7 +466,8 @@ function display_flat($threads, $oldest)
$results = 0; $results = 0;
$shown = array(); $shown = array();
foreach ($threads as $key => $value) { foreach ($threads as $key => $value) {
if (! check_group_for_user($value, $userdata, $user_config)) { // Skip if not in registered users sub list
if (! $foundgroup = check_group_for_user($value, $userdata, $user_config, true)) {
continue; continue;
} }
$target = $this_overboard['msgids'][$value]; $target = $this_overboard['msgids'][$value];
@ -499,18 +479,13 @@ function display_flat($threads, $oldest)
} else { } else {
$shown[$value . $target['newsgroup']] = $value; $shown[$value . $target['newsgroup']] = $value;
} }
if ($target['date'] < $oldest) { if ($target['date'] < $oldest) {
continue; continue;
} }
// Check if only displaying new posts in section
if ($newonly) { if ($newonly) {
$allgroups = get_group_array_from_msgid($value); if ($foundgroup && $foundgroup != '') {
foreach ($allgroups as $onegroup) { if ($target['date'] < $userdata[$foundgroup]) {
if (isset($userdata[$onegroup])) { continue;
if ($userdata[$onegroup] > $target['date']) {
continue 2;
}
} }
} }
} }
@ -640,24 +615,32 @@ function show_overboard_header($grouplist)
// Return TRUE unless group is not subscribed by user // Return TRUE unless group is not subscribed by user
// It is assumed $newsgroups to check are verified to be in SECTION // It is assumed $newsgroups to check are verified to be in SECTION
function check_group_for_user($msgid, $userdata, $user_config) function check_group_for_user($msgid, $userdata, $user_config, $check_section = false)
{ {
global $logdir, $config_name; global $logdir, $config_name;
$logfile = $logdir . '/overboard.log'; $logfile = $logdir . '/overboard.log';
if (! is_array($userdata)) { if (! is_array($userdata)) {
// No logged in user // No logged in user
return true; return '';
} }
if (! isset($user_config['hide_unsub']) || $user_config['hide_unsub'] != 'hide') { if (! isset($user_config['hide_unsub']) || $user_config['hide_unsub'] != 'hide') {
return true; return '';
} }
$newsgroups = get_newsgroups_by_msgid($msgid); $newsgroups = get_newsgroups_by_msgid($msgid);
if ($newsgroups == false) { if ($newsgroups == false) {
return false; return false;
} }
foreach ($newsgroups as $newsgroup) { foreach ($newsgroups as $newsgroup) {
if (isset($userdata[$newsgroup])) { if ($check_section) {
return true; if ($config_name == get_section_by_group($newsgroup)) {
if (isset($userdata[$newsgroup])) {
return $newsgroup;
}
}
} else {
if (isset($userdata[$newsgroup])) {
return $newsgroup;
}
} }
} }
return false; return false;