Joomla批量密码重置!

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Joomla批量密码重置!相关的知识,希望对你有一定的参考价值。

Basic sample courtesy of John Martin @ www.bigspring.co.uk/
  1. <?php
  2.  
  3. /* take the following script and modify the connection details and query to suit your needs */
  4.  
  5. // function to generate salt
  6. function genRandomPassword($length = 32)
  7. {
  8. $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  9. $len = strlen($salt);
  10. $makepass = '';
  11. mt_srand(10000000 * (double) microtime());
  12. for ($i = 0; $i < $length; $i ++) {
  13.  
  14. $makepass .= $salt[mt_rand(0, $len -1)];
  15.  
  16. }
  17.  
  18. return $makepass;
  19. }
  20.  
  21. // connection
  22. // FILL IN YOUR DATABASE DETAILS HERE
  23. $hostname = "yourhost";
  24. $database = "db_name";
  25. $username = "db_user";
  26. $password = "db_pass";
  27.  
  28. $site = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR);
  29. mysql_select_db($database, $site);
  30.  
  31. // run query
  32. // QUERY TO RETURN USER IDS OF ALL 'registgered' usertypes (gid = 18)
  33.  
  34. $query = "SELECT * FROM jos_users WHERE gid <= '18'";
  35.  
  36. $result = mysql_query($query, $site) or die(mysql_error());
  37. $row_result = mysql_fetch_assoc($result);
  38. $num_rows = mysql_num_rows($result);
  39. echo "You're resetting ". $num_rows ." passwords";
  40.  
  41. do {
  42.  
  43.  
  44. //generate salt
  45. $salt = genRandomPassword();
  46.  
  47. // update
  48.  
  49. $query_update = "UPDATE jos_users SET password = '" . md5(stripslashes("NEW-PASSWORD").$salt) .':'.$salt . "' WHERE id = " . $row_result['id'];
  50. $update_result = mysql_query($query_update, $site) or die(mysql_error());
  51. echo $query_update."<br />";
  52.  
  53.  
  54. } while ($row_result = mysql_fetch_assoc($result));
  55.  
  56.  
  57. ?>

以上是关于Joomla批量密码重置!的主要内容,如果未能解决你的问题,请参考以下文章

Joomla 3和VM密码重置重定向到VM寄存器

TSINGSEE青犀视频智能分析开发中大华设备搜索和批量重置密码的代码实现

sql 批量密码重置

CSS Joomla的全局CSS重置

Joomla1.5:模板化片段

如何从片段外部清除/重置地图?