Crazy Bone - Version 0.3.0

Version Description

Download this release

Release Info

Developer wokamoto
Plugin Icon wp plugin Crazy Bone
Version 0.3.0
Comparing to
See all releases

Code changes from version 0.2.0 to 0.3.0

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-16 09:56+0900\n"
7
  "Last-Translator: wokamoto <wokamoto1973@gmail.com>\n"
8
  "Language-Team: JAPANESE <http://wppluginsj.sourceforge.jp/>\n"
9
  "Language: ja_JP\n"
@@ -146,3 +146,12 @@ msgstr "ログインしてきた IP アドレス:"
146
 
147
  msgid "Your current IP address :"
148
  msgstr "現在の IP アドレス:"
 
 
 
 
 
 
 
 
 
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 14:46+0900\n"
7
  "Last-Translator: wokamoto <wokamoto1973@gmail.com>\n"
8
  "Language-Team: JAPANESE <http://wppluginsj.sourceforge.jp/>\n"
9
  "Language: ja_JP\n"
146
 
147
  msgid "Your current IP address :"
148
  msgstr "現在の IP アドレス:"
149
+
150
+ msgid "Truncate Log"
151
+ msgstr "ログイン履歴の消去"
152
+
153
+ msgid "days and older."
154
+ msgstr "日前"
155
+
156
+ msgid "Truncate"
157
+ msgstr "消去"
languages/user-login-log.pot CHANGED
@@ -136,3 +136,12 @@ msgstr ""
136
 
137
  msgid "Your current IP address :"
138
  msgstr ""
 
 
 
 
 
 
 
 
 
136
 
137
  msgid "Your current IP address :"
138
  msgstr ""
139
+
140
+ msgid "Truncate Log"
141
+ msgstr ""
142
+
143
+ msgid "days and older."
144
+ msgstr ""
145
+
146
+ msgid "Truncate"
147
+ msgstr ""
plugin.php CHANGED
@@ -4,7 +4,7 @@ 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.2.0
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
@@ -531,6 +531,37 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
531
  public function option_page() {
532
  global $wpdb;
533
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  $page = abs(intval(isset($_GET['apage']) ? $_GET['apage'] : 1));
535
  $per_page = self::LIST_PER_PAGE;
536
  $start = ($page - 1) * $per_page;
@@ -545,10 +576,10 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
545
  $user_id = intval($user->ID);
546
  }
547
 
548
- $sql = " from `{$this->ull_table}` left join `{$wpdb->users}` on `{$this->ull_table}`.`user_id` = `{$wpdb->users}`.`ID`";
549
  if ($user_id >= 0)
550
- $sql .= $wpdb->prepare(" where `user_id` = %d", $user_id);
551
- $total = intval($wpdb->get_var("select count(`{$this->ull_table}`.`ID`)".$sql));
552
  $page_links = paginate_links( array(
553
  'base' => add_query_arg( 'apage', '%#%' ) ,
554
  'format' => '' ,
@@ -565,8 +596,8 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
565
  $page_links
566
  );
567
 
568
- $sql = 'select `user_login`, `activity_date`, `activity_status`, `activity_IP`, `activity_agent`, `activity_errors`'.
569
- $sql.' order by `activity_date` DESC'.
570
  ' limit '.$start.','.self::LIST_PER_PAGE;
571
 
572
  $ull = $wpdb->get_results($sql);
@@ -575,8 +606,10 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
575
  <div class="wrap">
576
  <div id="icon-profile" class="icon32"></div>
577
  <h2><?php _e('Login Log', self::TEXT_DOMAIN); ?></h2>
 
578
 
579
  <div class="tablenav">
 
580
  <?php if (current_user_can('create_users')) { ?>
581
  <div class="alignleft actions">
582
  <form action="" method="get">
@@ -591,10 +624,24 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
591
  }
592
  ?>
593
  </select>
594
- <?php submit_button( __( 'Apply Filters' ), 'action', false, false, array( 'id' => "doaction" ) );?>
 
 
 
 
 
 
 
 
 
 
 
 
 
595
  </form>
596
  </div>
597
  <?php } ?>
 
598
  <div class="alignright tablenav-pages">
599
  <?php echo $page_links_text; ?>
600
  </div>
4
  Plugin URI:
5
  Description: Tracks user name, time of login, IP address and browser user agent.
6
  Author: wokamoto
7
+ Version: 0.3.0
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
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
+ if ($user_id < 0) {
544
+ $sql = $wpdb->prepare(
545
+ "DELETE FROM {$this->ull_table} WHERE `activity_date` <= DATE_SUB(NOW(), INTERVAL %d day)",
546
+ $truncate_date
547
+ );
548
+ } else {
549
+ $sql = $wpdb->prepare(
550
+ "DELETE FROM {$this->ull_table} WHERE `activity_date` <= DATE_SUB(NOW(), INTERVAL %d day) AND `user_id` = %d",
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>'."\n",
559
+ empty($err_message) ? __('Done!', self::TEXT_DOMAIN) : $err_message
560
+ );
561
+ }
562
+ }
563
+
564
+ // Pagination
565
  $page = abs(intval(isset($_GET['apage']) ? $_GET['apage'] : 1));
566
  $per_page = self::LIST_PER_PAGE;
567
  $start = ($page - 1) * $per_page;
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(" WHERE `user_id` = %d", $user_id);
582
+ $total = intval($wpdb->get_var("SELECT count(`{$this->ull_table}`.`ID`)".$sql));
583
  $page_links = paginate_links( array(
584
  'base' => add_query_arg( 'apage', '%#%' ) ,
585
  'format' => '' ,
596
  $page_links
597
  );
598
 
599
+ $sql = 'SELECT `user_login`, `activity_date`, `activity_status`, `activity_IP`, `activity_agent`, `activity_errors`'.
600
+ $sql.' ORDER BY `activity_date` DESC'.
601
  ' limit '.$start.','.self::LIST_PER_PAGE;
602
 
603
  $ull = $wpdb->get_results($sql);
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."\n"; ?>
610
 
611
  <div class="tablenav">
612
+
613
  <?php if (current_user_can('create_users')) { ?>
614
  <div class="alignleft actions">
615
  <form action="" method="get">
624
  }
625
  ?>
626
  </select>
627
+ <?php submit_button(__('Apply Filters'), 'action', false, false, array('id' => "doaction"));?>
628
+ </form>
629
+ </div>
630
+ <?php } ?>
631
+
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) . "\n"; ?>
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);?>&nbsp;
640
+ <?php submit_button(__('Truncate', self::TEXT_DOMAIN), 'action', false, false, array('id' => "truncate"));?>
641
  </form>
642
  </div>
643
  <?php } ?>
644
+
645
  <div class="alignright tablenav-pages">
646
  <?php echo $page_links_text; ?>
647
  </div>
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.2.0
8
 
9
  Tracks user name, time of login, IP address and browser user agent.
10
 
@@ -34,5 +34,8 @@ none
34
 
35
  == Changelog ==
36
 
 
 
 
37
  **0.1.0 - May 10, 2013**
38
  Initial release.
4
  Tags: log, login, users
5
  Requires at least: 3.5
6
  Tested up to: 3.5.1
7
+ Stable tag: 0.3.0
8
 
9
  Tracks user name, time of login, IP address and browser user agent.
10
 
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.