forked from gburton/CE-Phoenix
/
newsletter.php
executable file
·79 lines (65 loc) · 3.38 KB
/
newsletter.php
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
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2002 osCommerce
Released under the GNU General Public License
*/
class newsletter {
var $show_choose_audience, $title, $content;
function __construct($title, $content) {
$this->show_choose_audience = false;
$this->title = $title;
$this->content = $content;
}
function choose_audience() {
return false;
}
function confirm() {
$mail_query = tep_db_query("select count(*) as count from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
$mail = tep_db_fetch_array($mail_query);
$confirm_string = '<table border="0" cellspacing="0" cellpadding="2">' . "\n" .
' <tr>' . "\n" .
' <td class="main"><font color="#ff0000"><strong>' . sprintf(TEXT_COUNT_CUSTOMERS, $mail['count']) . '</strong></font></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="main"><strong>' . $this->title . '</strong></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="main"><tt>' . nl2br($this->content) . '</tt></td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td>' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td>' . "\n" .
' </tr>' . "\n" .
' <tr>' . "\n" .
' <td class="smallText" align="right">' . tep_draw_button(IMAGE_SEND, 'mail-closed', tep_href_link('newsletters.php', 'page=' . $_GET['page'] . '&nID=' . $_GET['nID'] . '&action=confirm_send'), 'primary') . tep_draw_button(IMAGE_CANCEL, 'close', tep_href_link('newsletters.php', 'page=' . $_GET['page'] . '&nID=' . $_GET['nID'])) . '</td>' . "\n" .
' </tr>' . "\n" .
'</table>';
return $confirm_string;
}
function send($newsletter_id) {
$mail_query = tep_db_query("select customers_firstname, customers_lastname, customers_email_address from " . TABLE_CUSTOMERS . " where customers_newsletter = '1'");
$mimemessage = new email(array('X-Mailer: osCommerce'));
// Build the text version
$text = strip_tags($this->content);
if (EMAIL_USE_HTML == 'true') {
$mimemessage->add_html($this->content, $text);
} else {
$mimemessage->add_text($text);
}
$mimemessage->build_message();
while ($mail = tep_db_fetch_array($mail_query)) {
$mimemessage->send($mail['customers_firstname'] . ' ' . $mail['customers_lastname'], $mail['customers_email_address'], '', EMAIL_FROM, $this->title);
}
$newsletter_id = tep_db_prepare_input($newsletter_id);
tep_db_query("update " . TABLE_NEWSLETTERS . " set date_sent = now(), status = '1' where newsletters_id = '" . tep_db_input($newsletter_id) . "'");
}
}
?>