I make the site not on the drupal, and you need to make the user login. Database from Dryupal 7. How to encrypt the password for verification?
Drupal 7
If the drupal is installed and the engine itself works, then something like this can be done:
we connect drupal
$path_to_drupal = "/var/www/DRUPAL_FOLDER"; define('DRUPAL_ROOT', $path_to_drupal); //устанавливаем константу DRUPAL_ROOT так как она используется в бутстрап require_once dirname(__FILE__) . '/includes/bootstrap.inc';//подключаем сам бутстрап require_once dirname(__FILE__) . '/includes/password.inc';// в этом файле собраны все функции для работы с паролями drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); // стартуем друпал Next, select from the user base
$query = db_select('users', 'u'); $query ->condition('u.uid', 0, '<>') ->fields('u', array('uid', 'pass')); $result = $query->execute(); We pull password hashes and compare with what came from the form
foreach ($result as $users) { $stored_hash = $users->pass; $new_pass = $_POST['form_password_field'];// тут то, что пришло с формы $hash = _password_crypt('sha512', $new_pass, $stored_hash); if ($hash && $stored_hash == $hash) { echo 'PASSWORD CORRECTLY'; } else { echo 'YOU WRONG'; } } If the drupal is not installed, but you need to use its user base, then from /includes/password.inc rewrite the _password_crypt and user_check_password , substituting our variables.
salt is in the configuration file settings.php
Source: https://ru.stackoverflow.com/questions/242280/
All Articles