Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php
- <?php
- $users = "
- first_name last_name\temail\tpassword\n
- first_name last_name\temail\tpassword\n
- first_name last_name\temail\tpassword\n
- first_name last_name\temail\tpassword\n
- first_name last_name\temail\tpassword\n
- ";
- define('DRUPAL_ROOT', getcwd());
- $_SERVER['HTTP_HOST'] = 'default';
- $_SERVER['PHP_SELF'] = '/index.php';
- $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
- $_SERVER['SERVER_SOFTWARE'] = NULL;
- $_SERVER['REQUEST_METHOD'] = 'GET';
- $_SERVER['QUERY_STRING'] = '';
- $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
- $_SERVER['HTTP_USER_AGENT'] = 'console';
- include_once DRUPAL_ROOT . '/includes/password.inc';
- include_once DRUPAL_ROOT . './includes/bootstrap.inc';
- drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
- $users = explode("\n", $users);
- foreach ($users as $user)
- {
- if (empty($user))
- {
- continue;
- }
- $user = explode("\t", $user);
- if (count($user) != 3)
- {
- continue;
- }
- $old = user_load_by_mail($user[1]);
- if (!empty($old) && $old->uid)
- {
- continue;
- }
- $obj = new stdClass();
- $obj->name = trim($user[0]);
- $obj->pass = user_hash_password(trim($user[2]));
- $obj->mail = trim($user[1]);
- $obj->theme = 'garland';
- $obj->status = 1;
- $obj->roles = array(
- 2 => 'authenticated user',
- // here is the role list
- // [ROLE_ID] => '[ROLE_NAME]'
- );
- user_save($obj);
- }
- echo 'Done';
Add Comment
Please, Sign In to add comment