/ Published in: PHP
Basic sample courtesy of John Martin @ www.bigspring.co.uk/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* take the following script and modify the connection details and query to suit your needs */ // function to generate salt function genRandomPassword($length = 32) { $salt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $makepass = ''; for ($i = 0; $i < $length; $i ++) { } return $makepass; } // connection // FILL IN YOUR DATABASE DETAILS HERE $hostname = "yourhost"; $database = "db_name"; $username = "db_user"; $password = "db_pass"; $site = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR); // run query // QUERY TO RETURN USER IDS OF ALL 'registgered' usertypes (gid = 18) $query = "SELECT * FROM jos_users WHERE gid <= '18'"; echo "You're resetting ". $num_rows ." passwords"; do { //generate salt $salt = genRandomPassword(); // update $query_update = "UPDATE jos_users SET password = '" . md5(stripslashes("NEW-PASSWORD").$salt) .':'.$salt . "' WHERE id = " . $row_result['id']; echo $query_update."<br />"; ?>
URL: http://www.bigspring.co.uk/research-blog/batch-creation-of-joomla-passwords