Template File Examples:
<?php
class html_template {
public $vars = array();
public function renderTemplate() {
$template = '<br /><br /><br />---------------------------------------------------------<br />
This email was generated from the MM Lite Project Management application.<br />
This email is provided for informational purposes only. Please do not respond to this email.';
return $template;
}
}
?>
<?php
class html_template {
public $vars = array();
public function renderTemplate() {
$template = '<b>Thank you for registering!</b>
<br/ >
<br />
Username: ' . $this->vars["un"] . '<br/>
Password: ' . $this->vars["pw"] . '<br />
<a href="' . $this->vars["link"] . '">Click to Activate Account!</a>';
return $template;
}
}
?>
method that calls template, and email method
public function getTemplateResponse($template = "", $data = array()) {
$template = trim($template);
if ($template != "") {
include_once($this->shared->path . "/templates/" . $template . ".php");
$template = new html_template();
if ($template->vars) {
$template->vars = $data;
} else {}
$value = $template->renderTemplate();
unset($template);
return $value;
}
else {
return false;
}
}
public function sendMail($to, $subject, $message, $headers = array()) {
$messageHeaders = array();
$defaultHeaders = array(
"MIME-Version:" => "1.0",
"Content-type:" => "text/html;charset=iso-8859-1",
"From:" => "MM Lite Project Management Mailer Daemon <noreply@mechanicmatt.com>"
);
foreach ($headers as $k => $v) {
$defaultHeaders[$k] = $v;
}
foreach ($defaultHeaders as $k => $v) {
$messageHeaders[] = $k . " " . $v;
}
$footer = $this->getTemplateResponse("mail/footer");
return mail($to, $subject, $message . $footer, implode("\r\n", $messageHeaders) . "\r\n");
}
The method that starts the process
private function submitRegistration() {
$data = $this->escapeArray($this->shared->request);
$password = $this->generatePassword();
$response = $this->database->query("INSERT INTO todo_users (email, name, username, password, cellphone, enabled, isCreator) VALUES('" . $data["userEml"] . "','" . $data["name"] . "','" . $data["userName"] . "',PASSWORD('" . $password . "'),'" . $data["userCell"] . "','0','" . $data["role"] . "')");
$userID = $this->database->insertid();
if ($response !== false) {
$token = md5(uniqid(rand(), true) . serialize($_REQUEST));
$this->database->query("INSERT INTO todo_tokens (token, userID, expiry) VALUES('" . $token . "','" . $userID . "',DATE_ADD(NOW(), INTERVAL 1 DAY))");
$templateVars = array (
"un" => $this->shared->request["userName"],
"pw" => $password,
"link" => $this->shared->absolute . "index.php?component=registration&task=activate&token=" . $token . "&uid=" . $userID
);
$message = $this->getTemplateResponse("mail/sendActivationLink", $templateVars);
$this->sendMail($this->shared->request["userEml"], "Account Activation", $message);
header("Location: " . $this->shared->absolute . "?component=registration&task=afterReg");
die();
}
else {
$this->highlightError($this->errors->registrationInsertError, "high", "?component=registration");
}
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.