| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
if(!current_user_can('manage_email')) { |
|---|
| 22 |
die('Access Denied'); |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 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 |
|
|---|
| 39 |
if(!empty($email_sortby)) { |
|---|
| 40 |
$email_sort_url .= '&by='.$email_sortby; |
|---|
| 41 |
} |
|---|
| 42 |
if(!empty($email_sortorder)) { |
|---|
| 43 |
$email_sort_url .= '&order='.$email_sortorder; |
|---|
| 44 |
} |
|---|
| 45 |
if(!empty($email_log_perpage)) { |
|---|
| 46 |
$email_sort_url .= '&perpage='.$email_log_perpage; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 138 |
$offset = ($email_page-1) * $email_log_perpage; |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 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 |
|
|---|
| 150 |
if (($offset + 1) > ($total_email)) { |
|---|
| 151 |
$display_on_page = $total_email; |
|---|
| 152 |
} else { |
|---|
| 153 |
$display_on_page = ($offset + 1); |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
$total_pages = ceil($total_email / $email_log_perpage); |
|---|
| 159 |
|
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
$email_logs = $wpdb->get_results("SELECT * FROM $wpdb->email ORDER BY $email_sortby $email_sortorder LIMIT $offset, $email_log_perpage"); |
|---|
| 163 |
?> |
|---|
| 164 |
<?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.$text.'</p></div>'; } ?> |
|---|
| 165 |
<!-- Manage E-Mail --> |
|---|
| 166 |
<div class="wrap"> |
|---|
| 167 |
<h2><?php _e('E-Mail Logs', 'wp-email'); ?></h2> |
|---|
| 168 |
<p><?php printf(__('Dispaying <strong>%s</strong> To <strong>%s</strong> Of <strong>%s</strong> E-Mail Logs', 'wp-email'), $display_on_page, $max_on_page, $total_email); ?></p> |
|---|
| 169 |
<p><?php printf(__('Sorted By <strong>%s</strong> In <strong>%s</strong> Order', 'wp-email'), $email_sortby_text, $email_sortorder_text); ?></p> |
|---|
| 170 |
<?php |
|---|
| 171 |
$colspan = 7; |
|---|
| 172 |
if(EMAIL_SHOW_REMARKS) { |
|---|
| 173 |
$colspan++; |
|---|
| 174 |
} |
|---|
| 175 |
?> |
|---|
| 176 |
<table class="widefat"> |
|---|
| 177 |
<thead> |
|---|
| 178 |
<tr> |
|---|
| 179 |
<th><?php _e('ID', 'wp-email'); ?></th> |
|---|
| 180 |
<th><?php _e('From', 'wp-email'); ?></th> |
|---|
| 181 |
<th><?php _e('To', 'wp-email'); ?></th> |
|---|
| 182 |
<th><?php _e('Date / Time', 'wp-email'); ?></th> |
|---|
| 183 |
<th><?php _e('IP / Host', 'wp-email'); ?></th> |
|---|
| 184 |
<?php |
|---|
| 185 |
if(EMAIL_SHOW_REMARKS) { |
|---|
| 186 |
echo '<th>'.__('Remarks', 'wp-email').'</th>'; |
|---|
| 187 |
} |
|---|
| 188 |
?> |
|---|
| 189 |
<th><?php _e('Post Title', 'wp-email'); ?></th> |
|---|
| 190 |
<th><?php _e('Status', 'wp-email'); ?></th> |
|---|
| 191 |
</tr> |
|---|
| 192 |
</thead> |
|---|
| 193 |
<?php |
|---|
| 194 |
if($email_logs) { |
|---|
| 195 |
$i = 0; |
|---|
| 196 |
foreach($email_logs as $email_log) { |
|---|
| 197 |
if($i%2 == 0) { |
|---|
| 198 |
$style = ''; |
|---|
| 199 |
} else { |
|---|
| 200 |
$style = 'class="alternate"'; |
|---|
| 201 |
} |
|---|
| 202 |
$email_id = intval($email_log->email_id); |
|---|
| 203 |
$email_yourname = stripslashes($email_log->email_yourname); |
|---|
| 204 |
$email_youremail = stripslashes($email_log->email_youremail); |
|---|
| 205 |
$email_friendname = stripslashes($email_log->email_friendname); |
|---|
| 206 |
$email_friendemail = stripslashes($email_log->email_friendemail); |
|---|
| 207 |
$email_postid = intval($email_log->email_postid); |
|---|
| 208 |
$email_remarks = htmlspecialchars(stripslashes($email_log->email_yourremarks)); |
|---|
| 209 |
$email_posttitle = htmlspecialchars(stripslashes($email_log->email_posttitle)); |
|---|
| 210 |
$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)); |
|---|
| 211 |
$email_ip = $email_log->email_ip; |
|---|
| 212 |
$email_host = $email_log->email_host; |
|---|
| 213 |
$email_status = stripslashes($email_log->email_status); |
|---|
| 214 |
echo "<tr $style>\n"; |
|---|
| 215 |
echo "<td>$email_id</td>\n"; |
|---|
| 216 |
echo "<td>$email_yourname<br />$email_youremail</td>\n"; |
|---|
| 217 |
echo "<td>$email_friendname<br />$email_friendemail</td>\n"; |
|---|
| 218 |
echo "<td>$email_date</td>\n"; |
|---|
| 219 |
echo "<td>$email_ip<br />$email_host</td>\n"; |
|---|
| 220 |
if(EMAIL_SHOW_REMARKS) { |
|---|
| 221 |
echo '<td>'.$email_remarks.'</td>'; |
|---|
| 222 |
} |
|---|
| 223 |
echo "<td>$email_posttitle</td>\n"; |
|---|
| 224 |
echo "<td>$email_status</td>\n"; |
|---|
| 225 |
echo '</tr>'; |
|---|
| 226 |
$i++; |
|---|
| 227 |
} |
|---|
| 228 |
} else { |
|---|
| 229 |
echo '<tr><td colspan="'.$colspan.'" align="center"><strong>'.__('No E-Mail Logs Found', 'wp-email').'</strong></td></tr>'; |
|---|
| 230 |
} |
|---|
| 231 |
?> |
|---|
| 232 |
</table> |
|---|
| 233 |
<!-- <Paging> --> |
|---|
| 234 |
<?php |
|---|
| 235 |
if($total_pages > 1) { |
|---|
| 236 |
?> |
|---|
| 237 |
<br /> |
|---|
| 238 |
<table class="widefat"> |
|---|
| 239 |
<tr> |
|---|
| 240 |
<td align="left" width="50%"> |
|---|
| 241 |
<?php |
|---|
| 242 |
if($email_page > 1 && ((($email_page*$email_log_perpage)-($email_log_perpage-1)) <= $total_email)) { |
|---|
| 243 |
echo '<strong>«</strong> <a href="'.$base_page.'&emailpage='.($email_page-1).$email_sort_url.'" title="« '.__('Previous Page', 'wp-email').'">'.__('Previous Page', 'wp-email').'</a>'; |
|---|
| 244 |
} else { |
|---|
| 245 |
echo ' '; |
|---|
| 246 |
} |
|---|
| 247 |
?> |
|---|
| 248 |
</td> |
|---|
| 249 |
<td align="right" width="50%"> |
|---|
| 250 |
<?php |
|---|
| 251 |
if($email_page >= 1 && ((($email_page*$email_log_perpage)+1) <= $total_email)) { |
|---|
| 252 |
echo '<a href="'.$base_page.'&emailpage='.($email_page+1).$email_sort_url.'" title="'.__('Next Page', 'wp-email').' »">'.__('Next Page', 'wp-email').'</a> <strong>»</strong>'; |
|---|
| 253 |
} else { |
|---|
| 254 |
echo ' '; |
|---|
| 255 |
} |
|---|
| 256 |
?> |
|---|
| 257 |
</td> |
|---|
| 258 |
</tr> |
|---|
| 259 |
<tr class="alternate"> |
|---|
| 260 |
<td colspan="2" align="center"> |
|---|
| 261 |
<?php _e('Pages', 'wp-email'); ?> (<?php echo $total_pages; ?>): |
|---|
| 262 |
<?php |
|---|
| 263 |
if ($email_page >= 4) { |
|---|
| 264 |
echo '<strong><a href="'.$base_page.'&emailpage=1'.$email_sort_url.'" title="'.__('Go to First Page', 'wp-email').'">« '.__('First', 'wp-email').'</a></strong> ... '; |
|---|
| 265 |
} |
|---|
| 266 |
if($email_page > 1) { |
|---|
| 267 |
echo ' <strong><a href="'.$base_page.'&emailpage='.($email_page-1).$email_sort_url.'" title="« '.__('Go to Page', 'wp-email').' '.($email_page-1).'">«</a></strong> '; |
|---|
| 268 |
} |
|---|
| 269 |
for($i = $email_page - 2 ; $i <= $email_page +2; $i++) { |
|---|
| 270 |
if ($i >= 1 && $i <= $total_pages) { |
|---|
| 271 |
if($i == $email_page) { |
|---|
| 272 |
echo "<strong>[$i]</strong> "; |
|---|
| 273 |
} else { |
|---|
| 274 |
echo '<a href="'.$base_page.'&emailpage='.($i).$email_sort_url.'" title="'.__('Page', 'wp-email').' '.$i.'">'.$i.'</a> '; |
|---|
| 275 |
} |
|---|
| 276 |
} |
|---|
| 277 |
} |
|---|
| 278 |
if($email_page < $total_pages) { |
|---|
| 279 |
echo ' <strong><a href="'.$base_page.'&emailpage='.($email_page+1).$email_sort_url.'" title="'.__('Go to Page', 'wp-email').' '.($email_page+1).' »">»</a></strong> '; |
|---|
| 280 |
} |
|---|
| 281 |
if (($email_page+2) < $total_pages) { |
|---|
| 282 |
echo ' ... <strong><a href="'.$base_page.'&emailpage='.($total_pages).$email_sort_url.'" title="'.__('Go to Last Page', 'wp-email'), 'wp-email'.'">'.__('Last', 'wp-email').' »</a></strong>'; |
|---|
| 283 |
} |
|---|
| 284 |
?> |
|---|
| 285 |
</td> |
|---|
| 286 |
</tr> |
|---|
| 287 |
</table> |
|---|
| 288 |
<!-- </Paging> --> |
|---|
| 289 |
<?php |
|---|
| 290 |
} |
|---|
| 291 |
?> |
|---|
| 292 |
<br /> |
|---|
| 293 |
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="get"> |
|---|
| 294 |
<table class="widefat"> |
|---|
| 295 |
<tr> |
|---|
| 296 |
<td> |
|---|
| 297 |
<input type="hidden" name="page" value="<?php echo $base_name; ?>" /> |
|---|
| 298 |
<?php _e('Sort Options:', 'wp-email'); ?> |
|---|
| 299 |
<select name="by" size="1"> |
|---|
| 300 |
<option value="id"<?php if($email_sortby == 'email_id') { echo ' selected="selected"'; }?>><?php _e('ID', 'wp-email'); ?></option> |
|---|
| 301 |
<option value="fromname"<?php if($email_sortby == 'email_yourname') { echo ' selected="selected"'; }?>><?php _e('From Name', 'wp-email'); ?></option> |
|---|
| 302 |
<option value="fromemail"<?php if($email_sortby == 'email_youremail') { echo ' selected="selected"'; }?>><?php _e('From E-Mail', 'wp-email'); ?></option> |
|---|
| 303 |
<option value="toname"<?php if($email_sortby == 'email_friendname') { echo ' selected="selected"'; }?>><?php _e('To Name', 'wp-email'); ?></option> |
|---|
| 304 |
<option value="toemail"<?php if($email_sortby == 'email_friendemail') { echo ' selected="selected"'; }?>><?php _e('To E-Mail', 'wp-email'); ?></option> |
|---|
| 305 |
<option value="date"<?php if($email_sortby == 'email_timestamp') { echo ' selected="selected"'; }?>><?php _e('Date', 'wp-email'); ?></option> |
|---|
| 306 |
<option value="postid"<?php if($email_sortby == 'email_postid') { echo ' selected="selected"'; }?>><?php _e('Post ID', 'wp-email'); ?></option> |
|---|
| 307 |
<option value="posttitle"<?php if($email_sortby == 'email_posttitle') { echo ' selected="selected"'; }?>><?php _e('Post Title', 'wp-email'); ?></option> |
|---|
| 308 |
<option value="ip"<?php if($email_sortby == 'email_ip') { echo ' selected="selected"'; }?>><?php _e('IP', 'wp-email'); ?></option> |
|---|
| 309 |
<option value="host"<?php if($email_sortby == 'email_host') { echo ' selected="selected"'; }?>><?php _e('Host', 'wp-email'); ?></option> |
|---|
| 310 |
<option value="status"<?php if($email_sortby == 'email_status') { echo ' selected="selected"'; }?>><?php _e('Status', 'wp-email'); ?></option> |
|---|
| 311 |
</select> |
|---|
| 312 |
|
|---|
| 313 |
<select name="order" size="1"> |
|---|
| 314 |
<option value="asc"<?php if($email_sortorder == 'ASC') { echo ' selected="selected"'; }?>><?php _e('Ascending', 'wp-email'); ?></option> |
|---|
| 315 |
<option value="desc"<?php if($email_sortorder == 'DESC') { echo ' selected="selected"'; } ?>><?php _e('Descending', 'wp-email'); ?></option> |
|---|
| 316 |
</select> |
|---|
| 317 |
|
|---|
| 318 |
<select name="perpage" size="1"> |
|---|
| 319 |
<?php |
|---|
| 320 |
for($i=10; $i <= 100; $i+=10) { |
|---|
| 321 |
if($email_log_perpage == $i) { |
|---|
| 322 |
echo "<option value=\"$i\" selected=\"selected\">".__('Per Page', 'wp-email').": $i</option>\n"; |
|---|
| 323 |
} else { |
|---|
| 324 |
echo "<option value=\"$i\">".__('Per Page', 'wp-email').": $i</option>\n"; |
|---|
| 325 |
} |
|---|
| 326 |
} |
|---|
| 327 |
?> |
|---|
| 328 |
</select> |
|---|
| 329 |
<input type="submit" value="<?php _e('Sort', 'wp-email'); ?>" class="button" /> |
|---|
| 330 |
</td> |
|---|
| 331 |
</tr> |
|---|
| 332 |
</table> |
|---|
| 333 |
</form> |
|---|
| 334 |
</div> |
|---|
| 335 |
<p> </p> |
|---|
| 336 |
|
|---|
| 337 |
<!-- E-Mail Stats --> |
|---|
| 338 |
<div class="wrap"> |
|---|
| 339 |
<h2><?php _e('E-Mail Logs Stats', 'wp-email'); ?></h2> |
|---|
| 340 |
<br style="clear" /> |
|---|
| 341 |
<table class="widefat"> |
|---|
| 342 |
<tr> |
|---|
| 343 |
<th><?php _e('Total E-Mails:', 'wp-email'); ?></th> |
|---|
| 344 |
<td><?php echo number_format_i18n($total_email); ?></td> |
|---|
| 345 |
</tr> |
|---|
| 346 |
<tr class="alternate"> |
|---|
| 347 |
<th><?php _e('Total E-Mail Sent:', 'wp-email'); ?></th> |
|---|
| 348 |
<td><?php echo number_format_i18n($total_email_success); ?></td> |
|---|
| 349 |
</tr> |
|---|
| 350 |
<tr> |
|---|
| 351 |
<th><?php _e('Total E-Mail Failed:', 'wp-email'); ?></th> |
|---|
| 352 |
<td><?php echo number_format_i18n($total_email_failed); ?></td> |
|---|
| 353 |
</tr> |
|---|
| 354 |
</table> |
|---|
| 355 |
</div> |
|---|
| 356 |
<p> </p> |
|---|
| 357 |
|
|---|
| 358 |
<!-- Delete E-Mail Logs --> |
|---|
| 359 |
<div class="wrap"> |
|---|
| 360 |
<h2><?php _e('Delete E-Mail Logs', 'wp-email'); ?></h2> |
|---|
| 361 |
<br style="clear" /> |
|---|
| 362 |
<div align="center"> |
|---|
| 363 |
<form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post"> |
|---|
| 364 |
<strong><?php _e('Are You Sure You Want To Delete All E-Mail Logs?', 'wp-email'); ?></strong><br /><br /> |
|---|
| 365 |
<input type="checkbox" name="delete_logs_yes" value="yes" /> Yes<br /><br /> |
|---|
| 366 |
<input type="submit" name="delete_logs" value="Delete" 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'); ?>')" /> |
|---|
| 367 |
</form> |
|---|
| 368 |
</div> |
|---|
| 369 |
</div> |
|---|