Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- include_once('config.php');
- $dbhost = 'localhost';
- $dbname = 'timeline';
- $dbuser = 'root';
- list($userName, $mailDomain) = split("@", $_POST['email']);
- function myCheckDNSRR($hostName, $recType = '')
- {
- if(!empty($hostName)) {
- if( $recType == '' ) $recType = "MX";
- exec("nslookup -type=$recType $hostName", $result);
- foreach ($result as $line) {
- if(eregi("^$hostName",$line)) {
- return true;
- }
- }
- return false;
- }
- return false;
- }
- function error($error){
- $fullerror = "<h1> An Error Occurred</h1><p>".$error."</p>";
- die($fullerror . "</div></body></html>");
- }
- function checkString($str,$filter)
- {
- foreach($filter as $key=>$value)
- {
- $inFilter = strpos($str, $value);
- if($inFilter === false)
- {
- $hold = false;
- } else {
- return true;
- }
- }
- return $hold;
- }
- mysql_connect($dbhost, $dbuser)or error("Could not connect: ".mysql_error());
- mysql_select_db($dbname) or error(mysql_error());
- if (isset($_POST['submit'])) {
- $u = $_POST['username'];
- if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
- error('You did not complete all of the required fields');
- }
- if (!get_magic_quotes_gpc()) {
- $_POST['username'] = addslashes($_POST['username']);
- }
- if(ereg("[^A-Za-z0-9]", $_POST['username'])){
- error("Your username is invalid");
- }
- if (checkString(strtolower($_POST['username']), $flt)==true) {
- error("Your username is invalid");
- }
- if(substr($_POST['username'], 0,1) == " " || substr(strrev($_POST['username']), 0,1) == " "){
- error('Undefined Error');
- }
- $_POST['username'] = mysql_real_escape_string($_POST['username']);
- $_POST['pass'] = mysql_real_escape_string($_POST['pass']);
- $_POST['email'] = mysql_real_escape_string($_POST['email']);
- if (!get_magic_quotes_gpc()) {
- $_POST['pass'] = addslashes($_POST['pass']);
- $_POST['email'] = addslashes($_POST['email']);
- $_POST['username'] = addslashes($_POST['username']);
- }
- require_once('recaptchalib.php');
- $privatekey = "6LfL5MgSAAAAAEkQ4XbAVDDd-1lNFILqW95y_Vve";
- $resp = recaptcha_check_answer ($privatekey,
- $_SERVER["REMOTE_ADDR"],
- $_POST["recaptcha_challenge_field"],
- $_POST["recaptcha_response_field"]);
- if (!$resp->is_valid) {
- // What happens when the CAPTCHA was entered incorrectly
- error("The reCAPTCHA wasn't entered correctly. Go back and try it again.");
- }
- if (!checkdnsrr($mailDomain, "MX")) {
- error('You have entered a invalid email!');
- }
- $usercheck = $_POST['username'];
- if(is_numeric($usercheck)) {
- die('The username cannot be numeric!');
- }
- if(is_numeric($usercheck{0})) {
- die('The username cannot be numeric!');
- }
- if(strlen($usercheck) <= 5){
- error('Your username is too short, it must be at least 6 characters!');
- }
- if(strlen($usercheck) >= 12){
- error('Your username is too long, it can only contain 6-12 letters!');
- }
- $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or error(mysql_error());
- $check2 = mysql_num_rows($check);
- {
- if ($check2 != 0) {
- error('Sorry, the username '.$_POST['username'].' is already in use.');
- }
- if ($_POST['pass'] != $_POST['pass2']) {
- error('Your passwords did not match. ');
- }
- if(strlen($_POST['pass']) <= 5){
- error('Your password is too short, it must be at least 6 characters! ');
- }
- if(strlen($_POST['username']) <= 3){
- error('Your username is too short, it must be 4 characters or longer! ');
- }
- $password = $_POST['password'];
- }
- $mysql_insert = "INSERT INTO users (username, password, email) VALUES(''$usercheck','" . md5(md5($_POST['pass'])) . "','" . $_POST['email'] . "');";
- $add_member = mysql_query($mysql_insert);
- mysql_free_result($add_member);
- mysql_free_result($check);
- ?>
- <h2>You have been registered.</h2>
- Dear <b><?php echo $_POST['username'];?></b>, Thank you for registering with us! <br /> You can login <a href="login.php">here</a>
Add Comment
Please, Sign In to add comment