1
我想從另一個腳本添加新用戶,我需要爲Drupal7用戶創建密碼,我無法在Drupal上找到確切的功能,這是什麼功能?如何加密drupal 7的密碼
我想從另一個腳本添加新用戶,我需要爲Drupal7用戶創建密碼,我無法在Drupal上找到確切的功能,這是什麼功能?如何加密drupal 7的密碼
使用drupal 7,密碼不再通過md5加密。
有幾種方法可以在drupal7中獲取/設置密碼。
使用drush(爲您的信息,而不是在你的情況下使用):
drush upwd admin --password="newpassword"
沒有drush,如果你有對服務器的訪問CLI:(爲您的信息,在不使用你的情況)
cd <drupal root directory>
php scripts/password-hash.sh 'myPassword'
現在複製結果哈希並將其粘貼到查詢:
update users set name='admin', pass='pasted_big_hash_from_above' where uid=1;
如果您在遠程環境上,您無法連接工作,你可以把這個指定的代碼在一個文件中,如password.php這如一個:
<?php
if (isset($_GET['p'])) {
require_once dirname(__FILE__) . '/includes/bootstrap.inc';
require_once dirname(__FILE__) . '/includes/password.inc';
print _password_crypt('sha512', $_GET['p'], _password_generate_salt(DRUPAL_HASH_COUNT));
exit();
}
print "No password to hash.";
然後打你的網站使用:http://domain.tld/password.php?p='MyPassword'。哈希將出現在您的瀏覽器選項卡上。
一旦完成,不要忘記將其刪除。
所以,如果你想使用一些密碼函數的產生,對_password_crypt()和_password_generate_salt()
非常感謝哈扎看看!這工作。 – Tom 2011-06-05 10:57:40