46 |
$sth = $dbh->query($sql); |
$sth = $dbh->query($sql); |
47 |
CheckError($sth); |
CheckError($sth); |
48 |
|
|
49 |
|
|
50 |
if ($sth->numRows() > 0) { |
if ($sth->numRows() > 0) { |
51 |
|
|
52 |
|
$new_news=0; |
53 |
|
|
54 |
$max_id = 0; |
$max_id = 0; |
55 |
while ($row = $sth->fetchRow()) { |
while ($row = $sth->fetchRow()) { |
56 |
$row[news_type] = $news_type[$row[type]]; |
$row[news_type] = $news_type[$row[type]]; |
57 |
$row[body] = wordwrap(strip_tags($row[body]), 75, "\n"); |
$row[body] = wordwrap(strip_tags($row[body]), 75, "\n"); |
58 |
$data[] = $row; |
$data[] = $row; |
59 |
if ($row[id] > $max_id) $max_id = $row[id]; |
if ($row[id] > $max_id) $max_id = $row[id]; |
60 |
|
$new_news++; |
61 |
} |
} |
62 |
|
|
63 |
$sth->free(); |
$sth->free(); |
64 |
|
|
65 |
$smarty->assign(array( |
$subscribers = 0; |
66 |
"email"=>$email, |
|
67 |
"data"=>$data |
$sql = "select email from news_sub where confirmed is true"; |
68 |
)); |
$sth = $dbh->query($sql); |
69 |
// iso_sendmail_t($smarty->fetch("newsletter_outgoing.tpl")); |
CheckError($sth); |
70 |
print "<pre>".$smarty->fetch("newsletter_outgoing.tpl")."</pre>"; |
|
71 |
|
while ($row = $sth->fetchRow()) { |
72 |
|
$smarty->assign(array( |
73 |
|
"email"=>$row[email], |
74 |
|
"data"=>$data |
75 |
|
)); |
76 |
|
iso_sendmail_t($smarty->fetch("newsletter_outgoing.tpl")); |
77 |
|
# print "<pre>".$smarty->fetch("newsletter_outgoing.tpl")."</pre><hr>"; |
78 |
|
$subscribers++; |
79 |
|
} |
80 |
|
|
81 |
// insert last news sent |
// insert last news sent |
82 |
$sth = $dbh->query("insert into news_sent (id) values ($max_id)"); |
$sth = $dbh->query("insert into news_sent (id) values ($max_id)"); |
83 |
CheckError($sth); |
CheckError($sth); |
84 |
|
|
85 |
|
|
86 |
|
print "sent $new_news news to $subscribers subscribers."; |
87 |
} else { |
} else { |
88 |
print "no news for newsletter to send!"; |
print "no news for newsletter to send!"; |
89 |
} |
} |