Browse code

news.php: add previously nonexistent check for nonexistent or formerly existing news entries... and UID 0

Clarissa Walker authored on 2026/10/29 12:49:25
Showing 1 changed files
... ...
@@ -34,6 +34,20 @@ if(isset($_REQUEST['nid'])) $nid = $_REQUEST['nid'];
34 34
 if(!isset($nid) || !isNumber($nid)) $nid = false;
35 35
 $cid = isset($_REQUEST['cid']) && isNumber($_REQUEST['cid']) ? $_REQUEST['cid'] : false;
36 36
 
37
+if ($nid < 1) {
38
+	$current = "newserror";
39
+	// load our template files to set up the page.
40
+	if (file_exists("$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl");
41
+	else $tpl = new TemplatePower("default_tpls/default.tpl");
42
+	$title = "News entry was not found";
43
+	$text  = "News entry with ID " . $nid . " is not in database";
44
+	include("includes/pagesetup.php");
45
+	$tpl->assign("output", "<div id='pagetitle'>" . $title . "</div>" . write_error($text));
46
+	$tpl->printToScreen();
47
+	dbclose();
48
+	exit();
49
+}
50
+
37 51
 if($nid) {
38 52
 
39 53
 	$output .= "<div id=\"pagetitle\">"._NEWS."</div>";
... ...
@@ -58,6 +72,19 @@ if($nid) {
58 72
 	if(file_exists("./$skindir/newsbox.tpl"))
59 73
 		$news = new TemplatePower( "./$skindir/newsbox.tpl" );
60 74
 	else $news = new TemplatePower( "./default_tpls/newsbox.tpl" );
75
+	if(empty($stories)) {
76
+		$current = "newserror";
77
+		// load our template files to set up the page.
78
+		if (file_exists("$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl");
79
+		else $tpl = new TemplatePower("default_tpls/default.tpl");
80
+		$title = "News entry was not found";
81
+		$text  = "News entry with ID " . $nid . " is not in database";
82
+		include("includes/pagesetup.php");
83
+		$tpl->assign("output", "<div id='pagetitle'>" . $title . "</div>" . write_error($text));
84
+		$tpl->printToScreen();
85
+		dbclose();
86
+		exit();
87
+	}
61 88
 	$news->prepare( );	
62 89
 	//create a new number_row block
63 90
 	$news->newBlock("newsbox");