Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.14 KB | None | 0 0
  1. <div id="column1" class="column">
  2. <div class="habblet-container ">
  3. <div class="cbb clearfix red ">
  4. <h2 class="title">Reset your Password<span style="float: right; font-weight: normal; font-size: 75%;"></span></h2>
  5. <div class="box-content" style="text-align:left;">
  6. <?php
  7.  
  8. echo '<html><head><title>Fresh: Password Reset</title></head><body>';
  9. $MySQLi = mysqli_connect('localhost', 'root', 'kaneisgay') or die(mysqli_error());
  10. mysqli_select_db($MySQLi, 'freshdb') or die("Could not connect to database, error: " . mysqli_error());
  11.  
  12. function sendEmail($to, $to_username, $body, $subject){
  13. $url = 'https://api.sendgrid.com/';
  14. $user = 'FreshNetworksv1';
  15. $pass = 'kaneisgay55';
  16. $url = 'https://api.sendgrid.com/';
  17. file_get_contents($url.'api/mail.send.json?api_user='.urlencode($user).'&api_key='.urlencode($pass).'&to='.urlencode($to).'&subject='.urlencode($subject).'&html='.urlencode($body).'&from='.urlencode('KANE.BLUD@DWP.GSI.GOV.UK'));
  18. }
  19. function getKey()
  20. {
  21. return substr(str_shuffle('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 25);
  22. }
  23. function getPassword()
  24. {
  25. return substr(str_shuffle('1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 10);
  26. }
  27.  
  28. if (!isset($_GET['resetkey']))
  29. {
  30. if (isset($_POST['username']))
  31. {
  32. if (isset($_POST['email']) && !empty($_POST['email']))
  33. {
  34. $q = @mysqli_query($MySQLi, "SELECT id,username,mail FROM users WHERE username = '" . mysqli_real_escape_string($MySQLi, $_POST['username']) . "'");
  35.  
  36. {
  37. if (@mysqli_num_rows($q) != 0)
  38. {
  39. $d = @mysqli_fetch_array($q);
  40.  
  41. if(strtolower($_POST['email']) == strtolower($d['mail']))
  42. {
  43. $canSend = true;
  44.  
  45. if(isset($_SESSION["ResetEmailCooldown"]))
  46. {
  47. if($_SESSION["ResetEmailCooldown"] > time())
  48. $canSend = false;
  49. }
  50. else
  51. $_SESSION["ResetEmailCooldown"] = time() + 3600;
  52.  
  53. if($canSend)
  54. {
  55. $email = $d['mail'];
  56. $key = getKey();
  57. mysqli_query($MySQLi, "UPDATE users SET dob = '" . $key . "', seckey = '" . time() . "' WHERE id = '" . $d['id'] . "'");
  58.  
  59. $n = new Newsletter;
  60. $n->greetingTo = "";
  61. $n->contents = "This is an automated email from Fresh Hotel (https://fresh-hotel.org) <br /><br />";
  62. $n->contents .= "Your password reset link is: <a href=\"https://fresh-hotel.org/account/password/forgot?resetkey=" . $key . "\">https://fresh-hotel.org/account/password/forgot?resetkey=" . $key . "</a>";
  63. $n->contents .= "<br /><br />Please click the link and reset immediately, as it will expire in 10 minutes.";
  64. $n->footer = "Copyright &copy; Fresh Hotel 2010-2017";
  65.  
  66. sendEmail($email, mysqli_real_escape_string($MySQLi, $_POST['username']), $n->drawEmail(), "Fresh: Password reset.");
  67. echo '<div class="rounded rounded-green">An email has been sent to the email used for the account "' . $_POST['username'] . '".</div>';
  68. }
  69. else
  70. {
  71. echo '<div class="rounded rounded-red">You can only send one email request every hour. Please wait and try again.</div>';
  72. }
  73. }
  74. else
  75. {
  76. echo '<div class="rounded rounded-red">The email you entered does not belong to the account ' . $_POST['username'] . '</div>';
  77. }
  78. }
  79. else
  80. {
  81. echo '<div class="rounded rounded-red">No acount was found with the username "' . $_POST['username'] . '".</div>';
  82. }
  83.  
  84. }
  85. }
  86. else
  87. {
  88. echo '<div class="rounded rounded-red">You need to enter an email address.</div>';
  89. }
  90. }
  91. else
  92. {
  93. echo '<center><b><form action="" method="POST"> Enter your username below. <br><input name="username" type="text"><br><br>Email on account<br><input name="email" type="text"><br>
  94. </script><br><br><input name="submit" type="submit" value="Reset Pasword" class="submit"></center>';
  95. }
  96. }
  97. else
  98. {
  99. $q = mysqli_query($MySQLi, "SELECT * FROM users WHERE dob = '" . mysqli_real_escape_string($MySQLi, $_GET['resetkey']) . "'");
  100. if (mysqli_num_rows($q) != 0 && strlen($_GET['resetkey']) > 15)
  101. {
  102. $d = mysqli_fetch_array($q);
  103. if ($d['seckey'] >= (time() - (60 * 10)))
  104. {
  105. $pw = getPassword();
  106. $email = $d['mail'];
  107. mysqli_query($MySQLi, "UPDATE users SET password = '" . sha1(md5($pw)) . "', dob = '', seckey = '' WHERE username = '" . $d['username'] . "'") or die(mysqli_error($MySQLi));
  108. //upto
  109. $n = new Newsletter;
  110. $n->greetingTo = "";
  111. $n->contents = "This is an automated email from Fresh Hotel (https://fresh-hotel.org) <br /><br />";
  112. $n->contents .= "Your new password is: " . $pw . "<br><br>Please login and change this immediately.";
  113. $n->footer = "Copyright &copy; Fresh Hotel 2010-2017";
  114. sendEmail($email, mysqli_real_escape_string($MySQLi, $d['username']), $n->drawEmail(), "Fresh Hotel: Password reset.");
  115. echo '<center><b>An email has been sent to "' . $email . '", which contains the new password for "' . $d['username'] . '".';
  116. }
  117. else
  118. {
  119. echo '<div class="rounded rounded-red">That password reset link has expired.</div>';
  120. }
  121. }
  122. else
  123. {
  124. echo '<div class="rounded rounded-red">That password reset link does not exist.</div>';
  125. }
  126. }
  127. echo '</b></center></body></html>'; ?>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
  133.  
  134. <div id="column2" class="column">
  135. <div class="habblet-container ">
  136. <div class="cbb clearfix red ">
  137. <h2 class="title">About this Page<span style="float: right; font-weight: normal; font-size: 75%;"></span></h2>
  138. <div class="box-content" style="text-align:left;">
  139. You can reset your Fresh password here, providing you know the email address associated with your account. <br /><br />If you don't know your email, you will be unable to reset your password.
  140. </div>
  141. </div>
  142. </div>
  143. <script type="text/javascript">if (!$(document.body).hasClassName('process-template')) { Rounder.init(); }</script>
  144. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement