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("
From: {$cphp_config->smtp->from}
To: {$to}
Subject: {$subject}

{$text}

{$html}
"); //$mail_transport->send($sMessage); } function generate_urlname($input, $iteration) { $uUrlName = preg_replace("/[ =_+]/", "-", $input); $sUrlName = preg_replace("/[^a-zA-Z0-9-]/", "", $uUrlName); $sUrlName = strtolower($sUrlName); if($iteration > 0) { $sUrlName .= "-" . $iteration; } return $sUrlName; }