Go Back   Pligg Forum > Pligg Development > Pligg Mods
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-08-2008, 08:10 PM
fhelik's Avatar
fhelik fhelik is offline
Casual Pligger
Pligg Version: 9.82
Pligg Template: jget
 
Join Date: Dec 2007
Location: Boston
Posts: 43
Downloads: 5
Uploads: 0
Thanks: 2
Thanked 4 Times in 2 Posts
Exclamation RECAPTCHA for submit

Ok these are the steps to get the Recaptcha in the submission page, so every user has to fill the captcha in order to continue with the submission. /

You will end up with something like this: (check the attachment)

(Before start you will need a Recaptcha keys, to get them go to recaptcha register and get the key, also download the recaptchalib.php from the same site and save it in your pligg base folder)

(Before we start make sure the User Registration Captcha is "true" under the admin, configuration, Captcha)

Step 1: open submit_step_2.tpl

Look for this:


HTML Code:
 <input type="submit" value="{#PLIGG_Visual_Submit2_Continue#}" class="submit" /> <input type="hidden" name="url" id="url" value="{$submit_url}" /> <input type="hidden" name="phase" value="2" /> <input type="hidden" name="randkey" value="{$randkey}" /> <input type="hidden" name="id" value="{$submit_id}" />
Right before that insert this( remember to change YOURPUBLICKEY for yours):

Code:
         {php} 		
			require_once('recaptchalib.php');
			$publickey = "YOURPUBLICKEY"; // you got this from the signup page
			echo recaptcha_get_html($publickey);
		{/php}
Now open submit.php

look for this:

PHP Code:
check_actions('do_submit1');
    
$main_smarty->display($the_template '/pligg.tpl');
}

// submit step 2 
right after insert this (remember to change YOUR PUBLIC AND SECRET):

PHP Code:
//captcha
if(enable_captcha == 'true') {
            
        require_once(
'recaptchalib.php');        
        
// Get a key from http://recaptcha.net/api/getkey
        
$publickey "YOURPUBLICKEY";
        
$privatekey "YOURPRIVATE";
        
        
# the response from reCAPTCHA
        
$resp null;
        
# the error code from reCAPTCHA, if any
        
$error null;
        
        
# was there a reCAPTCHA response?
        
if ($_POST["recaptcha_response_field"]) {
                
$resp recaptcha_check_answer ($privatekey,
                                                
$_SERVER["REMOTE_ADDR"],
                                                
$_POST["recaptcha_challenge_field"],
                                                
$_POST["recaptcha_response_field"]);
                
                if (
$resp->is_valid) {
                        echo 
"Succesfully verified that you are human.";
                } else {
                        
# set the error code so that we can display it
                        
$error $resp->error;

                }
        }    
            
        if (!
$resp->is_valid) { // if incorrect captcha code was entered
            
$main_smarty->assign('register_error_text'"badcode");
            
$main_smarty->display($the_template '/register_error.tpl');
            return;
        }
        
// fin capthca 
a little below look for this:

PHP Code:
}

// submit step 3 
and replace it with this: ( I just added one more } )

PHP Code:
}}

// submit step 3 
Before start make backup of these 2 files, in case you make a mistake.
I made this from a code I found there in pligg, plus the resources of Recaptcha.net and recaptcha group.

I hope this helps, and work, please leave a comment after installation.

I don't know what people are doing wrong, but for those here are the files. remember to do the backup of the 3 files before replace. NOTE i am using yget template on indipop.net

check the attachment for the files.

ok I hope it works for you guys. please post here if success
Attached Images
File Type: gif recaptcha.gif (16.0 KB, 99 views - Who Downloaded?)
Attached Files
File Type: zip recaptcha-for-submit.zip (8.5 KB, 48 views - Who Downloaded?)

Last edited by fhelik : 01-09-2008 at 05:41 PM. Reason: new files
Reply With Quote
The Following 3 Users Say Thank You to fhelik For This Useful Post:
Sponsored Links
Check out the New Templates at the Pligg Pro Shop.
  #2 (permalink)  
Old 01-08-2008, 08:14 PM
gen3ric's Avatar
gen3ric gen3ric is offline
Constant Pligger
Pligg Version: 9.X
Pligg Template: Custom
 
Join Date: Jul 2007
Location: Atlanta, GA
Posts: 113
Downloads: 27
Uploads: 0
Thanks: 22
Thanked 9 Times in 6 Posts
Awesome! Going to give it a shot right now...
__________________
Design Float - Digg For Designers
Reply With Quote
  #3 (permalink)  
Old 01-08-2008, 08:23 PM
gen3ric's Avatar
gen3ric gen3ric is offline
Constant Pligger
Pligg Version: 9.X
Pligg Template: Custom
 
Join Date: Jul 2007
Location: Atlanta, GA
Posts: 113
Downloads: 27
Uploads: 0
Thanks: 22
Thanked 9 Times in 6 Posts
Hmmm, I get a blank page after the captcha is entered and I hit submit. Could there be a syntax error?
__________________
Design Float - Digg For Designers
Reply With Quote
  #4 (permalink)  
Old 01-08-2008, 08:42 PM
fhelik's Avatar
fhelik fhelik is offline
Casual Pligger
Pligg Version: 9.82
Pligg Template: jget
 
Join Date: Dec 2007
Location: Boston
Posts: 43
Downloads: 5
Uploads: 0
Thanks: 2
Thanked 4 Times in 2 Posts
Exclamation

Quote:
Originally Posted by gen3ric View Post
Hmmm, I get a blank page after the captcha is entered and I hit submit. Could there be a syntax error?
make sure you have the reCAPTCHA Library, put it in the pligg base folder. (if the gaptcha appears, maybe is not this)

check that you have /register_error.tpl in your template folder

try this:
go to admin language find this: "PLIGG_Visual_Register_Error_BadCode", make sure is some text there.
1: submit 1 story and fill the gaptcha correct. It should go to next step.
2: submit 1 story and fill the captcha wrong. it have to show the error

NOTE: I use yget template. look in indipop.net, it is working fine. both for registration and submit.
Reply With Quote
  #5 (permalink)  
Old 01-09-2008, 09:03 AM
micxuy's Avatar
micxuy micxuy is offline
Casual Pligger
 
Join Date: May 2007
Posts: 80
Downloads: 51
Uploads: 0
Thanks: 2
Thanked 0 Times in 0 Posts
I got this error Fatal error: Call to undefined function do_submit2() in localhost/submit.php on line 64
Reply With Quote
  #6 (permalink)  
Old 01-09-2008, 05:42 PM
fhelik's Avatar
fhelik fhelik is offline
Casual Pligger
Pligg Version: 9.82
Pligg Template: jget
 
Join Date: Dec 2007
Location: Boston
Posts: 43
Downloads: 5
Uploads: 0
Thanks: 2
Thanked 4 Times in 2 Posts
Exclamation

Quote:
Originally Posted by micxuy View Post
I got this error Fatal error: Call to undefined function do_submit2() in localhost/submit.php on line 64
check the post I just upload my files, make backup and replace, i hope this works.
Reply With Quote
  #7 (permalink)  
Old 01-10-2008, 12:16 AM
micxuy's Avatar
micxuy micxuy is offline
Casual Pligger
 
Join Date: May 2007
Posts: 80
Downloads: 51
Uploads: 0
Thanks: 2
Thanked 0 Times in 0 Posts
Hello; I haven tried it out but just my thought, we should put the captcha at the submit step 3. It is much better, because my user go back to change something, he has to enter the captcha again. Meanwhile at step 3, you onyl need to enter once.

Thanks
Reply With Quote
  #8 (permalink)  
Old 01-10-2008, 03:30 PM
mntbikeracer1 mntbikeracer1 is offline
Casual Pligger
Pligg Version: 9.8.2
Pligg Template: none
 
Join Date: Dec 2007
Posts: 46
Downloads: 19
Uploads: 0
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by micxuy View Post
I got this error Fatal error: Call to undefined function do_submit2() in localhost/submit.php on line 64
I'm reveiving the same, but I think placement would make more sense in submit 3.
Reply With Quote
  #9 (permalink)  
Old 01-18-2008, 01:00 AM
MarekSpace MarekSpace is offline
Pligg Donor
Pligg Version: 9.9.0
Pligg Template: yget
 
Join Date: Jan 2008
Posts: 5
Downloads: 3
Uploads: 0
Thanks: 0
Thanked 1 Time in 1 Post
have you considered reCaptcha for the registration page?

So I see why you would want reCaptcha for adding new stories but what about the first step which is when they register? Wouldn't that alleviate the problem of spam bots creating accounts?
Reply With Quote
  #10 (permalink)  
Old 01-18-2008, 02:53 AM
MarekSpace MarekSpace is offline
Pligg Donor
Pligg Version: 9.9.0
Pligg Template: yget
 
Join Date: Jan 2008
Posts: 5
Downloads: 3
Uploads: 0
Thanks: 0
Thanked 1 Time in 1 Post
Code for Register User reCaptcha use

Quote:
Originally Posted by MarekSpace View Post
So I see why you would want reCaptcha for adding new stories but what about the first step which is when they register? Wouldn't that alleviate the problem of spam bots creating accounts?
This works for me.

1) In register_center.tpl add this:

{if isset($form_captcha_error)}{ foreach value=error from=$form_captcha_error }<br /><span class="error">{$error}</span><br />{ /foreach }<br />{/if}

{php}
require_once('recaptchalib.php');
$publickey = "..."; // you got this from the signup page
echo recaptcha_get_html($publickey);
{/php}

BEFORE THIS

<input type="submit" name="submit" value="{#PLIGG_Visual_Register_Create_User#}" class="log2" tabindex="36" />

2) In register.php add this:

require_once('recaptchalib.php');
$privatekey = "...";

$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);

if (!$resp->is_valid) { // if both captchas don't match
$error = true;
}


BEFORE THIS

$vars = array('username' => $username);
check_actions('register_check_errors', $vars);

AND THIS

$main_smarty->assign('form_captcha_error', 'The reCAPTCHA code you entered was incorrect.');

AFTER THIS

$main_smarty->assign('form_password_error', $form_password_error);
Reply With Quote
The Following User Says Thank You to MarekSpace For This Useful Post:
Reply



Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
[Mod] Dodging SPAM with recaptcha ednet Pligg Mods 22 08-09-2008 01:48 PM
Request: reCAPTCHA elindbloom Suggestions 1 06-24-2007 09:02 PM


LinkBacks Enabled by vBSEO 3.0.0