if (!mail_abstraction(array($email), $subject, $body)) { throw new UserError('Failed to send email.'); } $message = 'Email address updated and verification email sent.'; } else { if (isset($_POST['update'])) { if ($_POST['new_email'] !== $_POST['repeat_new_email']) { throw new UserException('The entered email addresses do not match.'); } if ($person['person_email'] === $_POST['new_email']) { throw new UserException('The entered email addresses is the same as the current email address.'); } if ($dal->selectPersonByEmail($_POST['new_email']) !== null) { throw new UserException('The entered email address is already in use.'); } $person['person_email_shared_secret'] = randHex(); $person['person_email'] = $_POST['new_email']; $person['person_email_verified'] = 'n'; $dal->updatePerson($person); $message = 'Email address updated.'; } else { if (isset($_GET['verify'])) { $person['person_email_verified'] = 'y'; $dal->updatePerson($person); $message = 'Email address verified.'; } } } $dal->commit(); } catch (UserException $e) { $dal->rollback();
if (!$_POST['email']) { throw new UserException('Email address not entered.'); } if (strlen($_POST['password']) < 8) { throw new UserException('Password must be at least 8 characters long.'); } if ($_POST['email'] !== $_POST['repeat_email']) { throw new UserException('The entered email addresses do not match.'); } if ($_POST['password'] !== $_POST['repeat_password']) { throw new UserException('The entered passwords do not match.'); } if ($dal->selectPersonByEmail($_POST['email']) !== null) { throw new UserException('The entered email address is already in use.'); } $person = array('person_first_name' => $_POST['first_name'], 'person_last_name' => $_POST['last_name'], 'person_organization' => $_POST['organization'], 'person_email' => $_POST['email'], 'person_subscribe' => isset($_POST['subscribe']) ? 'y' : 'n', 'person_email_verified' => 'n', 'person_email_shared_secret' => randHex()); setPersonPassword($person, $_POST['password']); $dal->insertPerson($person); $url = "http://" . $_SERVER['HTTP_HOST'] . "/register?person_id=" . $person['person_id'] . "&person_email_shared_secret=" . $person['person_email_shared_secret'] . '&verify'; $name = formatPersonName($person); $email = formatPersonEmail($person); $subject = "Register as OpenLCB User"; $body = "Hi {$name},\r\n\r\nYou can verify your email address with the link below.\r\n{$url}\r\n\r\nThe OpenLCB Group"; if (!mail_abstraction(array($email), $subject, $body)) { throw new UserError('Failed to send email.'); } $message = 'Registered and verification email sent.'; } else { if (isset($_GET['verify'])) { $user['person_email_verified'] = 'y'; $dal->updatePerson($user);