60) { $_SESSION['last_access'] = time(); } header("Expires: " . gmdate("D, d M Y H:i:s", time() + (120)) . " GMT"); header("Cache-Control: max-age=120"); header("Pragma: cache"); /* * 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"; if (isset($_COOKIE['mail_name'])) { if ($userdata = get_user_mail_auth_data($_COOKIE['mail_name'])) { $userfile = $spooldir . '/' . strtolower($_COOKIE['mail_name']) . '-articleviews.dat'; } } if (isset($frames_on) && $frames_on === true) { ?> Page Disabled"; include "tail.inc"; exit(); } $CONFIG = include ($config_file); $logfile = $logdir . '/overboard.log'; # How many days old should articles be displayed? if (isset($_GET['thisgroup'])) { $article_age = 30; } else { $article_age = 30; } $version = 1.2; # How long in seconds to cache results $cachetime = 60; # Maximum number of articles to show $maxdisplay = 1000; // default 1000 # How many characters of the body to display per article $snippetlength = 240; $spoolpath_regexp = '/' . preg_replace('/\//', '\\/', $spoolpath) . '/'; $thissite = '.'; $groupconfig = $file_groups; $cachefile = $spooldir . "/" . $config_name . "-overboard.dat"; $oldest = (time() - (86400 * $article_age)); $prune = false; if (isset($_GET['time'])) { $user_time = $_GET['time']; if (is_numeric($user_time)) { if (($user_time > time()) || ($user_time < $oldest)) { unset($user_time); } } else { unset($user_time); } } if (isset($_GET['thisgroup'])) { $_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"; if ($userdata) { $userdata[$grouplist[0]] = time(); file_put_contents($userfile, serialize($userdata)); } } else { $grouplist = file($groupconfig, FILE_IGNORE_NEW_LINES); } show_overboard_header($grouplist); $results = 0; if (! isset($this_overboard['version'])) { $this_overboard['version'] = '0'; } if (is_file($cachefile)) { $stats = stat($cachefile); $this_overboard = unserialize(file_get_contents($cachefile)); $cachedate = ($this_overboard['lastmessage'] - 86400); $oldest = $cachedate; } else { $cachedate = ($oldest - 86400); } if ($this_overboard['version'] !== $version) { unset($this_overboard); if (is_file($cachefile)) { unlink($cachefile); } $this_overboard['version'] = $version; $cachedate = ($oldest - 86400); } # Iterate through groups $database = $spooldir . '/articles-overview.db3'; $table = 'overview'; $dbh = overview_db_open($database, $table); $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]; $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 ]); $results = 0; while (($overviewline = $query->fetch()) !== false) { $thismsgid = $overviewline['msgid']; $target = get_data_from_msgid($thismsgid, $findgroup); if ($target['date'] > time()) { continue; } if (! isset($this_overboard['lastmessage'])) { $this_overboard['lastmessage'] = 0; } if ($target['date'] > $this_overboard['lastmessage']) { $this_overboard['lastmessage'] = $target['date']; } 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; } } } } } file_put_contents($cachefile, serialize($this_overboard)); if (isset($user_time)) { $oldest = ($user_time - 900); } else { $oldest = (time() - (86400 * $article_age)); } $results = display_threads($this_overboard['threads'], $oldest); show_overboard_footer(null, $results, null); echo ''; expire_overboard($cachefile); function expire_overboard($cachefile) { global $article_age, $logfile, $config_name, $prune, $this_overboard; if (! isset($this_overboard['expire'])) { $this_overboard['expire'] = time(); } 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]); } } $this_overboard['expire'] = time(); } if ($prune) { file_put_contents($cachefile, serialize($this_overboard)); } } function display_threads($threads, $oldest) { global $CONFIG, $OVERRIDES, $thissite, $logfile, $config_name, $snippetlength, $maxdisplay, $prune, $this_overboard; $display = ''; if (! isset($threads)) { $threads = (object) []; } else { krsort($threads); } // Get registered user settings 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')); } if (! isset($user_config['hide_unsub'])) { if (isset($OVERRIDES['hide_unsub'])) { $user_config['hide_unsub'] = $OVERRIDES['hide_unsub']; } else { $user_config['hide_unsub'] = 'hide'; } } } $results = 0; foreach ($threads as $key => $value) { $target = $this_overboard['msgids'][$value]; $checkgroup = $target['newsgroup']; if (! isset($target['msgid'])) { $target = get_data_from_msgid($value); } if (! isset($userdata[$checkgroup])) { if (isset($user_config['hide_unsub']) && $user_config['hide_unsub'] == 'hide') { continue; } } if ($target['date'] < $oldest) { continue; } if ($results > $maxdisplay) { $prune = true; unset($this_overboard['threads'][$target['date']]); unset($this_overboard['threadlink'][$value]); file_put_contents($logfile, "\n" . format_log_date() . " " . $config_name . " Pruning: " . $target['newsgroup'] . ":" . $target['number'], FILE_APPEND); } $poster = get_poster_name(mb_decode_mimeheader($target['name'])); $groupurl = $thissite . "/thread.php?group=" . _rawurlencode($target['newsgroup']); if (($results % 2) == 0) { $display .= '
'; } else { $display .= '
'; } $url = $thissite . "/article-flat.php?id=" . $target['number'] . "&group=" . _rawurlencode($target['newsgroup']) . "#" . $target['number']; $display .= '

'; $display .= '' . headerDecode($target['subject']) . ''; // 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) { $display .= ' (thread)'; } } $display .= '

'; $display .= '

'; $display .= '' . $target['newsgroup'] . ''; $display .= '

'; $display .= '

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

'; if ($CONFIG['article_database'] == '1') { $article = get_db_data_from_msgid($target['msgid'], $target['newsgroup'], 1); $display .= htmlentities(substr($article['search_snippet'], 0, $snippetlength)); } $results ++; } $display .= "
"; echo $display; return ($results); } function show_overboard_header($grouplist) { global $text_thread, $frame, $text_article, $file_index, $file_thread, $user_time; if (isset($_GET['thisgroup'])) { echo '

'; echo '' . basename(getcwd()) . ' / '; echo '' . htmlspecialchars(group_displaY_name($grouplist[0])) . ' / '; if (isset($user_time)) { echo ' new messages

'; } else { echo ' latest'; } echo ''; // Refresh button echo ''; // Article List button echo ''; // Newsgroups button (hidden) if (isset($frames_on) && $frames_on === true) { echo ''; } echo '
'; echo '
'; echo ''; if (isset($user_time)) { echo ''; } else { echo ''; } echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; } else { echo '

'; echo '' . basename(getcwd()) . ' / '; echo 'latest messages

'; echo ''; // Refresh button echo ''; // Newsgroups button (hidden) if (isset($frames_on) && $frames_on === true) { echo ''; } echo '
'; echo '
'; echo ''; echo '
'; echo '
'; echo '
'; echo ''; echo '
'; echo '
'; } } function show_overboard_footer($stats, $results, $iscached) { global $user_time, $rslight_version; if (isset($user_time)) { $recent = 'new'; } else { $recent = 'recent'; } if ($results == '1') { $arts = 'article'; } else { $arts = 'articles'; } echo ''; echo "

" . $results . " " . $recent . " " . $arts . " found.

\r\n"; # echo "
Rocksolid Overboard version ".$version; include "tail.inc"; if ($iscached) { echo "

cached copy: " . date("D M j G:i:s T Y", $stats[9]) . "

\r\n"; } } ?>