Some warnings cleanup in overboard.php.

This commit is contained in:
Retro_Guy 2023-06-03 11:42:49 -07:00
parent 75d000d89b
commit b0bac6f428
1 changed files with 30 additions and 14 deletions

View File

@ -114,6 +114,9 @@ show_overboard_header($grouplist);
$results=0; $results=0;
if(!isset($this_overboard['version'])) {
$this_overboard['version'] = '0';
}
if(is_file($cachefile)) { if(is_file($cachefile)) {
$stats = stat($cachefile); $stats = stat($cachefile);
$this_overboard = unserialize(file_get_contents($cachefile)); $this_overboard = unserialize(file_get_contents($cachefile));
@ -124,7 +127,9 @@ if(is_file($cachefile)) {
} }
if($this_overboard['version'] !== $version) { if($this_overboard['version'] !== $version) {
unset($this_overboard); unset($this_overboard);
unlink($cachefile); if(is_file($cachefile)) {
unlink($cachefile);
}
$this_overboard['version'] = $version; $this_overboard['version'] = $version;
$cachedate = ($oldest - 86400); $cachedate = ($oldest - 86400);
} }
@ -209,26 +214,32 @@ foreach($files as $article) {
continue; continue;
} }
preg_match('/References:.*/i', $header, $ref); $isref = preg_match('/References:.*/i', $header, $ref);
$getrefs = explode(': ', $ref[0]); if($isref) {
$ref = preg_split("/[\s]+/", $getrefs[1]); $getrefs = explode(': ', $ref[0]);
if($getrefs[1] && $refid = get_data_from_msgid($ref[0])) { $ref = preg_split("/[\s]+/", $getrefs[1]);
// Check that article to link is new enough for newsportal to display if($getrefs[1] && $refid = get_data_from_msgid($ref[0])) {
$groupinfo = file($spooldir.'/'.$refid["newsgroup"].'-info.txt'); // Check that article to link is new enough for newsportal to display
$range = explode(' ', $groupinfo[1]); $groupinfo = file($spooldir.'/'.$refid["newsgroup"].'-info.txt');
if($refid['number'] > (intval($range[0]) - 1)) { $range = explode(' ', $groupinfo[1]);
$threadref = $ref[0]; if($refid['number'] > (intval($range[0]) - 1)) {
$threadref = $ref[0];
} else {
$threadref = false;
}
} else { } else {
$threadref = false; $threadref = false;
} }
} else { } else {
$threadref = false; $threadref = false;
} }
$target = get_data_from_msgid($thismsgid); $target = get_data_from_msgid($thismsgid);
if($target['date'] > time()) { if($target['date'] > time()) {
continue; continue;
} }
if(!isset($this_overboard['lastmessage'])) {
$this_overboard['lastmessage'] = 0;
}
if($target['date'] > $this_overboard['lastmessage']) { if($target['date'] > $this_overboard['lastmessage']) {
$this_overboard['lastmessage'] = $target['date']; $this_overboard['lastmessage'] = $target['date'];
} }
@ -257,6 +268,9 @@ expire_overboard($cachefile);
function expire_overboard($cachefile) { function expire_overboard($cachefile) {
global $article_age, $logfile, $config_name, $prune, $this_overboard; global $article_age, $logfile, $config_name, $prune, $this_overboard;
if(!isset($this_overboard['expire'])) {
$this_overboard['expire'] = time();
}
if($this_overboard['expire'] < (time() - 86400)) { if($this_overboard['expire'] < (time() - 86400)) {
$prune = true; $prune = true;
foreach($this_overboard['msgids'] as $key => $value) { foreach($this_overboard['msgids'] as $key => $value) {
@ -276,7 +290,7 @@ function expire_overboard($cachefile) {
} }
function display_threads($threads, $oldest) { function display_threads($threads, $oldest) {
global $thissite, $logfile, $config_name, $snippetlength, $maxdisplay, $prune, $this_overboard; global $CONFIG,$thissite, $logfile, $config_name, $snippetlength, $maxdisplay, $prune, $this_overboard;
echo '<table cellspacing="0" width="100%" class="np_results_table">'; echo '<table cellspacing="0" width="100%" class="np_results_table">';
if(!isset($threads)) { if(!isset($threads)) {
$threads = (object)[]; $threads = (object)[];
@ -318,7 +332,9 @@ function display_threads($threads, $oldest) {
echo '<a href="'.$groupurl.'"><span class="visited">'.$target['newsgroup'].'</span></a>'; echo '<a href="'.$groupurl.'"><span class="visited">'.$target['newsgroup'].'</span></a>';
echo '</p>'; echo '</p>';
echo '<p class=np_ob_posted_date>Posted: '.get_date_interval(date("D, j M Y H:i T",$target['date'])).' by: '.create_name_link($poster['name'], $poster['from']).'</p>'; echo '<p class=np_ob_posted_date>Posted: '.get_date_interval(date("D, j M Y H:i T",$target['date'])).' by: '.create_name_link($poster['name'], $poster['from']).'</p>';
echo htmlentities(substr($article['search_snippet'], 0, $snippetlength)); if($CONFIG['article_database'] == '1') {
echo htmlentities(substr($article['search_snippet'], 0, $snippetlength));
}
$results++; $results++;
} }
echo "</table>"; echo "</table>";