Dołącz do zespołu ekspertów! Backend lub Frontend Developer?

Sprawdź najnowsze oferty pracy naszego partnera - 8lines.io!

Zaimpletowanie Google reCaptcha w rejestracji

Konfiguracja  Założony przez  Saurez.

wersja skryptu MyBB: 1.8.3
adres forum: 185.49.14.105/forum
na czym polega problem (screen, opis, komunikaty, nazwa i wersja wtyczki):
No więc aby uchronić się przed przyszłymi botami spamującymi, postanowiłem zamiast zwykłego CAPTCHA wprowadzić reCAPTCHA od Google. Więc według instrukcji zawartej na tej stronie: https://www.google.com/recaptcha/ (po dodaniu strony) dodaję do szablonu index przed znacznikiem </head> ten kod:
<script src='https://www.google.com/recaptcha/api.js'></script>
Całość szablonu index wygląda tak:
<html>
<head>
     <link rel="stylesheet" type="text/css" href="http://185.49.14.105/forum/cookies/main.css"/>
     <script type="text/javascript" src="http://185.49.14.105/forum/cookies/support-opt-in.js"></script>
     <script type="text/javascript" src="http://185.49.14.105/forum/cookies/require-opt-in.js" read_more="http://wszystkoociasteczkach.pl/"></script>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
<script type="text/javascript">
<!--
    lang.no_new_posts = "{$lang->no_new_posts}";
    lang.click_mark_read = "{$lang->click_mark_read}";
// -->
</script>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
{$header}
{$forums}{$tags}
{$boardstats}

<dl class="forum_legend smalltext">
    <dt><span class="forum_status forum_on" title="{$lang->new_posts}"></span></dt>
    <dd>{$lang->new_posts}</dd>

    <dt><span class="forum_status forum_off" title="{$lang->no_new_posts}"></span></dt>
    <dd>{$lang->no_new_posts}</dd>

    <dt><span class="forum_status forum_offlock" title="{$lang->forum_locked}"></span></dt>
    <dd>{$lang->forum_locked}</dd>

    <dt><span class="forum_status forum_offlink" title="{$lang->forum_redirect}"></span></dt>
    <dd>{$lang->forum_redirect}</dd>
</dl>
<br class="clear" />
{$footer}
</body>
</html>
Następnie wg. instrukcji 2 krokiem jest dodanie tego kodu tam, gdzie chcę, aby reCAPTCHA się pojawiło:
<div class="g-recaptcha" data-sitekey="6LevgQETAAAAAJZDj1EnwDqnbYsCx47hWpXXzwkG"></div>
Dodaję go zatem do szablonu member_register, całość wygląda tak:
<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->registration}</title>
{$headerinclude}
<script src="{$mybb->asset_url}/jscripts/validate/jquery.validate.min.js"></script>
</head>
<body>
{$header}
<form action="member.php" method="post" id="registration_form"><input type="text" style="visibility: hidden;" value="" name="regcheck1" /><input type="text" style="visibility: hidden;" value="true" name="regcheck2" />
{$regerrors}
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>{$lang->registration}</strong></td>
</tr>
<tr>
<td width="50%" class="trow1" valign="top">
<fieldset class="trow2">
<legend><strong>{$lang->account_details}</strong></legend>
<table cellspacing="0" cellpadding="{$theme['tablespace']}" width="100%">
<tr>
<td colspan="2"><span class="smalltext"><label for="username">{$lang->username}</label></span></td>
</tr>
<tr>
<td colspan="2"><input type="text" class="textbox" name="username" id="username" style="width: 100%" value="{$username}" /></td>
</tr>
{$passboxes}
<tr>
<td width="50%" valign="top"><span class="smalltext"><label for="email">{$lang->email}</label></span></td>
<td width="50%" valign="top"><span class="smalltext"><label for="email2">{$lang->confirm_email}</label></span></td>
</tr>
<tr>
<td width="50%" valign="top"><input type="text" class="textbox" name="email" id="email" style="width: 100%" maxlength="50" value="{$email}" /></td>
<td width="50%" valign="top"><input type="text" class="textbox" name="email2" id="email2" style="width: 100%" maxlength="50" value="{$email2}" /></td>
</tr>
<tr>
    <td colspan="2" style="display: none;" id="email_status">&nbsp;</td>
</tr>
{$hiddencaptcha}
</table>
</fieldset>
{$requiredfields}
{$customfields}
{$referrer}
{$regimage}
{$questionbox}
</td>
<td width="50%" class="trow1" valign="top">
<fieldset class="trow2">
<legend><strong>{$lang->account_prefs}</strong></legend>
<table cellspacing="0" cellpadding="{$theme['tablespace']}" width="100%">
<tr>
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="allownotices" id="allownotices" value="1" {$allownoticescheck} /></td>
<td valign="top"><span class="smalltext"><label for="allownotices">{$lang->allow_notices}</label></span></td>
</tr>
<tr>
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="hideemail" id="hideemail" value="1" {$hideemailcheck} /></td>
<td valign="top"><span class="smalltext"><label for="hideemail">{$lang->hide_email}</label></span></td>
</tr>
<tr>
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="receivepms" id="receivepms" value="1" {$receivepmscheck} /></td>
<td valign="top"><span class="smalltext"><label for="receivepms">{$lang->receive_pms}</label></span></td>
</tr>
<tr>
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="pmnotice" id="pmnotice" value="1"{$pmnoticecheck} /></td>
<td valign="top"><span class="smalltext"><label for="pmnotice">{$lang->pm_notice}</label></span></td>
</tr>
<tr>
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="pmnotify" id="pmnotify" value="1" {$pmnotifycheck} /></td>
<td valign="top"><span class="smalltext"><label for="pmnotify">{$lang->email_notify_newpm}</label></span></td>
</tr>
<tr>
<td valign="top" width="1"><input type="checkbox" class="checkbox" name="invisible" id="invisible" value="1" {$invisiblecheck} /></td>
<td valign="top"><span class="smalltext"><label for="invisible">{$lang->invisible_mode}</label></span></td>
</tr>
<tr>
<td colspan="2"><span class="smalltext"><label for="subscriptionmethod">{$lang->subscription_method}</label></span></td>
</tr>
<tr>
<td colspan="2">
    <select name="subscriptionmethod" id="subscriptionmethod">
        <option value="0" {$no_auto_subscribe_selected}>{$lang->no_auto_subscribe}</option>
        <option value="1" {$no_subscribe_selected}>{$lang->no_subscribe}</option>
        <option value="2" {$instant_email_subscribe_selected}>{$lang->instant_email_subscribe}</option>
        <option value="3" {$instant_pm_subscribe_selected}>{$lang->instant_pm_subscribe}</option>
    </select>
</td>
</tr>
</table>
</fieldset>
<br />
<fieldset class="trow2">
<legend><strong><label for="timezone">{$lang->time_offset}</label></strong></legend>
<table cellspacing="0" cellpadding="{$theme['tablespace']}" width="100%">
<tr>
<td><span class="smalltext">{$lang->time_offset_desc}</span></td>
</tr>
<tr>
<td>{$tzselect}</td>
</tr>
<tr>
<td><span class="smalltext">{$lang->dst_correction}</span></td>
</tr>
<tr>
<td>
    <select name="dstcorrection">
        <option value="2" {$dst_auto_selected}>{$lang->dst_correction_auto}</option>
        <option value="1" {$dst_enabled_selected}>{$lang->dst_correction_enabled}</option>
        <option value="0" {$dst_disabled_selected}>{$lang->dst_correction_disabled}</option>
    </select>
</td>
</tr>
</table>
</fieldset>
{$boardlanguage}
</td>
</tr>
</table>
<br />
<div align="center">
<input type="hidden" name="regtime" value="{$time}" />
<input type="hidden" name="step" value="registration" />
<input type="hidden" name="action" value="do_register" />
<input type="submit" class="button" name="regsubmit" value="{$lang->submit_registration}" />
</div>
    <div class="g-recaptcha" data-sitekey="6LevgQETAAAAAJZDj1EnwDqnbYsCx47hWpXXzwkG"></div>
</form>
<script type="text/javascript">
<!--
$().ready(function() {
    // validate registration_form
    $("#registration_form").validate({
        rules: {
          username: {
            required: true,
            minlength: {$mybb->settings['minnamelength']},
            maxlength: {$mybb->settings['maxnamelength']},
            remote:{
                url: "xmlhttp.php?action=username_availability",
                type: "post",
                  dataType: "json",
                data:
                {
                    my_post_key: my_post_key
                },
            },
          },
          email: {
                required: true,
                email: true,
          },
          email2: {
                required: true,
                email: true,
                equalTo: "#email"
          },
        },
        messages: {
            username: {
                      minlength: "{$lang->js_validator_username_length}",
                      maxlength: "{$lang->js_validator_username_length}",
            },
              email: "{$lang->js_validator_invalid_email}",
            email2: "{$lang->js_validator_email_match}",
        }
    });

   {$validator_extra}
});
// -->
</script>
{$footer}
</body>
</html>
Ten skrypt umieściłem przed znacznikiem </form>. Mimo to reCaptcha nie pojawia się. Jakieś sugestie?
Hej,
a próbowałeś ACP>>Ustawienia>> Ustawienia ogólne
w polach Klucz publiczny reCAPTCHA i Klucz prywatny reCAPTCHA wpisać klucze z google?
Hm, działa, tylko jest zwykłe pole tekstowe reCAPTCHA. Chciałem dokładniej mówiąc to:
[Obrazek: hero-recaptcha-demo.gif]
Odświeżam.
No to trzeba dokładniej pisać co chce się osiągnąć. To nie jest reCaptcha tylko no reCaptcha. Jeden wyraz więcej ale robi różnicę.
http://community.mybb.com/thread-163730.html
W MyBB 1.8.4 będzie to już w standardzie.



Użytkownicy przeglądający ten wątek:

1 gości