Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1f8249f

Browse files
committedSep 17, 2024
forum listings are now slightly happier with php 8
1 parent c91b9a1 commit 1f8249f

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed
 

‎forum.php

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
<?php
2+
23
require_once 'lib/function.php';
3-
$id = intval($_GET['id']);
4-
$user = intval($_GET['user']);
4+
5+
$id = intval($_GET['id'] ?? null);
6+
$user = intval($_GET['user'] ?? null);
7+
$thread = intval($_GET['thread'] ?? null);
8+
$fav = intval($_GET['fav'] ?? null);
9+
$act = $_GET['act'] ?? null;
510

611
if ($log)
712
$postread = $sql->getresultsbykey("SELECT forum,readdate FROM forumread WHERE user=$loguserid", 'forum', 'readdate');
@@ -101,14 +106,14 @@
101106
$hotcount = $sql->resultq('SELECT hotcount FROM misc',0,0);
102107
if ($hotcount <= 0) $hotcount = 0xFFFF;
103108

104-
$ppp = (($_GET['ppp']) ? intval($_GET['ppp']) : (($log) ? $loguser['postsperpage'] : 20));
105-
$ppp = max(min($ppp, 500), 1);
109+
$ppp = intval($_GET['ppp'] ?? ($loguser['postsperpage'] ?? 20));
110+
$ppp = max(min($ppp, 500), 1);
106111

107-
$tpp = (($_GET['tpp']) ? intval($_GET['tpp']) : (($log) ? $loguser['threadsperpage'] : 50));
108-
$tpp = max(min($tpp, 500), 1);
112+
$tpp = intval($_GET['tpp'] ?? ($loguser['threadsperpage'] ?? 50));
113+
$tpp = max(min($tpp, 500), 1);
109114

110-
$page = intval($_GET['page']);
111-
$min = $page*$tpp;
115+
$page = intval($_GET['page'] ?? 0);
116+
$min = $page * $tpp;
112117

113118
$newthreadbar = $forumlist = '';
114119
if ($id) {
@@ -134,7 +139,7 @@
134139
$forumpagelinks = '';
135140
if($threadcount > $tpp){
136141
$query = ($id ? "id=$id" : ($user ? "user=$user" : "fav=1"));
137-
if ($_GET['tpp']) $query .= "&tpp=$tpp";
142+
if ($_GET['tpp'] ?? null) $query .= "&tpp=$tpp";
138143

139144
$forumpagelinks = "<table width=100%><tr>
140145
<td align=left class='fonts'>Pages:";
@@ -241,7 +246,7 @@
241246
}
242247

243248
// Disabled polls
244-
if ($forum['pollstyle'] == -2)
249+
if (($forum['pollstyle'] ?? 0) == -2)
245250
$thread['poll'] = 0;
246251

247252
$new = "&nbsp;";

‎lib/function.php

+11-4
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ function doforumlist($id){
591591

592592
$forum1= $sql->query("SELECT id,title,catid FROM forums WHERE (minpower<=$power OR minpower<=0) AND `hidden` = '0' AND `id` != '0' OR `id` = '$id' ORDER BY forder") or print mysql_error();
593593
while($forum=$sql->fetch($forum1)) {
594+
if (!isset($fjump[$forum['catid']])) $fjump[$forum['catid']] = "";
594595
$fjump[$forum['catid']] .="<option value=forum.php?id=$forum[id]".($forum['id']==$id?' selected':'').">$forum[title]</option>";
595596
}
596597

@@ -777,9 +778,12 @@ function getuserlink(&$u, $substitutions = null, $urlclass = '') {
777778
if ($substitutions)
778779
$fn = array_merge($fn, $substitutions);
779780

780-
$akafield = htmlspecialchars($u[$fn['aka']], ENT_QUOTES);
781-
$alsoKnownAs = (($u[$fn['aka']] && $u[$fn['aka']] != $u[$fn['name']])
782-
? " title='Also known as: {$akafield}'" : '');
781+
$akafield = $alsoKnownAs = "";
782+
if ($u[$fn['aka']] ?? false) {
783+
$akafield = htmlspecialchars($u[$fn['aka']], ENT_QUOTES);
784+
$alsoKnownAs = (($u[$fn['aka']] && $u[$fn['aka']] != $u[$fn['name']])
785+
? " title='Also known as: {$akafield}'" : '');
786+
}
783787

784788
$u[$fn['name']] = htmlspecialchars($u[$fn['name']], ENT_QUOTES);
785789

@@ -934,8 +938,11 @@ function fonlineusers($id){
934938
}
935939
$p = ($numon ? ':' : '.');
936940
$s = ($numon != 1 ? 's' : '');
941+
$guests = "";
937942
$numguests = $sql->resultq("SELECT count(*) AS n FROM guests WHERE date>$onlinetime AND lastforum=$id",0,0);
938-
if($numguests) $guests="| $numguests guest".($numguests>1?'s':'');
943+
if ($numguests) {
944+
$guests = "| $numguests guest".($numguests>1?'s':'');
945+
}
939946
return "$numon user$s currently in $forumname$p $onlineusers $guests";
940947
}
941948

‎newreply.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
$userlogin
241241
<tr>
242242
$tccell1 style='width: 150px; max-width: 150px;'><strong>Reply:</strong></td>
243-
$tccell2l>$txta=message class='newposttextbox'>". htmlspecialchars($message, ENT_QUOTES) ."</TEXTAREA></td>
243+
$tccell2l>$txta=message class='newposttextbox' autofocus>". htmlspecialchars($message, ENT_QUOTES) ."</TEXTAREA></td>
244244
<tr>
245245
$tccell1>&nbsp;</td>$tccell2l>
246246
$inph=action VALUE=postreply>

0 commit comments

Comments
 (0)
Please sign in to comment.