Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.64 KB | None | 0 0
  1. <?php
  2. ob_start();
  3. session_start();
  4. require_once('functions/load_config.php');
  5. require_once('functions/quick_con.php');
  6. $config = load_config('settings/config.dat');
  7.  
  8. if($_POST['submit'] == 'Reset Password') {
  9.     print "<table width=100% height=100%><tr><td align=center valign=center>";
  10.     $email = ereg_replace("[^A-Za-z0-9@.]","",$_POST['email']);
  11.     $sql = my_quick_con($config) or die("SQL problem");
  12.     $ret = mysql_query("SELECT * FROM $config[users_table] WHERE email='$email';", $sql);
  13.  
  14.     $user = mysql_query("SELECT username FROM $config[users_table] WHERE email='$email';", $sql);
  15.     $user = mysql_fetch_assoc($user);
  16.     $user = $user['username'];
  17.  
  18.  
  19.     if(mysql_num_rows($ret) > 0) {
  20.         $new = "";
  21.         $c_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  22.         srand();
  23.         for($i = 0; $i < 8; $i++) {
  24.             $n = rand() % 25;
  25.             $new .= substr($c_list, $n, 1);
  26.         }
  27.         $new_hash = md5($new);
  28.         $ret = mysql_query("UPDATE users SET password = '$new_hash' WHERE email='$email';", $sql);
  29.  
  30.         $header = "From: no-reply@HvZSource.com \r\n";
  31.         $body  = "Your username is: $user.\n\n";       
  32.         $body .= "Your password has been reset.\n";
  33.         $body .= "Your new password is: $new.\n";
  34.         $body .= "You can change your password in your account page, once you login.\n\n";
  35.         $body .= "Thanks";
  36.         $body .= "The HvZ Robot";
  37.         mail($email, "HvZSource: Password Reset", $body, $header);
  38.         print "<body bgcolor='#000000'><font color='#ffffff'>Your password has been reset.<br>Check your email for your new password.<br><a href='index.php'>Go back Home!</a></font></body>";
  39.     } else {
  40.         print "<body bgcolor='#000000'><font color='#ffffff'>Your email address could not be found.<br>Please email your game administrator.<br><a href='index.php'>Go Back Home!</a> </font></body>";
  41.     }
  42.     mysql_close($sql);
  43.     print "</td></tr></table>";
  44. } else {
  45. include('template_top.php');
  46. ?>
  47. <td>
  48. <h1>Password Reset:</h1>
  49.          <center>
  50. <form method=POST action=<?php echo $PHP_SELF; ?>>
  51. <table>
  52. <tr>
  53.     <td>email address:</td>
  54.     <td><input type='text' name='email' size=20 maxlength=30></td>
  55. </tr>
  56. <tr><td colspan=2 align=center valign=center>
  57.     <input type='submit' name='submit' value='Reset Password'>
  58. </td></tr>
  59. </table>
  60. </form>
  61. </center>
  62. <small>
  63. <ul>
  64. <li>You can use this page to reset your password in case you've forgotten it.</li>
  65. <li><b>Both</b> username <b>and</b> password are case sensitive.</li>
  66. <li>Both username and password can be alphanumeric <b>only</b>. This means that if you did something clever, like making your username "I'm so awesome!" what got saved to the database was "Imsoawesome".</li>
  67. </ul>
  68. </small>
  69. </body>
  70.  
  71. </td>
  72. <?php
  73. }
  74.     include('template_bottom.php');
  75.     ob_end_flush();
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement