Address two minor php warnings. Check var exsists before using.

This commit is contained in:
Retro_Guy 2024-10-23 07:56:36 -07:00
parent d686415a0d
commit a9a9e2d6a2
2 changed files with 36 additions and 30 deletions

View File

@ -35,7 +35,7 @@ function thread_pageselect($group, $article_count, $first)
$pages = ceil($article_count / $articles_per_page); $pages = ceil($article_count / $articles_per_page);
if ($article_count > $articles_per_page) if ($article_count > $articles_per_page)
echo $text_thread["pages"]; echo $text_thread["pages"];
for ($i = 0; $i < $pages; $i ++) { for ($i = 0; $i < $pages; $i++) {
// echo '['; // echo '[';
if ($first != $i * $articles_per_page + 1) { if ($first != $i * $articles_per_page + 1) {
echo '<a class="np_pages_unselected" href="' . $file_thread . '?group=' . urlencode($group) . '&amp;first=' . ($i * $articles_per_page + 1) . '&amp;last=' . ($i + 1) * $articles_per_page . '">'; echo '<a class="np_pages_unselected" href="' . $file_thread . '?group=' . urlencode($group) . '&amp;first=' . ($i * $articles_per_page + 1) . '&amp;last=' . ($i + 1) * $articles_per_page . '">';
@ -156,11 +156,11 @@ function thread_overview_interpret($line, $overviewformat, $groupname)
$overviewfmt = explode("\t", $overviewformat); $overviewfmt = explode("\t", $overviewformat);
echo " "; // keep the connection to the webbrowser alive echo " "; // keep the connection to the webbrowser alive
flush(); // while generating the message-tree flush(); // while generating the message-tree
// $over=explode("\t",$line,count($overviewfmt)-1); // $over=explode("\t",$line,count($overviewfmt)-1);
$over = explode("\t", $line); $over = explode("\t", $line);
// $article=new headerType; // $article=new headerType;
$article = (object) []; $article = (object) [];
for ($i = 0; $i < count($overviewfmt) - 1; $i ++) { for ($i = 0; $i < count($overviewfmt) - 1; $i++) {
if ($overviewfmt[$i] == "Subject:") { if ($overviewfmt[$i] == "Subject:") {
$subject = preg_replace('/\[doctalk\]/i', '', headerDecode($over[$i + 1])); $subject = preg_replace('/\[doctalk\]/i', '', headerDecode($over[$i + 1]));
// $article->isReply = splitSubject($subject); // $article->isReply = splitSubject($subject);
@ -190,9 +190,11 @@ function thread_overview_interpret($line, $overviewformat, $groupname)
$article->references = explode(" ", $over[$i + 1]); $article->references = explode(" ", $over[$i + 1]);
} }
} }
foreach ($article->references as &$refs) { if (isset($article->references)) {
if (! strcmp($article->id, $refs)) { foreach ($article->references as &$refs) {
$refs = ""; if (! strcmp($article->id, $refs)) {
$refs = "";
}
} }
} }
$article->number = $over[0]; $article->number = $over[0];
@ -240,11 +242,11 @@ function thread_mycompare($a, $b)
{ {
global $thread_sort_order, $thread_sort_type; global $thread_sort_order, $thread_sort_type;
if ($thread_sort_type != "thread") { if ($thread_sort_type != "thread") {
$r = ($a->date < $b->date) ? - 1 : 1; $r = ($a->date < $b->date) ? -1 : 1;
if ($a->date == $b->date) if ($a->date == $b->date)
$r = 0; $r = 0;
} else { } else {
$r = ($a->date_thread < $b->date_thread) ? - 1 : 1; $r = ($a->date_thread < $b->date_thread) ? -1 : 1;
if ($a->date_thread == $b->date_thread) if ($a->date_thread == $b->date_thread)
$r = 0; $r = 0;
} }
@ -362,9 +364,9 @@ function thread_load_newsserver(&$ns, $groupname, $poll)
} }
if ($spoolopenmodus == 't') { if ($spoolopenmodus == 't') {
$count = 0; $count = 0;
for ($i = $oldgroupinfo[0]; $i < $groupinfo[2]; $i ++) { for ($i = $oldgroupinfo[0]; $i < $groupinfo[2]; $i++) {
thread_cache_removearticle($groupname, $i); thread_cache_removearticle($groupname, $i);
$count ++; $count++;
} }
// Save the info-file // Save the info-file
$oldinfo = file($infofilename); $oldinfo = file($infofilename);
@ -392,7 +394,12 @@ function thread_load_newsserver(&$ns, $groupname, $poll)
// parse the output of the server... // parse the output of the server...
$article = thread_overview_interpret($line, $overviewformat, $groupname); $article = thread_overview_interpret($line, $overviewformat, $groupname);
// ... and save it in our data structure // ... and save it in our data structure
$article->threadsize ++;
if (isset($article->threadsize)) {
$article->threadsize++;
} else {
$article->threadsize = 1;
}
$article->date_thread = $article->date; $article->date_thread = $article->date;
$headers[$article->id] = $article; $headers[$article->id] = $article;
// if we are in poll-mode: print status information and // if we are in poll-mode: print status information and
@ -417,8 +424,8 @@ function thread_load_newsserver(&$ns, $groupname, $poll)
if ((isset($headers)) && (count($headers) > 0)) { if ((isset($headers)) && (count($headers) > 0)) {
foreach ($headers as $c) { foreach ($headers as $c) {
if (($c->isAnswer == false) && (isset($c->references))) { // is the article an answer to an if (($c->isAnswer == false) && (isset($c->references))) { // is the article an answer to an
// other article? // other article?
// try to find a matching article to one of the references // try to find a matching article to one of the references
$refmatch = false; $refmatch = false;
foreach ($c->references as $reference) { foreach ($c->references as $reference) {
if (isset($headers[$reference])) { if (isset($headers[$reference])) {
@ -610,7 +617,7 @@ function thread_show_treegraphic($newtree)
{ {
global $imgdir; global $imgdir;
$return = ""; $return = "";
for ($o = 0; $o < strlen($newtree); $o ++) { for ($o = 0; $o < strlen($newtree); $o++) {
$return .= '<img src="' . $imgdir . '/'; $return .= '<img src="' . $imgdir . '/';
$k = substr($newtree, $o, 1); $k = substr($newtree, $o, 1);
$alt = $k; $alt = $k;
@ -721,7 +728,7 @@ function thread_format_date_color($date)
$return = ""; $return = "";
$currentTime = time(); $currentTime = time();
if ($age_count > 0) if ($age_count > 0)
for ($t = $age_count; $t >= 1; $t --) { for ($t = $age_count; $t >= 1; $t--) {
if ($currentTime - $date < $age_time[$t]) if ($currentTime - $date < $age_time[$t])
$color = $age_color[$t]; $color = $age_color[$t];
} }
@ -747,7 +754,7 @@ function thread_format_date($c)
else else
$date = $c->date; $date = $c->date;
if ($age_count > 0) if ($age_count > 0)
for ($t = $age_count; $t >= 1; $t --) for ($t = $age_count; $t >= 1; $t--)
if ($currentTime - $date < $age_time[$t]) if ($currentTime - $date < $age_time[$t])
$color = $age_color[$t]; $color = $age_color[$t];
if ($color != "") if ($color != "")
@ -807,8 +814,7 @@ function thread_format_lastmessage($c, $group = '')
$stmt->execute(); $stmt->execute();
if ($found = $stmt->fetch()) { if ($found = $stmt->fetch()) {
$ovfound = 1; $ovfound = 1;
} };
;
$dbh = null; $dbh = null;
} }
} else { } else {
@ -822,8 +828,7 @@ function thread_format_lastmessage($c, $group = '')
$stmt->execute(); $stmt->execute();
if ($found = $stmt->fetch()) { if ($found = $stmt->fetch()) {
$ovfound = 1; $ovfound = 1;
} };
;
$dbh = null; $dbh = null;
} }
$fromline = address_decode(headerDecode($found['name']), "nowhere"); $fromline = address_decode(headerDecode($found['name']), "nowhere");
@ -870,19 +875,19 @@ function thread_show_recursive(&$headers, &$liste, $depth, $tree, $group, $artic
$output = ""; $output = "";
if ($thread_treestyle == 3) if ($thread_treestyle == 3)
$output .= "\n<UL>\n"; $output .= "\n<UL>\n";
for ($i = 0; $i < count($liste); $i ++) { for ($i = 0; $i < count($liste); $i++) {
// CSS class for the actual line // CSS class for the actual line
$lineclass = "np_thread_line" . (($article_count % 2) + 1); $lineclass = "np_thread_line" . (($article_count % 2) + 1);
// read the first article // read the first article
$c = $headers[$liste[$i]]; $c = $headers[$liste[$i]];
$last_thread = $c->date_thread; $last_thread = $c->date_thread;
// Avoid listing if error (fixme) // Avoid listing if error (fixme)
// if (preg_match('/\D/', $c->number)) { // if (preg_match('/\D/', $c->number)) {
if (! is_numeric($c->number) || ! isset($c->id) || $c->date < 1) { if (! is_numeric($c->number) || ! isset($c->id) || $c->date < 1) {
continue; continue;
} }
$article_count ++; $article_count++;
// Render the graphical tree // Render the graphical tree
switch ($thread_treestyle) { switch ($thread_treestyle) {
case 4: // thread case 4: // thread
@ -1080,7 +1085,7 @@ function thread_show(&$headers, $group, $article_first = 0, $article_last = 0, $
$output = ""; $output = "";
reset($headers); reset($headers);
$c = current($headers); $c = current($headers);
for ($i = 0; $i <= count($headers) - 1; $i ++) { // create the array $liste for ($i = 0; $i <= count($headers) - 1; $i++) { // create the array $liste
if ($c->isAnswer == false) { // where are all the articles if ($c->isAnswer == false) { // where are all the articles
$liste[] = $c->id; // in that don't have $liste[] = $c->id; // in that don't have
} // references } // references
@ -1157,5 +1162,3 @@ function thread_getsubthreadids($id, $thread)
$subthread = thread_getsubthreadids_recursive($id); $subthread = thread_getsubthreadids_recursive($id);
return $subthread; return $subthread;
} }
?>

View File

@ -33,7 +33,7 @@ if (file_exists("lib/post.inc.php"))
$CONFIG = include($config_file); $CONFIG = include($config_file);
$keyfile = $spooldir.'/keys.dat'; $keyfile = $spooldir . '/keys.dat';
$keys = unserialize(file_get_contents($keyfile)); $keys = unserialize(file_get_contents($keyfile));
/* /*
@ -767,8 +767,11 @@ function groups_show($gruppen)
} }
/* Display article count */ /* Display article count */
$groupdisplay .= '</td><td class="' . $lineclass . '">'; $groupdisplay .= '</td><td class="' . $lineclass . '">';
if ($gl_age && isset($g->age)) if ($gl_age && isset($g->age)) {
$datecolor = thread_format_date_color($g->age); $datecolor = thread_format_date_color($g->age);
} else {
$datecolor = "";
}
$groupdisplay .= '<small>'; $groupdisplay .= '<small>';
if ($datecolor != "") if ($datecolor != "")
$groupdisplay .= '<font color="' . $datecolor . '">' . $g->count . '</font>'; $groupdisplay .= '<font color="' . $datecolor . '">' . $g->count . '</font>';