-
Notifications
You must be signed in to change notification settings - Fork 0
/
db-sanitization-admin.php
31 lines (30 loc) · 1.03 KB
/
db-sanitization-admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
// Don't ever sanitize the database on the live environment. Doing so would
// destroy the canonical version of the data.
if (defined('PANTHEON_ENVIRONMENT') && (PANTHEON_ENVIRONMENT !== 'live')) {
// Bootstrap Drupal using the same technique as is in index.php.
define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']);
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
if (file_exists($_ENV['HOME'] . "/code/dev-admin-pass.txt")) {
$secret = file_get_contents($_ENV['HOME'] . '/code/dev-admin-pass.txt');
}
else {
$secret = $_ENV['PANTHEON_SITE'];
}
$hashthepass = 'Password1!-' . $secret;
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
$hashthepass = user_hash_password(trim($hashthepass));
// Abort if the hashing failed and returned FALSE.
if (!$hashthepass) {
return FALSE;
}
else {
db_update('users')
->fields(array(
'pass' => $hashthepass
))
->condition('uid', '1')
->execute();
}
}