Browse code

viewstory.php: finally properly implement missing chapter check for single chapter stories - one for multi-chapter stories already exists

Clarissa Walker authored on 2026/11/15 08:35:37
Showing 1 changed files
... ...
@@ -338,7 +338,21 @@ else {
338 338
 	}
339 339
 	// if the story has only one chapter this is what happens
340 340
 	else {
341
+		$requested_chapter = $chapter;
341 342
 		$chapter = dbassoc($chapterinfo);
343
+		if(!$chapter || (int)$requested_chapter !== (int)$chapter['inorder']) {
344
+			$current = "chaptererror";
345
+			// load our template files to set up the page.
346
+			if (file_exists("$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl");
347
+			else $tpl = new TemplatePower("default_tpls/default.tpl");
348
+			$title = "Chapter was not found";
349
+			$text  = "Missing chapter";
350
+			include("includes/pagesetup.php");
351
+			$tpl->assign("output", "<div id='pagetitle'>" . $title . "</div>" . write_error($text));
352
+			$tpl->printToScreen();
353
+			dbclose();
354
+			exit();
355
+		}
342 356
 		$chapterauthor = $chapter['uid'];
343 357
 		$chapterpenname = $chapter['penname'];
344 358
 		$chaptertitle = $chapter['title'];