Advertisement
Guest User

Untitled

a guest
Sep 18th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. <?php include("salt.php")?>
  2.  
  3. <?php
  4.  
  5. $username = "xxxxxxxx";
  6. $password = "xxxxxxxx";
  7. $hostname = "xxxxxxxx";
  8.  
  9. // Connect to the database
  10. $connect = mysql_connect($hostname, $username, $password)
  11. or die("Sorry, the connection could not be established <br /> Please report this problem to the administrator if this continues");
  12.  
  13. // Select a database
  14. $selected = mysql_select_db("xxxxxxxxxxxxxxxxxxxxx",$connect)
  15. or die("Sorry, the database could not be selected <br /> Please report this problem to the administrator if this continues");
  16.  
  17. if(get_magic_quotes_gpc()) {
  18. $previousemail = stripslashes($_POST['previousemai']);
  19. $newemail = stripslashes($_POST['newemail']);
  20. $confirmemail = stripslashes($_POST['confirmemail']);
  21. $previouspassword = stripslashes($_POST['previouspassword']);
  22. $newpassword = stripslashes($_POST['newpassword']);
  23. $confirmpassword = stripslashes($_POST['confirmpassword']);
  24. } else {
  25. $previousemail = $_POST['previousemail'];
  26. $newemail = $_POST['newemail'];
  27. $confirmemail = $_POST['confirmemail'];
  28. $previouspassword = $_POST['previouspassword'];
  29. $newpassword = $_POST['newpassword'];
  30. $confirmpassword = $_POST['confirmpassword'];
  31. }
  32.  
  33. $_POST['previousemail'] = mysql_real_escape_string($previousemail, $connect);
  34. $_POST['newemail'] = mysql_real_escape_string($newemail, $connect);
  35. $_POST['confirmemail'] = mysql_real_escape_string($confirmemail, $connect);
  36. $_POST['previouspassword'] = mysql_real_escape_string($peviouspassword, $connect);
  37. $_POST['newpassword'] = mysql_real_escape_string($newpassword, $connect);
  38. $_POST['confirmpassword'] = mysql_real_escape_string($confirmpassword, $connect);
  39.  
  40. // Change email function
  41. function changeemail()
  42. {
  43. // Select query
  44. $emailquery = mysql_query("SELECT AES_DECRYPT('email','".SALT."') AS email FROM adminaccounts WHERE email='$previousemail'");
  45.  
  46. $checkselect = mysql_num_rows($emailquery);
  47.  
  48. // Check email matches records in MYSQL database
  49. if (!$checkselect) {
  50. die("Sorry the email you have entered does not match any records");
  51. }
  52.  
  53. // Check if fields are empty and if emails match
  54. if ($_POST['previousemail']==NULL || $_POST['newemail']==NULL || $_POST['confirmemail']==NULL)
  55. {
  56. die("Sorry but you have not completed all of the email fields, please go back and make sure all fields are completed.");
  57. }
  58.  
  59. elseif ($_POST['newemail']!=$_POST['confirmemail'])
  60. {
  61. die("Sorry but your emails do not match, please go back and make sure they match.");
  62. }
  63.  
  64. else{
  65.  
  66. // Update query
  67. $updatequery = mysql_query("UPDATE adminaccounts SET email=AES_ENCRYPT('$confirmemail','".SALT."') WHERE email='$previousemail'");
  68. }
  69.  
  70. $num_rows = mysql_num_rows($updatequery);
  71.  
  72. if(!updatequery) {
  73. die("Sorry but your email has not been changed, please go back to try again. If this problem continues please contact the administrator");
  74. }
  75. }
  76.  
  77.  
  78. // Change password function
  79. function changepassword()
  80. {
  81.  
  82. $passwordquery = mysql_query("SELECT AES_DECRYPT('password','".SALT."') AS password FROM adminaccounts WHERE password='$previouspassword'");
  83.  
  84. $checkselect = mysql_num_rows($passwordquery);
  85.  
  86. // Check password matches records in MYSQL database
  87. if (!$checkselect) {
  88. die("Sorry the password you have entered does not match any records");
  89. }
  90.  
  91. // Check if fields are empty and if passwords match
  92. if ($_POST['previouspassword']==NULL || $_POST['newpassword']==NULL || $_POST['confirmpassword']==NULL)
  93. {
  94. die("Sorry but you have not completed all of the password fields, please go back and make sure all fields are completed.");
  95. }
  96.  
  97. elseif ($_POST['newpassword']!=$_POST['confirmpassword'])
  98. {
  99. die("Sorry but your passwords do not match, please go back and make sure they match.");
  100. }
  101.  
  102. else{
  103.  
  104. // Update query
  105. $passwordquery = mysql_query("UPDATE adminaccounts SET password=AES_ENCRYPT('$confirmpassword','".SALT."') WHERE password='$previouspassword'");
  106. }
  107.  
  108. $num_rows = mysql_num_rows($passwordquery);
  109.  
  110. if(!passwordquery) {
  111. die("Sorry but your password has not been changed, please go back to try again. If this problem continues please contact the administrator");
  112. }
  113. }
  114.  
  115. // If changeemail button is pressed then call the changeemail function
  116. if (isset($_POST['changeemail'])) {
  117. changeemail();
  118. }
  119.  
  120. // If changepassword button is pressed then call the changepassword function
  121. if (isset($_POST['changepassword'])) {
  122. changepassword();
  123. }
  124.  
  125. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement