View Single Post
  #1 (permalink)  
Old 01-08-2008, 09:10 PM
fhelik's Avatar
fhelik fhelik is offline
Casual Pligger
 
Join Date: Dec 2007
Location: Boston
Posts: 43
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 Thumbnails
recaptcha-submit-recaptcha.gif  
Attached Files
File Type: zip recaptcha-for-submit.zip (8.5 KB, 92 views)

Last edited by fhelik; 01-09-2008 at 06:41 PM.. Reason: new files
The Following 3 Users Say Thank You to fhelik For This Useful Post: