Numerous fixes

- Hyperlinks in the digest
- No deleted, closed or moved threads in the digest
- No "Last update" column for threads with 0 replies
- Changed date format to 17/05/2017
- Set the timzeone explicitly
This commit is contained in:
Alexander Yakovlev 2017-05-09 16:46:02 +07:00
parent fe51385d4a
commit de9ab2aa5f
4 changed files with 14 additions and 8 deletions

View file

@ -17,6 +17,7 @@ function getLatestActiveThreads()
$query = "SELECT DISTINCT $query = "SELECT DISTINCT
`".MYBB_PREFIX."forums`.`fid`, `".MYBB_PREFIX."forums`.`fid`,
`".MYBB_PREFIX."forums`.`name` AS `forumname`, `".MYBB_PREFIX."forums`.`name` AS `forumname`,
`".MYBB_PREFIX."threads`.`tid`,
`".MYBB_PREFIX."threads`.`subject`, `".MYBB_PREFIX."threads`.`subject`,
`".MYBB_PREFIX."threads`.`lastpost`, `".MYBB_PREFIX."threads`.`lastpost`,
`".MYBB_PREFIX."threads`.`username`, `".MYBB_PREFIX."threads`.`username`,
@ -28,6 +29,8 @@ function getLatestActiveThreads()
LEFT JOIN `".MYBB_PREFIX."forums` ON `".MYBB_PREFIX.'forums`.`fid` = `'.MYBB_PREFIX.'threads`.`fid`'." LEFT JOIN `".MYBB_PREFIX."forums` ON `".MYBB_PREFIX.'forums`.`fid` = `'.MYBB_PREFIX.'threads`.`fid`'."
WHERE `".MYBB_PREFIX."threads`.`visible` = 1 WHERE `".MYBB_PREFIX."threads`.`visible` = 1
AND `".MYBB_PREFIX."threads`.`lastpost` > :date AND `".MYBB_PREFIX."threads`.`lastpost` > :date
AND `".MYBB_PREFIX."threads`.`deletetime` = 0
AND `".MYBB_PREFIX."threads`.`closed` = ''
ORDER BY `".MYBB_PREFIX."threads`.`lastpost` DESC ORDER BY `".MYBB_PREFIX."threads`.`lastpost` DESC
"; ";
$query = $pdo->prepare($query); $query = $pdo->prepare($query);

View file

@ -3,8 +3,10 @@ define('MYBB_ROOT', '../');
define('D_PATH', '/digest'); define('D_PATH', '/digest');
define('MYBB_PREFIX', 'mybbfo_'); define('MYBB_PREFIX', 'mybbfo_');
define('FORUM_ID', 0);// 0 means all forums define('FORUM_ID', 0);// 0 means all forums
define('DATE_FORMAT', 'd/M/Y h:i A'); define('DATE_FORMAT', 'd/m/Y h:i A');
define('DRY_RUN', true); define('DRY_RUN', true);
define('DSN', 'mysql:host=localhost;dbname=mybb;charset=utf8'); define('DSN', 'mysql:host=localhost;dbname=mybb;charset=utf8');
define('MYSQL_USER','root'); define('MYSQL_USER','root');
define('MYSQL_PASSWORD', '123456'); define('MYSQL_PASSWORD', '123456');
date_default_timezone_set('UTC+10'); // AEST

View file

@ -47,7 +47,7 @@ foreach ($temp as $row) {
foreach ($users as $user) { foreach ($users as $user) {
$email = $user['email']; $email = $user['email'];
$message = print_email($user['username'], $url.D_PATH.'/unsubscribe.php?email='.$user['email'].'&key='.$user['loginkey'], $threads, $forbidden[$user['usergroup']]); $message = print_email($user['username'], $url.D_PATH.'/unsubscribe.php?email='.$user['email'].'&key='.$user['loginkey'], $threads, $forbidden[$user['usergroup']], $url);
if (DRY_RUN) { if (DRY_RUN) {
echo $message; echo $message;
} }

View file

@ -1,7 +1,7 @@
<?php <?php
// forbidden: forbidden forums IDs // forbidden: forbidden forums IDs
// skips over threads made by this user with 0 replies // skips over threads made by this user with 0 replies
function print_email($username, $unsubscription, $threads, $forbidden) { function print_email($username, $unsubscription, $threads, $forbidden, $url) {
$th_style = "font-family: Arial, Helvetica, sans-serif;padding: 0.5em; border: 1px solid #eee;"; $th_style = "font-family: Arial, Helvetica, sans-serif;padding: 0.5em; border: 1px solid #eee;";
$td_style = "font-family: Arial, Helvetica, sans-serif;padding: 0.5em; border: 1px solid #eee;"; $td_style = "font-family: Arial, Helvetica, sans-serif;padding: 0.5em; border: 1px solid #eee;";
$message = <<<END $message = <<<END
@ -31,19 +31,20 @@ END;
continue; continue;
if ($thread['replies'] === '0' && $thread['username'] === $username) if ($thread['replies'] === '0' && $thread['username'] === $username)
continue; continue;
$lastupdate = $thread['lastposter'].', '.date(DATE_FORMAT, $thread['lastpost']);
if ($thread['replies'] === '0') {
$lastupdate = '&nbsp;';
}
$message .= ' $message .= '
<tr> <tr>
<td style="'.$td_style.'">'.$thread['forumname'].'</td> <td style="'.$td_style.'">'.$thread['forumname'].'</td>
<td style="'.$td_style.'">'.$thread['subject'].'</td> <td style="'.$td_style.'"><a href="'.$url.'/showthread.php?tid='.$thread['tid'].'">'.$thread['subject'].'</a></td>
<td style="'.$td_style.'">'. <td style="'.$td_style.'">'.
$thread['username'].', '. $thread['username'].', '.
date(DATE_FORMAT, $thread['dateline']).' date(DATE_FORMAT, $thread['dateline']).'
</td> </td>
<td style="'.$td_style.'">'.$thread['replies'].'</td> <td style="'.$td_style.'">'.$thread['replies'].'</td>
<td style="'.$td_style.'">'. <td style="'.$td_style.'">'.$lastupdate.'</td>
$thread['lastposter'].', '.
date(DATE_FORMAT, $thread['lastpost']).'
</td>
</tr> </tr>
'; ';
} }