<?php $userid = trim(@$_REQUEST['userid']); $confirmkey = trim(@$_REQUEST['confirmkey']); $user = Model_User::Get($userid); $confirms = new Model_UserConfirm(); $confirms->where('userid = ?', $userid); $confirms->where('confirmkey = ?', $confirmkey); $confirm = $confirms->getFirst(); if ($confirm->exists()) { $user['confirmed'] = 1; $user->save(); $confirm->delete(); Typeframe::Redirect('Your account confirmation is complete. Welcome!', TYPEF_WEB_DIR . '/', 1); } else { Typeframe::Redirect('Confirmation failed.', TYPEF_WEB_DIR . '/', 1); }
$mailer->AddAddress($_POST['email']); $mailer->Subject = 'Your Account Pre-Approval from ' . TYPEF_TITLE; $mailer->Body = $body; $mailer->Send(); } // set flag in template $pm->setVariable('typef_require_approval', true); } elseif (TYPEF_REQUIRE_CONFIRMATION) { // set flag in template $pm->setVariable('typef_require_confirmation', true); // get userid, confirmkey, and set to expire in 3 days $userid = $user->get('userid'); $confirmkey = randomID(); $expire = date('Y-m-d H:i:s', time() + 259200); // create an entry in the user confirmation table $user_confirm = Model_UserConfirm::Create(); $user_confirm->set('confirmkey', $confirmkey); $user_confirm->set('userid', $userid); $user_confirm->set('expire', $expire); $user_confirm->save(); // construct e-mail body $mm = new Pagemill($pm->root()->fork()); $mm->setVariable('username', $user->get('username')); $mm->setVariable('confirmurl', sprintf('http://%s%s/confirm?userid=%d&confirmkey=%s', $_SERVER['HTTP_HOST'], TYPEF_WEB_DIR, $userid, $confirmkey)); $body = str_replace('&', '&', $mm->writeString('<pm:include template="/users/register/confirmation.eml" />', true)); // e-mail the user so they can confirm their registration $mailer = new Mailer(); $mailer->Configure(); $mailer->IsHTML(true); $mailer->AddAddress($_POST['email']); $mailer->Subject = 'Your Account Confirmation from ' . TYPEF_TITLE;