Morus
www.votezone.eu , www.privateserversranking.com
Hi Guys,
 
I'm using at the moment Recaptcha for gatewat page
http://www.l2.votezone.eu/index.php?a=in&u=Lineage2Network
but I want to change it to AdsCaptcha but i have some difficulities. Any advise?
Below you can see code for /sources/in.php with recaptcha on it
	
	
	
		
And my gateway.html
	
	
	
		
For adscaptcha example php code you can find below
http://www.adscaptcha.com/Resources.aspx
								I'm using at the moment Recaptcha for gatewat page
http://www.l2.votezone.eu/index.php?a=in&u=Lineage2Network
but I want to change it to AdsCaptcha but i have some difficulities. Any advise?
Below you can see code for /sources/in.php with recaptcha on it
		Code:
	
	if (!defined('VISIOLIST')) {
  die("This file cannot be accessed directly.");
}
 
class in extends in_out {
  function in() {
    global $CONF, $DB, $FORM, $TMPL;
 
    if (isset($_SERVER['HTTP_REFERER'])) {
      $referer = $DB->escape($_SERVER['HTTP_REFERER'], 1);
    }
 
    $go_to_rankings = 0;
    if (isset($FORM['a']) && $FORM['a'] == 'in') {
      $go_to_rankings = 1;
      $username = $DB->escape($FORM['u']);
    }
    else {
      // Get user by referer?
      $good_referer = 0;
      if (isset($referer) && !isset($FORM['a']) && strpos($referer, $CONF['list_url']) === FALSE) {
        // Make sure it's not a search engine
        if (strpos($referer, 'http://www.google.com/search') === FALSE && strpos($referer, 'http://search.yahoo.com') === FALSE && strpos($referer, 'http://search.msn.com') === FALSE) {
          $good_referer = 1;
        }
      }
 
      if ($good_referer) {
        $username = $this->get_username($referer);
      }
      else {
        $username = '';
      }
    }
 
    if ($username) {
      list($username_sql) = $DB->fetch("SELECT username FROM {$CONF['sql_prefix']}_sites WHERE username = '{$username}'", __FILE__, __LINE__);
      if ($username_sql == $username) {
        if ($CONF['gateway'] && !isset($FORM['sid'])) {
          $this->gateway($username);
        }
        else {
          if ($CONF['gateway']) {
            $valid = $this->check($username);
          }
          else {
            $valid = 1;
          }
// Recaptcha Mod
require_once($CONF['path'].'/sources/recaptchalib.php');
$privatekey = "MY 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);
}
//
          if ($valid) {
            $this->record($username, 'in');
eval (PluginManager::getPluginManager ()->pluginHooks ('in_valid'));
 
          }
        }
      }
    }
 
    if ($go_to_rankings) {
      header("Location: {$CONF['list_url']}/?a=stats&u=$username");
      exit;
    }
  }
 
 
  function check($username) {
    global $CONF, $FORM;
 
    require_once("{$CONF['path']}/sources/misc/session.php");
    $session = new session;
    list($type, $data) = $session->get($FORM['sid']);
    $session->delete($FORM['sid']);
 
    if ($type == 'gateway' && $data == $username) {
      return 1;
    }
    else {
      return 0;
    }
  }
 
  function gateway($username) {
    global $DB, $LNG, $CONF, $FORM, $TMPL;
 
    require_once("{$CONF['path']}/sources/misc/session.php");
    $session = new session;
    $TMPL['sid'] = $session->create('gateway', $username);
 
    $TMPL['username'] = $username;
 
  // Recaptcha Mod
  require_once($CONF['path'].'/sources/recaptchalib.php');
  $publickey = "MY KEY";
  $TMPL['captcha_code'] = recaptcha_get_html($publickey);
  //
$result = $DB->query("SELECT title FROM {$CONF['sql_prefix']}_sites WHERE username = '{$username}' AND active='1'", __FILE__, __LINE__);
while (list($title) = $DB->fetch_array($result)) {
$TMPL['gateway_title'] = $title;
}
//
eval (PluginManager::getPluginManager ()->pluginHooks ('in_gateway'));
 
    echo $this->do_skin('gateway');
    exit;
  }
 
  function get_username($url) {
    global $CONF, $DB;
 
    $url = $this->short_url($url);
    $count = 0;
 
    $username = '';
    while (!$username) {
      list($username) = $DB->fetch("SELECT username FROM {$CONF['sql_prefix']}_sites WHERE short_url = '{$url}'", __FILE__, __LINE__);
 
      if (!$username) {
        $url = $this->short_url("{$url}.");
      }
 
      $count++;
      if ($count >= 10) {
        $username = 0;
        break;
      }
    }
 
    return $username;
  }
 
  function short_url($url) {
    // Lowercase
    $url = strtolower($url);
 
    // Get rid of www.
    $url = preg_replace('/\/\/www./', '//', $url);
 
    // Get rid of trailing slash
    $url = preg_replace('/\/$/', '', $url);
 
    // Get rid of page after the last slash
    preg_match('/^(http:\/\/.+)\/(.+)/', $url, $matches);
    if (!isset($matches[0])) {
      // Just a domain with a slash at the end
      $url = preg_replace('/^(http:\/\/.+)\//', '\\1', $url);
    }
    else {
      // All other URLs
      // Check to see if after the trailing slash is a file or a directory
      if (strpos($matches[2], '.')) { $url = $matches[1]; }
    }
 
    return $url;
  }
}
?>
	
		Code:
	
	<body>
{$wrapper_welcome}
<div id="header">
    <div id="logo"><a href="http://www.votezone.eu/"><img src="/images/votezone_logo.png" width=”300” height=”100” alt="{$list_name}"/></a></div>
<div id="logotext">Lineage 2 VoteZone Ranking Servers</div>
    <div id="headside">
    <div id="headbanner">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-8640561945009743";
/* 468x60, created 11/28/10 */
google_ad_slot = "3562668950";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
 
</div>
    </div>
</div>
 
<div id="gatewrap"><div id="gatewrap2">
    <h1>{$lng->gateway_header}</h1>
 
        <div id="gateway-top">{$gateway_top}</div>
 
        <p class="gatemessage">{$lng->gateway_text}</p><br /><br />
        <center><form method="post" action="{$list_url}/index.php?a=in&u={$username}&sid={$sid}">
  {$captcha_error}
  {$captcha_code}
  <br />
 
<center><font size="4"<b>Vote for:</b><br>{$gateway_title}</font></center>
  <div class="advertleft">
 
 
  <div class="votebox">
 
 
<br>
  <center><input type="image" STYLE="text-align:center; color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 14px; background-color: #72A4D2;" size="14" value="Solve captcha above and click here to vote for {$gateway_title}" class="cssbuttongo" /></center><br /><br /><br />
 
  </div>
 
       
       
 
<a href="{$list_url}/" class="" target=""><span>{$lng->gateway_no_vote}</span></a>
</div></div>
    <center><a href="{$list_url}/"><img src="{$skins_url}/{$skin_name}/images/advert/advert1468x60.png" alt="{$list_name}" /></a></center>
        <div class="floatLeft footerLeft">
</body>
</html>
	http://www.adscaptcha.com/Resources.aspx
				
 test away