Newsletter - Version 3.6.3

Version Description

  • fixed the feed by mail test function
Download this release

Release Info

Developer satollo
Plugin Icon 128x128 Newsletter
Version 3.6.3
Comparing to
See all releases

Code changes from version 3.5.2 to 3.6.3

do/change.php CHANGED
@@ -1,5 +1,8 @@
1
  <?php
2
 
 
 
 
3
  include '../../../../wp-load.php';
4
 
5
  $user = Newsletter::instance()->get_user_from_request(true);
@@ -10,14 +13,16 @@ $url = $_REQUEST['nu'];
10
 
11
  switch ($field) {
12
  case 'sex':
13
- if (!in_array($value, array('f', 'm', 'n'))) die('Invalid sex value');
 
14
  NewsletterUsers::instance()->set_user_field($user->id, 'sex', $value);
15
  break;
16
  // Should be managed by Feed by Mail
17
  case 'feed':
18
  if (isset($value) && ($value === '0' || $value === '1')) {
19
  NewsletterUsers::instance()->set_user_field($user->id, 'feed', $value);
20
- } else die('Invalid feed value');
 
21
  break;
22
  }
23
 
1
  <?php
2
 
3
+ header('Content-Type: text/html;charset=UTF-8');
4
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
5
+ header('Cache-Control: no-cache,no-store,private');
6
  include '../../../../wp-load.php';
7
 
8
  $user = Newsletter::instance()->get_user_from_request(true);
13
 
14
  switch ($field) {
15
  case 'sex':
16
+ if (!in_array($value, array('f', 'm', 'n')))
17
+ die('Invalid sex value');
18
  NewsletterUsers::instance()->set_user_field($user->id, 'sex', $value);
19
  break;
20
  // Should be managed by Feed by Mail
21
  case 'feed':
22
  if (isset($value) && ($value === '0' || $value === '1')) {
23
  NewsletterUsers::instance()->set_user_field($user->id, 'feed', $value);
24
+ } else
25
+ die('Invalid feed value');
26
  break;
27
  }
28
 
do/confirm.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
3
  // Patch to avoid "na" parameter to disturb the call
4
  unset($_REQUEST['na']);
@@ -17,17 +20,17 @@ if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
17
  }
18
  } else {
19
  ?>
20
- <!DOCTYPE html>
21
- <html>
22
- <head>
23
- <script>
24
- location.href = location.href + "&ts=<?php echo time(); ?>";
25
- </script>
26
- </head>
27
- <body>
28
- If you're not redirect in few seconds, <a href="<?php echo $_SERVER['REQUEST_URI']; ?>&ts=<?php echo time(); ?>">click here</a>, thank you.
29
- </body>
30
- </html>
31
- <?php
32
  }
33
  ?>
1
  <?php
2
+ header('Content-Type: text/html;charset=UTF-8');
3
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
4
+ header('Cache-Control: no-cache,no-store,private');
5
  if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
6
  // Patch to avoid "na" parameter to disturb the call
7
  unset($_REQUEST['na']);
20
  }
21
  } else {
22
  ?>
23
+ <!DOCTYPE html>
24
+ <html>
25
+ <head>
26
+ <script>
27
+ location.href = location.href + "&ts=<?php echo time(); ?>";
28
+ </script>
29
+ </head>
30
+ <body>
31
+ If you're not redirect in few seconds, <a href="<?php echo $_SERVER['REQUEST_URI']; ?>&ts=<?php echo time(); ?>">click here</a>, thank you.
32
+ </body>
33
+ </html>
34
+ <?php
35
  }
36
  ?>
do/profile.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  // Patch to avoid "na" parameter to disturb the call
3
  unset($_REQUEST['na']);
4
  unset($_POST['na']);
@@ -9,6 +13,7 @@ unset($_GET['na']);
9
  include '../../../../wp-load.php';
10
 
11
  $user = NewsletterSubscription::instance()->get_user_from_request();
12
- if ($user == null) die('No subscriber found.');
 
13
 
14
  NewsletterSubscription::instance()->show_message('profile', $user);
1
  <?php
2
+
3
+ header('Content-Type: text/html;charset=UTF-8');
4
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
5
+ header('Cache-Control: no-cache,no-store,private');
6
  // Patch to avoid "na" parameter to disturb the call
7
  unset($_REQUEST['na']);
8
  unset($_POST['na']);
13
  include '../../../../wp-load.php';
14
 
15
  $user = NewsletterSubscription::instance()->get_user_from_request();
16
+ if ($user == null)
17
+ die('No subscriber found.');
18
 
19
  NewsletterSubscription::instance()->show_message('profile', $user);
do/save.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  include '../../../../wp-load.php';
3
 
4
  $user = NewsletterSubscription::instance()->save_profile();
1
  <?php
2
+
3
+ header('Content-Type: text/html;charset=UTF-8');
4
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
5
+ header('Cache-Control: no-cache,no-store,private');
6
  include '../../../../wp-load.php';
7
 
8
  $user = NewsletterSubscription::instance()->save_profile();
do/subscribe.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  // Patch to avoid "na" parameter to disturb the call
3
  unset($_REQUEST['na']);
4
  unset($_POST['na']);
@@ -6,10 +9,37 @@ unset($_GET['na']);
6
 
7
  require_once '../../../../wp-load.php';
8
 
9
- $user = NewsletterSubscription::instance()->subscribe();
10
- if ($user->status == 'E') NewsletterSubscription::instance()->show_message('error', $user->id);
11
- if ($user->status == 'C') NewsletterSubscription::instance()->show_message('confirmed', $user->id);
12
- if ($user->status == 'A') NewsletterSubscription::instance()->show_message('already_confirmed', $user->id);
13
- if ($user->status == 'S') NewsletterSubscription::instance()->show_message('confirmation', $user->id);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ?>
15
  Uncorrect status: <?php echo $user->status; ?>
1
  <?php
2
+ header('Content-Type: text/html;charset=UTF-8');
3
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
4
+ header('Cache-Control: no-cache,no-store,private');
5
  // Patch to avoid "na" parameter to disturb the call
6
  unset($_REQUEST['na']);
7
  unset($_POST['na']);
9
 
10
  require_once '../../../../wp-load.php';
11
 
12
+ $module = NewsletterSubscription::instance();
13
+ if (!isset($module->options['antibot'])) $module->options['antibot'] = 0;
14
+
15
+ if ($module->options['antibot'] == 0 || $module->options['antibot'] == 1 && isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
16
+
17
+ $user = NewsletterSubscription::instance()->subscribe();
18
+ if ($user->status == 'E')
19
+ NewsletterSubscription::instance()->show_message('error', $user->id);
20
+ if ($user->status == 'C')
21
+ NewsletterSubscription::instance()->show_message('confirmed', $user->id);
22
+ if ($user->status == 'A')
23
+ NewsletterSubscription::instance()->show_message('already_confirmed', $user->id);
24
+ if ($user->status == 'S')
25
+ NewsletterSubscription::instance()->show_message('confirmation', $user->id);
26
+ }
27
+ else {
28
+ ?><!DOCTYPE html>
29
+ <html>
30
+ <head>
31
+
32
+ </head>
33
+ <body onload="document.getElementById('form').action = '?ts=<?php echo time(); ?>';document.getElementById('form').submit()">
34
+ <form id="form" action="<?php echo plugins_url('newsletter'); ?>/do/dummy.php" method="post">
35
+ <?php foreach ($_REQUEST as $name => $value) { ?>
36
+ <input type="hidden" name="<?php echo esc_attr($name); ?>" value="<?php echo esc_attr($value); ?>">
37
+ <?php } ?>
38
+ </form>
39
+ </body>
40
+ </html>
41
+ <?php
42
+ return;
43
+ }
44
  ?>
45
  Uncorrect status: <?php echo $user->status; ?>
do/unlock.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  // Patch to avoid "na" parameter to disturb the call
3
  unset($_REQUEST['na']);
4
  unset($_POST['na']);
1
  <?php
2
+ header('Content-Type: text/html;charset=UTF-8');
3
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
4
+ header('Cache-Control: no-cache,no-store,private');
5
  // Patch to avoid "na" parameter to disturb the call
6
  unset($_REQUEST['na']);
7
  unset($_POST['na']);
do/unsubscribe.php CHANGED
@@ -1,4 +1,7 @@
1
  <?php
 
 
 
2
  if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
3
  // Patch to avoid "na" parameter to disturb the call
4
  unset($_REQUEST['na']);
@@ -14,18 +17,17 @@ if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
14
  NewsletterSubscription::instance()->show_message('unsubscribed', $user);
15
  }
16
  } else {
17
- ?>
18
- <!DOCTYPE html>
19
- <html>
20
- <head>
21
- <script>
22
- location.href = location.href + "&ts=<?php echo time(); ?>";
23
- </script>
24
- </head>
25
- <body>
26
- If you're not redirect in few seconds, <a href="<?php echo $_SERVER['REQUEST_URI']; ?>&ts=<?php echo time(); ?>">click here</a>, thank you.
27
- </body>
28
- </html>
29
- <?php
30
  }
31
  ?>
1
  <?php
2
+ header('Content-Type: text/html;charset=UTF-8');
3
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
4
+ header('Cache-Control: no-cache,no-store,private');
5
  if (isset($_GET['ts']) && time() - $_GET['ts'] < 30) {
6
  // Patch to avoid "na" parameter to disturb the call
7
  unset($_REQUEST['na']);
17
  NewsletterSubscription::instance()->show_message('unsubscribed', $user);
18
  }
19
  } else {
20
+ ?><!DOCTYPE html>
21
+ <html>
22
+ <head>
23
+ <script>
24
+ location.href = location.href + "&ts=<?php echo time(); ?>";
25
+ </script>
26
+ </head>
27
+ <body>
28
+ If you're not redirect in few seconds, <a href="<?php echo $_SERVER['REQUEST_URI']; ?>&ts=<?php echo time(); ?>">click here</a>, thank you.
29
+ </body>
30
+ </html>
31
+ <?php
 
32
  }
33
  ?>
do/unsubscription.php CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
  // Patch to avoid "na" parameter to disturb the call
3
  unset($_REQUEST['na']);
4
  unset($_POST['na']);
@@ -7,6 +11,7 @@ unset($_GET['na']);
7
  require_once '../../../../wp-load.php';
8
 
9
  $user = NewsletterSubscription::instance()->get_user_from_request();
10
- if ($user == null) die('No subscriber found.');
 
11
  NewsletterSubscription::instance()->show_message('unsubscription', $user);
12
 
1
  <?php
2
+
3
+ header('Content-Type: text/html;charset=UTF-8');
4
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
5
+ header('Cache-Control: no-cache,no-store,private');
6
  // Patch to avoid "na" parameter to disturb the call
7
  unset($_REQUEST['na']);
8
  unset($_POST['na']);
11
  require_once '../../../../wp-load.php';
12
 
13
  $user = NewsletterSubscription::instance()->get_user_from_request();
14
+ if ($user == null)
15
+ die('No subscriber found.');
16
  NewsletterSubscription::instance()->show_message('unsubscription', $user);
17
 
do/view.php CHANGED
@@ -3,6 +3,9 @@
3
  * This is a generic viewer for sent emails. It is not binded to one shot emails, it can display even the emails from
4
  * updates or feed by mail module.
5
  */
 
 
 
6
  include '../../../../wp-load.php';
7
 
8
  // TODO: Change to Newsletter::instance()->get:email(), not urgent
3
  * This is a generic viewer for sent emails. It is not binded to one shot emails, it can display even the emails from
4
  * updates or feed by mail module.
5
  */
6
+ header('Content-Type: text/html;charset=UTF-8');
7
+ header('X-Robots-Tag: noindex,nofollow,noarchive');
8
+ header('Cache-Control: no-cache,no-store,private');
9
  include '../../../../wp-load.php';
10
 
11
  // TODO: Change to Newsletter::instance()->get:email(), not urgent
emails/edit.php CHANGED
@@ -37,6 +37,7 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
37
  $email['message_text'] = $controls->data['message_text'];
38
  $email['subject'] = $controls->data['subject'];
39
  $email['track'] = $controls->data['track'];
 
40
 
41
  // Builds the extended options
42
  $email['options'] = array();
@@ -44,6 +45,7 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
44
  $email['options']['preferences'] = $controls->data['preferences'];
45
  $email['options']['sex'] = $controls->data['sex'];
46
  $email['options']['status'] = $controls->data['status'];
 
47
  $email['options']['wp_users'] = $controls->data['wp_users'];
48
 
49
  $email['options'] = serialize($email['options']);
@@ -57,9 +59,9 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
57
  // Before send, we build the query to extract subscriber, so the delivery engine does not
58
  // have to worry about the email parameters
59
  if ($controls->data['status'] == 'S') {
60
- $query = "select * from " . $wpdb->prefix . "newsletter where status='S'";
61
  } else {
62
- $query = "select * from " . $wpdb->prefix . "newsletter where status='C'";
63
  }
64
 
65
  if ($controls->data['wp_users'] == '1') {
@@ -70,10 +72,11 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
70
  if (is_array($preferences)) {
71
 
72
  // Not set one of the preferences specified
 
73
  if ($controls->data['preferences_status'] == 1) {
74
  $query .= " and (";
75
  foreach ($preferences as $x) {
76
- $query .= "list_" . $x . "=0 or ";
77
  }
78
  $query = substr($query, 0, -4);
79
  $query .= ")";
@@ -81,7 +84,7 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
81
  else {
82
  $query .= " and (";
83
  foreach ($preferences as $x) {
84
- $query .= "list_" . $x . "=1 or ";
85
  }
86
  $query = substr($query, 0, -4);
87
  $query .= ")";
@@ -127,23 +130,23 @@ if ($controls->is_action('test') || $controls->is_action('save') || $controls->i
127
 
128
  if ($controls->is_action('send')) {
129
 
130
- $wpdb->update($wpdb->prefix . 'newsletter_emails', array('status' => 'sending'), array('id' => $email_id));
131
  $email['status'] = 'sending';
132
  $controls->messages .= "Email added to the queue.";
133
  }
134
 
135
  if ($controls->is_action('pause')) {
136
- $wpdb->update($wpdb->prefix . 'newsletter_emails', array('status' => 'paused'), array('id' => $email_id));
137
  $email['status'] = 'paused';
138
  }
139
 
140
  if ($controls->is_action('continue')) {
141
- $wpdb->update($wpdb->prefix . 'newsletter_emails', array('status' => 'sending'), array('id' => $email_id));
142
  $email['status'] = 'sending';
143
  }
144
 
145
  if ($controls->is_action('abort')) {
146
- $wpdb->query("update " . $wpdb->prefix . "newsletter_emails set last_id=0, total=0, sent=0, status='new' where id=" . $email_id);
147
  $email['status'] = 'new';
148
  $email['total'] = 0;
149
  $email['sent'] = 0;
@@ -308,8 +311,10 @@ if ($email['editor'] == 0) {
308
  <tr valign="top">
309
  <th><?php _e('Subscriber preferences', 'newsletter'); ?></th>
310
  <td>
311
- Subscribers with at least one preference
312
- <?php $controls->select('preferences_status', array(0=>'ACTIVE', 1=>'NOT ACTIVE')); ?>
 
 
313
  between the selected ones below:
314
 
315
  <?php $controls->preferences_group('preferences', true); ?>
@@ -364,6 +369,15 @@ if ($email['editor'] == 0) {
364
 
365
  <div id="tabs-d">
366
  <table class="form-table">
 
 
 
 
 
 
 
 
 
367
  <tr valign="top">
368
  <th>Track clicks and message opening?</th>
369
  <td>
37
  $email['message_text'] = $controls->data['message_text'];
38
  $email['subject'] = $controls->data['subject'];
39
  $email['track'] = $controls->data['track'];
40
+ $email['private'] = $controls->data['private'];
41
 
42
  // Builds the extended options
43
  $email['options'] = array();
45
  $email['options']['preferences'] = $controls->data['preferences'];
46
  $email['options']['sex'] = $controls->data['sex'];
47
  $email['options']['status'] = $controls->data['status'];
48
+ $email['options']['status_operator'] = $controls->data['status_operator'];
49
  $email['options']['wp_users'] = $controls->data['wp_users'];
50
 
51
  $email['options'] = serialize($email['options']);
59
  // Before send, we build the query to extract subscriber, so the delivery engine does not
60
  // have to worry about the email parameters
61
  if ($controls->data['status'] == 'S') {
62
+ $query = "select * from " . NEWSLETTER_USERS_TABLE . " where status='S'";
63
  } else {
64
+ $query = "select * from " . NEWSLETTER_USERS_TABLE . " where status='C'";
65
  }
66
 
67
  if ($controls->data['wp_users'] == '1') {
72
  if (is_array($preferences)) {
73
 
74
  // Not set one of the preferences specified
75
+ $operator = $controls->data['preferences_status_operator'] == 0?' or ':' and ';
76
  if ($controls->data['preferences_status'] == 1) {
77
  $query .= " and (";
78
  foreach ($preferences as $x) {
79
+ $query .= "list_" . $x . "=0" . $operator;
80
  }
81
  $query = substr($query, 0, -4);
82
  $query .= ")";
84
  else {
85
  $query .= " and (";
86
  foreach ($preferences as $x) {
87
+ $query .= "list_" . $x . "=1" . $operator;
88
  }
89
  $query = substr($query, 0, -4);
90
  $query .= ")";
130
 
131
  if ($controls->is_action('send')) {
132
 
133
+ $wpdb->update(NEWSLETTER_EMAILS_TABLE, array('status' => 'sending'), array('id' => $email_id));
134
  $email['status'] = 'sending';
135
  $controls->messages .= "Email added to the queue.";
136
  }
137
 
138
  if ($controls->is_action('pause')) {
139
+ $wpdb->update(NEWSLETTER_EMAILS_TABLE, array('status' => 'paused'), array('id' => $email_id));
140
  $email['status'] = 'paused';
141
  }
142
 
143
  if ($controls->is_action('continue')) {
144
+ $wpdb->update(NEWSLETTER_EMAILS_TABLE, array('status' => 'sending'), array('id' => $email_id));
145
  $email['status'] = 'sending';
146
  }
147
 
148
  if ($controls->is_action('abort')) {
149
+ $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set last_id=0, total=0, sent=0, status='new' where id=" . $email_id);
150
  $email['status'] = 'new';
151
  $email['total'] = 0;
152
  $email['sent'] = 0;
311
  <tr valign="top">
312
  <th><?php _e('Subscriber preferences', 'newsletter'); ?></th>
313
  <td>
314
+ Subscribers with
315
+ <?php $controls->select('preferences_status_operator', array(0=>'at least one preference', 1=>'all preferences')); ?>
316
+
317
+ <?php $controls->select('preferences_status', array(0=>'active', 1=>'not active')); ?>
318
  between the selected ones below:
319
 
320
  <?php $controls->preferences_group('preferences', true); ?>
369
 
370
  <div id="tabs-d">
371
  <table class="form-table">
372
+ <tr valign="top">
373
+ <th>Private?</th>
374
+ <td>
375
+ <?php $controls->yesno('private'); ?>
376
+ <div class="hints">
377
+ Potentially used for public showing of a newsletter. Actually has not effects.
378
+ </div>
379
+ </td>
380
+ </tr>
381
  <tr valign="top">
382
  <th>Track clicks and message opening?</th>
383
  <td>
emails/emails.php CHANGED
@@ -19,7 +19,7 @@ class NewsletterEmails extends NewsletterModule {
19
 
20
  function __construct() {
21
  $this->themes = new NewsletterThemes('emails');
22
- parent::__construct('emails', '1.1.0');
23
  }
24
 
25
  function upgrade() {
@@ -31,6 +31,7 @@ class NewsletterEmails extends NewsletterModule {
31
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column token varchar(10) not null default ''");
32
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column visibility");
33
  $this->upgrade_query("update " . NEWSLETTER_EMAILS_TABLE . " set type='message' where type=''");
 
34
 
35
  // Force a token to email without one already set.
36
  $token = self::get_token();
19
 
20
  function __construct() {
21
  $this->themes = new NewsletterThemes('emails');
22
+ parent::__construct('emails', '1.1.1');
23
  }
24
 
25
  function upgrade() {
31
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column token varchar(10) not null default ''");
32
  $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " drop column visibility");
33
  $this->upgrade_query("update " . NEWSLETTER_EMAILS_TABLE . " set type='message' where type=''");
34
+ $this->upgrade_query("alter table " . NEWSLETTER_EMAILS_TABLE . " add column private tinyint(1) not null default 0");
35
 
36
  // Force a token to email without one already set.
37
  $token = self::get_token();
emails/themes/default/images/facebook.png CHANGED
Binary file
emails/themes/default/images/googleplus.png CHANGED
Binary file
emails/themes/default/images/linkedin.png CHANGED
Binary file
emails/themes/default/images/pinterest.png CHANGED
Binary file
emails/themes/default/images/soundcloud.png ADDED
Binary file
emails/themes/default/images/tumblr.png CHANGED
Binary file
emails/themes/default/images/twitter.png CHANGED
Binary file
emails/themes/default/images/youtube.png CHANGED
Binary file
emails/themes/default/social-options.php CHANGED
@@ -32,4 +32,8 @@
32
  <th>YouTube</th>
33
  <td><?php $controls->text_url('theme_youtube', 30); ?></td>
34
  </tr>
 
 
 
 
35
  </table>
32
  <th>YouTube</th>
33
  <td><?php $controls->text_url('theme_youtube', 30); ?></td>
34
  </tr>
35
+ <tr>
36
+ <th>Soundcloud</th>
37
+ <td><?php $controls->text_url('theme_soundcloud', 30); ?></td>
38
+ </tr>
39
  </table>
emails/themes/default/social.php CHANGED
@@ -46,5 +46,11 @@ $social_icon_url = plugins_url('emails/themes/default/images', 'newsletter/plugi
46
  <a href="<?php echo $theme_options['theme_youtube'] ?>"><img src="<?php echo $social_icon_url ?>/youtube.png"><br>Youtube</a>
47
  </td>
48
  <?php } ?>
 
 
 
 
 
 
49
  </tr>
50
  </table>
46
  <a href="<?php echo $theme_options['theme_youtube'] ?>"><img src="<?php echo $social_icon_url ?>/youtube.png"><br>Youtube</a>
47
  </td>
48
  <?php } ?>
49
+
50
+ <?php if (!empty($theme_options['theme_soundcloud'])) { ?>
51
+ <td style="text-align: center; vertical-align: top" align="center" valign="top">
52
+ <a href="<?php echo $theme_options['theme_soundcloud'] ?>"><img src="<?php echo $social_icon_url ?>/soundcloud.png"><br>SoundCloud</a>
53
+ </td>
54
+ <?php } ?>
55
  </tr>
56
  </table>
feed/feed.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * This is only demo code just to make the demo Feed by Mail panel work.
4
  */
@@ -36,12 +37,23 @@ class NewsletterFeed extends NewsletterModule {
36
  require $this->themes->get_file_path($options['theme'], 'theme.php');
37
  $email['message'] = ob_get_clean();
38
 
 
 
 
 
 
 
 
 
 
39
  return $email;
40
  }
41
 
42
  function hook_user_subscribe($user) {
43
- if ($this->options['subscription'] == 1 && isset($_REQUEST['feed'])) $user['feed'] = 1;
44
- if ($this->options['subscription'] == 2) $user['feed'] = 1;
 
 
45
  return $user;
46
  }
47
 
@@ -61,7 +73,8 @@ class NewsletterFeed extends NewsletterModule {
61
  }
62
 
63
  function get_posts($options = null) {
64
- if ($options == null) $options = $this->options;
 
65
 
66
  $excluded_categories = '';
67
  $categories = get_categories();
@@ -72,10 +85,12 @@ class NewsletterFeed extends NewsletterModule {
72
  }
73
 
74
  $max_posts = $options['max_posts'];
75
- if (!is_numeric($max_posts)) $max_posts = 10;
 
76
 
77
  $filters = array('showposts' => $max_posts, 'post_status' => 'publish');
78
- if ($excluded_categories != '') $filters['cat'] = $excluded_categories;
 
79
 
80
  $posts = get_posts($filters);
81
 
@@ -86,6 +101,7 @@ class NewsletterFeed extends NewsletterModule {
86
 
87
  return $posts;
88
  }
 
89
  }
90
 
91
  NewsletterFeed::instance();
1
  <?php
2
+
3
  /**
4
  * This is only demo code just to make the demo Feed by Mail panel work.
5
  */
37
  require $this->themes->get_file_path($options['theme'], 'theme.php');
38
  $email['message'] = ob_get_clean();
39
 
40
+ if (!empty($theme_subject)) {
41
+ $email['subject'] = $theme_subject;
42
+ } else {
43
+ $email['subject'] = trim($options['subject']);
44
+ }
45
+ if (empty($email['subject'])) {
46
+ $email['subject'] = $posts[0]->post_title;
47
+ }
48
+
49
  return $email;
50
  }
51
 
52
  function hook_user_subscribe($user) {
53
+ if ($this->options['subscription'] == 1 && isset($_REQUEST['feed']))
54
+ $user['feed'] = 1;
55
+ if ($this->options['subscription'] == 2)
56
+ $user['feed'] = 1;
57
  return $user;
58
  }
59
 
73
  }
74
 
75
  function get_posts($options = null) {
76
+ if ($options == null)
77
+ $options = $this->options;
78
 
79
  $excluded_categories = '';
80
  $categories = get_categories();
85
  }
86
 
87
  $max_posts = $options['max_posts'];
88
+ if (!is_numeric($max_posts))
89
+ $max_posts = 10;
90
 
91
  $filters = array('showposts' => $max_posts, 'post_status' => 'publish');
92
+ if ($excluded_categories != '')
93
+ $filters['cat'] = $excluded_categories;
94
 
95
  $posts = get_posts($filters);
96
 
101
 
102
  return $posts;
103
  }
104
+
105
  }
106
 
107
  NewsletterFeed::instance();
feed/index.php CHANGED
@@ -36,6 +36,7 @@ else {
36
  }
37
  else {
38
  $email = $module->create_email($controls->data);
 
39
  Newsletter::instance()->send($email, $users);
40
 
41
  $controls->messages = 'Test email sent to: ';
@@ -45,7 +46,7 @@ else {
45
  }
46
 
47
  if ($controls->is_action('delete')) {
48
- $wpdb->query($wpdb->prepare("delete from " . $wpdb->prefix . "newsletter_emails where id=%d", $_POST['btn']));
49
  }
50
 
51
  if ($controls->is_action('reset_time')) {
36
  }
37
  else {
38
  $email = $module->create_email($controls->data);
39
+
40
  Newsletter::instance()->send($email, $users);
41
 
42
  $controls->messages = 'Test email sent to: ';
46
  }
47
 
48
  if ($controls->is_action('delete')) {
49
+ $wpdb->query($wpdb->prepare("delete from " . NEWSLETTER_EMAILS_TABLE . " where id=%d", $_POST['btn']));
50
  }
51
 
52
  if ($controls->is_action('reset_time')) {
includes/controls.php CHANGED
@@ -180,6 +180,11 @@ class NewsletterControls {
180
  $this->checkboxes_group($name, $list);
181
  }
182
 
 
 
 
 
 
183
  function select_group($name, $options) {
184
  $value_array = $this->get_value_array($name);
185
 
@@ -187,8 +192,9 @@ class NewsletterControls {
187
 
188
  foreach ($options as $key => $label) {
189
  echo '<option value="' . $key . '"';
190
- if (array_search($value, $value_array) !== false)
191
  echo ' selected';
 
192
  echo '>' . htmlspecialchars($label) . '</option>';
193
  }
194
 
180
  $this->checkboxes_group($name, $list);
181
  }
182
 
183
+ /** Used to create a select which is part of a group of controls identified by $name that will
184
+ * produce an array of values as $_REQUEST['name'].
185
+ * @param string $name
186
+ * @param array $options Associative array
187
+ */
188
  function select_group($name, $options) {
189
  $value_array = $this->get_value_array($name);
190
 
192
 
193
  foreach ($options as $key => $label) {
194
  echo '<option value="' . $key . '"';
195
+ if (array_search($key, $value_array) !== false) {
196
  echo ' selected';
197
+ }
198
  echo '>' . htmlspecialchars($label) . '</option>';
199
  }
200
 
main/diagnostic.php CHANGED
@@ -37,7 +37,7 @@ if ($controls->is_action('upgrade')) {
37
  NewsletterSubscription::instance()->upgrade();
38
  NewsletterEmails::instance()->upgrade();
39
  NewsletterStatistics::instance()->upgrade();
40
- if (class_exists('NewsletterFollowup')) {
41
  NewsletterFollowup::instance()->upgrade();
42
  }
43
  $controls->messages = 'Upgrade forced!';
@@ -303,45 +303,8 @@ if (empty($controls->data))
303
  If inactive or always in "running now" status your blog has a problem: <a href="http://www.satollo.net/?p=2015" target="_blank">read more here</a>.
304
  </td>
305
  </tr>
306
- <tr>
307
- <td>
308
- Feed by Mail
309
- </td>
310
- <td>
311
- <?php echo NewsletterModule::format_scheduler_time('newsletter_feed'); ?>
312
- <?php //$controls->button('trigger_followup', 'Trigger now'); ?>
313
- <br>
314
- This time is not necessarily when the email will be sent but when Feed by Mail does its check to see if
315
- this is a planned day and if there is something to send.
316
- </td>
317
- </tr>
318
- <tr>
319
- <td>
320
- Follow Up
321
- </td>
322
- <td>
323
- <?php echo NewsletterModule::format_scheduler_time('newsletter_followup'); ?>
324
- <br>
325
- Indicates when the Follow Up system runs again (usually every hour) to check for new follow up to send out.
326
- <?php //$controls->button('trigger_followup', 'Trigger now'); ?>
327
- </td>
328
- </tr>
329
- <tr>
330
- <td>
331
- SendGrid bounce checking
332
- </td>
333
- <td>
334
- <?php echo NewsletterModule::format_scheduler_time('newsletter_sendgrid_bounce'); ?>
335
- </td>
336
- </tr>
337
- <tr>
338
- <td>
339
- MailJet bounce checking
340
- </td>
341
- <td>
342
- <?php echo NewsletterModule::format_scheduler_time('newsletter_mailjet_bounce'); ?>
343
- </td>
344
- </tr>
345
  </tbody>
346
  </table>
347
  </div>
37
  NewsletterSubscription::instance()->upgrade();
38
  NewsletterEmails::instance()->upgrade();
39
  NewsletterStatistics::instance()->upgrade();
40
+ if (method_exists('NewsletterFollowup', 'upgrade')) {
41
  NewsletterFollowup::instance()->upgrade();
42
  }
43
  $controls->messages = 'Upgrade forced!';
303
  If inactive or always in "running now" status your blog has a problem: <a href="http://www.satollo.net/?p=2015" target="_blank">read more here</a>.
304
  </td>
305
  </tr>
306
+
307
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  </tbody>
309
  </table>
310
  </div>
main/index.php CHANGED
@@ -12,11 +12,6 @@ if ($controls->is_action('feed_disable')) {
12
  update_option('newsletter_feed_demo_disable', 1);
13
  $controls->messages = 'Feed by Mail demo panel disabled. On next page reload it will disappear.';
14
  }
15
-
16
- if ($controls->is_action('check_versions')) {
17
- $newsletter->hook_check_versions();
18
- $controls->messages = 'Module versions updated';
19
- }
20
  ?>
21
  <div class="wrap main-index">
22
 
@@ -26,7 +21,7 @@ if ($controls->is_action('check_versions')) {
26
 
27
  <div id="newsletter-title">
28
  <h2>Welcome and Support</h2>
29
- <p>
30
  With my horrible English, everything can be found starting from <a href="http://www.satollo.net/plugins/newsletter" target="_blank">Newsletter Official page</a>
31
  and every configuration panel has some included documentation just to avoid the most common mistakes.
32
  </p>
@@ -103,137 +98,15 @@ if ($controls->is_action('check_versions')) {
103
  </li>
104
  </ol>
105
 
106
- <h3>Modules</h3>
107
  <p>
108
- Below is the list of available modules that can be used with Newsletter plugin. Some modules are the "core" part
109
- of Newsletter and are automatically updated with Newsletter official updates. Other modules are <strong>extensions</strong> and
110
- can be downloaded from <a href="http://www.satollo.net/downloads" target="_blank">www.satollo.net/downloads</a>.
111
- <br>
112
- Extensions must be installed in the folder wp-content/extensions/newsletter.
 
113
  </p>
114
-
115
- <table class="widefat" style="width: auto">
116
- <thead>
117
- <tr>
118
- <th>Module</th>
119
- <th>Version</th>
120
- <th>Available version</th>
121
- </tr>
122
- </thead>
123
- <!-- TODO: Should be a cicle of installed modules -->
124
- <tbody>
125
- <tr>
126
- <td>
127
- <a href="http://www.satollo.net/plugins/newsletter/reports-module" target="_blank">Reports</a>
128
- <br><small>Extends the statistics system with a better report</small>
129
- </td>
130
- <?php if (class_exists('NewsletterReports')) { ?>
131
- <td><?php echo NewsletterReports::instance()->version; ?></td>
132
- <?php } else { ?>
133
- <td>Not installed</td>
134
- <?php } ?>
135
- <td><?php echo get_option('newsletter_reports_available_version'); ?></td>
136
- </tr>
137
- <tr>
138
- <td>
139
- <a href="http://www.satollo.net/plugins/newsletter/feed-by-mail-module" target="_blank">Feed by Mail (Demo)</a>
140
- <br><small>Demostrative panels of the Feed by Mail module</small>
141
- </td>
142
- <?php if (get_option('newsletter_feed_demo_disable') != 1) { ?>
143
- <td><?php $controls->button('feed_disable', 'Disable'); ?></td>
144
- <?php } else { ?>
145
- <td><?php $controls->button('feed_enable', 'Enable'); ?></td>
146
- <?php } ?>
147
- <td>&nbsp;</td>
148
- </tr>
149
- <tr>
150
- <td>
151
- <a href="http://www.satollo.net/plugins/newsletter/feed-by-mail-module" target="_blank">Feed by Mail</a>
152
- <br><small>Automatically generate and send email with blog contents</small>
153
- </td>
154
- <?php if (NewsletterModule::extension_exists('feed') && class_exists('NewsletterFeed')) { ?>
155
- <td><?php echo NewsletterFeed::instance()->version; ?></td>
156
- <?php } else { ?>
157
- <td>Not installed</td>
158
- <?php } ?>
159
- <td><?php echo get_option('newsletter_feed_available_version'); ?></td>
160
- </tr>
161
- <tr>
162
- <td>
163
- <a href="http://www.satollo.net/plugins/newsletter/follow-up-module" target="_blank">Follow Up</a>
164
- <br><small>Sends email series after a subscriber signs up</small>
165
- </td>
166
- <?php if (NewsletterModule::extension_exists('followup') && class_exists('NewsletterFollowup')) { ?>
167
- <td><?php echo NewsletterFollowup::instance()->version; ?></td>
168
- <?php } else { ?>
169
- <td>Not installed</td>
170
- <?php } ?>
171
- <td><?php echo get_option('newsletter_followup_available_version'); ?></td>
172
- </tr>
173
- <tr>
174
- <td>
175
- <a href="http://www.satollo.net/plugins/newsletter/facebook-up-module" target="_blank">Facebook</a>
176
- <br><small>Newsletter sign up (easy) with Facebook</small>
177
- </td>
178
- <?php if (class_exists('NewsletterFacebook')) { ?>
179
- <td><?php echo NewsletterFacebook::instance()->version; ?></td>
180
- <?php } else { ?>
181
- <td>Not installed</td>
182
- <?php } ?>
183
- <td><?php echo get_option('newsletter_facebook_available_version'); ?></td>
184
- </tr>
185
- <tr>
186
- <td>
187
- <a href="http://www.satollo.net/plugins/newsletter/sendgrid-module" target="_blank">SendGrid</a>
188
- <br><small>Integrates with <a href="http://www.satollo.net/affiliate/sendgrid" target="_blank">SendGrid</a> SMTP and bounce report</small>
189
- </td>
190
- <?php if (class_exists('NewsletterSendgrid')) { ?>
191
- <td><?php echo NewsletterSendgrid::instance()->version; ?></td>
192
- <?php } else { ?>
193
- <td>Not installed</td>
194
- <?php } ?>
195
- <td><?php echo get_option('newsletter_sendgrid_available_version'); ?></td>
196
- </tr>
197
- <tr>
198
- <td>
199
- <a href="http://www.satollo.net/plugins/newsletter/mandrill-module" target="_blank">Mandrill</a>
200
- <br><small>Integrates with <a href="http://www.mandrill.com/" target="_blank">Mandrill by Mailchimp</a> SMTP and bounce report (experimental)</small>
201
- </td>
202
- <?php if (class_exists('NewsletterMandrill')) { ?>
203
- <td><?php echo NewsletterMandrill::instance()->version; ?></td>
204
- <?php } else { ?>
205
- <td>Not installed</td>
206
- <?php } ?>
207
- <td><?php echo get_option('newsletter_mandrill_available_version'); ?></td>
208
- </tr>
209
- <tr>
210
- <td>
211
- <a href="http://www.satollo.net/plugins/newsletter/popup-module" target="_blank">Popup</a>
212
- <br><small>A very simple subscription popup (experimental)</small>
213
- </td>
214
- <?php if (class_exists('NewsletterPopup')) { ?>
215
- <td><?php echo NewsletterPopup::instance()->version; ?></td>
216
- <?php } else { ?>
217
- <td>Not installed</td>
218
- <?php } ?>
219
- <td><?php echo get_option('newsletter_popup_available_version'); ?></td>
220
- </tr>
221
- <tr>
222
- <td>
223
- <a href="http://www.satollo.net/plugins/newsletter/mailjet-module" target="_blank">MailJet</a>
224
- <br><small>Integrates with MailJet SMTP service.
225
- </td>
226
- <?php if (class_exists('NewsletterMailjet')) { ?>
227
- <td><?php echo NewsletterMailjet::instance()->version; ?></td>
228
- <?php } else { ?>
229
- <td>Not installed</td>
230
- <?php } ?>
231
- <td><?php echo get_option('newsletter_mailjet_available_version'); ?></td>
232
- </tr>
233
- </tbody>
234
- </table>
235
-
236
- <?php $controls->button('check_versions', 'Check for new versions'); ?>
237
 
238
  <h3>Support</h3>
239
  <p>
@@ -247,13 +120,6 @@ if ($controls->is_action('check_versions')) {
247
  <li>Write directly to me at stefano@satollo.net</li>
248
  </ul>
249
 
250
- <h3>Collaboration</h3>
251
- <p>
252
- Any kind of collaboration for this free plugin is welcome (of course). I set up a
253
- <a href="http://www.satollo.net/plugins/newsletter/newsletter-collaboration" target="_blank">How to collaborate</a>
254
- page.
255
- </p>
256
-
257
  <h3>Documentation</h3>
258
  <p>
259
  Below are the pages on www.satollo.net which document Newsletter. Since the site evolves, more pages can be available and
12
  update_option('newsletter_feed_demo_disable', 1);
13
  $controls->messages = 'Feed by Mail demo panel disabled. On next page reload it will disappear.';
14
  }
 
 
 
 
 
15
  ?>
16
  <div class="wrap main-index">
17
 
21
 
22
  <div id="newsletter-title">
23
  <h2>Welcome and Support</h2>
24
+ <p>
25
  With my horrible English, everything can be found starting from <a href="http://www.satollo.net/plugins/newsletter" target="_blank">Newsletter Official page</a>
26
  and every configuration panel has some included documentation just to avoid the most common mistakes.
27
  </p>
98
  </li>
99
  </ol>
100
 
101
+ <h3>Extensions</h3>
102
  <p>
103
+ Newsletter plugin can be extended with advanced features installing one or more of the
104
+ available Professional Extensions you can find on <a href="http://www.satollo.net/downloads" target="_blank">www.satollo.net/downloads</a>.
105
+ </p>
106
+ <p>
107
+ Newsletter Extensions are regular plugins (from version 2.x) and can be managed from the plugin panel of your
108
+ once installed for the first time.
109
  </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
  <h3>Support</h3>
112
  <p>
120
  <li>Write directly to me at stefano@satollo.net</li>
121
  </ul>
122
 
 
 
 
 
 
 
 
123
  <h3>Documentation</h3>
124
  <p>
125
  Below are the pages on www.satollo.net which document Newsletter. Since the site evolves, more pages can be available and
main/main.php CHANGED
@@ -197,15 +197,29 @@ if (!$controls->is_action()) {
197
  <th>Reply to</th>
198
  <td>
199
  <?php $controls->text_email('reply_to', 40); ?> (valid email address)
200
- <div class="hints">
201
  This is the email address where subscribers will reply (eg. if they want to reply to a newsletter). Leave it blank if
202
  you don't want to specify a different address from the sender email above. Since this setting can
203
  affect the reliability of delivery,
204
  <a href="http://www.satollo.net/plugins/newsletter/newsletter-configuration#reply-to" target="_blank">read my notes here</a> (important).
205
- </div>
206
  </td>
207
  </tr>
208
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  </table>
210
  </div>
211
 
197
  <th>Reply to</th>
198
  <td>
199
  <?php $controls->text_email('reply_to', 40); ?> (valid email address)
200
+ <p class="description">
201
  This is the email address where subscribers will reply (eg. if they want to reply to a newsletter). Leave it blank if
202
  you don't want to specify a different address from the sender email above. Since this setting can
203
  affect the reliability of delivery,
204
  <a href="http://www.satollo.net/plugins/newsletter/newsletter-configuration#reply-to" target="_blank">read my notes here</a> (important).
205
+ </p>
206
  </td>
207
  </tr>
208
+
209
+ <tr valign="top">
210
+ <th>License key</th>
211
+ <td>
212
+ <?php $controls->text('contract_key', 40); ?>
213
+ <p class="description">
214
+ This key is used by <a href="http://www.satollo.net/plugins/newsletter" target="_blank">extensions</a> to
215
+ self update. It does not unlock hidden features or like!
216
+ <?php if (defined('NEWSLETTER_LICENSE_KEY')) { ?>
217
+ <br>A global license key is actually defined, this value will be ignored.
218
+ <?php } ?>
219
+ </p>
220
+ </td>
221
+ </tr>
222
+
223
  </table>
224
  </div>
225
 
plugin.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.satollo.net/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.satollo.net/plugins/newsletter#update">this page</a> to know what's changed.</strong>
7
- Version: 3.5.2
8
  Author: Stefano Lissa
9
  Author URI: http://www.satollo.net
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -12,8 +12,8 @@
12
  Copyright 2009-2014 Stefano Lissa (email: stefano@satollo.net, web: http://www.satollo.net)
13
  */
14
 
15
- // Useed as dummy parameter on css and js links
16
- define('NEWSLETTER_VERSION', '3.5.2');
17
 
18
  global $wpdb, $newsletter;
19
 
@@ -304,7 +304,7 @@ class Newsletter extends NewsletterModule {
304
  $user = $this->check_user();
305
  if ($user == null)
306
  die('No user');
307
- $wpdb->query("update " . $wpdb->prefix . "newsletter set followup=2 where id=" . $user->id);
308
  $options_followup = get_option('newsletter_followup');
309
  $this->message = $options_followup['unsubscribed_text'];
310
  return;
@@ -362,7 +362,8 @@ class Newsletter extends NewsletterModule {
362
  'facebook' => 41,
363
  'sendgrid' => 40,
364
  'popup' => 43,
365
- 'mandrill' => 44);
 
366
 
367
  foreach ($modules as $name => $id) {
368
  $version = @file_get_contents($url . $id);
@@ -445,6 +446,8 @@ class Newsletter extends NewsletterModule {
445
 
446
  $headers = array('List-Unsubscribe' => '<' . NEWSLETTER_UNSUBSCRIBE_URL . '?nk=' . $user->id . '-' . $user->token . '>');
447
  $headers['Precedence'] = 'bulk';
 
 
448
 
449
  if (!$test) {
450
  $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set sent=sent+1, last_id=" . $user->id . " where id=" . $email->id . " limit 1");
@@ -757,7 +760,7 @@ class Newsletter extends NewsletterModule {
757
  }
758
 
759
  if (is_numeric($id) && !empty($token)) {
760
- return $wpdb->get_row($wpdb->prepare("select * from " . $wpdb->prefix . "newsletter where id=%d and token=%s limit 1", $id, $token));
761
  }
762
 
763
  return null;
@@ -1158,13 +1161,14 @@ require_once NEWSLETTER_DIR . '/users/users.php';
1158
  require_once NEWSLETTER_DIR . '/statistics/statistics.php';
1159
 
1160
 
1161
-
1162
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/feed/feed.php')) {
1163
- require_once WP_CONTENT_DIR . '/extensions/newsletter/feed/feed.php';
1164
- } else {
1165
- if (get_option('newsletter_feed_demo_disable') != 1) {
1166
- if (is_file(NEWSLETTER_DIR . '/feed/feed.php')) {
1167
- require_once NEWSLETTER_DIR . '/feed/feed.php';
 
1168
  }
1169
  }
1170
  }
@@ -1173,36 +1177,46 @@ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/feed/feed.php')) {
1173
  // require_once WP_CONTENT_DIR . '/extensions/newsletter/updates/updates.php';
1174
  //}
1175
 
1176
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php')) {
1177
- require_once WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php';
 
 
1178
  }
1179
 
1180
- //if (!is_dir(WP_PLUGIN_DIR . '/newsletter-reports')) {
1181
  if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/reports/reports.php')) {
1182
- //require_once WP_CONTENT_DIR . '/extensions/newsletter/reports/reports.php';
1183
  }
1184
- //}
1185
 
1186
- //if (!is_dir(WP_PLUGIN_DIR . '/newsletter-mailjet')) {
1187
  if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/mailjet/mailjet.php')) {
1188
  require_once WP_CONTENT_DIR . '/extensions/newsletter/mailjet/mailjet.php';
1189
  }
1190
- //}
1191
-
1192
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/sendgrid/sendgrid.php')) {
1193
- require_once WP_CONTENT_DIR . '/extensions/newsletter/sendgrid/sendgrid.php';
 
1194
  }
1195
 
1196
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php')) {
1197
- require_once WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php';
 
 
1198
  }
1199
 
1200
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php')) {
1201
- require_once WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php';
 
 
 
1202
  }
1203
 
1204
- if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/mandrill/mandrill.php')) {
1205
- require_once WP_CONTENT_DIR . '/extensions/newsletter/mandrill/mandrill.php';
 
 
1206
  }
1207
 
1208
 
4
  Plugin Name: Newsletter
5
  Plugin URI: http://www.satollo.net/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="http://www.satollo.net/plugins/newsletter#update">this page</a> to know what's changed.</strong>
7
+ Version: 3.6.3
8
  Author: Stefano Lissa
9
  Author URI: http://www.satollo.net
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
12
  Copyright 2009-2014 Stefano Lissa (email: stefano@satollo.net, web: http://www.satollo.net)
13
  */
14
 
15
+ // Used as dummy parameter on css and js links
16
+ define('NEWSLETTER_VERSION', '3.6.3');
17
 
18
  global $wpdb, $newsletter;
19
 
304
  $user = $this->check_user();
305
  if ($user == null)
306
  die('No user');
307
+ $wpdb->query("update " . NEWSLETTER_USERS_TABLE . " set followup=2 where id=" . $user->id);
308
  $options_followup = get_option('newsletter_followup');
309
  $this->message = $options_followup['unsubscribed_text'];
310
  return;
362
  'facebook' => 41,
363
  'sendgrid' => 40,
364
  'popup' => 43,
365
+ 'mandrill' => 44,
366
+ 'mailjet' => 38);
367
 
368
  foreach ($modules as $name => $id) {
369
  $version = @file_get_contents($url . $id);
446
 
447
  $headers = array('List-Unsubscribe' => '<' . NEWSLETTER_UNSUBSCRIBE_URL . '?nk=' . $user->id . '-' . $user->token . '>');
448
  $headers['Precedence'] = 'bulk';
449
+ $headers['X-Newsletter-Email-Id'] = $email->id;
450
+
451
 
452
  if (!$test) {
453
  $wpdb->query("update " . NEWSLETTER_EMAILS_TABLE . " set sent=sent+1, last_id=" . $user->id . " where id=" . $email->id . " limit 1");
760
  }
761
 
762
  if (is_numeric($id) && !empty($token)) {
763
+ return $wpdb->get_row($wpdb->prepare("select * from " . NEWSLETTER_USERS_TABLE . " where id=%d and token=%s limit 1", $id, $token));
764
  }
765
 
766
  return null;
1161
  require_once NEWSLETTER_DIR . '/statistics/statistics.php';
1162
 
1163
 
1164
+ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-feed')) {
1165
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/feed/feed.php')) {
1166
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/feed/feed.php';
1167
+ } else {
1168
+ if (get_option('newsletter_feed_demo_disable') != 1) {
1169
+ if (is_file(NEWSLETTER_DIR . '/feed/feed.php')) {
1170
+ require_once NEWSLETTER_DIR . '/feed/feed.php';
1171
+ }
1172
  }
1173
  }
1174
  }
1177
  // require_once WP_CONTENT_DIR . '/extensions/newsletter/updates/updates.php';
1178
  //}
1179
 
1180
+ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-followup')) {
1181
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php')) {
1182
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/followup/followup.php';
1183
+ }
1184
  }
1185
 
1186
+ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-reports')) {
1187
  if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/reports/reports.php')) {
1188
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/reports/reports.php';
1189
  }
1190
+ }
1191
 
1192
+ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-mailjet')) {
1193
  if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/mailjet/mailjet.php')) {
1194
  require_once WP_CONTENT_DIR . '/extensions/newsletter/mailjet/mailjet.php';
1195
  }
1196
+ }
1197
+ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-sendgrid')) {
1198
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/sendgrid/sendgrid.php')) {
1199
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/sendgrid/sendgrid.php';
1200
+ }
1201
  }
1202
 
1203
+ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-facebook')) {
1204
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php')) {
1205
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/facebook/facebook.php';
1206
+ }
1207
  }
1208
 
1209
+
1210
+ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-popup')) {
1211
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php')) {
1212
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/popup/popup.php';
1213
+ }
1214
  }
1215
 
1216
+ if (!is_dir(WP_PLUGIN_DIR . '/newsletter-mandrill')) {
1217
+ if (is_file(WP_CONTENT_DIR . '/extensions/newsletter/mandrill/mandrill.php')) {
1218
+ require_once WP_CONTENT_DIR . '/extensions/newsletter/mandrill/mandrill.php';
1219
+ }
1220
  }
1221
 
1222
 
readme.txt CHANGED
@@ -1,7 +1,7 @@
1
  === Newsletter ===
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing
3
  Requires at least: 3.3.0
4
- Tested up to: 3.8.1
5
  Stable tag: trunk
6
  Donate link: http://www.satollo.net/donations
7
 
@@ -57,6 +57,57 @@ No screen shots are available at this time.
57
 
58
  == Changelog ==
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  = 3.5.2 =
61
 
62
  * Fixed the {title} tag replacement for old subscriber list with the gender not set
1
  === Newsletter ===
2
  Tags: newsletter,email,subscription,mass mail,list build,email marketing,direct mailing
3
  Requires at least: 3.3.0
4
+ Tested up to: 3.9.2
5
  Stable tag: trunk
6
  Donate link: http://www.satollo.net/donations
7
 
57
 
58
  == Changelog ==
59
 
60
+ = 3.6.3 =
61
+
62
+ * fixed the feed by mail test function
63
+
64
+ = 3.6.2 =
65
+
66
+ * Added the separator selection on CSV export
67
+ * Added the UTF-8 BOM to the export
68
+ * Fixed some debug noticies
69
+
70
+ = 3.6.1 =
71
+
72
+ * Fixed the widget when field names contain double quotes
73
+
74
+ = 3.6.0 =
75
+
76
+ * Removed the extension list from welcome panel
77
+ * Added the and operator in the newsletter recipients selector
78
+ * Fixed the select_group(...) in NewsletterControls class
79
+
80
+ = 3.5.9 =
81
+
82
+ * Added a possible antibot to the subscription flow
83
+
84
+ = 3.5.8 =
85
+
86
+ * Added soundcloud for social icon on default theme
87
+ * Fixed the welcome screen (should)
88
+
89
+ = 3.5.7 =
90
+
91
+ * Added the private flag on newsletters
92
+ * Fixed old extension version checking/reporting
93
+
94
+ = 3.5.6 =
95
+
96
+ * Added custom header for newsletter tagging with mandrill
97
+ * Added internally used html 5 subscription form
98
+
99
+ = 3.5.5 =
100
+
101
+ * Added the license key field for special installations
102
+
103
+ = 3.5.4 =
104
+
105
+ * Fixed the web preview charset
106
+
107
+ = 3.5.3 =
108
+
109
+ * Added support for extensions as plugins
110
+
111
  = 3.5.2 =
112
 
113
  * Fixed the {title} tag replacement for old subscriber list with the gender not set
subscription/options.php CHANGED
@@ -237,6 +237,15 @@ if ($controls->is_action('create')) {
237
  </div>
238
  </td>
239
  </tr>
 
 
 
 
 
 
 
 
 
240
  </table>
241
 
242
  <h3>Special cases</h3>
237
  </div>
238
  </td>
239
  </tr>
240
+ <tr valign="top">
241
+ <th>Enable the antibot?</th>
242
+ <td>
243
+ <?php $controls->yesno('antibot'); ?>
244
+ <p class="description">
245
+ Tries to block bot generated subscriptions (without the annoying captcha).
246
+ </p>
247
+ </td>
248
+ </tr>
249
  </table>
250
 
251
  <h3>Special cases</h3>
subscription/subscription.php CHANGED
@@ -340,10 +340,10 @@ class NewsletterSubscription extends NewsletterModule {
340
  } else {
341
  $user = $newsletter->get_user($user_id);
342
  }
343
-
344
  $this->logger->debug('Confirmation for:');
345
  $this->logger->debug($user);
346
-
347
 
348
  if ($user == null) {
349
  $this->logger->debug('Not found');
@@ -383,10 +383,10 @@ class NewsletterSubscription extends NewsletterModule {
383
  function unsubscribe() {
384
  global $newsletter;
385
  $user = $this->get_user_from_request();
386
-
387
  $this->logger->debug('Unsubscription for:');
388
  $this->logger->debug($user);
389
-
390
  setcookie('newsletter', '', time() - 3600);
391
  if ($user == null) {
392
  $this->logger->debug('Not found');
@@ -511,11 +511,14 @@ class NewsletterSubscription extends NewsletterModule {
511
  } else if (isset($_REQUEST['ni'])) {
512
  $id = (int) $_REQUEST['ni'];
513
  $token = $_REQUEST['nt'];
 
 
514
  }
515
  $user = $newsletter->get_user($id);
516
 
517
- if ($user == null || $token != $user->token)
518
  return null;
 
519
  return $user;
520
  }
521
 
@@ -557,7 +560,7 @@ class NewsletterSubscription extends NewsletterModule {
557
  }
558
 
559
  if (is_numeric($id) && !empty($token)) {
560
- return $wpdb->get_row($wpdb->prepare("select * from " . $wpdb->prefix . "newsletter where id=%d and token=%s limit 1", $id, $token));
561
  }
562
 
563
  return null;
@@ -744,7 +747,116 @@ class NewsletterSubscription extends NewsletterModule {
744
  $buffer .= "</table>\n</form>\n</div>";
745
  return $buffer;
746
  }
747
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748
 
749
  /**
750
  * Generate the profile editing form.
@@ -945,7 +1057,7 @@ function newsletter_shortcode($attrs, $content) {
945
  $module = NewsletterSubscription::instance();
946
  $user = $module->get_user_from_request();
947
  $message_key = $module->get_message_key_from_request();
948
- $alert = stripslashes($_REQUEST['alert']);
949
 
950
  $message = $module->options[$message_key . '_text'];
951
 
@@ -977,8 +1089,9 @@ function newsletter_shortcode($attrs, $content) {
977
 
978
  $message = $newsletter->replace($message, $user, null, 'page');
979
 
980
- if (!empty($alert)) {
981
- $message .= '<script>alert("' . addslashes(strip_tags($alert)) . '");</script>';
 
982
  }
983
 
984
  return $message;
@@ -1009,8 +1122,9 @@ function newsletter_subscription_user_register($wp_user_id) {
1009
  $module->logger->error('User not found?!');
1010
  return;
1011
  }
1012
-
1013
- if (!NewsletterModule::is_email($wp_user->user_email)) return;
 
1014
 
1015
  $_REQUEST['ne'] = $wp_user->user_email;
1016
  $_REQUEST['nr'] = 'registration';
@@ -1047,4 +1161,3 @@ function newsletter_register_form() {
1047
  echo '</p>';
1048
  }
1049
  }
1050
-
340
  } else {
341
  $user = $newsletter->get_user($user_id);
342
  }
343
+
344
  $this->logger->debug('Confirmation for:');
345
  $this->logger->debug($user);
346
+
347
 
348
  if ($user == null) {
349
  $this->logger->debug('Not found');
383
  function unsubscribe() {
384
  global $newsletter;
385
  $user = $this->get_user_from_request();
386
+
387
  $this->logger->debug('Unsubscription for:');
388
  $this->logger->debug($user);
389
+
390
  setcookie('newsletter', '', time() - 3600);
391
  if ($user == null) {
392
  $this->logger->debug('Not found');
511
  } else if (isset($_REQUEST['ni'])) {
512
  $id = (int) $_REQUEST['ni'];
513
  $token = $_REQUEST['nt'];
514
+ } else {
515
+ return null;
516
  }
517
  $user = $newsletter->get_user($id);
518
 
519
+ if ($user == null || $token != $user->token) {
520
  return null;
521
+ }
522
  return $user;
523
  }
524
 
560
  }
561
 
562
  if (is_numeric($id) && !empty($token)) {
563
+ return $wpdb->get_row($wpdb->prepare("select * from " . NEWSLETTER_USERS_TABLE . " where id=%d and token=%s limit 1", $id, $token));
564
  }
565
 
566
  return null;
747
  $buffer .= "</table>\n</form>\n</div>";
748
  return $buffer;
749
  }
750
+
751
+ function get_subscription_form_html5($referrer = null, $action = null) {
752
+ $options_profile = get_option('newsletter_profile');
753
+ $options = get_option('newsletter');
754
+
755
+ $buffer = $this->get_form_javascript();
756
+
757
+
758
+ $buffer .= '<div class="newsletter newsletter-subscription">' . "\n";
759
+ if (empty($action)) {
760
+ $buffer .= '<form method="post" action="' . plugins_url('newsletter/do/subscribe.php') . '" onsubmit="return newsletter_check(this)">' . "\n\n";
761
+ } else {
762
+ $buffer .= '<form method="post" action="' . $action . '" onsubmit="return newsletter_check(this)">' . "\n\n";
763
+ }
764
+ if (!empty($referrer)) {
765
+ $buffer .= "<input type='hidden' name='nr' value='$referrer'>\n";
766
+ }
767
+
768
+ if ($options_profile['name_status'] == 2) {
769
+ $buffer .= '<div class="newsletter-field-div newsletter-firstname-div"><label>' . $options_profile['name'] . '</label>';
770
+ $buffer .= '<input class="newsletter-firstname" type="text" name="nn" size="30"' . ($options_profile['name_rules'] == 1 ? 'required' : '') . '></div>';
771
+ $buffer .= "\n";
772
+ }
773
+
774
+ if ($options_profile['surname_status'] == 2) {
775
+ $buffer .= '<div class="newsletter-field-div newsletter-lastname-div"><label>' . $options_profile['surname'] . '</label>';
776
+ $buffer .= '<input class="newsletter-lastname" type="text" name="ns" size="30"' . ($options_profile['surname_rules'] == 1 ? 'required' : '') . '></div>';
777
+ $buffer .= "\n";
778
+ }
779
+
780
+ $buffer .= '<div class="newsletter-field-div newsletter-email-div"><label>' . $options_profile['email'] . '</label>';
781
+ $buffer .= '<input class="newsletter-email" type="email" name="ne" size="30" required></div>';
782
+ $buffer .= "\n";
783
+
784
+ if ($options_profile['sex_status'] == 2) {
785
+ $buffer .= '<div class="newsletter-field-div newsletter-sex-p"><label>' . $options_profile['sex'] . '</label>';
786
+ $buffer .= '<select name="nx" class="newsletter-sex">';
787
+ $buffer .= '<option value="m">' . $options_profile['sex_male'] . '</option>';
788
+ $buffer .= '<option value="f">' . $options_profile['sex_female'] . '</option>';
789
+ $buffer .= '</select></div>';
790
+ $buffer .= "\n";
791
+ }
792
+
793
+ $lists = '';
794
+ for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
795
+ if ($options_profile['list_' . $i . '_status'] != 2)
796
+ continue;
797
+ $lists .= "\t\t" . '<div class="newsletter-preference-div"><label><input class="newsletter-preference" type="checkbox" name="nl[]" value="' . $i . '"';
798
+ if ($options_profile['list_' . $i . '_checked'] == 1)
799
+ $lists .= ' checked';
800
+ $lists .= '/>&nbsp;' . $options_profile['list_' . $i] . '</label></div>';
801
+ }
802
+ if (!empty($lists))
803
+ $buffer .= '<div class="newsletter-field-div newsletter-preferences-div">' . $lists . '</div>';
804
+
805
+ // Extra profile fields
806
+ for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
807
+ // Not for subscription form
808
+ if ($options_profile['profile_' . $i . '_status'] != 2)
809
+ continue;
810
+
811
+ // Text field
812
+ if ($options_profile['profile_' . $i . '_type'] == 'text') {
813
+ $buffer .= "<tr>\n\t<th>" . $options_profile['profile_' . $i] . "</th>\n\t<td>\n\t\t" . '<input class="newsletter-profile newsletter-profile-' . $i . '" type="text" size="30" name="np' . $i . '"/>' . "\n\t</td>\n</tr>\n\n";
814
+ }
815
+
816
+ // Select field
817
+ if ($options_profile['profile_' . $i . '_type'] == 'select') {
818
+ $buffer .= "<tr>\n\t<th>" . $options_profile['profile_' . $i] . "</th>\n\t<td>\n\t\t" . '<select class="newsletter-profile newsletter-profile-' . $i . '" name="np' . $i . '">' . "\n";
819
+ $opts = explode(',', $options_profile['profile_' . $i . '_options']);
820
+ for ($j = 0; $j < count($opts); $j++) {
821
+ $buffer .= "\t\t\t<option>" . trim($opts[$j]) . "</option>\n";
822
+ }
823
+ $buffer .= "\t\t</select>\n\t</td>\n</tr>\n\n";
824
+ }
825
+ }
826
+
827
+ $extra = apply_filters('newsletter_subscription_extra', array());
828
+ foreach ($extra as &$x) {
829
+ $label = $x['label'];
830
+ if (empty($label))
831
+ $label = '&nbsp;';
832
+ $buffer .= "<p><label>" . $label . "</label>";
833
+ $buffer .= $x['field'] . "\n</p>\n\n";
834
+ }
835
+
836
+ if ($options_profile['privacy_status'] == 1) {
837
+ $buffer .= "<p class='newsletter-privacy-div'>\n\t";
838
+ $buffer .= '<input type="checkbox" name="ny" required class="newsletter-privacy">&nbsp;';
839
+ if (!empty($options_profile['privacy_url'])) {
840
+ $buffer .= '<label><a target="_blank" href="' . $options_profile['privacy_url'] . '"></label>';
841
+ $buffer .= $options_profile['privacy'] . '</a>';
842
+ } else {
843
+ $buffer .= '<label>' . $options_profile['privacy'] . '</label>';
844
+ }
845
+ $buffer .= '</div>';
846
+ $buffer .= "\n";
847
+ }
848
+
849
+ $buffer .= '<div class="newsletter-submit-div">';
850
+
851
+ if (strpos($options_profile['subscribe'], 'http://') !== false) {
852
+ $buffer .= "\t\t" . '<input class="newsletter-submit-image" type="image" src="' . $options_profile['subscribe'] . '">' . "\n\t";
853
+ } else {
854
+ $buffer .= "\t\t" . '<input class="newsletter-submit" type="submit" value="' . $options_profile['subscribe'] . '">' . "\n\t";
855
+ }
856
+
857
+ $buffer .= "</div>\n</form>\n</div>";
858
+ return $buffer;
859
+ }
860
 
861
  /**
862
  * Generate the profile editing form.
1057
  $module = NewsletterSubscription::instance();
1058
  $user = $module->get_user_from_request();
1059
  $message_key = $module->get_message_key_from_request();
1060
+
1061
 
1062
  $message = $module->options[$message_key . '_text'];
1063
 
1089
 
1090
  $message = $newsletter->replace($message, $user, null, 'page');
1091
 
1092
+ if (isset($_REQUEST['alert'])) {
1093
+ // slashes are already added by wordpress!
1094
+ $message .= '<script>alert("' . strip_tags($_REQUEST['alert']) . '");</script>';
1095
  }
1096
 
1097
  return $message;
1122
  $module->logger->error('User not found?!');
1123
  return;
1124
  }
1125
+
1126
+ if (!NewsletterModule::is_email($wp_user->user_email))
1127
+ return;
1128
 
1129
  $_REQUEST['ne'] = $wp_user->user_email;
1130
  $_REQUEST['nr'] = 'registration';
1161
  echo '</p>';
1162
  }
1163
  }
 
users/export.php CHANGED
@@ -32,13 +32,24 @@ for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
32
  <form method="post" action="<?php echo plugins_url('newsletter'); ?>/users/csv.php">
33
  <?php $controls->init(); ?>
34
  <table class="form-table">
 
 
 
 
 
 
 
35
  <tr>
 
36
  <td>
37
  <?php $controls->select('list', $lists); ?>
38
- <?php $controls->button('export', 'Export'); ?>
39
  </td>
40
  </tr>
41
  </table>
 
 
 
42
  </form>
43
 
44
  </div>
32
  <form method="post" action="<?php echo plugins_url('newsletter'); ?>/users/csv.php">
33
  <?php $controls->init(); ?>
34
  <table class="form-table">
35
+ <tr>
36
+ <th>Fields separator</th>
37
+ <td>
38
+ <?php $controls->select('separator', array(';' => 'Semicolon', ',' => 'Comma', 'tab' => 'Tabulation')); ?>
39
+ <p class="description">Try to change the separator if Excel does not recognize the columns.</p>
40
+ </td>
41
+ </tr>
42
  <tr>
43
+ <th>Limit to</th>
44
  <td>
45
  <?php $controls->select('list', $lists); ?>
46
+ <p class="description">Limit to the user with that preference active</p>
47
  </td>
48
  </tr>
49
  </table>
50
+ <p>
51
+ <?php $controls->button('export', 'Export'); ?>
52
+ </p>
53
  </form>
54
 
55
  </div>
users/index-old.php CHANGED
@@ -46,7 +46,7 @@ if ($controls->is_action('search')) {
46
  if (empty($controls->data['search_order'])) $order = 'email';
47
  if ($controls->data['search_order'] == 'id') $order = 'id desc';
48
 
49
- $query = "select * from " . $wpdb->prefix . "newsletter where 1=1";
50
 
51
  if (!empty($controls->data['search_status'])) {
52
  $query .= " and status='" . $wpdb->escape($controls->data['search_status']) . "'";
@@ -258,7 +258,7 @@ else {
258
  <?php if ($options['search_clicks'] == 1) { ?>
259
  <td><small>
260
  <?php
261
- $clicks = $wpdb->get_results($wpdb->prepare("select * from " . $wpdb->prefix . "newsletter_stats where user_id=%d order by newsletter", $s->id));
262
  foreach ($clicks as &$click) {
263
  ?>
264
  <?php echo $click->newsletter; ?>: <?php echo $click->url; ?><br />
46
  if (empty($controls->data['search_order'])) $order = 'email';
47
  if ($controls->data['search_order'] == 'id') $order = 'id desc';
48
 
49
+ $query = "select * from " . NEWSLETTER_USERS_TABLE . " where 1=1";
50
 
51
  if (!empty($controls->data['search_status'])) {
52
  $query .= " and status='" . $wpdb->escape($controls->data['search_status']) . "'";
258
  <?php if ($options['search_clicks'] == 1) { ?>
259
  <td><small>
260
  <?php
261
+ $clicks = $wpdb->get_results($wpdb->prepare("select * from " . NEWSLETTER_STATS_TABLE . " where user_id=%d order by newsletter", $s->id));
262
  foreach ($clicks as &$click) {
263
  ?>
264
  <?php echo $click->newsletter; ?>: <?php echo $click->url; ?><br />
users/index.php CHANGED
@@ -42,7 +42,7 @@ if ($controls->is_action('resend_welcome')) {
42
  }
43
 
44
  if ($controls->is_action('remove')) {
45
- $wpdb->query($wpdb->prepare("delete from " . $wpdb->prefix . "newsletter where id=%d", $controls->button_data));
46
  unset($controls->data['subscriber_id']);
47
  }
48
 
@@ -73,7 +73,7 @@ if (!empty($controls->data['search_status'])) {
73
  // Total items, total pages
74
  $items_per_page = 20;
75
  $where = $wpdb->prepare($where, $query_args);
76
- $count = Newsletter::instance()->store->get_count($wpdb->prefix . 'newsletter', $where);
77
  $last_page = floor($count / $items_per_page) - ($count % $items_per_page == 0 ? 1 : 0);
78
  if ($last_page < 0) $last_page = 0;
79
 
@@ -97,7 +97,7 @@ if ($controls->is_action('search')) {
97
  if ($controls->data['search_page'] < 0) $controls->data['search_page'] = 0;
98
  if ($controls->data['search_page'] > $last_page) $controls->data['search_page'] = $last_page;
99
 
100
- $query = "select * from " . $wpdb->prefix . "newsletter " . $where . " order by id desc";
101
  $query .= " limit " . ($controls->data['search_page']*$items_per_page) . "," . $items_per_page;
102
  $list = $wpdb->get_results($query);
103
 
42
  }
43
 
44
  if ($controls->is_action('remove')) {
45
+ $wpdb->query($wpdb->prepare("delete from " . NEWSLETTER_USERS_TABLE . " where id=%d", $controls->button_data));
46
  unset($controls->data['subscriber_id']);
47
  }
48
 
73
  // Total items, total pages
74
  $items_per_page = 20;
75
  $where = $wpdb->prepare($where, $query_args);
76
+ $count = Newsletter::instance()->store->get_count(NEWSLETTER_USERS_TABLE, $where);
77
  $last_page = floor($count / $items_per_page) - ($count % $items_per_page == 0 ? 1 : 0);
78
  if ($last_page < 0) $last_page = 0;
79
 
97
  if ($controls->data['search_page'] < 0) $controls->data['search_page'] = 0;
98
  if ($controls->data['search_page'] > $last_page) $controls->data['search_page'] = $last_page;
99
 
100
+ $query = "select * from " . NEWSLETTER_USERS_TABLE . ' ' . $where . " order by id desc";
101
  $query .= " limit " . ($controls->data['search_page']*$items_per_page) . "," . $items_per_page;
102
  $list = $wpdb->get_results($query);
103
 
users/massive.php CHANGED
@@ -73,7 +73,7 @@ if ($controls->is_action('list_manage')) {
73
  }
74
 
75
  if ($controls->is_action('resend_all')) {
76
- $list = $wpdb->get_results("select * from " . $wpdb->prefix . "newsletter where status='S'");
77
  $opts = get_option('newsletter');
78
 
79
  if ($list) {
@@ -296,9 +296,9 @@ if ($controls->is_action('bounces')) {
296
  <h3>Sex</h3>
297
  <?php
298
  // TODO: do them with a single query
299
- $all_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='C'");
300
- $male_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where sex='m' and status='C'");
301
- $female_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where sex='f' and status='C'");
302
  $other_count = ($all_count-$male_count-$female_count)
303
  ?>
304
  <table class="widefat" style="width: 300px">
73
  }
74
 
75
  if ($controls->is_action('resend_all')) {
76
+ $list = $wpdb->get_results("select * from " . NEWSLETTER_USERS_TABLE . " where status='S'");
77
  $opts = get_option('newsletter');
78
 
79
  if ($list) {
296
  <h3>Sex</h3>
297
  <?php
298
  // TODO: do them with a single query
299
+ $all_count = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='C'");
300
+ $male_count = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where sex='m' and status='C'");
301
+ $female_count = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where sex='f' and status='C'");
302
  $other_count = ($all_count-$male_count-$female_count)
303
  ?>
304
  <table class="widefat" style="width: 300px">
users/stats.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- $all_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter");
3
  $options_profile = get_option('newsletter_profile');
4
 
5
  $module = NewsletterUsers::instance();
@@ -39,37 +39,37 @@ $module = NewsletterUsers::instance();
39
  <tr valign="top">
40
  <td>Any</td>
41
  <td>
42
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter"); ?>
43
  </td>
44
  </tr>
45
  <tr>
46
  <td>Confirmed</td>
47
  <td>
48
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='C'"); ?>
49
  </td>
50
  </tr>
51
  <tr>
52
  <td>Not confirmed</td>
53
  <td>
54
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='S'"); ?>
55
  </td>
56
  </tr>
57
  <tr>
58
  <td>Subscribed to feed by mail</td>
59
  <td>
60
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='C' and feed=1"); ?>
61
  </td>
62
  </tr>
63
  <tr>
64
  <td>Unsubscribed</td>
65
  <td>
66
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='U'"); ?>
67
  </td>
68
  </tr>
69
  <tr>
70
  <td>Bounced</td>
71
  <td>
72
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where status='B'"); ?>
73
  </td>
74
  </tr>
75
  </table>
@@ -98,7 +98,7 @@ $module = NewsletterUsers::instance();
98
  <tr>
99
  <td><?php echo '(' . $i . ') ' . $options_profile['list_' . $i]; ?></td>
100
  <td>
101
- <?php echo $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where list_" . $i . "=1 and status='C'"); ?>
102
  </td>
103
  </tr>
104
  <?php } ?>
@@ -119,7 +119,7 @@ $module = NewsletterUsers::instance();
119
  </div>
120
  <?php
121
  if (class_exists('NewsletterReports')) {
122
- $countries = $wpdb->get_results("select country, count(*) as total from " . $wpdb->prefix . "newsletter where status='C' and country<>'' group by country order by total");
123
  }
124
  ?>
125
 
@@ -140,7 +140,7 @@ $module = NewsletterUsers::instance();
140
  </p>
141
  </div>
142
  <?php
143
- $list = $wpdb->get_results("select referrer, count(*) as total from " . $wpdb->prefix . "newsletter where status='C' group by referrer order by total desc");
144
  ?>
145
  <table class="widefat" style="width: 300px">
146
  <thead><tr><th>Referrer</th><th>Total</th></thead>
@@ -162,7 +162,7 @@ $module = NewsletterUsers::instance();
162
  </div>
163
 
164
  <?php
165
- $list = $wpdb->get_results("select http_referer, count(*) as total from " . $wpdb->prefix . "newsletter where status='C' group by http_referer order by count(*) desc limit 100");
166
  ?>
167
  <table class="widefat" style="width: 300px">
168
  <thead><tr><th>URL</th><th>Total</th></thead>
@@ -177,8 +177,8 @@ $module = NewsletterUsers::instance();
177
  <div id="tabs-gender">
178
 
179
  <?php
180
- $male_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where sex='m'");
181
- $female_count = $wpdb->get_var("select count(*) from " . $wpdb->prefix . "newsletter where sex='f'");
182
  $other_count = ($all_count - $male_count - $female_count)
183
  ?>
184
  <table class="widefat" style="width: 300px">
@@ -197,7 +197,7 @@ $module = NewsletterUsers::instance();
197
 
198
  <h4>Subscriptions by month (max 24 months)</h4>
199
  <?php
200
- $months = $wpdb->get_results("select count(*) as c, concat(year(created), '-', date_format(created, '%m')) as d from " . $wpdb->prefix . "newsletter where status='C' group by concat(year(created), '-', date_format(created, '%m')) order by d desc limit 24");
201
  ?>
202
  <div id="months-chart"></div>
203
 
@@ -218,7 +218,7 @@ $module = NewsletterUsers::instance();
218
 
219
  <h4>Subscriptions by day (max 90 days)</h4>
220
  <?php
221
- $list = $wpdb->get_results("select count(*) as c, date(created) as d from " . $wpdb->prefix . "newsletter where status='C' group by date(created) order by d desc limit 90");
222
  ?>
223
  <table class="widefat" style="width: 300px">
224
  <thead>
1
  <?php
2
+ $all_count = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE);
3
  $options_profile = get_option('newsletter_profile');
4
 
5
  $module = NewsletterUsers::instance();
39
  <tr valign="top">
40
  <td>Any</td>
41
  <td>
42
+ <?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE); ?>
43
  </td>
44
  </tr>
45
  <tr>
46
  <td>Confirmed</td>
47
  <td>
48
+ <?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='C'"); ?>
49
  </td>
50
  </tr>
51
  <tr>
52
  <td>Not confirmed</td>
53
  <td>
54
+ <?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='S'"); ?>
55
  </td>
56
  </tr>
57
  <tr>
58
  <td>Subscribed to feed by mail</td>
59
  <td>
60
+ <?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='C' and feed=1"); ?>
61
  </td>
62
  </tr>
63
  <tr>
64
  <td>Unsubscribed</td>
65
  <td>
66
+ <?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='U'"); ?>
67
  </td>
68
  </tr>
69
  <tr>
70
  <td>Bounced</td>
71
  <td>
72
+ <?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where status='B'"); ?>
73
  </td>
74
  </tr>
75
  </table>
98
  <tr>
99
  <td><?php echo '(' . $i . ') ' . $options_profile['list_' . $i]; ?></td>
100
  <td>
101
+ <?php echo $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where list_" . $i . "=1 and status='C'"); ?>
102
  </td>
103
  </tr>
104
  <?php } ?>
119
  </div>
120
  <?php
121
  if (class_exists('NewsletterReports')) {
122
+ $countries = $wpdb->get_results("select country, count(*) as total from " . NEWSLETTER_USERS_TABLE . " where status='C' and country<>'' group by country order by total");
123
  }
124
  ?>
125
 
140
  </p>
141
  </div>
142
  <?php
143
+ $list = $wpdb->get_results("select referrer, count(*) as total from " . NEWSLETTER_USERS_TABLE . " where status='C' group by referrer order by total desc");
144
  ?>
145
  <table class="widefat" style="width: 300px">
146
  <thead><tr><th>Referrer</th><th>Total</th></thead>
162
  </div>
163
 
164
  <?php
165
+ $list = $wpdb->get_results("select http_referer, count(*) as total from " . NEWSLETTER_USERS_TABLE . " where status='C' group by http_referer order by count(*) desc limit 100");
166
  ?>
167
  <table class="widefat" style="width: 300px">
168
  <thead><tr><th>URL</th><th>Total</th></thead>
177
  <div id="tabs-gender">
178
 
179
  <?php
180
+ $male_count = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where sex='m'");
181
+ $female_count = $wpdb->get_var("select count(*) from " . NEWSLETTER_USERS_TABLE . " where sex='f'");
182
  $other_count = ($all_count - $male_count - $female_count)
183
  ?>
184
  <table class="widefat" style="width: 300px">
197
 
198
  <h4>Subscriptions by month (max 24 months)</h4>
199
  <?php
200
+ $months = $wpdb->get_results("select count(*) as c, concat(year(created), '-', date_format(created, '%m')) as d from " . NEWSLETTER_USERS_TABLE . " where status='C' group by concat(year(created), '-', date_format(created, '%m')) order by d desc limit 24");
201
  ?>
202
  <div id="months-chart"></div>
203
 
218
 
219
  <h4>Subscriptions by day (max 90 days)</h4>
220
  <?php
221
+ $list = $wpdb->get_results("select count(*) as c, date(created) as d from " . NEWSLETTER_USERS_TABLE . " where status='C' group by date(created) order by d desc limit 90");
222
  ?>
223
  <table class="widefat" style="width: 300px">
224
  <thead>
users/users.php CHANGED
@@ -80,26 +80,35 @@ class NewsletterUsers extends NewsletterModule {
80
  //$this->add_admin_page('index', 'Old search');
81
  }
82
 
83
- function export() {
84
  global $wpdb;
85
 
86
  header('Content-Type: application/octet-stream');
87
  header('Content-Disposition: attachment; filename="newsletter-subscribers.csv"');
88
 
 
 
 
 
 
 
 
 
89
  // CSV header
90
- echo '"Email";"Name";"Surname";"Sex";"Status";"Date";"Token";';
91
 
92
  // In table profiles
93
  for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
94
- echo '"Profile ' . $i . '";'; // To adjust with field name
95
  }
96
 
97
  // Lists
98
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
99
- echo '"List ' . $i . '";';
100
  }
101
 
102
- echo '"Feed by mail";"Follow up"';
 
103
 
104
  echo "\n";
105
 
@@ -111,23 +120,26 @@ class NewsletterUsers extends NewsletterModule {
111
  }
112
  $recipients = $wpdb->get_results($query . " order by email limit " . $page * 500 . ",500");
113
  for ($i = 0; $i < count($recipients); $i++) {
114
- echo '"' . $recipients[$i]->email . '";"' . $this->sanitize_csv($recipients[$i]->name) .
115
- '";"' . $this->sanitize_csv($recipients[$i]->surname) .
116
- '";"' . $recipients[$i]->sex .
117
- '";"' . $recipients[$i]->status . '";"' . $recipients[$i]->created . '";"' . $recipients[$i]->token . '";';
118
 
119
  for ($j = 1; $j <= NEWSLETTER_PROFILE_MAX; $j++) {
120
  $column = 'profile_' . $j;
121
- echo $this->sanitize_csv($recipients[$i]->$column) . ';';
122
  }
123
 
124
  for ($j = 1; $j <= NEWSLETTER_LIST_MAX; $j++) {
125
  $list = 'list_' . $j;
126
- echo $recipients[$i]->$list . ';';
127
  }
128
 
129
- echo $recipients[$i]->feed . ';';
130
- echo $recipients[$i]->followup . ';';
 
 
 
131
 
132
  echo "\n";
133
  flush();
80
  //$this->add_admin_page('index', 'Old search');
81
  }
82
 
83
+ function export($options = null) {
84
  global $wpdb;
85
 
86
  header('Content-Type: application/octet-stream');
87
  header('Content-Disposition: attachment; filename="newsletter-subscribers.csv"');
88
 
89
+ // BOM
90
+ echo "\xEF\xBB\xBF";
91
+
92
+ $sep = ';';
93
+ if ($options) {
94
+ $sep = $options['separator'];
95
+ }
96
+
97
  // CSV header
98
+ echo '"Email"' . $sep . '"Name"' . $sep . '"Surname"' . $sep . '"Sex"' . $sep . '"Status"' . $sep . '"Date"' . $sep . '"Token";';
99
 
100
  // In table profiles
101
  for ($i = 1; $i <= NEWSLETTER_PROFILE_MAX; $i++) {
102
+ echo '"Profile ' . $i . '"' . $sep; // To adjust with field name
103
  }
104
 
105
  // Lists
106
  for ($i = 1; $i <= NEWSLETTER_LIST_MAX; $i++) {
107
+ echo '"List ' . $i . '"' . $sep;
108
  }
109
 
110
+ echo '"Feed by mail"' . $sep . '"Follow up"' . $sep;
111
+ echo '"IP"' . $sep . '"Referrer"' . $sep . '"Country"';
112
 
113
  echo "\n";
114
 
120
  }
121
  $recipients = $wpdb->get_results($query . " order by email limit " . $page * 500 . ",500");
122
  for ($i = 0; $i < count($recipients); $i++) {
123
+ echo '"' . $recipients[$i]->email . '"' . $sep . '"' . $this->sanitize_csv($recipients[$i]->name) .
124
+ '"' . $sep . '"' . $this->sanitize_csv($recipients[$i]->surname) .
125
+ '"' . $sep . '"' . $recipients[$i]->sex .
126
+ '"' . $sep . '"' . $recipients[$i]->status . '"' . $sep . '"' . $recipients[$i]->created . '";"' . $recipients[$i]->token . '"' . $sep;
127
 
128
  for ($j = 1; $j <= NEWSLETTER_PROFILE_MAX; $j++) {
129
  $column = 'profile_' . $j;
130
+ echo '"' . $this->sanitize_csv($recipients[$i]->$column) . '"' . $sep;
131
  }
132
 
133
  for ($j = 1; $j <= NEWSLETTER_LIST_MAX; $j++) {
134
  $list = 'list_' . $j;
135
+ echo '"' . $recipients[$i]->$list . '"' . $sep;
136
  }
137
 
138
+ echo '"' . $recipients[$i]->feed . '"' . $sep;
139
+ echo '"' . $recipients[$i]->followup . '"' . $sep;
140
+ echo '"' . $recipients[$i]->ip . '"' . $sep;
141
+ echo '"' . $recipients[$i]->referrer . '"' . $sep;
142
+ echo '"' . $recipients[$i]->country . '"' . $sep;
143
 
144
  echo "\n";
145
  flush();
widget.php CHANGED
@@ -18,12 +18,12 @@ class NewsletterWidget extends WP_Widget {
18
  $form .= '<input type="hidden" name="nr" value="widget"/>';
19
 
20
  if ($options_profile['name_status'] == 2)
21
- $form .= '<p><input class="newsletter-firstname" type="text" name="nn" value="' . $options_profile['name'] . '" onclick="if (this.defaultValue==this.value) this.value=\'\'" onblur="if (this.value==\'\') this.value=this.defaultValue"/></p>';
22
 
23
  if ($options_profile['surname_status'] == 2)
24
- $form .= '<p><input class="newsletter-lastname" type="text" name="ns" value="' . $options_profile['surname'] . '" onclick="if (this.defaultValue==this.value) this.value=\'\'" onblur="if (this.value==\'\') this.value=this.defaultValue"/></p>';
25
 
26
- $form .= '<p><input class="newsletter-email" type="email" required name="ne" value="' . $options_profile['email'] . '" onclick="if (this.defaultValue==this.value) this.value=\'\'" onblur="if (this.value==\'\') this.value=this.defaultValue"/></p>';
27
 
28
  if ($options_profile['sex_status'] == 2) {
29
  $form .= '<p><select name="nx" class="newsletter-sex">';
18
  $form .= '<input type="hidden" name="nr" value="widget"/>';
19
 
20
  if ($options_profile['name_status'] == 2)
21
+ $form .= '<p><input class="newsletter-firstname" type="text" name="nn" value="' . esc_attr($options_profile['name']) . '" onclick="if (this.defaultValue==this.value) this.value=\'\'" onblur="if (this.value==\'\') this.value=this.defaultValue"/></p>';
22
 
23
  if ($options_profile['surname_status'] == 2)
24
+ $form .= '<p><input class="newsletter-lastname" type="text" name="ns" value="' . esc_attr($options_profile['surname']) . '" onclick="if (this.defaultValue==this.value) this.value=\'\'" onblur="if (this.value==\'\') this.value=this.defaultValue"/></p>';
25
 
26
+ $form .= '<p><input class="newsletter-email" type="email" required name="ne" value="' . esc_attr($options_profile['email']) . '" onclick="if (this.defaultValue==this.value) this.value=\'\'" onblur="if (this.value==\'\') this.value=this.defaultValue"/></p>';
27
 
28
  if ($options_profile['sex_status'] == 2) {
29
  $form .= '<p><select name="nx" class="newsletter-sex">';