function DoConfirmationEmail() { global $q_stash, $q_email, $q_name, $q_rememberme; if (is_null($q_stash)) { // create a default stashed request $template_data = array('reason_web' => "Log in", 'reason_email' => "Log in to Journalisted", 'reason_email_subject' => 'Log in to Journalisted'); $q_stash = stash_new_request("POST", "/login", null, rabx_serialise($template_data), null); } $token = auth_token_store('login', array('email' => $q_email, 'name' => $q_name, 'stash' => $q_stash)); db_commit(); /* send out a confirmation email */ $url = OPTION_BASE_URL . "/login?t={$token}"; $ex = stash_get_extra($q_stash); $values = rabx_unserialise($ex); $body = "Please click on the link below to confirm your email address.\n" . "{$values['reason_email']}\n" . "\n" . "{$url}\n" . "\n"; $subject = $values['reason_email_subject']; $from_name = "Journalisted"; $from_email = OPTION_TEAM_EMAIL; if (!OPTION_JL_BYPASS_LOGIN_EMAIL) { jl_send_text_email($q_email, $from_name, $from_email, $subject, $body); } return $url; }
function do_generate_token() { $person_id = get_http_var("person_id"); $login_dest = get_http_var("login_dest"); $person = db_getRow("SELECT * FROM person WHERE id=?", get_http_var('person_id')); $template_data = array(); $url = person_make_signon_url(rabx_serialise($template_data), $person['email'], "GET", $login_dest, null); db_commit(); ?> <p>Here is your login link:</p> <p><a href="<?php echo $url; ?> "><?php echo $url; ?> </a></p> <p>(This will log in as <code><?php echo $person['email']; ?> </code> and go the <code><?php echo $login_dest; ?> </code> page)</p> <?php }
function person_signon($template_data, $email = null, $name = null, $person_if_signed_on_function = null) { $P = person_already_signed_on($email, $name, $person_if_signed_on_function); if ($P) { return $P; } /* Get rid of any previous cookie -- if user is logging in again under a * different email, we don't want to remember the old one. */ person_signoff(); if (headers_sent()) { err("Headers have already been sent in person_signon without cookie being present"); } if (array_key_exists('instantly_send_email', $template_data)) { $send_email_part = "&SendEmail=1"; unset($template_data['instantly_send_email']); } else { $send_email_part = ''; } /* No or invalid cookie. We will need to redirect the user via another * page, either to log in or to prove their email address. */ $st = stash_request(rabx_serialise($template_data), $email); db_commit(); if ($email) { $email_part = "&email=" . urlencode($email); } else { $email_part = ""; } if ($name) { $name_part = "&name=" . urlencode($name); } else { $name_part = ""; } header("Location: /login?stash={$st}{$send_email_part}{$email_part}{$name_part}"); exit; }
function do_ComposeWelcomeEmail() { $person_id = get_http_var('person_id'); $journo_id = get_http_var('journo_id'); $emailtext = get_http_var('emailtext'); $subject = get_http_var('subject', "Your journalisted profile"); $journo = db_getRow("SELECT * FROM journo WHERE id=?", $journo_id); $person = db_getRow("SELECT * FROM person WHERE id=?", $person_id); if (!$emailtext) { /* suggested email text */ $firstname = ucwords($journo['firstname']); //$profile_url = OPTION_BASE_URL . "/" . $journo['ref'] . "?login=1"; // generate a link that'll log them in and take them to their profile $template_data = array(); $login_link = person_make_signon_url(rabx_serialise($template_data), $person['email'], "GET", '/' . $journo['ref'], null); db_commit(); $emailtext = <<<EOT Hi {$firstname}, Your account at journalisted has been activated, and you can now edit your profile page at: {$login_link} You can also contact us via Twitter @journalisted Best wishes The journalisted team EOT; } ?> <h3>Send a welcome email to <?php echo h($person['email']); ?> </h3> <p>Let them know their account has been approved...</p> <form method="POST" action="/adm/claims"> <input type="hidden" name="person_id" value="<?php echo h($person_id); ?> " /> <input type="hidden" name="journo_id" value="<?php echo h($journo_id); ?> " /> <label for="subject">subject:</label><br/> <input type="text" id="subject" name="subject" value="<?php echo h($subject); ?> " /> <br/> <label for="emailtext">message:</label><br/> <textarea id="emailtext" name="emailtext" cols="80" rows="15"> <?php echo h($emailtext); ?> </textarea> <input type="hidden" name="action" value="send_welcome_email" /> <br/> <button type="submit">Send This Email</button> </form> <?php }