-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinclude_sendmails.php
More file actions
80 lines (71 loc) · 2.95 KB
/
Copy pathinclude_sendmails.php
File metadata and controls
80 lines (71 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
*
* @module Forum
* @version 0.5.10
* @authors Julian Schuh, Bernd Michna, "Herr Rilke", Dietrich Roland Pehlke (last)
* @license GNU General Public License
* @platform 2.8.x
* @requirements PHP 5.6.x and higher
*
*/
if(!defined('WB_PATH')) {
exit("Cannot access this file directly");
}
/*
$res = $database->query('SELECT COUNT(*) as total FROM '.TABLE_PREFIX.'mod_forum_post WHERE threadid = ' . $thread['threadid'] );
$_count = $res->fetchRow();
$_pages = ceil($_count['total'] / SHOWTHREAD_PERPAGE);
*/
$sql = 'SELECT DISTINCT (u.email),u.display_name
FROM '.TABLE_PREFIX.'mod_forum_post p
INNER JOIN '.TABLE_PREFIX.'users u ON(p.userid = u.user_id)
WHERE threadid = ' . $thread['threadid'] .'
AND u.email <> "' . (isset($_SESSION['EMAIL']) ? $_SESSION['EMAIL'] : "") .'" ';
$res = $database->query($sql);
$poster = $author = isset($_SESSION['USERNAME']) && $_SESSION['USERNAME'] !='' ? $_SESSION['USERNAME'] : $MOD_FORUM['TXT_GUEST_F'];
$mails_ok = 0;
$mails_error = 0;
$mail_subject = WEBSITE_TITLE . ': ' . $MOD_FORUM['TXT_MAILSUBJECT_NEW_POST'];
$arr_search = array('##THREAD##', '##LINK##');
$_link = WB_URL . '/modules/forum/thread_view.php?goto='. $id['id'];
$arr_replace = array(trim($_POST['title']), $_link);
if( isset($res) AND $res->numRows() > 0)
{
$mail_body = str_replace($arr_search, $arr_replace , $MOD_FORUM['TXT_MAILTEXT_NEW_POST'] );
while(FORUM_SENDMAILS_ON_NEW_POSTS && $row = $res->fetchRow())
{
$_body = str_replace('##USERNAME##', $row['display_name'], $mail_body);
$_body = str_replace('##POSTER##', $poster, $mail_body);
//$wb->mail($fromaddress, $toaddress, $mail_subject, $mail_body, $fromname='')
if ($row['email'] != FORUM_ADMIN_INFO_ON_NEW_POSTS)
$versand = $wb->mail(FORUM_MAIL_SENDER, $row['email'], $mail_subject, $_body, FORUM_MAIL_SENDER_REALNAME);
if ($versand) {
$mails_ok ++;
}else{
$mails_error ++;
}
}
}// if $res
// notification to admin on new posts if address is given
if (strpos(FORUM_ADMIN_INFO_ON_NEW_POSTS,'@') !== false && (!isset($_SESSION['EMAIL']) || FORUM_ADMIN_INFO_ON_NEW_POSTS != $_SESSION['EMAIL'])) {
$admin_name = "ADMIN";
$sql = 'SELECT display_name FROM '.TABLE_PREFIX.'users WHERE email = "' . FORUM_ADMIN_INFO_ON_NEW_POSTS .'"';
$res = $database->query($sql);
while($row = $res->fetchRow()) {
$admin_name = $row['display_name'];
}
$mail_body = str_replace($arr_search, $arr_replace , $MOD_FORUM['TXT_MAILTEXT_NEW_POST_ADMIN'] );
$mail_body = str_replace('##USERNAME##', $admin_name, $mail_body);
$_body = str_replace('##POSTER##', $poster, $mail_body);
$versand = $wb->mail(FORUM_MAIL_SENDER, FORUM_ADMIN_INFO_ON_NEW_POSTS, $mail_subject, $_body, FORUM_MAIL_SENDER_REALNAME);
if ($versand) {
$mails_ok ++;
}else{
$mails_error ++;
}
}
if ($mails_ok || $mails_error)
$mailing_result = '<br/>' . $mails_ok . $MOD_FORUM['TXT_MAILS_SEND_F'] . '<br/>' . $mails_error . $MOD_FORUM['TXT_MAIL_ERRORS_F'];
// die ($tmp);
// die( htmlentities( nl2br($debug) ));