forked from slim2000/sendy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscribers.php
634 lines (592 loc) · 26.5 KB
/
subscribers.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
<?php include('includes/header.php');?>
<?php include('includes/login/auth.php');?>
<?php include('includes/subscribers/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').'/list?i='.get_app_info('restricted_to_app').'"</script>';
exit;
}
$q = 'SELECT app FROM lists WHERE id = '.mysqli_real_escape_string($mysqli, $_GET['l']);
$r = mysqli_query($mysqli, $q);
if ($r)
{
while($row = mysqli_fetch_array($r))
{
$a = $row['app'];
}
if($a!=get_app_info('restricted_to_app'))
{
echo '<script type="text/javascript">window.location="'.get_app_info('path').'/list?i='.get_app_info('restricted_to_app').'"</script>';
exit;
}
}
}
//vars
if(isset($_GET['s'])) $s = $_GET['s'];
else $s = '';
if(isset($_GET['c'])) $c = $_GET['c'];
else $c = '';
if(isset($_GET['p'])) $p = $_GET['p'];
else $p = '';
if(isset($_GET['a'])) $a = $_GET['a'];
else $a = '';
if(isset($_GET['u'])) $u = $_GET['u'];
else $u = '';
if(isset($_GET['b'])) $b = $_GET['b'];
else $b = '';
if(isset($_GET['cp'])) $cp = $_GET['cp'];
else $cp = '';
?>
<div class="row-fluid">
<div class="span2">
<?php include('includes/sidebar.php');?>
</div>
<div class="span10">
<div>
<p class="lead"><?php echo get_app_data('app_name');?></p>
</div>
<h2><?php echo _('Subscriber lists');?></h2> <br/>
<button class="btn" onclick="window.location='<?php echo get_app_info('path');?>/update-list?i=<?php echo get_app_info('app');?>&l=<?php echo $_GET['l'];?>'"><i class="icon-plus-sign"></i> <?php echo _('Add subscribers');?></button>
<button class="btn" onclick="window.location='<?php echo get_app_info('path');?>/delete-from-list?i=<?php echo get_app_info('app');?>&l=<?php echo $_GET['l'];?>'"><i class="icon-minus-sign"></i> <?php echo _('Delete subscribers');?></button>
<button class="btn" onclick="window.location='<?php echo get_app_info('path');?>/unsubscribe-from-list?i=<?php echo get_app_info('app');?>&l=<?php echo $_GET['l'];?>'"><i class="icon-ban-circle"></i> <?php echo _('Mass unsubscribe');?></button>
<?php
//export according to which section user is on
if($a=='' && $c=='' && $u=='' && $b=='' && $cp=='')
{
$filter = '';
$filter_val = '';
$export_title = _('all subscribers');
}
else if($a!='')
{
$filter = 'a';
$filter_val = $a;
$export_title = _('active subscribers');
}
else if($c!='')
{
$filter = 'c';
$filter_val = $c;
$export_title = _('unconfirmed subscribers');
}
else if($u!='')
{
$filter = 'u';
$filter_val = $u;
$export_title = _('unsubscribers');
}
else if($b!='')
{
$filter = 'b';
$filter_val = $b;
$export_title = _('bounced subscribers');
}
else if($cp!='')
{
$filter = 'cp';
$filter_val = $cp;
$export_title = _('subscribers who marked your email as spam');
}
?>
<a href="<?php echo get_app_info('path');?>/includes/subscribers/export-csv.php?i=<?php echo get_app_info('app');?>&l=<?php echo $_GET['l'];?>&<?php echo $filter.'='.$filter_val;?>" class="btn" title="<?php echo _('Export');?> <?php echo $export_title;?>"><i class="icon-download-alt"></i> <?php echo _('Export');?></a>
<form class="form-search" action="<?php echo get_app_info('path');?>/subscribers" method="GET" style="float:right;">
<input type="hidden" name="i" value="<?php echo get_app_info('app');?>">
<input type="hidden" name="l" value="<?php echo $_GET['l'];?>">
<?php if($a!=''):?>
<input type="hidden" name="a" value="<?php echo $a;?>">
<?php elseif($c!=''):?>
<input type="hidden" name="c" value="<?php echo $c;?>">
<?php elseif($u!=''):?>
<input type="hidden" name="u" value="<?php echo $u;?>">
<?php elseif($b!=''):?>
<input type="hidden" name="b" value="<?php echo $b;?>">
<?php elseif($cp!=''):?>
<input type="hidden" name="cp" value="<?php echo $cp;?>">
<?php endif;?>
<input type="text" class="input-medium search-query" name="s">
<button type="submit" class="btn"><i class="icon-search"></i> <?php echo _('Search');?></button>
</form>
<br/><br/>
<p class="well"><?php echo _('List');?>: <a href="<?php echo get_app_info('path');?>/subscribers?i=<?php echo get_app_info('app');?>&l=<?php echo $_GET['l'];?>" title=""><span class="label label-info"><?php echo get_lists_data('name', $_GET['l']);?></span></a> | <a href="<?php echo get_app_info('path')?>/list?i=<?php echo get_app_info('app');?>" title=""><?php echo _('Back to lists');?></a>
<a href="<?php echo get_app_info('path');?>/edit-list?i=<?php echo get_app_info('app');?>&l=<?php echo $_GET['l'];?>" style="float:right;"><i class="icon-wrench"></i> <?php echo _('List settings');?></a>
<a href="#subscribeform" style="float:right;margin-right:20px;" data-toggle="modal"><i class="icon-list-alt"></i> <?php echo _('Subscribe form');?></a>
<?php
$q = 'SELECT cron_ares FROM login WHERE id = '.get_app_info('main_userID');
$r = mysqli_query($mysqli, $q);
if ($r)
{
while($row = mysqli_fetch_array($r))
$cron_ares = $row['cron_ares'];
}
if($cron_ares):
?>
<span class="badge" style="float:right;margin:0 20px 0 -15px;"><?php echo get_autoresponder_count();?></span>
<a href="<?php echo get_app_info('path');?>/autoresponders-list?i=<?php echo get_app_info('app');?>&l=<?php echo $_GET['l'];?>" style="float:right;margin-right:20px;"><i class="icon-time"></i> <?php echo _('Autoresponders');?></a>
<?php else:?>
<a href="#ares_cron" style="float:right;margin-right:20px;" data-toggle="modal"><i class="icon-time"></i> <?php echo _('Autoresponders');?></a>
<?php endif;?>
<span class="badge" style="float:right;margin:0 20px 0 -15px;"><?php echo get_custom_fields_count();?></span>
<a href="<?php echo get_app_info('path');?>/custom-fields?i=<?php echo get_app_info('app');?>&l=<?php echo $_GET['l'];?>" style="float:right;margin-right:20px;"><i class="icon-list"></i> <?php echo _('Custom fields');?></a>
</p><br/>
<div id="subscribeform" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3><?php echo _('Subscribe form');?></h3>
</div>
<div class="modal-body">
<p><?php echo _('This is the subscribe form HTML code for');?> <span class="label label-info"><?php echo get_lists_data('name', $_GET['l']);?></span>. <?php echo _('To sign users up programmatically, use our');?> <a href="http://sendy.co/api" style="text-decoration: underline;" target="_blank"><?php echo _('API');?></a>.</p>
<pre>
<form action="<?php echo get_app_info('path');?>/subscribe" method="POST" accept-charset="utf-8">
<label for="name">Name</label><br/>
<input type="text" name="name" id="name"/>
<br/>
<label for="email">Email</label><br/>
<input type="text" name="email" id="email"/><?php
$q = 'SELECT custom_fields FROM lists WHERE id = '.mysqli_real_escape_string($mysqli, $_GET['l']);
$r = mysqli_query($mysqli, $q);
if ($r)
{
while($row = mysqli_fetch_array($r))
{
$custom_fields = $row['custom_fields'];
}
if($custom_fields!='')
{
$custom_fields_array = explode('%s%', $custom_fields);
foreach($custom_fields_array as $cf)
{
$cf_array = explode(':', $cf);
echo '
<br/>
<label for="'.str_replace(' ', '', $cf_array[0]).'">'.$cf_array[0].'</label><br/>
<input type="text" name="'.str_replace(' ', '', $cf_array[0]).'" id="'.str_replace(' ', '', $cf_array[0]).'"/>';
}
}
}
?>
<br/>
<input type="hidden" name="list" value="<?php echo short($_GET['l']);?>"/>
<input type="submit" name="submit" id="submit"/>
</form></pre>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-inverse" data-dismiss="modal"><i class="icon icon-ok-sign"></i> <?php echo _('Okay');?></a>
</div>
</div>
<?php if($s!=''):?>
<p><?php echo _('Keyword');?>: <span class="label"><?php echo $s;?></span></p><br/>
<?php endif;?>
<div class="row-fluid">
<div class="span12">
<div id="container" style="min-height:200px;margin:0 0 30px 0;"></div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<ul class="nav nav-tabs">
<li><a href="<?php echo get_app_info('path')?>/subscribers?i=<?php echo $_GET['i']?>&l=<?php echo $_GET['l']?>" id="all"><?php echo _('All');?> <span class="badge badge-info"><?php echo get_totals('', '');?></span></a></li>
<li><a href="<?php echo get_app_info('path')?>/subscribers?i=<?php echo $_GET['i']?>&l=<?php echo $_GET['l']?>&a=1" id="active"><?php echo _('Active');?> <span class="badge badge-success"><?php echo get_totals('a', '');?></span></a></li>
<li><a href="<?php echo get_app_info('path')?>/subscribers?i=<?php echo $_GET['i']?>&l=<?php echo $_GET['l']?>&c=0" id="unconfirmed"><?php echo _('Unconfirmed');?> <span class="badge"><?php echo get_totals('confirmed', 0);?></span></a></li>
<li><a href="<?php echo get_app_info('path')?>/subscribers?i=<?php echo $_GET['i']?>&l=<?php echo $_GET['l']?>&u=1" id="unsubscribed"><?php echo _('Unsubscribed');?> <span class="badge badge-important"><?php echo get_totals('unsubscribed', 1);?></span></a></li>
<li><a href="<?php echo get_app_info('path')?>/subscribers?i=<?php echo $_GET['i']?>&l=<?php echo $_GET['l']?>&b=1" id="bounced"><?php echo _('Bounced');?> <span class="badge badge-inverse"><?php echo get_totals('bounced', 1);?></span></a></li>
<li><a href="<?php echo get_app_info('path')?>/subscribers?i=<?php echo $_GET['i']?>&l=<?php echo $_GET['l']?>&cp=1" id="complaint"><?php echo _('Marked as spam');?> <span class="badge badge-inverse"><?php echo get_totals('complaint', 1);?></span></a></li>
</ul>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
<?php if($a=='' && $c=='' && $u=='' && $b=='' && $cp==''):?>
$("#all").addClass("tab-active");
<?php elseif($a!=''):?>
$("#active").addClass("tab-active");
<?php elseif($c!=''):?>
$("#unconfirmed").addClass("tab-active");
<?php elseif($u!=''):?>
$("#unsubscribed").addClass("tab-active");
<?php elseif($b!=''):?>
$("#bounced").addClass("tab-active");
<?php elseif($cp!=''):?>
$("#complaint").addClass("tab-active");
<?php endif;?>
$("#single").click(function(){
$("#opt_in").val("0");
});
$("#double").click(function(){
$("#opt_in").val("1");
});
});
</script>
<table class="table table-striped table-condensed responsive">
<thead>
<tr>
<th><?php echo _('Name');?></th>
<th><?php echo _('Email');?></th>
<th><?php echo _('Last activity');?></th>
<th><?php echo _('Status');?></th>
<th><?php echo _('Unsubscribe');?></th>
<th><?php echo _('Delete');?></th>
</tr>
</thead>
<tbody>
<?php
$limit = 20;
$total_subs = totals($_GET['l']);
$total_pages = ceil($total_subs/$limit);
if($p!=null)
{
$offset = ($p-1) * $limit;
}
else
$offset = 0;
if($s=='')
{
if($a=='' && $c=='' && $u=='' && $b=='' && $cp=='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($a!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND confirmed = 1 AND unsubscribed = 0 AND bounced = 0 AND complaint = 0 ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($c!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND confirmed = '.$c.' ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($u!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND unsubscribed = '.$u.' ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($b!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND bounced = '.$b.' ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($cp!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND complaint = '.$cp.' ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
}
else
{
if($a=='' && $c=='' && $u=='' && $b=='' && $cp=='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND (name LIKE "%'.$s.'%" OR email LIKE "%'.$s.'%" OR custom_fields LIKE "%'.$s.'%") ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($a!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND confirmed = 1 AND unsubscribed = 0 AND bounced = 0 AND complaint = 0 AND (name LIKE "%'.$s.'%" OR email LIKE "%'.$s.'%" OR custom_fields LIKE "%'.$s.'%") ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($c!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND confirmed = '.$c.' AND (name LIKE "%'.$s.'%" OR email LIKE "%'.$s.'%" OR custom_fields LIKE "%'.$s.'%") ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($u!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND unsubscribed = '.$u.' AND (name LIKE "%'.$s.'%" OR email LIKE "%'.$s.'%" OR custom_fields LIKE "%'.$s.'%") ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($b!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND bounced = '.$b.' AND (name LIKE "%'.$s.'%" OR email LIKE "%'.$s.'%" OR custom_fields LIKE "%'.$s.'%") ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
else if($cp!='')
$q = 'SELECT * FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND complaint = '.$cp.' AND (name LIKE "%'.$s.'%" OR email LIKE "%'.$s.'%" OR custom_fields LIKE "%'.$s.'%") ORDER BY timestamp DESC LIMIT '.$offset.','.$limit;
}
$r = mysqli_query($mysqli, $q);
if ($r && mysqli_num_rows($r) > 0)
{
while($row = mysqli_fetch_array($r))
{
$id = $row['id'];
$name = stripslashes($row['name']);
$email = stripslashes($row['email']);
$unsubscribed = $row['unsubscribed'];
$bounced = $row['bounced'];
$complaint = $row['complaint'];
$confirmed = $row['confirmed'];
$timestamp = parse_date($row['timestamp'], 'short', true);
if($unsubscribed==0)
$unsubscribed = '<span class="label label-success">'._('Subscribed').'</span>';
else if($unsubscribed==1)
$unsubscribed = '<span class="label label-important">'._('Unsubscribed').'</span>';
if($bounced==1)
$unsubscribed = '<span class="label label-inverse">'._('Bounced').'</span>';
if($complaint==1)
$unsubscribed = '<span class="label label-inverse">'._('Marked as spam').'</span>';
if($confirmed==0)
$unsubscribed = '<span class="label">'._('Unconfirmed').'</span>';
if($name=='')
$name = '['._('No name').']';
echo '
<tr id="'.$id.'">
<td><a href="#subscriber-info" data-id="'.$id.'" data-toggle="modal" class="subscriber-info">'.$name.'</a></td>
<td><a href="#subscriber-info" data-id="'.$id.'" data-toggle="modal" class="subscriber-info">'.$email.'</a></td>
<td>'.$timestamp.'</td>
<td id="unsubscribe-label-'.$id.'">'.$unsubscribed.'</td>
<td>
';
if($row['unsubscribed']==0)
$action_icon = '
<a href="javascript:void(0)" title="'._('Unsubscribe').' '.$email.'" data-action'.$id.'="unsubscribe" id="unsubscribe-btn-'.$id.'">
<i class="icon icon-ban-circle"></i>
</a>
';
else if($row['unsubscribed']==1)
$action_icon = '
<a href="javascript:void(0)" title="'._('Resubscribe').' '.$email.'" data-action'.$id.'="resubscribe" id="unsubscribe-btn-'.$id.'">
<i class="icon icon-ok"></i>
</a>
';
if($row['bounced']==1 || $row['complaint']==1)
$action_icon = '
-
';
if($row['confirmed']==0)
$action_icon = '
<a href="javascript:void(0)" title="'._('Confirm').' '.$email.'" data-action'.$id.'="confirm" id="unsubscribe-btn-'.$id.'">
<i class="icon icon-ok"></i>
</a>
';
echo $action_icon;
echo'
</td>
<td><a href="javascript:void(0)" title="Delete '.$email.'?" id="delete-btn-'.$id.'" class="delete-subscriber"><i class="icon icon-trash"></i></a></td>
<script type="text/javascript">
$("#delete-btn-'.$id.'").click(function(e){
e.preventDefault();
c = confirm("'._('Confirm delete').' '.$email.'?");
if(c)
{
$.post("includes/subscribers/delete.php", { subscriber_id: '.$id.' },
function(data) {
if(data)
{
$("#'.$id.'").fadeOut();
}
else
{
alert("'._('Sorry, unable to delete. Please try again later!').'");
}
}
);
}
});
$("#unsubscribe-btn-'.$id.'").click(function(e){
e.preventDefault();
action = $("#unsubscribe-btn-'.$id.'").data("action'.$id.'");
$.post("includes/subscribers/unsubscribe.php", { subscriber_id: '.$id.', action: action},
function(data) {
if(data)
{
if($("#unsubscribe-label-'.$id.'").text()=="'._('Subscribed').'")
{
$("#unsubscribe-btn-'.$id.'").html("<li class=\'icon icon-ok\'></li>");
$("#unsubscribe-btn-'.$id.'").data("action'.$id.'", "resubscribe");
$("#unsubscribe-label-'.$id.'").html("<span class=\'label label-important\'>'._('Unsubscribed').'</span>");
}
else
{
$("#unsubscribe-btn-'.$id.'").html("<li class=\'icon icon-ban-circle\'></li>");
$("#unsubscribe-btn-'.$id.'").data("action'.$id.'", "unsubscribe");
$("#unsubscribe-label-'.$id.'").html("<span class=\'label label-success\'>'._('Subscribed').'</span>");
}
if($("#unsubscribe-label-'.$id.'").text()=="'._('Unconfirmed').'")
{
$("#unsubscribe-btn-'.$id.'").html("<li class=\'icon icon-ban-circle\'></li>");
$("#unsubscribe-btn-'.$id.'").data("action'.$id.'", "confirm");
$("#unsubscribe-label-'.$id.'").html("<span class=\'label label-success\'>'._('Subscribed').'</span>");
}
}
else
{
alert("'._('Sorry, unable to unsubscribe. Please try again later!').'");
}
}
);
});
</script>
</tr>
';
}
}
else
{
echo '
<tr>
<td>'._('No subscribers found.').'</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
';
}
?>
</tbody>
</table>
<?php pagination($limit);?>
</div>
</div>
<!-- Subscriber info card -->
<div id="subscriber-info" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3><?php echo _('Subscriber info');?></h3>
</div>
<div class="modal-body">
<p id="subscriber-text"></p>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-inverse" data-dismiss="modal"><i class="icon icon-ok-sign" style="margin-top: 5px;"></i> <?php echo _('Close');?></a>
</div>
</div>
<script type="text/javascript">
$(".subscriber-info").click(function(){
s_id = $(this).data("id");
$("#subscriber-text").html("<?php echo _('Fetching');?>..");
$.post("<?php echo get_app_info('path');?>/includes/subscribers/subscriber-info.php", { id: s_id, app:<?php echo get_app_info('app');?> },
function(data) {
if(data)
{
$("#subscriber-text").html(data);
}
else
{
$("#subscriber-text").html("<?php echo _('Oops, there was an error getting the subscriber\'s info. Please try again later.');?>");
}
}
);
});
</script>
<?php
if(!$cron_ares):
$server_path_array = explode('subscribers.php', $_SERVER['SCRIPT_FILENAME']);
$server_path = $server_path_array[0];
?>
<!-- Autoresponder cron instructions -->
<div id="ares_cron" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3><i class="icon icon-time" style="margin-top: 5px;"></i> <?php echo _('Add a cron job for autoresponders');?></h3>
</div>
<div class="modal-body">
<p><?php echo _('To activate autoresponders, add a');?> <a href="http://en.wikipedia.org/wiki/Cron" target="_blank" style="text-decoration:underline"><?php echo _('cron job');?></a> <?php echo _('with the following command.');?></p>
<h3><?php echo _('Command');?></h3>
<pre>php <?php echo $server_path;?>autoresponders.php > /dev/null 2>&1</pre>
<p><?php echo _('This command needs to be run every minute in order to check the database for any autoresponder emails to send. You\'ll need to set your cron job with the following.');?> <br/><em>(<?php echo _('Note that adding cron jobs vary from hosts to hosts, most offer a UI to add a cron job easily. Check your hosting control panel or consult your host if unsure.');?>)</em>.</p>
<h3><?php echo _('Cron job');?></h3>
<pre>*/1 * * * * php <?php echo $server_path;?>autoresponders.php > /dev/null 2>&1</pre>
<p><?php echo _('Once added, wait one minute. If your cron job is functioning correctly, you\'ll see the autoresponder options instead of this modal window when you click on the "Autoresponders" button.');?></p>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-inverse" data-dismiss="modal"><i class="icon icon-ok-sign"></i> <?php echo _('Okay');?></a>
</div>
</div>
<?php endif;?>
<script src="js/highcharts/highcharts.js"></script>
<script type="text/javascript">
var month=new Array();
month[0]="Jan";month[1]="Feb";month[2]="Mar";month[3]="Apr";month[4]="May";month[5]="Jun";month[6]="Jul";month[7]="Aug";month[8]="Sep";month[9]="Oct";month[10]="Nov";month[11]="Dec";
var chart;
$(document).ready(function() {
Highcharts.setOptions({
colors: ['#468847', '#B94A48', '#333333']
});
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'areaspline',
marginBottom: 25
},
title: {
text: false
},
subtitle: {
text: false
},
xAxis: {
categories: [
<?php
$month_array = array();
$year_array = array();
$q = 'SELECT MAX(timestamp) FROM subscribers WHERE list = '.mysqli_real_escape_string($mysqli, $_GET['l']);
$r = mysqli_query($mysqli, $q);
if ($r && mysqli_num_rows($r) > 0)
{
while($row = mysqli_fetch_array($r))
{
$month_max = $row['MAX(timestamp)'];
if($month_max=='')
$month_max = time();
$month = strftime('%m', $month_max)-1;
$year = strftime('%y', $month_max);
}
}
for($i=0;$i<12;$i++)
{
array_push($month_array, $month);
array_push($year_array, $year);
$month--;
if($month<0)
{
$month = 11;
$year--;
}
}
$month_array = array_reverse($month_array);
$year_array = array_reverse($year_array);
for($i=0;$i<12;$i++)
{
echo 'month['.$month_array[$i].']'.'+" '.$year_array[$i].'"';
if($i<11)
echo ',';
}
?>
]
},
yAxis: {
title: {
text: false
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
plotOptions: {
line: {
stacking: 'normal'
},
series: {
marker: {
enabled: false
}
}
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y;
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
series: [{
name: 'Subscribers',
data: [
<?php
$graph_array = array();
$onemonth = 2629746;
$maxmonth = $month_max;
for($i=0;$i<12;$i++)
{
$q = 'SELECT timestamp FROM subscribers WHERE timestamp <= '.$maxmonth.' AND list = '.mysqli_real_escape_string($mysqli, $_GET['l']).' AND unsubscribed=0 AND bounced = 0 AND complaint = 0 AND confirmed = 1';
$r = mysqli_query($mysqli, $q);
if ($r && mysqli_num_rows($r) > 0)
{
array_push($graph_array, mysqli_num_rows($r));
}
else
array_push($graph_array, '0');
$maxmonth = $maxmonth - $onemonth;
}
$graph_array = array_reverse($graph_array);
for($i=0;$i<12;$i++)
{
echo $graph_array[$i];
if($i<11)
echo ',';
}
?>
]
}]
});
});
</script>
<?php include('includes/footer.php');?>