diff --git a/digest.php b/digest.php index a386631..673d5fe 100644 --- a/digest.php +++ b/digest.php @@ -3,7 +3,7 @@ require_once "vendor/autoload.php"; require_once "activethreads.php"; require_once "email.php"; define("MYBB_ROOT", "../"); -define("MYBB_PREFIX", "mybb_"); +define("MYBB_PREFIX", "mybbfo_"); define("FORUM_ID", 0);// 0 means all forums $dsn = 'mysql:host=localhost;dbname=mybb;charset=utf8'; $usr = 'root'; @@ -31,14 +31,12 @@ foreach ($tmp as $row) { unset($tmp); $transport = Swift_SmtpTransport::newInstance($smtp['smtp_host'], $smtp['smtp_port']) ->setUsername($smtp['smtp_user']) - ->setPassword($smtp['smtp_password']); + ->setPassword($smtp['smtp_pass']); $mailer = Swift_Mailer::newInstance($transport); foreach ($users as $user) { $email = $user['email']; - ob_start(); - print_email($user['username'], $url.'/unsubscribe', $threads); - $message = ob_end_flush(); + $message = print_email($user['username'], $url.'/unsubscribe', $threads); $message = Swift_Message::newInstance() ->setSubject('Daily digest') ->setFrom(array('john@doe.com' => 'John Doe')) diff --git a/email.php b/email.php index 93b5c55..1a85acd 100644 --- a/email.php +++ b/email.php @@ -1,5 +1,6 @@ +function print_email($username, $unsubscription, $threads) { + $message = << @@ -7,7 +8,7 @@ function print_email($username, $unsubscription, $threads) { ?> Daily digest from Olympic Business Forum -

,

+

$username,

Here’s a daily update of activity on the Olympic Business forum.

@@ -20,28 +21,34 @@ function print_email($username, $unsubscription, $threads) { ?> Last update - +END; + foreach ($threads as $thread) { + $message .= ' - - - - , - + '.$thread['forumname'].' + '.$thread['subject'].' + '. + $thread['username'].', '. + date('d.m.Y H:m:i', $thread['dateline']).' - - - , - + '.$thread['replies'].' + '. + $thread['lastposter'].', '. + date('d.m.Y H:m:i', $thread['lastpost']).' - + '; + } + $message .= <<

Thank you,
Olympic Business Forum Staff

-

To unsubscribe from these daily digests, click here:

+

To unsubscribe from these daily digests, click here: $unsubscription

- +END; + return $message; +} ?> diff --git a/patch.sql b/patch.sql new file mode 100644 index 0000000..bb490e1 --- /dev/null +++ b/patch.sql @@ -0,0 +1 @@ +ALTER TABLE mybb_users ADD COLUMN isSubscribed TinyInt( 1 ) NOT NULL DEFAULT '1';