Subscribe to Comments - Version 2.0.1

Version Description

Download this release

Release Info

Developer markjaquith
Plugin Icon wp plugin Subscribe to Comments
Version 2.0.1
Comparing to
See all releases

Version 2.0.1

readme.html ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html>
2
+ <head>
3
+ <title>Subscribe to Comments 2 for WordPress README</title>
4
+ </head>
5
+ <body>
6
+ <h1>Subscribe to Comments 2</h1>
7
+
8
+ <h2>Description</h2>
9
+ <p>Subscribe to Comments 2 is a WordPress plugin that allows commenters on an entry to subscribe to e-mail notifications for subsequent comments. It does <em>NOT</em> e-mail you new blog posts. For that functionality, use Skippy's <a href="http://www.skippy.net/blog/2005/02/17/subscribe2/">Subscribe2 plugin</a>.</p>
10
+
11
+ <h2>Links</h2>
12
+ <p>Here are some of the crucial Subscribe to Comments 2 links</p>
13
+ <ul>
14
+ <li><a href="http://txfx.net/code/wordpress/subscribe-to-comments/">Plugin's home</a></li>
15
+ <li><a href="http://dev.wp-plugins.org/wiki/SubscribeToComments">WP Plugins Wiki Page</a></li>
16
+ <li><a href="http://dev.wp-plugins.org/newticket">Report Bugs or Suggest Features</a></li>
17
+ <li><a href="http://svn.wp-plugins.org/subscribe-to-comments/tags/latest-stable/subscribe-to-comments.zip">Latest Stable Version</a></li>
18
+ <li><a href="http://downloads.wordpress.org/plugin/subscribe-to-comments.zip">Bleeding Edge Development Version</a></li>
19
+ </ul>
20
+
21
+ <h2>Installation</h2>
22
+ <ol>
23
+ <li>Put <code>subscribe-to-comments.php</code> into <code>[wordpress_dir]/wp-content/plugins/</code></li>
24
+ <li>Put <code>wp-subscription-manager.php</code> into your blog's root WordPress directory (the directory where <code>wp-config.php</code> resides)</li>
25
+ <li>Go into the WordPress admin interface and activate the plugin</li>
26
+ <li>Optional: if your WordPress 1.5 theme doesn't have the <code>comment_form</code> hook, or if you would like to manually determine where in your comments form the subscribe checkbox appears, enter this where you would like it: <code>&lt;?php show_subscription_checkbox(); ?&gt;</code></li>
27
+ <li>Optional: If you would like to enable users to subscribe to comments without having to leave a comment, place this somewhere in your template, but make sure it is <strong>outside the comments form</strong>. A good place would be right after the ending <code>&lt;/form&gt;</code> tag for the comments form: <code>&lt;?php show_manual_subscription_form(); ?></code></li>
28
+ </ol>
29
+
30
+ <h2>Change Log</h2>
31
+ <ul>
32
+ <li>2005-06-09 beta 1 released</li>
33
+ <li>Alpha development took place between March and June of 2005</li>
34
+ </ul>
35
+
36
+ <h2>Notes</h2>
37
+ <ul>
38
+ <li>The function &gt;?php comment_subscription_status(); ?&gt; can be used within the comments loop to determine if a comment's author is subscribed or not. e.g.
39
+ <pre><code>&lt;?php if (comment_subscription_status()) { ?&gt;
40
+ Subscribed
41
+ &lt;?php } ?&gt;</code></pre></li>
42
+ <li>You need to be a logged-in WordPress user of 8 or above in order to search for subscriptions on random e-mail addresses or to remove a "do not mail" block.</li>
43
+ <li>The author of the post is always determined to be subscribed, and thus will never see the "subscribe" checkbox for his entries, but instead will see the "entry author" message.</li>
44
+ <li>Users are never e-mailed notifications for their own comments. (important that you know that for testing out the plugin)</li>
45
+ <li>The text shown next to the checkbox for unsubscribed users, the "you are subscribed" text, and the "you are the author of this entry" text can all be customized in the options (Options -&gt; Subscribe to Comments).</li>
46
+ <li>By default, the "subscribe" checkbox is unchecked, but you can change that in the options (i.e. so that it is checked by default).</li>
47
+ <li>The following CSS can be used with the Kubrick theme if you want to use a custom style for the Subscription Manager and should be added to your <code>style.css</code> file:<br /><br />
48
+ <pre>
49
+ /* SUBSCRIPTION MANAGER STYLE */
50
+ .subscription-manager {
51
+ padding: 10px 0 20px 0;
52
+ margin: 5px 0 0 55px;
53
+ width: 650px;
54
+ }
55
+
56
+ div.wrap {
57
+ background: #fafafa;
58
+ padding: 5px 10px;
59
+ margin: 20px 0;
60
+ border: 1px solid #ccc;
61
+ }
62
+
63
+ div.wrap h2 {
64
+ margin: .5em 0 1em 0;
65
+ border-bottom: 2px solid #589bd2;
66
+ }
67
+
68
+ div.wrap fieldset {
69
+ border: 1px solid #555;
70
+ margin: 1em 0;
71
+ padding: 5px 10px;
72
+ }
73
+
74
+ div.wrap fieldset legend {
75
+ font-weight: bold;
76
+ font-size: small;
77
+ }
78
+
79
+ div.wrap p.submit {
80
+ text-align: right;
81
+ }
82
+
83
+
84
+ .updated {
85
+ background: #B9D6EF;
86
+ border: 1px solid #589bd2;
87
+ margin: 1em 5% 10px;
88
+ padding: 0 1em;
89
+ }
90
+
91
+ .updated-error {
92
+ background-color: #FFA3A3;
93
+ border: 1px solid #FF5D5D;
94
+ }
95
+
96
+ div.wrap form {
97
+ margin: 0;
98
+ padding: 0;
99
+ }
100
+
101
+ div.warp li {
102
+ margin-bottom: 6px;
103
+ line-height: 130%;
104
+ }
105
+ /* END SUBSCRIPTION MANAGER STYLE */
106
+
107
+ </pre></li>
108
+
109
+
110
+
111
+
112
+ </ul>
113
+
114
+ </body>
115
+ </html>
subscribe-to-comments.php ADDED
@@ -0,0 +1,864 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Subscribe To Comments
4
+ Version: 2.0.1
5
+ Plugin URI: http://txfx.net/search/subscribe%20to%20comments%202
6
+ Description: Allows readers to recieve notifications of new comments that are posted to an entry
7
+ Author: Mark Jaquith and Jennifer (ScriptyGoddess)
8
+ Author URI: http://scriptygoddess.com/
9
+ */
10
+
11
+
12
+
13
+ ///////////////////////
14
+ /* Display Functions */
15
+ ///////////////////////
16
+
17
+ /* -------------------------
18
+ What follows are the functions that display things in your comments form.
19
+ Feel free to customize them to your needs
20
+ ------------------------- */
21
+
22
+ /* -------------------------
23
+ This is the code that is inserted into your comment form. You may modify it, if you wish.
24
+ ------------------------- */
25
+ function show_subscription_checkbox ($id='0') {
26
+ global $sg_subscribe;
27
+ sg_subscribe_start();
28
+
29
+ if ( $sg_subscribe->checkbox_shown ) return $id;
30
+ if ( !$email = $sg_subscribe->current_viewer_subscription_status() ) : ?>
31
+
32
+ <?php /* ------------------------------------------------------------------- */ ?>
33
+ <?php /* This is the text that is displayed for users who are NOT subscribed */ ?>
34
+ <?php /* ------------------------------------------------------------------- */ ?>
35
+
36
+ <p style="clear: both;" class="subscribe-to-comments">
37
+ <input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" <?php if ($sg_subscribe->default_subscribed) echo 'checked="checked" '; ?>/>
38
+ <label for="subscribe"><?php echo $sg_subscribe->not_subscribed_text; ?></label>
39
+ </p>
40
+
41
+ <?php /* ------------------------------------------------------------------- */ ?>
42
+
43
+ <?php elseif ( $email == 'admin' ) : ?>
44
+
45
+ <?php /* ------------------------------------------------------------- */ ?>
46
+ <?php /* This is the text that is displayed for the author of the post */ ?>
47
+ <?php /* ------------------------------------------------------------- */ ?>
48
+
49
+ <p style="clear: both;" class="subscribe-to-comments">
50
+ <?php echo str_replace('[manager_link]', $sg_subscribe->manage_link($email, true, false), $sg_subscribe->author_text); ?>
51
+ </p>
52
+
53
+ <?php else : ?>
54
+
55
+ <?php /* --------------------------------------------------------------- */ ?>
56
+ <?php /* This is the text that is displayed for users who ARE subscribed */ ?>
57
+ <?php /* --------------------------------------------------------------- */ ?>
58
+
59
+ <p style="clear: both;" class="subscribe-to-comments">
60
+ <?php echo str_replace('[manager_link]', $sg_subscribe->manage_link($email, true, false), $sg_subscribe->subscribed_text); ?>
61
+ </p>
62
+
63
+ <?php /* --------------------------------------------------------------- */ ?>
64
+
65
+ <?php endif;
66
+
67
+ $sg_subscribe->checkbox_shown = true;
68
+ return $id;
69
+ }
70
+
71
+
72
+
73
+ /* -------------------------------------------------------------------- */
74
+ /* This function outputs a "subscribe without commenting" form. */
75
+ /* Place this somewhere within "the loop", but NOT within another form */
76
+ /* This is NOT inserted automaticallly... you must place it yourself */
77
+ /* -------------------------------------------------------------------- */
78
+ function show_manual_subscription_form () {
79
+ global $id, $sg_subscribe, $user_email;
80
+ sg_subscribe_start();
81
+ $sg_subscribe->show_errors('solo_subscribe', '<div class="solo-subscribe-errors">', '</div>', __('<strong>Error: </strong>', 'subscribe-to-comments'), '<br />');
82
+
83
+ if ( !$sg_subscribe->current_viewer_subscription_status() ) :
84
+ get_currentuserinfo(); ?>
85
+
86
+ <?php /* ------------------------------------------------------------------- */ ?>
87
+ <?php /* This is the text that is displayed for users who are NOT subscribed */ ?>
88
+ <?php /* ------------------------------------------------------------------- */ ?>
89
+
90
+ <form action="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ?>" method="post">
91
+ <input type="hidden" name="solo-comment-subscribe" value="solo-comment-subscribe" />
92
+ <input type="hidden" name="postid" value="<?php echo $id; ?>" />
93
+ <input type="hidden" name="ref" value="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>" />
94
+
95
+ <p class="solo-subscribe-to-comments">
96
+ <?php _e('Subscribe without commenting', 'subscribe-to-comments'); ?>
97
+ <br />
98
+ <label for="solo-subscribe-email"><?php _e('E-Mail:', 'subscribe-to-comments'); ?>
99
+ <input type="text" name="email" id="solo-subscribe-email" size="22" value="<?php echo $user_email; ?>" /></label>
100
+ <input type="submit" name="submit" value="<?php _e('Subscribe', 'subscribe-to-comments'); ?>" />
101
+ </p>
102
+ </form>
103
+
104
+ <?php /* ------------------------------------------------------------------- */ ?>
105
+
106
+ <?php endif;
107
+ }
108
+
109
+
110
+
111
+ /* -------------------------
112
+ Use this function on your comments display - to show whether a user is subscribed to comments on the post or not.
113
+ Note: this must be used within the comments loop! It will not work properly outside of it.
114
+ ------------------------- */
115
+ function comment_subscription_status() {
116
+ global $comment;
117
+ if ($comment->comment_subscribe == 'Y') {
118
+ return true;
119
+ } else {
120
+ return false;
121
+ }
122
+ }
123
+
124
+
125
+
126
+
127
+
128
+
129
+ ///////////////////////////////////
130
+ /* DO NOT MODIFY BELOW THIS LINE */
131
+ ///////////////////////////////////
132
+
133
+ class sg_subscribe_settings
134
+ {
135
+ function options_page_contents()
136
+ {
137
+ /** Commit changed options if posted **/
138
+ if($_SERVER['REQUEST_METHOD'] == 'POST')
139
+ {
140
+ update_option('sg_subscribe_settings', $_POST['sg_subscribe_settings']);
141
+ update_option('sg_subscribe_settings', $_POST['sg_subscribe_settings']);
142
+ }
143
+ echo '<h2>Subscribe to Comments Options</h2>';
144
+ echo '<ul>';
145
+
146
+ echo '<li><label for="name">' . __('"From" name for notifications:', 'subscribe-to-comments') . ' <input type="text" size="40" id="name" name="sg_subscribe_settings[name]" value="' . sg_subscribe_settings::form_setting('name') . '" /></label></li>';
147
+ echo '<li><label for="email">' . __('"From" e-mail addresss for notifications:', 'subscribe-to-comments') . ' <input type="text" size="40" id="email" name="sg_subscribe_settings[email]" value="' . sg_subscribe_settings::form_setting('email') . '" /></label></li>';
148
+ echo '<li><label for="default_subscribed"><input type="checkbox" id="default_subscribed" name="sg_subscribe_settings[default_subscribed]" value="default_subscribed"' . sg_subscribe_settings::checkflag('default_subscribed') . ' /> ' . __('"Subscribe" box should be checked by default', 'subscribe-to-comments') . '</label></li>';
149
+ echo '</ul>';
150
+
151
+ echo '<fieldset><legend>' . __('Comment Form Text', 'subscribe-to-comments') . '</legend>';
152
+
153
+ echo '<p>' . __('Customize the messages shown to different people. Use <code>[manager_link]</code> to insert the URI to the Subscription Manager.', 'subscribe-to-comments') . '</p>';
154
+
155
+ echo '<ul>';
156
+
157
+ echo '<li><label for="not_subscribed_text">' . __('Not subscribed', 'subscribe-to-comments') . '</label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="not_subscribed_text" name="sg_subscribe_settings[not_subscribed_text]">' . sg_subscribe_settings::textarea_setting('not_subscribed_text') . '</textarea></li>';
158
+
159
+ echo '<li><label for="subscribed_text">' . __('Subscribed', 'subscribe-to-comments') . '</label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="subscribed_text" name="sg_subscribe_settings[subscribed_text]">' . sg_subscribe_settings::textarea_setting('subscribed_text') . '</textarea></li>';
160
+
161
+ echo '<li><label for="author_text">' . __('Entry Author', 'subscribe-to-comments') . '</label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="author_text" name="sg_subscribe_settings[author_text]">' . sg_subscribe_settings::textarea_setting('author_text') . '</textarea></li>';
162
+
163
+ echo '</ul></fieldset>';
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+ echo '<fieldset>';
173
+ echo '<legend><input type="checkbox" id="use_custom_style" name="sg_subscribe_settings[use_custom_style]" value="use_custom_style"' . sg_subscribe_settings::checkflag('use_custom_style') . ' /> <label for="use_custom_style">' . __('Use custom style for Subscription Manager', 'subscribe-to-comments') . '</label></legend>';
174
+
175
+ echo '<p>' . __('These settings only matter if you are using a custom style. <code>[theme_path]</code> will be replaced with the path to your current theme.', 'subscribe-to-comments') . '</p>';
176
+
177
+ echo '<ul>';
178
+ echo '<li><label for="sg_sub_header">' . __('Path to header:', 'subscribe-to-comments') . ' <input type="text" size="40" id="sg_sub_header" name="sg_subscribe_settings[header]" value="' . sg_subscribe_settings::form_setting('header') . '" /></label></li>';
179
+ echo '<li><label for="sg_sub_sidebar">' . __('Path to sidebar:', 'subscribe-to-comments') . ' <input type="text" size="40" id="sg_sub_sidebar" name="sg_subscribe_settings[sidebar]" value="' . sg_subscribe_settings::form_setting('sidebar') . '" /></label></li>';
180
+ echo '<li><label for="sg_sub_footer">' . __('Path to footer:', 'subscribe-to-comments') . ' <input type="text" size="40" id="sg_sub_footer" name="sg_subscribe_settings[footer]" value="' . sg_subscribe_settings::form_setting('footer') . '" /></label></li>';
181
+
182
+
183
+ echo '<li><label for="before_manager">' . __('HTML for before the subscription manager:', 'subscribe-to-comments') . ' </label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="before_manager" name="sg_subscribe_settings[before_manager]">' . sg_subscribe_settings::textarea_setting('before_manager') . '</textarea></li>';
184
+ echo '<li><label for="after_manager">' . __('HTML for after the subscription manager:', 'subscribe-to-comments') . ' </label><br /><textarea style="width: 98%; font-size: 12px;" rows="2" cols="60" id="after_manager" name="sg_subscribe_settings[after_manager]">' . sg_subscribe_settings::textarea_setting('after_manager') . '</textarea></li>';
185
+ echo '</ul>';
186
+ echo '</fieldset>';
187
+ }
188
+
189
+ function checkflag($optname)
190
+ {
191
+ $options = get_settings('sg_subscribe_settings');
192
+ if($options[$optname] != $optname) return '';
193
+ return ' checked="checked"';
194
+ }
195
+
196
+ function form_setting($optname)
197
+ {
198
+ $options = get_settings('sg_subscribe_settings');
199
+ return htmlspecialchars(stripslashes($options[$optname]), ENT_QUOTES);
200
+ }
201
+
202
+ function textarea_setting($optname)
203
+ {
204
+ $options = get_settings('sg_subscribe_settings');
205
+ return htmlspecialchars(stripslashes($options[$optname]));
206
+ }
207
+
208
+ function options_page()
209
+ {
210
+ /** Display "saved" notification on post **/
211
+ if(isset($_POST['sg_subscribe_settings_submit']))
212
+ {
213
+ echo '<div class="updated"><p><strong>' . __('Options saved.', 'SmallOptions') . '</strong></p></div>';
214
+ }
215
+
216
+ echo '<form method="post"><div class="wrap">';
217
+
218
+ sg_subscribe_settings::options_page_contents();
219
+
220
+ echo '<p class="submit"><input type="submit" name="sg_subscribe_settings_submit" value="';
221
+ _e('Update Options &raquo;', 'subscribe-to-comments');
222
+ echo '" /></p></div>';
223
+ echo '</form>';
224
+ }
225
+
226
+ }
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ class sg_subscribe
235
+ {
236
+ var $errors;
237
+ var $messages;
238
+ var $post_subscriptions;
239
+ var $email_subscriptions;
240
+ var $subscriber_email;
241
+ var $site_email;
242
+ var $site_name;
243
+ var $standalone;
244
+ var $form_action;
245
+ var $checkbox_shown;
246
+ var $use_wp_style;
247
+ var $header;
248
+ var $sidebar;
249
+ var $footer;
250
+ var $before_manager;
251
+ var $after_manager;
252
+ var $email;
253
+ var $new_email;
254
+ var $ref;
255
+ var $key;
256
+ var $key_type;
257
+ var $action;
258
+ var $default_subscribed;
259
+ var $not_subscribed_text;
260
+ var $subscribed_text;
261
+ var $author_text;
262
+
263
+
264
+ function sg_subscribe() {
265
+ global $wpdb;
266
+ $this->db_upgrade_check();
267
+
268
+ $sg_subscribe_settings = get_settings('sg_subscribe_settings');
269
+
270
+ $this->site_email = ( is_email($sg_subscribe_settings['email']) && $sg_subscribe_settings['email'] != 'email@example.com' ) ? $sg_subscribe_settings['email'] : get_bloginfo('admin_email');
271
+ $this->site_name = ( $sg_subscribe_settings['name'] != 'YOUR NAME' && !empty($sg_subscribe_settings['name']) ) ? stripslashes($sg_subscribe_settings['name']) : get_bloginfo('name');
272
+ $this->default_subscribed = ($sg_subscribe_settings['default_subscribed']) ? true : false;
273
+
274
+ $this->not_subscribed_text = stripslashes($sg_subscribe_settings['not_subscribed_text']);
275
+ $this->subscribed_text = stripslashes($sg_subscribe_settings['subscribed_text']);
276
+ $this->author_text = stripslashes($sg_subscribe_settings['author_text']);
277
+
278
+ $this->errors = '';
279
+ $this->post_subscriptions = '';
280
+ $this->email_subscriptions = '';
281
+ }
282
+
283
+
284
+ function manager_init() {
285
+ $sg_subscribe_settings = get_settings('sg_subscribe_settings');
286
+ $this->messages = '';
287
+ $this->use_wp_style = ($sg_subscribe_settings['use_custom_style'] == 'use_custom_style') ? false : true;
288
+ if( !$this->use_wp_style ) {
289
+ $this->header = str_replace('[theme_path]', get_template_directory(), stripslashes($sg_subscribe_settings['header']));
290
+ $this->sidebar = str_replace('[theme_path]', get_template_directory(), stripslashes($sg_subscribe_settings['sidebar']));
291
+ $this->footer = str_replace('[theme_path]', get_template_directory(), stripslashes($sg_subscribe_settings['footer']));
292
+ $this->before_manager = stripslashes($sg_subscribe_settings['before_manager']);
293
+ $this->after_manager = stripslashes($sg_subscribe_settings['after_manager']);
294
+ }
295
+
296
+ // if ( !$this->standalone && $this->use_wp_style ) add_action('admin_head', create_function('$a', 'global $sg_subscribe; $sg_subscribe->sg_wp_head();'));
297
+
298
+ foreach (array('email', 'key', 'ref', 'new_email') as $var) {
299
+ if ( isset($_REQUEST[$var]) && !empty($_REQUEST[$var]) )
300
+ $this->{$var} = trim($_REQUEST[$var]);
301
+
302
+ }
303
+ }
304
+
305
+
306
+ function add_error($text='generic error', $type='manager') {
307
+ $this->errors[$type][] = $text;
308
+ }
309
+
310
+
311
+ function show_errors($type='manager', $before_all='<div class="updated updated-error">', $after_all='</div>', $before_each='<p>', $after_each='</p>'){
312
+ if ( is_array($this->errors[$type]) ) {
313
+ echo $before_all;
314
+ foreach ($this->errors[$type] as $error) {
315
+ echo $before_each . $error . $after_each;
316
+ }
317
+ echo $after_all;
318
+ }
319
+ unset($this->errors);
320
+ }
321
+
322
+
323
+ function add_message($text) {
324
+ $this->messages[] = $text;
325
+ }
326
+
327
+
328
+ function show_messages($before_all='', $after_all='', $before_each='<div class="updated"><p>', $after_each='</p></div>'){
329
+ if ( is_array($this->messages) ) {
330
+ echo $before_all;
331
+ foreach ($this->messages as $message) {
332
+ echo $before_each . $message . $after_each;
333
+ }
334
+ echo $after_all;
335
+ }
336
+ unset($this->messages);
337
+ }
338
+
339
+
340
+ function subscriptions_from_post($postid) {
341
+ if ( is_array($this->post_subscriptions) ) return $this->post_subscriptions;
342
+ global $wpdb;
343
+ $postid = (int) $postid;
344
+ $this->post_subscriptions = $wpdb->get_results("SELECT comment_author_email FROM $wpdb->comments WHERE comment_post_ID = '$postid' AND comment_subscribe='Y' AND comment_author_email != '' AND comment_approved = '1' GROUP BY LCASE(comment_author_email)");
345
+ $subscribed_without_comment = get_post_meta($postid, '_sg_subscribe-to-comments');
346
+ if( is_array($subscribed_without_comment) ) {
347
+ foreach ($subscribed_without_comment as $email)
348
+ $this->post_subscriptions[]->comment_author_email = $email;
349
+ }
350
+ return $this->post_subscriptions;
351
+ }
352
+
353
+
354
+ function subscriptions_from_email($email='') {
355
+ if ( is_array($this->email_subscriptions) ) return $this->email_subscriptions;
356
+ if(!is_email($email)) $email = $this->email;
357
+ global $wpdb;
358
+ $email = $wpdb->escape(strtolower($email));
359
+ $i = 0;
360
+ $subscriptions = $wpdb->get_results("SELECT comment_post_ID FROM $wpdb->comments WHERE LCASE(comment_author_email) = '$email' AND comment_subscribe='Y' AND comment_approved = '1' GROUP BY comment_post_ID");
361
+ if ( is_array($subscriptions) ) {
362
+ foreach ($subscriptions as $subscription) {
363
+ $this->email_subscriptions[$i] = $subscription->comment_post_ID;
364
+ $i++;
365
+ }
366
+ }
367
+ $subscriptions = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_sg_subscribe-to-comments' AND LCASE(meta_value) = '$email' GROUP BY post_id");
368
+ if ( is_array($subscriptions) ) {
369
+ foreach ($subscriptions as $subscription) {
370
+ $this->email_subscriptions[$i] = $subscription->post_id;
371
+ $i++;
372
+ }
373
+ }
374
+ if ($i > 0) {
375
+ sort($this->email_subscriptions, SORT_NUMERIC);
376
+ return $this->email_subscriptions;
377
+ }
378
+ // no subscriptions
379
+ return false;
380
+ }
381
+
382
+
383
+ function solo_subscribe ($email, $postid) {
384
+ global $wpdb, $cache_userdata, $user_email;
385
+ $postid = (int) $postid;
386
+ $email = strtolower($email);
387
+ if ( !is_email($email) ) {
388
+ get_currentuserinfo();
389
+ if ( is_email($user_email) )
390
+ $email = strtolower($user_email);
391
+ else
392
+ $this->add_error(__('Please provide a valid e-mail address.', 'subscribe-to-comments'),'solo_subscribe');
393
+ }
394
+
395
+ if ( ( $email == $this->site_email && is_email($this->site_email) ) || ( $email == get_settings('admin_email') && is_email(get_settings('admin_email')) ) ) $this->add_error(__('This e-mail address may not be subscribed', 'subscribe-to-comments'),'solo_subscribe');
396
+
397
+ if ( is_array($this->subscriptions_from_email($email)) )
398
+ if (in_array($postid, $this->subscriptions_from_email($email))) {
399
+ // already subscribed
400
+ setcookie('comment_author_email_' . COOKIEHASH, stripslashes($email), time() + 30000000, COOKIEPATH);
401
+ $this->add_error(__('You appear to be already subscribed to this entry.', 'subscribe-to-comments'),'solo_subscribe');
402
+ }
403
+ $email = $wpdb->escape($email);
404
+ $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$postid' AND comment_status <> 'closed' AND ( post_status = 'static' OR post_status = 'publish') LIMIT 1");
405
+
406
+ if(!$post) $this->add_error(__('Comments are not allowed on this entry.', 'subscribe-to-comments'),'solo_subscribe');
407
+
408
+ if ( empty($cache_userdata[$post->post_author]) && $post->post_author != 0) {
409
+ $cache_userdata[$post->post_author] = $wpdb->get_row("SELECT * FROM $wpdb->users WHERE ID = $post->post_author");
410
+ $cache_userdata[$cache_userdata[$post->post_author]->user_login] =& $cache_userdata[$post->post_author];
411
+ }
412
+
413
+ $post_author = $cache_userdata[$post->post_author];
414
+
415
+ if ( strtolower($post_author->user_email) == stripslashes($email) ) $this->add_error(__('You appear to be already subscribed to this entry.', 'subscribe-to-comments'),'solo_subscribe');
416
+
417
+ if ( !is_array($this->errors['solo_subscribe']) ) {
418
+ add_post_meta($postid, '_sg_subscribe-to-comments', stripslashes($email));
419
+
420
+ setcookie('comment_author_email_' . COOKIEHASH, stripslashes($email), time() + 30000000, COOKIEPATH);
421
+ $location = $this->manage_link(stripslashes($email), false, false) . '&subscribeid=' . $postid;
422
+ header("Location: $location");
423
+ exit();
424
+ }
425
+ }
426
+
427
+
428
+ function add_subscriber($cid) {
429
+ global $wpdb;
430
+ $id = (int) $id;
431
+ $email = $wpdb->escape(strtolower($wpdb->get_var("SELECT comment_author_email FROM $wpdb->comments WHERE comment_ID = '$cid'")));
432
+ $postid = $wpdb->get_var("SELECT comment_post_ID from $wpdb->comments WHERE comment_ID = '$cid'");
433
+
434
+ $previously_subscribed = ( $wpdb->get_var("SELECT comment_subscribe from $wpdb->comments WHERE comment_post_ID = '$postid' AND LCASE(comment_author_email) = '$email' AND comment_subscribe = 'Y' LIMIT 1") || in_array(stripslashes($email), get_post_meta($postid, '_sg_subscribe-to-comments')) ) ? true : false;
435
+
436
+ // If user wants to be notified or has previously subscribed, set the flag on this current comment
437
+ if (($_POST['subscribe'] == 'subscribe' && is_email($email)) || $previously_subscribed) {
438
+ delete_post_meta($postid, '_sg_subscribe-to-comments', stripslashes($email));
439
+ $wpdb->query("UPDATE $wpdb->comments SET comment_subscribe = 'Y' where comment_post_ID = '$postid' AND LCASE(comment_author_email) = '$email'");
440
+ }
441
+ return $cid;
442
+ }
443
+
444
+
445
+ function is_blocked($email='') {
446
+ global $wpdb;
447
+ if ( !is_email($email) ) $email = $this->email;
448
+ if ( empty($email) ) return false;
449
+ $email = strtolower($email);
450
+ // add the option if it doesn't exist
451
+ add_option('do_not_mail', '');
452
+ $blocked = explode (' ', get_settings('do_not_mail'));
453
+ if ( in_array($email, $blocked) ) {
454
+ return true;
455
+ }
456
+ return false;
457
+ }
458
+
459
+
460
+ function add_block($email='') {
461
+ if ( !is_email($email) ) $email = $this->email;
462
+ global $wpdb;
463
+ $email = strtolower($email);
464
+
465
+ // add the option if it doesn't exist
466
+ add_option('do_not_mail', '');
467
+
468
+ // check to make sure this email isn't already in there
469
+ if ( !$this->is_blocked($email) ) {
470
+ // email hasn't already been added - so add it
471
+ $blocked = get_settings('do_not_mail') . ' ' . $email;
472
+ update_option('do_not_mail', $blocked);
473
+ return true;
474
+ }
475
+ return false;
476
+ }
477
+
478
+
479
+ function remove_block($email='') {
480
+ if ( !is_email($email) ) $email = $this->email;
481
+ global $wpdb;
482
+ $email = strtolower($email);
483
+
484
+ if ( $this->is_blocked($email) ) {
485
+ // e-mail is in the list - so remove it
486
+ $blocked = str_replace (' ' . $email, '', explode (' ', get_settings('do_not_mail')));
487
+ update_option('do_not_mail', $blocked);
488
+ return true;
489
+ }
490
+ return false;
491
+ }
492
+
493
+
494
+ function hidden_form_fields() { ?>
495
+ <input type="hidden" name="ref" value="<?php echo $this->ref; ?>" />
496
+ <input type="hidden" name="key" value="<?php echo $this->key; ?>" />
497
+ <input type="hidden" name="email" value="<?php echo $this->email; ?>" />
498
+ <?php
499
+ }
500
+
501
+
502
+ function validate_key() {
503
+ global $user_level;
504
+
505
+ if ( $this->key == md5($this->email . DB_PASSWORD) )
506
+ $this->key_type = 'normal';
507
+ elseif ( $this->key == md5($this->email . $this->new_email . DB_PASSWORD) )
508
+ $this->key_type = 'change_email';
509
+ elseif ( $this->key == md5($this->email . 'blockrequest' . DB_PASSWORD) )
510
+ $this->key_type = 'block';
511
+ elseif ( $user_level >= 8 )
512
+ $this->key_type = 'admin';
513
+ else
514
+ return false;
515
+
516
+ return true;
517
+ }
518
+
519
+
520
+ function determine_action() {
521
+ global $user_level;
522
+
523
+ // rather than check it a bunch of times
524
+ $is_email = is_email($this->email);
525
+
526
+ if ( is_email($this->new_email) && $is_email && $this->key_type == 'change_email' )
527
+ $this->action = 'change_email';
528
+ elseif ( isset($_POST['removesubscrips']) && $is_email )
529
+ $this->action = 'remove_subscriptions';
530
+ elseif ( isset($_POST['removeBlock']) && $is_email && $user_level >= 8 )
531
+ $this->action = 'remove_block';
532
+ elseif ( isset($_POST['changeemailrequest']) && $is_email && is_email($this->new_email) )
533
+ $this->action = 'email_change_request';
534
+ elseif ( $is_email && isset($_POST['blockemail']) )
535
+ $this->action = 'block_request';
536
+ elseif ( isset($_GET['subscribeid']) )
537
+ $this->action = 'solo_subscribe';
538
+ elseif ( $is_email && isset($_GET['blockemailconfirm']) && $this->key == md5($this->email . 'blockrequest' . DB_PASSWORD) )
539
+ $this->action = 'block';
540
+ else
541
+ $this->action = 'none';
542
+
543
+ }
544
+
545
+
546
+ function remove_subscriber($email, $postid) {
547
+ global $wpdb;
548
+ $postid = (int) $postid;
549
+ $email = $wpdb->escape(strtolower($email));
550
+
551
+ if ( delete_post_meta($postid, '_sg_subscribe-to-comments', stripslashes($email)) || $wpdb->query("UPDATE $wpdb->comments SET comment_subscribe = 'N' WHERE comment_post_ID = '$postid' AND LCASE(comment_author_email) ='$email'") )
552
+ return true;
553
+ else
554
+ return false;
555
+ }
556
+
557
+
558
+ function remove_subscriptions ($postids) {
559
+ global $wpdb;
560
+ $removed = 0;
561
+ for ($i = 0; $i < count($postids); $i++) {
562
+ if( $this->remove_subscriber($this->email, $postids[$i]) ) $removed++;
563
+ }
564
+ return $removed;
565
+ }
566
+
567
+
568
+ function send_notifications($cid) {
569
+ global $wpdb;
570
+ $cid = (int) $cid;
571
+ $comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID='$cid' LIMIT 1");
572
+ $post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID='$comment->comment_post_ID' LIMIT 1");
573
+
574
+ if ($comment->comment_approved == '1' && $comment->comment_type == '') {
575
+ // Comment has been approved and isn't a trackback or a pingback, so we should send out notifications
576
+
577
+ $message = sprintf(__("There is a new comment on the post \"%s\"", 'subscribe-to-comments') . ". \n%s\n\n", stripslashes($post->post_title), get_permalink($comment->comment_post_ID));
578
+ $message .= sprintf(__("Author: %s\n", 'subscribe-to-comments'), $comment->comment_author);
579
+ $message .= __("Comment:\n", 'subscribe-to-comments') . stripslashes($comment->comment_content) . "\n\n";
580
+ $message .= __("See all comments on this post here:\n", 'subscribe-to-comments');
581
+ $message .= get_permalink($comment->comment_post_ID) . "#comments\n\n";
582
+ //add link to manage comment notifications
583
+ $message .= __("To manage your subscriptions or to block all notifications from this site, click the link below:\n", 'subscribe-to-comments');
584
+ $message .= get_settings('siteurl')."/wp-subscription-manager.php?email=[email]&key=[key]";
585
+
586
+ $subject = sprintf(__('New Comment On: %s', 'subscribe-to-comments'), stripslashes($post->post_title));
587
+
588
+ $subscriptions = $this->subscriptions_from_post($comment->comment_post_ID);
589
+ if ( is_array($subscriptions) ) {
590
+ foreach($subscriptions as $email) {
591
+ if (!$this->is_blocked($email->comment_author_email) && $email->comment_author_email != $comment->comment_author_email && is_email($email->comment_author_email)) {
592
+ $message_final = str_replace('[email]', $email->comment_author_email, $message);
593
+ $message_final = str_replace('[key]', md5($email->comment_author_email . DB_PASSWORD), $message_final);
594
+ $this->send_mail($email->comment_author_email, $subject, $message_final);
595
+ }
596
+ } // foreach subscription
597
+ } // if subscriptions
598
+ } // end if comment approved
599
+ return $cid;
600
+ }
601
+
602
+
603
+ function change_email_request() {
604
+ if ( $this->is_blocked() ) return false;
605
+
606
+ $subject = __('E-mail change confirmation', 'subscribe-to-comments');
607
+ $message = sprintf(__("You are receiving this message to confirm a change of e-mail address for your subscriptions at \"%s\"\n\n", 'subscribe-to-comments'), get_bloginfo('blogname'));
608
+ $message .= sprintf(__("To change your e-mail address to %s, click this link:\n\n", 'subscribe-to-comments'), $this->new_email);
609
+ $message .= get_bloginfo('wpurl') . "/wp-subscription-manager.php?email=" . $this->email . "&new_email=" . $this->new_email . "&key=" . md5($this->email . $this->new_email . DB_PASSWORD) . ".\n\n";
610
+ $message .= __('If you did not request this action, please disregard this message.', 'subscribe-to-comments');
611
+ return $this->send_mail($this->email, $subject, $message);
612
+ }
613
+
614
+
615
+ function block_email_request($email) {
616
+ if($this->is_blocked($email)) return false;
617
+ $subject = __('E-mail block confirmation', 'subscribe-to-comments');
618
+ $message = sprintf(__("You are receiving this message to confirm that you no longer wish to receive e-mail comment notifications from \"%s\"\n\n", 'subscribe-to-comments'), get_bloginfo('name'));
619
+ $message .= __("To cancel all future notifications for this address, click this link:\n\n", 'subscribe-to-comments');
620
+ $message .= get_bloginfo('wpurl') . "/wp-subscription-manager.php?email=" . $email . "&key=" . md5($email . 'blockrequest' . DB_PASSWORD) . "&blockemailconfirm=true" . ".\n\n";
621
+ $message .= __("If you did not request this action, please disregard this message.", 'subscribe-to-comments');
622
+ return $this->send_mail($email, $subject, $message);
623
+ }
624
+
625
+
626
+ function send_mail($to, $subject, $message) {
627
+ $subject = '[' . get_bloginfo('name') . '] ' . $subject;
628
+ $headers = "From: ".$this->site_name." <".$this->site_email.">\n";
629
+ $headers .= "MIME-Version: 1.0\n" . "Content-Type: text/plain; charset=\"" . get_settings('blog_charset') . "\"\n";
630
+ return wp_mail($to, $subject, $message, $headers);
631
+ }
632
+
633
+
634
+ function change_email() {
635
+ global $wpdb;
636
+ $new_email = $wpdb->escape(strtolower($this->new_email));
637
+ $email = $wpdb->escape(strtolower($this->email));
638
+ if ( $wpdb->query("UPDATE $wpdb->comments SET comment_author_email = '$new_email' WHERE comment_author_email = '$email'") )
639
+ $return = true;
640
+ if ( $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$new_email' WHERE meta_value = '$email' AND meta_key = '_sg_subscribe-to-comments'") )
641
+ $return = true;
642
+
643
+ return $return;
644
+ }
645
+
646
+
647
+ function entry_link($postid, $uri='') {
648
+ if ( empty($uri) ) $uri = get_permalink($postid);
649
+ $postid = (int) $postid;
650
+ $title = get_the_title($postid);
651
+ if ( empty($title) ) $title = __('click here', 'subscribe-to-comments');
652
+ $output = '<a href="'.$uri.'">'.$title.'</a>';
653
+ return $output;
654
+ }
655
+
656
+
657
+ function sg_wp_head() { ?>
658
+ <style type="text/css" media="screen">
659
+ .updated-error {
660
+ background-color: #FF8080;
661
+ border: 1px solid #F00;
662
+ }
663
+ </style>
664
+ <?php
665
+ return true;
666
+ }
667
+
668
+
669
+ function db_upgrade_check () {
670
+ global $wpdb;
671
+
672
+ // add the options
673
+ add_option('sg_subscribe_settings', array('use_custom_style' => '', 'email' => get_bloginfo('admin_email'), 'name' => get_bloginfo('name'), 'header' => '[theme_path]/header.php', 'sidebar' => '', 'footer' => '[theme_path]/footer.php', 'before_manager' => '<div id="content" class="widecolumn subscription-manager">', 'after_manager' => '</div>', 'default_subscribed' => '', 'not_subscribed_text' => __('Notify me of followup comments via e-mail', 'subscribe-to-comments'), 'subscribed_text' => __('You are subscribed to this entry. <a href="[manager_link]">Manage your subscriptions</a>.', 'subscribe-to-comments'), 'author_text' => __('You are the author of this entry. <a href="[manager_link]">Manage subscriptions</a>.', 'subscribe-to-comments')));
674
+
675
+ $column_name = 'comment_subscribe';
676
+ foreach ($wpdb->get_col("DESC $wpdb->comments", 0) as $column )
677
+ if ($column == $column_name) return true;
678
+
679
+ // didn't find it... create it
680
+ $wpdb->query("ALTER TABLE $wpdb->comments ADD COLUMN comment_subscribe enum('Y','N') NOT NULL default 'N'");
681
+ }
682
+
683
+
684
+ function current_viewer_subscription_status(){
685
+ global $wpdb, $post, $user_email;
686
+
687
+ $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
688
+ get_currentuserinfo();
689
+
690
+ if(is_email($user_email)) {
691
+ $email = strtolower($user_email);
692
+ $loggedin = true;
693
+ } elseif(is_email($comment_author_email)) {
694
+ $email = strtolower($comment_author_email);
695
+ } else {
696
+ return false;
697
+ }
698
+
699
+ $post_author = get_userdata($post->post_author);
700
+ if (strtolower($post_author->user_email) == $email && $loggedin) return 'admin';
701
+
702
+ if ( is_array($this->subscriptions_from_email($email)) )
703
+ if ( in_array($post->ID, $this->email_subscriptions) ) return $email;
704
+ return false;
705
+ }
706
+
707
+
708
+ function url_to_postid($url) {
709
+ // This function is the version of WordPress' url_to_postid()
710
+ // function that was modified by Mark Jaquith for use in
711
+ // the upcoming WordPress version 1.6
712
+ // It fixes many bugs inherant in the 1.5.x version of the function
713
+
714
+ global $wp_rewrite;
715
+
716
+ // First, check to see if there is a 'p=N' or 'page_id=N' to match against
717
+ preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
718
+ $id = intval($values[2]);
719
+ if ($id) return $id;
720
+
721
+ // Check to see if we are using rewrite rules
722
+ $rewrite = $wp_rewrite->wp_rewrite_rules();
723
+
724
+ // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
725
+ if ( empty($rewrite) )
726
+ return 0;
727
+
728
+ // $url cleanup by Mark Jaquith
729
+ // This fixes things like #anchors, ?query=strings, missing 'www.',
730
+ // added 'www.', or added 'index.php/' that will mess up our WP_Query
731
+ // and return a false negative
732
+
733
+ // Get rid of the #anchor
734
+ $url_split = explode('#', $url);
735
+ $url = $url_split[0];
736
+
737
+ // Get rid of URI ?query=string
738
+ $url_split = explode('?', $url);
739
+ $url = $url_split[0];
740
+
741
+ // Add 'www.' if it is absent and should be there
742
+ if ( false !== strpos(get_settings('home'), '://www.') && false === strpos($url, '://www.') )
743
+ $url = str_replace('://', '://www.', $url);
744
+
745
+ // Strip 'www.' if it is present and shouldn't be
746
+ if ( false === strpos(get_settings('home'), '://www.') )
747
+ $url = str_replace('://www.', '://', $url);
748
+
749
+ // Strip 'index.php/' if we're not using path info permalinks
750
+ if ( false === strpos($rewrite, 'index.php/') )
751
+ $url = str_replace('index.php/', '', $url);
752
+
753
+ // Chop off http://domain.com
754
+ if ( false !== strpos($url, get_settings('home')) ) {
755
+ $url = str_replace(get_settings('home'), '', $url);
756
+ } else {
757
+ // Chop off /path/to/blog
758
+ $home_path = parse_url(get_settings('home'));
759
+ $home_path = $home_path['path'];
760
+ $url = str_replace($home_path, '', $url);
761
+ }
762
+
763
+ // Trim leading and lagging slashes
764
+ $url = trim($url, '/');
765
+
766
+ $request = $url;
767
+
768
+ // Done with cleanup
769
+
770
+ // Look for matches.
771
+ $request_match = $request;
772
+ foreach ($rewrite as $match => $query) {
773
+ // If the requesting file is the anchor of the match, prepend it
774
+ // to the path info.
775
+ if ((! empty($url)) && (strpos($match, $url) === 0)) {
776
+ $request_match = $url . '/' . $request;
777
+ }
778
+
779
+ if (preg_match("!^$match!", $request_match, $matches)) {
780
+ // Got a match.
781
+ // Trim the query of everything up to the '?'.
782
+ $query = preg_replace("!^.+\?!", '', $query);
783
+
784
+ // Substitute the substring matches into the query.
785
+ eval("\$query = \"$query\";");
786
+ $query = new WP_Query($query);
787
+ if ( $query->is_single || $query->is_page )
788
+ return $query->post->ID;
789
+ else
790
+ return 0;
791
+ }
792
+ }
793
+
794
+ return 0;
795
+ }
796
+
797
+
798
+ function manage_link($email='', $html=true, $echo=true) {
799
+ $link = get_bloginfo('wpurl') . '/wp-subscription-manager.php?';
800
+ if ($html) $amp = 'amp;';
801
+ if($email != 'admin')
802
+ $link .= 'email=' . $email . '&' . $amp . 'key=' . md5($email . DB_PASSWORD);
803
+ $link .= '&' . $amp . 'ref=http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
804
+
805
+ if ($echo)
806
+ echo $link;
807
+ else
808
+ return $link;
809
+ }
810
+
811
+
812
+ function add_admin_menu() {
813
+ add_management_page(__('Comment Subscription Manager', 'subscribe-to-comments'), __('Subscriptions', 'subscribe-to-comments'), 8, __FILE__, 'sg_subscribe_admin');
814
+
815
+ if(class_exists('SmallOptions'))
816
+ add_action('small_options_page', array('sg_subscribe_settings', 'options_page_contents'));
817
+ else
818
+ add_options_page(__('Subscribe to Comments', 'subscribe-to-comments'), __('Subscribe to Comments', 'subscribe-to-comments'), 5, basename(__FILE__), array('sg_subscribe_settings', 'options_page'));
819
+ }
820
+
821
+
822
+ } // class sg_subscribe
823
+
824
+ // ///////////////////// //
825
+ /* outside the class now */
826
+ // ///////////////////// //
827
+
828
+
829
+ function sg_subscribe_start() {
830
+ global $sg_subscribe;
831
+
832
+ if (!$sg_subscribe) {
833
+ load_plugin_textdomain('subscribe-to-comments');
834
+ $sg_subscribe = new sg_subscribe();
835
+ }
836
+ }
837
+
838
+ function sg_subscribe_admin() {
839
+ include (ABSPATH . 'wp-subscription-manager.php');
840
+ }
841
+
842
+
843
+ // This will be overridden if the user manually places the function
844
+ // in the comments form before the comment_form do_action() call
845
+ add_action('comment_form', 'show_subscription_checkbox');
846
+
847
+ // priority is very low (50) because we want to let anti-spam plugins have their way first.
848
+ add_action('comment_post', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); return $sg_subscribe->send_notifications($a);'), 50);
849
+ add_action('comment_post', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); return $sg_subscribe->add_subscriber($a);'));
850
+
851
+ add_action('wp_set_comment_status', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); return $sg_subscribe->send_notifications($a);'));
852
+ add_action('admin_menu', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); $sg_subscribe->add_admin_menu();'));
853
+ add_action('admin_head', create_function('$a', 'global $sg_subscribe; sg_subscribe_start(); $sg_subscribe->sg_wp_head();'));
854
+
855
+
856
+
857
+ // detect "subscribe without commenting" attempts
858
+ add_action('init', create_function('$a',
859
+ 'global $sg_subscribe;
860
+ if($_POST[\'solo-comment-subscribe\'] == \'solo-comment-subscribe\' && is_numeric($_POST[\'postid\']) ) {
861
+ sg_subscribe_start();
862
+ $sg_subscribe->solo_subscribe($_POST[\'email\'], $_POST[\'postid\']);
863
+ }') );
864
+ ?>
subscribe-to-comments.pot ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Subscribe to Comments 2.0\n"
4
+ "POT-Creation-Date: \n"
5
+ "PO-Revision-Date: 2005-07-11 18:42-0500\n"
6
+ "Last-Translator: Mark Jaquith <mark.i18n@txfx.net>\n"
7
+ "Language-Team: Mark Jaquith <mark.wordpress@txfx.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-Keywords: __,_e\n"
12
+ "X-Poedit-Basepath: .\n"
13
+ "X-Poedit-SearchPath-0: c:\\stc\n"
14
+
15
+ # c:\stc/subscribe-to-comments.php:81
16
+ msgid "<strong>Error: </strong>"
17
+ msgstr ""
18
+
19
+ # c:\stc/subscribe-to-comments.php:96
20
+ msgid "Subscribe without commenting"
21
+ msgstr ""
22
+
23
+ # c:\stc/subscribe-to-comments.php:98
24
+ msgid "E-Mail:"
25
+ msgstr ""
26
+
27
+ # c:\stc/subscribe-to-comments.php:100
28
+ msgid "Subscribe"
29
+ msgstr ""
30
+
31
+ # c:\stc/subscribe-to-comments.php:146
32
+ msgid "\"From\" name for notifications:"
33
+ msgstr ""
34
+
35
+ # c:\stc/subscribe-to-comments.php:147
36
+ msgid "\"From\" e-mail addresss for notifications:"
37
+ msgstr ""
38
+
39
+ # c:\stc/subscribe-to-comments.php:148
40
+ msgid "\"Subscribe\" box should be checked by default"
41
+ msgstr ""
42
+
43
+ # c:\stc/subscribe-to-comments.php:151
44
+ msgid "Comment Form Text"
45
+ msgstr ""
46
+
47
+ # c:\stc/subscribe-to-comments.php:153
48
+ msgid "Customize the messages shown to different people. Use <code>[manager_link]</code> to insert the URI to the Subscription Manager."
49
+ msgstr ""
50
+
51
+ # c:\stc/subscribe-to-comments.php:157
52
+ msgid "Not subscribed"
53
+ msgstr ""
54
+
55
+ # c:\stc/subscribe-to-comments.php:159
56
+ msgid "Subscribed"
57
+ msgstr ""
58
+
59
+ # c:\stc/subscribe-to-comments.php:161
60
+ msgid "Entry Author"
61
+ msgstr ""
62
+
63
+ # c:\stc/subscribe-to-comments.php:173
64
+ msgid "Use custom style for Subscription Manager"
65
+ msgstr ""
66
+
67
+ # c:\stc/subscribe-to-comments.php:175
68
+ msgid "These settings only matter if you are using a custom style. <code>[theme_path]</code> will be replaced with the path to your current theme."
69
+ msgstr ""
70
+
71
+ # c:\stc/subscribe-to-comments.php:178
72
+ msgid "Path to header:"
73
+ msgstr ""
74
+
75
+ # c:\stc/subscribe-to-comments.php:179
76
+ msgid "Path to sidebar:"
77
+ msgstr ""
78
+
79
+ # c:\stc/subscribe-to-comments.php:180
80
+ msgid "Path to footer:"
81
+ msgstr ""
82
+
83
+ # c:\stc/subscribe-to-comments.php:183
84
+ msgid "HTML for before the subscription manager:"
85
+ msgstr ""
86
+
87
+ # c:\stc/subscribe-to-comments.php:184
88
+ msgid "HTML for after the subscription manager:"
89
+ msgstr ""
90
+
91
+ # c:\stc/subscribe-to-comments.php:213
92
+ msgid "Options saved."
93
+ msgstr ""
94
+
95
+ # c:\stc/subscribe-to-comments.php:221
96
+ msgid "Update Options &raquo;"
97
+ msgstr ""
98
+
99
+ # c:\stc/subscribe-to-comments.php:392
100
+ msgid "Please provide a valid e-mail address."
101
+ msgstr ""
102
+
103
+ # c:\stc/subscribe-to-comments.php:395
104
+ msgid "This e-mail address may not be subscribed"
105
+ msgstr ""
106
+
107
+ # c:\stc/subscribe-to-comments.php:401
108
+ # c:\stc/subscribe-to-comments.php:415
109
+ msgid "You appear to be already subscribed to this entry."
110
+ msgstr ""
111
+
112
+ # c:\stc/subscribe-to-comments.php:406
113
+ msgid "Comments are not allowed on this entry."
114
+ msgstr ""
115
+
116
+ # c:\stc/subscribe-to-comments.php:577
117
+ #, php-format
118
+ msgid "There is a new comment on the post \"%s\""
119
+ msgstr ""
120
+
121
+ # c:\stc/subscribe-to-comments.php:578
122
+ #, php-format
123
+ msgid "Author: %s\n"
124
+ msgstr ""
125
+
126
+ # c:\stc/subscribe-to-comments.php:579
127
+ msgid "Comment:\n"
128
+ msgstr ""
129
+
130
+ # c:\stc/subscribe-to-comments.php:580
131
+ msgid "See all comments on this post here:\n"
132
+ msgstr ""
133
+
134
+ # c:\stc/subscribe-to-comments.php:583
135
+ msgid "To manage your subscriptions or to block all notifications from this site, click the link below:\n"
136
+ msgstr ""
137
+
138
+ # c:\stc/subscribe-to-comments.php:586
139
+ #, php-format
140
+ msgid "New Comment On: %s"
141
+ msgstr ""
142
+
143
+ # c:\stc/subscribe-to-comments.php:606
144
+ msgid "E-mail change confirmation"
145
+ msgstr ""
146
+
147
+ # c:\stc/subscribe-to-comments.php:607
148
+ #, php-format
149
+ msgid ""
150
+ "You are receiving this message to confirm a change of e-mail address for your subscriptions at \"%s\"\n"
151
+ "\n"
152
+ msgstr ""
153
+
154
+ # c:\stc/subscribe-to-comments.php:608
155
+ #, php-format
156
+ msgid ""
157
+ "To change your e-mail address to %s, click this link:\n"
158
+ "\n"
159
+ msgstr ""
160
+
161
+ # c:\stc/subscribe-to-comments.php:610
162
+ # c:\stc/subscribe-to-comments.php:621
163
+ msgid "If you did not request this action, please disregard this message."
164
+ msgstr ""
165
+
166
+ # c:\stc/subscribe-to-comments.php:617
167
+ msgid "E-mail block confirmation"
168
+ msgstr ""
169
+
170
+ # c:\stc/subscribe-to-comments.php:618
171
+ #, php-format
172
+ msgid ""
173
+ "You are receiving this message to confirm that you no longer wish to receive e-mail comment notifications from \"%s\"\n"
174
+ "\n"
175
+ msgstr ""
176
+
177
+ # c:\stc/subscribe-to-comments.php:619
178
+ msgid ""
179
+ "To cancel all future notifications for this address, click this link:\n"
180
+ "\n"
181
+ msgstr ""
182
+
183
+ # c:\stc/subscribe-to-comments.php:651
184
+ msgid "click here"
185
+ msgstr ""
186
+
187
+ # c:\stc/subscribe-to-comments.php:673
188
+ msgid "Notify me of followup comments via e-mail"
189
+ msgstr ""
190
+
191
+ # c:\stc/subscribe-to-comments.php:673
192
+ msgid "You are subscribed to this entry. <a href=\"[manager_link]\">Manage your subscriptions</a>."
193
+ msgstr ""
194
+
195
+ # c:\stc/subscribe-to-comments.php:673
196
+ msgid "You are the author of this entry. <a href=\"[manager_link]\">Manage subscriptions</a>."
197
+ msgstr ""
198
+
199
+ # c:\stc/subscribe-to-comments.php:813
200
+ # c:\stc/wp-subscription-manager.php:119
201
+ msgid "Comment Subscription Manager"
202
+ msgstr ""
203
+
204
+ # c:\stc/subscribe-to-comments.php:813
205
+ # c:\stc/wp-subscription-manager.php:220
206
+ msgid "Subscriptions"
207
+ msgstr ""
208
+
209
+ # c:\stc/subscribe-to-comments.php:818
210
+ msgid "Subscribe to Comments"
211
+ msgstr ""
212
+
213
+ # c:\stc/wp-subscription-manager.php:9
214
+ msgid "You must activate the \"Subscribe to Comments\" plugin in the WordPress admin panel"
215
+ msgstr ""
216
+
217
+ # c:\stc/wp-subscription-manager.php:26
218
+ msgid "You may not access this page without a valid key."
219
+ msgstr ""
220
+
221
+ # c:\stc/wp-subscription-manager.php:34
222
+ #, php-format
223
+ msgid "All notifications that were formerly sent to <strong>%s</strong> will now be sent to <strong>%s</strong>!"
224
+ msgstr ""
225
+
226
+ # c:\stc/wp-subscription-manager.php:46
227
+ #, php-format
228
+ msgid "<strong>%s</strong> %s removed successfully."
229
+ msgstr ""
230
+
231
+ # c:\stc/wp-subscription-manager.php:46
232
+ msgid "subscriptions"
233
+ msgstr ""
234
+
235
+ # c:\stc/wp-subscription-manager.php:46
236
+ msgid "subscription"
237
+ msgstr ""
238
+
239
+ # c:\stc/wp-subscription-manager.php:51
240
+ #, php-format
241
+ msgid "The block on <strong>%s</strong> has been successfully removed."
242
+ msgstr ""
243
+
244
+ # c:\stc/wp-subscription-manager.php:53
245
+ #, php-format
246
+ msgid "<strong>%s</strong> isn't blocked!"
247
+ msgstr ""
248
+
249
+ # c:\stc/wp-subscription-manager.php:58
250
+ #, php-format
251
+ msgid "<strong>%s</strong> has been blocked from receiving notifications. You will have to have the administrator remove the block before you will be able to change your notification address."
252
+ msgstr ""
253
+
254
+ # c:\stc/wp-subscription-manager.php:61
255
+ #, php-format
256
+ msgid "Your change of e-mail request was successfully received. Please check your old account (<strong>%s</strong>) in order to confirm the change."
257
+ msgstr ""
258
+
259
+ # c:\stc/wp-subscription-manager.php:66
260
+ #, php-format
261
+ msgid "Your request to block <strong>%s</strong> from receiving any further notifications has been received. In order for you to complete the block, please check your e-mail and click on the link in the message that has been sent to you."
262
+ msgstr ""
263
+
264
+ # c:\stc/wp-subscription-manager.php:70
265
+ #, php-format
266
+ msgid "<strong>%s</strong> has been successfully subscribed to %s"
267
+ msgstr ""
268
+
269
+ # c:\stc/wp-subscription-manager.php:75
270
+ #, php-format
271
+ msgid "<strong>%s</strong> has been added to the \"do not mail\" list. You will no longer receive any notifications from this site. If this was done in error, please contact the <a href=\"mailto:%s\">site administrator</a> to remove this block."
272
+ msgstr ""
273
+
274
+ # c:\stc/wp-subscription-manager.php:77
275
+ #, php-format
276
+ msgid "<strong>%s</strong> has already been blocked!"
277
+ msgstr ""
278
+
279
+ # c:\stc/wp-subscription-manager.php:94
280
+ #, php-format
281
+ msgid "%s Comment Subscription Manager"
282
+ msgstr ""
283
+
284
+ # c:\stc/wp-subscription-manager.php:122
285
+ #, php-format
286
+ msgid "Return to the page you were viewing: %s"
287
+ msgstr ""
288
+
289
+ # c:\stc/wp-subscription-manager.php:133
290
+ msgid "Remove Block"
291
+ msgstr ""
292
+
293
+ # c:\stc/wp-subscription-manager.php:136
294
+ #, php-format
295
+ msgid "Click the button below to remove the block on <strong>%s</strong>. This should only be done if the user has specifically requested it."
296
+ msgstr ""
297
+
298
+ # c:\stc/wp-subscription-manager.php:144
299
+ msgid "Remove Block &raquo;"
300
+ msgstr ""
301
+
302
+ # c:\stc/wp-subscription-manager.php:152
303
+ msgid "Blocked"
304
+ msgstr ""
305
+
306
+ # c:\stc/wp-subscription-manager.php:155
307
+ #, php-format
308
+ msgid "You have indicated that you do not wish to receive any notifications at <strong>%s</strong> from this site. If this is incorrect, or if you wish to have the block removed, please contact the <a href=\"mailto:%s\">site administrator</a>."
309
+ msgstr ""
310
+
311
+ # c:\stc/wp-subscription-manager.php:169
312
+ #, php-format
313
+ msgid "<strong>%s</strong> is not subscribed to any posts on this site."
314
+ msgstr ""
315
+
316
+ # c:\stc/wp-subscription-manager.php:171
317
+ #, php-format
318
+ msgid "<strong>%s</strong> is not a valid e-mail address."
319
+ msgstr ""
320
+
321
+ # c:\stc/wp-subscription-manager.php:183
322
+ msgid "Find Subscriptions"
323
+ msgstr ""
324
+
325
+ # c:\stc/wp-subscription-manager.php:186
326
+ msgid "Enter an e-mail address to view its subscriptions or undo a block."
327
+ msgstr ""
328
+
329
+ # c:\stc/wp-subscription-manager.php:194
330
+ msgid "Search &raquo;"
331
+ msgstr ""
332
+
333
+ # c:\stc/wp-subscription-manager.php:223
334
+ #, php-format
335
+ msgid "<strong>%s</strong> is subscribed to the posts listed below. To unsubscribe to one or more posts, click the checkbox next to the title, then click \"Remove Selected Subscription(s)\" at the bottom of the list."
336
+ msgstr ""
337
+
338
+ # c:\stc/wp-subscription-manager.php:237
339
+ msgid "Invert Checkbox Selection"
340
+ msgstr ""
341
+
342
+ # c:\stc/wp-subscription-manager.php:241
343
+ msgid "Remove Selected Subscription(s) &raquo;"
344
+ msgstr ""
345
+
346
+ # c:\stc/wp-subscription-manager.php:248
347
+ msgid "Advanced Options"
348
+ msgstr ""
349
+
350
+ # c:\stc/wp-subscription-manager.php:251
351
+ msgid "Block All Notifications"
352
+ msgstr ""
353
+
354
+ # c:\stc/wp-subscription-manager.php:258
355
+ #, php-format
356
+ msgid "If you would like <strong>%s</strong> to be blocked from receiving any notifications from this site, click the button below. This should be reserved for cases where someone is signing you up for notifications without your consent."
357
+ msgstr ""
358
+
359
+ # c:\stc/wp-subscription-manager.php:262
360
+ msgid "Block Notifications &raquo;"
361
+ msgstr ""
362
+
363
+ # c:\stc/wp-subscription-manager.php:268
364
+ msgid "Change E-mail Address"
365
+ msgstr ""
366
+
367
+ # c:\stc/wp-subscription-manager.php:275
368
+ #, php-format
369
+ msgid "If you would like to change the e-mail address for your subscriptions, enter the new address below. You will be required to verify this request by clicking a special link sent to your current address (<strong>%s</strong>)."
370
+ msgstr ""
371
+
372
+ # c:\stc/wp-subscription-manager.php:279
373
+ msgid "New E-mail Address:"
374
+ msgstr ""
375
+
376
+ # c:\stc/wp-subscription-manager.php:284
377
+ msgid "Change E-mail Address &raquo;"
378
+ msgstr ""
379
+
wp-subscription-manager.php ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // need to declare these global;
3
+ global $wpdb, $user_level, $sg_subscribe;
4
+
5
+ if (!function_exists('sg_subscribe_start')) {
6
+ require('./wp-blog-header.php');
7
+
8
+ if (!function_exists('sg_subscribe_start'))
9
+ die (__('You must activate the "Subscribe to Comments" plugin in the WordPress admin panel', 'subscribe-to-comments'));
10
+
11
+ sg_subscribe_start();
12
+ $sg_subscribe->form_action = 'wp-subscription-manager.php';
13
+ $sg_subscribe->standalone = true;
14
+ ob_start(create_function('$a', 'return str_replace("<title>", "<title> " . __("Subscription Manager", "subscribe-to-comments") . " &raquo; ", $a);'));
15
+ } else {
16
+ sg_subscribe_start();
17
+ $sg_subscribe->form_action = 'edit.php?page=subscribe-to-comments.php';
18
+ $sg_subscribe->standalone = false;
19
+ }
20
+
21
+ $sg_subscribe->manager_init();
22
+
23
+ get_currentuserinfo();
24
+
25
+ if ( !$sg_subscribe->validate_key() )
26
+ die ( __('You may not access this page without a valid key.', 'subscribe-to-comments') );
27
+
28
+ $sg_subscribe->determine_action();
29
+
30
+ switch ($sg_subscribe->action) :
31
+
32
+ case "change_email" :
33
+ if ( $sg_subscribe->change_email() ) {
34
+ $sg_subscribe->add_message(sprintf(__('All notifications that were formerly sent to <strong>%s</strong> will now be sent to <strong>%s</strong>!', 'subscribe-to-comments'), $sg_subscribe->email, $sg_subscribe->new_email));
35
+ // change info to the new email
36
+ $sg_subscribe->email = $sg_subscribe->new_email;
37
+ unset($sg_subscribe->new_email);
38
+ $sg_subscribe->key = md5($sg_subscribe->email . DB_PASSWORD);
39
+ $sg_subscribe->validate_key();
40
+ }
41
+ break;
42
+
43
+ case "remove_subscriptions" :
44
+ $postsremoved = $sg_subscribe->remove_subscriptions($_POST['subscrips']);
45
+ if ( $postsremoved > 0 )
46
+ $sg_subscribe->add_message(sprintf(__('<strong>%s</strong> %s removed successfully.', 'subscribe-to-comments'), $postsremoved, ($postsremoved != 1) ? __('subscriptions', 'subscribe-to-comments') : __('subscription', 'subscribe-to-comments')));
47
+ break;
48
+
49
+ case "remove_block" :
50
+ if ($sg_subscribe->remove_block($sg_subscribe->email))
51
+ $sg_subscribe->add_message(sprintf(__('The block on <strong>%s</strong> has been successfully removed.', 'subscribe-to-comments'), $sg_subscribe->email));
52
+ else
53
+ $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> isn\'t blocked!', 'subscribe-to-comments'), $sg_subscribe->email), 'manager');
54
+ break;
55
+
56
+ case "email_change_request" :
57
+ if ($sg_subscribe->is_blocked($sg_subscribe->email))
58
+ $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> has been blocked from receiving notifications. You will have to have the administrator remove the block before you will be able to change your notification address.', 'subscribe-to-comments'), $sg_subscribe->email));
59
+ else
60
+ if ($sg_subscribe->change_email_request($sg_subscribe->email, $sg_subscribe->new_email))
61
+ $sg_subscribe->add_message(sprintf(__('Your change of e-mail request was successfully received. Please check your old account (<strong>%s</strong>) in order to confirm the change.', 'subscribe-to-comments'), $sg_subscribe->email));
62
+ break;
63
+
64
+ case "block_request" :
65
+ if ($sg_subscribe->block_email_request($sg_subscribe->email ))
66
+ $sg_subscribe->add_message(sprintf(__('Your request to block <strong>%s</strong> from receiving any further notifications has been received. In order for you to complete the block, please check your e-mail and click on the link in the message that has been sent to you.', 'subscribe-to-comments'), $sg_subscribe->email));
67
+ break;
68
+
69
+ case "solo_subscribe" :
70
+ $sg_subscribe->add_message(sprintf(__('<strong>%s</strong> has been successfully subscribed to %s', 'subscribe-to-comments'), $sg_subscribe->email, $sg_subscribe->entry_link($_GET['subscribeid'])));
71
+ break;
72
+
73
+ case "block" :
74
+ if ($sg_subscribe->add_block($sg_subscribe->email))
75
+ $sg_subscribe->add_message(sprintf(__('<strong>%s</strong> has been added to the "do not mail" list. You will no longer receive any notifications from this site. If this was done in error, please contact the <a href="mailto:%s">site administrator</a> to remove this block.', 'subscribe-to-comments'), $sg_subscribe->email, $sg_subscribe->site_email));
76
+ else
77
+ $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> has already been blocked!', 'subscribe-to-comments'), $sg_subscribe->email), 'manager');
78
+ $sg_subscribe->key = md5($sg_subscribe->email . DB_PASSWORD);
79
+ $sg_subscribe->validate_key();
80
+ break;
81
+
82
+ endswitch;
83
+
84
+
85
+
86
+ if ($sg_subscribe->standalone) {
87
+ if ( !$sg_subscribe->use_wp_style && !empty($sg_subscribe->header) ) {
88
+
89
+ include ( $sg_subscribe->header );
90
+ echo $sg_subscribe->before_manager;
91
+ } else { ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
92
+ <html>
93
+ <head>
94
+ <title><?php printf(__('%s Comment Subscription Manager', 'subscribe-to-comments'), bloginfo('name')); ?></title>
95
+
96
+ <style type="text/css" media="screen">
97
+ @import url( <?php echo get_settings('siteurl'); ?>/wp-admin/wp-admin.css );
98
+ </style>
99
+
100
+ <link rel="stylesheet" type="text/css" media="print" href="<?php echo get_settings('siteurl'); ?>/print.css" />
101
+
102
+ <meta http-equiv="Content-Type" content="text/plain;
103
+ charset=<?php bloginfo('charset'); ?>" />
104
+
105
+ <?php $sg_subscribe->sg_wp_head(); ?>
106
+
107
+ </head>
108
+ <body>
109
+ <?php } ?>
110
+ <?php } ?>
111
+
112
+
113
+ <?php $sg_subscribe->show_messages(); ?>
114
+
115
+ <?php $sg_subscribe->show_errors(); ?>
116
+
117
+
118
+ <div class="wrap">
119
+ <h2><?php bloginfo('name'); ?> <?php _e('Comment Subscription Manager', 'subscribe-to-comments'); ?></h2>
120
+
121
+ <?php if (!empty($sg_subscribe->ref)) : ?>
122
+ <?php $sg_subscribe->add_message(sprintf(__('Return to the page you were viewing: %s', 'subscribe-to-comments'), $sg_subscribe->entry_link($sg_subscribe->url_to_postid($sg_subscribe->ref), $sg_subscribe->ref))); ?>
123
+ <?php $sg_subscribe->show_messages(); ?>
124
+ <?php endif; ?>
125
+
126
+
127
+
128
+ <?php if ($sg_subscribe->is_blocked()) { ?>
129
+
130
+ <?php if ($user_level >= 8) : ?>
131
+
132
+ <fieldset class="options">
133
+ <legend><?php _e('Remove Block', 'subscribe-to-comments'); ?></legend>
134
+
135
+ <p>
136
+ <?php printf(__('Click the button below to remove the block on <strong>%s</strong>. This should only be done if the user has specifically requested it.', 'subscribe-to-comments'), $sg_subscribe->email); ?>
137
+ </p>
138
+
139
+ <form name="removeBlock" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
140
+ <input type="hidden" name="removeBlock" value="removeBlock /">
141
+ <?php $sg_subscribe->hidden_form_fields(); ?>
142
+
143
+ <p class="submit">
144
+ <input type="submit" name="submit" value="<?php _e('Remove Block &raquo;', 'subscribe-to-comments'); ?>" />
145
+ </p>
146
+ </form>
147
+ </fieldset>
148
+
149
+ <?php else : ?>
150
+
151
+ <fieldset class="options">
152
+ <legend><?php _e('Blocked', 'subscribe-to-comments'); ?></legend>
153
+
154
+ <p>
155
+ <?php printf(__('You have indicated that you do not wish to receive any notifications at <strong>%s</strong> from this site. If this is incorrect, or if you wish to have the block removed, please contact the <a href="mailto:%s">site administrator</a>.', 'subscribe-to-comments'), $sg_subscribe->email, $sg_subscribe->site_email); ?>
156
+ </p>
157
+ </fieldset>
158
+
159
+ <?php endif; ?>
160
+
161
+
162
+ <?php } else { ?>
163
+
164
+
165
+ <?php $postlist = $sg_subscribe->subscriptions_from_email(); ?>
166
+
167
+ <?php if (isset($sg_subscribe->email) && !is_array($postlist) && $sg_subscribe->email != $sg_subscribe->site_email && $sg_subscribe->email != get_bloginfo('admin_email') ) { ?>
168
+ <?php if (is_email($sg_subscribe->email)) : ?>
169
+ <?php $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> is not subscribed to any posts on this site.', 'subscribe-to-comments'), $sg_subscribe->email)); ?>
170
+ <?php else : ?>
171
+ <?php $sg_subscribe->add_error(sprintf(__('<strong>%s</strong> is not a valid e-mail address.', 'subscribe-to-comments'), $sg_subscribe->email)); ?>
172
+ <?php endif; ?>
173
+ <?php } ?>
174
+
175
+ <?php $sg_subscribe->show_errors(); ?>
176
+
177
+
178
+
179
+
180
+ <?php if ( $user_level >= 8 ) { ?>
181
+
182
+ <fieldset class="options">
183
+ <legend><?php _e('Find Subscriptions', 'subscribe-to-comments'); ?></legend>
184
+
185
+ <p>
186
+ <?php _e('Enter an e-mail address to view its subscriptions or undo a block.', 'subscribe-to-comments'); ?>
187
+ </p>
188
+
189
+ <form name="getemail" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
190
+ <input type="hidden" name="ref" value="<?php echo $sg_subscribe->ref; ?>" />
191
+
192
+ <p>
193
+ <input name="email" type="text" id="email" size="40" />
194
+ <input type="submit" value="<?php _e('Search &raquo;', 'subscribe-to-comments'); ?>" />
195
+ </p>
196
+ </form>
197
+ </fieldset>
198
+
199
+ <?php } ?>
200
+
201
+ <?php if ( count($postlist) > 0 && is_array($postlist) ) { ?>
202
+
203
+
204
+ <script type="text/javascript">
205
+ <!--
206
+ function checkAll(form) {
207
+ for( i = 0, n = form.elements.length; i < n; i++ ) {
208
+ if( form.elements[i].type == "checkbox" ) {
209
+ if( form.elements[i].checked == true )
210
+ form.elements[i].checked = false;
211
+ else
212
+ form.elements[i].checked = true;
213
+ }
214
+ }
215
+ }
216
+ // -->
217
+ </script>
218
+
219
+ <fieldset class="options">
220
+ <legend><?php _e('Subscriptions', 'subscribe-to-comments'); ?></legend>
221
+
222
+ <p>
223
+ <?php printf(__('<strong>%s</strong> is subscribed to the posts listed below. To unsubscribe to one or more posts, click the checkbox next to the title, then click "Remove Selected Subscription(s)" at the bottom of the list.', 'subscribe-to-comments'), $sg_subscribe->email); ?>
224
+ </p>
225
+
226
+ <form name="removeSubscription" id="removeSubscription" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
227
+ <input type="hidden" name="removesubscrips" value="removesubscrips" />
228
+ <?php $sg_subscribe->hidden_form_fields(); ?>
229
+
230
+ <ol>
231
+ <?php for ($i = 0; $i < count($postlist); $i++) { ?>
232
+ <li><label for="subscrip-<?php echo $i; ?>"><input id="subscrip-<?php echo $i; ?>" type="checkbox" name="subscrips[]" value="<?php echo $postlist[$i]; ?>" /> <?php echo $sg_subscribe->entry_link($postlist[$i]); ?></label></li>
233
+ <?php } ?>
234
+ </ol>
235
+
236
+ <p>
237
+ <a href="javascript:;" onclick="checkAll(document.getElementById('removeSubscription')); return false; "><?php _e('Invert Checkbox Selection', 'subscribe-to-comments'); ?></a>
238
+ </p>
239
+
240
+ <p class="submit">
241
+ <input type="submit" name="submit" value="<?php _e('Remove Selected Subscription(s) &raquo;', 'subscribe-to-comments'); ?>" />
242
+ </p>
243
+ </form>
244
+ </fieldset>
245
+ </div>
246
+
247
+ <div class="wrap">
248
+ <h2><?php _e('Advanced Options', 'subscribe-to-comments'); ?></h2>
249
+
250
+ <fieldset class="options">
251
+ <legend><?php _e('Block All Notifications', 'subscribe-to-comments'); ?></legend>
252
+
253
+ <form name="blockemail" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
254
+ <input type="hidden" name="blockemail" value="blockemail" />
255
+ <?php $sg_subscribe->hidden_form_fields(); ?>
256
+
257
+ <p>
258
+ <?php printf(__('If you would like <strong>%s</strong> to be blocked from receiving any notifications from this site, click the button below. This should be reserved for cases where someone is signing you up for notifications without your consent.', 'subscribe-to-comments'), $sg_subscribe->email); ?>
259
+ </p>
260
+
261
+ <p class="submit">
262
+ <input type="submit" name="submit" value="<?php _e('Block Notifications &raquo;', 'subscribe-to-comments'); ?>" />
263
+ </p>
264
+ </form>
265
+ </fieldset>
266
+
267
+ <fieldset class="options">
268
+ <legend><?php _e('Change E-mail Address', 'subscribe-to-comments'); ?></legend>
269
+
270
+ <form name="changeemailrequest" method="post" action="<?php echo $sg_subscribe->form_action; ?>">
271
+ <input type="hidden" name="changeemailrequest" value="changeemailrequest" />
272
+ <?php $sg_subscribe->hidden_form_fields(); ?>
273
+
274
+ <p>
275
+ <?php printf(__('If you would like to change the e-mail address for your subscriptions, enter the new address below. You will be required to verify this request by clicking a special link sent to your current address (<strong>%s</strong>).', 'subscribe-to-comments'), $sg_subscribe->email); ?>
276
+ </p>
277
+
278
+ <p>
279
+ <?php _e('New E-mail Address:', 'subscribe-to-comments'); ?>
280
+ <input name="new_email" type="text" id="new_email" size="40" />
281
+ </p>
282
+
283
+ <p class="submit">
284
+ <input type="submit" name="submit" value="<?php _e('Change E-mail Address &raquo;', 'subscribe-to-comments'); ?>" />
285
+ </p>
286
+ </form>
287
+ </fieldset>
288
+
289
+ <?php } ?>
290
+ <?php } //end if not in do not mail ?>
291
+ </div>
292
+
293
+ <?php if ( $sg_subscribe->standalone ) : ?>
294
+ <?php if ( !$sg_subscribe->use_wp_style ) :
295
+ echo $sg_subscribe->after_manager;
296
+
297
+ if ( !empty($sg_subscribe->sidebar) )
298
+ include_once($sg_subscribe->sidebar);
299
+ if ( !empty($sg_subscribe->footer) )
300
+ include_once($sg_subscribe->footer);
301
+ ?>
302
+ <?php else : ?>
303
+ </body>
304
+ </html>
305
+ <?php endif; ?>
306
+ <?php endif; ?>