0 Members and 1 Guest are viewing this topic.

*

Pharg

  • *****
  • 2,789
    • OsDateFourm
  • osDate Version: osDate Evo v1.2
How to remove the captcha and replace with recaptcha in signup
« on: November 01, 2016, 08:54:18 AM »
Here is how to remove the captcha and replace with the google recaptcha on signup.

In the savesignup.php on line 152 find and remove then save:
Code: [Select]
if ( $config['spam_code_length'] > 0 && (!isset($_SESSION['spam_code']) || !isset($_POST['spam_code']) || strtolower($_POST['spam_code']) != strtolower($_SESSION['spam_code'])  || $_SESSION['spam_code'] == NULL ) )  {

$err = INVALID_SPAMCODE;

}

Then in the signup.tpl on line 4 add this code:
Code: [Select]
{literal}
<script type="text/javascript">
var verifyCallback = function(response) {
document.getElementById('submitbutton').disabled=false;
document.getElementById('responsePost').value=response;
}; 
var onloadCallback = function() {
grecaptcha.render('recaptcha_html_element', {
'sitekey' : 'PUT YOU SITEKEY HERE',
'callback' : verifyCallback,
});
};
</script>{/literal}

Create and get your sitekey from https://www.google.com/recaptcha/admin

Find this line 30 and delete it:
Code: [Select]

{if $config.spam_code_length > 0}
CheckFieldString("noblank",form.spam_code,"{lang mkey='errormsgs' skey='120'}");
{/if}

Find line 649 in signup.tpl and change this:
Code: [Select]
{if $config.spam_code_length > 0}
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td height="4"></td></tr>
<tr>
<td colspan="2"><b>{lang mkey="security_code_txt"}</b></td>
</tr>
<tr><td colspan="2" height="4"></td></tr>
                  <tr>
<td valign="top" valign="middle" width="45px" nowrap>{lang mkey='enter_spamcode'}:
</td>
<td valign="top" >
<table  cellpadding="0" cellspacing="0" border="0" >
<tr>
<td valign="left">
&nbsp;&nbsp;<input type="text" class="textinput"  name="spam_code" id="spam_code" value="" style="width:120px;"/>
</td>
                              </tr>
                               <tr><td colspan="2" height="4"></td></tr>
                               <tr>
<td valign="left" nowrap>
&nbsp;&nbsp;<img src="captcha/SecurityImage.php"  alt="Security Code" id="spam_code_img" name="spam_code_img" />
&nbsp;&nbsp;
<a href="javascript:reloadCaptcha();" ><img src="captcha/images/arrow_refresh.png" alt="Refresh Code" border="0" /></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
{/if}

To this:
Code: [Select]
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td height="4"></td></tr>
<tr>
<td colspan="2"><b>{lang mkey="security_code_txt"}</b></td>
</tr>
<tr><td colspan="2" height="4"></td></tr>
                  <tr>
<td valign="top" valign="middle" width="45px" nowrap>{lang mkey='enter_spamcode'}:
</td>
<td valign="top" >
<table  cellpadding="0" cellspacing="0" border="0" align="center" >
<tr>
<td valign="left">
    <form action="validateform.php" method="POST">
                       <div id="recaptcha_html_element"></div>
                                </form>
</td>
</tr>
</table>
</td>
</tr>
</table>


Quote
{if $config.spam_code_length > 0}
{/if}
DO NOT PUT BACK THIS CODE ABOVE or you will get a error:


Then find this:
Code: [Select]
<input type="submit" class="formbutton" value="{lang mkey='submit'}" />
Change to:
Code: [Select]
<input type="submit" class="formbutton" value="{lang mkey='submit'}" id="submitbutton" disabled />
Now go to line 690 and add this after the <div style="clear:both;"></div>:
Code: [Select]
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>

Now save the changes.
This disables the submit button until the recaptcha spam check is correct.
Regards,
Pharg ( Phill )

REMEMBER: ALWAYS BACKUP BEFORE YOU MAKE ANY CHANGES!!

osDateEvo v1.2 | PHP: 5.3.42 & PHP: 5.6.18 | MySQL: 5.5.35

*

heebeha

  • ***
  • 102
  • Me
Re: How to remove the captcha and replace with recaptcha in signup
« Reply #1 on: April 26, 2017, 03:10:06 PM »
Will this work for older version so osdate? I am using version 2.7

*

heebeha

  • ***
  • 102
  • Me
Re: How to remove the captcha and replace with recaptcha in signup
« Reply #2 on: April 26, 2017, 04:29:38 PM »
This works with osdate 2.7 I just set it up :)