Khôi phục mật khẩu trong Drupal 7

Khôi phục mật khẩu trong Drupal 7

It happens to all of us ... we lose our password.

Actually recovering your original password in Drupal 7 is not possible, but resetting one is possible and we're going to show you how to do it.

Your first step should be to try and reset your password by adding this to your site's URL: /user/password/. If that doesn't work or if you don't know the email for the account, then you can use this tutorial.

Drupal 6 vs Drupal 7

Resetting your password was easier in Drupal 6 and is explained in this tutorial.

Drupal 7 uses a more powerful 128bit encryption called sha512. In this tutorial we will show you how to generate the encrypted form of the password, which you an then paste into the data base and change the password "hard" way.

Step 1: Create a short PHP script

This method uses a short PHP script. The code is below. First thing to do is copy this to your clipboard exactly as it's written. Paste this into a text or script editor and then save it with an arbitrary and random name. If you use a plain language name it will give you an error message telling you to rename it with a random string., and be sure to remove this file from your server immediately after you use it. This is a big security risk since anyone accessing this could change your administrator password.

01.<?php
02.define('DRUPAL_ROOT', getcwd());
03.require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
04.drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
05.require_once DRUPAL_ROOT . '/includes/password.inc';
06.if (isset($_GET['pass']) && !empty($_GET['pass'])) {
07.$newhash = user_hash_password($_GET['pass']);
08.}
09.else {
10.die('Retry with ?pass=PASSWORD set in the URL');
11.}
12.$updatepass = db_update('users')
13.->fields(array(
14.'pass' => $newhash,
15.// 'name' => 'admin',
16.// 'mail' => '<a href="mailto:yourmail@example.com'">yourmail@example.com'</a>;
17.))
18.->condition('uid', '1', '=')
19.->execute();
20.print "Done. Please delete this file immediately!";
21.drupal_exit();
22.?>

Step 2: Load the PHP script to your main Drupal Directory

Password Recovery for Drupal 7
  • Paste this in a plain text editor or script editor and save it with the name password.php (you can use any name you want. I just chose an arbitrary name.)
  • Upload this to your Drupal home directory.
  • Rename the file to something totally random.

Step 3: Use the PHP script from your browser address bar

tutuploadsmedia_1339610299149.png
  • Go to http://yoursite.com/totalyrandom.php?pass=mypassword in the address bar of your browser.
  • Replace "mypassword" with whatever you want to use as the password. The script accesses the Drupal password function and changes the password for you.
tutuploadsmedia_1339610953748.png
  • This script can also be used to change the admin username and email as well.
  • In the script itself uncomment the lines that deal with those (lines 19 and 20 in the image above) and change them to what you want. Remove the // marks from the beginning of the line, to uncomment them and make them active.
tutuploadsmedia_1339611105476.png

Here's what they look like with the comment marks removed.

Step 4: Uninstall the PHP script and login

  • One you're done resetting passwords. Be sure to uninstall the php script you created by deleting it using FTP or your file manager.

 

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Tommy Tran

Tommy Tran owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy
  • Phone/Zalo: (+84) 944 225 212
  • WhatsApp: (+84) 944 225 212
  • Line Messenger: (+84) 944 225 212
  • Email: asaleotestf@gmail.com
  • Telegram Messenger: https:/t.me/tommytran0401

Quảng cáo việc làm

 

Thích hợp các bạn nữ mảng thợ may làm việc tại nước NGA

Đơn hàng Tuyển dụng 100 Thợ may đi Nga(đợt 1 tháng 3.2021, đợt 2 tháng 5.2021). Lương thực lãnh 800 USD, bao ăn ở, vé máy bay và visa, phí xuất cảnh(1800 USD)trả khi đi làm có lương. Bạn có thể liên hệ CÔNG TY qua Phone/Zalo: (+84) 944 225 212. Công ty sẽ tư vấn cho bạn.

Xem chi tiết: >>> https://bit.ly/3o9NOfR

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Achieve Rocketship-Fast Jobs in CircleCI by Preinstalling the Database

Sử dụng CircleCI làm environment for testing trong Drupal 8

CircleCI is great at enabling developers to spin up an environment for testing from a set of defined images. When dealing with a website with a database, the usual build process involves downloading a database dump

Hướng dẫn viết module Ajax in Forms trên Drupal 8

Hướng dẫn viết module Ajax in Forms trên Drupal 8

We will be making a simple form which will contain a text field that will validate if the username entered exists, and a button that will replace the text field value with a random existing username.

Loa dock hình viên thuốc cho iPod nano

Loa dock hình viên thuốc cho iPod nano

Đây là mẫu loa dock đầu tiên dành cho iPod nano với kiểu dáng bắt mắt và thiết kế đầy sáng tạo.