Recaptcha on Gateway Mod

Various mods to change or add features.

Recaptcha on Gateway Mod

Postby Rich » 2009-09-07 10:50 am

What this does?
Secures your voting gateway from automated votes by using the Recaptcha system. You'll need to register on http://www.recaptcha.net/ and insert your API codes from there.

Example:
Image

As seen on Lineage Server Toplist.

Instructions:
Create an account and get the required keys on recaptcha.net

Download the Recaptcha PHP File and upload to your sources folder.

Open sources/in.php

Find:

Code: Select all
  function in() {
    global $CONF, $DB, $FORM


After $FORM, directly add:

Code: Select all
, $TMPL


So it looks like:

Code: Select all
  function in() {
    global $CONF, $DB, $FORM, $TMPL;


Find:

Code: Select all
          if ($CONF['gateway']) {
            $valid = $this->check($username);
          }
          else {
            $valid = 1;
          }


After, Add: (Insert private key where stated)

Code: Select all
// Recaptcha Mod
require_once($CONF['path'].'/sources/recaptchalib.php');
$privatekey = "INSERT YOUR PRIVATE KEY";
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
   unset($go_to_rankings);
   unset($valid);
  $TMPL['captcha_error'] = '<div class="error">Captcha was incorrect</div>';
          $this->gateway($username);
}
//


Find:

Code: Select all
    require_once("{$CONF['path']}/sources/misc/session.php");
    $session = new session;
    $TMPL['sid'] = $session->create('gateway', $username);

    $TMPL['username'] = $username;


After, Add: (Insert public key where stated)

Code: Select all
   // Recaptcha Mod
   require_once($CONF['path'].'/sources/recaptchalib.php');
   $publickey = "INSERT YOUR PUBLIC KEY";
   $TMPL['captcha_code'] = recaptcha_get_html($publickey);
   //


Open skins/{your skin}/gateway.html:

Find:

Code: Select all
<p class="gatemessage">{$lng->gateway_text}</p><br /><br />


Underneath should be similar to:

Code: Select all
  <div class="votebox">
   <span class="votehead"> </span>
   <br /><br />
   <a href="{$list_url}/index.php?a=in&amp;u={$username}&amp;sid={$sid}" class="cssbuttongo">{$lng->gateway_vote}</a><br /><br /><br />
   <span class="votehead"> </span>
  </div>
  <div class="voteboxno">
  <span class="votehead"> </span><br /><br />
  <a href="{$list_url}/"  class="cssbutton">{$lng->gateway_no_vote}</a><br /><br /><br />
   <span class="votehead"> </span>
  </div>
</div>


Replace with, or modify to, this:

Code: Select all
<form method="post" action="{$list_url}/index.php?a=in&amp;u={$username}&amp;sid={$sid}">
  {$captcha_error}
  {$captcha_code}
  <div class="votebox">
   <span class="votehead"> </span>
   <br /><br />
   <input type="image" value="{$lng->gateway_vote}" class="cssbuttongo" /><br /><br /><br />
   <span class="votehead"> </span>
  </div>
  <div class="voteboxno">
  <span class="votehead"> </span><br /><br />
  <a href="{$list_url}/"  class="cssbutton">{$lng->gateway_no_vote}</a><br /><br /><br />
   <span class="votehead"> </span>
  </div>
</div>
</form>


Now adjust the design/css to your spec. You will need to insert into the screen.css your styling for the error class. I use this:

Code: Select all
.error {
   padding:10px;
   margin:10px;
   background:#561B1C;
   border-top: 2px #fff solid;
   border-bottom: 2px #fff solid;
   color: #fff;
   font-weight: bold;
   text-align:center;
}


Done! Let me know if there's any problems with this.
Rich
Member
 
Posts: 20
Joined: 2005-08-24 12:14 pm

Re: Recaptcha on Gateway Mod

Postby |Jose!xD| » 2010-09-16 05:36 pm

it isnt working :/
|Jose!xD|
Newbie
 
Posts: 1
Joined: 2010-09-16 05:33 pm

Re: Recaptcha on Gateway Mod

Postby forosdelro » 2011-03-06 01:32 am

why no work ? i was trayning and always go to home page , what is the problem :? :? :?
forosdelro
Member
 
Posts: 21
Joined: 2010-11-03 11:16 pm

Re: Recaptcha on Gateway Mod

Postby luna » 2011-11-20 12:41 pm

for me doesnt work :S the part of catpcha doesnt appear but if i press enter and vote it says catpcha is wrong of

look
Image
luna
Newbie
 
Posts: 2
Joined: 2011-11-20 11:52 am

Re: Recaptcha on Gateway Mod

Postby buttlerkid » 2012-02-25 05:00 am

It worked for a while, but now when i type the two words and click the vote button, it won't vote, won't get me through the vote page. Any help, please?

Thanks!
buttlerkid
Newbie
 
Posts: 3
Joined: 2012-02-16 08:39 am


Return to Mods

Who is online

Users browsing this forum: No registered users and 0 guests

cron