Subscribe2 - Version 1.1

Version Description

Download this release

Release Info

Developer MattyRob
Plugin Icon 128x128 Subscribe2
Version 1.1
Comparing to
See all releases

Version 1.1

subscribe.php ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Subscribe2
4
+ // Copyright 2004 Scott Merrill skippy@skippy.net
5
+ // Distributed under the terms of the GNU Public License
6
+ // http://www.gnu.org/copyleft/gpl.html
7
+
8
+ require_once('./wp-blog-header.php');
9
+ $admin = get_userdata(1);
10
+
11
+ $s2 = get_option('s2_options');
12
+
13
+ $domain = 'subscribe2';
14
+ $locale = get_locale();
15
+ $mofile = ABSPATH . "wp-content/plugins/$domain-$locale.mo";
16
+ load_textdomain($domain, $mofile);
17
+
18
+ // the database table to use
19
+ $s2_table = $table_prefix . "subscribe2";
20
+
21
+ $email = (isset($_POST['email'])) ? $_POST['email'] : '';
22
+ $action = (isset($_POST['action'])) ? $_POST['action'] : '';
23
+ $hash = (isset($_GET['x'])) ? $_GET['x'] : '';
24
+
25
+ if ('' != $hash) {
26
+ $foo = explode('x', $hash);
27
+ $action = $foo[0];
28
+ $id = $foo[2];
29
+ $sql = "SELECT email FROM " . $s2_table . " WHERE id='" . $id . "'";
30
+ $email = $wpdb->get_var($sql);
31
+ if ('' == $email) {
32
+ main('invalid');
33
+ }
34
+ if ('a' == $action) {
35
+ if ('2' == s2_check($email)) {
36
+ s2_confirm($email);
37
+ main('added');
38
+ } else {
39
+ main('already_there');
40
+ }
41
+ } elseif ('d' == $action) {
42
+ s2_delete($email);
43
+ main('deleted');
44
+ } else {
45
+ // safety valve
46
+ main();
47
+ }
48
+ }
49
+
50
+ if ( ('' != $action) && ( ('' == $email) || (! is_email($email)) )) {
51
+ main('invalid');
52
+ }
53
+
54
+ if ( strtolower($admin->user_email) == strtolower($email) ) {
55
+ main('self');
56
+ }
57
+
58
+ if ('add' == $action) {
59
+ if ('0' !== s2_check($email)) {
60
+ main('already_there');
61
+ }
62
+ s2_add($email);
63
+ s2_send_confirmation ($email, 'add');
64
+ main('add_confirm');
65
+ }elseif ('delete' == $action) {
66
+ if ('0' === s2_check($email)) {
67
+ main('not_there');
68
+ }
69
+ s2_send_confirmation ($email, 'delete');
70
+ main('delete_confirm');
71
+ } else {
72
+ main();
73
+ }
74
+
75
+ /////////////////
76
+ // *** main() ***
77
+ // display the main page
78
+ /////////////////
79
+ function main($doing = '') {
80
+ global $s2;
81
+
82
+ // Display the page
83
+ get_header();
84
+ get_sidebar();
85
+ // display a message, depending on what was passed to main()
86
+ if ('' == $doing) {
87
+ $doing = 'welcome';
88
+ }
89
+ echo '<div id="content" class="narrowcolumn"><div class="post"><p>' . stripslashes($s2["s2_$doing"]) . "</p>\r\n";
90
+ if ( ('not_there' == $doing) || ('already_there' == $doing) || ('self' == $doing) || ('invalid' == $doing) || ('welcome' == $doing) ) {
91
+ echo '<p><form method="post">';
92
+ echo __('Your email', 'subscribe2') . ':&#160;<input type="text" name="email" value="" size="20" />&#160;<br />';
93
+ echo '<input type="radio" name="action" value="add" checked="checked" />' . __('subscribe', 'subscribe2') . "\r\n";
94
+ echo '<input type="radio" name="action" value="delete" />' . __('unsubscribe', 'subscribe2') . "&#160\r\n";
95
+ echo '<input type="submit" value="Send!" />';
96
+ echo "</form></p>\r\n";
97
+ }
98
+ echo '<p><strong>' . __('Note', 'subscribe2') . ':</strong> ' . get_settings('blogname') . ' ' . __('values personal privacy', 'subscribe2') . '.<br />';
99
+ _e('This list is used solely to inform you when new posts are added.', 'subscribe2');
100
+ echo "<br />\r\n";
101
+ _e('Your email address will not be shared with any other party', 'subscribe2');
102
+ echo ".</p>\r\n";
103
+ echo '<p><a href="' . get_settings('siteurl') . '">' . __('Return to ', 'subscribe2') . get_settings('blogname') . "</a></p>\r\n";
104
+ echo "</div></div>\r\n";
105
+
106
+ get_footer();
107
+ die;
108
+ } // main()
109
+
110
+ ////////////////////
111
+ // *** s2_check() ***
112
+ // check whether an email address exists in the database
113
+ // return values:
114
+ // 0 == not present
115
+ // 1 == present, and confirmed
116
+ // 2 == present, and not confirmed
117
+ ////////////////////
118
+ function s2_check ($email = '') {
119
+ global $wpdb, $s2_table;
120
+
121
+ if ( ('' == $email) || (! is_email($email)) ) {
122
+ // no valid email, so bail out
123
+ return '0';
124
+ }
125
+ $query = "SELECT * FROM " . $s2_table . " WHERE email='" . $email . "'";
126
+ $foo = $wpdb->get_row($query);
127
+
128
+ if ('1' === $foo->active) {
129
+ return '1';
130
+ } elseif ('0' === $foo->active) {
131
+ return '2';
132
+ } else {
133
+ return '0';
134
+ }
135
+ } // s2_check
136
+
137
+ ///////////////////
138
+ // *** s2_add() ***
139
+ // add an email address to the database with a status of "0" (unconfirmed)
140
+ ///////////////////
141
+ function s2_add ($email = '') {
142
+ global $wpdb, $s2_table;
143
+ if ( ('' == $email) || (! is_email($email)) ) {
144
+ // no valid email, so bail out
145
+ return;
146
+ }
147
+ // check to make sure the address isn't already there
148
+ if ('0' != s2_check($email)) {
149
+ // user exists, so bail out
150
+ return '1';
151
+ }
152
+ $sql = "INSERT INTO " . $s2_table . " (email, active) VALUES ('" . $email . "', '0')";
153
+ $result = $wpdb->query($sql);
154
+ } // s2_add
155
+
156
+ ///////////////////////
157
+ // *** s2_confirm() ***
158
+ // change the status of an email address in the database to "1" (confirmed)
159
+ ///////////////////////
160
+ function s2_confirm ($email = '') {
161
+ global $s2, $wpdb, $s2_table;
162
+
163
+ if ( ('' == $email) || (! is_email($email)) ) {
164
+ // no valid email, so bail out
165
+ return;
166
+ }
167
+
168
+ $admin = get_userdata(1);
169
+
170
+ if ('2' == s2_check($email)) {
171
+ $sql = "UPDATE " . $s2_table . " SET active = '1' WHERE email = '" . $email . "'";
172
+ $result = $wpdb->query($sql);
173
+ $mailtext = __('The following email address has successfully subscribed to your blog', 'subscribe2') . ":\n\n $email\n";
174
+ $mailheaders = "From: $admin->user_nickname <$admin->user_email>";
175
+ mail($admin->user_email, stripslashes($s2['s2_subscribed_admin_subject']), $mailtext, $mailheaders);
176
+ }
177
+ } // s2_confirm
178
+
179
+ //////////////////////
180
+ // *** s2_delete() ***
181
+ // remove an email address from the database
182
+ //////////////////////
183
+ function s2_delete ($email = '') {
184
+ global $s2, $wpdb, $s2_table;
185
+
186
+ if ( ('' == $email) || (! is_email($email)) ) {
187
+ // no valid email, so bail out
188
+ return;
189
+ }
190
+ if ('0' === s2_check($email)) {
191
+ // user does not exist, bail out
192
+ return;
193
+ }
194
+ $sql = "DELETE FROM " . $s2_table . " WHERE email = '" . $email . "'";
195
+ $result = $wpdb->query($sql);
196
+
197
+ $admin = get_userdata(1);
198
+
199
+ $mailtext = __('The following email address has successfully unsubscribed from your blog', 'subscribe2') . ":\n\n $email\n";
200
+ $mailheaders = "From: $admin->user_nickname <$admin->user_email>";
201
+ mail($admin->user_email, $s2['s2_unsubscribed_admin_subject'], $mailtext, $mailheaders);
202
+ } // s2_delete
203
+
204
+ ///////////////////////////
205
+ // *** s2_send_confirmaion() ***
206
+ // send a confirmation email to an address
207
+ ///////////////////////////
208
+ function s2_send_confirmation ($email = '', $action = '') {
209
+ global $wpdb, $s2_table, $s2;
210
+
211
+ if ( ('' == $email) || (! is_email($email)) || ('' == $action) ) {
212
+ // no valid email or action, so bail out
213
+ return;
214
+ }
215
+
216
+ $sql = "SELECT id FROM " . $s2_table . " WHERE email = '" . $email . "'";
217
+ $id = $wpdb->get_var($sql);
218
+
219
+ if ('add' == $action) {
220
+ // link to confirm their address
221
+ $link = get_settings('siteurl') . "/" . basename($_SERVER['PHP_SELF']) . "?x=ax" . md5($email) . "x" . $id;
222
+ } elseif ('delete' == $action) {
223
+ // link to confirm their address
224
+ $link = get_settings('siteurl') . "/" . basename($_SERVER['PHP_SELF']) . "?x=dx" . md5($email) . "x" . $id;
225
+ }
226
+
227
+ $admin = get_userdata(1);
228
+
229
+ $body = stripslashes(str_replace("LINK", $link, $s2['s2_confirm_email']));
230
+ $body = str_replace("BLOGNAME", get_settings('blogname'), $body);
231
+ $body = str_replace("MYNAME", $admin->user_nickname, $body);
232
+ $body = str_replace("EMAIL", $admin->user_email, $body);
233
+
234
+ $subject = stripslashes(str_replace("BLOGNAME", get_settings('blogname'), $s2['s2_confirm_subject']));
235
+ $subject = str_replace("MYNAME", $admin->user_nickname, $subject);
236
+ $subject = str_replace("EMAIL", $admin->user_email, $subject);
237
+
238
+ $mailheaders = "From: $admin->user_nickname <$admin->user_email>";
239
+ mail ($email, $subject, $body, $mailheaders);
240
+ } // s2_send_confirmation()
241
+
242
+ ?>
subscribe2.CHANGELOG ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Changelog:
2
+ 2.1.0
3
+ fresh i18n effort: /wp-content/subscribe2/ contains the .mo and .po files
4
+ both subscribe2.php and subscribe.php are translatable: place the appropriate .po file in the same directory as the source file for which it provides the translation
5
+ 2.0.9
6
+ added editable subject line when sending an email to all subscribers
7
+ 2.0.8
8
+ fixed batch logic
9
+ 2.0.7
10
+ fixed broken comment
11
+ 2.0.6
12
+ added $dreamhost manual override to force batched notification delivery
13
+ thanks to Wade Emmert and Joe Mezzanini (http://themezz.com/) for their help
14
+ added Content-Type text/plain for plaintext mail delivery.
15
+ thanks to Toto:
16
+ http://www.skippy.net/blog/2005/02/17/subscribe2/#comment-2059
17
+ 2.0.5
18
+ added strip_tags() to plaintext email delivery, to remove HTML from post content
19
+ added date check to suppress sending notification on future-dated posts
20
+
21
+ 2.0.4
22
+ fixed a typo which broke sending excerpts -- Thanks MarcoB!
23
+
24
+ 2.0.3
25
+ added __() and _e(), plus subscribe2.po for localization
26
+ added stripslashes to (I hope!) all output
27
+ 2.0.2
28
+ beautified output of categories to exlude
29
+
30
+ 2.0.1
31
+ minor form fixes -- thanks Matt Read
32
+
33
+ 2.0.0
34
+ major overhaul.
35
+ using new admin menu hooks
36
+ added Options page for web-based control of all messages
37
+ added HTML email support
38
+
39
+ 1.5.6:
40
+ tightened up check against our own email; now only checks for an exact match against the admin email as defined in the blog options.
41
+ updated description of $categories_to_skip to indicate that category IDs should be entered
42
+
43
+ 1.5.5:
44
+ fixed error handling when blank or invalid emails are passed to subscribe.php
45
+ fixed name used to sign email messages sent from subscribe.php: now using the admin account (user ID 1) email and nicename
46
+
47
+ 1.5.4:
48
+ fixed s2_style() to check for 1.5, which should fix it for 1.2 again. Sorry 'bout that.
49
+
50
+ 1.5.3:
51
+ fixed s2_style() to only include the style when loading the Subscriber management page adjusted subscribe.php to (hopefully) utilize the active theme (WordPress 1.5+ only)
52
+
53
+ 1.5.2:
54
+ fixed subscribe.php link generation (thanks Anthony: http://www.anthonyemigration.net/)
55
+ added check before including upgrade-functions.php (thanks Indi: http://www.indi.ca/)
56
+ added $categories_to_skip to allow bypass of email for certain categories
57
+ added email notification to admin on successful (un)subscribe operation
58
+
59
+ 1.5.1:
60
+ fixed problem for 1.2 users
61
+
62
+ 1.5:
63
+ integrated management into WordPress admin section
64
+
65
+ 1.1:
66
+ added is_array() checks to suppress spurious PHP warnings (thanks aalex: www.sourcelibre.com)
67
+ fixed broken $form calls (d'oh)
68
+
69
+ 1.0:
70
+ first version
71
+
subscribe2.README ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ == subscribe2 ==
2
+
3
+ Tags: subscribe, email
4
+ copyright (c) 2004 Scott Merrill
5
+ skippy@skippy.net | http://skippy.net/
6
+ Released under the terms of the GNU General Public License.
7
+ Distributed with no warranty. Use it at your own risk.
8
+
9
+ This plugin provides a comprehensive subscription management system for WordPress blogs. Visitors can subscribe and unsubscribe through a convenient web-based form. All requests require confirmation by email.
10
+ Administators can configure the email template used for new post notifications, as well the messages used for (un)subscription requests. Admins can also subscribe or unsubscribe users, as well as send out an email to all confirmed subscribers.
11
+
12
+ == INSTALLATION ==
13
+
14
+ 1) Copy the subscribe2.php file into your /wp-content/plugins/ directory.
15
+ 2) Copy the subscribe.php file to the root of your WordPress installation.
16
+ 3) Activate the plugin.
17
+ 4) Click the "Options" admin menu link, and select "Subscribe2".
18
+ 5) Configure the options to taste, including the email template and messages displayed to subscribers.
19
+ 6) Click the "Manage" admin menu link, and select "Subscribers".
20
+ 7) Manually subscribe people as you see fit.
21
+ 8) Add a link somewhere in your template to subscribe.php:
22
+
23
+ <a href="/subscribe.php">Sign up for email notifications whenever my blog is updated!</a>
24
+
25
+ You can use the WordPress Links manager for this, if you'd prefer.
26
+
27
+ ***********************
28
+ ** AN IMPORTANT NOTE **
29
+ ***********************
30
+ Some hosting providers place a restriction on the maximum number of recipients in any one email message. For example, the venerable Dreamhost (http://www.dreamhost.com/) does not allow any message to contain more than 30 recipients.
31
+
32
+ Previous versions of this plugin would simlpy fail to work correctly if your subscriber list was larger than the maximum number of permitted recipients: the mail server would gobble up the post notification and no one would ever receive the message.
33
+
34
+ Starting with version 2.0.6, subscribe2.php now includes a variable, $dreamhost, which is declared at the very top of the script. By default, this variable is 0 (zero). If you change the zero to 1 (one), subscribe2 will now batch post notification messages for 30 (thirty) recipients at a time. If your host is even more restrictive than Dreamhost, simply change all instances of "30" to a lower value that will work.
35
+
36
+ To enable this batch operation, edit the file subscribe2.php, move to line 14, and change the 0 to 1. Save the file. You're done.
37
+
38
+ Reminder: because subscribe2 places all recipients in BCC fields, and places the blog admin in the TO field, the blog admin will receive one email per batched delivery. So if you have 90 subscribers, the blog admin should receive three post notification emails, one for eah set of 30 BCC recipients.
39
+
40
+ Many thanks to Wade Emmert and Joe Messanini for their patience and their assistance in testing this new functionality.
41
+
42
+ == TRANSLATION ==
43
+ Using the files in /wp-content/subscribe2/ you can translate the text that this plugin displays. Create a subscribe2-xx_XX.po and subscribe2-xx_XX.mo file (where xx_XX is your langauge locale) and place these files in /wp-content/plugins/. subscribe2 will should immediately begin using the translated text you supply.
44
+
45
+ The .mo file you create or download will provide translations for both the WordPress administration screens, as well as the user subscription page.
46
+
47
+ See here for additional localization information:
48
+ http://codex.wordpress.org/Localizing_WordPress
49
+
wp-content/plugins/subscribe2.php ADDED
@@ -0,0 +1,737 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Subscribe2
4
+ Plugin URI: http://www.skippy.net/blog/2005/02/17/subscribe2
5
+ Description: Notifies an email list when new entries are posted.
6
+ Version: 2.1.1
7
+ Author: Scott Merrill
8
+ Author URI: http://www.skippy.net/
9
+ */
10
+
11
+ // ****************************************
12
+ // CHANGE THIS TO 1 IF YOU ARE ON DREAMHOST
13
+ // ****************************************
14
+ $dreamhost = 1;
15
+
16
+ /////////////////////
17
+ // main program block
18
+ add_action ('admin_menu', 'subscribe2_menu');
19
+ add_action ('publish_post', 'subscribe2', 8);
20
+ //////////// END MAIN PROGRAM /////////////
21
+
22
+
23
+ //////////// BEGIN FUNCTIONS //////////////
24
+ function subscribe2_menu() {
25
+ add_management_page(__('Subscribers', 'subscribe2'), __('Subscribers', 'subscribe2'), 9, __FILE__, 's2_manage');
26
+ add_options_page(__('Subscribe2 Options', 'subscribe2'), __('Subscribe2', 'subscribe2'), 9, __FILE__, 's2_options');
27
+ }
28
+
29
+ //////////////////////////////////
30
+ if (! function_exists('subscribe2')) {
31
+ function subscribe2 ($post_ID = 0) {
32
+ global $dreamhost, $table_prefix, $wpdb;
33
+
34
+ $s2_table = $table_prefix . "subscribe2";
35
+
36
+ // gets the name of your blog
37
+ $blogname = get_settings('blogname');
38
+ // gets the link to the new post
39
+ $postlink = get_permalink($post_ID);
40
+ $postdata = get_postdata($post_ID);
41
+ $cats = wp_get_post_cats('1', $post_ID);
42
+
43
+ // is this post's date set in the future?
44
+ if ($postdata['Date'] > current_time('mysql')) {
45
+ // if so, let's not tell anyone about this
46
+ return $post_ID;
47
+ }
48
+
49
+ // get our options
50
+ $s2 = get_option('s2_options');
51
+
52
+ // should we bypass the email notice on this post?
53
+ $skip = explode(',', $s2['s2_cats_to_skip']);
54
+ $bypass = '0';
55
+ foreach ($skip as $skippy) {
56
+ if ('1' == $bypass) { break; }
57
+ if (in_array($skippy, $cats)) {
58
+ $bypass = '1';
59
+ }
60
+ }
61
+ if ('1' == $bypass) { return $post_ID; }
62
+
63
+ // do we send as admin, or post author?
64
+ if ('author' == $s2['s2_sender']) {
65
+ // get author details
66
+ $user = get_userdata($postdata['Author_ID']);
67
+ } else {
68
+ // get admin detailts
69
+ $user = get_userdata(1);
70
+ }
71
+ $myname = $user->user_nicename;
72
+ $myemailadd = $user->user_email;
73
+
74
+ // gets the path to your blog directory
75
+ $s2_link = get_settings('siteurl') . "/subscribe.php";
76
+
77
+ // get the list of active recipients from the database
78
+ $sql = "SELECT email FROM " . $s2_table . " WHERE active='1'";
79
+ $recipients = $wpdb->get_col($sql);
80
+ if (count($recipients) == 0) {
81
+ // no one to send to!
82
+ return $post_ID;
83
+ }
84
+
85
+ // Set email subject
86
+ $subject = stripslashes($s2['s2_subject']);
87
+ // do any substitutions that are necessary
88
+ $subject = str_replace('BLOGNAME', $blogname, $subject);
89
+ $subject = str_replace('TITLE', $postdata['Title'], $subject);
90
+ $subject = str_replace('MYNAME', $myname, $subject);
91
+ $subject = str_replace('EMAIL', $myemailadd, $subject);
92
+
93
+ // Set sender details
94
+ $headers = "From: " . $myname . " <" . $myemailadd . ">\r\n";
95
+
96
+ // BCC all recipients
97
+ // with batching for Dreamhost
98
+ if (1 == $dreamhost) {
99
+ $count = 1;
100
+ $bcc = '';
101
+ $batch = array();
102
+ foreach ($recipients as $recipient) {
103
+ $recipient = trim($recipient);
104
+ if (! empty($recipient)) {
105
+ $bcc .= "Bcc: " . $recipient . "\r\n";
106
+ }
107
+ if (30 == $count) {
108
+ $count = 1;
109
+ $batch[] = $bcc;
110
+ $bcc = '';
111
+ } else {
112
+ $count++;
113
+ }
114
+ }
115
+ if (0 == count($batch)) {
116
+ // we have less than 30 subscribers, so let's skip batching
117
+ $headers .= $bcc;
118
+ unset($batch);
119
+ }
120
+ } else {
121
+ // we're not on dreamhost, so do it normal
122
+ foreach ($recipients as $recipient) {
123
+ $recipient = trim($recipient);
124
+ if (! empty($recipient)) {
125
+ $headers .= "Bcc: " . $recipient . "\r\n";
126
+ }
127
+ }
128
+ }
129
+
130
+ // prepare the message template
131
+ $mailtext = stripslashes($s2['s2_mailtext']);
132
+ $mailtext = str_replace('BLOGNAME', $blogname, $mailtext);
133
+ $mailtext = str_replace('BLOGLINK', get_bloginfo('url'), $mailtext);
134
+ $mailtext = str_replace('TITLE', $postdata['Title'], $mailtext);
135
+ $mailtext = str_replace('PERMALINK', $postlink, $mailtext);
136
+ $mailtext = str_replace('S2LINK', $s2_link, $mailtext);
137
+ $mailtext = str_replace('MYNAME', $myname, $mailtext);
138
+ $mailtext = str_replace('EMAIL', $myemailadd, $mailtext);
139
+ if ('post' == $s2['s2_excerpt']) {
140
+ $content = $postdata['Content'];
141
+ } elseif ('excerpt' == $s2['s2_excerpt']) {
142
+ $content = $postdata['Excerpt'];
143
+ } else {
144
+ $content = '';
145
+ }
146
+ $mailtext = str_replace('EXCERPT', $content, $mailtext);
147
+
148
+ if ('html' == $s2['s2_html']) {
149
+ // To send HTML mail, the Content-type header must be set
150
+ $headers .= 'MIME-Version: 1.0' . "\r\n";
151
+ $headers .= 'Content-type: ' . get_bloginfo('html_type') . '; charset='. get_bloginfo('charset');
152
+ $mailtext = apply_filters('the_content', $mailtext);
153
+ $mailtext = str_replace(']]>', ']]&gt;', $mailtext);
154
+ $mailtext = "<html><head><title>$subject</title></head><body>" . $mailtext . "</body></html>";
155
+ } else {
156
+ $headers .= 'MIME-Version: 1.0' . "\r\n";
157
+ $headers .= 'Content-type: text/plain; charset='. get_bloginfo('charset');
158
+ $mailtext = strip_tags($mailtext);
159
+ }
160
+
161
+ // And away we go...
162
+ if (isset($_POST['publish'])) { // we only want to send on publish
163
+ // handle batches for Dreamhost
164
+ if ( (1 == $dreamhost) && (isset($batch)) ) {
165
+ foreach ($batch as $bcc) {
166
+ $newheaders = $headers . $bcc;
167
+ mail($myemailadd, $subject, $mailtext, $newheaders);
168
+ }
169
+ } else {
170
+ mail($myemailadd, $subject, $mailtext, $headers);
171
+ }
172
+ }
173
+ return $post_ID;
174
+ } // end subscribe2
175
+ }
176
+
177
+ ///////////////////////
178
+ function s2_install() {
179
+ // include upgrade-functions for maybe_create_table;
180
+ if (! function_exists('maybe_create_table')) {
181
+ require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
182
+ }
183
+
184
+ global $table_prefix;
185
+ $s2_table = $table_prefix . "subscribe2";
186
+ $s2_table_sql = "CREATE TABLE " . $s2_table . "( id int(11) NOT NULL auto_increment, email varchar(64) NOT NULL default '', active tinyint(1) default 0, PRIMARY KEY (id) )";
187
+
188
+ // create the table, as needed
189
+ maybe_create_table($s2_table, $s2_table_sql);
190
+
191
+ s2_reset();
192
+ } // s2_install
193
+
194
+ ///////////////////
195
+ function s2_reset() {
196
+ $s2 = array ('s2_html' => 'text',
197
+ 's2_sender' => 'author',
198
+ 's2_excerpt' => 'excerpt',
199
+ 's2_subject' => 'BLOGNAME has been updated!',
200
+ 's2_mailtext' => "BLOGNAME has posted a new item, 'TITLE'\r\nEXCERPT\r\nYou may view the latest post at\r\nPERMALINK\r\nYou received this e-mail because you asked to be notified when new updates are posted.\r\nIf you no longer wish to receive notifications of new posts then please visit:\r\nS2LINK\r\n\nBest regards,\r\nMYNAME\r\nEMAIL",
201
+ 's2_welcome' => 'By subscribing to this service you will be notified every time a new post is added.',
202
+ 's2_confirm_subject' => 'Confirmation Request from BLOGNAME',
203
+ 's2_confirm_email' => "In order to confirm your request for BLOGNAME, please click on the link below:\n\nLINK\n\nIf you did not request this, please feel free to disregard this notice!\n\nThank you,\nMYNAME.",
204
+ 's2_invalid' => 'Sorry, but that does not look like an email address to me!',
205
+ 's2_self' => "Thanks, but I'll make my own decisions about my email!",
206
+ 's2_already_there' => 'I already know about that email address.',
207
+ 's2_not_there' => "That email address wasn't in the system.",
208
+ 's2_add_confirm' => 'Thank you for subscribing, a confirmation email is on its way!',
209
+ 's2_delete_confirm' => 'An email has been sent to you with further instructions.',
210
+ 's2_added' => 'Your email address has been successfully subscribed. Thank you!',
211
+ 's2_deleted' => 'Your email has been removed from the list.',
212
+ 's2_subscribed_admin_subject' => 'New subscriber!',
213
+ 's2_unsubscribed_admin_subject' => 'Subscriber removed.',
214
+ 's2_cats_to_skip' => ''
215
+ );
216
+
217
+ update_option('s2_options', $s2, '', 'no');
218
+
219
+ } // end s2_reset
220
+
221
+ ////////////////////
222
+ function s2_options() {
223
+ global $wpdb, $table_prefix, $cache_categories;
224
+
225
+ $s2_table = $table_prefix . "subscribe2";
226
+
227
+ // check if we need to install the table
228
+ $sql = "SELECT COUNT(id) FROM " . $s2_table;
229
+ // turn errors off, for the momemnt
230
+ $errors = $wpdb->hide_errors();
231
+ $foo = $wpdb->get_var($sql);
232
+ // turn errors back on
233
+ $errors = $wpdb->show_errors();
234
+ if ('' == $foo) { s2_install(); }
235
+
236
+ // now try to figure out what we're supposed to do
237
+ if (isset($_POST['s2_admin'])) {
238
+ $admin = $_POST['s2_admin'];
239
+ }
240
+ if ('options' == $admin) {
241
+ s2_options_update();
242
+ } elseif ('RESET' == $admin) {
243
+ s2_reset();
244
+ }
245
+
246
+ $s2 = get_option('s2_options');
247
+
248
+ load_plugin_textdomain('subscribe2');
249
+
250
+ echo '<div class="wrap">';
251
+ echo '<h2>' . __('Notification Settings', 'subscribe2') . "</h2>\r\n";
252
+ echo '<form method="POST">';
253
+ echo '<input type="hidden" name="s2_admin" value="options" />';
254
+ echo '<fieldset class="options"><legend>' . __('Email Options', 'subscribe2') . ':</legend>';
255
+ echo __('Send email as', 'subscribe2') . ': &nbsp;&nbsp;';
256
+ echo '<input type="radio" name="s2_html" value="html"';
257
+ if ('html' == $s2['s2_html']) {
258
+ echo 'checked="checked" ';
259
+ }
260
+ echo '/> ' . __('HTML', 'subscribe2') .' &nbsp;&nbsp;';
261
+ echo '<input type="radio" name="s2_html" value="text" ';
262
+ if ('text' == $s2['s2_html']) {
263
+ echo 'checked="checked" ';
264
+ }
265
+ echo '/> ' . __('Plain Text', 'subscribe2') . "<br /><br />\r\n";
266
+ echo __('Send Email From', 'subscribe2') . ':&nbsp;&nbsp;';
267
+ echo '<input type="radio" name="s2_sender" value="author" ';
268
+ if ('author' == $s2['s2_sender']) {
269
+ echo 'checked="checked" ';
270
+ }
271
+ echo ' /> ' . __('Author of the post', 'subscribe2') . ' &nbsp;&nbsp;';
272
+ echo '<input type="radio" name="s2_sender" value="admin" ';
273
+ if ('admin' == $s2['s2_sender']) {
274
+ echo 'checked="checked" ';
275
+ }
276
+ echo ' /> ' . __('Blog Admin', 'subscribe2') . "<br /><br />\r\n";
277
+ echo __('Amount of post to deliver', 'subscribe2') . ':&nbsp;&nbsp;';
278
+
279
+ $foo = array ('none' => __('None', 'subscribe2'), 'excerpt' => __('Excerpt Only', 'subscribe2'), 'post' => __('Full Post', 'subscribe2'));
280
+ foreach ($foo as $value => $key) {
281
+ echo '<input type="radio" name="s2_excerpt" value="' . $value . '"';
282
+ if (strtolower($value) == strtolower($s2['s2_excerpt'])) {
283
+ echo ' checked="checked"';
284
+ }
285
+ echo ' /> ' . $key . '&nbsp;&nbsp;';
286
+ }
287
+ echo '</fieldset>';
288
+
289
+ echo '<fieldset class="options"><legend>' . __('Email Template', 'subscribe2') . "</legend>\r\n";
290
+ echo __('Subject', 'subscribe2') . ': (' . __('must not be empty', 'subscribe2') . ')';
291
+ echo "<br />\r\n";
292
+ echo '<input type="text" name="s2_subject" size="60" value="' . stripslashes($s2['s2_subject']) . '" />';
293
+ echo "<br /><br />\r\n";
294
+ echo __('Message', 'subscribe2') . ': (' . __('must not be empty', 'subscribe2') . ')';
295
+ echo "<br />\r\n";
296
+ echo '<textarea rows="15" cols="90" name="s2_mailtext">' . stripslashes($s2['s2_mailtext']) . "</textarea>\r\n";
297
+
298
+ echo '<fieldset class="options"><legend>' . __('Message substitions', 'subscribe2') . ":</legend>\r\n";
299
+ echo '<table width="100%">';
300
+ echo '<tr><td width="50%">';
301
+ echo '<ul>';
302
+ echo '<li><b>BLOGNAME</b>: ' . __('replaced with', 'subscribe2') . ' ' . get_bloginfo('name') . "</li>\r\n";
303
+ echo '<li><b>BLOGLINK</b>: ' . __('replaced with', 'subscribe2') . ' ' . get_bloginfo('url') . "</li>\r\n";
304
+ echo '<li><b>TITLE</b>: ' . __('replaced with', 'subscribe2') . ' ' . __("the post's title", 'subscribe2') . "</li>\r\n";
305
+ echo '<li><b>EXCERPT</b>: ' . __('replaced with', 'subscribe2') . ' ' . __('blank, the excerpt, or the entire post, based on the option set above', 'subscribe2') . "</li>\r\n";
306
+ echo '</ul>';
307
+ echo "</td><td>\r\n";
308
+ echo '<ul>';
309
+ echo '<li><b>PERMALINK</b>: ' . __('replaced with', 'subscribe2') . ' ' . __("the post's permalink", 'subscribe2') . "</li>\r\n";
310
+ echo '<li><b>S2LINK</b>: ' . __('replaced with', 'subscribe2') . ' ' . __('a link to your subscribe.php file', 'subscribe2') . "</li>\r\n";
311
+ echo '<li><b>MYNAME</b>: ' . __('replaced with', 'subscribe2') . ' ' . __("the post author's name", 'subscribe2') . "</li>\r\n";
312
+ echo '<li><b>EMAIL</b>: ' . __('replaced with', 'subscribe2') . ' ' . __("the post author's email", 'subscribe2') . "</li>\r\n";
313
+ echo '</ul>';
314
+ echo '</td></tr>';
315
+ echo "</table>\r\n";
316
+ echo "</fieldset>\r\n";
317
+ echo "</fieldset>\r\n";
318
+
319
+ echo '<h2>' . __('Subscription Messages', 'subscribe2') . "</h2>\r\n";
320
+ echo '<fieldset class="options"><legend>' . __('Website messages', 'subscribe2') . ":</legend>\r\n";
321
+ echo '<table width="100%" cellspacing="2" cellpadding="5" class="editform">';
322
+ echo '<tr><td colspan="2" align="center">';
323
+ echo __('Welcome message', 'subscribe2') . ":<br />\r\n";
324
+ echo '<input type="text" size="90" name="s2_welcome" value="' . stripslashes($s2['s2_welcome']) . '" />';
325
+ echo "</td></tr>\r\n";
326
+ echo "<tr><td>\r\n";
327
+ echo __('Invalid email was supplied', 'subscribe2') . ":<br />\r\n";
328
+ echo '<input type="text" size="53" name="s2_invalid" value="' . stripslashes($s2['s2_invalid']) . '" />';
329
+ echo "</td><td>\r\n";
330
+ echo __('Your email was supplied', 'subscribe2') . ":<br />\r\n";
331
+ echo '<input type="text" size="53" name="s2_self" value="' . stripslashes($s2['s2_self']) . '" />';
332
+ echo "<td></tr>\r\n";
333
+ echo "<tr><td>\r\n";
334
+ echo __('Known email was supplied', 'subscribe2') . ":<br />\r\n";
335
+ echo '<input type="text" size="53" name="s2_already_there" value="' . stripslashes($s2['s2_already_there']) . '" />';
336
+ echo "</td><td>\r\n";
337
+ echo __('Non-existant email supplied', 'subscribe2') . ":<br />\r\n";
338
+ echo '<input type="text" size="53" name="s2_not_there" value="' . stripslashes($s2['s2_not_there']) . '" />';
339
+ echo "<td></tr>\r\n";
340
+ echo "<tr><td>\r\n";
341
+ echo __('Subscribe confirmation email dispatched', 'subscribe2') . ":<br />\r\n";
342
+ echo '<textarea cols="50" rows="3" name="s2_add_confirm">' . stripslashes($s2['s2_add_confirm']) . '</textarea>';
343
+ echo "</td><td>\r\n";
344
+ echo __('Unsubscribe confirmation email dispatched', 'subscribe2') . ":<br />\r\n";
345
+ echo '<textarea cols="50" rows="3" name="s2_delete_confirm">' . stripslashes($s2['s2_delete_confirm']) . '</textarea>';
346
+ echo "</td><tr>\r\n";
347
+ echo "<tr><td>\r\n";
348
+ echo __('Successful subscription message', 'subscribe2') . ":<br />\r\n";
349
+ echo '<input type="text" size="53" name="s2_added" value="' . stripslashes($s2['s2_added']) . '" />';
350
+ echo "</td><td>\r\n";
351
+ echo __('Successful deletion message', 'subscribe2') . ":<br />\r\n";
352
+ echo '<input type="text" size="53" name="s2_deleted" value="' . stripslashes($s2['s2_deleted']) . '" />';
353
+ echo "</td></tr>\r\n";
354
+ echo '</table>';
355
+ echo "</fieldset>\r\n";
356
+
357
+ echo '<fieldset class="options"><legend>' . __('Email messages', 'subscribe2') . ":</legend>\r\n";
358
+ echo '<table width="100%" cellspacing="2" cellpadding="5" class="editform">';
359
+ echo '<tr><td colspan="2">';
360
+ echo __('Subject line for all confirmation emails', 'subscribe2') . ":<br />\r\n";
361
+ echo '<input type="text" size="50" name="s2_confirm_subject" value="' . stripslashes($s2['s2_confirm_subject']) . '" />';
362
+ echo "</td></tr>\r\n";
363
+ echo '<tr><td colspan="2">';
364
+ echo __('Subscribe / Unsubscribe confirmation email', 'subscribe2') . ":<br />\r\n";
365
+ echo '<textarea cols="80" rows="5" name="s2_confirm_email">' . stripslashes($s2['s2_confirm_email']) . '</textarea>';
366
+ echo "</td></tr>\r\n";
367
+ echo "<tr><td>\r\n";
368
+ echo __('Subscribe notification subject sent to admin', 'subscribe2') . ":<br />\r\n";
369
+ echo '<input type="text" size="50" name="s2_subscribed_admin_subject" value="' . stripslashes($s2['s2_subscribed_admin_subject']) . '" />';
370
+ echo "</td><td>\r\n";
371
+ echo __('Unsubscribe notification subject sent to admin', 'subscribe2') . ":<br />\r\n";
372
+ echo '<input type="text" size="50" name="s2_unsubscribed_admin_subject" value="' . stripslashes($s2['s2_unsubscribed_admin_subject']) . '" />';
373
+ echo "</td></tr>\r\n";
374
+ echo "</table>\r\n";
375
+
376
+ echo '<fieldset class="options"><legend>' . __('Message substitions', 'subscribe2') . ":</legend>\r\n";
377
+ echo '<ul>';
378
+ echo '<li><b>BLOGNAME</b>: ' . __('replaced with', 'subscribe2') . ' ' . __("the blog's name", 'subscribe2') . "</li>\r\n";
379
+ echo '<li><b>LINK</b>: ' . __('replaced with', 'subscribe2') . ' ' . __("the confirmation link for the user's request", 'subscribe2') . "</li>\r\n";
380
+ echo '<li><b>MYNAME</b>: ' . __('replaced with', 'subscribe2') . ' ' . __("the post author's name", 'subscribe2') . "</li>\r\n";
381
+ echo '<li><b>EMAIL</b>: ' . __('replaced with', 'subscribe2') . ' ' . __("the post author's email", 'subscribe2') . "</li>\r\n";
382
+ echo "</ul></fieldset></fieldset>\r\n";
383
+
384
+ echo '<h2>' . __('Categories to Exclude', 'subscribe2') . "</h2>\r\n";
385
+ echo '<table width="50%" cellspacing="2" cellpadding="5" class="editform" align="center">';
386
+ echo '<tr><td width="50%" align="left">';
387
+
388
+ // let's collect all of our excluded categories
389
+ $excluded = array();
390
+ $excluded = explode(',', $s2['s2_cats_to_skip']);
391
+
392
+ // let's get an array of all the categories
393
+ if (count($cache_categories) == 0) {
394
+ update_category_cache();
395
+ }
396
+ $half = (count($cache_categories) / 2);
397
+ $i = 0;
398
+ $j = 0;
399
+ foreach ($cache_categories as $cat) {
400
+ if ( ($i > $half) && (0 == $j) ){
401
+ echo '</td><td width="50%" align="right">';
402
+ $j++;
403
+ }
404
+ if (0 == $j) {
405
+ echo '<input type="checkbox" name="' . $cat->cat_ID . '" ';
406
+ if (in_array($cat->cat_ID, $excluded)) {
407
+ echo 'checked="checked" ';
408
+ }
409
+ echo '/>' . $cat->cat_name . "<br />\r\n";
410
+ } else {
411
+ echo $cat->cat_name . ' <input type="checkbox" name="' . $cat->cat_ID . '" ';
412
+ if (in_array($cat->cat_ID, $excluded)) {
413
+ echo 'checked="checked" ';
414
+ }
415
+ echo "/><br />\r\n";
416
+ }
417
+ $i++;
418
+ }
419
+ echo "</td></tr></table>\r\n";
420
+ echo '<p align="center"><input type="submit" name="submit" value="submit" /></p>';
421
+ echo "</form>\r\n";
422
+
423
+ echo '<h2>' . __('Reset Default', 'subscribe2') . "</h2>\r\n";
424
+ echo '<fieldset class="options">';
425
+ echo '<p>';
426
+ _e('Use this to reset all options to their defaults. This <strong><em>will not</em></strong> modify your list of subscribers.', 'subscribe2');
427
+ echo "</p>";
428
+ echo '<form method="POST">';
429
+ echo '<p align="center">';
430
+ echo '<input type="submit" name="s2_admin" value="RESET" />';
431
+ echo "</p></form></fieldset>\r\n";
432
+
433
+ include(ABSPATH . '/wp-admin/admin-footer.php');
434
+ // just to be sure
435
+ die;
436
+
437
+ } // s2_options
438
+
439
+ ////////////////////
440
+ function s2_manage() {
441
+ global $admin_sent, $table_prefix, $wpdb;
442
+
443
+ $s2_table = $table_prefix . "subscribe2";
444
+
445
+ // check if we need to install the table
446
+ $sql = "SELECT COUNT(id) FROM " . $s2_table;
447
+ // turn errors off, for the momemnt
448
+ $errors = $wpdb->hide_errors();
449
+ $foo = $wpdb->get_var($sql);
450
+ // turn errors back on
451
+ $errors = $wpdb->show_errors();
452
+ if ('' == $foo) { s2_install(); }
453
+
454
+ // now try to figure out what we're supposed to do
455
+ if (isset($_POST['s2_admin'])) {
456
+ $admin = $_POST['s2_admin'];
457
+ }
458
+
459
+ if ('delete' == $admin) {
460
+ s2_admin_delete();
461
+ } elseif ('send' == $admin) {
462
+ s2_admin_send();
463
+ } elseif ('subscribe' == $admin) {
464
+ s2_admin_subscribe();
465
+ } elseif ('toggle' == $admin) {
466
+ s2_admin_toggle();
467
+ }
468
+
469
+ load_plugin_textdomain('subscribe2');
470
+
471
+ // get the list of confirmed subscribers
472
+ $sql = "SELECT email FROM " . $s2_table . " WHERE active='1' ORDER BY email ASC";
473
+ $confirmed = $wpdb->get_col($sql);
474
+
475
+ // get unconfirmed subscribers
476
+ $sql = "SELECT email FROM " . $s2_table . " WHERE active='0' ORDER BY email ASC";
477
+ $unconfirmed = $wpdb->get_col($sql);
478
+ if ('admin_sent' == $admin_sent) {
479
+ echo '<div class="updated"><p align="center">' . __('Message delivered!', 'subscribe2') . "</p></div>\r\n";
480
+ }
481
+
482
+ echo '<div class="wrap">';
483
+ echo '<h2>' . __('Admin Tools', 'subscribe2') . "</h2>\r\n";
484
+ echo '<table width="100%"><tr><td align="left">';
485
+ echo "<form method='POST'>\r\n";
486
+ echo __('Subscribe Addresses', 'subscribe2') . ': (' . __('one per line, or comma-seperated', 'subscribe2') . ")<br />\r\n";
487
+ echo '<textarea rows="10" cols="55" name="addresses"></textarea>';
488
+ echo "<br />\r\n";
489
+ echo '<input type="submit" name="s2_admin" value="subscribe">';
490
+ echo '</form></td><td align="right">';
491
+ echo "<form method='POST'>\r\n";
492
+ echo __('Send email to all subscribers', 'subscribe2') . ':';
493
+ echo '<input type="text" size="30" name="s2_subject" value="' . __('A message from ', 'subscribe2') . get_settings('blogname') . '" /> <br />';
494
+ echo '<textarea rows="10" cols="55" name="message"></textarea>';
495
+ echo "<br />\r\n";
496
+ echo '<input type="submit" name="s2_admin" value="send">&nbsp;';
497
+ echo "</form></td></tr></table>\r\n";
498
+ echo '<div style="clear: both;"><p>&nbsp;</p></div>';
499
+ echo '<h2>' . __('Subscribers', 'subscribe2') . "</h2>\r\n";
500
+ echo '<table width="45%" cellpadding="3" cellspacing="3" align="left">';
501
+ echo '<tr><th colspan="3"><strong>' . __('Confirmed Subscribers', 'subscribe2') . ':</strong></th></tr>';
502
+
503
+ if (is_array($confirmed)) {
504
+ $alternate = 'alternate';
505
+ foreach ($confirmed as $subscriber) {
506
+ echo '<tr class="' . $alternate . '">';
507
+ echo '<td width="5%" align="center"><form method="POST"><input type="hidden" name="email" value="' . $subscriber . '" /><input type="hidden" name="s2_admin" value="delete" /><input type="submit" name="submit" value=" X " /></form></td>';
508
+ echo '<td align="center"><a href="mailto:' . $subscriber . '">' . $subscriber . "</a></td>\r\n";
509
+ echo '<td width="5%" align="center"><form method="POST"><input type="hidden" name="email" value="' . $subscriber .'" /><input type="hidden" name="s2_admin" value="toggle" /><input type="submit" name="submit" value="-&gt;" /></form></td>';
510
+ echo "</tr>\r\n";
511
+ ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
512
+ }
513
+ } else {
514
+ echo '<tr><td width="100%" align="center" colspan="3"><strong>' . __('NONE', 'subscribe2') . "</strong></td></tr>\r\n";
515
+ }
516
+ echo "</table>\r\n";
517
+ echo '<table width="45%" cellpadding="3" cellspacing="3" align="right">';
518
+ echo '<tr><th colspan="3"><strong>' . __('Uncomfirmed Subscribers', 'subscribe2') . ":</strong></th></tr>\r\n";
519
+
520
+ if (is_array($unconfirmed)) {
521
+ $alternate = 'alternate';
522
+ foreach ($unconfirmed as $subscriber) {
523
+ echo '<tr class="' . $alternate . '">';
524
+ echo '<td width="5%" align="center"><form method="POST"><input type="hidden" name="email" value="' . $subscriber . '" /><input type="hidden" name="s2_admin" value="toggle" /><input type="submit" name="submit" value="&lt;-" /></form></td>';
525
+ echo '<td align="center"><a href="mailto:' . $subscriber . '">' . $subscriber . "</a></td>\r\n";
526
+ echo '<td width="5%" align="center"><form method="POST"><input type="hidden" name="email" value="' . $subscriber . '" /><input type="hidden" name="s2_admin" value="delete" /><input type="submit" name="submit" value=" X " /></form></td>';
527
+ echo "</tr>\r\n";
528
+ ('alternate' == $alternate) ? $alternate = '' : $alternate = 'alternate';
529
+ }
530
+ } else {
531
+ echo '<tr><td width="100%" align="center" colspan="3"><strong>' . __('NONE', 'subscribe2') . "</strong></td></tr>\r\n";
532
+ }
533
+
534
+ echo "</table>\r\n";
535
+ echo '<div style="clear: both;"><p>&nbsp;</p></div>';
536
+ echo "</div>\r\n";
537
+
538
+ include(ABSPATH . '/wp-admin/admin-footer.php');
539
+ // just to be sure
540
+ die;
541
+ } // end s2_manage
542
+
543
+ /////////////////////////////
544
+ function s2_admin_subscribe() {
545
+ global $wpdb, $table_prefix;
546
+
547
+ $s2_table = $table_prefix . "subscribe2";
548
+
549
+ foreach (preg_split ("/[\s,]+/", $_POST['addresses']) as $email) {
550
+ if (is_email($email)) {
551
+ if (! $wpdb->get_var("SELECT id FROM $s2_table WHERE email='$email'")) {
552
+ $wpdb->query("INSERT INTO $s2_table (email, active) VALUES ('$email', '1')");
553
+ }
554
+ }
555
+ } // foreach...
556
+
557
+ $_POST['s2_admin'] = '';
558
+ s2_manage();
559
+ die; // just to be sure
560
+ } // s2_admin_subscribe
561
+
562
+ //////////////////////////
563
+ function s2_admin_delete() {
564
+ global $wpdb, $table_prefix;
565
+
566
+ $s2_table = $table_prefix . "subscribe2";
567
+
568
+ if ( (isset($_POST['email'])) && ('' != $_POST['email']) && ( is_email($_POST['email'])) ) {
569
+ $email = $_POST['email'];
570
+ if ($wpdb->get_var("SELECT id FROM $s2_table WHERE email = '$email'")) {
571
+ $result = $wpdb->query("DELETE FROM $s2_table WHERE email = '$email'");
572
+ }
573
+ }
574
+ $_POST['s2_admin'] = '';
575
+ s2_manage();
576
+ die; // just to be sure
577
+ } // s2_admin_delete;
578
+
579
+ //////////////////////////
580
+ function s2_admin_toggle() {
581
+ global $wpdb, $table_prefix;
582
+
583
+ $s2_table = $table_prefix . "subscribe2";
584
+
585
+ if ( (isset($_POST['email'])) && ('' != $_POST['email']) && ( is_email($_POST['email'])) ) {
586
+ $email = $_POST['email'];
587
+ $sql = "SELECT active FROM $s2_table WHERE email='$email'";
588
+ $active = $wpdb->get_var($sql);
589
+ if ('0' === $active) {
590
+ $foo = '1';
591
+ } elseif ('1' == $active) {
592
+ $foo = '0';
593
+ }
594
+ if (isset($foo)) {
595
+ $sql = "UPDATE $s2_table SET active='$foo' where email='$email'";
596
+ $result = $wpdb->query($sql);
597
+ }
598
+ }
599
+ $_POST['s2_admin'] = '';
600
+ s2_manage();
601
+ die();
602
+ } // end s2_admin_toggle
603
+
604
+ ///////////////////////
605
+ function s2_admin_send() {
606
+ global $dreamhost, $wpdb, $table_prefix, $user_identity, $user_email;
607
+
608
+ if ( (! isset($_POST['message'])) || ('' == $_POST['message'])) {
609
+ s2_manage();
610
+ }
611
+
612
+ get_currentuserinfo();
613
+ $subject = $_POST['s2_subject'];
614
+ $mailtext = stripslashes($_POST['message']);
615
+
616
+ $s2_table = $table_prefix . "subscribe2";
617
+
618
+ // Set sender details
619
+ $headers = "From: " . $user_identity . " <" . $user_email . ">\r\n";
620
+
621
+ // get the list of active recipients from the database
622
+ $sql = "SELECT email FROM $s2_table WHERE active='1'";
623
+ $recipients = $wpdb->get_col($sql);
624
+ if (count($recipients) == 0) {
625
+ // <admiral ackbar> it's a trap!! </ackbar>
626
+ s2_manage();
627
+ }
628
+
629
+ // BCC all recipients
630
+ // with batching for Dreamhost
631
+ if (1 == $dreamhost) {
632
+ $count = 1;
633
+ $bcc = '';
634
+ $batch = array();
635
+ foreach ($recipients as $recipient) {
636
+ $recipient = trim($recipient);
637
+ if (! empty($recipient)) {
638
+ $bcc .= "BCC: " . $recipient . "\r\n";
639
+ }
640
+ if (30 == $count) {
641
+ $batch[] = $bcc;
642
+ $count = 1;
643
+ $bcc = '';
644
+ } else {
645
+ $count++;
646
+ }
647
+ }
648
+ if (0 == count($batch)) {
649
+ // we have less than 30 subscribers, so let's skip batching
650
+ $headers .= $bcc;
651
+ unset($batch);
652
+ }
653
+ } else {
654
+ foreach ($recipients as $recipient) {
655
+ $recipient = trim($recipient);
656
+ if (! empty($recipient)) {
657
+ $headers .= "BCC: " . $recipient . "\r\n";
658
+ }
659
+ }
660
+ }
661
+
662
+ $s2 = get_option('s2_options');
663
+ if ('html' == $s2['s2_html']) {
664
+ $mailtext = "<html><head><title>$subject</title></head><body>$mailtext</body></html>";
665
+ $headers .= 'MIME-Version: 1.0' . "\r\n";
666
+ $headers .= 'Content-type: ' . get_bloginfo('html_type') . '; charset='. get_bloginfo('charset');
667
+ } else {
668
+ $headers .= 'MIME-Version: 1.0' . "\r\n";
669
+ $headers .= 'Content-type: text/plain; charset='. get_bloginfo('charset');
670
+ }
671
+
672
+ if ( (1 == $dreamhost) && (isset($batch)) ) {
673
+ foreach ($batch as $bcc) {
674
+ $newheaders = $headers . $bcc;
675
+ mail($myemailadd, $subject, $mailtext, $newheaders);
676
+ }
677
+ } else {
678
+ mail($user_email, $subject, $mailtext, $headers);
679
+ }
680
+
681
+ $_POST['s2_admin'] = '';
682
+ global $admin_sent;
683
+ $admin_sent = 'admin_sent';
684
+ s2_manage();
685
+ die();
686
+ } // s2_admin_send()
687
+
688
+ ///////////////////////////
689
+ function s2_options_update() {
690
+ global $cache_categories;
691
+
692
+ if (0 == count($cache_categories)) {
693
+ update_categories_cache();
694
+ }
695
+
696
+ $exclude_list = '';
697
+
698
+ foreach ($cache_categories as $cat) {
699
+ if (isset($_POST[$cat->cat_ID])) {
700
+ if ('' == $exclude_list) {
701
+ $exclude_list = "$cat->cat_ID";
702
+ } else {
703
+ $exclude_list .= ",$cat->cat_ID";
704
+ }
705
+ }
706
+ }
707
+
708
+ $s2 = array ('s2_html' => $_POST['s2_html'],
709
+ 's2_sender' => $_POST['s2_sender'],
710
+ 's2_excerpt' => $_POST['s2_excerpt'],
711
+ 's2_subject' => $_POST['s2_subject'],
712
+ 's2_mailtext' => $_POST['s2_mailtext'],
713
+ 's2_welcome' => $_POST['s2_welcome'],
714
+ 's2_confirm_subject' => $_POST['s2_confirm_subject'],
715
+ 's2_confirm_email' => $_POST['s2_confirm_email'],
716
+ 's2_invalid' => $_POST['s2_invalid'],
717
+ 's2_self' => $_POST['s2_self'],
718
+ 's2_already_there' => $_POST['s2_already_there'],
719
+ 's2_not_there' => $_POST['s2_not_there'],
720
+ 's2_add_confirm' => $_POST['s2_add_confirm'],
721
+ 's2_delete_confirm' => $_POST['s2_delete_confirm'],
722
+ 's2_added' => $_POST['s2_added'],
723
+ 's2_deleted' => $_POST['s2_deleted'],
724
+ 's2_subscribed_admin_subject' => $_POST['s2_subscribed_admin_subject'],
725
+ 's2_unsubscribed_admin_subject' => $_POST['s2_unsubscribed_admin_subject'],
726
+ 's2_cats_to_skip' => $exclude_list
727
+ );
728
+
729
+ update_option('s2_options', $s2);
730
+
731
+ $_POST['s2_admin'] = "";
732
+ s2_options();
733
+ die;
734
+ } // s2_options_update
735
+
736
+
737
+ ?>
wp-content/subscribe2/subscribe2-en_US.mo ADDED
Binary file
wp-content/subscribe2/subscribe2-en_US.po ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: subscribe2\n"
4
+ "POT-Creation-Date: \n"
5
+ "PO-Revision-Date: 2005-06-22 19:59-0500\n"
6
+ "Last-Translator: skippy <skippy@skippy.net>\n"
7
+ "Language-Team: skippy <skippy@skippy.net>\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=utf-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Poedit-Language: English\n"
12
+ "X-Poedit-Country: United States\n"
13
+ "X-Poedit-SourceCharset: utf-8\n"
14
+ "X-Poedit-Keywords: __,_e\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+
18
+ #: subscribe.php:92
19
+ msgid "Your email"
20
+ msgstr "Your email"
21
+
22
+ #: subscribe.php:93
23
+ msgid "subscribe"
24
+ msgstr "subscribe"
25
+
26
+ #: subscribe.php:94
27
+ msgid "unsubscribe"
28
+ msgstr "unsubscribe"
29
+
30
+ #: subscribe.php:98
31
+ msgid "Note"
32
+ msgstr "Note"
33
+
34
+ #: subscribe.php:98
35
+ msgid "values personal privacy"
36
+ msgstr "values personal privacy"
37
+
38
+ #: subscribe.php:99
39
+ msgid "This list is used solely to inform you when new posts are added."
40
+ msgstr "This list is used solely to inform you when new posts are added."
41
+
42
+ #: subscribe.php:101
43
+ msgid "Your email address will not be shared with any other party"
44
+ msgstr "Your email address will not be shared with any other party"
45
+
46
+ #: subscribe.php:103
47
+ msgid "Return to "
48
+ msgstr "Return to "
49
+
50
+ #: subscribe.php:173
51
+ msgid "The following email address has successfully subscribed to your blog"
52
+ msgstr "The following email address has successfully subscribed to your blog"
53
+
54
+ #: subscribe.php:199
55
+ msgid "The following email address has successfully unsubscribed from your blog"
56
+ msgstr "The following email address has successfully unsubscribed from your blog"
57
+
58
+ #: subscribe2.php:25
59
+ #: subscribe2.php:499
60
+ msgid "Subscribers"
61
+ msgstr "Subscribers"
62
+
63
+ #: subscribe2.php:26
64
+ msgid "Subscribe2 Options"
65
+ msgstr "Subscribe2 Options"
66
+
67
+ #: subscribe2.php:26
68
+ msgid "Subscribe2"
69
+ msgstr "Subscribe2"
70
+
71
+ #: subscribe2.php:251
72
+ msgid "Notification Settings"
73
+ msgstr "Notification Settings"
74
+
75
+ #: subscribe2.php:254
76
+ msgid "Email Options"
77
+ msgstr "Email Options"
78
+
79
+ #: subscribe2.php:255
80
+ msgid "Send email as"
81
+ msgstr "Send email as"
82
+
83
+ #: subscribe2.php:260
84
+ msgid "HTML"
85
+ msgstr "HTML"
86
+
87
+ #: subscribe2.php:265
88
+ msgid "Plain Text"
89
+ msgstr "Plain Text"
90
+
91
+ #: subscribe2.php:266
92
+ msgid "Send Email From"
93
+ msgstr "Send Email From"
94
+
95
+ #: subscribe2.php:271
96
+ msgid "Author of the post"
97
+ msgstr "Author of the post"
98
+
99
+ #: subscribe2.php:276
100
+ msgid "Blog Admin"
101
+ msgstr "Blog Admin"
102
+
103
+ #: subscribe2.php:277
104
+ msgid "Amount of post to deliver"
105
+ msgstr "Amount of post to deliver"
106
+
107
+ #: subscribe2.php:279
108
+ msgid "None"
109
+ msgstr "None"
110
+
111
+ #: subscribe2.php:279
112
+ msgid "Excerpt Only"
113
+ msgstr "Excerpt Only"
114
+
115
+ #: subscribe2.php:279
116
+ msgid "Full Post"
117
+ msgstr "Full Post"
118
+
119
+ #: subscribe2.php:289
120
+ msgid "Email Template"
121
+ msgstr "Email Template"
122
+
123
+ #: subscribe2.php:290
124
+ msgid "Subject"
125
+ msgstr "Subject"
126
+
127
+ #: subscribe2.php:290
128
+ #: subscribe2.php:294
129
+ msgid "must not be empty"
130
+ msgstr "must not be empty"
131
+
132
+ #: subscribe2.php:294
133
+ msgid "Message"
134
+ msgstr "Message"
135
+
136
+ #: subscribe2.php:298
137
+ #: subscribe2.php:376
138
+ msgid "Message substitions"
139
+ msgstr "Message substitions"
140
+
141
+ #: subscribe2.php:302
142
+ #: subscribe2.php:303
143
+ #: subscribe2.php:304
144
+ #: subscribe2.php:305
145
+ #: subscribe2.php:309
146
+ #: subscribe2.php:310
147
+ #: subscribe2.php:311
148
+ #: subscribe2.php:312
149
+ #: subscribe2.php:378
150
+ #: subscribe2.php:379
151
+ #: subscribe2.php:380
152
+ #: subscribe2.php:381
153
+ msgid "replaced with"
154
+ msgstr "replaced with"
155
+
156
+ #: subscribe2.php:304
157
+ msgid "the post's title"
158
+ msgstr "the post's title"
159
+
160
+ #: subscribe2.php:305
161
+ msgid "blank, the excerpt, or the entire post, based on the option set above"
162
+ msgstr "blank, the excerpt, or the entire post, based on the option set above"
163
+
164
+ #: subscribe2.php:309
165
+ msgid "the post's permalink"
166
+ msgstr "the post's permalink"
167
+
168
+ #: subscribe2.php:310
169
+ msgid "a link to your subscribe.php file"
170
+ msgstr "a link to your subscribe.php file"
171
+
172
+ #: subscribe2.php:311
173
+ #: subscribe2.php:380
174
+ msgid "the post author's name"
175
+ msgstr "the post author's name"
176
+
177
+ #: subscribe2.php:312
178
+ #: subscribe2.php:381
179
+ msgid "the post author's email"
180
+ msgstr "the post author's email"
181
+
182
+ #: subscribe2.php:319
183
+ msgid "Subscription Messages"
184
+ msgstr "Subscription Messages"
185
+
186
+ #: subscribe2.php:320
187
+ msgid "Website messages"
188
+ msgstr "Website messages"
189
+
190
+ #: subscribe2.php:323
191
+ msgid "Welcome message"
192
+ msgstr "Welcome message"
193
+
194
+ #: subscribe2.php:327
195
+ msgid "Invalid email was supplied"
196
+ msgstr "Invalid email was supplied"
197
+
198
+ #: subscribe2.php:330
199
+ msgid "Your email was supplied"
200
+ msgstr "Your email was supplied"
201
+
202
+ #: subscribe2.php:334
203
+ msgid "Known email was supplied"
204
+ msgstr "Known email was supplied"
205
+
206
+ #: subscribe2.php:337
207
+ msgid "Non-existant email supplied"
208
+ msgstr "Non-existant email supplied"
209
+
210
+ #: subscribe2.php:341
211
+ msgid "Subscribe confirmation email dispatched"
212
+ msgstr "Subscribe confirmation email dispatched"
213
+
214
+ #: subscribe2.php:344
215
+ msgid "Unsubscribe confirmation email dispatched"
216
+ msgstr "Unsubscribe confirmation email dispatched"
217
+
218
+ #: subscribe2.php:348
219
+ msgid "Successful subscription message"
220
+ msgstr "Successful subscription message"
221
+
222
+ #: subscribe2.php:351
223
+ msgid "Successful deletion message"
224
+ msgstr "Successful deletion message"
225
+
226
+ #: subscribe2.php:357
227
+ msgid "Email messages"
228
+ msgstr "Email messages"
229
+
230
+ #: subscribe2.php:360
231
+ msgid "Subject line for all confirmation emails"
232
+ msgstr "Subject line for all confirmation emails"
233
+
234
+ #: subscribe2.php:364
235
+ msgid "Subscribe / Unsubscribe confirmation email"
236
+ msgstr "Subscribe / Unsubscribe confirmation email"
237
+
238
+ #: subscribe2.php:368
239
+ msgid "Subscribe notification subject sent to admin"
240
+ msgstr "Subscribe notification subject sent to admin"
241
+
242
+ #: subscribe2.php:371
243
+ msgid "Unsubscribe notification subject sent to admin"
244
+ msgstr "Unsubscribe notification subject sent to admin"
245
+
246
+ #: subscribe2.php:378
247
+ msgid "the blog's name"
248
+ msgstr "the blog's name"
249
+
250
+ #: subscribe2.php:379
251
+ msgid "the confirmation link for the user's request"
252
+ msgstr "the confirmation link for the user's request"
253
+
254
+ #: subscribe2.php:384
255
+ msgid "Categories to Exclude"
256
+ msgstr "Categories to Exclude"
257
+
258
+ #: subscribe2.php:423
259
+ msgid "Reset Default"
260
+ msgstr "Reset Default"
261
+
262
+ #: subscribe2.php:426
263
+ msgid "Use this to reset all options to their defaults. This <strong><em>will not</em></strong> modify your list of subscribers."
264
+ msgstr "Use this to reset all options to their defaults. This <strong><em>will not</em></strong> modify your list of subscribers."
265
+
266
+ #: subscribe2.php:479
267
+ msgid "Message delivered!"
268
+ msgstr "Message delivered!"
269
+
270
+ #: subscribe2.php:483
271
+ msgid "Admin Tools"
272
+ msgstr "Admin Tools"
273
+
274
+ #: subscribe2.php:486
275
+ msgid "Subscribe Addresses"
276
+ msgstr "Subscribe Addresses"
277
+
278
+ #: subscribe2.php:486
279
+ msgid "one per line, or comma-seperated"
280
+ msgstr "one per line, or comma-seperated"
281
+
282
+ #: subscribe2.php:492
283
+ msgid "Send email to all subscribers"
284
+ msgstr "Send email to all subscribers"
285
+
286
+ #: subscribe2.php:493
287
+ msgid "A message from "
288
+ msgstr "A message from "
289
+
290
+ #: subscribe2.php:501
291
+ msgid "Confirmed Subscribers"
292
+ msgstr "Confirmed Subscribers"
293
+
294
+ #: subscribe2.php:514
295
+ #: subscribe2.php:531
296
+ msgid "NONE"
297
+ msgstr "NONE"
298
+
299
+ #: subscribe2.php:518
300
+ msgid "Uncomfirmed Subscribers"
301
+ msgstr "Uncomfirmed Subscribers"
302
+