Crazy Bone - Version 0.5.3

Version Description

Download this release

Release Info

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

Code changes from version 0.5.2 to 0.5.3

Files changed (3) hide show
  1. plugin.php +33 -12
  2. readme.txt +5 -2
  3. uninstall.php +1 -1
plugin.php CHANGED
@@ -4,7 +4,7 @@ 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.5.2
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
@@ -34,6 +34,13 @@ if (!class_exists('DetectBrowsersController'))
34
  if (!class_exists('DetectCountriesController'))
35
  require_once( dirname(__FILE__) . '/includes/detect_countries.php' );
36
 
 
 
 
 
 
 
 
37
  load_plugin_textdomain(crazy_bone::TEXT_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages/');
38
 
39
  class crazy_bone {
@@ -58,7 +65,19 @@ class crazy_bone {
58
 
59
  static $instance;
60
 
61
- function __construct(){
 
 
 
 
 
 
 
 
 
 
 
 
62
  global $wpdb;
63
 
64
  self::$instance = $this;
@@ -74,7 +93,10 @@ class crazy_bone {
74
  $this->options = array('installed' => false);
75
  if (!isset($this->options['installed']) || !$this->options['installed'])
76
  $this->activate();
 
77
 
 
 
78
  add_action('wp_login', array($this, 'user_login_log'), 10, 2);
79
  add_action('wp_authenticate', array($this, 'wp_authenticate_log'), 10, 2);
80
  add_action('login_form_logout', array($this, 'user_logout_log'));
@@ -92,9 +114,6 @@ class crazy_bone {
92
 
93
  add_action('wp_ajax_dismiss-ull-wp-pointer', array($this, 'ajax_dismiss'));
94
  add_action('wp_ajax_nopriv_dismiss-ull-wp-pointer', array($this, 'ajax_dismiss'));
95
-
96
- register_activation_hook(__FILE__, array($this, 'activate'));
97
- register_deactivation_hook(__FILE__, array($this, 'deactivate'));
98
  }
99
 
100
  public function activate(){
@@ -219,13 +238,17 @@ CREATE TABLE `{$this->ull_table}` (
219
  }
220
 
221
  public function cookie_expired_log($cookie_elements) {
222
- $user = get_userdatabylogin($cookie_elements['username']);
223
- $this->logging($user->ID, 'cookie_expired');
 
 
224
  }
225
 
226
  public function cookie_bad_hash_log($cookie_elements) {
227
- $user = get_userdatabylogin($cookie_elements['username']);
228
- $this->logging($user->ID, 'cookie_bad_hash');
 
 
229
  }
230
 
231
  function wp_authenticate_log($user_login, $user_password) {
@@ -985,6 +1008,4 @@ if ($errors != 'invalid_username')
985
  </div>
986
  <?php
987
  }
988
- }
989
-
990
- new 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.5.3
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
34
  if (!class_exists('DetectCountriesController'))
35
  require_once( dirname(__FILE__) . '/includes/detect_countries.php' );
36
 
37
+ $crazy_bone = crazy_bone::get_instance();
38
+ $crazy_bone->init();
39
+ $crazy_bone->add_action();
40
+
41
+ register_activation_hook(__FILE__, array($crazy_bone, 'activate'));
42
+ register_deactivation_hook(__FILE__, array($crazy_bone, 'deactivate'));
43
+
44
  load_plugin_textdomain(crazy_bone::TEXT_DOMAIN, false, dirname(plugin_basename(__FILE__)) . '/languages/');
45
 
46
  class crazy_bone {
65
 
66
  static $instance;
67
 
68
+ private function __construct() {}
69
+
70
+ public static function get_instance() {
71
+ if( !isset( self::$instance ) ) {
72
+ $c = __CLASS__;
73
+ self::$instance = new $c();
74
+ }
75
+
76
+ return self::$instance;
77
+ }
78
+
79
+ // 初期化
80
+ public function init(){
81
  global $wpdb;
82
 
83
  self::$instance = $this;
93
  $this->options = array('installed' => false);
94
  if (!isset($this->options['installed']) || !$this->options['installed'])
95
  $this->activate();
96
+ }
97
 
98
+ // フックの登録
99
+ public function add_action(){
100
  add_action('wp_login', array($this, 'user_login_log'), 10, 2);
101
  add_action('wp_authenticate', array($this, 'wp_authenticate_log'), 10, 2);
102
  add_action('login_form_logout', array($this, 'user_logout_log'));
114
 
115
  add_action('wp_ajax_dismiss-ull-wp-pointer', array($this, 'ajax_dismiss'));
116
  add_action('wp_ajax_nopriv_dismiss-ull-wp-pointer', array($this, 'ajax_dismiss'));
 
 
 
117
  }
118
 
119
  public function activate(){
238
  }
239
 
240
  public function cookie_expired_log($cookie_elements) {
241
+ if ( function_exists('get_userdatabylogin') ) {
242
+ $user = get_userdatabylogin($cookie_elements['username']);
243
+ $this->logging($user->ID, 'cookie_expired');
244
+ }
245
  }
246
 
247
  public function cookie_bad_hash_log($cookie_elements) {
248
+ if ( function_exists('get_userdatabylogin') ) {
249
+ $user = get_userdatabylogin($cookie_elements['username']);
250
+ $this->logging($user->ID, 'cookie_bad_hash');
251
+ }
252
  }
253
 
254
  function wp_authenticate_log($user_login, $user_password) {
1008
  </div>
1009
  <?php
1010
  }
1011
+ }
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wokamoto, megumithemes
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJCY7XB8F4&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=JPY&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: log, login, users
5
  Requires at least: 3.5
6
- Tested up to: 3.6.1
7
- Stable tag: 0.5.2
8
 
9
  Tracks user name, time of login, IP address and browser user agent.
10
 
@@ -34,6 +34,9 @@ none
34
 
35
  == Changelog ==
36
 
 
 
 
37
  **0.5.2 - Oct. 23, 2013**
38
  action hook fix, sql syntax fix
39
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJCY7XB8F4&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=JPY&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: log, login, users
5
  Requires at least: 3.5
6
+ Tested up to: 4.0
7
+ Stable tag: 0.5.3
8
 
9
  Tracks user name, time of login, IP address and browser user agent.
10
 
34
 
35
  == Changelog ==
36
 
37
+ **0.5.3 - Oct. 20, 2014**
38
+ source code refactoring.
39
+
40
  **0.5.2 - Oct. 23, 2013**
41
  action hook fix, sql syntax fix
42
 
uninstall.php CHANGED
@@ -9,5 +9,5 @@ $wpdb->query("delete from {$wpdb->usermeta} where meta_key like 'user_login_log%
9
  delete_option( 'user-login-log' );
10
 
11
  $ull_table = $wpdb->prefix.'user_login_log';
12
- if ($wpdb->get_var("show tables like '{$ull_table}'") != $ull_table)
13
  $wpdb->query("DROP TABLE `{$ull_table}`");
9
  delete_option( 'user-login-log' );
10
 
11
  $ull_table = $wpdb->prefix.'user_login_log';
12
+ if ($wpdb->get_var("show tables like '{$ull_table}'") == $ull_table)
13
  $wpdb->query("DROP TABLE `{$ull_table}`");