Add option to enable or disable ratings abuse guard
--- a/admin/convert_mod.php
+++ b/admin/convert_mod.php
@@ -36,6 +36,8 @@
// only if you installed the 'clean' future 3.5.9 version prior
if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'setreg'")))
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `setreg` tinyint(1) NOT NULL DEFAULT '1' AFTER `multiplecats`");
+ if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'rateguard'")))
+ dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `rateguard` tinyint(1) NOT NULL DEFAULT '0' AFTER `rateonly`");
if (!dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = 'convert' AND panel_title = 'Archive Conversion';"))) {
dbquery("UPDATE `".TABLEPREFIX."fanfiction_panels` SET panel_order = '12' WHERE panel_name = 'modules'");
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')");
--- a/admin/convert_mod_0900.php
+++ b/admin/convert_mod_0900.php
@@ -36,6 +36,8 @@
// only if you installed the 'clean' future 3.5.9 version prior
if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'setreg'")))
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `setreg` tinyint(1) NOT NULL DEFAULT '1' AFTER `multiplecats`");
+ if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'rateguard'")))
+ dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `rateguard` tinyint(1) NOT NULL DEFAULT '0' AFTER `rateonly`");
if (!dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = 'convert' AND panel_title = 'Archive Conversion';"))) {
dbquery("UPDATE `".TABLEPREFIX."fanfiction_panels` SET panel_order = '12' WHERE panel_name = 'modules'");
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')");
--- a/admin/settings.php
+++ b/admin/settings.php
@@ -261,9 +261,10 @@
$reviewsallowed = $_POST['newreviewsallowed'] == 1 ? 1 : 0;
$anonreviews = $_POST['newanonreviews'] == 1 ? 1 : 0;
$rateonly = $_POST['newrateonly'] == 1 ? 1 : 0;
+ $rateguard = $_POST['newrateguard'] == 1 ? 1 : 0;
$ratings = isset($_POST['newratings']) && isNumber($_POST['newratings']) ? $_POST['newratings'] : 0;
$revdelete = isset($_POST['newrevdelete']) && isNumber($_POST['newrevdelete']) ? $_POST['newrevdelete'] : 0;
- $result = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET reviewsallowed = '$reviewsallowed', anonreviews = '$anonreviews', rateonly = '$rateonly', ratings = '$ratings', revdelete = '$revdelete' WHERE sitekey ='".SITEKEY."'");
+ $result = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET reviewsallowed = '$reviewsallowed', anonreviews = '$anonreviews', rateonly = '$rateonly', rateguard = '$rateguard', ratings = '$ratings', revdelete = '$revdelete' WHERE sitekey ='".SITEKEY."'");
}
else if($sect == "useropts") {
$alertson = $_POST['newalertson'] == 1 ? 1 : 0;
@@ -576,7 +577,13 @@
<td><label for='newrateonly'>"._ALLOWRATEONLY.":</label></td><td><select name='newrateonly'>
<option value='1'".($rateonly == "1" ? " selected" : "").">"._YES."</option>
<option value='0'".($rateonly == "0" ? " selected" : "").">"._NO."</option>
- </select> <a href='#' class='pophelp'>[?]<span>"._HELP_RATEONLY."</span></a></td></tr>";
+ </select> <a href='#' class='pophelp'>[?]<span>"._HELP_RATEONLY."</span></a></td>
+ </tr>
+ <tr>
+ <td><label for='newrateguard'>"._RATEGUARD.":</label></td><td><select name='newrateguard'>
+ <option value='1'".($rateguard == "1" ? " selected" : "").">"._YES."</option>
+ <option value='0'".($rateguard == "0" ? " selected" : "").">"._NO."</option>
+ </select> <a href='#' class='pophelp'>[?]<span>"._HELP_RATEGUARD."</span></a></td></tr>";
}
else if($sect == "useropts") {
$output .= "<div class='sectionheader'>"._USERSETTINGS."</div>
--- a/docs/settingstable.sql
+++ b/docs/settingstable.sql
@@ -50,6 +50,7 @@
`anonreviews` tinyint(1) NOT NULL default '0',
`revdelete` tinyint(1) NOT NULL default '0',
`rateonly` tinyint(1) NOT NULL default '0',
+ `rateguard` tinyint(1) NOT NULL default '0',
`pwdsetting` tinyint(1) NOT NULL default '0',
`alertson` tinyint(1) NOT NULL default '0',
`disablepopups` tinyint(1) NOT NULL default '0',
--- a/includes/reviewform.php
+++ b/includes/reviewform.php
@@ -23,8 +23,15 @@
if(!defined("_CHARSET")) exit( );
if(!isset($item)) $item = "";
if(!isset($action)) $action == "add";
+if ($rateguard == 1) {
+$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>
+<br><form method=\"POST\" id=\"reviewform\" enctype=\"multipart/form-data\" action=\"reviews.php?action=".($action == "edit" ? "edit&reviewid=".$review['reviewid'] : "add&type=$type&item=$item").(!empty($nextchapter) ? "&next=$nextchapter" : "")."\">
+<div style=\"width: 350px; margin: 0 auto; text-align: left;\"><label for=\"reviewer\">"._NAME.":</label> ";
+}
+else {
$form = "<form method=\"POST\" id=\"reviewform\" enctype=\"multipart/form-data\" action=\"reviews.php?action=".($action == "edit" ? "edit&reviewid=".$review['reviewid'] : "add&type=$type&item=$item").(!empty($nextchapter) ? "&next=$nextchapter" : "")."\">
<div style=\"width: 350px; margin: 0 auto; text-align: left;\"><label for=\"reviewer\">"._NAME.":</label> ";
+}
if($action != "edit") {
$review = array('reviewid' => '', 'reviewer' => '', 'review' => '', 'rating' => '-1');
if(isMEMBER)
--- a/install/install.php
+++ b/install/install.php
@@ -959,6 +959,7 @@
`anonreviews` tinyint(1) NOT NULL default '0',
`revdelete` tinyint(1) NOT NULL default '0',
`rateonly` tinyint(1) NOT NULL default '0',
+ `rateguard` tinyint(1) NOT NULL default '0',
`pwdsetting` tinyint(1) NOT NULL default '0',
`alertson` tinyint(1) NOT NULL default '0',
`disablepopups` tinyint(1) NOT NULL default '0',
--- a/languages/en_admin.php
+++ b/languages/en_admin.php
@@ -207,6 +207,7 @@
define ("_PWDSETTING", "Password at Registration");
define ("_QUEUECOUNT", "There are %d chapters waiting to be validated."); // Added for 3.0
define ("_RANDOM", "randomly generated");
+define ("_RATEGUARD", "Ratings Abuse Guard");
define ("_RECALCREVIEWS", "Recalculate Reviews");
define ("_RECALCSTORIES", "Recalculate Stories");
define ("_RECENTDAYS", "Number of days to limit "._MOSTRECENT);
@@ -358,6 +359,7 @@
define ("_HELP_REVDELETE", "If reviews are turned on, this defines which reviews (if any) authors are allowed to delete themselves.");
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.");
define ("_HELP_RATEONLY", "Defines whether or not reviewers may post a rating for the story (if ratings are on) without posting a review.");
+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.");
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.");
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.");
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");
--- a/reviews.php
+++ b/reviews.php
@@ -179,6 +179,7 @@
else if($type == "ST") {
if(isset($_POST['chapid']) && isNumber($_POST['chapid'])) $chapid = $_POST['chapid'];
if(!isset($chapid)) $chapid = 0;
+ if ($rateguard == 1) {
// Ratings-abuse guard (issue #8): a logged-in member gets one
// rating per story chapter. A repeat submission revises their
// existing review row instead of inserting a fresh one and
@@ -195,6 +196,10 @@
else {
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')");
}
+ }
+ else if ($rateguard == 0) {
+ 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')");
+ }
if($ratings == 3) {
$count = dbquery("SELECT COUNT(rating) as totalcount FROM ".TABLEPREFIX."fanfiction_reviews WHERE item = '$item' AND type = 'ST' AND rating != '-1'");
} else {
@@ -233,6 +238,7 @@
}
}
else if($type == "SE"){
+ if ($rateguard == 1) {
// Same ratings-abuse guard for series reviews (issue #8).
$alreadyrated = 0;
if(USERUID && isNumber(USERUID)) {
@@ -244,6 +250,10 @@
}
else {
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)."')");
+ }
+ }
+ else if ($rateguard == 0) {
+ 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')");
}
$thisseries = $item;
seriesreview($item);
--- a/update.php
+++ b/update.php
@@ -288,6 +288,8 @@
{
if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'setreg'")))
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `setreg` tinyint(1) NOT NULL DEFAULT '1' AFTER `multiplecats`");
+ if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'setreg'")))
+ dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `rateguard` tinyint(1) NOT NULL DEFAULT '0' AFTER `rateonly`");
if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'smtp_port'")))
dbquery("ALTER TABLE `".TABLEPREFIX."fanfiction_settings` ADD `smtp_port` varchar(5) NOT NULL DEFAULT ''");
if (!dbassoc(dbquery("SHOW COLUMNS FROM ".TABLEPREFIX."fanfiction_settings LIKE 'smtp_secure'")))