Not logged in. · Lost password · Register
Forum: Advanced Guestbook Modifications RSS
Add a simple human verification question (Important)
Page:  1  2  3  4  5  6  next 
Avatar
carbonize (Administrator) #1
Member since Jan 2004 · 789 posts · Location: Bristol, UK
Group memberships: Administrators, Members
Show profile · Link to this post
Subject: Add a simple human verification question
Ok after numerous requests I have decided to write this mod to let you add a test to make sure the poster is human. It's not infallible and will not stop human posters from spamming.

For Advanced Guestbook 2.3.1 and 2.3.2 (instructions for 2.2 are after)

For 2.3.3 or 2.3.4 follow the 2.3.2 instructions.

Open templates/form.php

Find
if(document.book.gb_comment.value == "") {

replace that with
if(document.book.bottest.value == "") {
   alert("$LANG[ErrorPost12]");
   document.book.bottest.focus();
   return false;
 }
 if(document.book.gb_comment.value == "") {

 next find
  <tr bgcolor="$VARS[tb_color_1]">
    <td width="25%"><div align="left" class="font2">$HTML_CODE<br>$SMILE_CODE<br>$AG_CODE</div></td>
    <td>
   
Replace that with
  <tr bgcolor="$VARS[tb_color_1]">
    <td width="25%" class="font2"><img src="$GB_PG[base_url]/img/user.gif" width="16" height="15" alt=""> Human Verification:</td>
    <td class="font2">To prove you are not a bot please type the word ARMADILLO into the box below.<br>
    <input type="text" size="42" maxlength="30" name="bottest"></td>
  </tr>
  <tr bgcolor="$VARS[tb_color_1]">
    <td width="25%"><div align="left" class="font2">$HTML_CODE<br>$SMILE_CODE<br>$AG_CODE</div></td>
    <td>
   
Remember to change the question to make it unique to your site.

Save and close the file

Now open addentry.php UNLESS you are using the guestbook as a module in PHP Nuke in which case make these changes to index.php

For 2.3.1 find
$gb_post->name = (isset($HTTP_POST_VARS["gb_name"])) ? $HTTP_POST_VARS["gb_name"] : '';

replace with
$gb_post->bottest = (isset($HTTP_POST_VARS["bottest"])) ? $HTTP_POST_VARS["bottest"] : '';
$gb_post->name = (isset($HTTP_POST_VARS["gb_name"])) ? $HTTP_POST_VARS["gb_name"] : '';

For 2.3.2 find
$gb_post->name = (isset($_POST["gb_name"])) ? $_POST["gb_name"] : '';

replace with
$gb_post->bottest = (isset($_POST["bottest"])) ? $_POST["bottest"] : '';
$gb_post->name = (isset($_POST["gb_name"])) ? $_POST["gb_name"] : '';

Save and close the file.

Now open lib/add.class.php and find
var $name = '';

replace that with
var $name = '';
  var $bottest = '';
  var $bottestanswer = 'armadillo'; /* this is the answer to the question. It must contain no '  */
 
Next find
if ($this->name == "") {

and replace that with
    if (!get_magic_quotes_gpc())
    {
     $this->bottest = addslashes($this->bottest);
     $this->bottestanswer = addslashes($this->bottestanswer);
    }
if ($this->name == "") {

Now find
} else {
            $this->url = trim($this->url);
           
Replace with
        } elseif ($this->bottest == '') {
                    return $this->db->gb_error($this->db->LANG["ErrorPost12"]);
                } elseif (strtolower($this->bottest) != strtolower($this->bottestanswer)) {
                    return $this->db->gb_error($this->db->LANG["ErrorPost13"]);
        } else {
            $this->url = trim($this->url);
           
Next find
$HIDDEN .= "<input type=\"hidden\" name=\"gb_name\" value=\"".$this->name."\">\n";

and replace it with
$HIDDEN .= "<input type=\"hidden\" name=\"gb_name\" value=\"".$this->name."\">\n";
$HIDDEN .= "<input type=\"hidden\" name=\"bottest\" value=\"".$this->bottest."\">\n";

Save and close the file.

Finally open lang/english.php (If your guestbook is not in English open the appropriate language file and change the messages into your own language.

Find
$LANG["ErrorPost11"] = "You forgot to fill in the Comment field. Please correct it and re-submit.";

and replace it with
$LANG["ErrorPost11"] = "You forgot to fill in the Comment field. Please correct it and re-submit.";
$LANG["ErrorPost12"] = "You forgot to fill in the Human Verification field. Please correct it and re-submit.";
$LANG["ErrorPost13"] = "The Human verification answer you supplied is wrong. Please correct it and re-submit.";

Save and close the file and you are done.

INSTRUCTIONS FOR 2.2

Open templates/form.php

Find
if(document.book.comment.value == "") {

replace that with
if(document.book.bottest.value == "") {
   alert("$LANG[ErrorPost12]");
   document.book.bottest.focus();
   return false;
 }
 if(document.book.comment.value == "") {

 next find
  <tr bgcolor="$VARS[tb_color_1]">
    <td width="25%"><div align="left" class="font2">$HTML_CODE<br>$SMILE_CODE<br>$AG_CODE</div></td>
    <td>
   
Replace that with
  <tr bgcolor="$VARS[tb_color_1]">
    <td width="25%" class="font2"><img src="$GB_PG[base_url]/img/user.gif" width="16" height="15" alt=""> Human Verification:</td>
    <td class="font2">To prove you are not a bot please type the word ARMADILLO into the box below.<br>
    <input type="text" size="42" maxlength="30" name="bottest"></td>
  </tr>
  <tr bgcolor="$VARS[tb_color_1]">
    <td width="25%"><div align="left" class="font2">$HTML_CODE<br>$SMILE_CODE<br>$AG_CODE</div></td>
    <td>
   
Remember to change the question to make it unique to your site.

Save and close the file

Now open addentry.php

For 2.3.1 find
$gb_post->name = (isset($HTTP_POST_VARS["name"])) ? $HTTP_POST_VARS["name"] : '';

replace with
$gb_post->bottest = (isset($HTTP_POST_VARS["bottest"])) ? $HTTP_POST_VARS["bottest"] : '';
$gb_post->name = (isset($HTTP_POST_VARS["name"])) ? $HTTP_POST_VARS["name"] : '';

Save and close the file.

Now open lib/add.class.php and find
var $name = '';

replace that with
var $name = '';
  var $bottest = '';
  var $bottestanswer = 'armadillo'; /* this is the answer to the question. It must contain no '  */
 
Next find
if ($this->name == "") {

and replace that with
    if (!get_magic_quotes_gpc())
    {
     $this->bottest = addslashes($this->bottest);
     $this->bottestanswer = addslashes($this->bottestanswer);
    }
if ($this->name == "") {

Now find
} else {
            $this->url = trim($this->url);
           
Replace with
        } elseif ($this->bottest == '') {
                    return $this->db->gb_error($this->db->LANG["ErrorPost12"]);
                } elseif (strtolower($this->bottest) != strtolower($this->bottestanswer)) {
                    return $this->db->gb_error($this->db->LANG["ErrorPost13"]);
        } else {
            $this->url = trim($this->url);
           
Next find
$HIDDEN .= "<input type=\"hidden\" name=\"name\" value=\"".$this->name."\">\n";

and replace it with
$HIDDEN .= "<input type=\"hidden\" name=\"name\" value=\"".$this->name."\">\n";
$HIDDEN .= "<input type=\"hidden\" name=\"bottest\" value=\"".$this->bottest."\">\n";

Save and close the file.

Finally open lang/english.php (If your guestbook is not in English open the appropriate language file and change the messages into your own language.

Find
$LANG["ErrorPost11"] = "You forgot to fill in the Comment field. Please correct it and re-submit.";

and replace it with
$LANG["ErrorPost11"] = "You forgot to fill in the Comment field. Please correct it and re-submit.";
$LANG["ErrorPost12"] = "You forgot to fill in the Human Verification field. Please correct it and re-submit.";
$LANG["ErrorPost13"] = "The Human verification answer you supplied is wrong. Please correct it and re-submit.";

Save and close the file and you are done.
C a r b o n i z e
This post was edited 14 times, last on 2005-09-26, 09:17 by Unknown user.
cyberdyne #2
Member since Jun 2005 · 55 posts
Group memberships: Members
Show profile · Link to this post
Will this work along-side the image verification mod or is it best to use either / or  :?:

(another insomniac i see)
 :D
=======
cd
Avatar
carbonize (Administrator) #3
Member since Jan 2004 · 789 posts · Location: Bristol, UK
Group memberships: Administrators, Members
Show profile · Link to this post
I'd say either/or. Image verification is the best method of anti spam but not everybody can use it as not all hosts have GD which is required. I did contemplate adding image verification to Lazarus as an option but have defered it until version 2.
C a r b o n i z e
cyberdyne #4
Member since Jun 2005 · 55 posts
Group memberships: Members
Show profile · Link to this post
Ok, thats cool.
Thanks for all your help  :)
=======
cd
torb (Guest) #5
No profile available.
Link to this post
Subject: ??
Carbonize,

I must be thick.  :red:  I am running Advanced 2.2 and looked for the code specified above, but my files code differs from what you have posed above. Any suggestions please?

Cheers
Ric
Avatar
carbonize (Administrator) #6
Member since Jan 2004 · 789 posts · Location: Bristol, UK
Group memberships: Administrators, Members
Show profile · Link to this post
Which part are you having the problem with?
C a r b o n i z e
(Guest) #7
No profile available.
Link to this post
All of it,  8-(  I have sent you an email.

Cheers
Ric
Avatar
carbonize (Administrator) #8
Member since Jan 2004 · 789 posts · Location: Bristol, UK
Group memberships: Administrators, Members
Show profile · Link to this post
Just fixed an error I had regarding the contents of addentry.php in 2.3.x
C a r b o n i z e
(Guest) #9
No profile available.
Link to this post
Many thanks, it works now and hopefully will stop those pesky spammers.

Cheers
Ric
redmyrlin #10
Member since Jun 2005 · 2 posts
Group memberships: Members
Show profile · Link to this post
Subject: Submit from preview
Thanks for your excellent anti-spam modifications.  I am runnuning 2.2 and have patched it with both the human verification and the $-POST+gb_actionWORD code.

I think though that there is something missing from the preview form with regards the human verification mod.  The "submit" button from preview leads to errors even though the verification word has been entered correctly - or am I missing something?
Avatar
carbonize (Administrator) #11
Member since Jan 2004 · 789 posts · Location: Bristol, UK
Group memberships: Administrators, Members
Show profile · Link to this post
Oh yeah. Duh at me :|
C a r b o n i z e
Avatar
carbonize (Administrator) #12
Member since Jan 2004 · 789 posts · Location: Bristol, UK
Group memberships: Administrators, Members
Show profile · Link to this post
It's fixed.
C a r b o n i z e
redmyrlin #13
Member since Jun 2005 · 2 posts
Group memberships: Members
Show profile · Link to this post
Quote by "carbonize":
It's fixed.
Thanks!  8)
Avatar
carbonize (Administrator) #14
Member since Jan 2004 · 789 posts · Location: Bristol, UK
Group memberships: Administrators, Members
Show profile · Link to this post
Ok just fixed a typo where I had $this->$bot and not $this->bot. I have also made the new form boxs fit in with the rest of the form better. I am now using this on my own guestbook so no it works as it should.
C a r b o n i z e
Avatar
carbonize (Administrator) #15
Member since Jan 2004 · 789 posts · Location: Bristol, UK
Group memberships: Administrators, Members
Show profile · Link to this post
Ok just added javascript to make the bottest a required field.technically it already is but this way they get a pop up if they don't fill it in.

For 2.3.x open templates/form.php and find
if(document.book.gb_comment.value == "") {
and replace with
if(document.book.bottest.value == "") {
   alert("$LANG[ErrorPost2]");
   document.book.bottest.focus();
   return false;
 }
 if(document.book.gb_comment.value == "") {

For 2.2 open templates/form.php and find
if(document.book.comment.value == "") {
and replace with
if(document.book.bottest.value == "") {
   alert("$LANG[ErrorPost2]");
   document.book.bottest.focus();
   return false;
 }
 if(document.book.comment.value == &quot;&quot;) {
C a r b o n i z e
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please note the verification code from the picture into the text field next to it.
Smilies: :lmao: ':)' :hug: :-)) :shrug: :-' :lol: x-( :-x :'( :-o :-{} :-! :-? :"> :-(( B-) ;-) #-( :-# O_o TiT :-zZ :-) ZzZ
Special characters:
Page:  1  2  3  4  5  6  next 
Go to forum
Unclassified NewsBoard 1.6.3 © 2003-6 by Yves Goergen
Page created in 330.4 ms (255.5 ms) · 102 database queries in 151.4 ms
Current time: 2010-07-07, 09:26:57 (UTC +01:00)