Browse code

viewuser.php: Add previously nonexistent check for nonexistent or formerly existing users... oh, and UID 0 - should probably use a better message than the generic database one, though

Clarissa Walker authored on 2026/10/12 21:57:37
Showing 1 changed files
... ...
@@ -40,6 +40,19 @@ include("includes/pagesetup.php");
40 40
 // If uid isn't a number kill the script with an error message.  The only way this happens is a hacker.
41 41
 if(empty($uid)) {
42 42
 	if(!isMEMBER) accessDenied( );
43
+	$uid = '';
44
+	if ($uid < 1) {
45
+		$current = "userinfoerror";
46
+		// load our template files to set up the page.
47
+		if (file_exists("$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl");
48
+		else $tpl = new TemplatePower("default_tpls/default.tpl");		$title = "User was not found";
49
+		$text  = "User with ID " . (($uid) ?? null) . " is not in database";
50
+		include("includes/pagesetup.php");
51
+		$tpl->assign("output", "<div id='pagetitle'>" . $title . "</div>" . write_error($text));
52
+		$tpl->printToScreen();
53
+		dbclose();
54
+		exit();
55
+	}
43 56
 	else $uid = USERUID;
44 57
 }
45 58
 if($displayprofile) include("user/profile.php");
... ...
@@ -55,6 +68,19 @@ else if(isADMIN && uLEVEL < 3) {
55 68
 $infoquery = dbquery("SELECT "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
56 69
 
57 70
 list($penname) = dbrow($infoquery);
71
+if(!$penname) {
72
+	$current = "userinfoerror";
73
+	// load our template files to set up the page.
74
+	if (file_exists("$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl");
75
+	else $tpl = new TemplatePower("default_tpls/default.tpl");
76
+	$title = "User was not found";
77
+	$text  = "User with ID " . (($uid) ?? null) . " is not in database";
78
+	include("includes/pagesetup.php");
79
+	$tpl->assign("output", "<div id='pagetitle'>" . $title . "</div>" . write_error($text));
80
+	$tpl->printToScreen();
81
+	dbclose();
82
+	exit();
83
+}
58 84
 $tpl->assign("pagetitle", "<div id='pagetitle'>$penname</div>");
59 85
 $panelquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE ".($action ? "panel_name = '$action' AND (panel_type = 'P' OR panel_type = 'F')" : "panel_type = 'P' AND panel_hidden = 0 ORDER BY panel_order ASC")." LIMIT 1");
60 86
 if($panelquery) {
... ...
@@ -124,4 +150,4 @@ $tpl->gotoBlock("_ROOT");
124 150
 $tpl->assign( "output", $output );
125 151
 $tpl->printToScreen();
126 152
 dbclose( );
127
-?>
128 153
\ No newline at end of file
154
+?>