Version Description
Download this release
Release Info
Developer | wokamoto |
Plugin | Crazy Bone |
Version | 0.4.0 |
Comparing to | |
See all releases |
Code changes from version 0.3.0 to 0.4.0
- languages/user-login-log-ja.mo +0 -0
- languages/user-login-log-ja.po +13 -1
- languages/user-login-log.pot +12 -0
- plugin.php +275 -67
- readme.txt +7 -1
languages/user-login-log-ja.mo
CHANGED
Binary file
|
languages/user-login-log-ja.po
CHANGED
@@ -3,7 +3,7 @@ msgstr ""
|
|
3 |
"Project-Id-Version: user-login-log\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
"POT-Creation-Date: 2013-05-10 10:07+0900\n"
|
6 |
-
"PO-Revision-Date: 2013-05-17
|
7 |
"Last-Translator: wokamoto <wokamoto1973@gmail.com>\n"
|
8 |
"Language-Team: JAPANESE <http://wppluginsj.sourceforge.jp/>\n"
|
9 |
"Language: ja_JP\n"
|
@@ -155,3 +155,15 @@ msgstr "日前"
|
|
155 |
|
156 |
msgid "Truncate"
|
157 |
msgstr "消去"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
"Project-Id-Version: user-login-log\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
"POT-Creation-Date: 2013-05-10 10:07+0900\n"
|
6 |
+
"PO-Revision-Date: 2013-05-17 18:38+0900\n"
|
7 |
"Last-Translator: wokamoto <wokamoto1973@gmail.com>\n"
|
8 |
"Language-Team: JAPANESE <http://wppluginsj.sourceforge.jp/>\n"
|
9 |
"Language: ja_JP\n"
|
155 |
|
156 |
msgid "Truncate"
|
157 |
msgstr "消去"
|
158 |
+
|
159 |
+
msgid "Summary"
|
160 |
+
msgstr "サマリー"
|
161 |
+
|
162 |
+
msgid "Summary Login Log"
|
163 |
+
msgstr "ログイン履歴 (サマリー)"
|
164 |
+
|
165 |
+
msgid "Invalid User Name / Password"
|
166 |
+
msgstr "エラー時のユーザー名 / パスワード"
|
167 |
+
|
168 |
+
msgid "Count"
|
169 |
+
msgstr "合計"
|
languages/user-login-log.pot
CHANGED
@@ -145,3 +145,15 @@ msgstr ""
|
|
145 |
|
146 |
msgid "Truncate"
|
147 |
msgstr ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
msgid "Truncate"
|
147 |
msgstr ""
|
148 |
+
|
149 |
+
msgid "Summary"
|
150 |
+
msgstr ""
|
151 |
+
|
152 |
+
msgid "Summary Login Log"
|
153 |
+
msgstr ""
|
154 |
+
|
155 |
+
msgid "Invalid User Name / Password"
|
156 |
+
msgstr ""
|
157 |
+
|
158 |
+
msgid "Count"
|
159 |
+
msgstr ""
|
plugin.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Crazy Bone
|
4 |
-
Plugin URI:
|
5 |
Description: Tracks user name, time of login, IP address and browser user agent.
|
6 |
Author: wokamoto
|
7 |
-
Version: 0.
|
8 |
Author URI: http://dogmap.jp/
|
9 |
Text Domain: user-login-log
|
10 |
Domain Path: /languages/
|
@@ -329,7 +329,7 @@ function get_ull_info() {
|
|
329 |
dataType: 'json',
|
330 |
type: 'POST',
|
331 |
success: function(res){
|
332 |
-
<?php if (self::DEBUG_MODE) echo "
|
333 |
if (!res.dismiss && res.IP !== res.login_IP) {
|
334 |
jQuery('#wp-admin-bar-my-account').pointer({
|
335 |
content: '<?php echo $caution; ?>',
|
@@ -529,84 +529,153 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
|
|
529 |
}
|
530 |
|
531 |
public function option_page() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
global $wpdb;
|
533 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
534 |
// Truncate Log
|
535 |
$nonce_action = 'truncate_logs';
|
536 |
$nonce_name = '_wpnonce_truncate_logs';
|
537 |
$truncate_date = '';
|
538 |
-
$err_message = '';
|
539 |
if (current_user_can('manage_options') && isset($_POST['truncate_date']) && check_admin_referer($nonce_action, $nonce_name)) {
|
540 |
if (is_numeric($_POST['truncate_date'])) {
|
541 |
$user_id = intval($_POST['user_id']);
|
542 |
$truncate_date = intval($_POST['truncate_date']);
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
$truncate_date,
|
552 |
-
$user_id
|
553 |
-
);
|
554 |
-
}
|
555 |
$wpdb->query($sql);
|
556 |
|
557 |
$err_message = sprintf(
|
558 |
-
'<div id="message" class="updated fade"><p><strong>%s</strong></p></div>'."
|
559 |
empty($err_message) ? __('Done!', self::TEXT_DOMAIN) : $err_message
|
560 |
);
|
561 |
}
|
562 |
}
|
563 |
|
564 |
-
//
|
565 |
-
$
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
$user_id = 0;
|
570 |
-
if (current_user_can('create_users') && isset($_GET['user_id'])) {
|
571 |
-
$user_id = intval($_GET['user_id']);
|
572 |
-
} else {
|
573 |
-
$user = wp_get_current_user();
|
574 |
-
if (is_wp_error($user))
|
575 |
-
return;
|
576 |
-
$user_id = intval($user->ID);
|
577 |
-
}
|
578 |
-
|
579 |
-
$sql = " FROM `{$this->ull_table}` LEFT JOIN `{$wpdb->users}` ON `{$this->ull_table}`.`user_id` = `{$wpdb->users}`.`ID`";
|
580 |
if ($user_id >= 0)
|
581 |
-
$sql .= $wpdb->prepare("
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
'format' => '' ,
|
586 |
-
'prev_text' => __('«') ,
|
587 |
-
'next_text' => __('»') ,
|
588 |
-
'total' => ceil($total / $per_page) ,
|
589 |
-
'current' => $page
|
590 |
-
));
|
591 |
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
$page_links
|
597 |
-
);
|
598 |
|
599 |
-
|
|
|
|
|
600 |
$sql.' ORDER BY `activity_date` DESC'.
|
601 |
-
'
|
602 |
-
|
|
|
|
|
603 |
$ull = $wpdb->get_results($sql);
|
|
|
604 |
$row_num = 0;
|
605 |
?>
|
606 |
<div class="wrap">
|
607 |
<div id="icon-profile" class="icon32"></div>
|
608 |
<h2><?php _e('Login Log', self::TEXT_DOMAIN); ?></h2>
|
609 |
-
<?php echo $err_message."
|
610 |
|
611 |
<div class="tablenav">
|
612 |
|
@@ -614,16 +683,7 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
|
|
614 |
<div class="alignleft actions">
|
615 |
<form action="" method="get">
|
616 |
<input type="hidden" name="page" value="<?php echo plugin_basename(__FILE__); ?>" />
|
617 |
-
|
618 |
-
<option value="-1"<?php if ($user_id == -1) echo ' selected="selected"';?>><?php _e('All Users', self::TEXT_DOMAIN); ?></option>
|
619 |
-
<option value="0"<?php if ($user_id == 0) echo ' selected="selected"';?>><?php _e('Unknown', self::TEXT_DOMAIN); ?></option>
|
620 |
-
<?php
|
621 |
-
$users = $wpdb->get_results("select ID, user_login from `{$wpdb->users}` order by ID");
|
622 |
-
foreach((array)$users as $user) {
|
623 |
-
printf("<option value=\"%d\"%s>%s</option>\n", $user->ID, $user->ID == $user_id ? ' selected="selected"' : '', $user->user_login);
|
624 |
-
}
|
625 |
-
?>
|
626 |
-
</select>
|
627 |
<?php submit_button(__('Apply Filters'), 'action', false, false, array('id' => "doaction"));?>
|
628 |
</form>
|
629 |
</div>
|
@@ -632,10 +692,10 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
|
|
632 |
<?php if (current_user_can('manage_options')) { ?>
|
633 |
<div class="alignleft actions">
|
634 |
<form action="" method="post">
|
635 |
-
<?php echo wp_nonce_field($nonce_action, $nonce_name, true, false) . "
|
636 |
<input type="hidden" name="user_id" value="<?php echo $user_id; ?>" />
|
637 |
<label for="truncate_date"><?php _e('Truncate Log', self::TEXT_DOMAIN);?></label>
|
638 |
-
<input type="text" name="truncate_date" value="<?php echo $truncate_date;?>" size="2" />
|
639 |
<?php _e('days and older.', self::TEXT_DOMAIN);?>
|
640 |
<?php submit_button(__('Truncate', self::TEXT_DOMAIN), 'action', false, false, array('id' => "truncate"));?>
|
641 |
</form>
|
@@ -645,6 +705,21 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
|
|
645 |
<div class="alignright tablenav-pages">
|
646 |
<?php echo $page_links_text; ?>
|
647 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
648 |
<br class="clear" />
|
649 |
</div>
|
650 |
|
@@ -660,7 +735,8 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
|
|
660 |
<th scope="col" class="manage-column column-status"><?php _e('Status', self::TEXT_DOMAIN); ?></th>
|
661 |
<th scope="col" class="manage-column column-ip"><?php _e('IP', self::TEXT_DOMAIN); ?></th>
|
662 |
<th scope="col" class="manage-column column-agent"><?php _e('User Agent', self::TEXT_DOMAIN); ?></th>
|
663 |
-
<th scope="col" class="manage-column column-errors"
|
|
|
664 |
</tr>
|
665 |
</thead>
|
666 |
<tfoot>
|
@@ -672,7 +748,8 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
|
|
672 |
<th scope="col" class="manage-column column-status"><?php _e('Status', self::TEXT_DOMAIN); ?></th>
|
673 |
<th scope="col" class="manage-column column-ip"><?php _e('IP', self::TEXT_DOMAIN); ?></th>
|
674 |
<th scope="col" class="manage-column column-agent"><?php _e('User Agent', self::TEXT_DOMAIN); ?></th>
|
675 |
-
<th scope="col" class="manage-column column-errors"
|
|
|
676 |
</tr>
|
677 |
</tfoot>
|
678 |
|
@@ -689,6 +766,10 @@ $user_login =
|
|
689 |
(is_array($errors) && isset($errors['user_login']))
|
690 |
? $errors['user_login']
|
691 |
: $row->user_login;
|
|
|
|
|
|
|
|
|
692 |
$errors =
|
693 |
(is_array($errors) && isset($errors['errors']))
|
694 |
? implode(', ', array_keys($errors['errors']))
|
@@ -703,6 +784,133 @@ $errors =
|
|
703 |
<td class="ip column-ip"><?php echo trim(self::get_country_flag($row->activity_IP) . '<br>' . $row->activity_IP); ?></td>
|
704 |
<td class="agent column-agent"><?php echo trim(self::get_browser_icon($row->activity_agent) . '<br>' . $ua); ?></td>
|
705 |
<td class="errors column-errors"><?php echo $errors; ?></td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
706 |
</tr>
|
707 |
<?php $row_num++; }?>
|
708 |
</tbody>
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Crazy Bone
|
4 |
+
Plugin URI: https://github.com/wokamoto/crazy-bone
|
5 |
Description: Tracks user name, time of login, IP address and browser user agent.
|
6 |
Author: wokamoto
|
7 |
+
Version: 0.4.0
|
8 |
Author URI: http://dogmap.jp/
|
9 |
Text Domain: user-login-log
|
10 |
Domain Path: /languages/
|
329 |
dataType: 'json',
|
330 |
type: 'POST',
|
331 |
success: function(res){
|
332 |
+
<?php if (self::DEBUG_MODE) echo "�t�t�tconsole.log(res);�n" ?>
|
333 |
if (!res.dismiss && res.IP !== res.login_IP) {
|
334 |
jQuery('#wp-admin-bar-my-account').pointer({
|
335 |
content: '<?php echo $caution; ?>',
|
529 |
}
|
530 |
|
531 |
public function option_page() {
|
532 |
+
if (isset($_GET['summary']))
|
533 |
+
$this->summary_page();
|
534 |
+
else
|
535 |
+
$this->login_log_page();
|
536 |
+
}
|
537 |
+
|
538 |
+
private function filter_option($selected_user_id, $selected_status) {
|
539 |
global $wpdb;
|
540 |
|
541 |
+
$selectd = ' selected="selected"';
|
542 |
+
|
543 |
+
echo '<select name="user_id">'."�n";
|
544 |
+
printf('<option value="%d"%s>%s</option>'."�n", -1, $selected_user_id == -1 ? $selectd : '', __('All Users', self::TEXT_DOMAIN));
|
545 |
+
printf('<option value="%d"%s>%s</option>'."�n", 0, $selected_user_id == 0 ? $selectd : '', __('Unknown', self::TEXT_DOMAIN));
|
546 |
+
$users = $wpdb->get_results("select ID, user_login from `{$wpdb->users}` order by ID");
|
547 |
+
foreach((array)$users as $user) {
|
548 |
+
printf('<option value="%d"%s>%s</option>'."�n", $user->ID, $selected_user_id == $user->ID ? $selectd : '', $user->user_login);
|
549 |
+
}
|
550 |
+
echo "</select>�n";
|
551 |
+
|
552 |
+
echo '<select name="status">'."�n";
|
553 |
+
foreach (array('', 'login', 'logout', 'login_error') as $status) {
|
554 |
+
printf('<option value="%1$s"%2$s>%1$s</option>'."�n", $status, $selected_status == $status ? ' selected="selected"' : '');
|
555 |
+
}
|
556 |
+
echo "</select>�n";
|
557 |
+
}
|
558 |
+
|
559 |
+
// Pagination
|
560 |
+
private function get_pagenation($total, $per_page, $page, $start = ''){
|
561 |
+
if (empty($start))
|
562 |
+
$start = (intval($page) - 1) * intval($per_page);
|
563 |
+
|
564 |
+
$page_links = paginate_links( array(
|
565 |
+
'base' => add_query_arg( 'apage', '%#%' ) ,
|
566 |
+
'format' => '' ,
|
567 |
+
'prev_text' => __('«') ,
|
568 |
+
'next_text' => __('»') ,
|
569 |
+
'total' => ceil(intval($total) / intval($per_page)) ,
|
570 |
+
'current' => intval($page)
|
571 |
+
));
|
572 |
+
|
573 |
+
$page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
|
574 |
+
number_format_i18n( intval($total) > 0 ? intval($start) + 1 : 0 ),
|
575 |
+
number_format_i18n( min(intval($page) * intval($per_page), intval($total)) ),
|
576 |
+
number_format_i18n( intval($total) ),
|
577 |
+
$page_links
|
578 |
+
);
|
579 |
+
|
580 |
+
return $page_links_text;
|
581 |
+
}
|
582 |
+
|
583 |
+
private function get_user_id(){
|
584 |
+
$user_id = 0;
|
585 |
+
if (current_user_can('create_users') && isset($_GET['user_id'])) {
|
586 |
+
$user_id = intval($_GET['user_id']);
|
587 |
+
} else {
|
588 |
+
$user = wp_get_current_user();
|
589 |
+
if (is_wp_error($user))
|
590 |
+
return;
|
591 |
+
$user_id = intval($user->ID);
|
592 |
+
}
|
593 |
+
return $user_id;
|
594 |
+
}
|
595 |
+
|
596 |
+
private function get_status(){
|
597 |
+
$status = '';
|
598 |
+
if (!current_user_can('create_users'))
|
599 |
+
return $status;
|
600 |
+
|
601 |
+
if (isset($_GET['status'])) {
|
602 |
+
switch (strtolower($_GET['status'])){
|
603 |
+
case 'login':
|
604 |
+
case 'logout':
|
605 |
+
case 'login_error':
|
606 |
+
$status = strtolower($_GET['status']);
|
607 |
+
break;
|
608 |
+
default:
|
609 |
+
$status = '';
|
610 |
+
}
|
611 |
+
}
|
612 |
+
return $status;
|
613 |
+
}
|
614 |
+
|
615 |
+
private function login_log_page() {
|
616 |
+
global $wpdb;
|
617 |
+
|
618 |
+
$err_message = '';
|
619 |
+
$user_id = $this->get_user_id();
|
620 |
+
$status = $this->get_status();
|
621 |
+
|
622 |
// Truncate Log
|
623 |
$nonce_action = 'truncate_logs';
|
624 |
$nonce_name = '_wpnonce_truncate_logs';
|
625 |
$truncate_date = '';
|
|
|
626 |
if (current_user_can('manage_options') && isset($_POST['truncate_date']) && check_admin_referer($nonce_action, $nonce_name)) {
|
627 |
if (is_numeric($_POST['truncate_date'])) {
|
628 |
$user_id = intval($_POST['user_id']);
|
629 |
$truncate_date = intval($_POST['truncate_date']);
|
630 |
+
$sql = $wpdb->prepare(
|
631 |
+
"DELETE FROM {$this->ull_table} WHERE `activity_date` <= DATE_SUB(NOW(), INTERVAL %d day)",
|
632 |
+
$truncate_date
|
633 |
+
);
|
634 |
+
if ($user_id >= 0)
|
635 |
+
$sql .= $wpdb->prepare(" AND `user_id` = %d", $user_id);
|
636 |
+
if (!empty($status))
|
637 |
+
$sql .= $wpdb->prepare(" AND `activity_status` = %s", $status);
|
|
|
|
|
|
|
|
|
638 |
$wpdb->query($sql);
|
639 |
|
640 |
$err_message = sprintf(
|
641 |
+
'<div id="message" class="updated fade"><p><strong>%s</strong></p></div>'."�n",
|
642 |
empty($err_message) ? __('Done!', self::TEXT_DOMAIN) : $err_message
|
643 |
);
|
644 |
}
|
645 |
}
|
646 |
|
647 |
+
// get total count
|
648 |
+
$sql = "
|
649 |
+
FROM `{$this->ull_table}`
|
650 |
+
LEFT JOIN `{$wpdb->users}` ON `{$this->ull_table}`.`user_id` = `{$wpdb->users}`.`ID`
|
651 |
+
WHERE 1 = 1";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
652 |
if ($user_id >= 0)
|
653 |
+
$sql .= $wpdb->prepare(" AND `user_id` = %d", $user_id);
|
654 |
+
if (!empty($status))
|
655 |
+
$sql .= $wpdb->prepare(" AND `activity_status` = %s", $status);
|
656 |
+
$total = intval($wpdb->get_var("SELECT count(`{$this->ull_table}`.`ID`) {$sql}"));
|
|
|
|
|
|
|
|
|
|
|
|
|
657 |
|
658 |
+
// Pagination
|
659 |
+
$page = abs(intval(isset($_GET['apage']) ? $_GET['apage'] : 1));
|
660 |
+
$start = ($page - 1) * self::LIST_PER_PAGE;
|
661 |
+
$page_links_text = $this->get_pagenation($total, self::LIST_PER_PAGE, $page, $start);
|
|
|
|
|
662 |
|
663 |
+
// get login log
|
664 |
+
$sql = $wpdb->prepare(
|
665 |
+
'SELECT `user_id`, `user_login`, `activity_date`, `activity_status`, `activity_IP`, `activity_agent`, `activity_errors`'.
|
666 |
$sql.' ORDER BY `activity_date` DESC'.
|
667 |
+
' LIMIT %d, %d',
|
668 |
+
$start,
|
669 |
+
self::LIST_PER_PAGE
|
670 |
+
);
|
671 |
$ull = $wpdb->get_results($sql);
|
672 |
+
|
673 |
$row_num = 0;
|
674 |
?>
|
675 |
<div class="wrap">
|
676 |
<div id="icon-profile" class="icon32"></div>
|
677 |
<h2><?php _e('Login Log', self::TEXT_DOMAIN); ?></h2>
|
678 |
+
<?php echo $err_message."�n"; ?>
|
679 |
|
680 |
<div class="tablenav">
|
681 |
|
683 |
<div class="alignleft actions">
|
684 |
<form action="" method="get">
|
685 |
<input type="hidden" name="page" value="<?php echo plugin_basename(__FILE__); ?>" />
|
686 |
+
<?php $this->filter_option($user_id, $status); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
687 |
<?php submit_button(__('Apply Filters'), 'action', false, false, array('id' => "doaction"));?>
|
688 |
</form>
|
689 |
</div>
|
692 |
<?php if (current_user_can('manage_options')) { ?>
|
693 |
<div class="alignleft actions">
|
694 |
<form action="" method="post">
|
695 |
+
<?php echo wp_nonce_field($nonce_action, $nonce_name, true, false) . "�n"; ?>
|
696 |
<input type="hidden" name="user_id" value="<?php echo $user_id; ?>" />
|
697 |
<label for="truncate_date"><?php _e('Truncate Log', self::TEXT_DOMAIN);?></label>
|
698 |
+
<input type="text" name="truncate_date" value="<?php echo $truncate_date;?>" size="2" style="text-align:right;" />
|
699 |
<?php _e('days and older.', self::TEXT_DOMAIN);?>
|
700 |
<?php submit_button(__('Truncate', self::TEXT_DOMAIN), 'action', false, false, array('id' => "truncate"));?>
|
701 |
</form>
|
705 |
<div class="alignright tablenav-pages">
|
706 |
<?php echo $page_links_text; ?>
|
707 |
</div>
|
708 |
+
|
709 |
+
<?php if (current_user_can('manage_options')) { ?>
|
710 |
+
<div class="alignright tablenav-pages" style="margin-right:1em;">
|
711 |
+
<form action="" method="GET">
|
712 |
+
<input type="hidden" name="page" value="<?php echo plugin_basename(__FILE__); ?>" />
|
713 |
+
<input type="hidden" name="summary" value="summary" />
|
714 |
+
<input type="hidden" name="user_id" value="<?php echo $user_id; ?>" />
|
715 |
+
<?php if (!empty($status)) { ?>
|
716 |
+
<input type="hidden" name="status" value="<?php echo $status; ?>" />
|
717 |
+
<?php } ?>
|
718 |
+
<?php submit_button(__('Summary', self::TEXT_DOMAIN), 'action', false, false, array('id' => "summary"));?>
|
719 |
+
</form>
|
720 |
+
</div>
|
721 |
+
<?php } ?>
|
722 |
+
|
723 |
<br class="clear" />
|
724 |
</div>
|
725 |
|
735 |
<th scope="col" class="manage-column column-status"><?php _e('Status', self::TEXT_DOMAIN); ?></th>
|
736 |
<th scope="col" class="manage-column column-ip"><?php _e('IP', self::TEXT_DOMAIN); ?></th>
|
737 |
<th scope="col" class="manage-column column-agent"><?php _e('User Agent', self::TEXT_DOMAIN); ?></th>
|
738 |
+
<th scope="col" class="manage-column column-errors"><?php _e('Errors', self::TEXT_DOMAIN); ?></th>
|
739 |
+
<th scope="col" class="manage-column column-errors"><?php _e('Invalid User Name / Password', self::TEXT_DOMAIN); ?></th>
|
740 |
</tr>
|
741 |
</thead>
|
742 |
<tfoot>
|
748 |
<th scope="col" class="manage-column column-status"><?php _e('Status', self::TEXT_DOMAIN); ?></th>
|
749 |
<th scope="col" class="manage-column column-ip"><?php _e('IP', self::TEXT_DOMAIN); ?></th>
|
750 |
<th scope="col" class="manage-column column-agent"><?php _e('User Agent', self::TEXT_DOMAIN); ?></th>
|
751 |
+
<th scope="col" class="manage-column column-errors"><?php _e('Errors', self::TEXT_DOMAIN); ?></th>
|
752 |
+
<th scope="col" class="manage-column column-errors"><?php _e('Invalid User Name / Password', self::TEXT_DOMAIN); ?></th>
|
753 |
</tr>
|
754 |
</tfoot>
|
755 |
|
766 |
(is_array($errors) && isset($errors['user_login']))
|
767 |
? $errors['user_login']
|
768 |
: $row->user_login;
|
769 |
+
$password =
|
770 |
+
(is_array($errors) && isset($errors['user_login']) && isset($errors['user_password']))
|
771 |
+
? "{$errors['user_login']} / {$errors['user_password']}"
|
772 |
+
: '';
|
773 |
$errors =
|
774 |
(is_array($errors) && isset($errors['errors']))
|
775 |
? implode(', ', array_keys($errors['errors']))
|
784 |
<td class="ip column-ip"><?php echo trim(self::get_country_flag($row->activity_IP) . '<br>' . $row->activity_IP); ?></td>
|
785 |
<td class="agent column-agent"><?php echo trim(self::get_browser_icon($row->activity_agent) . '<br>' . $ua); ?></td>
|
786 |
<td class="errors column-errors"><?php echo $errors; ?></td>
|
787 |
+
<td class="password column-errors"><?php echo $password; ?></td>
|
788 |
+
</tr>
|
789 |
+
<?php $row_num++; }?>
|
790 |
+
</tbody>
|
791 |
+
</table>
|
792 |
+
|
793 |
+
<div class="tablenav">
|
794 |
+
<div class="alignright tablenav-pages">
|
795 |
+
<?php echo $page_links_text; ?>
|
796 |
+
</div>
|
797 |
+
<br class="clear" />
|
798 |
+
</div>
|
799 |
+
|
800 |
+
</div>
|
801 |
+
<?php
|
802 |
+
}
|
803 |
+
|
804 |
+
private function summary_page(){
|
805 |
+
global $wpdb;
|
806 |
+
|
807 |
+
$err_message = '';
|
808 |
+
$user_id = $this->get_user_id();
|
809 |
+
$status = $this->get_status();
|
810 |
+
|
811 |
+
// get total count
|
812 |
+
$sql =
|
813 |
+
"SELECT distinct `user_id`, `user_login`, `activity_status`, `activity_errors`, count(*) as `count`
|
814 |
+
FROM `{$this->ull_table}`
|
815 |
+
LEFT JOIN `{$wpdb->users}` ON `{$this->ull_table}`.`user_id` = `{$wpdb->users}`.`ID`
|
816 |
+
WHERE 1 = 1";
|
817 |
+
if ($user_id >= 0)
|
818 |
+
$sql .= $wpdb->prepare(" AND `user_id` = %d", $user_id);
|
819 |
+
if (!empty($status))
|
820 |
+
$sql .= $wpdb->prepare(" AND `activity_status` = %s", $status);
|
821 |
+
$sql .= " GROUP BY `user_id`, `user_login`, `activity_status`, `activity_errors`";
|
822 |
+
$total = intval($wpdb->get_var("SELECT count(*) from ({$sql}) as log"));
|
823 |
+
|
824 |
+
// Pagination
|
825 |
+
$page = abs(intval(isset($_GET['apage']) ? $_GET['apage'] : 1));
|
826 |
+
$start = ($page - 1) * self::LIST_PER_PAGE;
|
827 |
+
$page_links_text = $this->get_pagenation($total, self::LIST_PER_PAGE, $page, $start);
|
828 |
+
|
829 |
+
// get login log summary
|
830 |
+
$ull_summary = $wpdb->get_results($wpdb->prepare("{$sql} ORDER BY `count` DESC LIMIT %d,%d", $start, self::LIST_PER_PAGE));
|
831 |
+
|
832 |
+
$row_num = 0;
|
833 |
+
?>
|
834 |
+
<div class="wrap">
|
835 |
+
<div id="icon-profile" class="icon32"></div>
|
836 |
+
<h2><?php _e('Summary Login Log', self::TEXT_DOMAIN); ?></h2>
|
837 |
+
<?php echo $err_message."�n"; ?>
|
838 |
+
|
839 |
+
<div class="tablenav">
|
840 |
+
<?php if (current_user_can('create_users')) { ?>
|
841 |
+
<div class="alignleft actions">
|
842 |
+
<form action="" method="get">
|
843 |
+
<input type="hidden" name="page" value="<?php echo plugin_basename(__FILE__); ?>" />
|
844 |
+
<input type="hidden" name="summary" value="summary" />
|
845 |
+
<?php $this->filter_option($user_id, $status); ?>
|
846 |
+
<?php submit_button(__('Apply Filters'), 'action', false, false, array('id' => "doaction"));?>
|
847 |
+
</form>
|
848 |
+
</div>
|
849 |
+
<?php } ?>
|
850 |
+
|
851 |
+
<div class="alignright tablenav-pages">
|
852 |
+
<?php echo $page_links_text; ?>
|
853 |
+
</div>
|
854 |
+
|
855 |
+
<?php if (current_user_can('manage_options')) { ?>
|
856 |
+
<div class="alignright tablenav-pages" style="margin-right:1em;">
|
857 |
+
<form action="" method="GET">
|
858 |
+
<input type="hidden" name="page" value="<?php echo plugin_basename(__FILE__); ?>" />
|
859 |
+
<input type="hidden" name="user_id" value="<?php echo $user_id; ?>" />
|
860 |
+
<?php if (!empty($status)) { ?>
|
861 |
+
<input type="hidden" name="status" value="<?php echo $status; ?>" />
|
862 |
+
<?php } ?>
|
863 |
+
<?php submit_button(__('Login Log', self::TEXT_DOMAIN), 'action', false, false, array('id' => "login_log"));?>
|
864 |
+
</form>
|
865 |
+
<?php } ?>
|
866 |
+
<br class="clear" />
|
867 |
+
</div>
|
868 |
+
|
869 |
+
<div class="clear"></div>
|
870 |
+
|
871 |
+
<table class="widefat comments fixed" cellspacing="0">
|
872 |
+
<thead>
|
873 |
+
<tr>
|
874 |
+
<th scope="col" class="manage-column column-username"><?php _e('User Name', self::TEXT_DOMAIN); ?></th>
|
875 |
+
<th scope="col" class="manage-column column-status"><?php _e('Status', self::TEXT_DOMAIN); ?></th>
|
876 |
+
<th scope="col" class="manage-column column-errors"><?php _e('Errors', self::TEXT_DOMAIN); ?></th>
|
877 |
+
<th scope="col" class="manage-column column-errors"><?php _e('Invalid User Name / Password', self::TEXT_DOMAIN); ?></th>
|
878 |
+
<th scope="col" class="manage-column column-errors" style="text-align:right;"><?php _e('Count', self::TEXT_DOMAIN); ?></th>
|
879 |
+
</tr>
|
880 |
+
</thead>
|
881 |
+
<tfoot>
|
882 |
+
<tr>
|
883 |
+
<th scope="col" class="manage-column column-username"><?php _e('User Name', self::TEXT_DOMAIN); ?></th>
|
884 |
+
<th scope="col" class="manage-column column-status"><?php _e('Status', self::TEXT_DOMAIN); ?></th>
|
885 |
+
<th scope="col" class="manage-column column-errors"><?php _e('Errors', self::TEXT_DOMAIN); ?></th>
|
886 |
+
<th scope="col" class="manage-column column-errors"><?php _e('Invalid User Name / Password', self::TEXT_DOMAIN); ?></th>
|
887 |
+
<th scope="col" class="manage-column column-errors" style="text-align:right;"><?php _e('Count', self::TEXT_DOMAIN); ?></th>
|
888 |
+
</tr>
|
889 |
+
</tfoot>
|
890 |
+
|
891 |
+
<tbody id="user-login-log">
|
892 |
+
<?php foreach($ull_summary as $row) {?>
|
893 |
+
<?php
|
894 |
+
$errors = unserialize($row->activity_errors);
|
895 |
+
$user_login =
|
896 |
+
(is_array($errors) && isset($errors['user_login']))
|
897 |
+
? $errors['user_login']
|
898 |
+
: $row->user_login;
|
899 |
+
$password =
|
900 |
+
(is_array($errors) && isset($errors['user_login']) && isset($errors['user_password']))
|
901 |
+
? "{$errors['user_login']} / {$errors['user_password']}"
|
902 |
+
: '';
|
903 |
+
$errors =
|
904 |
+
(is_array($errors) && isset($errors['errors']))
|
905 |
+
? implode(', ', array_keys($errors['errors']))
|
906 |
+
: '';
|
907 |
+
?>
|
908 |
+
<tr id="log-<?php echo $row_num ?>">
|
909 |
+
<td class="username column-username"><?php echo $user_login; ?></td>
|
910 |
+
<td class="status column-status"><?php echo $row->activity_status; ?></td>
|
911 |
+
<td class="errors column-errors"><?php echo $errors; ?></td>
|
912 |
+
<td class="password column-errors"><?php echo $password; ?></td>
|
913 |
+
<td class="count column-errors" style="text-align:right;"><?php echo $row->count; ?></td>
|
914 |
</tr>
|
915 |
<?php $row_num++; }?>
|
916 |
</tbody>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJ
|
|
4 |
Tags: log, login, users
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 0.
|
8 |
|
9 |
Tracks user name, time of login, IP address and browser user agent.
|
10 |
|
@@ -34,8 +34,14 @@ none
|
|
34 |
|
35 |
== Changelog ==
|
36 |
|
|
|
|
|
|
|
|
|
37 |
**0.3.0 - May 17, 2013**
|
|
|
38 |
Added "Truncate Log" option.
|
39 |
|
40 |
**0.1.0 - May 10, 2013**
|
|
|
41 |
Initial release.
|
4 |
Tags: log, login, users
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 0.4.0
|
8 |
|
9 |
Tracks user name, time of login, IP address and browser user agent.
|
10 |
|
34 |
|
35 |
== Changelog ==
|
36 |
|
37 |
+
**0.4.0 - May 17, 2013**
|
38 |
+
|
39 |
+
Added Summary page.
|
40 |
+
|
41 |
**0.3.0 - May 17, 2013**
|
42 |
+
|
43 |
Added "Truncate Log" option.
|
44 |
|
45 |
**0.1.0 - May 10, 2013**
|
46 |
+
|
47 |
Initial release.
|