6:58 pm
Mood: na

Description: This mod is merely an attempt to discourage spammers from hitting your reviews through logging of IP addresses, adding rel="nofollow" attributes to links, and a few other, little things.

Please note that this is NOT going to stop everyone and I can't guarantee this will stop them if they're currently hitting you. I'm not even sure when the spammers got tired of trying to hit my reviews and moved on.

The general idea behind this mod is that we're trying to make it difficult enough on them that they decide to move on to easier sites.

As usual, I can't take total credit for this mod. Tammy, Carissa, and Seiji helped me a lot as these mods were taking shape.

 

 

Also, a note about IP addresses. IP addresses change, especially with dial-up users. They can also be spoofed or the spammer could have a relay set up so they post from an impossible variety of IP addresses. They simply aren't a good way to control anyone. On my site, we mainly use them for statistical purposes and passive behavior control. However, that being said, one of my worst spammers seemed to be posting from just one ISP out of China. I banned the whole ISP for about six weeks and the spam from that person stopped.

 

 

I should also explain what rel="nofollow" does. rel="nofollow" is an attribute you can add to hyperlinks that tells search engines (especially Google -- [1] [2]) not to figure the link in when their determine page ranks. Since the spammers are attempting to increase their page rank, this means they aren't benefiting by spamming your reviews. Again, it doesn't stop them... it just makes your reviews less appealing.

If you wish, you can skip adding the rel="nofollow" tags to the links pointing to your reviews. Just make sure you leave the link replace function alone so it can add the nofollow tag to any links anyone attempts to leave.

 

 

For this mod, I used files from the latest release. (2.0.7, 28 Aug 2006 patch) The line numbers are all approximate and will likely change as you progress through this mod. Please consider them simply a guide to put you into the general area.

Requirements: eFiction 2.0.7 -- Please make sure you are completely up-to-date

Difficulty: Intermediate - Advanced

Mod History:
12-November-2006 -- Released mod to public
13-November-2006 @ 12:28am -- Fixed a mistake. For line 97 of reviews.php I wrote chapter.title as title instead of series.title as title.
14-November-2006 @ 6:44pm -- Added explanation of what rel="nofollow" does
01-December-2006 -- Solved edit review bug

Demo: http://www.lunaescence.com/fics/search.php?action=tens&list=reviewedstories

Files Involved:

  • viewstory.php
  • series.php
  • reviews.php
  • func.reviewform.php
  • storyblock.php
  • seriesblock.php
  • languages/en.php

Instructions:

 

 

 

 

 

 

This mod calls for a database mod. You need to modify your fanfiction_reviews table in order to accept the new field.

General Information (for phpMyAdmin, etc.)

  • Field Name: ipaddr
  • Datatype: varchar(40)
  • Null: NOT NULL
  • After: seriesid

 

 

SQL Statement:

MySQL:
  1. ALTER TABLE `fanfiction_reviews` ADD `ipaddr` VARCHAR(40) NOT NULL AFTER `seriesid`

 

 

 

 

 

 

Open: viewstory.php

On line 1, look for this:

PHP:
  1. <?php

Below that, add:

PHP:
  1. // MOD: Review Spam ------------------------------------------------

 

 

On line 227, look for this:

PHP:
  1. if($reviewsallowed) {
  2.                     $tpl->assign("reviews", "<a href=\"reviews.php?sid=".$chap['sid']."&amp;chapid=".$chap['chapid']."\">"._REVIEWS."</a>");
  3.                     $tpl->assign("numreviews", "<a href=\"reviews.php?sid=".$chap['sid']."&amp;chapid=".$chap['chapid']."\">".$chap['reviews']."</a>");

Inside that, look for this:

PHP:
  1. <a href=\"reviews.php?sid=".$chap['sid']."&amp;chapid=".$chap['chapid']."\">"._REVIEWS."</a>

After $chap['chapid']."\", but before the closing >, add this:

PHP:
  1. rel=\"nofollow\"

Do this ON BOTH LINES.

 

 

On line 340, look for this:

PHP:
  1. if($reviewsallowed ) {
  2.         if($loggedin || $anonreviews) {
  3.             $reviewslink = "<a href=\"reviews.php?action=add&amp;sid=$sid&amp;chapid=$chapid&amp;next=$nextchapter\">"._SUBMITREVIEW."</a>";

Inside that, look for this:

PHP:
  1. $nextchapter\">

In between the ending " and the >, add:

PHP:
  1. rel=\"nofollow\"

 

 

On line 344, look for this:

PHP:
  1. $reviews = "<a href=\"reviews.php?sid=$sid&amp;chapid=$chapid\">"._REVIEWS."</a>";
  2. $numreviews = "<a href=\"reviews.php?sid=$sid&amp;chapid=$chapid\">".($storyinfo['reviews'] ? $storyinfo['reviews'] : 0)."</a>";

ON BOTH LINES, look for this:

PHP:
  1. chapid=$chapid\">

In between the ending " and the >, add:

PHP:
  1. rel=\"nofollow\"

 

 

 

 

 

 

Open: series.php

On line 1, look for this:

PHP:
  1. <?php

Below that, add:

PHP:
  1. // MOD: Review Spam ------------------------------------------------

 

 

On line 133, look for this:

PHP:
  1. if($reviewsallowed && ($loggedin || $anonreviews)) {
  2.             $titleblock->assign("reviews", "<a href=\"reviews.php?seriesid=$seriesid\">"._REVIEWS."</a>");
  3.             $titleblock->assign("numreviews", "<a href=\"reviews.php?seriesid=$seriesid\">$reviews</a>");
  4.             $titleblock->assign("submitreviews", "<a href=\"reviews.php?action=add&amp;seriesid=$seriesid\">"._SUBMITREVIEW."</a>");

Inside, ON ALL 3 LINES, look for this:

PHP:
  1. seriesid=$seriesid\">

In between the ending " and the >, add:

PHP:
  1. rel=\"nofollow\"

 

 

 

 

 

 

Open: seriesblock.php

On line 1, look for this:

PHP:
  1. <?php

Below that, add:

PHP:
  1. // MOD: Review Spam ------------------------------------------------

 

 

Line 36, look for this:

PHP:
  1. $tpl->assign("reviews", "<a href=\"reviews.php?seriesid=".$stories['subid']."\">"._REVIEWS."</a>");
  2.         $tpl->assign("numreviews", "<a href=\"reviews.php?seriesid=".$stories['subid']."\">".$stories['subreviews']."</a>");

Inside, ON BOTH LINES, look for this:

PHP:
  1. $stories['subid']."\">

Between the " and the closing >, add:

PHP:
  1. rel=\"nofollow\"

 

 

 

 

 

 

Open: storyblock.php

On line 1, look for this:

PHP:
  1. <?php

Below that, add:

PHP:
  1. // MOD: Review Spam ------------------------------------------------

 

 

Line 102, look for this:

PHP:
  1. $tpl->assign("reviews"   , ($reviewsallowed ? "<a href=\"reviews.php?sid=".$stories['sid']."\">"._REVIEWS."</a>" : "") );

Inside that, look for this:

PHP:
  1. $stories['sid']."\"

Between the " and the closing >, add:

PHP:
  1. rel=\"nofollow\"

 

 

Line 114, look for this:

PHP:
  1. $tpl->assign("numreviews"   , ($reviewsallowed == "1" ? "<a href=\"reviews.php?sid=".$stories['sid']."\">".$stories['reviews']."</a>" : "") );

Inside that, look for this:

PHP:
  1. $stories['sid']."\"

Between the " and the closing >, add:

PHP:
  1. rel=\"nofollow\"

 

 

 

 

 

 

Open: reviews.php

On line 1, look for this:

PHP:
  1. <?php

Below that, add:

PHP:
  1. // MOD: Review Spam ------------------------------------------------

 

 

Line 93, look for this:

PHP:
  1. $query = mysql_query("SELECT review.reviewid, review.review, review.member, review.reviewer, review.rating, DATE_FORMAT(date, '$datum - %h:%i%p') as date, chapter.title as title, chapter.inorder as inorder FROM ".$tableprefix."fanfiction_reviews as review, ".$tableprefix."fanfiction_chapters as chapter WHERE chapter.chapid = '$chapid' AND chapter.chapid = review.chapid AND review.review != 'No Review' ORDER BY reviewid DESC LIMIT $offset,$itemsperpage");

Inside that, look for:

PHP:
  1. chapter.title as title

BEFORE that, add this:

PHP:
  1. review.ipaddr,

 

 

Line 97, look for this:

PHP:
  1. $query = mysql_query("SELECT review.reviewid, review.review, review.member, review.reviewer, review.rating, DATE_FORMAT(review.date, '$datum - %h:%i%p') as date, series.title as title FROM ".$tableprefix."fanfiction_reviews as review, ".$tableprefix."fanfiction_series as series WHERE series.seriesid = '$seriesid' AND series.seriesid = review.seriesid AND review.review != 'No Review' ORDER BY reviewid DESC LIMIT $offset,$itemsperpage");

Inside that, look for:

PHP:
  1. series.title as title

BEFORE that, add this:

PHP:
  1. review.ipaddr,

 

 

Line 101, look for this:

PHP:
  1. $query = mysql_query("SELECT review.reviewid, review.review, review.member, review.reviewer, review.rating, DATE_FORMAT(review.date, '$datum - %h:%i%p') as date, chapter.title as title, chapter.inorder as inorder FROM ".$tableprefix."fanfiction_reviews as review LEFT JOIN ".$tableprefix."fanfiction_chapters as chapter ON chapter.chapid = review.chapid WHERE review.sid = '".$_GET['sid']."'  AND review.review != 'No Review' ORDER BY reviewid DESC LIMIT $offset,$itemsperpage");

Inside that, look for:

PHP:
  1. chapter.title as title

BEFORE that, add this:

PHP:
  1. review.ipaddr,

 

 

Line 138, look for this:

PHP:
  1. $tpl->assign("review"   , stripinput($reviews['review']));

Immediately before that, add this:

PHP:
  1. // Original review tpl
  2. /*

Immediately after, add this:

PHP:
  1. */

Hit enter a couple times, then paste this:

PHP:
  1. // No-follow mod
  2.                 // This adds the rel=nofollow to any links inside reviews
  3.         $reviewtext = $reviews['review'];
  4.         $reviewsearch = array('<a ');
  5.         $reviewreplace = array("<a rel=\"nofollow\" target=\"_blank\"");
  6.         $reviews['review'] = str_replace($reviewsearch, $reviewreplace, $reviewtext);
  7.         $tpl->assign("review"   , stripinput($reviews['review']));
  8.         // End No-follow mod

Hit enter a couple more times.

 

 

Line 152, look for this:

PHP:
  1. $tpl->assign("member", $member );

After that, hit enter a couple times, then add this:

PHP:
  1. // Ip Record Mod
  2.         if(($adminloggedin && $level <4)) {
  3.                 $ipaddress = $reviews['ipaddr'];
  4.                 $ipdisplay = "<div class=\"iplogging\">"._IPADDR."&nbsp; $ipaddress";
  5.                 if((!$ipaddress)) {
  6.                     $ipdisplay = "<div class=\"iplogging\">"._IPADDR."&nbsp; "._IPUNKNOWN."</div>";
  7.         }
  8.             }
  9.         else {
  10.             $ipdisplay = "<div class=\"iplogging\">"._IPADDR."&nbsp; "._IPLOGGED."</div>";
  11.         }
  12.         $tpl->assign("ipaddress", $ipdisplay );
  13.         // End Ip Record Mod

 

 

Line 237, look for this:

PHP:
  1. $chapid = $_REQUEST["chapid"];

After that, add this:

PHP:
  1. $ipaddr = $_SERVER ['REMOTE_ADDR'];

 

 

Line 250, look for this:

PHP:
  1. else if(find_naughty($reviewer)) $output .= "<center>"._NAUGHTYWORDS."</center>";

After that, add this:

PHP:
  1. // Control Reviewer Names
  2. else if(!$loggedin && !preg_match("/^[-@.A-Za-z0-9_\- ]+$/", $reviewer)) $output .= "<center>"._INVALIDCHARACTERS."</center>";

 

 

Line 265, look for this:

PHP:
  1. mysql_query("INSERT INTO ".$tableprefix."fanfiction_reviews (sid, reviewer, review, rating, date, member, chapid) VALUES ('$sid', '$reviewer', '$review', '".$_POST['rating']."', now(), '".(isset($_POST['member']) ? $_POST['member'] : 0)."', '$chapid')") or die(_FATALERROR."Query: INSERT INTO ".$tableprefix."fanfiction_reviews (sid, reviewer, review, rating, date, member, chapid) VALUES ('$sid', '$reviewer', '$review', '".$_POST['rating']."', now(), '".$_POST['member']."', '$chapid') <br />Error: (".mysql_errno( ).") ".mysql_error( ));

Inside that, look for this:

PHP:
  1. fanfiction_reviews (sid, reviewer, review, rating, date, member, chapid)

Between chapid and ), add this:

PHP:
  1. , ipaddr

Same line, further down, look for this:

PHP:
  1. (isset($_POST['member']) ? $_POST['member'] : 0)."', '$chapid')

In between '$chapid' and ), add this:

PHP:
  1. , '$ipaddr'

Same line, further down, look for this:

PHP:
  1. INSERT INTO ".$tableprefix."fanfiction_reviews (sid, reviewer, review, rating, date, member, chapid)

In between the chapid and ), add this:

PHP:
  1. , ipaddr

Same line, further down, look for this:

PHP:
  1. '".$_POST['rating']."', now(), '".$_POST['member']."', '$chapid'

In between the '$chapid' and ), add this:

PHP:
  1. , '$ipaddr'

 

 

Now, that was so much fun, lets down it again! :-P

 

 

Line 284, look for this:

PHP:
  1. mysql_query("INSERT INTO ".$tableprefix."fanfiction_reviews (seriesid, reviewer, review, rating, date, member) VALUES ('$seriesid', '$reviewer', '$review', '".$_POST['rating']."', now(), '".$_POST['member']."')") or die(_FATALERROR."Query: INSERT INTO ".$tableprefix."fanfiction_reviews (seriesid, reviewer, review, rating, date, member, chapid) VALUES ('$seriesid', '$reviewer', '$review', '".$_POST['rating']."', now(), '".$_POST['member']."') <br />Error: (".mysql_errno( ).") ".mysql_error( ));

Inside that, look for

PHP:
  1. fanfiction_reviews (seriesid, reviewer, review, rating, date, member)

Between member and ), add this:

PHP:
  1. , ipaddr

Same line, further down, look for this:

PHP:
  1. now(), '".$_POST['member']."')

Between the quotes and the ), add this:

PHP:
  1. , '$ipaddr'

Same line, further down, look for this:

PHP:
  1. INSERT INTO ".$tableprefix."fanfiction_reviews (seriesid, reviewer, review, rating, date, member, chapid)

Between the chapid and the ), add this:

PHP:
  1. , ipaddr

Same line, further down, look for this:

PHP:
  1. now(), '".$_POST['member']."')

In between the quotes and the ), add this:

PHP:
  1. , '$ipaddr'

 

 

 

 

 

 

Open: func.reviewform.php

Relax, this part isn't as nitpicky as the last one.

On line 1, look for this:

PHP:
  1. <?php

Below that, add:

PHP:
  1. // MOD: Review Spam ------------------------------------------------

 

 

Scroll alll the way down to line 50, look for this:

PHP:
  1. if($ratings) $form .= "<div>"._REVIEWNOTE."</div>";

Below that, add this:

PHP:
  1. // Control Reviewer Names
  2. if($loggedin) $form .= "<div>"._REVIEWNOTE2."</div>";
  3. if(!$loggedin) $form .= "<div>"._REVIEWNOTE3."</div>";

 

 

 

 

 

 

Open: languages/en.php (or your language)

Okay, scroll all the way to the bottom and add this:

PHP:
  1. // Review Spam Mod
  2. define ("_IPADDR", "IP Address");
  3. define ("_IPUNKNOWN", "Unknown");
  4. define ("_IPLOGGED", "Logged");
  5. define ("_INVALIDCHARACTERS", "<span class=\"error\">Sorry, reviewer names may only contain upper and lower case letters (A-Z), numbers (0-9), spaces, hyphens ( - ), periods ( . ), at signs ( @ ), and underscores ( _ ).</span>");
  6. define ("_REVIEWNOTE2", "<small><span class=\"label\">Note:</span> Please be respectful when leaving a review and do not spam.</small>");
  7. define ("_REVIEWNOTE3", "<small><span class=\"label\">Note:</span> Reviewer names may contain upper and lower case letters (A-Z), numbers (0-9), spaces, hyphens ( - ), underscores ( _ ), periods ( . ), and the at symbol ( &#64; ).<br /><br />Also, any links posted with this form will be altered to deter spam and IP addresses are logged.</small>");

For a while I used REVIEWNOTE2 to warn my registered users about the IP logging and link alterations. I set it more or less to my current note, though you can do what you wish.

 

 

Save, upload, and enjoy!

You can leave a response, or trackback from your own site.

Leave a Reply