recaptcha for personal messages

Started by emoryvincent, May 24, 2009, 04:20:31 AM

Previous topic - Next topic

emoryvincent

ive seen recaptcha implemented with mods for the registration page. is there a mod for changing the personal message captcha to a recaptcha image or can some one figure out the code for doing this? thanks

Kermit

#1
First of all install that mod

http://custom.simplemachines.org/mods/index.php?mod=1044

after that make these changes

./Sources/ModSettings.php

Code (find) Select

// Reporting of personal messages?
array('check', 'enableReportPM'),


Code (replace with) Select

// Reporting of personal messages?
array('check', 'enableReportPM'),
array('check', 'recaptcha_enabled'),
array('select', 'recaptcha_theme', array('Clean' => 'Clean', 'Black Glass' => 'Black Glass', 'Red' => 'Red', 'White' => 'White')),
array('text', 'recaptcha_public_key','40'),
array('text', 'recaptcha_private_key','40'),



in Sources/PersonalMessage.php

Code (find) Select

$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
}


Code (replace with) Select

$_SESSION['visual_verification_code'] .= $character_range[array_rand($character_range)];
}
$context['use_recaptcha'] = !empty($modSettings['recaptcha_enabled']) && ($modSettings['recaptcha_enabled'] == 1 && !empty($modSettings['recaptcha_public_key']) && !empty($modSettings['recaptcha_private_key'])) && $user_info['posts'] < $modSettings['pm_posts_verification'] ;
if ($context['use_recaptcha'])
{
// Disable the built-in visual verification if we are using reCAPTCHA
$context['visual_verification'] = FALSE;
}


in ./Themes/default/PersonalMessage.template.php

Code (find) Select

if ($context['visual_verification'])
{
echo '
<tr>
<td align="right" valign="top">
<b>', $txt['pm_visual_verification_label'], ':</b>
</td>
<td>';
if ($context['use_graphic_library'])
echo '
<img src="', $context['verificiation_image_href'], '" alt="', $txt['pm_visual_verification_desc'], '" /><br />';
else
echo '
<img src="', $context['verificiation_image_href'], ';letter=1" alt="', $txt['pm_visual_verification_desc'], '" />
<img src="', $context['verificiation_image_href'], ';letter=2" alt="', $txt['pm_visual_verification_desc'], '" />
<img src="', $context['verificiation_image_href'], ';letter=3" alt="', $txt['pm_visual_verification_desc'], '" />
<img src="', $context['verificiation_image_href'], ';letter=4" alt="', $txt['pm_visual_verification_desc'], '" />
<img src="', $context['verificiation_image_href'], ';letter=5" alt="', $txt['pm_visual_verification_desc'], '" /><br />';
echo '
<a href="', $context['verificiation_image_href'], ';sound" onclick="return reqWin(this.href, 400, 120);">', $txt['pm_visual_verification_listen'], '</a><br /><br />
<input type="text" name="visual_verification_code" size="30" tabindex="', $context['tabindex']++, '" />
<div class="smalltext">', $txt['pm_visual_verification_desc'], '</div>
</td>
</tr>';
}


Code (replace with) Select

if ($context['visual_verification'] || $context['use_recaptcha'])
{
echo '
<tr>
<td align="right" valign="top">
<b>', $txt['pm_visual_verification_label'], ':</b>
</td>
<td>';

if ($context['use_recaptcha'])
{
echo '
<script>
var RecaptchaOptions = {
   theme : \'', empty($modSettings['recaptcha_theme']) ? 'clean' : $modSettings['recaptcha_theme'] , '\',
};
</script>
<script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=', $modSettings['recaptcha_public_key'], '">
</script>

<noscript>
<iframe src="http://api.recaptcha.net/noscript?k=', $modSettings['recaptcha_public_key'], '"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>';
}
else
{
if ($context['use_graphic_library'])
echo '
<img src="', $context['verificiation_image_href'], '" alt="', $txt['pm_visual_verification_desc'], '" /><br />';
else
echo '
<img src="', $context['verificiation_image_href'], ';letter=1" alt="', $txt['pm_visual_verification_desc'], '" />
<img src="', $context['verificiation_image_href'], ';letter=2" alt="', $txt['pm_visual_verification_desc'], '" />
<img src="', $context['verificiation_image_href'], ';letter=3" alt="', $txt['pm_visual_verification_desc'], '" />
<img src="', $context['verificiation_image_href'], ';letter=4" alt="', $txt['pm_visual_verification_desc'], '" />
<img src="', $context['verificiation_image_href'], ';letter=5" alt="', $txt['pm_visual_verification_desc'], '" /><br />';
echo '
<a href="', $context['verificiation_image_href'], ';sound" onclick="return reqWin(this.href, 400, 120);">', $txt['pm_visual_verification_listen'], '</a><br /><br />
<input type="text" name="visual_verification_code" size="30" tabindex="', $context['tabindex']++, '" />
<div class="smalltext">', $txt['pm_visual_verification_desc'], '</div>
</td>
</tr>';
}
}



PS: It can be enabled via AdminCP -> Features and Options -> Use reCAPTCHA Verification System
My Mods
Please don't PM/mail me for support,unless i invite you
Formerly known as Duncan85
Quote
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."

A. Einstein

emoryvincent

#2
QuotePS: It can be enabled via AdminCP -> Features and Options -> Use reCAPTCHA Verification System

I dont see this option....i am currently in the process of editing the code you posted. also do my keys need to be placed in modsettings.php or another file?

emoryvincent

#3
recaptcha is showing up but when i solve the captcha and click send it takes me back to my message without any errors and replaces recaptcha with the regular smf captcha. the message isnt sent at all

Kermit

It works for me without any problem,so that means you're doing something wrong,check your files again !
My Mods
Please don't PM/mail me for support,unless i invite you
Formerly known as Duncan85
Quote
"Two things are infinite: the universe and human stupidity; and I'm not sure about the the universe."

A. Einstein

emoryvincent

here is a copy of my files. maybe i missed something and im not seeing it. also is there a file i need to edit in the template im using?

N3RVE

Quote from: emoryvincent on May 24, 2009, 04:46:04 PM
I dont see this option....i am currently in the process of editing the code you posted. also do my keys need to be placed in modsettings.php or another file?

The keys should be entered into the field provided in the "Registration" center of the Admin CP (not Feature and Options).
I ask that you direct further support queries pertaining this modification to the author(s) via the mod's support/comment thread. Marking this solved.

-[n3rve]
Ralph "[n3rve]" Otowo
Former Marketing Co-ordinator, Simple Machines.
ralph [at] simplemachines [dot] org                       
Quote"Somewhere, something incredible is waiting to be known." - Carl Sagan

miranon

Quote from: emoryvincent on May 24, 2009, 05:06:31 PM
recaptcha is showing up but when i solve the captcha and click send it takes me back to my message without any errors and replaces recaptcha with the regular smf captcha. the message isnt sent at all

I have exactly the same problem. Please help.

miranon


Advertisement: