A unf. social network done poorly.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
4.9KB

  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', '1');
  4. require_once($_SERVER['DOCUMENT_ROOT'] . '/socialtune/includes/session.php');
  5. require_once($_SERVER['DOCUMENT_ROOT'] . '/socialtune/includes/config.php');
  6. /* ## On security...
  7. * Change the encryption method. >> bcrypt
  8. OR
  9. SHA-256 + per-user salt.
  10. */
  11. $is_band = (!empty($_POST['is_Band'])) ? $_POST['is_Band'] : false;
  12. /********************************************
  13. ***** ------------------------------- *
  14. ***** ### NORMA USER SIGN UP PART #### *
  15. ***** ------------------------------- *
  16. *********************************************/
  17. if($is_band == false){
  18. $first_name = (!empty($_POST['first_name'])) ? $_POST['first_name'] : false;
  19. $last_name = (!empty($_POST['last_name'])) ? $_POST['last_name'] : false;
  20. $email = (!empty($_POST['email'])) ? $_POST['email'] : false;
  21. $password = (!empty($_POST['password'])) ? $_POST['password'] : false;
  22. $month = (!empty($_POST['month'])) ? $_POST['month'] : false;
  23. $day = (!empty($_POST['day'])) ? $_POST['day'] : false;
  24. $year = (!empty($_POST['year'])) ? $_POST['year'] : false;
  25. // Disallow "text entry"
  26. if(is_string($month)){
  27. $month = false;
  28. }
  29. if(is_string($day)){
  30. $day = false;
  31. }
  32. if(is_string($year)){
  33. $year = false;
  34. }
  35. // Convert to proper input.
  36. $birthdate = $month."/".$day."/".$year;
  37. $date = getdate();
  38. $signup_date = $date['mon'].'/'.$date['mday'].'/'.$date['year'];
  39. if($first_name && $last_name && $email && $password && $year && $day && $year){
  40. $connection = mysqli_connect($dbHost, $dbUser, $dbPass, $dbName); // variables provided /include/.
  41. $storedHash = $salt . $password;
  42. for($i = 0; $i < 1; $i++){
  43. $storedHash = hash('sha256', $storedHash);
  44. }
  45. $officialHash = substr($storedHash, 0, 64);
  46. $password = $officialHash;
  47. if(mysqli_connect_error()){
  48. echo "ERROR #001 - ".mysqli_connect_error; // Didn't connect. Check all settings.
  49. }
  50. $command = "INSERT INTO users(first_name, last_name, email, password, birthdate, signup_date)
  51. VALUES
  52. ( '$first_name', '$last_name', '$email', '$password', '$birthdate', '$signup_date')";
  53. if(!mysqli_query($connection, $command)){
  54. die("This email is already registered.");
  55. header("Location: signup.php?q=1"); // NOT SO MUCH READY TO GO. WTF DUDE GET AN EMAIL BR0.
  56. }
  57. echo "Signup complete... You are being redirected.";
  58. header("location: index.php?q=1"); // Ready to go!!!
  59. }else{
  60. echo "Missing data. -- Normal user";
  61. header("Location: signup.php?q=2"); // Normal user - Forgot to input something.
  62. }
  63. }
  64. /********************************************
  65. ***** -------------------------- *
  66. ***** ### BAND SIGN UP PART #### *
  67. ***** -------------------------- *
  68. *********************************************/
  69. if($is_band){
  70. $band_name = (!empty($_POST['band_name'])) ? $_POST['band_name'] : false;
  71. $email = (!empty($_POST['email'])) ? $_POST['email'] : false;
  72. $password = (!empty($_POST['password'])) ? $_POST['password'] : false;
  73. $month = (!empty($_POST['month'])) ? $_POST['month'] : false;
  74. $day = (!empty($_POST['day'])) ? $_POST['day'] : false;
  75. $year = (!empty($_POST['year'])) ? $_POST['year'] : false;
  76. /*---- Disallow "text entry" ----*/
  77. if(ctype_alpha($month)){
  78. $month = false;
  79. echo 'something went wrong with the month entry.<br>';
  80. }
  81. if(ctype_alpha($day)){
  82. $day = false;
  83. echo 'something went wrong with the day entry.<br>';
  84. }
  85. if(ctype_alpha($year)){
  86. $year = false;
  87. echo 'something went wrong with the year entry.<br>';
  88. }
  89. // Converts to proper input.
  90. $birthdate = $month."/".$day."/".$year;
  91. $date = getdate();
  92. $signup_date = $date['mon'].'/'.$date['mday'].'/'.$date['year'];
  93. if($band_name && $email && $password && $month && $day && $year){
  94. $connection = mysqli_connect($dbHost, $dbUser, $dbPass, $dbName); // variables provided /include/.
  95. $storedHash = $salt . $password;
  96. for($i = 0; $i < 1; $i++){
  97. $storedHash = hash('sha256', $storedHash);
  98. }
  99. $officialHash = substr($storedHash, 0, 64);
  100. $password = $officialHash;
  101. if(mysqli_connect_error()){
  102. echo "ERROR #001 - ".mysqli_connect_error; // Didn't connect. Check all settings.
  103. }
  104. $command = "INSERT INTO users(first_name, email, password, birthdate, signup_date, user_type)
  105. VALUES
  106. ( '$band_name', '$email', '$password', '$birthdate', '$signup_date', '$is_band')";
  107. if(!mysqli_query($connection, $command)){
  108. die("This email is already registered.");
  109. // header("Location: signup.php?q=1"); // NOT SO MUCH READY TO GO. WTF DUDE GET AN EMAIL BR0.
  110. }
  111. echo "Signup complete... You are being redirected.";
  112. header("location: index.php?q=1"); // Ready to go!!!
  113. }else{
  114. echo "Missing data. -- band users. <br /><br />";
  115. header("Location: signup.php?q=1"); // NOT SO MUCH READY TO GO. WTF DUDE GET AN EMAIL BR0.
  116. }
  117. }
  118. ?>