PluginProbe
WP-EMail / 2.50
WP-EMail v2.50
3.0.0 trunk 1.00 2.00b 2.01 2.02 2.03 2.04 2.04a 2.05 2.06 2.07 2.10 2.11 2.20 2.30 2.31 2.40 2.50 2.51 2.52 2.61 2.62 2.63 2.64 All 42 releases
wp-email / email-manager.php

email-manager.php in WP-EMail 2.50, at email-manager.php

371 lines 14.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 +----------------------------------------------------------------+
4 | |
5 | WordPress 2.8 Plugin: WP-EMail 2.50 |
6 | Copyright (c) 2009 Lester "GaMerZ" Chan |
7 | |
8 | File Written By: |
9 | - Lester "GaMerZ" Chan |
10 | - http://lesterchan.net |
11 | |
12 | File Information: |
13 | - Manages Your E-Mail Logs |
14 | - wp-content/plugins/wp-email/email-manager.php |
15 | |
16 +----------------------------------------------------------------+
17 */
18
19
20 ### Check Whether User Can Manage EMail
21 if(!current_user_can('manage_email')) {
22 die('Access Denied');
23 }
24
25
26 ### E-Mail Variables
27 $base_name = plugin_basename('wp-email/email-manager.php');
28 $base_page = 'admin.php?page='.$base_name;
29 $email_page = intval($_GET['emailpage']);
30 $email_sortby = trim($_GET['by']);
31 $email_sortby_text = '';
32 $email_sortorder = trim($_GET['order']);
33 $email_sortorder_text = '';
34 $email_log_perpage = intval($_GET['perpage']);
35 $email_sort_url = '';
36
37
38 ### Form Sorting URL
39 if(!empty($email_sortby)) {
40 $email_sort_url .= '&amp;by='.$email_sortby;
41 }
42 if(!empty($email_sortorder)) {
43 $email_sort_url .= '&amp;order='.$email_sortorder;
44 }
45 if(!empty($email_log_perpage)) {
46 $email_sort_url .= '&amp;perpage='.$email_log_perpage;
47 }
48
49
50 ### Get Order By
51 switch($email_sortby) {
52 case 'id':
53 $email_sortby = 'email_id';
54 $email_sortby_text = __('ID', 'wp-email');
55 break;
56 case 'fromname':
57 $email_sortby = 'email_yourname';
58 $email_sortby_text = __('From Name', 'wp-email');
59 break;
60 case 'fromemail':
61 $email_sortby = 'email_youremail';
62 $email_sortby_text = __('From E-Mail', 'wp-email');
63 break;
64 case 'toname':
65 $email_sortby = 'email_friendname';
66 $email_sortby_text = __('To Name', 'wp-email');
67 break;
68 case 'toemail':
69 $email_sortby = 'email_friendemail';
70 $email_sortby_text = __('To E-Mail', 'wp-email');
71 break;
72 case 'postid':
73 $email_sortby = 'email_postid';
74 $email_sortby_text = __('Post ID', 'wp-email');
75 break;
76 case 'posttitle':
77 $email_sortby = 'email_posttitle';
78 $email_sortby_text = __('Post Title', 'wp-email');
79 break;
80 case 'ip':
81 $email_sortby = 'email_ip';
82 $email_sortby_text = __('IP', 'wp-email');
83 break;
84 case 'host':
85 $email_sortby = 'email_host';
86 $email_sortby_text = __('Host', 'wp-email');
87 break;
88 case 'status':
89 $email_sortby = 'email_status';
90 $email_sortby_text = __('Status', 'wp-email');
91 break;
92 case 'date':
93 default:
94 $email_sortby = 'email_timestamp';
95 $email_sortby_text = __('Date', 'wp-email');
96 }
97
98
99 ### Get Sort Order
100 switch($email_sortorder) {
101 case 'asc':
102 $email_sortorder = 'ASC';
103 $email_sortorder_text = __('Ascending', 'wp-email');
104 break;
105 case 'desc':
106 default:
107 $email_sortorder = 'DESC';
108 $email_sortorder_text = __('Descending', 'wp-email');
109 }
110
111
112 ### Form Processing
113 if(!empty($_POST['delete_logs'])) {
114 if(trim($_POST['delete_logs_yes']) == 'yes') {
115 $delete_logs = $wpdb->query("DELETE FROM $wpdb->email");
116 if($delete_logs) {
117 $text = '<font color="green">'.__('All E-Mail Logs Have Been Deleted.', 'wp-email').'</font>';
118 } else {
119 $text = '<font color="red">'.__('An Error Has Occured While Deleting All E-Mail Logs.', 'wp-email').'</font>';
120 }
121 }
122 }
123
124
125 ### Get E-Mail Logs Data
126 $total_email_success = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Success', 'wp-email')."'");
127 $total_email_failed = $wpdb->get_var("SELECT COUNT(email_id) FROM $wpdb->email WHERE email_status = '".__('Failed', 'wp-email')."'");
128 $total_email = $total_email_success+$total_email_failed;
129
130
131 ### Checking $email_page and $offset
132 if(empty($email_page) || $email_page == 0) { $email_page = 1; }
133 if(empty($offset)) { $offset = 0; }
134 if(empty($email_log_perpage) || $email_log_perpage == 0) { $email_log_perpage = 20; }
135
136
137 ### Determin $offset
138 $offset = ($email_page-1) * $email_log_perpage;
139
140
141 ### Determine Max Number Of Polls To Display On Page
142 if(($offset + $email_log_perpage) > $total_email) {
143 $max_on_page = $total_email;
144 } else {
145 $max_on_page = ($offset + $email_log_perpage);
146 }
147
148
149 ### Determine Number Of Polls To Display On Page
150 if (($offset + 1) > ($total_email)) {
151 $display_on_page = $total_email;
152 } else {
153 $display_on_page = ($offset + 1);
154 }
155
156 ### Determing Total Amount Of Pages
157 $total_pages = ceil($total_email / $email_log_perpage);
158
159
160 ### Get The Logs
161 $email_logs = $wpdb->get_results("SELECT * FROM $wpdb->email ORDER BY $email_sortby $email_sortorder LIMIT $offset, $email_log_perpage");
162 ?>
163 <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?>
164 <!-- Manage E-Mail -->
165 <div class="wrap">
166 <div id="icon-wp-email" class="icon32"><br /></div>
167 <h2><?php _e('Manage E-Mail', 'wp-email'); ?></h2>
168 <h3><?php _e('E-Mail Logs', 'wp-email'); ?></h3>
169 <p><?php printf(__('Displaying <strong>%s</strong> To <strong>%s</strong> Of <strong>%s</strong> E-Mail Logs', 'wp-email'), number_format_i18n($display_on_page), number_format_i18n($max_on_page), number_format_i18n($total_email)); ?></p>
170 <p><?php printf(__('Sorted By <strong>%s</strong> In <strong>%s</strong> Order', 'wp-email'), $email_sortby_text, $email_sortorder_text); ?></p>
171 <?php
172 $colspan = 7;
173 if(EMAIL_SHOW_REMARKS) {
174 $colspan++;
175 }
176 ?>
177 <table class="widefat">
178 <thead>
179 <tr>
180 <th><?php _e('ID', 'wp-email'); ?></th>
181 <th><?php _e('From', 'wp-email'); ?></th>
182 <th><?php _e('To', 'wp-email'); ?></th>
183 <th><?php _e('Date / Time', 'wp-email'); ?></th>
184 <th><?php _e('IP / Host', 'wp-email'); ?></th>
185 <?php
186 if(EMAIL_SHOW_REMARKS) {
187 echo '<th>'.__('Remarks', 'wp-email').'</th>';
188 }
189 ?>
190 <th><?php _e('Post Title', 'wp-email'); ?></th>
191 <th><?php _e('Status', 'wp-email'); ?></th>
192 </tr>
193 </thead>
194 <?php
195 if($email_logs) {
196 $i = 0;
197 foreach($email_logs as $email_log) {
198 if($i%2 == 0) {
199 $style = '';
200 } else {
201 $style = 'class="alternate"';
202 }
203 $email_id = intval($email_log->email_id);
204 $email_yourname = stripslashes($email_log->email_yourname);
205 $email_youremail = stripslashes($email_log->email_youremail);
206 $email_friendname = stripslashes($email_log->email_friendname);
207 $email_friendemail = stripslashes($email_log->email_friendemail);
208 $email_postid = intval($email_log->email_postid);
209 $email_remarks = htmlspecialchars(stripslashes($email_log->email_yourremarks));
210 $email_posttitle = htmlspecialchars(stripslashes($email_log->email_posttitle));
211 $email_date = mysql2date(sprintf(__('%s @ %s', 'wp-email'), get_option('date_format'), get_option('time_format')), gmdate('Y-m-d H:i:s', $email_log->email_timestamp));
212 $email_ip = $email_log->email_ip;
213 $email_host = $email_log->email_host;
214 $email_status = stripslashes($email_log->email_status);
215 echo "<tr $style>\n";
216 echo "<td>".number_format_i18n($email_id)."</td>\n";
217 echo "<td>$email_yourname<br />$email_youremail</td>\n";
218 echo "<td>$email_friendname<br />$email_friendemail</td>\n";
219 echo "<td>$email_date</td>\n";
220 echo "<td>$email_ip<br />$email_host</td>\n";
221 if(EMAIL_SHOW_REMARKS) {
222 echo '<td>'.$email_remarks.'</td>';
223 }
224 echo "<td>$email_posttitle</td>\n";
225 echo "<td>$email_status</td>\n";
226 echo '</tr>';
227 $i++;
228 }
229 } else {
230 echo '<tr><td colspan="'.$colspan.'" align="center"><strong>'.__('No E-Mail Logs Found', 'wp-email').'</strong></td></tr>';
231 }
232 ?>
233 </table>
234 <!-- <Paging> -->
235 <?php
236 if($total_pages > 1) {
237 ?>
238 <br />
239 <table class="widefat">
240 <tr>
241 <td align="<?php echo ('rtl' == $text_direction) ? 'right' : 'left'; ?>" width="50%">
242 <?php
243 if($email_page > 1 && ((($email_page*$email_log_perpage)-($email_log_perpage-1)) <= $total_email)) {
244 echo '<strong>&laquo;</strong> <a href="'.$base_page.'&amp;emailpage='.($email_page-1).$email_sort_url.'" title="&laquo; '.__('Previous Page', 'wp-email').'">'.__('Previous Page', 'wp-email').'</a>';
245 } else {
246 echo '&nbsp;';
247 }
248 ?>
249 </td>
250 <td align="<?php echo ('rtl' == $text_direction) ? 'left' : 'right'; ?>" width="50%">
251 <?php
252 if($email_page >= 1 && ((($email_page*$email_log_perpage)+1) <= $total_email)) {
253 echo '<a href="'.$base_page.'&amp;emailpage='.($email_page+1).$email_sort_url.'" title="'.__('Next Page', 'wp-email').' &raquo;">'.__('Next Page', 'wp-email').'</a> <strong>&raquo;</strong>';
254 } else {
255 echo '&nbsp;';
256 }
257 ?>
258 </td>
259 </tr>
260 <tr class="alternate">
261 <td colspan="2" align="center">
262 <?php printf(__('Pages (%s): ', 'wp-postratings'), number_format_i18n($total_pages)); ?>
263 <?php
264 if ($email_page >= 4) {
265 echo '<strong><a href="'.$base_page.'&amp;emailpage=1'.$email_sort_url.'" title="'.__('Go to First Page', 'wp-email').'">&laquo; '.__('First', 'wp-email').'</a></strong> ... ';
266 }
267 if($email_page > 1) {
268 echo ' <strong><a href="'.$base_page.'&amp;emailpage='.($email_page-1).$email_sort_url.'" title="&laquo; '.__('Go to Page', 'wp-email').' '.number_format_i18n($email_page-1).'">&laquo;</a></strong> ';
269 }
270 for($i = $email_page - 2 ; $i <= $email_page +2; $i++) {
271 if ($i >= 1 && $i <= $total_pages) {
272 if($i == $email_page) {
273 echo '<strong>['.number_format_i18n($i).']</strong> ';
274 } else {
275 echo '<a href="'.$base_page.'&amp;emailpage='.($i).$email_sort_url.'" title="'.__('Page', 'wp-email').' '.number_format_i18n($i).'">'.number_format_i18n($i).'</a> ';
276 }
277 }
278 }
279 if($email_page < $total_pages) {
280 echo ' <strong><a href="'.$base_page.'&amp;emailpage='.($email_page+1).$email_sort_url.'" title="'.__('Go to Page', 'wp-email').' '.number_format_i18n($email_page+1).' &raquo;">&raquo;</a></strong> ';
281 }
282 if (($email_page+2) < $total_pages) {
283 echo ' ... <strong><a href="'.$base_page.'&amp;emailpage='.($total_pages).$email_sort_url.'" title="'.__('Go to Last Page', 'wp-email'), 'wp-email'.'">'.__('Last', 'wp-email').' &raquo;</a></strong>';
284 }
285 ?>
286 </td>
287 </tr>
288 </table>
289 <!-- </Paging> -->
290 <?php
291 }
292 ?>
293 <br />
294 <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="get">
295 <table class="widefat">
296 <tr>
297 <td>
298 <input type="hidden" name="page" value="<?php echo $base_name; ?>" />
299 <?php _e('Sort Options:', 'wp-email'); ?>&nbsp;&nbsp;&nbsp;
300 <select name="by" size="1">
301 <option value="id"<?php if($email_sortby == 'email_id') { echo ' selected="selected"'; }?>><?php _e('ID', 'wp-email'); ?></option>
302 <option value="fromname"<?php if($email_sortby == 'email_yourname') { echo ' selected="selected"'; }?>><?php _e('From Name', 'wp-email'); ?></option>
303 <option value="fromemail"<?php if($email_sortby == 'email_youremail') { echo ' selected="selected"'; }?>><?php _e('From E-Mail', 'wp-email'); ?></option>
304 <option value="toname"<?php if($email_sortby == 'email_friendname') { echo ' selected="selected"'; }?>><?php _e('To Name', 'wp-email'); ?></option>
305 <option value="toemail"<?php if($email_sortby == 'email_friendemail') { echo ' selected="selected"'; }?>><?php _e('To E-Mail', 'wp-email'); ?></option>
306 <option value="date"<?php if($email_sortby == 'email_timestamp') { echo ' selected="selected"'; }?>><?php _e('Date', 'wp-email'); ?></option>
307 <option value="postid"<?php if($email_sortby == 'email_postid') { echo ' selected="selected"'; }?>><?php _e('Post ID', 'wp-email'); ?></option>
308 <option value="posttitle"<?php if($email_sortby == 'email_posttitle') { echo ' selected="selected"'; }?>><?php _e('Post Title', 'wp-email'); ?></option>
309 <option value="ip"<?php if($email_sortby == 'email_ip') { echo ' selected="selected"'; }?>><?php _e('IP', 'wp-email'); ?></option>
310 <option value="host"<?php if($email_sortby == 'email_host') { echo ' selected="selected"'; }?>><?php _e('Host', 'wp-email'); ?></option>
311 <option value="status"<?php if($email_sortby == 'email_status') { echo ' selected="selected"'; }?>><?php _e('Status', 'wp-email'); ?></option>
312 </select>
313 &nbsp;&nbsp;&nbsp;
314 <select name="order" size="1">
315 <option value="asc"<?php if($email_sortorder == 'ASC') { echo ' selected="selected"'; }?>><?php _e('Ascending', 'wp-email'); ?></option>
316 <option value="desc"<?php if($email_sortorder == 'DESC') { echo ' selected="selected"'; } ?>><?php _e('Descending', 'wp-email'); ?></option>
317 </select>
318 &nbsp;&nbsp;&nbsp;
319 <select name="perpage" size="1">
320 <?php
321 for($i=10; $i <= 100; $i+=10) {
322 if($email_log_perpage == $i) {
323 echo "<option value=\"$i\" selected=\"selected\">".__('Per Page', 'wp-email').": ".number_format_i18n($i)."</option>\n";
324 } else {
325 echo "<option value=\"$i\">".__('Per Page', 'wp-email').": ".number_format_i18n($i)."</option>\n";
326 }
327 }
328 ?>
329 </select>
330 <input type="submit" value="<?php _e('Sort', 'wp-email'); ?>" class="button" />
331 </td>
332 </tr>
333 </table>
334 </form>
335 </div>
336 <p>&nbsp;</p>
337
338 <!-- E-Mail Stats -->
339 <div class="wrap">
340 <h3><?php _e('E-Mail Logs Stats', 'wp-email'); ?></h3>
341 <br style="clear" />
342 <table class="widefat">
343 <tr>
344 <th><?php _e('Total E-Mails:', 'wp-email'); ?></th>
345 <td><?php echo number_format_i18n($total_email); ?></td>
346 </tr>
347 <tr class="alternate">
348 <th><?php _e('Total E-Mail Sent:', 'wp-email'); ?></th>
349 <td><?php echo number_format_i18n($total_email_success); ?></td>
350 </tr>
351 <tr>
352 <th><?php _e('Total E-Mail Failed:', 'wp-email'); ?></th>
353 <td><?php echo number_format_i18n($total_email_failed); ?></td>
354 </tr>
355 </table>
356 </div>
357 <p>&nbsp;</p>
358
359 <!-- Delete E-Mail Logs -->
360 <div class="wrap">
361 <h3><?php _e('Delete E-Mail Logs', 'wp-email'); ?></h3>
362 <br style="clear" />
363 <div align="center">
364 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>">
365 <strong><?php _e('Are You Sure You Want To Delete All E-Mail Logs?', 'wp-email'); ?></strong><br /><br />
366 <input type="checkbox" name="delete_logs_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-email'); ?><br /><br />
367 <input type="submit" name="delete_logs" value="<?php _e('Delete', 'wp-email'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Delete All E-Mail Logs\nThis Action Is Not Reversible.\n\n Choose [Cancel] to stop, [OK] to delete.', 'wp-email'); ?>')" />
368 </form>
369 </div>
370 </div>
371