-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewmail.php
111 lines (90 loc) · 2.63 KB
/
newmail.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
include_once WPR_DIR."/mail.lib.php";
function wpr_newmail()
{
global $wpdb;
if (isset($_POST['subject']))
{
date_default_timezone_set("UTC");
$subject = $_POST['subject'];
$nid = $_POST['newsletter'];
$textbody = trim($_POST['body']);
$htmlbody = trim($_POST['htmlbody']);
$whentosend = $_POST['whentosend'];
$date = $_POST['date'];
$htmlenabled = ($_POST['htmlenabled'] == "on");
$hour = $_POST['hour'];
$timezoneOffset = $_POST['timezoneoffset'];
$min = $_POST['minute'];
if ($whentosend == "now")
$timeToSend = time();
else
{
if (empty($date))
{
$error = "The date field is required";
}
else
{
$sections = explode("/",$date);
$timeToSend = mktime($hour,$min,0,$sections[0],$sections[1],$sections[2]);
$timeToSend = $timeToSend-$timezoneOffset;
}
}
if (!(trim($subject) && trim($textbody)))
{
$error = "Subject and the Text Body are mandatory.";
}
if ($timeToSend < time() && !$error)
{
$error = "The time mentioned is in the past. Please enter a time in the future.";
if ($htmlenabled && !$error)
{
if (empty($htmlbody))
{
$error = "HTML Body is empty. Enter the HTML body of this email";
}
}
}
if (!$htmlenabled)
$htmlbody="";
if (!$error)
{
$query = "insert into ".$wpdb->prefix."wpr_newsletter_mailouts (nid,subject,textbody,htmlbody,time,status) values ('$nid','$subject','$textbody','$htmlbody','$timeToSend',0);";
$wpdb->query($query);
_wpr_mail_sending();
return;
}
}
$param = (object) array(
"nid"=>$nid,
"textbody"=>$textbody,
"subject"=>$subject,
"htmlbody"=>$htmlbody,
"htmlenabled"=>1,
"whentosend"=>$whentosend,
"date" => $date,
"hour"=>$hour,
"minute"=>$min,
"title"=>"New Mail"
);
//There are no newsletters. Ask to create one before sending mailouts
if (Newsletter::whetherNoNewslettersExist()) {
?>
<h2>No Newsletters Found</h2>
You need to create a newsletter before you can send a broadcast.
<?php
return;
}
wpr_mail_form($param,"new",$error);
}
function _wpr_mail_sending($nowOrLater="now")
{
?>
<div class="wrap"><h2>Email Broadcast Scheduled.</h2></div>
The mail broadcast has been scheduled and will be delivered at the specified time.
<p>
<a href="admin.php?page=wpresponder/allmailouts.php" class="button-primary">View All Broadcasts</a> <a href="admin.php?page=wpresponder/wpresponder.php" class="button">Go to Dashboard</a>
</p>
<?php
}