-
Notifications
You must be signed in to change notification settings - Fork 28
/
sending.php
205 lines (190 loc) · 6.01 KB
/
sending.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<?php
include('includes/config.php');
include('includes/helpers/locale.php');
//--------------------------------------------------------------//
function dbConnect() { //Connect to database
//--------------------------------------------------------------//
// Access global variables
global $mysqli;
global $dbHost;
global $dbUser;
global $dbPass;
global $dbName;
// Attempt to connect to database server
if(isset($dbPort)) $mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbName, $dbPort);
else $mysqli = new mysqli($dbHost, $dbUser, $dbPass, $dbName);
// If connection failed...
if ($mysqli->connect_error) {
fail("<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/><link rel=\"Shortcut Icon\" type=\"image/ico\" href=\"/img/favicon.png\"><title>"._('Can\'t connect to database')."</title></head><style type=\"text/css\">body{background: #ffffff;font-family: Helvetica, Arial;}#wrapper{background: #f2f2f2;width: 300px;height: 110px;margin: -140px 0 0 -150px;position: absolute;top: 50%;left: 50%;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;}p{text-align: center;line-height: 18px;font-size: 12px;padding: 0 30px;}h2{font-weight: normal;text-align: center;font-size: 20px;}a{color: #000;}a:hover{text-decoration: none;}</style><body><div id=\"wrapper\"><p><h2>"._('Can\'t connect to database')."</h2></p><p>"._('There is a problem connecting to the database. Please try again later.')."</p></div></body></html>");
}
global $charset; mysqli_set_charset($mysqli, isset($charset) ? $charset : "utf8");
return $mysqli;
}
//--------------------------------------------------------------//
function fail($errorMsg) { //Database connection fails
//--------------------------------------------------------------//
echo $errorMsg;
exit;
}
// connect to database
dbConnect();
?>
<?php
$campaign_id = mysqli_real_escape_string($mysqli, $_GET['c']);
$email_list = explode(',', $_GET['e']);
$app = $_GET['i'];
$schedule = $_GET['s'];
$cron = $_GET['cr'];
//Set language
$q = 'SELECT login.language FROM campaigns, login WHERE campaigns.id = '.$campaign_id.' AND login.app = campaigns.app';
$r = mysqli_query($mysqli, $q);
if ($r && mysqli_num_rows($r) > 0) while($row = mysqli_fetch_array($r)) $language = $row['language'];
set_locale($language);
//check if sent
$q = 'SELECT sent FROM campaigns WHERE id = '.$campaign_id;
$r = mysqli_query($mysqli, $q);
if ($r && mysqli_num_rows($r) > 0)
{
while($row = mysqli_fetch_array($r))
{
$sent = stripslashes($row['sent']);
}
}
//if not schedule
if($schedule=='true'):
//get POST variables
$the_date = $_GET['date'];
$timezone = $_GET['timezone'];
$q = 'UPDATE campaigns SET send_date = "'.$the_date.'", lists = "'.$_GET['e'].'", timezone = "'.$timezone.'" WHERE id = '.$campaign_id;
$r = mysqli_query($mysqli, $q);
if($r):
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="Shortcut Icon" type="image/ico" href="<?php echo APP_PATH;?>/img/favicon.png">
<title><?php echo _('Your campaign has been scheduled');?></title>
</head>
<style type="text/css">
body{
background: #ffffff;
font-family: Helvetica, Arial;
}
#wrapper
{
background: #f2f2f2;
width: 280px;
height: 250px;
margin: -190px 0 0 -185px;
position: absolute;
top: 50%;
left: 50%;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 10px 20px;
}
p{
text-align: center;
font-size: 12px;
line-height: 16px;
}
h2{
font-weight: normal;
text-align: center;
}
a{
color: #000;
}
a:hover{
text-decoration: none;
}
#sending{
margin-left: 95px;
}
</style>
<body>
<div id="wrapper">
<h2><?php echo _('Your campaign has been scheduled');?>!</h2>
<img id="sending" src="<?php echo APP_PATH;?>/img/scheduled.jpg" />
<p><?php echo _('You will be notified by email once your campaign has been sent.');?></p>
</div>
</body>
</html>
<?php endif;?>
<?php else:?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="<?php echo APP_PATH;?>/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="<?php echo APP_PATH;?>/js/jquery-migrate-1.1.0.min.js"></script>
<link rel="Shortcut Icon" type="image/ico" href="<?php echo APP_PATH;?>/img/favicon.png">
<title><?php echo _('Now sending');?></title>
<?php if($sent==''):?>
<script type="text/javascript">
$(document).ready(function() {
list = [<?php
for($i=0;$i<count($email_list);$i++)
{
echo "'".$email_list[$i]."'";
if($i<count($email_list)-1)
echo ',';
}
?>];
$.post("<?php echo APP_PATH;?>/includes/create/send-now.php", { campaign_id: <?php echo $campaign_id;?>, email_list: list, app: <?php echo $app;?>, cron: <?php echo $cron;?> },
function(data) {
if(data){}
}
);
});
</script>
<?php endif;?>
</head>
<style type="text/css">
body{
background: #ffffff;
font-family: Helvetica, Arial;
}
#wrapper
{
background: #f2f2f2;
width: 350px;
height: 250px;
margin: -190px 0 0 -185px;
position: absolute;
top: 50%;
left: 50%;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
padding: 10px 20px;
}
p{
text-align: center;
font-size: 12px;
line-height: 16px;
}
h2{
font-weight: normal;
text-align: center;
}
a{
color: #000;
}
a:hover{
text-decoration: none;
}
#sending{
margin-left: 130px;
}
</style>
<body>
<div id="wrapper">
<h2><?php echo _('Your campaign is on the way!');?></h2>
<img id="sending" src="<?php echo APP_PATH;?>/img/sending.jpg" />
<p><?php echo _('You can close this window and your campaign will continue to send. You will be notified by email once your campaign has completed sending.');?></p>
</div>
</body>
</html>
<?php endif;?>