You are here:  » Captcha


Captcha

Submitted by HJW on Tue, 2009-12-08 00:28 in

Hello David,

Is it possible to add a captcha to the review form, enabling auto publish and reducing spam?
If so what type should I use php? JavaScript? And where do I put the code?

Many thanks

Hayden

Submitted by support on Tue, 2009-12-08 07:05

Hello Hayden,

There is actually already a JavaScript "captcha" included in the review form; so if you're confident that this is working (you would be able to tell if you are getting spam reviews in the moderation area of course). If it all looks OK, to auto-approve reviews, in reviews.php look for the following code beginning at line 14:

      $sql = "INSERT INTO `".$config_databaseTablePrefix."reviews` SET created='".time()."',approved='0',product_name='".database_safe($q)."',rating='".database_safe($_POST["rating"])."',comments='".database_safe(stripslashes(trim($_POST["comments"])))."'";
      database_queryModify($sql,$insertId);

...and REPLACE with:

      $sql = "INSERT INTO `".$config_databaseTablePrefix."reviews` SET created='".time()."',approved='1',product_name='".database_safe($q)."',rating='".database_safe($_POST["rating"])."',comments='".database_safe(stripslashes(trim($_POST["comments"])))."'";
      database_queryModify($sql,$insertId);
      require("includes/admin.php");
      admin_importReviews();

If you want to be able to subsequently remove reviews; there is a simply "Manage Reviews" script in the following thread:

http://www.pricetapestry.com/node/647

Hope this helps!

Cheers,
David.

Submitted by HJW on Tue, 2009-12-08 11:50

Hi David,

Excellent, I've impemented both of these and they work a treat! You are a star.
Oh one more thing... I've searched the forum, is there a script for a 'bad word' filter?

Again, thank you.

Hayden

Submitted by support on Tue, 2009-12-08 13:23

Hi Hayden,

There isn't as yet, but it's straight forward to implement. Insert the following
code immediately before the replacement described above to scan for any of the
words in the $block array (enter the words all in lower case only) and clear
the comments completely, leaving only the rating if any are matched.

  $block = array("word1","word2","word3","etc...");
  foreach($block as $word)
  {
    $comments = strtolower($_POST["comments"]);
    if (strpos($comments,$word) !== FALSE)
    {
      $_POST["comments"] = "";
      break;
    }
  }

Hope this helps!
Cheers,
David.

Submitted by HJW on Tue, 2009-12-08 15:15

Excellent, once again top marks for your first class service!

Thanks

Hayden