Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. <?php
  2. $app->post("/encrypt/register", function() use($app){
  3. $db_con = DBConnection();
  4. $allPostVars = $app->request->post();
  5. $error;
  6. $encrypt_2 = $allPostVars["encrypt_2"];
  7. $encrypt_3 = $allPostVars["encrypt_3"];
  8. $encrypt_4 = $allPostVars["encrypt_4"];
  9. $encrypt_4_1 = $allPostVars["encrypt_4_1"];
  10. $checkPassword = EncryptPss($encrypt_4, $encrypt_4_1);
  11. $encrypt_2 = md5($encrypt_2);
  12. $encrypt_3 = md5($encrypt_3);
  13. $encrypt_4 = md5($encrypt_4);
  14. if($checkPassword == 1){
  15. try{
  16. $sql = "INSERT INTO encrypt(encrypt_2, encrypt_3, encrypt_4) values ('$encrypt_2', '$encrypt_3','$encrypt_4')";
  17. $stmt = $db_con->exec($sql);
  18. }catch(PDOException $e){
  19. $error = $e->getMessage();
  20. }
  21. if(isset($error)){
  22. echo '{"status":false}';
  23. }else{
  24. echo '{"status":true}';
  25. }
  26. }else{
  27. echo '{"status":false}';
  28. }
  29. });
  30.  
  31. $app->post("/encrypt/login", function() use($app){
  32. $dbCon = DBConnection();
  33. $req = $app->request->post();
  34. $email = $req['encrypt_2'];
  35. $password = $req['encrypt_4'];
  36. $email = md5($email);
  37. $password = md5($password);
  38. $sql = "SELECT * FROM encrypt WHERE encrypt_2 = '$email' AND encrypt_4 = '$password'";
  39. try{
  40. $stmt = $dbCon->prepare($sql);
  41. $stmt->bindParam("email", $email);
  42. $stmt->bindParam("password", $password);
  43. $stmt->execute();
  44. $count = $stmt->rowCount();
  45. if($count == 0){
  46. echo '{"status":false}';
  47. }else{
  48. echo '{"status":true}';
  49. }
  50. }catch(PDOException $e){
  51. echo '{"status":false}';
  52. }
  53. });
  54.  
  55. $app->post("/encrypt/login2", function() use($app){
  56. $dbCon = DBConnection();
  57. $req = $app->request->post();
  58. $email = $req['encrypt_2'];
  59. $username = $req['encrypt_3'];
  60. $emailChecker = EncryptEml($email);
  61. $email = md5($email);
  62. $username = md5($username);
  63. if($emailChecker == 0){
  64. try{
  65. $sql = "INSERT INTO encrypt(encrypt_2, encrypt_3) values ('$email', '$username')";
  66. $stmt = $dbCon->exec($sql);
  67. }catch(PDOException $e){
  68. $error = $e->getMessage();
  69. }
  70. if(isset($error)){
  71. echo '{"status":false}';
  72. }else{
  73. echo '{"status":true}';
  74. }
  75. }else{
  76. echo '{"status":true}';
  77. }
  78. });
  79.  
  80. function EncryptPss($password_1, $password_2){
  81. if($password_1 == $password_2){
  82. return TRUE;
  83. }else{
  84. return FALSE;
  85. }
  86. }
  87.  
  88. function EncryptEml($email){
  89. $db = DBConnection();
  90. $error;
  91. $sql = "SELECT encrypt_2 FROM encrypt WHERE encrypt_2 = '$email'";
  92. $result = $db->query($sql);
  93. $count = $result->rowCount();
  94. return $count;
  95. }
  96. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement