Browse code

browse/ratings.php: fix Undefined variable warning for ratingslist in PHP 8 - sub-issue of previous Uncaught TypeError message in PHP 8

Clarissa Walker authored on 2026/09/06 16:47:45
Showing 1 changed files
... ...
@@ -34,7 +34,7 @@ if($rating) {
34 34
 }
35 35
 else {
36 36
 	$output .= "<div id='pagetitle'>"._RATINGS."</div>";
37
-	$total = is_countable($ratingslist);
37
+	$total = is_countable($ratingslist ?? null);
38 38
 	$count = 0;
39 39
 	$column = 1;
40 40
 	$list = floor($total / $displaycolumns);
Browse code

browse/ratings.php: fix Uncaught TypeError in PHP 8 with visiting the Browse Ratings section with no ratings listed

Clarissa Walker authored on 2026/09/06 14:45:02
Showing 1 changed files
... ...
@@ -34,7 +34,7 @@ if($rating) {
34 34
 }
35 35
 else {
36 36
 	$output .= "<div id='pagetitle'>"._RATINGS."</div>";
37
-	$total = count($ratingslist);
37
+	$total = is_countable($ratingslist);
38 38
 	$count = 0;
39 39
 	$column = 1;
40 40
 	$list = floor($total / $displaycolumns);
Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,58 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Valid HTML 4.01 Transitional
5
+// Based on eFiction 1.1
6
+// Copyright (C) 2003 by Rebecca Smallwood.
7
+// http://efiction.sourceforge.net/
8
+// ----------------------------------------------------------------------
9
+// LICENSE
10
+//
11
+// This program is free software; you can redistribute it and/or
12
+// modify it under the terms of the GNU General Public License (GPL)
13
+// as published by the Free Software Foundation; either version 2
14
+// of the License, or (at your option) any later version.
15
+//
16
+// This program is distributed in the hope that it will be useful,
17
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
+// GNU General Public License for more details.
20
+//
21
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
22
+// ----------------------------------------------------------------------
23
+if(!defined("_CHARSET")) exit( );
24
+
25
+
26
+$disablesorts = array("ratings");
27
+$rating = isset($_REQUEST['rating']) ? $_GET['rating'] : false;
28
+if($rating) {
29
+	$output .= "<div id='pagetitle'>"._RATING.": ".$ratingslist[$rating]['name']."</div>";
30
+	$storyquery .= " AND rid = '$rating'";
31
+	$storyquery .= _ORDERBY;
32
+	$countquery .= " AND rid = '$rating'";
33
+	$numrows = search(_STORYQUERY.$storyquery, _STORYCOUNT.$countquery, $pagelink = "browse.php?");
34
+}
35
+else {
36
+	$output .= "<div id='pagetitle'>"._RATINGS."</div>";
37
+	$total = count($ratingslist);
38
+	$count = 0;
39
+	$column = 1;
40
+	$list = floor($total / $displaycolumns);
41
+	if($total % $displaycolumns != 0) $list++;
42
+	if(!empty($ratingslist) && count($ratingslist) > 0) {
43
+		$output .= "<div id=\"columncontainer\"><div id=\"browseblock\">".($displaycolumns ? "<div class=\"column\">" : "");
44
+		foreach($ratingslist as $rating => $info) {
45
+			$count++;
46
+			$output .= "<a href='browse.php?type=ratings&amp;rating=$rating'>".$info['name']."</a><br />";
47
+			if( $count >= $list && $column != $displaycolumns) {
48
+				$output .= "</div><div class=\"column\">";
49
+				if($total % $displaycolumns == $column) $list--;
50
+				$column++;
51
+				$count = 0;
52
+			}
53
+		}
54
+		$output .= "</div>".($displaycolumns ? "</div>" : "")."<div class='cleaner'>&nbsp;</div></div>";
55
+	}
56
+}
57
+
58
+?>