if (isset($_POST['submit'])) { require_once AC_INCLUDE_PATH . 'classes/DAO/UsersDAO.class.php'; $usersDAO = new UsersDAO(); /* password check: password is verified front end by javascript. here is to handle the errors from javascript */ if ($_POST['password_error'] != "") { $pwd_errors = explode(",", $_POST['password_error']); foreach ($pwd_errors as $pwd_error) { if ($pwd_error == "missing_password") { $missing_fields[] = _AC('password'); } else { $msg->addError($pwd_error); } } } else { if (!isset($_GET['id'])) { $user_id = $usersDAO->Create($_POST['user_group_id'], $_POST['login'], $_POST['form_password_hidden'], $_POST['email'], $_POST['first_name'], $_POST['last_name'], $_POST['status']); if (is_int($user_id) && $user_id > 0) { if (defined('AC_EMAIL_CONFIRMATION') && AC_EMAIL_CONFIRMATION) { $msg->addFeedback('REG_THANKS_CONFIRM'); $code = substr(md5($_POST['email'] . $now . $user_id), 0, 10); $confirmation_link = $_base_href . 'confirm.php?id=' . $user_id . SEP . 'm=' . $code; /* send the email confirmation message: */ require AC_INCLUDE_PATH . 'classes/phpmailer/acheckermailer.class.php'; $mail = new ACheckerMailer(); $mail->From = $_config['contact_email']; $mail->AddAddress($_POST['email']); $mail->Subject = SITE_NAME . ' - ' . _AC('email_confirmation_subject'); $mail->Body = _AC('email_confirmation_message', SITE_NAME, $confirmation_link) . "\n\n"; $mail->Send(); } else { $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
$msg->addError($pwd_error); } } $has_error = true; } //CAPTCHA if (isset($_POST['captcha_in_use']) && $_POST['captcha_in_use']) { $img = new Securimage(); $valid = $img->check($_POST['secret']); if (!$valid) { $has_error = true; $msg->addError('SECRET_ERROR'); } } if (!$has_error) { $user_id = $usersDAO->Create(AC_USER_GROUP_USER, $_POST['login'], $_POST['form_password_hidden'], $_POST['email'], $_POST['first_name'], $_POST['last_name'], ''); if (is_int($user_id) && $user_id > 0) { if (defined('AC_EMAIL_CONFIRMATION') && AC_EMAIL_CONFIRMATION) { $msg->addFeedback('REG_THANKS_CONFIRM'); $code = substr(md5($_POST['email'] . $now . $user_id), 0, 10); $confirmation_link = $_base_href . 'confirm.php?id=' . $user_id . SEP . 'm=' . $code; /* send the email confirmation message: */ require AC_INCLUDE_PATH . 'classes/phpmailer/acheckermailer.class.php'; $mail = new ACheckerMailer(); $mail->From = $_config['contact_email']; $mail->AddAddress($_POST['email']); $mail->Subject = SITE_NAME . ' - ' . _AC('email_confirmation_subject'); $mail->Body = _AC('email_confirmation_message', SITE_NAME, $confirmation_link) . "\n\n"; $mail->Send(); } else { // auto login
$pwd_errors = explode(",", $_POST['password_error']); foreach ($pwd_errors as $pwd_error) { if ($pwd_error == "missing_password") { $missing_fields[] = _AT('password'); } else { $msg->addError($pwd_error); } } } else { if (isset($_POST['is_author'])) { $is_author = 1; } else { $is_author = 0; } if (!isset($_GET['id'])) { $user_id = $usersDAO->Create($_POST['user_group_id'], $_POST['login'], $_POST['form_password_hidden'], $_POST['email'], $_POST['first_name'], $_POST['last_name'], $is_author, $_POST['organization'], $_POST['phone'], $_POST['address'], $_POST['city'], $_POST['province'], $_POST['country'], $_POST['postal_code'], $_POST['status']); if (is_int($user_id) && $user_id > 0) { if (defined('TR_EMAIL_CONFIRMATION') && TR_EMAIL_CONFIRMATION) { $msg->addFeedback('REG_THANKS_CONFIRM'); $code = substr(md5($_POST['email'] . $now . $user_id), 0, 10); $confirmation_link = $_base_href . 'confirm.php?id=' . $user_id . SEP . 'm=' . $code; /* send the email confirmation message: */ require TR_INCLUDE_PATH . 'classes/phpmailer/transformablemailer.class.php'; $mail = new TransformableMailer(); $mail->From = $_config['contact_email']; $mail->AddAddress($_POST['email']); $mail->Subject = SITE_NAME . ' - ' . _AT('email_confirmation_subject'); $mail->Body = _AT('email_confirmation_message', SITE_NAME, $confirmation_link) . "\n\n"; $mail->Send(); } else { $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
} //CAPTCHA if ($_config['use_captcha'] == TR_STATUS_ENABLED) { $img = new Securimage(); $valid = $img->check($_POST['secret']); if (!$valid) { $msg->addError('SECRET_ERROR'); } } if (!$msg->containsErrors()) { if (isset($_POST['is_author'])) { $is_author = 1; } else { $is_author = 0; } $user_id = $usersDAO->Create(TR_USER_GROUP_USER, $_POST['login'], $_POST['form_password_hidden'], $_POST['email'], $_POST['first_name'], $_POST['last_name'], $is_author, $_POST['organization'], $_POST['phone'], $_POST['address'], $_POST['city'], $_POST['province'], $_POST['country'], $_POST['postal_code'], TR_STATUS_ENABLED); if (is_int($user_id) && $user_id > 0) { if (defined('TR_EMAIL_CONFIRMATION') && TR_EMAIL_CONFIRMATION) { $msg->addFeedback('REG_THANKS_CONFIRM'); $code = substr(md5($_POST['email'] . $now . $user_id), 0, 10); $confirmation_link = $_base_href . 'confirm.php?id=' . $user_id . SEP . 'm=' . $code; /* send the email confirmation message: */ require TR_INCLUDE_PATH . 'classes/phpmailer/transformablemailer.class.php'; $mail = new TransformableMailer(); $mail->From = $_config['contact_email']; $mail->AddAddress($_POST['email']); $mail->Subject = SITE_NAME . ' - ' . _AT('email_confirmation_subject'); $mail->Body = _AT('email_confirmation_message', SITE_NAME, $confirmation_link) . "\n\n"; $mail->Send(); } else { // auto login