Bugfix patches from upstream - and general cleanup of old hacks
Bugfix patches from upstream - and general cleanup of old hacks

file:a/browse.php -> file:b/browse.php
--- a/browse.php
+++ b/browse.php
@@ -42,6 +42,7 @@
 	$scountquery = array();
 	$searchtype = (isset($_REQUEST['searchtype']) ? $_REQUEST['searchtype'] : "simple");
 	$searchterm =  (isset($_REQUEST['searchterm']) ? escapestring(descript($_REQUEST['searchterm'])) : false);
+	if($searchterm !== false) $searchterm = str_replace(array('%', '_'), array('\\%', '\\_'), escapestring($searchterm));
 	$disablesorts = array( );
 	if($searchterm) {
 		if($searchtype == "title") {
@@ -65,6 +66,9 @@
 				$countquery[] = "FIND_IN_SET(stories.uid, '".implode(",",$authorlist)."') > 0";
 				$scountquery[] = "FIND_IN_SET(series.uid, '".implode(",",$authorlist)."') > 0";
 			}
+			else {
+				$query[] = "1 = 0"; $countquery[] = "1 = 0"; $scountquery[] = "1 = 0";
+			}
 		}
 		if($searchtype == "advanced" || !$searchtype) {
 			$query[] = "(stories.summary LIKE '%$searchterm%' OR stories.title LIKE '%$searchterm%') ";
@@ -72,10 +76,12 @@
 			$scountquery[] = "(summary LIKE '%$searchterm%' OR title LIKE '%$searchterm%') ";
 		}
 	}
-	if(isset($_REQUEST['authors'])) {
-		$query[] = "FIND_IN_SET(stories.uid, '".implode(",",$searchVars['authors'])."') > 0";
-		$countquery[] = "FIND_IN_SET(stories.uid, '".implode(",",$searchVars['authors'])."') > 0";
-		$scountquery[] = "FIND_IN_SET(series.uid, '".implode(",",$searchVars['authors'])."') > 0";
+	$ef_authors = isset($_REQUEST['authors']) ? array_filter(array_map('trim', is_array($_REQUEST['authors']) ? $_REQUEST['authors'] : explode(",", (string)$_REQUEST['authors'])), "isNumber") : array( );
+	if($ef_authors) {
+		$ef_authors = implode(",", array_map('intval', $ef_authors));
+		$query[] = "FIND_IN_SET(stories.uid, '".$ef_authors."') > 0";
+		$countquery[] = "FIND_IN_SET(stories.uid, '".$ef_authors."') > 0";
+		$scountquery[] = "FIND_IN_SET(series.uid, '".$ef_authors."') > 0";
 	}
 	if(isset($_REQUEST['catid'])) {
 		$catid = is_array($_REQUEST['catid']) ? $_REQUEST['catid'] : explode(",", $_REQUEST['catid']);

--- a/browse/ratings.php
+++ b/browse/ratings.php
@@ -34,7 +34,8 @@
 }
 else {
 	$output .= "<div id='pagetitle'>"._RATINGS."</div>";
-	if ($ratingslist) $total = count(isset($ratingslist) ? $ratingslist : null);
+	if(empty($ratingslist) || !is_array($ratingslist)) $ratingslist = array( );
+	$total = count($ratingslist);
 	$count = 0;
 	$column = 1;
 	$list = floor($total / $displaycolumns);

file:a/search.php -> file:b/search.php
--- a/search.php
+++ b/search.php
@@ -162,12 +162,12 @@
 
 	if(isset($_REQUEST['rid'])) $rid = is_array($_REQUEST['rid']) ? $_REQUEST['rid'] : explode(",", $_REQUEST['rid']);
 	else $rid = array();
+	$rid = array_filter((array)$rid, function($r) { return is_string($r) && isNumber($r); });
 	if(count($rid) > 0) {
-		$rid = array_filter($rid, "isNumber");
 		$query[] = findclause('rid', $rid);
 		$countquery[] = findclause('rid', $rid);
 	}
-	if(isset($_REQUEST['complete'])) {
+	if(isset($_REQUEST['complete']) || isset($_REQUEST['completed'])) {
 		$query[] = "stories.completed = '1'";
 		$countquery[] = "stories.completed = '1'";
 	}

file:a/series.php -> file:b/series.php
--- a/series.php
+++ b/series.php
@@ -61,6 +61,18 @@
 	}
 }
 if(!$allowseries && !$admin) accessDenied( );
+$ef_sid_post = isset($_POST['seriesid']) ? $_POST['seriesid'] : null;
+if($ef_sid_post !== null && !isNumber($ef_sid_post)) accessDenied( );
+$ef_target = $seriesid ? $seriesid : ($ef_sid_post !== null ? (int)$ef_sid_post : false);
+$ef_changes = $action == "edit" || $action == "validate" || ($action == "delete" && isset($_GET['confirmed']) && $_GET['confirmed'] == "yes") || !empty($_GET['go']);
+if($ef_changes && $ef_target && !$admin) {
+	$ef_owner = dbq_value("SELECT uid FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = ? LIMIT 1", (int)$ef_target);
+	$ef_story_owner = false;
+	// a story's author may take their own story out of someone else's series
+	if($action == "delete" && !empty($inorder))
+		$ef_story_owner = (int)dbq_value("SELECT s.uid FROM ".TABLEPREFIX."fanfiction_inseries AS i JOIN ".TABLEPREFIX."fanfiction_stories AS s ON s.sid = i.sid WHERE i.seriesid = ? AND i.inorder = ? LIMIT 1", (int)$ef_target, (int)$inorder) === (int)USERUID;
+	if($ef_owner === null || ((int)$ef_owner !== (int)USERUID && !$ef_story_owner)) accessDenied( );
+}
 if($allowseries == 1 && !$admin) {
 	list($count) = dbrow(dbquery("SELECT COUNT(sid) FROM ".TABLEPREFIX."fanfiction_stories WHERE uid = '".USERUID."'"));
 	if($count == 0) accessDenied( );
@@ -218,6 +230,8 @@
 			if($item['sid']) $items[] = $item['sid'];
 			if($item['subseriesid']) $subs[] = $item['subseriesid'];
 		}
+		if(!$owner || (!$admin && USERUID != $owner && !$isopen)) accessDenied( );
+		$ef_mine = !$admin && USERUID != $owner;
 		if($admin || USERUID == $owner || $isopen == 2 ) $confirmed = 1;
 		else {
 			$confirmed = 0;
@@ -230,6 +244,7 @@
 		if(!empty($_POST["sid"])) {
 			foreach($_POST["sid"] as $story) {
 				if(!isNumber($story)) continue;
+				if($ef_mine && !dbnumrows(dbquery("SELECT s.sid FROM ".TABLEPREFIX."fanfiction_stories AS s LEFT JOIN ".TABLEPREFIX."fanfiction_coauthors AS c ON c.sid = s.sid AND c.uid = '".(int)USERUID."' WHERE s.sid = '".(int)$story."' AND (s.uid = '".(int)USERUID."' OR c.uid IS NOT NULL) LIMIT 1"))) continue;
 				if(!isset($items) || !is_array($items) || !in_array($story, $items)) {
 					$count++;
 					$validate = dbquery("SELECT validated FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = '$story' LIMIT 1");

--- a/stories.php
+++ b/stories.php
@@ -57,8 +57,18 @@
 					$coauthors[] = $c['uid'];
 				}
 			}
-			if($story['uid'] != USERUID && (is_array($coauthors) && !in_array(USERUID, $coauthors)) && !$story['rr']) accessDenied( );
-		}
+			if(!$story) accessDenied( );
+			$ef_own = $story['uid'] == USERUID || in_array(USERUID, $coauthors);
+			if(!$ef_own) {
+				// A round robin lets other members add chapters, and edit or delete the
+				// chapters they wrote. The story itself stays with its authors.
+				// (Before 3.5.74 any member could edit or delete a round robin story.)
+				if(!$story['rr']) accessDenied( );
+				$ef_rr_ok = $action == "newchapter" || (isset($chapid) && isset($author) && $author == USERUID && in_array($action, array("editchapter", "delete")));
+				if(!$ef_rr_ok) accessDenied( );
+			}
+		}
+		else if(isset($chapid)) accessDenied( );
 	}
 	else if(isADMIN && uLEVEL < 4 && isset($_GET['admin'])) {
 		$admin = 1;

--- a/user/editprefs.php
+++ b/user/editprefs.php
@@ -34,7 +34,7 @@
 		$storyindex = isset($_POST['storyindex']) && $_POST['storyindex'] == "on" ? 1 : 0;
 		$sortby = isset($_POST['sortby']) && $_POST['sortby'] == 1 ? 1 : 0;
 		$skinnew = descript(strip_tags($_POST['skinnew']));
-		if(($skinnew) != $skin || ($skinnew) == $skin) $_SESSION[$sitekey."_skin"] = $skinnew;
+		$_SESSION[$sitekey."_skin"] = $skinnew;
 		dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorprefs SET alertson = '$useralertson', newreviews = '$newreviews', newrespond = '$newrespond', ageconsent = '$ageconsent', tinyMCE ='$tinyMCE', userskin = '$skinnew', storyindex = '$storyindex', sortby = '$sortby' WHERE uid = '".USERUID."'");
 		$output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
 	}

--- a/user/favst.php
+++ b/user/favst.php
@@ -29,9 +29,9 @@
 		$uid = USERUID;
 		$output .= "<div id='pagetitle'>"._YOURSTATS."</div>";
 	}
-	$add = isset($_GET['add']) ? $_GET['add'] : false;
-	$edit = isset($_GET['edit']) ? $_GET['edit'] : false;
-	$delete = isset($_GET['delete']) ? $_GET['delete'] : false;
+	$add = isset($_GET['add']) && isNumber($_GET['add']) ? $_GET['add'] : false;
+	$edit = isset($_GET['edit']) && isNumber($_GET['edit']) ? $_GET['edit'] : false;
+	$delete = isset($_GET['delete']) && isNumber($_GET['delete']) ? $_GET['delete'] : false;
 	if($add) $output .= "<div class='sectionheader'>"._ADDTOFAVORITES."</div>";
 	else if($edit) $output .= "<div class='sectionheader'>"._EDITFAVORITES."</div>";
 	else $output .= "<div class='sectionheader'>"._FAVORITESTORIES."</div>";
@@ -49,7 +49,7 @@
 		if($result) $output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
 	}
 	if($edit && isset($_POST['submit'])) {
-		$result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_favorites SET comments = '".escapestring(descript(strip_tags(replace_naughty($_POST['comments']), $allowed_tags)))."' WHERE uid = '$uid' AND item = '$edit' AND type = 'ST'");
+		$result = dbquery("UPDATE ".TABLEPREFIX."fanfiction_favorites SET comments = '".escapestring(descript(strip_tags(replace_naughty($_POST['comments']), $allowed_tags)))."' WHERE uid = '".USERUID."' AND item = '".(int)$edit."' AND type = 'ST'");
 		if($result) $output .= write_message(_ACTIONSUCCESSFUL." "._BACK2ACCT);
 		else $output .= write_error(_ERROR);
 	}

--- a/user/revres.php
+++ b/user/revres.php
@@ -28,8 +28,25 @@
 	if(isset($_POST['submit'])) {
 		$reviewid = isset($_POST['rid']) && isNumber($_POST['rid']) ? $_POST['rid'] : false;
 		if(!$reviewid) accessDenied( );
-		$result = dbquery("SELECT review, reviewid, item, type, chapid, uid FROM ".TABLEPREFIX."fanfiction_reviews WHERE reviewid = '$reviewid' LIMIT 1");
+		$result = dbquery("SELECT review, reviewid, item, type, chapid, uid FROM ".TABLEPREFIX."fanfiction_reviews WHERE reviewid = '".(isset($_POST['rid']) && isNumber($_POST['rid']) ? $_POST['rid'] : 0)."' LIMIT 1");
 		list($review, $reviewid, $item, $type, $chapid, $uid) = dbrow($result);
+		$ef_owner = false;
+		if($reviewid && $type == "ST") {
+			$ef_o = dbassoc(dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_stories WHERE sid = '".(int)$item."' LIMIT 1"));
+			$ef_owner = ($ef_o && $ef_o['uid'] == USERUID) || dbnumrows(dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_coauthors WHERE sid = '".(int)$item."' AND uid = '".(int)USERUID."'"));
+		}
+		else if($reviewid && $type == "SE") {
+			$ef_o = dbassoc(dbquery("SELECT uid FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '".(int)$item."' LIMIT 1"));
+			$ef_owner = $ef_o && $ef_o['uid'] == USERUID;
+		}
+		else if($reviewid) $ef_owner = isADMIN;   // reviews of module items: admins only
+		if(!$ef_owner) accessDenied( );
+		if(dbnumrows(dbquery("SELECT reviewid FROM ".TABLEPREFIX."fanfiction_reviews WHERE reviewid = '".(int)$reviewid."' AND respond = '1'"))) {
+			$tpl->assign("output", write_message(_ALREADYRESPONDED));
+			$tpl->printToScreen( );
+			dbclose( );
+			exit( );
+		}
 		$updated = escapestring($review . "<br><br><i>"._AUTHORSRESPONSE.": " .replace_naughty(descript(strip_tags($_POST['response'], $allowed_tags)))."</i>");
 		$success = dbquery("UPDATE ".TABLEPREFIX."fanfiction_reviews SET review = '$updated', respond = '1' WHERE reviewid = '$reviewid'");
 		if($uid) {

--- a/viewstory.php
+++ b/viewstory.php
@@ -64,8 +64,8 @@
 
 	//  Check that the story is valid and that the visitor has permissions to read this story
 	$warning = "";
-	if(!$storyinfo) $warning = _INVALIDSTORY;
-	if(!$storyinfo['valid'] && !isADMIN && ($storyinfo['uid'] != USERUID || !in_array(USERUID, $storyinfo['coauthors']))) $warning = _ACCESSDENIED;
+	$ef_ownview = isADMIN || (USERUID && ($storyinfo['uid'] == USERUID || isset($storyinfo['coauthors'][USERUID])));
+	if(!$storyinfo['valid'] && !$ef_ownview) $warning = _ACCESSDENIED;
 	if ($storyinfo['rid']  != 0 ) {
 		$ratingquery = dbquery("SELECT ratingwarning, warningtext FROM " . TABLEPREFIX . "fanfiction_ratings WHERE rid = '" . $storyinfo['rid'] . "' LIMIT 1");
 		$rating = dbassoc($ratingquery);
@@ -160,6 +160,19 @@
 	else {
 		$chapterinfo = dbquery("SELECT *, "._PENNAMEFIELD." as penname FROM (".TABLEPREFIX."fanfiction_chapters as c, "._AUTHORTABLE.") WHERE sid = '$sid' AND inorder = '$chapter' AND c.uid = "._UIDFIELD." LIMIT 1");
 		$c = dbassoc($chapterinfo);
+		if(!$c) {
+			$current = "chaptererror";
+			// load our template files to set up the page.
+			if (file_exists("$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl");
+			else $tpl = new TemplatePower("default_tpls/default.tpl");
+			$title = "Chapter was not found";
+			$text  = "Missing chapter";
+			include("includes/pagesetup.php");
+			$tpl->assign("output", "<div id='pagetitle'>" . $title . "</div>" . write_error($text));
+			$tpl->printToScreen();
+			dbclose();
+			exit();
+		}
 		// if the *CHAPTER* hasn't been validated and the viewer isn't an admin or the author throw them a warning.  
 		if(empty($c['validated']) && !isADMIN && USERUID != $c['uid'] && !in_array(USERUID, $stories['coauthors'])) {
 			$warning = write_error(_ACCESSDENIED);
@@ -227,7 +240,7 @@
 		eval($code['code_text']);
 	}
 	include("includes/storyblock.php");
-	$printicon = "<a href=\"viewstory.php?action=printable&amp;textsize=$textsize&amp;sid=$sid&amp;chapter=all\" target=\"_blank\"><img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'></a>";
+	$printicon = "<img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'> <a href=\"viewstory.php?action=printable&amp;textsize=$textsize&amp;sid=$sid&amp;chapter=all\" target=\"_blank\">"._STORY."</a>";
 	if($reviewsallowed && (isMEMBER || $anonreviews))
 			$reviewslink = "<a href=\"reviews.php?action=add&amp;item=$sid&amp;next=2&amptype=ST\">"._SUBMITREVIEW."</a>";
 	$tpl->assign( "reviewslink", $reviewslink );
@@ -249,7 +262,7 @@
 		$tpl->assign("chapternumber", $chap['inorder']);
 		$tpl->assign("title", "<a href=\"viewstory.php?sid=$sid&amp;chapter=".$chap['inorder']."\">".$chap['title']."</a>");
 		$tpl->assign("author", "<a href='viewuser.php?uid=".$chap['uid']."'>".$chap['penname']."</a>");
-		$tpl->assign("printicon", "<a href=\"viewstory.php?action=printable&amp;textsize=$textsize&amp;sid=$sid&amp;chapter=".$chap['inorder']."\" target=\"_blank\"><img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'></a>");
+		$tpl->assign("printicon", "<img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'> <a href=\"viewstory.php?action=printable&amp;textsize=$textsize&amp;sid=$sid&amp;chapter=".$chap['inorder']."\" target=\"_blank\">"._STORY."</a>");
 		$tpl->assign("ratingpics", ratingpics($chap['rating']));
 		if($reviewsallowed) {
 			$tpl->assign("reviews", "<a href=\"reviews.php?type=ST&amp;item=$sid&amp;chapid=".$chap['chapid']."\">"._REVIEWS."</a>");
@@ -296,26 +309,7 @@
 			}
 		}
 		$jumpmenu .= "</select>";
-		if($chapter < $chapters) {
-			$nextchapter = $chapter + 1;
-			$next = "<a href=\"viewstory.php?sid=$sid&amp;textsize=$textsize&amp;chapter=".($chapter+1)."\" class=\"next\">"._NEXT."</a>";
-		}
-		else {
-			$nextchapter = "";
-			// Hook for adding content to only the end of the story.
-			$codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'storyend'");
-			while($code = dbassoc($codeblocks)) {
-				eval($code['code_text']);
-			}
-		}
-		$jumpmenu .= "</form>";
-	}
-	// if the story has only one chapter this is what happens
-	else {
-		$chapter = dbassoc($chapterinfo);
-
-		if (!$chapter)
-		{
+		if(!isset($inorder)) {
 			$current = "chaptererror";
 			// load our template files to set up the page.
 			if (file_exists("$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl");
@@ -328,7 +322,23 @@
 			dbclose();
 			exit();
 		}
-
+		if($chapter < $chapters) {
+			$nextchapter = $chapter + 1;
+			$next = "<a href=\"viewstory.php?sid=$sid&amp;textsize=$textsize&amp;chapter=".($chapter+1)."\" class=\"next\">"._NEXT."</a>";
+		}
+		else {
+			$nextchapter = "";
+			// Hook for adding content to only the end of the story.
+			$codeblocks = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'storyend'");
+			while($code = dbassoc($codeblocks)) {
+				eval($code['code_text']);
+			}
+		}
+		$jumpmenu .= "</form>";
+	}
+	// if the story has only one chapter this is what happens
+	else {
+		$chapter = dbassoc($chapterinfo);
 		$chapterauthor = $chapter['uid'];
 		$chapterpenname = $chapter['penname'];
 		$chaptertitle = $chapter['title'];
@@ -344,26 +354,24 @@
 		while($code = dbassoc($codeblocks)) {
 			eval($code['code_text']);
 		}
-		$printicon = "<a href=\"viewstory.php?action=printable&amp;sid=$sid&amp;textsize=$textsize&amp;chapter=1\" target=\"_blank\"><img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'></a>";
+		$printicon = "<img src='".(isset($printer) ? $printer : "images/print.gif")."' border='0' alt='"._PRINTER."'> <a href=\"viewstory.php?action=printable&amp;sid=$sid&amp;textsize=$textsize&amp;chapter=1\" target=\"_blank\">"._STORY."</a>";
 	}
 	// if the *CHAPTER* hasn't been validated and the viewer isn't an admin or the author throw them a warning.  
-	if(!(isset($valid)) && !isADMIN && USERUID != isset($chapterauthor) && !in_array($chapterauthor, $storyinfo['coauthors'])) {
-		$warning = accessDenied( );
-	}
+	if(!$valid && !$ef_ownview && USERUID != $chapterauthor) ef_story_error(_ACCESSDENIED, $title);
 	$stories = $storyinfo;
 	$tpl->gotoBlock("_ROOT");
 	$jumpmenu2 = ""; 
 	include("includes/storyblock.php");
 	unset($adminlinks);
 	if(isADMIN && uLEVEL < 3) 
-		$adminlinks = "<div class=\"adminoptions\"><span class='label'>"._ADMINOPTIONS.":</span> "._EDIT." - <a href=\"stories.php?action=editstory&amp;sid=$sid&amp;admin=1\">"._STORY."</a> "._OR." <a href=\"stories.php?action=editchapter&amp;chapid=".(isset($chapid) ? $chapid : null)."&amp;admin=1\">"._CHAPTER."</a> | "._DELETE." - <a href=\"stories.php?action=delete&amp;sid=$sid&amp;admin=1\">"._STORY."</a> "._OR." <a href=\"stories.php?action=delete&amp;chapid=".(isset($chapid) ? $chapid : null)."&amp;sid=$sid&amp;admin=1\">"._CHAPTER."</a></div>";
+		$adminlinks = "<div class=\"adminoptions\"><span class='label'>"._ADMINOPTIONS.":</span> "._EDIT." - <a href=\"stories.php?action=editstory&amp;sid=$sid&amp;admin=1\">"._STORY."</a> "._OR." <a href=\"stories.php?action=editchapter&amp;chapid=".$chapid."&amp;admin=1\">"._CHAPTER."</a> | "._DELETE." - <a href=\"stories.php?action=delete&amp;sid=$sid&amp;admin=1\">"._STORY."</a> "._OR." <a href=\"stories.php?action=delete&amp;chapid=".$chapid."&amp;sid=$sid&amp;admin=1\">"._CHAPTER."</a></div>";
 	if(isMEMBER && $favorites) {
 		$jumpmenu2 .= "<option value=\"user.php?action=favst&amp;add=1&amp;sid=$sid\">"._ADDSTORY2FAVES."</option><option value=\"user.php?action=favau&amp;add=1&amp;author=".$stories['uid'].(count($storyinfo['coauthors']) ? ",".implode(",", array_keys($storyinfo['coauthors'])) : "")."\">"._ADDAUTHOR2FAVES."</option>";
 	}
 	if($reviewsallowed ) {
 		if(isMEMBER || $anonreviews) {
-			$reviewslink = "<a href=\"reviews.php?action=add&amp;type=ST&amp;item=$sid&amp;chapid=".(isset($chapid) ? $chapid : null)."&amp;next=$nextchapter\">"._SUBMITREVIEW."</a>";
-			$jumpmenu2 .= "<option value=\"reviews.php?action=add&amp;type=ST&amp;item=$sid&amp;chapid=".(isset($chapid) ? $chapid : null)."&amp;next=$nextchapter\">"._SUBMITREVIEW."</option>";
+			$reviewslink = "<a href=\"reviews.php?action=add&amp;type=ST&amp;item=$sid&amp;chapid=".$chapid."&amp;next=$nextchapter\">"._SUBMITREVIEW."</a>";
+			$jumpmenu2 .= "<option value=\"reviews.php?action=add&amp;type=ST&amp;item=$sid&amp;chapid=".$chapid."&amp;next=$nextchapter\">"._SUBMITREVIEW."</option>";
 		}
 		else $reviewslink = write_message(sprintf(_LOGINTOREVIEW, strtolower($pagelinks['login']['link']), strtolower($pagelinks['register']['link'])));
 	}