Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <?php
  2. include("../config/dbconf.php");
  3.  
  4. function encryptpw($user, $pass) {
  5. $user = strtoupper($user);
  6. $pass = strtoupper($user);
  7. return sha1($user.':'.$pass);
  8. }
  9.  
  10. $email = strtoupper($_POST['email']);
  11. $expansion = $_POST['exp'];
  12. $bnetindex = "1";
  13.  
  14.  
  15. // Battlenet Password
  16. $bnetpassword = strtoupper(bin2hex(strrev(hex2bin(strtoupper(hash("sha256",strtoupper(hash("sha256", strtoupper($email)).":".strtoupper($_POST['pass']))))))));
  17.  
  18. // Queries
  19. if($insbnet = $conn->prepare("SELECT id FROM battlenet_accounts WHERE email = ?")) {
  20. $insbnet->bind_param("s", $email);
  21. $insbnet->execute();
  22. if($insbnet = $conn->prepare("INSERT INTO battlenet_accounts (email, sha_pass_hash) VALUES (?, ?);")) {
  23. $insbnet->bind_param("ss", $email, $bnetpassword);
  24. $insbnet->execute();
  25.  
  26. $getid = $conn->prepare("SELECT id FROM battlenet_accounts WHERE email = ?");
  27. $getid->bind_param("s", $email);
  28. $getid->execute();
  29. $getid->bind_result($id);
  30. $getid->store_result();
  31. if($getid->num_rows > 0) {
  32. while($getid->fetch()) {
  33. $bnetacc = $id;
  34. $username = $id."#".$bnetindex;
  35. $accpassword = encryptpw($username, $_POST['pass']);
  36. }
  37. echo "1";
  38. return;
  39. }
  40.  
  41. if($insacc = $conn->prepare("INSERT INTO account (username, sha_pass_hash, email, reg_mail, expansion, battlenet_account, battlenet_index) VALUES (?, ?, ?, ?, ?, ?);")) {
  42. $insacc->bind_param("ssssiii", $username, $accpassword, $email, $expansion, $bnetacc, $bnetindex);
  43. $insacc->execute();
  44. }else{
  45. echo $insacc->error;
  46. }
  47. echo "registered";
  48. }else{
  49. echo $insbnet->error;
  50. }
  51. } else {
  52. echo $insbnet->error;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement