Newsletter - Version 1.1.9

Version Description

Download this release

Release Info

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

Code changes from version 1.1.8 to 1.1.9

Files changed (4) hide show
  1. import.php +45 -23
  2. newsletter.php +16 -3
  3. plugin.php +3 -2
  4. readme.txt +1 -1
import.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php
2
  if (isset($_POST['import']))
3
  {
 
4
  $csv = newsletter_request('csv');
5
  $lines = explode("\n", $csv);
6
 
@@ -11,6 +12,10 @@ if (isset($_POST['import']))
11
  if ($line == '') continue;
12
  if ($line[0] == '#') continue;
13
  $data = explode(';', $line);
 
 
 
 
14
  $email = newsletter_normalize_email($data[0]);
15
  $name = $data[1];
16
  $token = md5(rand());
@@ -23,34 +28,51 @@ if (isset($_POST['import']))
23
  ?>
24
 
25
  <div class="wrap">
 
 
 
 
 
 
 
 
 
 
26
  <form method="post">
27
- <h2>Subscribers Import</h2>
28
-
29
- <table class="form-table">
30
- <tr valign="top">
31
- <th scope="row"><label>Message</label></th>
32
- <td>
33
- <textarea name="csv" wrap="off" rows="20" cols="75"></textarea>
34
- <br />
35
- Copy here a text with csv format: "email@example.com;Name Surname". Empty rows or
36
- rows starting with "#" are skipped.
37
- </td>
38
- </tr>
39
- <?php if ($errors) { ?>
40
- <tr valign="top">
41
- <th scope="row"><label>Rows with errors</label></th>
42
- <td>
43
- <textarea name="csv" wrap="off" rows="20" cols="75"><?php echo htmlspecialchars(implode("\n", $errors))?></textarea>
44
- <br />
45
- </td>
46
- </tr>
47
- <?php } ?>
48
- </table>
49
-
50
 
 
51
  <p class="submit">
52
  <input class="button" type="submit" name="import" value="Import"/>
53
  </p>
54
  </form>
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  </div>
1
  <?php
2
  if (isset($_POST['import']))
3
  {
4
+ if (!check_admin_referer()) die('No hacking please');
5
  $csv = newsletter_request('csv');
6
  $lines = explode("\n", $csv);
7
 
12
  if ($line == '') continue;
13
  if ($line[0] == '#') continue;
14
  $data = explode(';', $line);
15
+ if (!newsletter_is_email($data[0])) {
16
+ $errors[] = $line;
17
+ continue;
18
+ }
19
  $email = newsletter_normalize_email($data[0]);
20
  $name = $data[1];
21
  $token = md5(rand());
28
  ?>
29
 
30
  <div class="wrap">
31
+
32
+ <h2>Subscribers Import/Export</h2>
33
+
34
+ <?php if ($errors) { ?>
35
+ <h3>Rows with errors</h3>
36
+
37
+ <textarea wrap="off" style="width: 100%; height: 150px; font-size: 11px; font-family: monospace"><?php echo htmlspecialchars(implode("\n", $errors))?></textarea>
38
+
39
+ <?php } ?>
40
+
41
  <form method="post">
42
+ <?php wp_nonce_field(); ?>
43
+ <h3>Import</h3>
44
+ <p>On the textarea below you can copy a text in CSV (comma separated values)
45
+ with format:<br /><br />
46
+ user email;user name
47
+ <br /><br />
48
+ and then import them. If an email is already stored, it won't be imported. If an
49
+ email is wrong it won't be imported. Even when there are errors on CSV lines, the import
50
+ will continue to the end. After the import process has ended, a box will appear with all
51
+ the line not imported due to duplications or errors. Imported subscriber will be set as confirmed.
52
+ </p>
53
+ <p>Empty rows and rows staring with sharp (#) are skipped. Emails will be normalized and a
54
+ subscriber token generated for each imported email.</p>
 
 
 
 
 
 
 
 
 
 
55
 
56
+ <textarea name="csv" wrap="off" style="width: 100%; height: 300px; font-size: 11px; font-family: monospace"></textarea>
57
  <p class="submit">
58
  <input class="button" type="submit" name="import" value="Import"/>
59
  </p>
60
  </form>
61
 
62
+ <h3>Export</h3>
63
+ <p>The text below is a list of all your subscribers (confirmed and not) in a
64
+ cvs format. You can copy, save and edit it with Excel or other software. Status
65
+ column has 2 values: S - subscribed but not confirmed, C - confirmed.</p>
66
+
67
+ <textarea wrap="off" style="width: 100%; height: 300px; font-size: 11px; font-family: monospace">Email,Name,Status,Token
68
+ <?php
69
+ $query = "select * from " . $wpdb->prefix . "newsletter where status='C'";
70
+ $recipients = $wpdb->get_results($query . " order by email");
71
+ for ($i=0; $i<count($recipients); $i++)
72
+ {
73
+ echo $recipients[$i]->email . ';' . $recipients[$i]->name .
74
+ ';' . $recipients[$i]->status . ';' . $recipients[$i]->token . "\n";
75
+ }
76
+ ?></textarea>
77
+
78
  </div>
newsletter.php CHANGED
@@ -93,15 +93,21 @@ $last = get_option('newsletter_last');
93
  <h2>Newsletter Composer</h2>
94
 
95
  <h3>Last batch infos</h3>
 
 
 
 
 
96
  <?php if (!$last) { ?>
97
- <p>No batch info found.</p>
98
  <?php } else { ?>
99
- <p>
100
  Total emails to send: <?php echo $last['total']; ?><br />
101
  Emails sent till now: <?php echo $last['sent']; ?><br />
102
  Last email (if empty the batch has completed): <?php echo $last['email']; ?><br />
103
- </p>
104
  <?php } ?>
 
105
 
106
 
107
 
@@ -150,6 +156,7 @@ $last = get_option('newsletter_last');
150
  if (!$res)
151
  {
152
  echo '</p><form action="" method="post">Still some emails to send.';
 
153
  echo '<input type="submit" name="simulate2" value="Proceed"/>';
154
  echo '</form>';
155
  }
@@ -213,6 +220,12 @@ $last = get_option('newsletter_last');
213
  <strong>{unsubscription_url}</strong> unsubscription URL.
214
  </td>
215
  </tr>
 
 
 
 
 
 
216
  </table>
217
 
218
 
93
  <h2>Newsletter Composer</h2>
94
 
95
  <h3>Last batch infos</h3>
96
+ <p>Here you find information about last sending batch. A sending batch may have completed
97
+ or not. If not you can use the "restart" button and the batch starts again from the last
98
+ email address processed.</p>
99
+
100
+ <div style="padding: 15px; border: 1px solid #ccc">
101
  <?php if (!$last) { ?>
102
+ No batch info found.
103
  <?php } else { ?>
104
+
105
  Total emails to send: <?php echo $last['total']; ?><br />
106
  Emails sent till now: <?php echo $last['sent']; ?><br />
107
  Last email (if empty the batch has completed): <?php echo $last['email']; ?><br />
108
+
109
  <?php } ?>
110
+ </div>
111
 
112
 
113
 
156
  if (!$res)
157
  {
158
  echo '</p><form action="" method="post">Still some emails to send.';
159
+ wp_nonce_field();
160
  echo '<input type="submit" name="simulate2" value="Proceed"/>';
161
  echo '</form>';
162
  }
220
  <strong>{unsubscription_url}</strong> unsubscription URL.
221
  </td>
222
  </tr>
223
+ <tr valign="top">
224
+ <td>
225
+ Max emails to send in a single batch<br />
226
+ <input name="options[max]" type="text" size="5" value="<?php echo htmlspecialchars($options['max'])?>"/>
227
+ </td>
228
+ </tr>
229
  </table>
230
 
231
 
plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Newsletter
4
  Plugin URI: http://www.satollo.net/plugins/newsletter
5
  Description: Newsletter is a simple plugin (still in developement) to collect subscribers and send out newsletters
6
- Version: 1.1.8
7
  Author: Satollo
8
  Author URI: http://www.satollo.net
9
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -173,6 +173,7 @@ function newsletter_send_batch($subject, $message, $simulate=true)
173
  global $wpdb;
174
 
175
  $options = get_option('newsletter');
 
176
 
177
  // Get infos on the last batch sent
178
  $last = get_option('newsletter_last');
@@ -236,7 +237,7 @@ function newsletter_send_batch($subject, $message, $simulate=true)
236
  $last['sent']++;
237
 
238
  // Timeout check, max time is zero if set_time_limit works
239
- if ($max_time != 0 && (time()-$start_time) > $max_time)
240
  {
241
  $last['email'] = $r->email;
242
  update_option('newsletter_last', $last);
3
  Plugin Name: Newsletter
4
  Plugin URI: http://www.satollo.net/plugins/newsletter
5
  Description: Newsletter is a simple plugin (still in developement) to collect subscribers and send out newsletters
6
+ Version: 1.1.9
7
  Author: Satollo
8
  Author URI: http://www.satollo.net
9
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
173
  global $wpdb;
174
 
175
  $options = get_option('newsletter');
176
+ $options_email = get_option('newsletter_email');
177
 
178
  // Get infos on the last batch sent
179
  $last = get_option('newsletter_last');
237
  $last['sent']++;
238
 
239
  // Timeout check, max time is zero if set_time_limit works
240
+ if (($options_email['max'] && $idx > $options_email['max']) || ($max_time != 0 && (time()-$start_time) > $max_time))
241
  {
242
  $last['email'] = $r->email;
243
  update_option('newsletter_last', $last);
readme.txt CHANGED
@@ -3,7 +3,7 @@
3
  Tags: newsletter,email,subscription,mass mail
4
  Requires at least: 2.7
5
  Tested up to: 2.8.4
6
- Stable tag: 1.1.8
7
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2545483
8
  Contributors: satollo
9
 
3
  Tags: newsletter,email,subscription,mass mail
4
  Requires at least: 2.7
5
  Tested up to: 2.8.4
6
+ Stable tag: 1.1.9
7
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2545483
8
  Contributors: satollo
9