-
Notifications
You must be signed in to change notification settings - Fork 7
/
autoresponders-emails.php
228 lines (208 loc) · 9.52 KB
/
autoresponders-emails.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php include('includes/header.php');?>
<?php include('includes/login/auth.php');?>
<?php include('includes/ares/main.php');?>
<?php include('includes/helpers/short.php');?>
<?php
if(get_app_info('is_sub_user'))
{
if(get_app_info('app')!=get_app_info('restricted_to_app'))
{
echo '<script type="text/javascript">window.location="'.get_app_info('path').'/autoresponders-emails?i='.get_app_info('restricted_to_app').'&a='.$_GET['a'].'"</script>';
exit;
}
}
?>
<script type="text/javascript" src="<?php echo get_app_info('path')?>/js/fancybox/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo get_app_info('path')?>/js/fancybox/jquery.fancybox.css" media="screen" />
<script type="text/javascript" src="<?php echo get_app_info('path');?>/js/validate.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//iframe preview
$(".iframe-preview").click(function(e) {
e.preventDefault();
$.fancybox.open({
href : $(this).attr("href"),
type : 'iframe',
padding : 0
});
});
});
</script>
<div class="row-fluid">
<div class="span2">
<?php include('includes/sidebar.php');?>
</div>
<div class="span10">
<div class="row-fluid">
<div class="span12">
<div>
<p class="lead"><?php echo get_app_data('app_name');?></p>
</div>
<h2><?php echo _('Autoresponder emails');?></h2><?php echo _('For');?>: <span class="label label-info"><?php echo get_ares_data('name');?></span> <span>(<?php echo get_ares_type_name('type');?>)</span>
</div>
</div>
<br/><br/>
<a href="<?php echo get_app_info('path')?>/autoresponders-create?i=<?php echo get_app_info('app')?>&a=<?php echo $_GET['a']?>" title="" class="btn"><i class="icon icon-plus"></i> <?php echo _('Add a new email to this autoresponder');?></a>
<br/><br/>
<div class="row-fluid">
<div class="span12 ares">
<table class="table ares-email-table table-striped responsive">
<thead>
<tr>
<th><?php echo _('Send');?></th>
<th><?php echo _('Email');?></th>
<th><?php echo _('Sent');?></th>
<th><?php echo _('Unique Opens');?></th>
<th><?php echo _('Unique Clicks');?></th>
</tr>
</thead>
<tbody>
<?php
$q = 'SELECT * FROM ares_emails WHERE ares_id = '.mysqli_real_escape_string($mysqli, $_GET['a']);
$r = mysqli_query($mysqli, $q);
if ($r && mysqli_num_rows($r) > 0)
{
while($row = mysqli_fetch_array($r))
{
$ares_email_id = $row['id'];
$time_condition = $row['time_condition'];
$title = $row['title'];
$recipients = $row['recipients'];
$opens = $row['opens'];
$from_email = $row['from_email'];
//opens
if($opens=='')
{
$percentage_opened = 0;
$opens_unique = 0;
}
else
{
$opens_array = explode(',', $opens);
$opens_unique = count(array_unique($opens_array));
$percentage_opened = round($opens_unique/$recipients * 100, 2);
}
if($recipients==0 || $recipients=='') $percentage_clicked = round(get_click_percentage($ares_email_id) *100, 2);
else $percentage_clicked = round(get_click_percentage($ares_email_id)/$recipients *100, 2);
//format time condition
if($time_condition=='immediately')
$time_condition = _('On').'<br/><b>'._('sign up').'</b>';
else if($time_condition=='')
{
if(get_ares_data('type')==2)
$time_condition = _('Annually on').'<br/><b>'.get_ares_data('custom_field').'</b>';
else
$time_condition = _('Once on').'<br/><b>'.get_ares_data('custom_field').'</b>';
}
else
{
if(substr($time_condition, 0, 1)=='+')
{
switch(get_ares_data('type'))
{
case 1:
$time_condition_beforeafter = _('after').'<br/><b>'._('signup').'</b>';
break;
default:
$time_condition_beforeafter = _('after').'<br/><b>'.get_ares_data('custom_field').'</b>';
}
}
else
{
switch(get_ares_data('type'))
{
case 1:
$time_condition_beforeafter = _('before').'<br/><b>'._('signup').'</b>';
break;
default:
$time_condition_beforeafter = _('before').'<br/><b>'.get_ares_data('custom_field').'</b>';
}
}
$time_condition = substr($time_condition, 1);
$time_condition_array = explode(' ', $time_condition);
switch($time_condition_array[0])
{
case 1:
$time_condition = '1 '.substr($time_condition_array[1], 0, -1).' '.$time_condition_beforeafter;
break;
default:
$time_condition = $time_condition.' '.$time_condition_beforeafter;
break;
}
}
//tags for subject
preg_match_all('/\[([a-zA-Z0-9!#%^&*()+=$@._-|\/?<>~`"\'\s]+),\s*fallback=/i', $title, $matches_var, PREG_PATTERN_ORDER);
preg_match_all('/,\s*fallback=([a-zA-Z0-9!,#%^&*()+=$@._-|\/?<>~`"\'\s]*)\]/i', $title, $matches_val, PREG_PATTERN_ORDER);
preg_match_all('/(\[[a-zA-Z0-9!#%^&*()+=$@._-|\/?<>~`"\'\s]+,\s*fallback=[a-zA-Z0-9!,#%^&*()+=$@._-|\/?<>~`"\'\s]*\])/i', $title, $matches_all, PREG_PATTERN_ORDER);
$matches_var = $matches_var[1];
$matches_val = $matches_val[1];
$matches_all = $matches_all[1];
for($i=0;$i<count($matches_var);$i++)
{
$field = $matches_var[$i];
$fallback = $matches_val[$i];
$tag = $matches_all[$i];
//for each match, replace tag with fallback
$title = str_replace($tag, $fallback, $title);
}
$title = str_replace('[Email]', $from_email, $title);
?>
<tr id="email-<?php echo $ares_email_id;?>">
<td><?php echo $time_condition;?></td>
<td>
<strong><?php echo $title;?></strong><br/>
<div class="btns">
<ul class="ares_email_options">
<li><a href="<?php echo get_app_info('path')?>/autoresponders-edit?i=<?php echo get_app_info('app')?>&a=<?php echo $_GET['a']?>&ae=<?php echo $ares_email_id?>" title=""><?php echo _('Edit');?></a></li>
<li><a href="<?php echo get_app_info('path');?>/w/<?php echo short($ares_email_id);?>/a?<?php echo time();?>" title="" class="iframe-preview"><?php echo _('Preview');?></a></li>
<li><a href="javascript:void(0)" title="" id="delete-<?php echo $ares_email_id;?>" data-id="<?php echo $ares_email_id;?>"><?php echo _('Delete');?></a></li>
<li><a href="<?php echo get_app_info('path');?>/autoresponders-report.php?i=<?php echo get_app_info('app')?>&a=<?php echo $_GET['a'];?>&ae=<?php echo $ares_email_id; ?>" title=""><?php echo _('View report');?></a></li>
</ul>
<script type="text/javascript">
$("#delete-<?php echo $ares_email_id?>").click(function(e){
e.preventDefault();
c = confirm("<?php echo _('Confirm delete');?> '<?php echo $title;?>'?");
if(c)
{
$.post("<?php echo get_app_info('path')?>/includes/ares/delete-email.php", { id: $(this).data("id") },
function(data) {
if(data)
{
$("#email-<?php echo $ares_email_id;?>").fadeOut();
}
else
{
alert("<?php echo _('Sorry, unable to delete. Please try again later!');?>");
}
}
);
}
});
</script>
</div>
</td>
<td><?php echo $recipients;?></td>
<td><span class="label"><?php echo $percentage_opened;?>%</span> <?php echo number_format($opens_unique);?> <?php echo _('opened');?></td>
<td><span class="label"><?php echo $percentage_clicked;?>%</span> <?php echo number_format(get_click_percentage($ares_email_id));?> <?php echo _('clicked');?></td>
</tr>
<?php
}
}
else
{
echo '
<tr>
<td colspan="5">'._('No autoresponder emails are set up.').'</td>
</tr>
';
}
?>
</tbody>
</table>
<br/>
<a href="<?php echo get_app_info('path');?>/autoresponders-list?i=<?php echo $_GET['i']?>&l=<?php echo get_ares_data('list');?>" title=""><i class="icon icon-chevron-left"></i> <?php echo _('Back to autoresponders list');?></a>
</div>
</div>
</div>
</div>
<?php include('includes/footer.php');?>