change_password.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. class ChangePassword
  3. {
  4. public function dispatch()
  5. {
  6. //print_r($_SERVER);
  7. if (empty($_GET['v'])) {
  8. return $this->renderError('General error');
  9. }
  10. $key = $_GET['v'];
  11. $real_key = sha1($_SERVER['HTTP_USER_AGENT'].$_SERVER['REMOTE_ADDR']);
  12. $key_sha1 = substr($key, 0, 10) . substr($key, 20, strlen($key));
  13. $stamp = substr($key, 10, 10);
  14. $allowed = time() - 60 * 5; // - 5 mins
  15. if (strcmp($real_key, $key_sha1) != 0) {
  16. return $this->renderError('Invalid keys');
  17. }
  18. /*if ($stamp < $allowed) {
  19. return $this->renderError('Key is expired');
  20. }*/
  21. $this->showResetForm();
  22. print $key_sha1 . "<br />" . $real_key;
  23. }
  24. public function showResetForm()
  25. {
  26. print <<<HTML
  27. <form action="" >
  28. <input type="hidden" name="action" value="change" />
  29. <label>Enter secret code:</label>
  30. <input type="text" name="secret_code" value="" />
  31. <label>Enter new password:</label>
  32. <input type="text" name="secret_code" value="" />
  33. </form>
  34. HTML;
  35. }
  36. public function renderError($message)
  37. {
  38. print <<<HTML
  39. {$message}
  40. HTML;
  41. }
  42. }
  43. $changePassword = new ChangePassword();
  44. $changePassword->dispatch();
  45. ?>