|
Page 1 of 1
|
alexlehm
Joined: March 2010
Posts: 4
|
 Function To Mass-register User Accounts?
Version: 13053a new install
I have just started using Icy Phoenix to build an internal forum that I want to use for our development department.
To get the project going, I started creating user accounts for the people instead of having everybody register themselves and I would like to automate this in some way.
Assuming that I have CSV file with necessary data, can the user creation process be automated? Either by inserting the records directly into the database or by calling a xml-rpc or something similar?
If this is not possible currently, would it be feasible to create a batch registration process?
bye, Alexander
|
#1 Wed 03 Mar, 2010 21:31 |
|
Sponsors

|
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.
|
|
Mighty Gorgon 
Luca Libralato
Joined: August 2006
Posts: 7192
Location:  Borgo San Michele
|
 Re: Function To Mass-register User Accounts?
I have created a file for doing that a while ago... but never tested it on live websites and IP 1.3.
You can have a try and let us know.
<?php
/**
*
* @package Icy Phoenix
* @version $Id$
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/GPL-license.php GNU Public License
*
*/
define('CTRACKER_DISABLED', true);
define('IN_ICYPHOENIX', true);
if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
include(IP_ROOT_PATH . 'common.' . PHP_EXT);
// Start session management
$userdata = session_pagestart($user_ip);
init_userprefs($userdata);
// End session management
die('Decomment me!!!');
@set_time_limit(0);
//@ignore_user_abort(true);
@ini_set('memory_limit', '64M');
$users_start = request_var('us', 0);
$users_step = request_var('up', 50);
$users_data = array();
/*
$users_data[] = array(
'username' => 'username',
'user_password' => 'password',
'user_email' => 'email',
'user_style' => 1;
'user_lang' => 'english',
'user_timezone' => '0.00',
'user_dateformat' => 'Y/m/d - H:i',
);
$users_data[] = array(
0 => 'username',
1 => 'password',
2 => 'email',
3 => 'user_style',
4 => 'lang',
5 => 'user_timezone',
6 => 'user_dateformat',
);
CSV Example:
"User 01","pwd01","user01@user01.com",1,"english","0.00","Y/m/d - H:i"
"User 02","pwd02","user02@user01.com",1,"english","0.00","Y/m/d - H:i"
"User 03","pwd03","user03@user01.com",1,"english","0.00","Y/m/d - H:i"
*/
$users_counter = 0;
$handle = fopen('users_to_add.csv', 'r');
while (($data = fgetcsv($handle, 0, ',')) !== false)
{
$num = sizeof($data);
for ($c = 0; $c < $num; $c++)
{
$users_data[$users_counter][$c] = $data[$c];
}
$users_counter++;
}
fclose($handle);
//include($phpbb_root_path . 'users_to_add.' . $phpEx);
$users_list = '';
$total_users = sizeof($users_data);
$users_this_step = min($users_start + $users_step, $total_users);
$users_this_step = ($users_this_step == 0) ? $total_users : $users_this_step;
$new_start = $users_start;
include(IP_ROOT_PATH . 'includes/class_users.' . PHP_EXT);
$users_class = new class_users();
$users_fields_name = array('username', 'user_password', 'user_email', 'user_style', 'user_lang', 'user_timezone', 'user_dateformat');
for ($i = $users_start; $i < $users_this_step; $i++)
{
$users_fields_values = array($users_data[$i][0], $users_data[$i][1], $users_data[$i][2], $config['default_style'], $config['default_lang'], $config['board_timezone'], $config['default_dateformat']);
for ($j = 0; $j < sizeof($users_fields_name); $j++)
{
$users_data[$i][$j] = (empty($users_data[$i][$j])) ? $users_fields_values[$j] : $users_data[$i][$j];
$users_data[$i][$users_fields_name[$j]] = $users_fields_values[$j];
unset($users_data[$i][$j]);
}
$action_result = $users_class->create_user($users_data[$i]['username'], $users_data[$i]['user_password'], $users_data[$i]['user_email'], $users_data[$i]['user_style'], $users_data[$i]['user_lang'], $users_data[$i]['user_dateformat'], $users_data[$i]['user_timezone'], true, true);
if ($action_result)
{
$users_list .= (($users_list == '') ? '' : ', ') . $users_data[$i]['username'];
}
$new_start++;
}
$message_text = 'The following users have been added to the DB:<br /><br />' . $users_list;
if ($new_start >= $total_users)
{
$message = 'All users have been imported correctly!<br /><br />' . $message_text;
$template->assign_vars(array(
'MESSAGE_TITLE' => $meta_content['page_title'],
'MESSAGE_TEXT' => $message,
)
);
full_page_generation('message_body.tpl', 'Users Import', '', '');
}
else
{
$redirect_url = append_sid('users_add.' . PHP_EXT . '?us=' . $new_start . '&up=' . $users_step);
meta_refresh(3, $redirect_url);
$message = 'The process is not finished yet, this page will redirect automatically in few seconds, please wait...<br /><br />' . $message_text;
message_die(GENERAL_MESSAGE, $message);
}
exit;
?>
____________ Luca
SEARCH is the quickest way to get support.
Icy Phoenix ColorizeIt - CustomIcy - HON
|
#2 Thu 25 Mar, 2010 11:09 |
|
|
Page 1 of 1
|
Was this topic useful?
Was this topic useful?
Link this topic |
URL |
|
BBCode |
|
HTML |
|
You cannot post new topics You cannot reply to topics You cannot edit your posts You cannot delete your posts You cannot vote in polls You cannot attach files You can download files You cannot post calendar events
|
|
|
|