PHP Code:
function phpbb_create_account($nick, $password, $email_address) {
if ($this->phpBB['installed'] != true || !zen_not_null($password) || !zen_not_null($email_address) || !zen_not_null($nick)) return false;
if ($this->phpbb_check_for_duplicate_email($email_address) == 'already_exists') {
// $this->phpbb_change_email($old_email, $email_address);
} else {
$sql = "select max(user_id) as total from " . $this->phpBB['users_table'];
$phpbb_users = $this->db_phpbb->Execute($sql);
$user_id = ($phpbb_users->fields['total'] + 1);
// $sql = "insert into " . $this->phpBB['users_table'] . "
// (user_id, username, user_password, user_email, user_regdate)
// values
// ('" . (int)$user_id . "', '" . $nick . "', '" . md5($password) . "', '" . $email_address . "', '" . time() ."')";
$sql = "insert into " . $this->phpBB['users_table'] . "
( username,username_clean, user_password, user_email, user_regdate, user_passchg, group_id, user_permissions, user_sig, user_occ, user_interests, user_email_hash)
values
( '" . $nick . "','" . $nick . "', '" . md5($password) . "', '" . $email_address . "', '" . time() . "', '" . time(). "', 2, '', '', '', '', '" . crc32(strtolower($email_address)) . strlen($email_address) . "')";
$this->db_phpbb->Execute($sql);
//could do a check here to see if Insert_ID() matches $user_id...
$sql = "SELECT user_id, username, user_colour
FROM " . $this->phpBB['users_table'] . "
WHERE user_type IN ('0', '3')
ORDER BY user_id DESC LIMIT 1";
$phpbb_newest_user = $this->db_phpbb->Execute($sql);
$sql = "UPDATE " . $this->phpBB['config_table'] . "
SET config_value = '" . $phpbb_newest_user->fields['user_id'] . "'
WHERE config_name = 'newest_user_id'";
$this->db_phpbb->Execute($sql);
$sql = "UPDATE " . $this->phpBB['config_table'] . "
SET config_value = '" . $phpbb_newest_user->fields['username'] . "'
WHERE config_name = 'newest_username'";
$this->db_phpbb->Execute($sql);
$sql = "UPDATE " . $this->phpBB['config_table'] . "
SET config_value = '" . $phpbb_newest_user->fields['user_colour'] . "'
WHERE config_name = 'newest_user_colour'";
$this->db_phpbb->Execute($sql);
$sql = "UPDATE " . $this->phpBB['config_table'] . "
SET config_value = config_value + 1
WHERE config_name = 'num_users'";
$this->db_phpbb->Execute($sql);
// @TODO: MySQL5
// $sql = "INSERT INTO " . $this->phpBB['groups_table'] . " (group_name, group_desc, group_single_user, group_moderator)
// VALUES (0, 'Personal User', 1, 0)";
// $this->db_phpbb->Execute($sql);
// $group_id = $this->db_phpbb->Insert_ID();
$sql = "INSERT INTO " . $this->phpBB['user_group_table'] . " (user_id, group_id, user_pending)
VALUES ($user_id, 2, 0)";
$this->db_phpbb->Execute($sql);
//might optionally send an extra email welcoming them to the phpBB forum, reminding them of their nickname?
}
}
Bookmarks