Crazy Bone - Version 0.5.4

Version Description

Download this release

Release Info

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

Code changes from version 0.5.3 to 0.5.4

includes/detect_browsers.php CHANGED
@@ -25,24 +25,22 @@ License:
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
 
 
 
28
  class DetectBrowsersController {
29
- var $_ua_cache = array();
30
 
31
  /**********************************************************
32
  * Constructor
33
  ***********************************************************/
34
- function DetectBrowsersController() {
35
- $this->__construct();
36
- }
37
- function __construct() {
38
- if (!class_exists('DetectBrowsers'))
39
- require_once 'class-detect-browsers.php';
40
  }
41
 
42
  /**********************************************************
43
  * Get Information from user agent
44
  ***********************************************************/
45
- function get_info($ua) {
46
  if ( isset($this->_ua_cache[$ua]) )
47
  return $this->_ua_cache[$ua];
48
 
25
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
  */
27
 
28
+ if (!class_exists('DetectBrowsers'))
29
+ require_once 'class-detect-browsers.php';
30
+
31
  class DetectBrowsersController {
32
+ private $_ua_cache = array();
33
 
34
  /**********************************************************
35
  * Constructor
36
  ***********************************************************/
37
+ public function __construct() {
 
 
 
 
 
38
  }
39
 
40
  /**********************************************************
41
  * Get Information from user agent
42
  ***********************************************************/
43
+ public function get_info($ua) {
44
  if ( isset($this->_ua_cache[$ua]) )
45
  return $this->_ua_cache[$ua];
46
 
includes/detect_countries.php CHANGED
@@ -34,11 +34,16 @@ class DetectCountriesController {
34
  const IP2C_BIN_FILE = 'ip-to-country.bin';
35
  const IP2C_VER_FILE = 'db.version';
36
 
 
37
 
38
  /**********************************************************
39
  * Constructor
40
  ***********************************************************/
41
- function __construct() {
 
 
 
 
42
  // Check ip-to-country.bin file
43
  $ip2c_bin_file = dirname(__FILE__) . '/ip2c/' .self::IP2C_BIN_FILE;
44
  if ( !file_exists($ip2c_bin_file) ) {
@@ -48,6 +53,9 @@ class DetectCountriesController {
48
  }
49
 
50
  public function get_info($ip) {
 
 
 
51
  $res = $this->ip2c->get_country($ip);
52
  $ccode = $res != false ? $res['id2'] : null;
53
  unset($res);
34
  const IP2C_BIN_FILE = 'ip-to-country.bin';
35
  const IP2C_VER_FILE = 'db.version';
36
 
37
+ static $instance;
38
 
39
  /**********************************************************
40
  * Constructor
41
  ***********************************************************/
42
+ public function __construct() {
43
+ $this->init();
44
+ }
45
+
46
+ public function init() {
47
  // Check ip-to-country.bin file
48
  $ip2c_bin_file = dirname(__FILE__) . '/ip2c/' .self::IP2C_BIN_FILE;
49
  if ( !file_exists($ip2c_bin_file) ) {
53
  }
54
 
55
  public function get_info($ip) {
56
+ if ( !isset($this->ip2c) )
57
+ $this->init();
58
+
59
  $res = $this->ip2c->get_country($ip);
60
  $ccode = $res != false ? $res['id2'] : null;
61
  unset($res);
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.3
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
@@ -13,7 +13,7 @@ License:
13
  Released under the GPL license
14
  http://www.gnu.org/copyleft/gpl.html
15
 
16
- Copyright 2013 (email : wokamoto1973@gmail.com)
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
@@ -76,7 +76,7 @@ class crazy_bone {
76
  return self::$instance;
77
  }
78
 
79
- // 初期化
80
  public function init(){
81
  global $wpdb;
82
 
@@ -95,7 +95,7 @@ class crazy_bone {
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);
@@ -453,7 +453,9 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
453
 
454
  // Detect Country
455
  public static function detect_country($ip) {
456
- $detect_countries = new DetectCountriesController();
 
 
457
  list($country_name, $country_code) = $detect_countries->get_info($ip);
458
  if ( empty($country_code) )
459
  $country_code = __('UNKNOWN', self::TEXT_DOMAIN);
@@ -467,7 +469,9 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
467
 
468
  // Detect Browser
469
  public static function detect_browser($ua) {
470
- $detect_browsers = new DetectBrowsersController();
 
 
471
  list($browser_name, $browser_code, $browser_ver, $os_name, $os_code, $os_ver, $pda_name, $pda_code, $pda_ver) = $detect_browsers->get_info($ua);
472
  if (empty($os_code)) {
473
  $os_name = !empty($pda_code) ? $pda_name : $browser_name;
@@ -498,53 +502,22 @@ jQuery(function(){setTimeout('get_ull_info()', 10000);});
498
  return $time;
499
  }
500
 
501
- private function nice_time($dest) {
502
- $dest = intval($dest);
503
  $sour = intval(func_num_args() == 1 ? strtotime($this->time()) : func_get_arg(1));
504
  $nicetime = '';
505
-
506
  $tt = $dest - $sour;
507
 
508
- $year = intval($tt / self::SEC_YEAR);
509
- if ($year < -1) {
510
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . sprintf(__('%d years', self::TEXT_DOMAIN), abs($year));
511
- } else if ($year == -1) {
512
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . __('one year', self::TEXT_DOMAIN);
513
- }
514
-
515
- $month = intval($tt / self::SEC_MONTH);
516
- if ($month < -1) {
517
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . sprintf(__('%d months', self::TEXT_DOMAIN), abs($month));
518
- $tt = ($dest + abs($year) * self::SEC_MONTH) - $sour;
519
- } else if ($month == -1) {
520
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . __('one month', self::TEXT_DOMAIN);
521
- $tt = ($dest + self::SEC_MONTH) - $sour;
522
- }
523
-
524
- $day = intval($tt / self::SEC_DAY);
525
- if ($day < -1) {
526
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . sprintf(__('%d days', self::TEXT_DOMAIN), abs($day));
527
- } else if ($day == -1) {
528
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . __('one day', self::TEXT_DOMAIN);
529
- }
530
-
531
- $hour = intval($tt / self::SEC_HOUR);
532
- if ($hour < -1) {
533
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . sprintf(__('%d hours', self::TEXT_DOMAIN), abs($hour));
534
- $tt = ($dest + abs($hour) * self::SEC_HOUR) - $sour;
535
- } else if ($hour == -1) {
536
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . __('one hour', self::TEXT_DOMAIN);
537
- $tt = ($dest + self::SEC_HOUR) - $sour;
538
- }
539
-
540
  $minute = intval($tt / self::SEC_MINUITE);
541
- if ($minute < -1) {
542
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . sprintf(__('%d minutes', self::TEXT_DOMAIN), abs($minute));
 
 
543
  } else if ($minute == -1) {
544
- $nicetime .= (!empty($nicetime) ? ' ' : '' ) . __('one minute', self::TEXT_DOMAIN);
545
  }
546
 
547
- return empty($nicetime) ? __('Just now!', self::TEXT_DOMAIN) : sprintf(__('%s ago.', self::TEXT_DOMAIN), $nicetime);
548
  }
549
 
550
  public static function icon_img_tag($src, $alt, $title, $style = 'width:16px;height:16px;', $class = '') {
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.4
8
  Author URI: http://dogmap.jp/
9
  Text Domain: user-login-log
10
  Domain Path: /languages/
13
  Released under the GPL license
14
  http://www.gnu.org/copyleft/gpl.html
15
 
16
+ Copyright 2013-2014 (email : wokamoto1973@gmail.com)
17
 
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
76
  return self::$instance;
77
  }
78
 
79
+ // initialize
80
  public function init(){
81
  global $wpdb;
82
 
95
  $this->activate();
96
  }
97
 
98
+ // added action
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);
453
 
454
  // Detect Country
455
  public static function detect_country($ip) {
456
+ static $detect_countries;
457
+ if ( !isset($detect_countries) )
458
+ $detect_countries = new DetectCountriesController();
459
  list($country_name, $country_code) = $detect_countries->get_info($ip);
460
  if ( empty($country_code) )
461
  $country_code = __('UNKNOWN', self::TEXT_DOMAIN);
469
 
470
  // Detect Browser
471
  public static function detect_browser($ua) {
472
+ static $detect_browsers;
473
+ if ( !isset($detect_browsers) )
474
+ $detect_browsers = new DetectBrowsersController();
475
  list($browser_name, $browser_code, $browser_ver, $os_name, $os_code, $os_ver, $pda_name, $pda_code, $pda_ver) = $detect_browsers->get_info($ua);
476
  if (empty($os_code)) {
477
  $os_name = !empty($pda_code) ? $pda_name : $browser_name;
502
  return $time;
503
  }
504
 
505
+ private function nice_time($date) {
506
+ $dest = intval($date);
507
  $sour = intval(func_num_args() == 1 ? strtotime($this->time()) : func_get_arg(1));
508
  $nicetime = '';
 
509
  $tt = $dest - $sour;
510
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  $minute = intval($tt / self::SEC_MINUITE);
512
+ if ($minute < -60) {
513
+ $nicetime .= date( get_option('date_format').' '.get_option('time_format'), $date );
514
+ } elseif ($minute < -1) {
515
+ $nicetime .= sprintf(__('%s ago.', self::TEXT_DOMAIN), (!empty($nicetime) ? ' ' : '' ) . sprintf(__('%d minutes', self::TEXT_DOMAIN), abs($minute)));
516
  } else if ($minute == -1) {
517
+ $nicetime .= sprintf(__('%s ago.', self::TEXT_DOMAIN), (!empty($nicetime) ? ' ' : '' ) . __('one minute', self::TEXT_DOMAIN));
518
  }
519
 
520
+ return empty($nicetime) ? __('Just now!', self::TEXT_DOMAIN) : $nicetime;
521
  }
522
 
523
  public static function icon_img_tag($src, $alt, $title, $style = 'width:16px;height:16px;', $class = '') {
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: 4.0
7
- Stable tag: 0.5.3
8
 
9
  Tracks user name, time of login, IP address and browser user agent.
10
 
@@ -34,10 +34,16 @@ none
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
 
43
  **0.5.1 - Sep. 9, 2013**
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.1
7
+ Stable tag: 0.5.4
8
 
9
  Tracks user name, time of login, IP address and browser user agent.
10
 
34
 
35
  == Changelog ==
36
 
37
+ **0.5.4 - Dec. 17, 2014**
38
+
39
+ Fix "Redefining already defined constructor" warning
40
+
41
  **0.5.3 - Oct. 20, 2014**
42
+
43
  source code refactoring.
44
 
45
  **0.5.2 - Oct. 23, 2013**
46
+
47
  action hook fix, sql syntax fix
48
 
49
  **0.5.1 - Sep. 9, 2013**
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}`");