Count per Day - Version 3.5.3

Version Description

  • Bugfix: undefined function cpd_inet_pton (once again)
Download this release

Release Info

Developer Tom Braider
Plugin Icon 128x128 Count per Day
Version 3.5.3
Comparing to
See all releases

Code changes from version 3.5.2 to 3.5.3

Files changed (4) hide show
  1. counter-core.php +40 -0
  2. counter.php +3 -3
  3. geoip.php +0 -37
  4. readme.txt +4 -1
counter-core.php CHANGED
@@ -1594,4 +1594,44 @@ function loadGeoIpAddon()
1594
  echo '<div class="error"><p>'.sprintf(__('Sorry, an error occurred. Load the file from %s and copy it to wp-content/count-per-day-geoip/ directory.', 'cpd'), '<a href="'.$source.'">'.$source.'</a>').'</p></div>';
1595
  }
1596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1597
  } // class
1594
  echo '<div class="error"><p>'.sprintf(__('Sorry, an error occurred. Load the file from %s and copy it to wp-content/count-per-day-geoip/ directory.', 'cpd'), '<a href="'.$source.'">'.$source.'</a>').'</p></div>';
1595
  }
1596
 
1597
+ /**
1598
+ * Windows server < PHP 5.3
1599
+ * PHP without IPv6 support
1600
+ */
1601
+ function inetPton($ip)
1602
+ {
1603
+ # ipv4
1604
+ if (strpos($ip, '.') !== FALSE)
1605
+ {
1606
+ if (strpos($ip, ':') === FALSE)
1607
+ $ip = pack('N',ip2long($ip));
1608
+ else
1609
+ {
1610
+ $ip = explode(':',$ip);
1611
+ $ip = pack('N',ip2long($ip[count($ip)-1]));
1612
+ }
1613
+ }
1614
+ # ipv6
1615
+ elseif (strpos($ip, ':') !== FALSE)
1616
+ {
1617
+ $ip = explode(':', $ip);
1618
+ $parts=8-count($ip);
1619
+ $res='';$replaced=0;
1620
+ foreach ($ip as $seg)
1621
+ {
1622
+ if ($seg!='')
1623
+ $res .= str_pad($seg, 4, '0', STR_PAD_LEFT);
1624
+ elseif ($replaced==0)
1625
+ {
1626
+ for ($i=0;$i<=$parts;$i++)
1627
+ $res.='0000';
1628
+ $replaced=1;
1629
+ } elseif ($replaced==1)
1630
+ $res.='0000';
1631
+ }
1632
+ $ip = pack('H'.strlen($res), $res);
1633
+ }
1634
+ return $ip;
1635
+ }
1636
+
1637
  } // class
counter.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Count Per Day
4
  Plugin URI: http://www.tomsdimension.de/wp-plugins/count-per-day
5
  Description: Counter, shows reads and visitors per page; today, yesterday, last week, last months ... on dashboard, per shortcode or in widget.
6
- Version: 3.5.2
7
  License: Postcardware
8
  Author: Tom Braider
9
  Author URI: http://www.tomsdimension.de
@@ -13,7 +13,7 @@ if (!defined('ABSPATH'))
13
  exit;
14
 
15
  $cpd_dir_name = 'count-per-day';
16
- $cpd_version = '3.5.2';
17
 
18
  if (strpos($_SERVER['SERVER_NAME'], '.test'))
19
  $cpd_path = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH.PLUGINDIR.'/'.$cpd_dir_name.'/');
@@ -159,7 +159,7 @@ function count( $x, $page = 'x' )
159
  {
160
  // IPv6
161
  // store dummy ipv4 until we can handle ipv6
162
- $packed = cpd_inet_pton($userip);
163
  if (strlen($packed) === 4)
164
  $unpacked = array_pad(unpack( "C4", $packed), -16, 0);
165
  else
3
  Plugin Name: Count Per Day
4
  Plugin URI: http://www.tomsdimension.de/wp-plugins/count-per-day
5
  Description: Counter, shows reads and visitors per page; today, yesterday, last week, last months ... on dashboard, per shortcode or in widget.
6
+ Version: 3.5.3
7
  License: Postcardware
8
  Author: Tom Braider
9
  Author URI: http://www.tomsdimension.de
13
  exit;
14
 
15
  $cpd_dir_name = 'count-per-day';
16
+ $cpd_version = '3.5.3';
17
 
18
  if (strpos($_SERVER['SERVER_NAME'], '.test'))
19
  $cpd_path = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH.PLUGINDIR.'/'.$cpd_dir_name.'/');
159
  {
160
  // IPv6
161
  // store dummy ipv4 until we can handle ipv6
162
+ $packed = $this->inetPton($userip);
163
  if (strlen($packed) === 4)
164
  $unpacked = array_pad(unpack( "C4", $packed), -16, 0);
165
  else
geoip.php CHANGED
@@ -141,40 +141,3 @@ static function updateGeoIpFile()
141
 
142
  }
143
 
144
- // Windows server < PHP 5.3
145
- // PHP without IPv6 support
146
- function cpd_inet_pton($ip)
147
- {
148
- # ipv4
149
- if (strpos($ip, '.') !== FALSE)
150
- {
151
- if (strpos($ip, ':') === FALSE)
152
- $ip = pack('N',ip2long($ip));
153
- else
154
- {
155
- $ip = explode(':',$ip);
156
- $ip = pack('N',ip2long($ip[count($ip)-1]));
157
- }
158
- }
159
- # ipv6
160
- elseif (strpos($ip, ':') !== FALSE)
161
- {
162
- $ip = explode(':', $ip);
163
- $parts=8-count($ip);
164
- $res='';$replaced=0;
165
- foreach ($ip as $seg)
166
- {
167
- if ($seg!='')
168
- $res .= str_pad($seg, 4, '0', STR_PAD_LEFT);
169
- elseif ($replaced==0)
170
- {
171
- for ($i=0;$i<=$parts;$i++)
172
- $res.='0000';
173
- $replaced=1;
174
- } elseif ($replaced==1)
175
- $res.='0000';
176
- }
177
- $ip = pack('H'.strlen($res), $res);
178
- }
179
- return $ip;
180
- }
141
 
142
  }
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Tom Braider
3
  Tags: counter, count, posts, visits, reads, dashboard, widget, shortcode
4
  Requires at least: 3.0
5
  Tested up to: 4.6
6
- Stable tag: 3.5.2
7
  License: Postcardware :)
8
  Donate link: http://www.tomsdimension.de/postcards
9
 
@@ -308,6 +308,9 @@ show( $before, $after, $show, $count, $page )'
308
 
309
  == Changelog ==
310
 
 
 
 
311
  = 3.5.2 =
312
  + Bugfix: undefined function cpd_inet_pton
313
 
3
  Tags: counter, count, posts, visits, reads, dashboard, widget, shortcode
4
  Requires at least: 3.0
5
  Tested up to: 4.6
6
+ Stable tag: 3.5.3
7
  License: Postcardware :)
8
  Donate link: http://www.tomsdimension.de/postcards
9
 
308
 
309
  == Changelog ==
310
 
311
+ = 3.5.3 =
312
+ + Bugfix: undefined function cpd_inet_pton (once again)
313
+
314
  = 3.5.2 =
315
  + Bugfix: undefined function cpd_inet_pton
316