Programmatic password reset

Public

Allows resetting of user password via code; access site with site.com?debug to see a list of users, and site.com?debug&uid=1 to set 'admin' as the password for user id = 1.

Get raw version
php
  1. if (isset($_GET['debug'])) {
  2. $result = db_query("SELECT uid, name, mail, pass, status FROM users");
  3.  
  4. foreach ($result as $row) {
  5. echo '<pre>' . print_r($row, 1) . '</pre>';
  6. }
  7.  
  8. if (isset($_GET['uid'])) {
  9. require './includes/password.inc';
  10.  
  11. $hash = user_hash_password('admin');
  12. db_query("UPDATE users SET pass = :hash, status = 1 WHERE uid = :uid", array(
  13. ':hash' => $hash,
  14. ':uid' => (int) $_GET['uid'],
  15. ));
  16.  
  17. if (isset($_GET['flood'])) {
  18. db_query("TRUNCATE flood");
  19. }
  20. }
  21.  
  22. exit();
  23. }