• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[GESIOR ACC] Adding reCaptcha to Accountmanagement

Roddet

Staff member
Global Moderator
Joined
May 1, 2013
Messages
943
Solutions
102
Reaction score
760
Location
Mex
reCaptcha for Gesior ACC (Accountmanagement)

This is very usefull against people trying to steal accounts using bots.

RecaptchaPreview.png


First of all, you need an API key then register a domain(s)... Also you need an Google Account.
Here: https://www.google.com/recaptcha/admin

We will need the Public and Private Key which are in your admin panel.

Then we go to layouts and in layout.php we'll add this before </head>
Code:
<script src='https://www.google.com/recaptcha/api.js'></script>

Next step is add the reCaptcha to your Accountmanagement so we go to accountmagement.php
Under <?php add this
Code:
if(isset($_REQUEST['account_login']) && isset($_REQUEST['password_login']) && !$captcha)
{
   $main_content .='<h2>Please check the reCaptcha form.</h2>';
}

Now we have to find this:
Code:
<input type="password" name="password_login" size="15" maxlength="15">

Next to the previous line add this:
Code:
<div class="g-recaptcha" data-sitekey="YOUR_PUBLIC_KEY_HERE"></div>
Note: You have to add your Public Key there ^
Note2: Also you can change the theme color to black adding this to div data-theme="dark"

Now we go to system/load.login.php and under <?php add this
Code:
if(isset($_POST['g-recaptcha-response']))
{
   $captcha=$_POST['g-recaptcha-response'];
}

Find:
Code:
if(isset($_REQUEST['account_login']) && isset($_REQUEST['password_login']))
{
    Visitor::setAccount($_REQUEST['account_login']);
    Visitor::setPassword($_REQUEST['password_login']);
    //Visitor::login(); // this set account and password from code above as login and password to next login attempt
    //Visitor::loadAccount(); // this is required to force reload account and get status of user
    $isTryingToLogin = true;
}

And replace it with:
Code:
if(isset($_REQUEST['account_login']) && isset($_REQUEST['password_login']) && $captcha)
{
        $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=YOUR_PRIVATE_KEY_HERE&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
        if($response.success==false)
        {
          echo '<h2>Dirty Robot!</h2>';
        }
        else
        {
           Visitor::setAccount($_REQUEST['account_login']);
           Visitor::setPassword($_REQUEST['password_login']);
           //Visitor::login(); // this set account and password from code above as login and password to next login attempt
           //Visitor::loadAccount(); // this is required to force reload account and get status of user
           $isTryingToLogin = true;
        }
}
Note: You have to add your Private Key there ^

That's all, now we have a fully working reCaptcha in our Accountmanagement. :)

You can see a demo here:
http://marlboro-war.servegame.com/?subtopic=accountmanagement
 
Last edited:
Why few players get this msg?:

The testera-global.com page isn’t working testera-global.com didn’t send any data. ERR_EMPTY_RESPONSE

Only few players of countries: Egypt, Colombia, Germany, Portugal... have this error.

Any idea?, Thanks!
 
Back
Top