I have been a silent spectator for a while. I wanted to post few but the some of my ideas are already posted. Needless to say how much i gained from this forum and people. Following is my humble contribution for stopping robots registration and to fight spammers.
Have fun playing with the spammers.
Todo:
1. Goto reCAPTCHA: Stop Spam, Read Books and register for an account.
2. Add a doman and get the Private and Public Key.
3. Download and Save the attched recaptchalib.php into your pligg directory.
4. Modify register_step_2.tpl as shown
5. Modify register.php do_register2() as shown.(Best way is to replace the function with this.
register_step_2.tpl
Code:
{config_load file="/libs/lang.conf"}
<h2>{#PLIGG_Visual_Breadcrumb_RegisterStep2#}</h2>
{if $register_error eq true}
<p class="error">{$register_error_text}</p>
{else}
<form action="{$URL_register}" method="post" id="thisform">
<fieldset><legend>{#PLIGG_Visual_Register_Validation#}</legend>
<?php
require_once('recaptchalib.php');
$publickey = "YOUR PUBLIC KEY"; // you got this from the signup page
echo recaptcha_get_html($publickey);
?>
{#PLIGG_Visual_Register_Enter_Number#}<br />
<input type="hidden" name="ts_random" value="{$ts_random}" /><br />
<input type="submit" name="submit" value="{#PLIGG_Visual_Register_Continue#}" class="submit" /></p>
<input type="hidden" name="process" value="2" />
<input type="hidden" name="email" value="{$templatelite.post.email}" />
<input type="hidden" name="username" value="{$templatelite.post.username}" />
<input type="hidden" name="password" value="{$templatelite.post.password}" />
<input type="hidden" name="reghash" value="{$reghash}" />
</fieldset>
</form>
{/if}
Code:
function do_register2() {
global $db, $current_user, $main_smarty, $the_template;
if(enable_captcha == 'true') {
require_once('recaptchalib.php');
// Get a key from http://recaptcha.net/api/getkey
$publickey = "YOUR PUBLIC KEY HERE";
$privatekey = "YOUR PRIVATE KEY HERE";
# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if ($resp->is_valid) {
echo "Succesfully verified that you are human.";
} else {
# set the error code so that we can display it
$error = $resp->error;
}
}
if (!$resp->is_valid) { // if incorrect captcha code was entered
$main_smarty->assign('register_error_text', "badcode");
$main_smarty->display($the_template . '/register_error.tpl');
return;
}
$reghash = $_POST["reghash"];
$mycombo = $_POST["username"].$_POST["email"].$_POST["password"];
if(generateHash($mycombo, substr($reghash, 0, SALT_LENGTH)) != $reghash){
loghack('Register Step 2', 'username: ' . $_POST["username"].'|email: '.$_POST["email"]);
}
}
$error = false;
$error = verify_reg($_POST["username"], $_POST["email"], $_POST["password"], $_POST["password"]);
if ($error) return;
$username=$db->escape(trim($_POST['username']));
$password=$db->escape(trim($_POST['password']));
$userip=$_SERVER['REMOTE_ADDR'];
$saltedpass=generateHash($password);
$email=$db->escape(trim($_POST['email']));
if (!user_exists($username)) {
if ($db->query("INSERT INTO " . table_users . " (user_login, user_email, user_pass, user_date, user_ip) VALUES ('$username', '$email', '$saltedpass', now(), '$userip')")) {
if($current_user->Authenticate($username, $password, false) == false) {
$main_smarty->assign('register_error_text', "errorinserting");
$main_smarty->display($the_template . '/register_error.tpl');
} else {
define('registerdetails', $username . ';' . $password . ';' . $email . ';' . $return);
check_actions('register_success_pre_redirect');
header('Location: ' . getmyurl('user', $username));
}
} else {
$main_smarty->assign('register_error_text', "errorinserting");
$main_smarty->display($the_template . '/register_error.tpl');
}
} else {
$main_smarty->assign('register_error_text', "usernameexists");
$main_smarty->display($the_template . '/register_error.tpl');
}
}
Let me know if something is wrong.
eddy.





Linear Mode

