SetGlobalVariables(); NewTemplater::SetGlobalVariable("logout-key", $_SESSION['logout_key']); } NewTemplater::RegisterVariableHook("errors", "get_errors"); NewTemplater::RegisterVariableHook("notices", "get_notices"); function get_errors($fetch) { if(isset($_SESSION['errors'])) { $errors = $_SESSION['errors']; if($fetch === true) { /* We only want to clear out errors if a call to * actually retrieve the errors was made, not just * something like an isempty. */ $_SESSION['errors'] = array(); } return $errors; } else { return array(); } } function get_notices($fetch) { if(isset($_SESSION['notices'])) { $notices = $_SESSION['notices']; if($fetch === true) { $_SESSION['notices'] = array(); } return $notices; } else { return array(); } } function flash_error($message) { $_SESSION['errors'][] = $message; } function flash_notice($message) { $_SESSION['notices'][] = $message; } function send_mail($to, $subject, $text, $html) { global $mail_transport, $cphp_config; $sMessage = Swift_Message::newInstance(); $sMessage->setSubject($subject); $sMessage->setTo($to); $sMessage->setFrom($cphp_config->smtp->from); $sMessage->setBody($text); $sMessage->addPart($html, "text/html"); echo("
{$text}