Browse code

Add option to enable or disable ratings abuse guard

Clarissa Walker authored on 2026/11/01 13:35:28
Showing 9 changed files
... ...
@@ -36,6 +36,8 @@ if($confirm == "yes") {
36 36
 		// only if you installed the 'clean' future 3.5.9 version prior
37 37
 		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'setreg'")))
38 38
 			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `setreg` tinyint(1) NOT NULL DEFAULT '1' AFTER `multiplecats`");
39
+		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'rateguard'")))
40
+			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `rateguard` tinyint(1) NOT NULL DEFAULT '0' AFTER `rateonly`");
39 41
 		if (!dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = 'convert' AND panel_title = 'Archive Conversion';"))) {
40 42
 			dbquery("UPDATE `".TABLEPREFIX."fanfiction_panels` SET panel_order = '12' WHERE panel_name = 'modules'");
41 43
 			dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_panels`(`panel_name`, `panel_title`, `panel_url`, `panel_level`, `panel_hidden`, `panel_type`, `panel_order`) VALUES( 'convert', 'Archive Conversion', '', '1', '0', 'A', '11')");
... ...
@@ -36,6 +36,8 @@ if($confirm == "yes") {
36 36
 		// only if you installed the 'clean' future 3.5.9 version prior
37 37
 		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'setreg'")))
38 38
 			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `setreg` tinyint(1) NOT NULL DEFAULT '1' AFTER `multiplecats`");
39
+		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'rateguard'")))
40
+			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `rateguard` tinyint(1) NOT NULL DEFAULT '0' AFTER `rateonly`");
39 41
 		if (!dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = 'convert' AND panel_title = 'Archive Conversion';"))) {
40 42
 			dbquery("UPDATE `".TABLEPREFIX."fanfiction_panels` SET panel_order = '12' WHERE panel_name = 'modules'");
41 43
 			dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_panels`(`panel_name`, `panel_title`, `panel_url`, `panel_level`, `panel_hidden`, `panel_type`, `panel_order`) VALUES( 'convert', 'Archive Conversion', '', '1', '0', 'A', '11')");
... ...
@@ -261,9 +261,10 @@ else if(isset($_POST['submit'])) {
261 261
 		$reviewsallowed = $_POST['newreviewsallowed'] == 1 ? 1 : 0;
262 262
 		$anonreviews = $_POST['newanonreviews'] == 1 ? 1 : 0;
263 263
 		$rateonly = $_POST['newrateonly'] == 1 ? 1 : 0;
264
+		$rateguard = $_POST['newrateguard'] == 1 ? 1 : 0;
264 265
 		$ratings = isset($_POST['newratings']) && isNumber($_POST['newratings']) ? $_POST['newratings'] : 0;
265 266
 		$revdelete = isset($_POST['newrevdelete']) && isNumber($_POST['newrevdelete']) ? $_POST['newrevdelete'] : 0;
266
-		$result = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET reviewsallowed = '$reviewsallowed', anonreviews = '$anonreviews', rateonly = '$rateonly', ratings = '$ratings', revdelete = '$revdelete' WHERE sitekey ='".SITEKEY."'");
267
+		$result = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET reviewsallowed = '$reviewsallowed', anonreviews = '$anonreviews', rateonly = '$rateonly', rateguard = '$rateguard', ratings = '$ratings', revdelete = '$revdelete' WHERE sitekey ='".SITEKEY."'");
267 268
 	}
268 269
 	else if($sect == "useropts") {
269 270
 		$alertson = $_POST['newalertson'] == 1 ? 1 : 0;
... ...
@@ -576,7 +577,13 @@ else if(isset($_POST['submit'])) {
576 577
 				<td><label for='newrateonly'>"._ALLOWRATEONLY.":</label></td><td><select name='newrateonly'>
577 578
 				<option value='1'".($rateonly == "1" ? " selected" : "").">"._YES."</option>
578 579
 				<option value='0'".($rateonly == "0" ? " selected" : "").">"._NO."</option>
579
-				</select> <a href='#' class='pophelp'>[?]<span>"._HELP_RATEONLY."</span></a></td></tr>";
580
+				</select> <a href='#' class='pophelp'>[?]<span>"._HELP_RATEONLY."</span></a></td>
581
+		</tr>
582
+		<tr>
583
+				<td><label for='newrateguard'>"._RATEGUARD.":</label></td><td><select name='newrateguard'>
584
+				<option value='1'".($rateguard == "1" ? " selected" : "").">"._YES."</option>
585
+				<option value='0'".($rateguard == "0" ? " selected" : "").">"._NO."</option>
586
+				</select> <a href='#' class='pophelp'>[?]<span>"._HELP_RATEGUARD."</span></a></td></tr>";
580 587
 	}
581 588
 	else if($sect == "useropts") {
582 589
 		$output .= "<div class='sectionheader'>"._USERSETTINGS."</div>
... ...
@@ -50,6 +50,7 @@ CREATE TABLE `fanfiction_settings` (
50 50
   `anonreviews` tinyint(1) NOT NULL default '0',
51 51
   `revdelete` tinyint(1) NOT NULL default '0',
52 52
   `rateonly` tinyint(1) NOT NULL default '0',
53
+  `rateguard` tinyint(1) NOT NULL default '0',
53 54
   `pwdsetting` tinyint(1) NOT NULL default '0',
54 55
   `alertson` tinyint(1) NOT NULL default '0',
55 56
   `disablepopups` tinyint(1) NOT NULL default '0',
... ...
@@ -23,8 +23,15 @@
23 23
 if(!defined("_CHARSET")) exit( );
24 24
 if(!isset($item)) $item = "";
25 25
 if(!isset($action)) $action == "add";
26
+if ($rateguard == 1) {
27
+$form = "<center>Warning: This archive has a review ratings guard.<br>Instead of creating a new review for a reviewer that <br>already created one prior, it updates them without confirmation.<br>So you must edit your review instead.</center>
28
+<br><form method=\"POST\" id=\"reviewform\" enctype=\"multipart/form-data\" action=\"reviews.php?action=".($action == "edit" ? "edit&amp;reviewid=".$review['reviewid'] : "add&amp;type=$type&amp;item=$item").(!empty($nextchapter) ? "&amp;next=$nextchapter" : "")."\">
29
+<div style=\"width: 350px; margin: 0 auto; text-align: left;\"><label for=\"reviewer\">"._NAME.":</label> ";
30
+}
31
+else {
26 32
 $form = "<form method=\"POST\" id=\"reviewform\" enctype=\"multipart/form-data\" action=\"reviews.php?action=".($action == "edit" ? "edit&amp;reviewid=".$review['reviewid'] : "add&amp;type=$type&amp;item=$item").(!empty($nextchapter) ? "&amp;next=$nextchapter" : "")."\">
27 33
 <div style=\"width: 350px; margin: 0 auto; text-align: left;\"><label for=\"reviewer\">"._NAME.":</label> ";
34
+}
28 35
 if($action != "edit") {
29 36
 	$review = array('reviewid' => '', 'reviewer' => '', 'review' => '', 'rating' => '-1');
30 37
 	if(isMEMBER)
... ...
@@ -959,6 +959,7 @@ switch ($_GET['step'])
959 959
   `anonreviews` tinyint(1) NOT NULL default '0',
960 960
   `revdelete` tinyint(1) NOT NULL default '0',
961 961
   `rateonly` tinyint(1) NOT NULL default '0',
962
+  `rateguard` tinyint(1) NOT NULL default '0',
962 963
   `pwdsetting` tinyint(1) NOT NULL default '0',
963 964
   `alertson` tinyint(1) NOT NULL default '0',
964 965
   `disablepopups` tinyint(1) NOT NULL default '0',
... ...
@@ -207,6 +207,7 @@ define ("_PURGELOG", "Purge the log");
207 207
 define ("_PWDSETTING", "Password at Registration");
208 208
 define ("_QUEUECOUNT", "There are %d chapters waiting to be validated."); // Added for 3.0
209 209
 define ("_RANDOM", "randomly generated");
210
+define ("_RATEGUARD", "Ratings Abuse Guard");
210 211
 define ("_RECALCREVIEWS", "Recalculate Reviews");
211 212
 define ("_RECALCSTORIES", "Recalculate Stories");
212 213
 define ("_RECENTDAYS", "Number of days to limit "._MOSTRECENT);
... ...
@@ -358,6 +359,7 @@ define ("_HELP_ANONREVIEWS", "If you have elected to turn on reviews, this deter
358 359
 define ("_HELP_REVDELETE", "If reviews are turned on, this defines which reviews (if any) authors are allowed to delete themselves.");
359 360
 define ("_HELP_RATINGS", "Defines the rating system in place in your archive.  Your choices are no ratings, like/dislike, or 5 star ratings.  You are <strong>strongly</strong> encouraged to not change this after installation or your ratings as changing from one system to the other will mess up existing ratings.");
360 361
 define ("_HELP_RATEONLY", "Defines whether or not reviewers may post a rating for the story (if ratings are on) without posting a review.");
362
+define ("_HELP_RATEGUARD", "Defines whether or not a review's ratings guard should be present on the site. If you want users to post multiple reviews in a chapter or series, disable this setting. You are recommended to disable ratings if you do not want review ratings abuse as well if you disable this setting.");
361 363
 define ("_HELP_ALERTSON", "This defines whether or not the author/story update alerts system is turned on.  If it is turned on, members will have an option in their preferences to receive e-mail alerts when their favorite authors and stories are updated.");
362 364
 define ("_HELP_AGECONSENT", "This setting determines if an age consent statement will appear in the member preference form.  If a member has confirmed their age in the preferences, it will allow them to by-pass the warning pop-ups for stories with age consent ratings.");
363 365
 define ("_HELP_POPUPS", "This setting lets you allow visitors to receive the warning pop-ups only once.  Logged in members who have confirmed the age consent statement in their profile by-pass the warnings altogether");
... ...
@@ -179,6 +179,7 @@ else if($action == "edit" || $action == "add") {
179 179
 			else if($type == "ST") {
180 180
 				if(isset($_POST['chapid']) && isNumber($_POST['chapid'])) $chapid = $_POST['chapid'];
181 181
 				if(!isset($chapid)) $chapid = 0;
182
+				if ($rateguard == 1) {
182 183
 				// Ratings-abuse guard (issue #8): a logged-in member gets one
183 184
 				// rating per story chapter. A repeat submission revises their
184 185
 				// existing review row instead of inserting a fresh one and
... ...
@@ -195,6 +196,10 @@ else if($action == "edit" || $action == "add") {
195 196
 				else {
196 197
 					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_reviews (item, type, reviewer, review, rating, date, uid, chapid) VALUES ('$item', 'ST', '$reviewer', '$review', '$rating', '" . time() . "', '".(USERUID && isNumber(USERUID) ? USERUID : 0)."', '$chapid')");
197 198
 				}
199
+				}
200
+				else if ($rateguard == 0) {
201
+					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_reviews (item, type, reviewer, review, rating, date, uid, chapid) VALUES ('$item', 'ST', '$reviewer', '$review', '$rating', '" . time() . "', '".(USERUID && isNumber(USERUID) ? USERUID : 0)."', '$chapid')");
202
+				}
198 203
 				if($ratings == 3) {
199 204
 					$count =  dbquery("SELECT COUNT(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews WHERE item = '$item' AND type = 'ST' AND rating != '-1'");
200 205
 				} else {
... ...
@@ -233,6 +238,7 @@ else if($action == "edit" || $action == "add") {
233 238
 				}
234 239
 			}
235 240
 			else if($type == "SE"){
241
+				if ($rateguard == 1) {
236 242
 				// Same ratings-abuse guard for series reviews (issue #8).
237 243
 				$alreadyrated = 0;
238 244
 				if(USERUID && isNumber(USERUID)) {
... ...
@@ -245,6 +251,10 @@ else if($action == "edit" || $action == "add") {
245 251
 				else {
246 252
 					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_reviews (item, type, reviewer, review, rating, date, uid) VALUES ('$item', 'SE', '$reviewer', '$review', '$rating', '" . time() . "', '".(USERUID && isNumber(USERUID) ? USERUID : 0)."')");
247 253
 				}
254
+				}
255
+				else if ($rateguard == 0) {
256
+					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_reviews (item, type, reviewer, review, rating, date, uid, chapid) VALUES ('$item', 'ST', '$reviewer', '$review', '$rating', '" . time() . "', '".(USERUID && isNumber(USERUID) ? USERUID : 0)."', '$chapid')");
257
+				}
248 258
 				$thisseries = $item;
249 259
 				seriesreview($item);
250 260
 				$uidquery = dbquery("SELECT uid as uid,title FROM ".TABLEPREFIX."fanfiction_series WHERE seriesid = '$item'");
... ...
@@ -288,6 +288,8 @@ elseif ($oldVersion[0] == 3 && $oldVersion[1] == 5 && $oldVersion[2] < 9)  // 3.
288 288
 	{
289 289
 		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'setreg'")))
290 290
 			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `setreg` tinyint(1) NOT NULL DEFAULT '1' AFTER `multiplecats`");
291
+		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'setreg'")))
292
+			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `rateguard` tinyint(1) NOT NULL DEFAULT '0' AFTER `rateonly`");
291 293
 		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'smtp_port'")))
292 294
 			dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `smtp_port` varchar(5) NOT NULL DEFAULT ''");
293 295
 		if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'smtp_secure'")))