u can use antiflood system in register.php by taking code from in creating new topics i try but i get error eror so i try again if i success il definately share here :D
turn off registration from any other sites
Collapse
X
-
Hello guys , m sharing my antiflood system i used at chatmasti hopefully it myt b help full to u ol...
STEP 1.
1. Create a file named captcha_image.php (you can use any file name) with following code
Code:<? // *** CAPTCHA image generation *** // *** http://chatmasti.mobi *** session_start(); // *** Tell the browser what kind of file is come'n at 'em! *** header("Content-Type: image/jpeg"); // *** Send a generated image to the browser *** die(create_image()); // *** Function List *** function create_image() { // *** Generate a passcode using md5 // (it will be all lowercase hex letters and numbers *** $md5 = md5(rand(0,9999)); $passy = substr($md5, 10, 5); // *** Set the session cookie so we know what the passcode is *** $_SESSION["passy"] = $passy; // *** Create the image resource *** $image = imagecreatetruecolor(100, 20); // *** We are making two colors, white and black *** $clr_white = ImageColorAllocate($image, 255, 255, 255); $clr_black = ImageColorAllocate($image, 0, 136, 204); // *** Make the background black *** imagefill($image, 0, 0, $clr_black); // *** Set the image height and width *** imagefontheight(15); imagefontwidth(15); // *** Add the passcode in white to the image *** imagestring($image, 5, 30, 3, $passy, $clr_white); // *** Throw in some lines to trick those cheeky bots! *** imageline($image, 5, 1, 50, 20, $clr_white); imageline($image, 60, 1, 96, 20, $clr_white); // *** Return the newly created image in jpeg format *** return imagejpeg($image); // *** Just in case... *** imagedestroy($image); } ?>
STEP 2.
1. Add This code in Your Registration form.
Code:echo "<img src=\"./captcha_image.php\" alt=\"ENABLE IMAGES\"/> <br/><strong>Enter Code shown In Image:*</strong><br/> <input type=\"text\" name=\"captcha_input\" maxlength=\"10\"/><br/>";
1.Now in Register.php or whatever file you use to insert values in database add this
Code:<?php ////////////////////////////////////////////////Check For captha Code///////////////// session_start(); $code = $_GET['captcha_input']; // *** The text input will come in through the variable $_POST["captcha_input"], // while the correct answer is stored in the cookie $_COOKIE["pass"] *** if ($code == $_SESSION["passy"]) ///////////////////////////////////////////////Continue If captha Result true////////////////// { // HERE You can place rest of your file fuctions //Dnt forget to add following code before closing if block $md5 = md5(rand(0,9999)); $pass = substr($md5, 10, 5); // *** Set the session cookie so we know what the passcode is *** $_SESSION["passy"] = $passy; } else { //////////////////////////////////////////////Error message For Invalid Captha///////////////////////// echo '<?xml version="1.0" encoding="UTF-8"?>'; echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; echo '<html xmlns="http://www.w3.org/1999/xhtml">'; include "./config.php"; echo "<head>"; echo "<title>Invalid Entry</title>\n"; echo "<style type = \"text/css\">\n"; echo $default; echo "</style></head>\n"; echo "<body>\n"; echo "<div>Invalid Entry</div>"; echo "<img src=\"image/not.gif\" alt=\"x\"/><br/>"; echo "Either you are a <strong>BOT</strong> or you Entered <strong>Invalid Image Text</strong>.<br/>"; echo "<strong>You Entered:</strong> $code<br/>"; echo "<strong>Correct Answer:</strong> " . $_SESSION["passy"]; echo "<hr/><a href=\"./regform.php\">Try Again</a><br/>"; $md5 = md5(rand(0,9999)); $passy = substr($md5, 10, 5); // *** Set the session cookie so we know what the passcode is *** $_SESSION["passy"] = $passy; } @mysql_close(); ?>
Note* if you get any error installing captcha leave me a pm hav fun n say gud bye to autobotz ....thanxLast edited by Navjot_Saini; 31.10.09, 00:47.
Comment
-
lol
Originally posted by Navjot_Saini View PostHello guys , m sharing my antiflood system i used at chatmasti hopefully it myt b help full to u ol...
STEP 1.
1. Create a file named captcha_image.php (you can use any file name) with following code
Code:<? // *** CAPTCHA image generation *** // *** http://chatmasti.mobi *** session_start(); // *** Tell the browser what kind of file is come'n at 'em! *** header("Content-Type: image/jpeg"); // *** Send a generated image to the browser *** die(create_image()); // *** Function List *** function create_image() { // *** Generate a passcode using md5 // (it will be all lowercase hex letters and numbers *** $md5 = md5(rand(0,9999)); $passy = substr($md5, 10, 5); // *** Set the session cookie so we know what the passcode is *** $_SESSION["passy"] = $passy; // *** Create the image resource *** $image = imagecreatetruecolor(100, 20); // *** We are making two colors, white and black *** $clr_white = ImageColorAllocate($image, 255, 255, 255); $clr_black = ImageColorAllocate($image, 0, 136, 204); // *** Make the background black *** imagefill($image, 0, 0, $clr_black); // *** Set the image height and width *** imagefontheight(15); imagefontwidth(15); // *** Add the passcode in white to the image *** imagestring($image, 5, 30, 3, $passy, $clr_white); // *** Throw in some lines to trick those cheeky bots! *** imageline($image, 5, 1, 50, 20, $clr_white); imageline($image, 60, 1, 96, 20, $clr_white); // *** Return the newly created image in jpeg format *** return imagejpeg($image); // *** Just in case... *** imagedestroy($image); } ?>
STEP 2.
1. Add This code in Your Registration form.
Code:echo "<img src=\"./captcha_image.php\" alt=\"ENABLE IMAGES\"/> <br/><strong>Enter Code shown In Image:*</strong><br/> <input type=\"text\" name=\"captcha_input\" maxlength=\"10\"/><br/>";
1.Now in Register.php or whatever file you use to insert values in database add this
Code:<?php ////////////////////////////////////////////////Check For captha Code///////////////// session_start(); $code = $_GET['captcha_input']; // *** The text input will come in through the variable $_POST["captcha_input"], // while the correct answer is stored in the cookie $_COOKIE["pass"] *** if ($code == $_SESSION["passy"]) ///////////////////////////////////////////////Continue If captha Result true////////////////// { // HERE You can place rest of your file fuctions //Dnt forget to add following code before closing if block $md5 = md5(rand(0,9999)); $pass = substr($md5, 10, 5); // *** Set the session cookie so we know what the passcode is *** $_SESSION["passy"] = $passy; } else { //////////////////////////////////////////////Error message For Invalid Captha///////////////////////// echo '<?xml version="1.0" encoding="UTF-8"?>'; echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"; echo '<html xmlns="http://www.w3.org/1999/xhtml">'; include "./config.php"; echo "<head>"; echo "<title>Invalid Entry</title>\n"; echo "<style type = \"text/css\">\n"; echo $default; echo "</style></head>\n"; echo "<body>\n"; echo "<div>Invalid Entry</div>"; echo "<img src=\"image/not.gif\" alt=\"x\"/><br/>"; echo "Either you are a <strong>BOT</strong> or you Entered <strong>Invalid Image Text</strong>.<br/>"; echo "<strong>You Entered:</strong> $code<br/>"; echo "<strong>Correct Answer:</strong> " . $_SESSION["passy"]; echo "<hr/><a href=\"./regform.php\">Try Again</a><br/>"; $md5 = md5(rand(0,9999)); $passy = substr($md5, 10, 5); // *** Set the session cookie so we know what the passcode is *** $_SESSION["passy"] = $passy; } @mysql_close(); ?>
Note* if you get any error installing captcha leave me a pm hav fun n say gud bye to autobotz ....thanx
Comment
-
Guest
Originally posted by bijaybd View Postis there any code to stop auto bot registration like someone is using my registration page from other site coded . like he is just typing the id in his page and its auto registering ids like 1 2 3 4 5 autometically so is there any code or .httacccess to stop this and the registration will only allowed from my site registration page ???
CAPTCHA is one way of doing it but I use the following method.
$browser = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
$now = time(NULL);
$browser = strtolower($browser);
$invalid = array("the browsers that you do not want to be able to register");
$array_size = count($invalid);
$browser_valid = "no";
for ($i = 0; $i <= $array_size - 1; $i++) {
$mystring = $browser;
$findme = $invalid[$i];
$pos = strpos($mystring, $findme);
if ($pos === false) { $browser_valid = "yes";} else $browser_valid = "no";
}
if ($browser_valid == "no") header("location:invalid_browser.php");
Comment
-
having a great problem again i set up no registeration with same browser even separeted for ip and browser but they have changed both of them for example browser shows like brower1 in 2nd registration time browser2 browser3 i have capcha but still its not working and they are registratering more then 100 ids with in a second by some application or some system i guess so any one could help ???
Comment
Comment