Guest User

Untitled

a guest
Aug 2nd, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. include_once('config.php');
  4. $dbhost = 'localhost';
  5. $dbname = 'timeline';
  6. $dbuser = 'root';
  7. list($userName, $mailDomain) = split("@", $_POST['email']);
  8. function myCheckDNSRR($hostName, $recType = '')
  9. {
  10. if(!empty($hostName)) {
  11. if( $recType == '' ) $recType = "MX";
  12. exec("nslookup -type=$recType $hostName", $result);
  13. foreach ($result as $line) {
  14. if(eregi("^$hostName",$line)) {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. return false;
  21. }
  22.  
  23. function error($error){
  24. $fullerror = "<h1> An Error Occurred</h1><p>".$error."</p>";
  25. die($fullerror . "</div></body></html>");
  26. }
  27.  
  28. function checkString($str,$filter)
  29. {
  30. foreach($filter as $key=>$value)
  31. {
  32. $inFilter = strpos($str, $value);
  33. if($inFilter === false)
  34. {
  35. $hold = false;
  36. } else {
  37. return true;
  38. }
  39. }
  40. return $hold;
  41. }
  42.  
  43. mysql_connect($dbhost, $dbuser)or error("Could not connect: ".mysql_error());
  44. mysql_select_db($dbname) or error(mysql_error());
  45.  
  46. if (isset($_POST['submit'])) {
  47. $u = $_POST['username'];
  48. if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] ) {
  49. error('You did not complete all of the required fields');
  50. }
  51. if (!get_magic_quotes_gpc()) {
  52. $_POST['username'] = addslashes($_POST['username']);
  53. }
  54. if(ereg("[^A-Za-z0-9]", $_POST['username'])){
  55. error("Your username is invalid");
  56. }
  57. if (checkString(strtolower($_POST['username']), $flt)==true) {
  58. error("Your username is invalid");
  59. }
  60.  
  61. if(substr($_POST['username'], 0,1) == " " || substr(strrev($_POST['username']), 0,1) == " "){
  62. error('Undefined Error');
  63. }
  64.  
  65. $_POST['username'] = mysql_real_escape_string($_POST['username']);
  66. $_POST['pass'] = mysql_real_escape_string($_POST['pass']);
  67. $_POST['email'] = mysql_real_escape_string($_POST['email']);
  68. if (!get_magic_quotes_gpc()) {
  69. $_POST['pass'] = addslashes($_POST['pass']);
  70. $_POST['email'] = addslashes($_POST['email']);
  71. $_POST['username'] = addslashes($_POST['username']);
  72. }
  73. require_once('recaptchalib.php');
  74. $privatekey = "6LfL5MgSAAAAAEkQ4XbAVDDd-1lNFILqW95y_Vve";
  75. $resp = recaptcha_check_answer ($privatekey,
  76. $_SERVER["REMOTE_ADDR"],
  77. $_POST["recaptcha_challenge_field"],
  78. $_POST["recaptcha_response_field"]);
  79.  
  80. if (!$resp->is_valid) {
  81. // What happens when the CAPTCHA was entered incorrectly
  82. error("The reCAPTCHA wasn't entered correctly. Go back and try it again.");
  83. }
  84.  
  85. if (!checkdnsrr($mailDomain, "MX")) {
  86. error('You have entered a invalid email!');
  87. }
  88.  
  89. $usercheck = $_POST['username'];
  90. if(is_numeric($usercheck)) {
  91. die('The username cannot be numeric!');
  92. }
  93.  
  94. if(is_numeric($usercheck{0})) {
  95. die('The username cannot be numeric!');
  96. }
  97.  
  98. if(strlen($usercheck) <= 5){
  99. error('Your username is too short, it must be at least 6 characters!');
  100. }
  101. if(strlen($usercheck) >= 12){
  102. error('Your username is too long, it can only contain 6-12 letters!');
  103. }
  104.  
  105. $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or error(mysql_error());
  106. $check2 = mysql_num_rows($check);
  107. {
  108. if ($check2 != 0) {
  109. error('Sorry, the username '.$_POST['username'].' is already in use.');
  110. }
  111. if ($_POST['pass'] != $_POST['pass2']) {
  112. error('Your passwords did not match. ');
  113. }
  114. if(strlen($_POST['pass']) <= 5){
  115. error('Your password is too short, it must be at least 6 characters! ');
  116. }
  117.  
  118. if(strlen($_POST['username']) <= 3){
  119. error('Your username is too short, it must be 4 characters or longer! ');
  120. }
  121. $password = $_POST['password'];
  122. }
  123. $mysql_insert = "INSERT INTO users (username, password, email) VALUES(''$usercheck','" . md5(md5($_POST['pass'])) . "','" . $_POST['email'] . "');";
  124. $add_member = mysql_query($mysql_insert);
  125. mysql_free_result($add_member);
  126. mysql_free_result($check);
  127. ?>
  128. <h2>You have been registered.</h2>
  129. 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