? scripts/hash-convert.sh ? scripts/hash-convert.sh.txt ? scripts/password-hash.sh.txt Index: scripts/password-hash.sh =================================================================== RCS file: scripts/password-hash.sh diff -N scripts/password-hash.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ scripts/password-hash.sh 23 Mar 2008 03:14:16 -0000 @@ -0,0 +1,93 @@ +#!/usr/bin/php +" +Example: {$script} "mynewpassword" + +All arguments are long options. + + --help Print this page. + + --root + + Set the working directory for the script to the specified path. + To execute this script this has to be the root directory of your + Drupal installation, e.g. /home/www/foo/drupal (assuming Drupal + running on Unix). Use surrounding quotation marks on Windows. + + "" ["" ["" ...]] + + One or more plan-text passwords enclosed by double quotes. The + output hash may be manually entered into the {users}.pass field to + change a password via SQL to a known value. + +To run this script without the --root argument invoke it from the root directory +of your Drupal installation as + + ./scripts/{$script} +\n +EOF; + exit; +} + +$passwords = array(); + +// Parse invocation arguments. +while ($param = array_shift($_SERVER['argv'])) { + switch ($param) { + case '--root': + // Change the working directory. + $path = array_shift($_SERVER['argv']); + if (is_dir($path)) { + chdir($path); + } + break; + default: + // Add a password to the list to be processed. + $passwords[] = $param; + break; + } +} + +include_once('includes/password.inc'); +include_once('includes/common.inc'); + +foreach ($passwords as $password) { + print("\npassword: $password \t\thash: ". user_hash_password($password) ."\n"); +} +print("\n"); +