From 4edf737869324b58ee07502f8f33a9d9cc3d37ee Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sat, 2 Mar 2013 04:13:48 +0100 Subject: [PATCH] Fix autoloader bug, and properly set up SMTP when debug mode is disabled --- public_html/includes/base.php | 45 ++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/public_html/includes/base.php b/public_html/includes/base.php index 78c3a69..a5fdb52 100644 --- a/public_html/includes/base.php +++ b/public_html/includes/base.php @@ -32,7 +32,7 @@ function autoload_redonate($class_name) } } -spl_autoload_register(autoload_redonate); +spl_autoload_register('autoload_redonate'); /* Set global templater variables */ NewTemplater::SetGlobalVariable("logged-in", !empty($_SESSION['user_id'])); @@ -101,6 +101,14 @@ function flash_notice($message) $_SESSION['notices'][] = $message; } +if($cphp_config->debugmode === false) +{ + $smtp = Swift_SmtpTransport::newInstance($cphp_config->smtp->host, $cphp_config->smtp->port) + ->setUsername($cphp_config->smtp->user)->setPassword($cphp_config->smtp->pass); + + $mail_transport = Swift_Mailer::newInstance($smtp); +} + function send_mail($to, $subject, $text, $html) { global $mail_transport, $cphp_config; @@ -111,21 +119,26 @@ function send_mail($to, $subject, $text, $html) $sMessage->setBody($text); $sMessage->addPart($html, "text/html"); - echo("
-
- From: {$cphp_config->smtp->from}
- To: {$to}
- Subject: {$subject} -
-
-
{$text}
-
-
- {$html} -
-
"); - - //$mail_transport->send($sMessage); + if($cphp_config->debugmode) + { + echo("
+
+ From: {$cphp_config->smtp->from}
+ To: {$to}
+ Subject: {$subject} +
+
+
{$text}
+
+
+ {$html} +
+
"); + } + else + { + $mail_transport->send($sMessage); + } } function generate_urlname($input, $iteration)