0 Members and 1 Guest are viewing this topic.

*

Pharg

  • *****
  • 2,886
    • OsDateFourm
  • osDate Version: osDateEvo 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 :)

*

nmccainjr

  • *
  • 7
  • osDate Version: osDateEvo v1.2
Re: How to remove the captcha and replace with recaptcha in signup
« Reply #3 on: October 16, 2017, 08:07:41 PM »
Hello,

How to do this in Feedback and Support Request?

Norman

*

Pharg

  • *****
  • 2,886
    • OsDateFourm
  • osDate Version: osDateEvo v1.2
Re: How to remove the captcha and replace with recaptcha in signup
« Reply #4 on: October 16, 2017, 10:27:53 PM »
Hi nmccainjr,

I just had a look at this and it's done the same way as above but you don't need to remove the first code part in the feedback.php.

Will post them both soon.

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

*

Pharg

  • *****
  • 2,886
    • OsDateFourm
  • osDate Version: osDateEvo v1.2
Re: How to remove the captcha and replace with recaptcha in signup
« Reply #5 on: October 16, 2017, 11:22:58 PM »
Hi nmccainjr,

In the feedback.tpl find this on line 13 remove this:
Code: [Select]
{if $config.spam_code_length > 0}
CheckFieldString("noblank",form.spam_code,"{lang mkey='errormsgs' skey='120'}");
{/if}

Then on line 29 add this:
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}

Then go to line 80 and find this:
Code: [Select]
{if $config.spam_code_length > 0}
<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" nowrap>{lang mkey='enter_spamcode'}:
</td>
<td valign="top" >
<table  cellpadding="0" cellspacing="0" border="0" >
<tr>
<td valign="middle">
<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="middle" nowrap>
<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>
<tr><td colspan="2" height="4"></td></tr>
{/if}

Change 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" align="left">
<tr>
  <td valign="left">
<form action="validateform.php" method="POST">
              <div id="recaptcha_html_element"></div>
                         </form>
</td>
  </tr>
</td>
</tr>
</table>

Then go to line 108 and find this:
Code: [Select]
<tr>
<td></td>
<td><input name="submit" class="formbutton" type="submit" value="{lang mkey='submit'}"/>&nbsp;
<input name="reset" type="reset" value="{lang mkey='reset'}" class="formbutton"/> </td>
</tr>
</table>

Change to this:
Code: [Select]
          <table>
<tr>
                <td colspan="2" height="6px">&nbsp;</td>
                <td><input type="submit" class="formbutton" value="{lang mkey='submit'}" id="submitbutton" disabled />&nbsp;
</td>
</tr>
</table>

Now add this above and before the {/strip} line 124
Code: [Select]
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>

All done.

Repeat this in the supreq.tpl file.
« Last Edit: October 16, 2017, 11:41:31 PM by Pharg »
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

Re: How to remove the captcha and replace with recaptcha in signup
« Reply #6 on: November 29, 2017, 06:52:17 PM »
Hi Phill,

On osDateevo1.2, on both feedback.php and supreq.php, I also had to updated the following code

Replace
Code: [Select]
if ( (strtolower($_SESSION['spam_code']) != strtolower($_POST['spam_code']) || !isset($_SESSION['spam_code']) ) && $config['spam_code_length'] > 0)  {
$t->assign('msg', get_lang('errormsgs','121') );
} else {

$From    = $config['admin_email'];
$To      = $config['feedback_email'];
$Subject = get_lang('email_feedback_subject');

$message = get_lang('feedback_email_to_admin', MAIL_FORMAT);
$message = str_replace('#txttitle#',$txttitle,$message);
$message = str_replace('#txtname#', $txtname,$message);
$message = str_replace('#txtemail#',$txtemail,$message);
$message = str_replace('#txtcountry#', $lang['countries'][$txtcountry],$message);
$message = str_replace('#txtcomments#', nl2br($txtcomments), $message);
$success = mailSender($From, $To, $To, $Subject, $message);
unset($message, $Subject);
$t->assign( 'success', $success );
}

With
Code: [Select]
$From    = $config['admin_email'];
$To      = $config['feedback_email'];
$Subject = get_lang('email_feedback_subject');

$message = get_lang('feedback_email_to_admin', MAIL_FORMAT);
$message = str_replace('#txttitle#',$txttitle,$message);
$message = str_replace('#txtname#', $txtname,$message);
$message = str_replace('#txtemail#',$txtemail,$message);
$message = str_replace('#txtcountry#', $lang['countries'][$txtcountry],$message);
$message = str_replace('#txtcomments#', nl2br($txtcomments), $message);
$success = mailSender($From, $To, $To, $Subject, $message);
unset($message, $Subject);
$t->assign( 'success', $success );

otherwise I got a security code does not match error.
PHPStorm, MAMP Pro, Sequel Pro
Currently converting my 2.1.6 site to osDateEvo 1.2

*

Pharg

  • *****
  • 2,886
    • OsDateFourm
  • osDate Version: osDateEvo v1.2
Re: How to remove the captcha and replace with recaptcha in signup
« Reply #7 on: November 29, 2017, 08:31:55 PM »
Hi arievaul,

Thanks, looks like I missed this code:

Code: [Select]
if ( (strtolower($_SESSION['spam_code']) != strtolower($_POST['spam_code']) || !isset($_SESSION['spam_code']) ) && $config['spam_code_length'] > 0)  {
$t->assign('msg', get_lang('errormsgs','121') );
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