function register_post(&$a) { $max_dailies = intval(get_config('system', 'max_daily_registrations')); if ($max_dailies) { $r = q("select count(account_id) as total from account where account_created > UTC_TIMESTAMP() - INTERVAL 1 day"); if ($r && $r[0]['total'] >= $max_dailies) { notice(t('Maximum daily site registrations exceeded. Please try again tomorrow.') . EOL); return; } } if (!x($_POST, 'tos')) { notice(t('Please indicate acceptance of the Terms of Service. Registration failed.') . EOL); return; } $policy = get_config('system', 'register_policy'); $email_verify = get_config('system', 'verify_email'); switch ($policy) { case REGISTER_OPEN: $flags = ACCOUNT_OK; break; case REGISTER_APPROVE: $flags = ACCOUNT_BLOCKED | ACCOUNT_PENDING; break; default: case REGISTER_CLOSED: if (!is_site_admin()) { notice(t('Permission denied.') . EOL); return; } $flags = ACCOUNT_BLOCKED; break; } if ($email_verify && $policy == REGISTER_OPEN) { $flags = $flags | ACCOUNT_UNVERIFIED; } if (!$_POST['password'] || $_POST['password'] !== $_POST['password2']) { notice(t('Passwords do not match.') . EOL); return; } $arr = $_POST; $arr['account_flags'] = $flags; $result = create_account($arr); if (!$result['success']) { notice($result['message']); return; } require_once 'include/security.php'; $using_invites = intval(get_config('system', 'invitation_only')); $num_invites = intval(get_config('system', 'number_invites')); $invite_code = x($_POST, 'invite_code') ? notags(trim($_POST['invite_code'])) : ''; if ($using_invites && $invite_code) { q("delete * from register where hash = '%s' limit 1", dbesc($invite_code)); set_pconfig($result['account']['account_id'], 'system', 'invites_remaining', $num_invites); } if ($policy == REGISTER_OPEN) { if ($email_verify) { $res = verify_email_address($result); } else { $res = send_verification_email($result['email'], $result['password']); } if ($res) { info(t('Registration successful. Please check your email for validation instructions.') . EOL); } } elseif ($policy == REGISTER_APPROVE) { $res = send_reg_approval_email($result); if ($res) { info(t('Your registration is pending approval by the site owner.') . EOL); } else { notice(t('Your registration can not be processed.') . EOL); } goaway(z_root()); } if ($email_verify) { goaway(z_root()); } authenticate_success($result['account'], true, false, true); if (!strlen($next_page = get_config('system', 'workflow_register_next'))) { $next_page = 'new_channel'; } $_SESSION['workflow'] = true; goaway(z_root() . '/' . $next_page); }
* LHS Math Club Website * * After users register, they must click a link in a verification email in * order to activate their account. This page sends that email and gives * users the option of resending it. */ require_once '../.lib/functions.php'; restrict_access('E'); if (isset($_GET['code'])) { verify_code(); } else { if (isset($_SESSION['ACCOUNT_do_send_verification_email'])) { send_verification_email(); } else { if (isset($_POST['do_resend_verification_email']) && $_POST['xsrf_token'] == $_SESSION['xsrf_token']) { send_verification_email(); } else { show_page(); } } } /* * show_page($re_sent) * - $re_sent: if the message has just been resent * * Shows a message to users who have not yet verified their email address. */ function show_page() { // Fetch email $email = DB::queryFirstField('SELECT email FROM users WHERE id=%i', $_SESSION['user_id']);