Skip to content

Instantly share code, notes, and snippets.

@kalabro
Created August 16, 2012 14:56
Show Gist options
  • Save kalabro/3370786 to your computer and use it in GitHub Desktop.
Save kalabro/3370786 to your computer and use it in GitHub Desktop.
Drupal 6/7: Auth as first admin if no ssh no Drush no money no honey...
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$user = user_load(1);
if ($user) {
$edit = (array)$user;
list($major_version, ) = explode('.', VERSION);
if ($major_version == '6') {
user_authenticate_finalize($edit);
}
elseif ($major_version == '7') {
user_login_finalize($edit);
}
drupal_set_message("Don't forget to delete " . __FILE__, 'warning');
drupal_goto();
}
else {
echo '<h2>Error.</h2>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment