userinfo['userid']) { $message->error(_('Sorry, you are already registered.')); } if (!$bugsys->options['allownewreg']) { $message->error(_('Sorry, we don\'t allow new registrations.')); } if ($bugsys->in['email'] != $bugsys->in['confirmemail']) { $message->add_error(_('The emails you entered do not match.')); } if ($bugsys->in['password'] != $bugsys->in['confirmpassword']) { $message->add_error(_('The passwords you entered did not match.')); } if (!$message->items) { $salt = $funct->rand(15); if ($bugsys->options['verifyemail']) { $usergroupid = 3; } else { if ($bugsys->options['moderatenewusers']) { $usergroupid = 4; } else { $usergroupid = 2; } } $user = new UserAPI($bugsys); $user->set('email', $bugsys->in['email']); $user->set('displayname', $bugsys->in['displayname']); $user->set('password', $bugsys->in['password']); $user->set('showemail', $bugsys->in['showemail']); $user->set('showcolors', 1); $user->set('languageid', $bugsys->in['languageid']); $user->set('usergroupid', $usergroupid); $user->insert(); $userid = $user->insertid; // Verify email address if ($usergroupid == 3) { $activationid = $funct->rand(25); $db->query("INSERT INTO " . TABLE_PREFIX . "useractivation (userid, activator, dateline, usergroupid) VALUES ($userid, '$activationid', " . TIMENOW . ", 2)"); $mail->to_add($bugsys->in['displayname'], $bugsys->in['email']); $mail->set('subject', sprintf(_('Welcome to %1$s'), $bugsys->options['trackertitle'])); $mail->set('bodytext', sprintf(_('Hi %1$s, Welcome to the %2$s tracker. Before you can begin posting bug reports, you\'ll need to activae your account. To do this, please click this link: %3$s/register.php?do=activate&userid=%4$s&activator=%5$s'), $bugsys->in['displayname'], $bugsys->options['trackertitle'], $bugsys->options['trackerurl'], $userid, $activationid )); $mail->send(); $message->message(_('You now need to activate your account via email.')); } else if ($usergroupid == 4 OR $usergroupid == 2) { if ($bugsys->options['sendwelcomemail']) { $mail->to_add($bugsys->in['displayname'], $bugsys->in['email']); $mail->set('subject', sprintf(_('Welcome to %1$s'), $bugsys->options['trackertitle'])); $mail->set('bodytext', sprintf(_('Hi %1$s, Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better. If you have any questions, please don\'t hesitate to contact the webmaster.'), $bugsys->in['displayname'], $bugsys->options['trackertitle'] )); $mail->send(); } if ($usergroupid == 4) { $message->message(_('Your account is pending approval.')); } else { $message->message(_('Thank you for registering. You may now use your account.')); } } } else { $_REQUEST['do'] = ''; $show['errors'] = true; $message->error_list_process(); } } // ################################################################### if (empty($_REQUEST['do'])) { if ($bugsys->userinfo['userid']) { $message->error(_('Sorry, you are already registered.')); } if (!$bugsys->options['allownewreg']) { $message->error(_('Sorry, we don\'t allow new registrations.')); } foreach ($bugsys->datastore['language'] AS $value => $temp) { $label = $temp['title']; $selected = ($value == $bugsys->in['languageid']); eval('$opts .= "' . $template->fetch('selectoption') . '";'); } eval('$template->flush("' . $template->fetch('register') . '");'); } // ################################################################### if ($_REQUEST['do'] == 'activate') { $bugsys->input_clean('userid', TYPE_UINT); if ($useractivation = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "useractivation WHERE userid = " . $bugsys->in['userid'] . " AND activator = '" . $bugsys->in['activator'] . "'")) { $user = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = " . $bugsys->in['userid']); $db->query("UPDATE " . TABLE_PREFIX . "user SET usergroupid = $useractivation[usergroupid] WHERE userid = " . $bugsys->in['userid']); $db->query("DELETE FROM " . TABLE_PREFIX . "useractivation WHERE userid = " . $bugsys->in['userid']); if ($bugsys->options['sendwelcomemail']) { $mail->to_add($user['displayname'], $user['email']); $mail->set('subject', sprintf(_('Welcome to %1$s'), $bugsys->options['trackertitle'])); $mail->set('bodytext', sprintf(_('Hi %1$s, Thank you for taking the time to register at %2$s. We look forward to your contributations to making our products better. If you have any questions, please don\'t hesitate to contact the webmaster.'), $user['displayname'], $bugsys->options['trackertitle'] )); $mail->send(); } $message->message(_('Your account is now activated and you can now login.')); } else { $message->error(_('Sorry, we could not match your registration string. Please make sure you entered the correct URL.')); } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>