2020-11-29 01:55:31 +01:00
< ? php
2023-08-20 00:33:05 +02:00
session_start ();
2023-12-23 21:07:03 +01:00
if ( ! isset ( $_SESSION [ 'last_access' ]) || ( time () - $_SESSION [ 'last_access' ]) > 60 ) {
$_SESSION [ 'last_access' ] = time ();
}
2023-09-22 12:33:24 +02:00
header ( " Expires: " . gmdate ( " D, d M Y H:i:s " , time () + ( 120 )) . " GMT " );
header ( " Cache-Control: max-age=120 " );
2023-08-20 00:33:05 +02:00
header ( " Pragma: cache " );
2023-09-22 12:33:24 +02:00
2023-08-20 00:33:05 +02:00
/*
* rocksolid overboard - overboard for rslight
* Download : https :// news . novabbs . com / getrslight
*
* E - Mail : retroguy @ novabbs . com
* Web : https :// news . novabbs . com
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*/
include " config.inc.php " ;
include " $file_newsportal " ;
2020-11-29 01:55:31 +01:00
2023-08-20 00:33:05 +02:00
if ( isset ( $frames_on ) && $frames_on === true ) {
?>
2020-11-29 01:55:31 +01:00
< 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
}
if ( isset ( $_GET [ 'thisgroup' ])) {
2023-08-20 00:33:05 +02:00
$title .= " - " . _rawurldecode ( _rawurldecode ( $_GET [ 'thisgroup' ])) . " - latest messages " ;
2024-02-02 18:20:37 +01:00
$activegroup = urldecode ( $_GET [ 'thisgroup' ]);
2020-11-29 01:55:31 +01:00
} else {
2023-08-20 00:33:05 +02:00
$title .= " - " . $config_name . " - overboard " ;
2020-11-29 01:55:31 +01:00
}
include " head.inc " ;
2023-09-04 16:07:06 +02:00
if ( disable_page_by_user_agent ( $client_device , " bot " , " Overboard " )) {
echo " <center>Page Disabled</center> " ;
include " tail.inc " ;
exit ();
}
2023-08-20 00:33:05 +02:00
$CONFIG = include ( $config_file );
$logfile = $logdir . '/overboard.log' ;
2020-11-29 01:55:31 +01:00
# How many days old should articles be displayed?
if ( isset ( $_GET [ 'thisgroup' ])) {
2023-08-20 00:33:05 +02:00
$article_age = 30 ;
2020-11-29 01:55:31 +01:00
} else {
2023-08-20 00:33:05 +02:00
$article_age = 30 ;
2020-11-29 01:55:31 +01:00
}
2024-03-10 12:48:57 +01:00
$version = 1.2 ;
2022-04-10 06:30:34 +02:00
2021-12-22 06:57:12 +01:00
# How long in seconds to cache results
$cachetime = 60 ;
2020-11-29 01:55:31 +01:00
# Maximum number of articles to show
2024-03-10 12:48:57 +01:00
$maxdisplay = 1000 ; // default 1000
2020-11-29 01:55:31 +01:00
# How many characters of the body to display per article
$snippetlength = 240 ;
2023-08-20 00:33:05 +02:00
$spoolpath_regexp = '/' . preg_replace ( '/\//' , '\\/' , $spoolpath ) . '/' ;
2020-11-29 01:55:31 +01:00
$thissite = '.' ;
2023-08-20 00:33:05 +02:00
$groupconfig = $file_groups ;
$cachefile = $spooldir . " / " . $config_name . " -overboard.dat " ;
2020-11-29 01:55:31 +01:00
$oldest = ( time () - ( 86400 * $article_age ));
2022-01-26 03:01:59 +01:00
if ( isset ( $_GET [ 'time' ])) {
2023-08-20 00:33:05 +02:00
$user_time = $_GET [ 'time' ];
if ( is_numeric ( $user_time )) {
if (( $user_time > time ()) || ( $user_time < $oldest )) {
unset ( $user_time );
}
} else {
unset ( $user_time );
2022-01-26 03:01:59 +01:00
}
}
2020-11-29 01:55:31 +01:00
if ( isset ( $_GET [ 'thisgroup' ])) {
2023-08-20 00:33:05 +02:00
$_GET [ 'thisgroup' ] = _rawurldecode ( $_GET [ 'thisgroup' ]);
if ( get_section_by_group ( $_GET [ 'thisgroup' ]) == false ) {
echo " Group not found " ;
exit ( 1 );
}
$grouplist = array ();
$grouplist [ 0 ] = _rawurldecode ( _rawurldecode ( $_GET [ 'thisgroup' ]));
$cachefile = $spooldir . " / " . $grouplist [ 0 ] . " -overboard.dat " ;
2024-04-26 13:48:28 +02:00
if ( isset ( $_COOKIE [ 'mail_name' ])) {
if ( $userdata = get_user_mail_auth_data ( $_COOKIE [ 'mail_name' ])) {
$userfile = $spooldir . '/' . strtolower ( $_COOKIE [ 'mail_name' ]) . '-articleviews.dat' ;
$user_config = unserialize ( file_get_contents ( $config_dir . '/userconfig/' . strtolower ( $_COOKIE [ 'mail_name' ]) . '.config' ));
$userdata [ $grouplist [ 0 ]] = time ();
file_put_contents ( $userfile , serialize ( $userdata ));
}
2023-08-20 00:33:05 +02:00
}
2020-11-29 01:55:31 +01:00
} else {
2023-08-20 00:33:05 +02:00
$grouplist = file ( $groupconfig , FILE_IGNORE_NEW_LINES );
2020-11-29 01:55:31 +01:00
}
2024-04-26 13:48:28 +02:00
// Determine default view style
if ( isset ( $_COOKIE [ 'mail_name' ])) {
2024-04-28 12:05:02 +02:00
if ( $user_obstyle = get_config_file_value ( $config_dir . '/userconfig/' . strtolower ( $_COOKIE [ 'mail_name' ]), 'obstyle' )) {
2024-04-26 13:48:28 +02:00
$_SESSION [ 'obstyle' ] = $user_obstyle ;
}
}
if ( isset ( $_POST [ 'obstyle' ])) {
$_SESSION [ 'obstyle' ] = $_POST [ 'obstyle' ];
}
if ( ! isset ( $_SESSION [ 'obstyle' ])) {
if ( isset ( $OVERRIDES [ 'overboard_default_view' ])) {
$_SESSION [ 'obstyle' ] = $OVERRIDES [ 'overboard_default_view' ];
} else {
$_SESSION [ 'obstyle' ] = 'articles' ;
}
}
if ( isset ( $_COOKIE [ 'mail_name' ])) {
save_config_value ( $config_dir . '/userconfig/' . strtolower ( $_COOKIE [ 'mail_name' ]), 'obstyle' , $_SESSION [ 'obstyle' ], true );
}
2024-04-28 12:05:02 +02:00
show_overboard_header ( $grouplist );
2024-04-26 13:48:28 +02:00
2023-08-20 00:33:05 +02:00
$results = 0 ;
2022-04-10 06:30:34 +02:00
2023-08-20 00:33:05 +02:00
if ( ! isset ( $this_overboard [ 'version' ])) {
2023-06-03 20:42:49 +02:00
$this_overboard [ 'version' ] = '0' ;
}
2023-08-20 00:33:05 +02:00
if ( is_file ( $cachefile )) {
$stats = stat ( $cachefile );
$this_overboard = unserialize ( file_get_contents ( $cachefile ));
$cachedate = ( $this_overboard [ 'lastmessage' ] - 86400 );
$oldest = $cachedate ;
2022-04-10 06:30:34 +02:00
} else {
2023-08-20 00:33:05 +02:00
$cachedate = ( $oldest - 86400 );
2022-04-10 06:30:34 +02:00
}
2023-08-20 00:33:05 +02:00
if ( $this_overboard [ 'version' ] !== $version ) {
unset ( $this_overboard );
if ( is_file ( $cachefile )) {
unlink ( $cachefile );
}
$this_overboard [ 'version' ] = $version ;
$cachedate = ( $oldest - 86400 );
2020-11-29 01:55:31 +01:00
}
2022-04-10 06:30:34 +02:00
2020-11-29 01:55:31 +01:00
# Iterate through groups
2023-08-20 00:33:05 +02:00
$database = $spooldir . '/articles-overview.db3' ;
2020-12-12 05:16:13 +01:00
$table = 'overview' ;
2023-08-13 19:00:48 +02:00
$dbh = overview_db_open ( $database , $table );
2023-08-20 00:33:05 +02:00
$query = $dbh -> prepare ( 'SELECT * FROM ' . $table . ' WHERE newsgroup=:findgroup AND date >= ' . $cachedate . ' ORDER BY date DESC LIMIT ' . $maxdisplay );
foreach ( $grouplist as $findgroup ) {
$groups = preg_split ( " /( \ | \t )/ " , $findgroup , 2 );
$findgroup = $groups [ 0 ];
2020-11-29 01:55:31 +01:00
2023-08-20 00:33:05 +02:00
$overboard_noshow = explode ( ' ' , $CONFIG [ 'overboard_noshow' ]);
foreach ( $overboard_noshow as $noshow ) {
if (( strpos ( $findgroup , $noshow ) !== false ) && ! isset ( $_GET [ 'thisgroup' ])) {
continue 2 ;
}
}
$thisgroup = preg_replace ( '/\./' , '/' , $findgroup );
if ( $dbh ) {
$query -> execute ([
'findgroup' => $findgroup
]);
2024-03-10 12:48:57 +01:00
$results = 0 ;
2023-08-20 00:33:05 +02:00
while (( $overviewline = $query -> fetch ()) !== false ) {
2024-03-10 12:48:57 +01:00
$thismsgid = $overviewline [ 'msgid' ];
$target = get_data_from_msgid ( $thismsgid , $findgroup );
if ( $target [ 'date' ] > time ()) {
continue ;
2023-08-20 00:33:05 +02:00
}
2024-03-10 12:48:57 +01:00
if ( ! isset ( $this_overboard [ 'lastmessage' ])) {
$this_overboard [ 'lastmessage' ] = 0 ;
}
if ( $target [ 'date' ] > $this_overboard [ 'lastmessage' ]) {
$this_overboard [ 'lastmessage' ] = $target [ 'date' ];
}
2024-04-26 13:48:28 +02:00
2024-03-10 12:48:57 +01:00
if ( ! isset ( $this_overboard [ 'threads' ][ $target [ 'date' ]])) {
$this_overboard [ 'threads' ][ $target [ 'date' ]] = $thismsgid ;
$this_overboard [ 'msgids' ][ $thismsgid ] = $target ;
if ( trim ( $overviewline [ 'refs' ]) != '' ) {
$ref = preg_split ( " /[ \ s]+/ " , $overviewline [ 'refs' ]);
$this_overboard [ 'threadlink' ][ $thismsgid ] = $ref [ 0 ];
}
if ( $results ++ > ( $maxdisplay - 2 )) {
break ;
}
2023-08-20 00:33:05 +02:00
}
}
2020-11-29 01:55:31 +01:00
}
2022-04-10 06:30:34 +02:00
}
2021-12-23 04:30:59 +01:00
2024-03-12 16:16:54 +01:00
$this_overboard [ 'version' ] = $version ;
2022-04-10 06:30:34 +02:00
file_put_contents ( $cachefile , serialize ( $this_overboard ));
2023-08-20 00:33:05 +02:00
if ( isset ( $user_time )) {
$oldest = ( $user_time - 900 );
2022-04-10 06:30:34 +02:00
} else {
2023-08-20 00:33:05 +02:00
$oldest = ( time () - ( 86400 * $article_age ));
2020-11-29 01:55:31 +01:00
}
2024-03-10 12:48:57 +01:00
2024-04-26 13:48:28 +02:00
if ( $_SESSION [ 'obstyle' ] == 'threads' ) {
$results = display_threads ( $this_overboard [ 'threads' ], $oldest );
} else {
$results = display_flat ( $this_overboard [ 'threads' ], $oldest );
}
2022-04-10 06:30:34 +02:00
show_overboard_footer ( null , $results , null );
echo '</body></html>' ;
expire_overboard ( $cachefile );
2023-08-20 00:33:05 +02:00
function expire_overboard ( $cachefile )
{
2024-04-26 13:48:28 +02:00
global $article_age , $logfile , $config_name , $this_overboard ;
2023-08-20 00:33:05 +02:00
if ( ! isset ( $this_overboard [ 'expire' ])) {
$this_overboard [ 'expire' ] = time ();
}
2024-04-26 13:48:28 +02:00
$prune = false ;
2023-08-20 00:33:05 +02:00
if ( $this_overboard [ 'expire' ] < ( time () - 86400 )) {
$prune = true ;
foreach ( $this_overboard [ 'msgids' ] as $key => $value ) {
$target = $this_overboard [ 'msgids' ][ $key ];
if ( $target [ 'date' ] < ( time () - ( 86400 * $article_age ))) {
file_put_contents ( $logfile , " \n " . format_log_date () . " " . $config_name . " Expiring: " . $target [ 'newsgroup' ] . " : " . $target [ 'number' ], FILE_APPEND );
unset ( $this_overboard [ 'threads' ][ $target [ 'date' ]]);
unset ( $this_overboard [ 'msgids' ][ $key ]);
unset ( $this_overboard [ 'threadlink' ][ $key ]);
}
2022-04-10 06:30:34 +02:00
}
2023-08-20 00:33:05 +02:00
$this_overboard [ 'expire' ] = time ();
2021-12-22 06:57:12 +01:00
}
2023-08-20 00:33:05 +02:00
if ( $prune ) {
file_put_contents ( $cachefile , serialize ( $this_overboard ));
2021-12-22 06:57:12 +01:00
}
2022-04-10 06:30:34 +02:00
}
2023-08-20 00:33:05 +02:00
function display_threads ( $threads , $oldest )
{
2024-04-28 12:05:02 +02:00
global $CONFIG , $OVERRIDES , $thissite , $logfile , $config_name , $spooldir , $config_dir , $snippetlength , $maxdisplay , $this_overboard , $article_age , $newonly ;
2024-04-26 13:48:28 +02:00
$expireme = time () - ( $article_age * 86400 );
$display = '<table cellspacing="0" width="100%" class="np_results_table">' ;
if ( ! isset ( $threads )) {
$threads = ( object ) [];
} else {
krsort ( $threads );
}
// Get registered user settings
2024-04-28 12:05:02 +02:00
$newonly = false ;
2024-04-26 13:48:28 +02:00
if ( isset ( $_COOKIE [ 'mail_name' ])) {
if ( $userdata = get_user_mail_auth_data ( $_COOKIE [ 'mail_name' ])) {
$user_config = unserialize ( file_get_contents ( $config_dir . '/userconfig/' . strtolower ( $_COOKIE [ 'mail_name' ]) . '.config' ));
2024-04-26 15:04:58 +02:00
$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 ;
}
2024-04-26 13:48:28 +02:00
}
if ( ! isset ( $user_config [ 'hide_unsub' ])) {
if ( isset ( $OVERRIDES [ 'hide_unsub' ])) {
$user_config [ 'hide_unsub' ] = $OVERRIDES [ 'hide_unsub' ];
} else {
$user_config [ 'hide_unsub' ] = 'hide' ;
}
}
2024-04-28 12:05:02 +02:00
// Show NEW in Section only
if ( isset ( $_REQUEST [ 'new' ]) && $_REQUEST [ 'new' ] == true ) {
$newonly = true ;
}
2024-04-26 13:48:28 +02:00
}
// Build display array
$nicole = array ();
foreach ( $threads as $key => $value ) {
if ( $key < $oldest ) {
continue ;
}
if ( ! isset ( $this_overboard [ 'threadlink' ][ $value ])) {
// Add article with no available top reference to array
$nicole [ $value ][ $value ] = $value ;
} else {
$nicole [ $this_overboard [ 'threadlink' ][ $value ]][ $value ] = $value ;
}
}
$style = 0 ;
$results = 0 ;
foreach ( $nicole as $key => $value ) {
$target_head = $this_overboard [ 'msgids' ][ $key ];
if ( ! isset ( $target_head [ 'msgid' ])) {
$target_head = get_data_from_msgid ( $key );
}
2024-04-28 12:05:02 +02:00
2024-04-26 13:48:28 +02:00
// Skip if not in registered users sub list
$checkgroup = $target_head [ 'newsgroup' ];
if ( ! isset ( $userdata [ $checkgroup ])) {
if ( isset ( $user_config [ 'hide_unsub' ]) && $user_config [ 'hide_unsub' ] == 'hide' ) {
continue ;
}
}
2024-04-28 12:05:02 +02:00
// 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 ;
}
}
}
}
2024-04-26 13:48:28 +02:00
$nohead = true ;
$result_count = count ( $value );
foreach ( $value as $new ) {
$target = $this_overboard [ 'msgids' ][ $new ];
if ( ! isset ( $target [ 'msgid' ])) {
$target = get_data_from_msgid ( $new );
}
if ( $target [ 'date' ] < $oldest ) {
continue ;
}
2024-04-28 12:05:02 +02:00
// Skip if not in registered users sub list
$checkgroup = $target [ 'newsgroup' ];
if ( ! isset ( $userdata [ $checkgroup ])) {
if ( isset ( $user_config [ 'hide_unsub' ]) && $user_config [ 'hide_unsub' ] == 'hide' ) {
continue ;
}
}
// Check if only displaying new posts in section
if ( $newonly ) {
$allgroups = get_group_array_from_msgid ( $new );
foreach ( $allgroups as $onegroup ) {
if ( isset ( $userdata [ $onegroup ])) {
if ( $userdata [ $onegroup ] > $target [ 'date' ]) {
continue 2 ;
}
}
}
}
2024-04-26 13:48:28 +02:00
$results ++ ;
$lone == '' ;
$skip = '' ;
if ( $nohead ) {
if (( $style % 2 ) == 0 ) {
$display .= '<tr class="np_result_line2"><td class="np_result_line2" style="word-wrap:break-word";>' ;
} 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>' ;
2024-04-28 12:05:02 +02:00
// RETRO - Determining whether to show snippet in each head may still have bugs
// meaning, it might show when it shouldn't or not when it should. Not sure yet.
2024-04-26 13:48:28 +02:00
if ( $result_count > 1 && isset ( $target_head [ 'date' ])) {
$poster = get_poster_name ( mb_decode_mimeheader ( $target_head [ 'name' ]));
2024-04-26 15:04:58 +02:00
$block = false ;
2024-04-26 16:03:51 +02:00
foreach ( $blocked_user_config as $bkey => $bvalue ) {
$blockme = '/' . addslashes ( $bkey ) . '/' ;
2024-04-26 15:04:58 +02:00
if ( preg_match ( $blockme , $target_head [ 'name' ])) {
$block = true ;
break ;
}
}
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 );
$display .= wordwrap ( substr ( $article [ 'search_snippet' ], 0 , $snippetlength ), ( $snippetlength / 2 ), " <br /> \n " , true );
}
2024-04-26 13:48:28 +02:00
}
$skip = $target_head [ 'number' ];
}
$display .= '</center>' ;
$style ++ ;
$nohead = false ;
}
if ( $skip != $target [ 'number' ]) {
$poster = get_poster_name ( mb_decode_mimeheader ( $target [ 'name' ]));
2024-04-26 15:04:58 +02:00
$block = false ;
foreach ( $blocked_user_config as $key => $value ) {
$blockme = '/' . addslashes ( $key ) . '/' ;
if ( preg_match ( $blockme , $target [ 'name' ])) {
$block = true ;
break ;
}
2024-04-26 13:48:28 +02:00
}
2024-04-26 15:04:58 +02:00
if ( $block ) {
$display .= '<br /><br />' ;
$display .= '<p class=np_ob_subject>' ;
$display .= '<b><span>(message #' . $target [ 'number' ] . ' hidden by your blocklist)</span></a></b>' ;
} else {
$groupurl = $thissite . " /thread.php?group= " . _rawurlencode ( $target [ 'newsgroup' ]);
$url = $thissite . " /article-flat.php?id= " . $target [ 'number' ] . " &group= " . _rawurlencode ( $target [ 'newsgroup' ]) . " # " . $target [ 'number' ];
$display .= '<br /><br />' ;
$display .= '<p class=np_ob_subject>' ;
$display .= '<b><a href="' . $url . '"><span>' . headerDecode ( $target [ 'subject' ]) . '</span></a></b>' ;
$display .= '</p>' ;
$display .= '<p class=np_ob_body>' ;
$display .= 'by: <b><i><span class="visited">' . create_name_link ( $poster [ 'name' ], $poster [ 'from' ]) . '</span></i></b>' ;
$display .= '</p>' ;
$display .= '<p class=np_ob_posted_date>Posted: ' . get_date_interval ( date ( " D, j M Y H:i T " , $target [ 'date' ])) . ' in: <a href="' . $groupurl . '"><span class="visited">' . $target [ 'newsgroup' ] . '</span></a></p>' ;
if ( $CONFIG [ 'article_database' ] == '1' ) {
$article = get_db_data_from_msgid ( $target [ 'msgid' ], $target [ 'newsgroup' ], 1 );
$display .= htmlentities ( substr ( $article [ 'search_snippet' ], 0 , $snippetlength ));
}
if ( $target [ 'date' ] < $expireme ) {
unset ( $this_overboard [ 'threads' ][ $target [ 'date' ]]);
unset ( $this_overboard [ 'threadlink' ][ $new ]);
file_put_contents ( $logfile , " \n " . format_log_date () . " " . $config_name . " Pruning: " . $target [ 'newsgroup' ] . " : " . $target [ 'number' ], FILE_APPEND );
}
2024-04-26 13:48:28 +02:00
}
}
}
$display .= '</td></tr>' ;
}
$display .= " </table> " ;
echo $display ;
return ( $results );
}
function display_flat ( $threads , $oldest )
{
2024-04-28 12:05:02 +02:00
global $CONFIG , $OVERRIDES , $thissite , $logfile , $spooldir , $config_name , $config_dir , $snippetlength , $maxdisplay , $this_overboard , $article_age , $newonly ;
2024-04-26 13:48:28 +02:00
$expireme = time () - ( $article_age * 86400 );
2024-03-10 12:48:57 +01:00
$display = '<table cellspacing="0" width="100%" class="np_results_table">' ;
2023-08-20 00:33:05 +02:00
if ( ! isset ( $threads )) {
$threads = ( object ) [];
2023-05-12 23:02:39 +02:00
} else {
2023-08-20 00:33:05 +02:00
krsort ( $threads );
2023-04-14 03:52:30 +02:00
}
2024-03-05 13:53:11 +01:00
// Get registered user settings
2024-04-28 12:05:02 +02:00
$newonly = false ;
2024-03-05 13:53:11 +01:00
if ( isset ( $_COOKIE [ 'mail_name' ])) {
if ( $userdata = get_user_mail_auth_data ( $_COOKIE [ 'mail_name' ])) {
$userfile = $spooldir . '/' . strtolower ( $_COOKIE [ 'mail_name' ]) . '-articleviews.dat' ;
$user_config = unserialize ( file_get_contents ( $config_dir . '/userconfig/' . strtolower ( $_COOKIE [ 'mail_name' ]) . '.config' ));
}
2024-04-26 15:04:58 +02:00
$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 ;
}
2024-03-10 12:48:57 +01:00
2024-03-05 13:53:11 +01:00
if ( ! isset ( $user_config [ 'hide_unsub' ])) {
if ( isset ( $OVERRIDES [ 'hide_unsub' ])) {
$user_config [ 'hide_unsub' ] = $OVERRIDES [ 'hide_unsub' ];
} else {
$user_config [ 'hide_unsub' ] = 'hide' ;
}
}
2024-04-28 12:05:02 +02:00
// Show NEW in Section only
if ( isset ( $_REQUEST [ 'new' ]) && $_REQUEST [ 'new' ] == true ) {
$newonly = true ;
}
2024-03-05 13:53:11 +01:00
}
2022-04-10 06:30:34 +02:00
$results = 0 ;
2023-08-20 00:33:05 +02:00
foreach ( $threads as $key => $value ) {
$target = $this_overboard [ 'msgids' ][ $value ];
2024-03-05 13:53:11 +01:00
$checkgroup = $target [ 'newsgroup' ];
2023-08-20 00:33:05 +02:00
if ( ! isset ( $target [ 'msgid' ])) {
$target = get_data_from_msgid ( $value );
}
2024-03-10 12:48:57 +01:00
if ( ! isset ( $userdata [ $checkgroup ])) {
2024-03-05 13:53:11 +01:00
if ( isset ( $user_config [ 'hide_unsub' ]) && $user_config [ 'hide_unsub' ] == 'hide' ) {
continue ;
}
}
2023-08-20 00:33:05 +02:00
if ( $target [ 'date' ] < $oldest ) {
continue ;
}
2024-04-28 12:05:02 +02:00
// Check if only displaying new posts in section
if ( $newonly ) {
$allgroups = get_group_array_from_msgid ( $value );
foreach ( $allgroups as $onegroup ) {
if ( isset ( $userdata [ $onegroup ])) {
if ( $userdata [ $onegroup ] > $target [ 'date' ]) {
continue 2 ;
}
}
}
}
2024-04-26 13:48:28 +02:00
if ( $target [ 'date' ] < $expireme ) {
2023-08-20 00:33:05 +02:00
unset ( $this_overboard [ 'threads' ][ $target [ 'date' ]]);
2024-04-26 13:48:28 +02:00
unset ( $this_overboard [ 'threadlink' ][ $new ]);
2023-08-20 00:33:05 +02:00
file_put_contents ( $logfile , " \n " . format_log_date () . " " . $config_name . " Pruning: " . $target [ 'newsgroup' ] . " : " . $target [ 'number' ], FILE_APPEND );
}
2022-04-10 06:30:34 +02:00
$poster = get_poster_name ( mb_decode_mimeheader ( $target [ 'name' ]));
2023-08-20 00:33:05 +02:00
$groupurl = $thissite . " /thread.php?group= " . _rawurlencode ( $target [ 'newsgroup' ]);
if (( $results % 2 ) == 0 ) {
2024-03-10 12:48:57 +01:00
$display .= '<tr class="np_result_line2"><td class="np_result_line2" style="word-wrap:break-word";>' ;
2022-04-10 06:30:34 +02:00
} else {
2024-03-10 12:48:57 +01:00
$display .= '<tr class="np_result_line1"><td class="np_result_line1" style="word-wrap:break-word";>' ;
2022-04-10 06:30:34 +02:00
}
2024-04-26 15:04:58 +02:00
$block = false ;
2024-04-26 16:03:51 +02:00
foreach ( $blocked_user_config as $bkey => $bvalue ) {
$blockme = '/' . addslashes ( $bkey ) . '/' ;
2024-04-26 15:04:58 +02:00
if ( preg_match ( $blockme , $target [ 'name' ])) {
$block = true ;
break ;
2024-02-02 21:10:01 +01:00
}
2023-08-20 00:33:05 +02:00
}
2024-04-26 15:04:58 +02:00
if ( $block ) {
$display .= '<p class=np_ob_subject>' ;
$display .= '<b><span>(message #' . $target [ 'number' ] . ' hidden by your blocklist)</span></a></b>' ;
} else {
$url = $thissite . " /article-flat.php?id= " . $target [ 'number' ] . " &group= " . _rawurlencode ( $target [ 'newsgroup' ]) . " # " . $target [ 'number' ];
$display .= '<p class=np_ob_subject>' ;
$display .= '<b><a href="' . $url . '"><span>' . headerDecode ( $target [ 'subject' ]) . '</span></a></b>' ;
2024-04-26 16:03:51 +02:00
$display .= '<p class=np_ob_body>' ;
$display .= 'by: <b><i><span class="visited">' . create_name_link ( $poster [ 'name' ], $poster [ 'from' ]) . '</span></i></b>' ;
2024-04-28 12:05:02 +02:00
2024-04-26 16:03:51 +02:00
$display .= '</p>' ;
2024-04-26 15:04:58 +02:00
// link for (thread), if possible
if ( isset ( $this_overboard [ 'threadlink' ][ $value ])) {
$thread = get_data_from_msgid ( $this_overboard [ 'threadlink' ][ $value ], $target [ 'newsgroup' ]);
if ( $thread !== false ) {
2024-04-26 16:03:51 +02:00
$display .= '<font class="np_ob_group"><a href="article-flat.php?id=' . $thread [ 'number' ] . '&group=' . rawurlencode ( $thread [ 'newsgroup' ]) . '#' . $thread [ 'number' ] . '"> (full thread)</a></font>' ;
2024-04-26 15:04:58 +02:00
}
}
$display .= '</p>' ;
2024-04-26 16:03:51 +02:00
$display .= '<p class=np_ob_posted_date>Posted: ' . get_date_interval ( date ( " D, j M Y H:i T " , $target [ 'date' ])) . ' in: <a href="' . $groupurl . '"><span class="visited">' . $target [ 'newsgroup' ] . '</p>' ;
2024-04-26 15:04:58 +02:00
if ( $CONFIG [ 'article_database' ] == '1' ) {
$article = get_db_data_from_msgid ( $target [ 'msgid' ], $target [ 'newsgroup' ], 1 );
$display .= htmlentities ( substr ( $article [ 'search_snippet' ], 0 , $snippetlength ));
}
2023-06-03 20:42:49 +02:00
}
2023-08-20 00:33:05 +02:00
$results ++ ;
2021-12-22 06:57:12 +01:00
}
2024-03-10 12:48:57 +01:00
$display .= " </table> " ;
echo $display ;
2023-08-20 00:33:05 +02:00
return ( $results );
2022-04-10 06:30:34 +02:00
}
2020-11-29 01:55:31 +01:00
2023-08-20 00:33:05 +02:00
function show_overboard_header ( $grouplist )
{
global $text_thread , $frame , $text_article , $file_index , $file_thread , $user_time ;
2021-12-22 06:57:12 +01:00
2023-08-20 00:33:05 +02:00
if ( isset ( $_GET [ 'thisgroup' ])) {
echo '<h1 class="np_thread_headline">' ;
echo '<a href="' . $file_index . '" target=' . $frame [ 'menu' ] . '>' . basename ( getcwd ()) . '</a> / ' ;
echo '<a href="' . $file_thread . '?group=' . rawurlencode ( $grouplist [ 0 ]) . '" target=' . $frame [ " content " ] . '>' . htmlspecialchars ( group_displaY_name ( $grouplist [ 0 ])) . '</a> / ' ;
if ( isset ( $user_time )) {
echo ' new messages</h1>' ;
} else {
echo ' latest</h1>' ;
}
echo '<table cellpadding="0" cellspacing="0" class="np_buttonbar"><tr>' ;
// Refresh button
echo '<td>' ;
2024-04-28 12:05:02 +02:00
echo '<div style="float:left;">' ;
2023-08-20 00:33:05 +02:00
echo '<form action="overboard.php">' ;
echo '<input type="hidden" name="thisgroup" value="' . $_GET [ 'thisgroup' ] . '"/>' ;
if ( isset ( $user_time )) {
echo '<button class="np_button_link" type="submit">overboard</button>' ;
} else {
echo '<button class="np_button_link" type="submit">' . $text_article [ " refresh " ] . '</button>' ;
}
echo '</form>' ;
2024-04-28 12:05:02 +02:00
echo '</div>' ;
2023-08-20 00:33:05 +02:00
// Article List button
echo '<form action="' . $file_thread . '">' ;
echo '<input type="hidden" name="group" value="' . $grouplist [ 0 ] . '"/>' ;
echo '<button class="np_button_link" type="submit">' . htmlspecialchars ( group_display_name ( $grouplist [ 0 ])) . '</button>' ;
echo '</form>' ;
echo '</td>' ;
// Newsgroups button (hidden)
if ( isset ( $frames_on ) && $frames_on === true ) {
echo '<td>' ;
echo '<form action="' . $file_index . '">' ;
echo '<button class="np_button_hidden" type="submit">' . $text_thread [ " button_grouplist " ] . '</button>' ;
echo '</form>' ;
echo '</td>' ;
}
2022-03-04 10:22:20 +01:00
} else {
2023-08-20 00:33:05 +02:00
echo '<h1 class="np_thread_headline">' ;
echo '<a href="' . $file_index . '" target=' . $frame [ 'menu' ] . '>' . basename ( getcwd ()) . '</a> / ' ;
echo 'latest messages</h1>' ;
echo '<table cellpadding="0" cellspacing="0" class="np_buttonbar"><tr>' ;
// Refresh button
echo '<td>' ;
echo '<form action="overboard.php">' ;
2024-04-28 12:05:02 +02:00
echo '<button class="np_button_link" type="submit">overboard</button>' ;
2023-08-20 00:33:05 +02:00
echo '</form>' ;
echo '</td>' ;
// Newsgroups button (hidden)
if ( isset ( $frames_on ) && $frames_on === true ) {
echo '<td>' ;
echo '<form action="' . $file_index . '">' ;
echo '<button class="np_button_hidden" type="submit">' . $text_thread [ " button_grouplist " ] . '</button>' ;
echo '</form>' ;
echo '</td>' ;
}
2022-03-04 10:22:20 +01:00
}
2024-04-28 12:05:02 +02:00
echo '</div><td></td>' ;
echo '<td class="np_ob_style_toggle">' ;
echo '<div style="float:right;">' ;
show_overboard_style_toggle ();
echo '</div>' ;
echo '</td>' ;
echo '</tr></table>' ;
2021-12-22 06:57:12 +01:00
}
2020-11-29 01:55:31 +01:00
2024-04-26 13:48:28 +02:00
function show_overboard_style_toggle ()
{
echo '<form method="post" action="' . $_SERVER [ 'REQUEST_URI' ] . '">' ;
echo 'Display as: ' ;
if ( $_SESSION [ 'obstyle' ] == 'threads' ) {
echo '<input type="radio" name="obstyle" value="threads" checked>Threads' ;
echo ' ' ;
echo '<input type="radio" name="obstyle" value="articles">Articles' ;
echo ' ' ;
} else {
echo '<input type="radio" name="obstyle" value="threads">Threads' ;
echo ' ' ;
echo '<input type="radio" name="obstyle" value="articles" checked>Articles' ;
echo ' ' ;
}
echo '<input class="np_button_link" type="submit" value="Reload" name="reload">' ;
echo '</form >' ;
}
2023-08-20 00:33:05 +02:00
function show_overboard_footer ( $stats , $results , $iscached )
{
2024-04-28 12:05:02 +02:00
global $user_time , $rslight_version , $newonly ;
if ( isset ( $user_time ) || $newonly ) {
2023-08-20 00:33:05 +02:00
$recent = 'new' ;
2022-01-26 03:01:59 +01:00
} else {
2023-08-20 00:33:05 +02:00
$recent = 'recent' ;
2022-01-26 03:01:59 +01:00
}
2023-08-20 00:33:05 +02:00
if ( $results == '1' ) {
$arts = 'article' ;
2022-01-28 05:17:01 +01:00
} else {
2023-08-20 00:33:05 +02:00
$arts = 'articles' ;
2022-01-28 05:17:01 +01:00
}
2021-12-22 06:57:12 +01:00
echo '</table>' ;
2023-08-20 00:33:05 +02:00
echo " <p class=np_ob_tail><b> " . $results . " </b> " . $recent . " " . $arts . " found.</p> \r \n " ;
# echo "<center><i>Rocksolid Overboard</i> version ".$version;
2021-12-22 06:57:12 +01:00
include " tail.inc " ;
2023-08-20 00:33:05 +02:00
if ( $iscached ) {
echo " <p class=np_ob_tail><font size='1em'>cached copy: " . date ( " D M j G:i:s T Y " , $stats [ 9 ]) . " </font></p> \r \n " ;
2021-12-22 06:57:12 +01:00
}
2020-11-29 01:55:31 +01:00
}