Count per Day - Version 3.2.6

Version Description

  • New: posts only parameters for [CPD_MOST_VISITED_POSTS]
  • New: don't count password protected posts without password
  • New: translate widget titles if possible
  • New: flags of Cambodia, Nigeria and Sudan
  • Bugfix: massbot post list has not show all post
  • Bugfix: security fix, XSS
  • Bugfix: problems while adding widgets
  • Bugfix: start session only in backend
  • Bugfix: empty database query
Download this release

Release Info

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

Code changes from version 3.2.5 to 3.2.6

Files changed (15) hide show
  1. ajax.php +4 -4
  2. counter-core.php +78 -71
  3. counter.css +31 -22
  4. counter.php +30 -16
  5. geoip/GeoIP.dat +0 -0
  6. geoip/cpd_geoip.inc +0 -713
  7. geoip/geoip.inc +433 -221
  8. geoip/geoip.php +35 -16
  9. img/cpd_flags.png +0 -0
  10. locale/cpd-sr_RS.mo +0 -0
  11. locale/cpd-sr_RS.po +1119 -0
  12. massbots.php +8 -8
  13. notes.php +3 -3
  14. readme.txt +57 -32
  15. userperspan.php +10 -8
ajax.php CHANGED
@@ -5,7 +5,7 @@ if ( $_GET['f'] == 'count' )
5
  if ( empty($_GET['time']) || time() - $_GET['time'] > 20 )
6
  {
7
  header("HTTP/1.0 403 Forbidden");
8
- die();
9
  }
10
 
11
  if (!session_id()) session_start();
@@ -27,11 +27,11 @@ if ( $_GET['f'] == 'count' )
27
  {
28
  echo $f.'===';
29
  if ( $f == 'getUserPerDay' )
30
- eval('echo $count_per_day->getUserPerDay('.$count_per_day->options['dashboard_last_days'].');');
31
  else if ( $f == 'show' )
32
- eval('echo $count_per_day->show("", "", false, false, '.$page.');');
33
  else
34
- eval('echo $count_per_day->'.$f.'();');
35
  echo '|';
36
  }
37
  }
5
  if ( empty($_GET['time']) || time() - $_GET['time'] > 20 )
6
  {
7
  header("HTTP/1.0 403 Forbidden");
8
+ die('wrong request');
9
  }
10
 
11
  if (!session_id()) session_start();
27
  {
28
  echo $f.'===';
29
  if ( $f == 'getUserPerDay' )
30
+ echo $count_per_day->getUserPerDay($count_per_day->options['dashboard_last_days']);
31
  else if ( $f == 'show' )
32
+ echo $count_per_day->show("", "", false, false, '.$page.');
33
  else
34
+ echo call_user_func('$count_per_day->'.$f);
35
  echo '|';
36
  }
37
  }
counter-core.php CHANGED
@@ -147,7 +147,8 @@ function init()
147
  add_action('admin_enqueue_scripts', array(&$this,'addThickbox'));
148
 
149
  // Session
150
- add_action('init', array(&$this,'startSession'), 1);
 
151
 
152
  $this->aton = 'INET_ATON';
153
  $this->ntoa = 'INET_NTOA';
@@ -159,11 +160,11 @@ function init()
159
  function addPostTypesColumns()
160
  {
161
  $post_types = get_post_types(array('public'=>true),'objects');
162
- foreach ($post_types as $post_type )
163
  {
164
  $name = trim($post_type->name);
165
- add_action('manage_'.trim($name).'s_custom_column', array(&$this,'cpdColumnContent'), 10, 2);
166
- add_filter('manage_edit-'.trim($name).'_columns', array(&$this,'cpdColumn'));
167
  }
168
  }
169
 
@@ -179,17 +180,6 @@ function addThickbox()
179
  wp_enqueue_script('cpd_flot', $this->dir.'/js/jquery.flot.min.js', 'jQuery');
180
  }
181
 
182
- function cpdReadsOrderby( $vars )
183
- {
184
- if ( isset($vars['orderby']) && $vars['orderby'] == 'cpd_reads' )
185
- {
186
- $vars = array_merge( $vars, array(
187
- 'meta_key' => 'cpd_reads',
188
- 'orderby' => 'meta_value_num'
189
- ));
190
- }
191
- return $vars;
192
- }
193
 
194
  /**
195
  * starts session to provide WP variables to "addons"
@@ -204,7 +194,7 @@ function startSession()
204
  /**
205
  * get result from database
206
  * @param string $kind kind of result
207
- * @param string $sql sql query
208
  * @param string $func name for debug info
209
  */
210
  function mysqlQuery( $kind = '', $sql, $func = '' )
@@ -214,14 +204,26 @@ function mysqlQuery( $kind = '', $sql, $func = '' )
214
  return;
215
  $t = microtime(true);
216
  $con = $wpdb->dbh;
217
- $preparedSql = $wpdb->prepare($sql, null);
 
 
 
 
 
 
 
 
 
 
 
 
218
  $r = false;
219
  if ($kind == 'var')
220
  $r = $wpdb->get_var( $preparedSql );
221
  else if ($kind == 'count')
222
  {
223
- $sql = 'SELECT COUNT(*) FROM ('.trim($sql,';').') t';
224
- $r = $wpdb->get_var( $wpdb->prepare($sql, null) );
225
  }
226
  else if ($kind == 'rows')
227
  {
@@ -262,6 +264,10 @@ function checkInstalledVersion()
262
  */
263
  function anonymize_ip( $ip )
264
  {
 
 
 
 
265
  if ( $this->options['debug'] )
266
  $this->queries[] = 'called Function: <b style="color:blue">anonymize_ip</b> IP: <code>'.$ip.'</code>';
267
  if ($this->options['anoip'])
@@ -360,7 +366,7 @@ function checkVersion()
360
  if (!empty($_GET['networkwide']))
361
  {
362
  $old_blog = $wpdb->blogid;
363
- $blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs", null));
364
  foreach ($blogids as $blog_id)
365
  {
366
  // create tables in all sub blogs
@@ -401,11 +407,12 @@ function createTables()
401
  `client` varchar(150) NOT NULL,
402
  `date` date NOT NULL,
403
  `page` mediumint(9) NOT NULL,
 
404
  `referer` varchar(100) NOT NULL,
405
  PRIMARY KEY (`id`),
406
  KEY `idx_page` (`page`),
407
  KEY `idx_dateip` (`date`,`ip`) )
408
- $charset_collate;";
409
  $this->mysqlQuery('', $sql, 'createTables '.__LINE__);
410
 
411
  // update fields in old table
@@ -438,15 +445,12 @@ function createTables()
438
  $sql .= 'ADD KEY `idx_dateip` (`date`,`ip`), ADD KEY `idx_page` (`page`)';
439
  $this->mysqlQuery('', $sql, 'make keys '.__LINE__);
440
 
441
- // if GeoIP installed we need row "country"
442
- if ( class_exists('CpdGeoIp') )
443
- {
444
- $this->mysqlQuery('', "SELECT country FROM `$cpd_c` LIMIT 1", 'check country '.__LINE__);
445
- if ((int) mysql_errno() == 1054)
446
- $this->mysqlQuery('', "ALTER TABLE `$cpd_c` ADD `country` CHAR(2) NOT NULL", 'make country '.__LINE__);
447
- }
448
 
449
- // referrer
450
  $this->mysqlQuery('', "SELECT referer FROM `$cpd_c` LIMIT 1", 'check referer '.__LINE__);
451
  if ((int) mysql_errno() == 1054)
452
  $this->mysqlQuery('', "ALTER TABLE `$cpd_c` ADD `referer` VARCHAR(100) NOT NULL", 'make referer '.__LINE__);
@@ -567,7 +571,7 @@ function addAjaxScript()
567
  <script type="text/javascript">
568
  // Count per Day
569
  //<![CDATA[
570
- jQuery(document).ready( function($)
571
  {
572
  jQuery.get('{$this->dir}/ajax.php?f=count&page={$this->page}&time={$time}', function(text)
573
  {
@@ -664,9 +668,9 @@ function updateOptions()
664
  'dashboard_last_days' => 7,
665
  'show_in_lists' => 1,
666
  'chart_days' => 60,
667
- 'chart_height' => 100,
668
  'countries' => 20,
669
- 'startdate' => '2000-01-01',
670
  'startcount' => '',
671
  'startreads' => '',
672
  'anoip' => 0,
@@ -702,39 +706,6 @@ function dashboardWidgetSetup()
702
  wp_add_dashboard_widget( 'cpdDashboardWidget', 'Count per Day', array(&$this,'dashboardWidget') );
703
  }
704
 
705
- /**
706
- * add counter column to page/post lists
707
- */
708
- function cpdColumn($defaults)
709
- {
710
- if ( $this->options['show_in_lists'] )
711
- $defaults['cpd_reads'] = '<img src="'.$this->img('cpd_menu.gif').'" alt="'.__('Reads', 'cpd').'" title="'.__('Reads', 'cpd').'" style="width:12px;height:12px;" />';
712
- return $defaults;
713
- }
714
-
715
- function cpdSortableColumns($columns)
716
- {
717
- // meta column id => sortby value used in query
718
- $custom = array('cpd_reads' => 'cpd_reads');
719
- return wp_parse_args($custom, $columns);
720
- }
721
-
722
- /**
723
- * adds content to the counter column
724
- */
725
- function cpdColumnContent($column_name, $id = 0)
726
- {
727
- global $wpdb;
728
- if( $column_name == 'cpd_reads' )
729
- {
730
- $c = $this->mysqlQuery('count', "SELECT 1 FROM $wpdb->cpd_counter WHERE page='$id'", 'cpdColumn_'.$id.'_'.__LINE__);
731
- $coll = get_option('count_per_day_posts');
732
- if ( $coll && isset($coll['p'.$id]) )
733
- $c += $coll['p'.$id];
734
- echo $c;
735
- }
736
- }
737
-
738
  /**
739
  * gets image recource with given name
740
  */
@@ -748,7 +719,7 @@ function img( $r )
748
  */
749
  function screenLayoutColumns($columns, $screen)
750
  {
751
- if ($screen == $this->pagehook)
752
  $columns[$this->pagehook] = 4;
753
  return $columns;
754
  }
@@ -856,8 +827,8 @@ function onShowPage()
856
  </div>
857
  <script type="text/javascript">
858
  //<![CDATA[
859
- jQuery(document).ready( function($) {
860
- $('.if-js-closed').removeClass('if-js-closed').addClass('closed');
861
  postboxes.add_postbox_toggles('<?php echo $this->pagehook; ?>');
862
  });
863
  //]]>
@@ -918,10 +889,20 @@ function shortUserPerMonth() { return $this->getUserPerMonth(true, true); }
918
  function shortUserPerPost() { return $this->getUserPerPost(0, true, true); }
919
  function shortCountries() { return $this->getCountries(0, true, false, true); }
920
  function shortCountriesUsers(){ return $this->getCountries(0, true, true, true); }
921
- function shortMostVisitedPosts(){ return $this->getMostVisitedPosts(0, 0, true, false, true); }
922
  function shortReferers() { return $this->getReferers(0, true, 0); }
923
  function shortDayWithMostReads(){ return $this->getDayWithMostReads(true, true); }
924
  function shortDayWithMostUsers(){ return $this->getDayWithMostUsers(true, true); }
 
 
 
 
 
 
 
 
 
 
925
  function shortGetSearches( $atts )
926
  {
927
  extract( shortcode_atts( array(
@@ -1451,7 +1432,7 @@ function getSearchString()
1451
  {
1452
  if (empty($_SERVER['HTTP_REFERER']))
1453
  return false;
1454
- $ref = parse_url(rawurldecode($_SERVER['HTTP_REFERER']));
1455
  if ( empty($ref['host']) || empty($ref['query']) )
1456
  return false;
1457
  $keys = array('p','q','s','query','search','prev','qkw','qry');
@@ -1459,11 +1440,37 @@ function getSearchString()
1459
  foreach ($keys as $key)
1460
  if (isset($query[$key]))
1461
  $search = str_ireplace(array('/search?q=','/images?q='), '', $query[$key]);
1462
- $search = strip_tags($search);
 
1463
  if (empty($search) || is_numeric($search)) // non WordPress postID
1464
  $search = '';
1465
  return trim($search);
1466
  }
1467
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1468
 
1469
  } // class
147
  add_action('admin_enqueue_scripts', array(&$this,'addThickbox'));
148
 
149
  // Session
150
+ if (strpos($_SERVER['SCRIPT_NAME'], '/wp-admin/') !== false )
151
+ add_action('init', array(&$this,'startSession'), 1);
152
 
153
  $this->aton = 'INET_ATON';
154
  $this->ntoa = 'INET_NTOA';
160
  function addPostTypesColumns()
161
  {
162
  $post_types = get_post_types(array('public'=>true),'objects');
163
+ foreach ($post_types as $post_type )
164
  {
165
  $name = trim($post_type->name);
166
+ add_action('manage_'.$name.'s_custom_column', array(&$this,'cpdColumnContent'), 10, 2);
167
+ add_filter('manage_edit-'.$name.'_columns', array(&$this,'cpdColumn'));
168
  }
169
  }
170
 
180
  wp_enqueue_script('cpd_flot', $this->dir.'/js/jquery.flot.min.js', 'jQuery');
181
  }
182
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
  /**
185
  * starts session to provide WP variables to "addons"
194
  /**
195
  * get result from database
196
  * @param string $kind kind of result
197
+ * @param string|array $sql sql query [and args]
198
  * @param string $func name for debug info
199
  */
200
  function mysqlQuery( $kind = '', $sql, $func = '' )
204
  return;
205
  $t = microtime(true);
206
  $con = $wpdb->dbh;
207
+
208
+ if ( is_array($sql) )
209
+ {
210
+ $sql = array_shift($sql);
211
+ $args = $sql;
212
+ $preparedSql = $wpdb->prepare($sql, $args);
213
+ }
214
+ else
215
+ $preparedSql = $sql;
216
+
217
+ if (empty($preparedSql))
218
+ return;
219
+
220
  $r = false;
221
  if ($kind == 'var')
222
  $r = $wpdb->get_var( $preparedSql );
223
  else if ($kind == 'count')
224
  {
225
+ // $sql = 'SELECT COUNT(*) FROM ('.trim($sql,';').') t';
226
+ $r = $wpdb->get_var('SELECT COUNT(*) FROM ('.trim($preparedSql,';').') t');
227
  }
228
  else if ($kind == 'rows')
229
  {
264
  */
265
  function anonymize_ip( $ip )
266
  {
267
+ // not on IPv6
268
+ if (strpos($ip,':'))
269
+ return $ip;
270
+
271
  if ( $this->options['debug'] )
272
  $this->queries[] = 'called Function: <b style="color:blue">anonymize_ip</b> IP: <code>'.$ip.'</code>';
273
  if ($this->options['anoip'])
366
  if (!empty($_GET['networkwide']))
367
  {
368
  $old_blog = $wpdb->blogid;
369
+ $blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM %s", $wpdb->blogs));
370
  foreach ($blogids as $blog_id)
371
  {
372
  // create tables in all sub blogs
407
  `client` varchar(150) NOT NULL,
408
  `date` date NOT NULL,
409
  `page` mediumint(9) NOT NULL,
410
+ `country` CHAR(2) NOT NULL,
411
  `referer` varchar(100) NOT NULL,
412
  PRIMARY KEY (`id`),
413
  KEY `idx_page` (`page`),
414
  KEY `idx_dateip` (`date`,`ip`) )
415
+ $charset_collate";
416
  $this->mysqlQuery('', $sql, 'createTables '.__LINE__);
417
 
418
  // update fields in old table
445
  $sql .= 'ADD KEY `idx_dateip` (`date`,`ip`), ADD KEY `idx_page` (`page`)';
446
  $this->mysqlQuery('', $sql, 'make keys '.__LINE__);
447
 
448
+ // column country
449
+ $this->mysqlQuery('', "SELECT country FROM `$cpd_c` LIMIT 1", 'check country '.__LINE__);
450
+ if ((int) mysql_errno() == 1054)
451
+ $this->mysqlQuery('', "ALTER TABLE `$cpd_c` ADD `country` CHAR(2) NOT NULL", 'make country '.__LINE__);
 
 
 
452
 
453
+ // column referrer
454
  $this->mysqlQuery('', "SELECT referer FROM `$cpd_c` LIMIT 1", 'check referer '.__LINE__);
455
  if ((int) mysql_errno() == 1054)
456
  $this->mysqlQuery('', "ALTER TABLE `$cpd_c` ADD `referer` VARCHAR(100) NOT NULL", 'make referer '.__LINE__);
571
  <script type="text/javascript">
572
  // Count per Day
573
  //<![CDATA[
574
+ jQuery(document).ready( function()
575
  {
576
  jQuery.get('{$this->dir}/ajax.php?f=count&page={$this->page}&time={$time}', function(text)
577
  {
668
  'dashboard_last_days' => 7,
669
  'show_in_lists' => 1,
670
  'chart_days' => 60,
671
+ 'chart_height' => 200,
672
  'countries' => 20,
673
+ 'startdate' => '',
674
  'startcount' => '',
675
  'startreads' => '',
676
  'anoip' => 0,
706
  wp_add_dashboard_widget( 'cpdDashboardWidget', 'Count per Day', array(&$this,'dashboardWidget') );
707
  }
708
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
709
  /**
710
  * gets image recource with given name
711
  */
719
  */
720
  function screenLayoutColumns($columns, $screen)
721
  {
722
+ if ( isset($this->pagehook) && $screen == $this->pagehook )
723
  $columns[$this->pagehook] = 4;
724
  return $columns;
725
  }
827
  </div>
828
  <script type="text/javascript">
829
  //<![CDATA[
830
+ jQuery(document).ready( function() {
831
+ jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
832
  postboxes.add_postbox_toggles('<?php echo $this->pagehook; ?>');
833
  });
834
  //]]>
889
  function shortUserPerPost() { return $this->getUserPerPost(0, true, true); }
890
  function shortCountries() { return $this->getCountries(0, true, false, true); }
891
  function shortCountriesUsers(){ return $this->getCountries(0, true, true, true); }
892
+ // function shortMostVisitedPosts(){ return $this->getMostVisitedPosts(0, 0, true, false, true); }
893
  function shortReferers() { return $this->getReferers(0, true, 0); }
894
  function shortDayWithMostReads(){ return $this->getDayWithMostReads(true, true); }
895
  function shortDayWithMostUsers(){ return $this->getDayWithMostUsers(true, true); }
896
+ function shortMostVisitedPosts( $atts )
897
+ {
898
+ extract( shortcode_atts( array(
899
+ 'days' => 0,
900
+ 'limit' => 0,
901
+ 'postsonly' => 0,
902
+ 'posttypes' => ''
903
+ ), $atts) );
904
+ return $this->getMostVisitedPosts( $days, $limit, true, $postsonly, false, $posttypes );
905
+ }
906
  function shortGetSearches( $atts )
907
  {
908
  extract( shortcode_atts( array(
1432
  {
1433
  if (empty($_SERVER['HTTP_REFERER']))
1434
  return false;
1435
+ $ref = parse_url(rawurldecode(wp_strip_all_tags($_SERVER['HTTP_REFERER'])));
1436
  if ( empty($ref['host']) || empty($ref['query']) )
1437
  return false;
1438
  $keys = array('p','q','s','query','search','prev','qkw','qry');
1440
  foreach ($keys as $key)
1441
  if (isset($query[$key]))
1442
  $search = str_ireplace(array('/search?q=','/images?q='), '', $query[$key]);
1443
+ if (isset($search))
1444
+ $search = wp_strip_all_tags($search);
1445
  if (empty($search) || is_numeric($search)) // non WordPress postID
1446
  $search = '';
1447
  return trim($search);
1448
  }
1449
 
1450
+ /**
1451
+ * add counter column to page/post lists
1452
+ */
1453
+ function cpdColumn($defaults)
1454
+ {
1455
+ if ( $this->options['show_in_lists'] )
1456
+ $defaults['cpd_reads'] = '<img src="'.$this->img('cpd_menu.gif').'" alt="'.__('Reads', 'cpd').'" title="'.__('Reads', 'cpd').'" style="width:12px;height:12px;" />';
1457
+ return $defaults;
1458
+ }
1459
+
1460
+ /**
1461
+ * adds content to the counter column
1462
+ */
1463
+ function cpdColumnContent($column_name, $id = 0)
1464
+ {
1465
+ global $wpdb;
1466
+ if( $column_name == 'cpd_reads' )
1467
+ {
1468
+ $c = $this->mysqlQuery('count', "SELECT 1 FROM $wpdb->cpd_counter WHERE page='$id'", 'cpdColumn_'.$id.'_'.__LINE__);
1469
+ $coll = get_option('count_per_day_posts');
1470
+ if ( $coll && isset($coll['p'.$id]) )
1471
+ $c += $coll['p'.$id];
1472
+ echo $c;
1473
+ }
1474
+ }
1475
 
1476
  } // class
counter.css CHANGED
@@ -85,26 +85,26 @@ h2 .cpd_icon {
85
  vertical-align: text-bottom;
86
  padding: 0 !important;
87
  }
88
- .cpd_backup{background-position: 0 0}
89
- .cpd_clean{background-position: 0 -46px}
90
- .cpd_collection{background-position: 0 -92px}
91
- .cpd_computer{background-position: 0 -138px}
92
- .cpd_calendar{background-position: 0 -184px}
93
- .cpd_day{background-position: 0 -230px}
94
- .cpd_geoip{background-position: 0 -276px}
95
- .cpd_help{background-position: 0 -322px}
96
- .cpd_massbots{background-position: 0 -368px}
97
- .cpd_online{background-position: 0 -414px}
98
- .cpd_post{background-position: 0 -460px}
99
- .cpd_reads{background-position: 0 -506px}
100
- .cpd_referrer{background-position: 0 -552px}
101
- .cpd_reset{background-position: 0 -598px}
102
- .cpd_settings{background-position: 0 -644px}
103
- .cpd_summary{background-position: 0 -690px}
104
- .cpd_tools{background-position: 0 -736px}
105
- .cpd_uninstall{background-position: 0 -782px}
106
- .cpd_update{background-position: 0 -828px}
107
- .cpd_user{background-position: 0 -874px}
108
 
109
  /* dashboard */
110
 
@@ -121,7 +121,9 @@ h2 .cpd_icon {
121
  }
122
 
123
  #cpd-flot {
 
124
  overflow: hidden;
 
125
  }
126
 
127
  #cpd-tooltip {
@@ -209,7 +211,7 @@ h2 .cpd_icon {
209
  .cpd_widget_item .widefat {
210
  width: 235px !important;
211
  margin-left: 15px;
212
-
213
  }
214
 
215
  /* thickbox */
@@ -268,7 +270,7 @@ h2 .cpd_icon {
268
  color: #ff0;
269
  }
270
 
271
- .cpd-notes input {
272
  width: 97%;
273
  font: 12px Verdana, Arial, Helvetica, sans-serif;
274
  }
@@ -433,3 +435,10 @@ h2 .cpd_icon {
433
  .cpd-flag-cm{background-position:0 -1586px;}
434
  .cpd-flag-mn{background-position:0 -1599px;}
435
  .cpd-flag-kz{background-position:0 -1612px;}
 
 
 
 
 
 
 
85
  vertical-align: text-bottom;
86
  padding: 0 !important;
87
  }
88
+ .cpd_backup{background-position: 0 0}
89
+ .cpd_clean{background-position: 0 -46px}
90
+ .cpd_collection{background-position: 0 -92px}
91
+ .cpd_computer{background-position: 0 -138px}
92
+ .cpd_calendar{background-position: 0 -184px}
93
+ .cpd_day{background-position: 0 -230px}
94
+ .cpd_geoip{background-position: 0 -276px}
95
+ .cpd_help{background-position: 0 -322px}
96
+ .cpd_massbots{background-position: 0 -368px}
97
+ .cpd_online{background-position: 0 -414px}
98
+ .cpd_post{background-position: 0 -460px}
99
+ .cpd_reads{background-position: 0 -506px}
100
+ .cpd_referrer{background-position: 0 -552px}
101
+ .cpd_reset{background-position: 0 -598px}
102
+ .cpd_settings{background-position: 0 -644px}
103
+ .cpd_summary{background-position: 0 -690px}
104
+ .cpd_tools{background-position: 0 -736px}
105
+ .cpd_uninstall{background-position: 0 -782px}
106
+ .cpd_update{background-position: 0 -828px}
107
+ .cpd_user{background-position: 0 -874px}
108
 
109
  /* dashboard */
110
 
121
  }
122
 
123
  #cpd-flot {
124
+ clear: both;
125
  overflow: hidden;
126
+ margin-top: 5px;
127
  }
128
 
129
  #cpd-tooltip {
211
  .cpd_widget_item .widefat {
212
  width: 235px !important;
213
  margin-left: 15px;
214
+
215
  }
216
 
217
  /* thickbox */
270
  color: #ff0;
271
  }
272
 
273
+ .cpd-notes input {
274
  width: 97%;
275
  font: 12px Verdana, Arial, Helvetica, sans-serif;
276
  }
435
  .cpd-flag-cm{background-position:0 -1586px;}
436
  .cpd-flag-mn{background-position:0 -1599px;}
437
  .cpd-flag-kz{background-position:0 -1612px;}
438
+ .cpd-flag-ng{background-position:0 -1625px;}
439
+ .cpd-flag-kh{background-position:0 -1638px;}
440
+ .cpd-flag-sd{background-position:0 -1651px;}
441
+
442
+
443
+
444
+
counter.php CHANGED
@@ -3,16 +3,19 @@
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.2.5
7
  License: Postcardware
8
  Author: Tom Braider
9
  Author URI: http://www.tomsdimension.de
10
  */
11
 
12
  $cpd_dir_name = 'count-per-day';
13
- $cpd_version = '3.2.5';
14
 
15
- $cpd_path = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH.PLUGINDIR.'/'.$cpd_dir_name.'/');
 
 
 
16
  include_once($cpd_path.'counter-core.php');
17
 
18
  /**
@@ -53,7 +56,7 @@ function show( $before='', $after=' reads', $show = true, $count = true, $page =
53
  // get count from collection
54
  $c = $this->getCollectedPostReads($page);
55
  // add current data
56
- $c += $this->mysqlQuery('var', $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->cpd_counter WHERE page='$page'", null), 'show '.__LINE__);
57
  if ($show)
58
  echo $before.$c.$after;
59
  else
@@ -103,8 +106,8 @@ function count( $x, $page = 'x' )
103
  .'page: <code>'.$page.'</code> '
104
  .'userlevel: <code>'.$userlevel.'</code>';
105
 
106
- // only count if: non bot, Logon is ok
107
- if ( !$isBot && $countUser && isset($page) )
108
  {
109
  if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
110
  {
@@ -116,8 +119,8 @@ function count( $x, $page = 'x' )
116
  $real_ip = $_SERVER['REMOTE_ADDR'];
117
 
118
  $userip = $this->anonymize_ip($real_ip);
119
- $client = ($this->options['referers']) ? $_SERVER['HTTP_USER_AGENT'] : '';
120
- $referer = ($this->options['referers'] && isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
121
  if ($this->options['referers_cut'])
122
  $referer = substr( $referer, 0, strpos($referer,'?') );
123
 
@@ -130,7 +133,7 @@ function count( $x, $page = 'x' )
130
  {
131
  // with GeoIP addon save country
132
  $gi = cpd_geoip_open($cpd_path.'geoip/GeoIP.dat', GEOIP_STANDARD);
133
- $country = strtolower(cpd_geoip_country_code_by_addr($gi, $userip));
134
  $this->mysqlQuery('', $wpdb->prepare("INSERT INTO $wpdb->cpd_counter (page, ip, client, date, country, referer)
135
  VALUES (%s, $this->aton(%s), %s, %s, %s, %s)", $page, $userip, $client, $date, $country, $referer), 'count insert '.__LINE__);
136
  }
@@ -665,7 +668,7 @@ function getUserPerDay( $days = 0, $return = false )
665
  * @param integer $limit count of posts (last posts)
666
  * @param boolean $postsonly don't show categories and taxonomies
667
  */
668
- function getMostVisitedPosts( $days = 0, $limit = 0, $frontend = false, $postsonly = false, $return = false )
669
  {
670
  global $wpdb;
671
  if ( $days == 0 )
@@ -674,6 +677,15 @@ function getMostVisitedPosts( $days = 0, $limit = 0, $frontend = false, $postson
674
  $limit = $this->options['dashboard_last_posts'];
675
  $date = date_i18n('Y-m-d', current_time('timestamp') - 86400 * $days);
676
 
 
 
 
 
 
 
 
 
 
677
  if ($postsonly)
678
  $sql = $wpdb->prepare("
679
  SELECT COUNT(c.id) count,
@@ -684,6 +696,7 @@ function getMostVisitedPosts( $days = 0, $limit = 0, $frontend = false, $postson
684
  ON p.id = c.page
685
  WHERE c.date >= %s
686
  AND c.page > 0
 
687
  GROUP BY c.page
688
  ORDER BY count DESC
689
  LIMIT %d",
@@ -790,6 +803,7 @@ function getVisitedPostsOnDay( $date = 0, $limit = 0, $show_form = true, $show_n
790
  $date = $_GET['daytoshow'];
791
  else if ( $date == 0 )
792
  $date = date_i18n('Y-m-d');
 
793
  if ( $limit == 0 )
794
  $limit = $this->options['dashboard_last_posts'];
795
 
@@ -1258,12 +1272,12 @@ class CountPerDay_Widget extends WP_Widget
1258
  echo '<span id="cpd_number_'.$k.'" class="cpd-r">';
1259
  // parameters only for special functions
1260
  if ( $f == 'getUserPerDay' )
1261
- eval('echo $count_per_day->getUserPerDay('.$count_per_day->options['dashboard_last_days'].');');
1262
  else if ( $f == 'show' )
1263
- eval('echo $count_per_day->show("","",false,false);');
1264
  else
1265
- eval('echo $count_per_day->'.$f.'();');
1266
- echo '</span>'.$instance[$k.'_name'].':</li>';
1267
  }
1268
  }
1269
  }
@@ -1318,7 +1332,8 @@ class CountPerDay_Widget extends WP_Widget
1318
  'getuseronline_name' => __('Visitors currently online', 'cpd'),
1319
  'getfirstcount_name' => __('Counter starts on', 'cpd')
1320
  );
1321
- $instance = wp_parse_args( (array) $instance, $default );
 
1322
 
1323
  // title field
1324
  $field_id = $this->get_field_id('title');
@@ -1362,7 +1377,6 @@ class CountPerDay_Widget extends WP_Widget
1362
  ?>
1363
  <script type="text/javascript">
1364
  //<![CDATA[
1365
- jQuery.noConflict();
1366
  jQuery(document).ready(function(){
1367
  jQuery('#cpdwidgetlist<?php echo $field_id ?>').sortable({
1368
  items: 'li:not(.cpd_widget_title)',
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.2.6
7
  License: Postcardware
8
  Author: Tom Braider
9
  Author URI: http://www.tomsdimension.de
10
  */
11
 
12
  $cpd_dir_name = 'count-per-day';
13
+ $cpd_version = '3.2.6';
14
 
15
+ if (strpos($_SERVER['SERVER_NAME'], '.test'))
16
+ $cpd_path = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH.PLUGINDIR.'/'.$cpd_dir_name.'/');
17
+ else
18
+ $cpd_path = dirname(__FILE__).'/';
19
  include_once($cpd_path.'counter-core.php');
20
 
21
  /**
56
  // get count from collection
57
  $c = $this->getCollectedPostReads($page);
58
  // add current data
59
+ $c += $this->mysqlQuery('var', $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->cpd_counter WHERE page = %d", $page), 'show '.__LINE__);
60
  if ($show)
61
  echo $before.$c.$after;
62
  else
106
  .'page: <code>'.$page.'</code> '
107
  .'userlevel: <code>'.$userlevel.'</code>';
108
 
109
+ // only count if: non bot, Logon is ok, no password required or ok
110
+ if ( !$isBot && $countUser && isset($page) && !post_password_required($page) )
111
  {
112
  if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
113
  {
119
  $real_ip = $_SERVER['REMOTE_ADDR'];
120
 
121
  $userip = $this->anonymize_ip($real_ip);
122
+ $client = ($this->options['referers']) ? wp_strip_all_tags($_SERVER['HTTP_USER_AGENT']) : '';
123
+ $referer = ($this->options['referers'] && isset($_SERVER['HTTP_REFERER'])) ? wp_strip_all_tags($_SERVER['HTTP_REFERER']) : '';
124
  if ($this->options['referers_cut'])
125
  $referer = substr( $referer, 0, strpos($referer,'?') );
126
 
133
  {
134
  // with GeoIP addon save country
135
  $gi = cpd_geoip_open($cpd_path.'geoip/GeoIP.dat', GEOIP_STANDARD);
136
+ $country = strtolower(cpd_geoip_country_code_by_addr_v6($gi, $userip));
137
  $this->mysqlQuery('', $wpdb->prepare("INSERT INTO $wpdb->cpd_counter (page, ip, client, date, country, referer)
138
  VALUES (%s, $this->aton(%s), %s, %s, %s, %s)", $page, $userip, $client, $date, $country, $referer), 'count insert '.__LINE__);
139
  }
668
  * @param integer $limit count of posts (last posts)
669
  * @param boolean $postsonly don't show categories and taxonomies
670
  */
671
+ function getMostVisitedPosts( $days = 0, $limit = 0, $frontend = false, $postsonly = false, $return = false, $posttypes = '' )
672
  {
673
  global $wpdb;
674
  if ( $days == 0 )
677
  $limit = $this->options['dashboard_last_posts'];
678
  $date = date_i18n('Y-m-d', current_time('timestamp') - 86400 * $days);
679
 
680
+ if ($posttypes)
681
+ {
682
+ $types = str_replace(' ', '', $posttypes);
683
+ $types = str_replace(',', "','", $types);
684
+ $postsonly = 1;
685
+ }
686
+ else
687
+ $types = false;
688
+
689
  if ($postsonly)
690
  $sql = $wpdb->prepare("
691
  SELECT COUNT(c.id) count,
696
  ON p.id = c.page
697
  WHERE c.date >= %s
698
  AND c.page > 0
699
+ ".( ($types) ? "AND p.post_type IN ('$types')" : '' )."
700
  GROUP BY c.page
701
  ORDER BY count DESC
702
  LIMIT %d",
803
  $date = $_GET['daytoshow'];
804
  else if ( $date == 0 )
805
  $date = date_i18n('Y-m-d');
806
+ $date = wp_strip_all_tags($date);
807
  if ( $limit == 0 )
808
  $limit = $this->options['dashboard_last_posts'];
809
 
1272
  echo '<span id="cpd_number_'.$k.'" class="cpd-r">';
1273
  // parameters only for special functions
1274
  if ( $f == 'getUserPerDay' )
1275
+ echo $count_per_day->getUserPerDay($count_per_day->options['dashboard_last_days']);
1276
  else if ( $f == 'show' )
1277
+ echo $count_per_day->show('', '', false, false);
1278
  else
1279
+ echo call_user_func( array(&$count_per_day, $f) );
1280
+ echo '</span>'.__($instance[$k.'_name']).':</li>';
1281
  }
1282
  }
1283
  }
1332
  'getuseronline_name' => __('Visitors currently online', 'cpd'),
1333
  'getfirstcount_name' => __('Counter starts on', 'cpd')
1334
  );
1335
+ if (empty($instance['order']))
1336
+ $instance = array_merge( (array) $instance, $default );
1337
 
1338
  // title field
1339
  $field_id = $this->get_field_id('title');
1377
  ?>
1378
  <script type="text/javascript">
1379
  //<![CDATA[
 
1380
  jQuery(document).ready(function(){
1381
  jQuery('#cpdwidgetlist<?php echo $field_id ?>').sortable({
1382
  items: 'li:not(.cpd_widget_title)',
geoip/GeoIP.dat CHANGED
Binary file
geoip/cpd_geoip.inc DELETED
@@ -1,713 +0,0 @@
1
- <?php
2
-
3
- /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
4
- /* geoip.inc
5
- *
6
- * Copyright (C) 2007 MaxMind LLC
7
- *
8
- * This library is free software; you can redistribute it and/or
9
- * modify it under the terms of the GNU Lesser General Public
10
- * License as published by the Free Software Foundation; either
11
- * version 2.1 of the License, or (at your option) any later version.
12
- *
13
- * This library is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
- * Lesser General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU Lesser General Public
19
- * License along with this library; if not, write to the Free Software
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
- */
22
-
23
- define("GEOIP_COUNTRY_BEGIN", 16776960);
24
- define("GEOIP_STATE_BEGIN_REV0", 16700000);
25
- define("GEOIP_STATE_BEGIN_REV1", 16000000);
26
- define("GEOIP_STANDARD", 0);
27
- define("GEOIP_MEMORY_CACHE", 1);
28
- define("GEOIP_SHARED_MEMORY", 2);
29
- define("STRUCTURE_INFO_MAX_SIZE", 20);
30
- define("DATABASE_INFO_MAX_SIZE", 100);
31
- define("GEOIP_COUNTRY_EDITION", 106);
32
- define("GEOIP_PROXY_EDITION", 8);
33
- define("GEOIP_ASNUM_EDITION", 9);
34
- define("GEOIP_NETSPEED_EDITION", 10);
35
- define("GEOIP_REGION_EDITION_REV0", 112);
36
- define("GEOIP_REGION_EDITION_REV1", 3);
37
- define("GEOIP_CITY_EDITION_REV0", 111);
38
- define("GEOIP_CITY_EDITION_REV1", 2);
39
- define("GEOIP_ORG_EDITION", 110);
40
- define("GEOIP_ISP_EDITION", 4);
41
- define("SEGMENT_RECORD_LENGTH", 3);
42
- define("STANDARD_RECORD_LENGTH", 3);
43
- define("ORG_RECORD_LENGTH", 4);
44
- define("MAX_RECORD_LENGTH", 4);
45
- define("MAX_ORG_RECORD_LENGTH", 300);
46
- define("GEOIP_SHM_KEY", 0x4f415401);
47
- define("US_OFFSET", 1);
48
- define("CANADA_OFFSET", 677);
49
- define("WORLD_OFFSET", 1353);
50
- define("FIPS_RANGE", 360);
51
- define("GEOIP_UNKNOWN_SPEED", 0);
52
- define("GEOIP_DIALUP_SPEED", 1);
53
- define("GEOIP_CABLEDSL_SPEED", 2);
54
- define("GEOIP_CORPORATE_SPEED", 3);
55
- define("GEOIP_DOMAIN_EDITION", 11);
56
- define("GEOIP_COUNTRY_EDITION_V6", 12);
57
- define("GEOIP_LOCATIONA_EDITION", 13);
58
- define("GEOIP_ACCURACYRADIUS_EDITION", 14);
59
- define("GEOIP_CITYCOMBINED_EDITION", 15);
60
- define("GEOIP_CITY_EDITION_REV1_V6", 30);
61
- define("GEOIP_CITY_EDITION_REV0_V6",31);
62
- define("GEOIP_NETSPEED_EDITION_REV1",32);
63
- define("GEOIP_NETSPEED_EDITION_REV1_V6",33);
64
- define("GEOIP_USERTYPE_EDITION",28);
65
- define("GEOIP_USERTYPE_EDITION_V6",29);
66
- define("GEOIP_ASNUM_EDITION_V6",21);
67
- define("GEOIP_ISP_EDITION_V6",22);
68
- define("GEOIP_ORG_EDITION_V6",23);
69
- define("GEOIP_DOMAIN_EDITION_V6",24);
70
-
71
- define("CITYCOMBINED_FIXED_RECORD", 7 );
72
-
73
- class GeoIPCpD {
74
- var $flags;
75
- var $filehandle;
76
- var $memory_buffer;
77
- var $databaseType;
78
- var $databaseSegments;
79
- var $record_length;
80
- var $shmid;
81
- var $GEOIP_COUNTRY_CODE_TO_NUMBER = array(
82
- "" => 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5,
83
- "AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "CW" => 10, "AO" => 11,
84
- "AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17,
85
- "AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23,
86
- "BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29,
87
- "BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35,
88
- "BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41,
89
- "CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47,
90
- "CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53,
91
- "CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59,
92
- "DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65,
93
- "ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71,
94
- "FM" => 72, "FO" => 73, "FR" => 74, "SX" => 75, "GA" => 76, "GB" => 77,
95
- "GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83,
96
- "GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89,
97
- "GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95,
98
- "HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101,
99
- "IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107,
100
- "IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113,
101
- "KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119,
102
- "KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125,
103
- "LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131,
104
- "LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137,
105
- "MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143,
106
- "MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149,
107
- "MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155,
108
- "NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161,
109
- "NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167,
110
- "PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173,
111
- "PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179,
112
- "PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185,
113
- "RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191,
114
- "SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197,
115
- "SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203,
116
- "SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209,
117
- "TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215,
118
- "TL" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221,
119
- "UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227,
120
- "VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233,
121
- "VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
122
- "ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
123
- "O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
124
- "MF" => 252, "BQ" => 253,
125
- );
126
- var $GEOIP_COUNTRY_CODES = array(
127
- "","AP","EU","AD","AE","AF","AG","AI","AL","AM","CW",
128
- "AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB",
129
- "BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO",
130
- "BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD",
131
- "CF","CG","CH","CI","CK","CL","CM","CN","CO","CR",
132
- "CU","CV","CX","CY","CZ","DE","DJ","DK","DM","DO",
133
- "DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ",
134
- "FK","FM","FO","FR","SX","GA","GB","GD","GE","GF",
135
- "GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT",
136
- "GU","GW","GY","HK","HM","HN","HR","HT","HU","ID",
137
- "IE","IL","IN","IO","IQ","IR","IS","IT","JM","JO",
138
- "JP","KE","KG","KH","KI","KM","KN","KP","KR","KW",
139
- "KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT",
140
- "LU","LV","LY","MA","MC","MD","MG","MH","MK","ML",
141
- "MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV",
142
- "MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI",
143
- "NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF",
144
- "PG","PH","PK","PL","PM","PN","PR","PS","PT","PW",
145
- "PY","QA","RE","RO","RU","RW","SA","SB","SC","SD",
146
- "SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO",
147
- "SR","ST","SV","SY","SZ","TC","TD","TF","TG","TH",
148
- "TJ","TK","TM","TN","TO","TL","TR","TT","TV","TW",
149
- "TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE",
150
- "VG","VI","VN","VU","WF","WS","YE","YT","RS","ZA",
151
- "ZM","ME","ZW","A1","A2","O1","AX","GG","IM","JE",
152
- "BL","MF", "BQ");
153
- var $GEOIP_COUNTRY_CODES3 = array(
154
- "","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","CUW",
155
- "AGO","ATA","ARG","ASM","AUT","AUS","ABW","AZE","BIH","BRB",
156
- "BGD","BEL","BFA","BGR","BHR","BDI","BEN","BMU","BRN","BOL",
157
- "BRA","BHS","BTN","BVT","BWA","BLR","BLZ","CAN","CCK","COD",
158
- "CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI",
159
- "CUB","CPV","CXR","CYP","CZE","DEU","DJI","DNK","DMA","DOM",
160
- "DZA","ECU","EST","EGY","ESH","ERI","ESP","ETH","FIN","FJI",
161
- "FLK","FSM","FRO","FRA","SXM","GAB","GBR","GRD","GEO","GUF",
162
- "GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","SGS","GTM",
163
- "GUM","GNB","GUY","HKG","HMD","HND","HRV","HTI","HUN","IDN",
164
- "IRL","ISR","IND","IOT","IRQ","IRN","ISL","ITA","JAM","JOR",
165
- "JPN","KEN","KGZ","KHM","KIR","COM","KNA","PRK","KOR","KWT",
166
- "CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
167
- "LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI",
168
- "MMR","MNG","MAC","MNP","MTQ","MRT","MSR","MLT","MUS","MDV",
169
- "MWI","MEX","MYS","MOZ","NAM","NCL","NER","NFK","NGA","NIC",
170
- "NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER","PYF",
171
- "PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW",
172
- "PRY","QAT","REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN",
173
- "SWE","SGP","SHN","SVN","SJM","SVK","SLE","SMR","SEN","SOM",
174
- "SUR","STP","SLV","SYR","SWZ","TCA","TCD","ATF","TGO","THA",
175
- "TJK","TKL","TKM","TUN","TON","TLS","TUR","TTO","TUV","TWN",
176
- "TZA","UKR","UGA","UMI","USA","URY","UZB","VAT","VCT","VEN",
177
- "VGB","VIR","VNM","VUT","WLF","WSM","YEM","MYT","SRB","ZAF",
178
- "ZMB","MNE","ZWE","A1","A2","O1","ALA","GGY","IMN","JEY",
179
- "BLM","MAF", "BES"
180
- );
181
- var $GEOIP_COUNTRY_NAMES = array(
182
- "","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Curacao",
183
- "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados",
184
- "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia",
185
- "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the",
186
- "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica",
187
- "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic",
188
- "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji",
189
- "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","Sint Maarten (Dutch part)","Gabon","United Kingdom","Grenada","Georgia","French Guiana",
190
- "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala",
191
- "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia",
192
- "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan",
193
- "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait",
194
- "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania",
195
- "Luxembourg","Latvia","Libya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali",
196
- "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives",
197
- "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua",
198
- "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia",
199
- "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau",
200
- "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan",
201
- "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname",
202
- "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand",
203
- "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan",
204
- "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela",
205
- "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa",
206
- "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey",
207
- "Saint Barthelemy","Saint Martin", "Bonaire, Saint Eustatius and Saba"
208
- );
209
-
210
- var $GEOIP_CONTINENT_CODES = array(
211
- "--", "AS","EU","EU","AS","AS","NA","NA","EU","AS","NA",
212
- "AF","AN","SA","OC","EU","OC","NA","AS","EU","NA",
213
- "AS","EU","AF","EU","AS","AF","AF","NA","AS","SA",
214
- "SA","NA","AS","AN","AF","EU","NA","NA","AS","AF",
215
- "AF","AF","EU","AF","OC","SA","AF","AS","SA","NA",
216
- "NA","AF","AS","AS","EU","EU","AF","EU","NA","NA",
217
- "AF","SA","EU","AF","AF","AF","EU","AF","EU","OC",
218
- "SA","OC","EU","EU","NA","AF","EU","NA","AS","SA",
219
- "AF","EU","NA","AF","AF","NA","AF","EU","AN","NA",
220
- "OC","AF","SA","AS","AN","NA","EU","NA","EU","AS",
221
- "EU","AS","AS","AS","AS","AS","EU","EU","NA","AS",
222
- "AS","AF","AS","AS","OC","AF","NA","AS","AS","AS",
223
- "NA","AS","AS","AS","NA","EU","AS","AF","AF","EU",
224
- "EU","EU","AF","AF","EU","EU","AF","OC","EU","AF",
225
- "AS","AS","AS","OC","NA","AF","NA","EU","AF","AS",
226
- "AF","NA","AS","AF","AF","OC","AF","OC","AF","NA",
227
- "EU","EU","AS","OC","OC","OC","AS","NA","SA","OC",
228
- "OC","AS","AS","EU","NA","OC","NA","AS","EU","OC",
229
- "SA","AS","AF","EU","EU","AF","AS","OC","AF","AF",
230
- "EU","AS","AF","EU","EU","EU","AF","EU","AF","AF",
231
- "SA","AF","NA","AS","AF","NA","AF","AN","AF","AS",
232
- "AS","OC","AS","AF","OC","AS","EU","NA","OC","AS",
233
- "AF","EU","AF","OC","NA","SA","AS","EU","NA","SA",
234
- "NA","NA","AS","OC","OC","OC","AS","AF","EU","AF",
235
- "AF","EU","AF","--","--","--","EU","EU","EU","EU",
236
- "NA","NA","NA"
237
- );
238
-
239
- }
240
- function cpd_geoip_load_shared_mem ($file) {
241
-
242
- $fp = fopen($file, "rb");
243
- if (!$fp) {
244
- print "error opening $file: $php_errormsg\n";
245
- exit;
246
- }
247
- $s_array = fstat($fp);
248
- $size = $s_array['size'];
249
- if ($shmid = @shmop_open (GEOIP_SHM_KEY, "w", 0, 0)) {
250
- shmop_delete ($shmid);
251
- shmop_close ($shmid);
252
- }
253
- $shmid = shmop_open (GEOIP_SHM_KEY, "c", 0644, $size);
254
- shmop_write ($shmid, fread($fp, $size), 0);
255
- shmop_close ($shmid);
256
- }
257
-
258
- function cpd_setup_segments($gi){
259
- $gi->databaseType = GEOIP_COUNTRY_EDITION;
260
- $gi->record_length = STANDARD_RECORD_LENGTH;
261
- if ($gi->flags & GEOIP_SHARED_MEMORY) {
262
- $offset = @shmop_size ($gi->shmid) - 3;
263
- for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
264
- $delim = @shmop_read ($gi->shmid, $offset, 3);
265
- $offset += 3;
266
- if ($delim == (chr(255).chr(255).chr(255))) {
267
- $gi->databaseType = ord(@shmop_read ($gi->shmid, $offset, 1));
268
- $offset++;
269
-
270
- if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
271
- $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
272
- } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
273
- $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
274
- } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
275
- ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
276
- || ($gi->databaseType == GEOIP_ORG_EDITION)
277
- || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
278
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
279
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
280
- || ($gi->databaseType == GEOIP_ISP_EDITION)
281
- || ($gi->databaseType == GEOIP_ISP_EDITION_V6)
282
- || ($gi->databaseType == GEOIP_USERTYPE_EDITION)
283
- || ($gi->databaseType == GEOIP_USERTYPE_EDITION_V6)
284
- || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
285
- || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
286
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
287
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
288
- || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1)
289
- || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6)
290
- || ($gi->databaseType == GEOIP_ASNUM_EDITION)
291
- || ($gi->databaseType == GEOIP_ASNUM_EDITION_V6)){
292
- $gi->databaseSegments = 0;
293
- $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
294
- for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
295
- $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
296
- }
297
- if (($gi->databaseType == GEOIP_ORG_EDITION)
298
- || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
299
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
300
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
301
- || ($gi->databaseType == GEOIP_ISP_EDITION)
302
- || ($gi->databaseType == GEOIP_ISP_EDITION_V6)) {
303
- $gi->record_length = ORG_RECORD_LENGTH;
304
- }
305
- }
306
- break;
307
- } else {
308
- $offset -= 4;
309
- }
310
- }
311
- if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
312
- ($gi->databaseType == GEOIP_COUNTRY_EDITION_V6)||
313
- ($gi->databaseType == GEOIP_PROXY_EDITION)||
314
- ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
315
- $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
316
- }
317
- } else {
318
- $filepos = ftell($gi->filehandle);
319
- fseek($gi->filehandle, -3, SEEK_END);
320
- for ($i = 0; $i < STRUCTURE_INFO_MAX_SIZE; $i++) {
321
- $delim = fread($gi->filehandle,3);
322
- if ($delim == (chr(255).chr(255).chr(255))){
323
- $gi->databaseType = ord(fread($gi->filehandle,1));
324
- if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
325
- $gi->databaseSegments = GEOIP_STATE_BEGIN_REV0;
326
- }
327
- else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
328
- $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
329
- } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)
330
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
331
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
332
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
333
- || ($gi->databaseType == GEOIP_ORG_EDITION)
334
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
335
- || ($gi->databaseType == GEOIP_ISP_EDITION)
336
- || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
337
- || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
338
- || ($gi->databaseType == GEOIP_ISP_EDITION_V6)
339
- || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
340
- || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
341
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
342
- || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
343
- || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1)
344
- || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6)
345
- || ($gi->databaseType == GEOIP_USERTYPE_EDITION)
346
- || ($gi->databaseType == GEOIP_USERTYPE_EDITION_V6)
347
- || ($gi->databaseType == GEOIP_ASNUM_EDITION)
348
- || ($gi->databaseType == GEOIP_ASNUM_EDITION_V6)){
349
- $gi->databaseSegments = 0;
350
- $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
351
- for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
352
- $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
353
- }
354
- if ( ( $gi->databaseType == GEOIP_ORG_EDITION )
355
- || ( $gi->databaseType == GEOIP_DOMAIN_EDITION )
356
- || ( $gi->databaseType == GEOIP_ISP_EDITION )
357
- || ( $gi->databaseType == GEOIP_ORG_EDITION_V6 )
358
- || ( $gi->databaseType == GEOIP_DOMAIN_EDITION_V6 )
359
- || ( $gi->databaseType == GEOIP_ISP_EDITION_V6 )) {
360
- $gi->record_length = ORG_RECORD_LENGTH;
361
- }
362
- }
363
- break;
364
- } else {
365
- fseek($gi->filehandle, -4, SEEK_CUR);
366
- }
367
- }
368
- if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
369
- ($gi->databaseType == GEOIP_COUNTRY_EDITION_V6)||
370
- ($gi->databaseType == GEOIP_PROXY_EDITION)||
371
- ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
372
- $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
373
- }
374
- fseek($gi->filehandle,$filepos,SEEK_SET);
375
- }
376
- return $gi;
377
- }
378
-
379
- function cpd_geoip_open($filename, $flags) {
380
- $gi = new GeoIPCpD;
381
- $gi->flags = $flags;
382
- if ($gi->flags & GEOIP_SHARED_MEMORY) {
383
- $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
384
- } else {
385
- $gi->filehandle = fopen($filename,"rb") or die( "Can not open $filename\n" );
386
- if ($gi->flags & GEOIP_MEMORY_CACHE) {
387
- $s_array = fstat($gi->filehandle);
388
- $gi->memory_buffer = fread($gi->filehandle, $s_array['size']);
389
- }
390
- }
391
-
392
- $gi = cpd_setup_segments($gi);
393
- return $gi;
394
- }
395
-
396
- function cpd_geoip_close($gi) {
397
- if ($gi->flags & GEOIP_SHARED_MEMORY) {
398
- return true;
399
- }
400
-
401
- return fclose($gi->filehandle);
402
- }
403
-
404
- function cpd_geoip_country_id_by_name_v6($gi, $name) {
405
- $rec = dns_get_record($name, DNS_AAAA);
406
- if ( !$rec ) {
407
- return false;
408
- }
409
- $addr = $rec[0]["ipv6"];
410
- if (!$addr || $addr == $name) {
411
- return false;
412
- }
413
- return cpd_geoip_country_id_by_addr_v6($gi, $addr);
414
- }
415
-
416
- function cpd_geoip_country_id_by_name($gi, $name) {
417
- $addr = gethostbyname($name);
418
- if (!$addr || $addr == $name) {
419
- return false;
420
- }
421
- return cpd_geoip_country_id_by_addr($gi, $addr);
422
- }
423
-
424
- function cpd_geoip_country_code_by_name_v6($gi, $name) {
425
- $country_id = cpd_geoip_country_id_by_name_v6($gi,$name);
426
- if ($country_id !== false) {
427
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
428
- }
429
- return false;
430
- }
431
-
432
- function cpd_geoip_country_code_by_name($gi, $name) {
433
- $country_id = cpd_geoip_country_id_by_name($gi,$name);
434
- if ($country_id !== false) {
435
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
436
- }
437
- return false;
438
- }
439
-
440
- function cpd_geoip_country_name_by_name_v6($gi, $name) {
441
- $country_id = cpd_geoip_country_id_by_name_v6($gi,$name);
442
- if ($country_id !== false) {
443
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
444
- }
445
- return false;
446
- }
447
-
448
- function cpd_geoip_country_name_by_name($gi, $name) {
449
- $country_id = cpd_geoip_country_id_by_name($gi,$name);
450
- if ($country_id !== false) {
451
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
452
- }
453
- return false;
454
- }
455
-
456
- function cpd_geoip_country_id_by_addr_v6($gi, $addr) {
457
- $ipnum = inet_pton($addr);
458
- return cpd_geoip_seek_country_v6($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
459
- }
460
-
461
- function cpd_geoip_country_id_by_addr($gi, $addr) {
462
- $ipnum = ip2long($addr);
463
- return cpd_geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
464
- }
465
-
466
- function cpd_geoip_country_code_by_addr_v6($gi, $addr) {
467
- $country_id = cpd_geoip_country_id_by_addr_v6($gi,$addr);
468
- if ($country_id !== false) {
469
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
470
- }
471
- return false;
472
- }
473
-
474
- function cpd_geoip_country_code_by_addr($gi, $addr) {
475
- if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
476
- $record = cpd_geoip_record_by_addr($gi,$addr);
477
- if ( $record !== false ) {
478
- return $record->country_code;
479
- }
480
- } else {
481
- $country_id = cpd_geoip_country_id_by_addr($gi,$addr);
482
- if ($country_id !== false) {
483
- return $gi->GEOIP_COUNTRY_CODES[$country_id];
484
- }
485
- }
486
- return false;
487
- }
488
-
489
- function cpd_geoip_country_name_by_addr_v6($gi, $addr) {
490
- $country_id = cpd_geoip_country_id_by_addr_v6($gi,$addr);
491
- if ($country_id !== false) {
492
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
493
- }
494
- return false;
495
- }
496
-
497
- function cpd_geoip_country_name_by_addr($gi, $addr) {
498
- if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
499
- $record = cpd_geoip_record_by_addr($gi,$addr);
500
- return $record->country_name;
501
- } else {
502
- $country_id = cpd_geoip_country_id_by_addr($gi,$addr);
503
- if ($country_id !== false) {
504
- return $gi->GEOIP_COUNTRY_NAMES[$country_id];
505
- }
506
- }
507
- return false;
508
- }
509
-
510
- function cpd_geoip_seek_country_v6($gi, $ipnum) {
511
-
512
- # arrays from unpack start with offset 1
513
- # yet another php mystery. array_merge work around
514
- # this broken behaviour
515
- $v6vec = array_merge(unpack( "C16", $ipnum));
516
-
517
- $offset = 0;
518
- for ($depth = 127; $depth >= 0; --$depth) {
519
- if ($gi->flags & GEOIP_MEMORY_CACHE) {
520
- // workaround php's broken substr, strpos, etc handling with
521
- // mbstring.func_overload and mbstring.internal_encoding
522
- $enc = mb_internal_encoding();
523
- mb_internal_encoding('ISO-8859-1');
524
-
525
- $buf = substr($gi->memory_buffer,
526
- 2 * $gi->record_length * $offset,
527
- 2 * $gi->record_length);
528
-
529
- mb_internal_encoding($enc);
530
- } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
531
- $buf = @shmop_read ($gi->shmid,
532
- 2 * $gi->record_length * $offset,
533
- 2 * $gi->record_length );
534
- } else {
535
- fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
536
- or die("fseek failed");
537
- $buf = fread($gi->filehandle, 2 * $gi->record_length);
538
- }
539
- $x = array(0,0);
540
- for ($i = 0; $i < 2; ++$i) {
541
- for ($j = 0; $j < $gi->record_length; ++$j) {
542
- $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
543
- }
544
- }
545
-
546
- $bnum = 127 - $depth;
547
- $idx = $bnum >> 3;
548
- $b_mask = 1 << ( $bnum & 7 ^ 7 );
549
- if (($v6vec[$idx] & $b_mask) > 0) {
550
- if ($x[1] >= $gi->databaseSegments) {
551
- return $x[1];
552
- }
553
- $offset = $x[1];
554
- } else {
555
- if ($x[0] >= $gi->databaseSegments) {
556
- return $x[0];
557
- }
558
- $offset = $x[0];
559
- }
560
- }
561
- trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
562
- return false;
563
- }
564
-
565
- function cpd_geoip_seek_country($gi, $ipnum) {
566
- $offset = 0;
567
- for ($depth = 31; $depth >= 0; --$depth) {
568
- if ($gi->flags & GEOIP_MEMORY_CACHE) {
569
- // workaround php's broken substr, strpos, etc handling with
570
- // mbstring.func_overload and mbstring.internal_encoding
571
- $enc = mb_internal_encoding();
572
- mb_internal_encoding('ISO-8859-1');
573
-
574
- $buf = substr($gi->memory_buffer,
575
- 2 * $gi->record_length * $offset,
576
- 2 * $gi->record_length);
577
-
578
- mb_internal_encoding($enc);
579
- } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
580
- $buf = @shmop_read ($gi->shmid,
581
- 2 * $gi->record_length * $offset,
582
- 2 * $gi->record_length );
583
- } else {
584
- fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
585
- or die("fseek failed");
586
- $buf = fread($gi->filehandle, 2 * $gi->record_length);
587
- }
588
- $x = array(0,0);
589
- for ($i = 0; $i < 2; ++$i) {
590
- for ($j = 0; $j < $gi->record_length; ++$j) {
591
- $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
592
- }
593
- }
594
- if ($ipnum & (1 << $depth)) {
595
- if ($x[1] >= $gi->databaseSegments) {
596
- return $x[1];
597
- }
598
- $offset = $x[1];
599
- } else {
600
- if ($x[0] >= $gi->databaseSegments) {
601
- return $x[0];
602
- }
603
- $offset = $x[0];
604
- }
605
- }
606
- trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
607
- return false;
608
- }
609
-
610
- function cpd_common_get_org($gi, $seek_org){
611
- $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
612
- if ($gi->flags & GEOIP_SHARED_MEMORY) {
613
- $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
614
- } else {
615
- fseek($gi->filehandle, $record_pointer, SEEK_SET);
616
- $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
617
- }
618
- // workaround php's broken substr, strpos, etc handling with
619
- // mbstring.func_overload and mbstring.internal_encoding
620
- $enc = mb_internal_encoding();
621
- mb_internal_encoding('ISO-8859-1');
622
- $org_buf = substr($org_buf, 0, strpos($org_buf, "\0"));
623
- mb_internal_encoding($enc);
624
- return $org_buf;
625
- }
626
-
627
- function cpd_get_org_v6($gi,$ipnum){
628
- $seek_org = cpd_geoip_seek_country_v6($gi,$ipnum);
629
- if ($seek_org == $gi->databaseSegments) {
630
- return NULL;
631
- }
632
- return cpd_common_get_org($gi, $seek_org);
633
- }
634
-
635
- function cpd_get_org($gi,$ipnum){
636
- $seek_org = cpd_geoip_seek_country($gi,$ipnum);
637
- if ($seek_org == $gi->databaseSegments) {
638
- return NULL;
639
- }
640
- return cpd_common_get_org($gi, $seek_org);
641
- }
642
-
643
-
644
-
645
- function cpd_geoip_name_by_addr_v6 ($gi,$addr) {
646
- if ($addr == NULL) {
647
- return 0;
648
- }
649
- $ipnum = inet_pton($addr);
650
- return cpd_get_org_v6($gi, $ipnum);
651
- }
652
-
653
- function cpd_geoip_name_by_addr ($gi,$addr) {
654
- if ($addr == NULL) {
655
- return 0;
656
- }
657
- $ipnum = ip2long($addr);
658
- return cpd_get_org($gi, $ipnum);
659
- }
660
-
661
- function cpd_geoip_org_by_addr ($gi,$addr) {
662
- return cpd_geoip_name_by_addr($gi, $addr);
663
- }
664
-
665
- function cpd_get_region($gi,$ipnum){
666
- if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
667
- $seek_region = cpd_geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
668
- if ($seek_region >= 1000){
669
- $country_code = "US";
670
- $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
671
- } else {
672
- $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
673
- $region = "";
674
- }
675
- return array ($country_code,$region);
676
- } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
677
- $seek_region = cpd_geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
678
- //print $seek_region;
679
- if ($seek_region < US_OFFSET){
680
- $country_code = "";
681
- $region = "";
682
- } else if ($seek_region < CANADA_OFFSET) {
683
- $country_code = "US";
684
- $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
685
- } else if ($seek_region < WORLD_OFFSET) {
686
- $country_code = "CA";
687
- $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
688
- } else {
689
- $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
690
- $region = "";
691
- }
692
- return array ($country_code,$region);
693
- }
694
- }
695
-
696
- function cpd_geoip_region_by_addr ($gi,$addr) {
697
- if ($addr == NULL) {
698
- return 0;
699
- }
700
- $ipnum = ip2long($addr);
701
- return cpd_get_region($gi, $ipnum);
702
- }
703
-
704
- function cpd_getdnsattributes ($l,$ip){
705
- $r = new Net_DNS_Resolver();
706
- $r->nameservers = array("ws1.maxmind.com");
707
- $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
708
- $str = is_object($p->answer[0])?$p->answer[0]->string():'';
709
- $str = substr( $str, 1, -1 );
710
- return $str;
711
- }
712
-
713
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
geoip/geoip.inc CHANGED
@@ -52,6 +52,23 @@ define("GEOIP_UNKNOWN_SPEED", 0);
52
  define("GEOIP_DIALUP_SPEED", 1);
53
  define("GEOIP_CABLEDSL_SPEED", 2);
54
  define("GEOIP_CORPORATE_SPEED", 3);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  class GeoIPCpd {
57
  var $flags;
@@ -62,147 +79,163 @@ class GeoIPCpd {
62
  var $record_length;
63
  var $shmid;
64
  var $GEOIP_COUNTRY_CODE_TO_NUMBER = array(
65
- "" => 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5,
66
- "AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "AN" => 10, "AO" => 11,
67
- "AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17,
68
- "AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23,
69
- "BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29,
70
- "BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35,
71
- "BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41,
72
- "CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47,
73
- "CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53,
74
- "CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59,
75
- "DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65,
76
- "ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71,
77
- "FM" => 72, "FO" => 73, "FR" => 74, "FX" => 75, "GA" => 76, "GB" => 77,
78
- "GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83,
79
- "GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89,
80
- "GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95,
81
- "HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101,
82
- "IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107,
83
- "IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113,
84
- "KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119,
85
- "KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125,
86
- "LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131,
87
- "LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137,
88
- "MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143,
89
- "MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149,
90
  "MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155,
91
- "NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161,
92
- "NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167,
93
- "PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173,
94
- "PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179,
95
- "PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185,
96
- "RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191,
97
- "SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197,
98
- "SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203,
99
- "SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209,
100
- "TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215,
101
- "TL" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221,
102
- "UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227,
103
  "VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233,
104
- "VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
105
- "ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
106
  "O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
107
- "MF" => 252
108
  );
109
  var $GEOIP_COUNTRY_CODES = array(
110
- "", "AP", "EU", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ",
111
- "AR", "AS", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH",
112
- "BI", "BJ", "BM", "BN", "BO", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA",
113
- "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU",
114
- "CV", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG",
115
- "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "FX", "GA", "GB",
116
- "GD", "GE", "GF", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT",
117
- "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IN",
118
- "IO", "IQ", "IR", "IS", "IT", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM",
119
- "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS",
120
- "LT", "LU", "LV", "LY", "MA", "MC", "MD", "MG", "MH", "MK", "ML", "MM", "MN",
121
- "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA",
122
- "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA",
123
- "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY",
124
- "QA", "RE", "RO", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI",
125
- "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "ST", "SV", "SY", "SZ", "TC", "TD",
126
- "TF", "TG", "TH", "TJ", "TK", "TM", "TN", "TO", "TL", "TR", "TT", "TV", "TW",
127
- "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN",
128
- "VU", "WF", "WS", "YE", "YT", "RS", "ZA", "ZM", "ME", "ZW", "A1", "A2", "O1",
129
- "AX", "GG", "IM", "JE", "BL", "MF"
130
- );
 
 
 
 
 
131
  var $GEOIP_COUNTRY_CODES3 = array(
132
- "","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG",
133
- "ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI",
134
- "BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC",
135
- "COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV",
136
- "CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH",
137
- "ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD",
138
- "GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM",
139
- "GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO",
140
- "IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA",
141
- "PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
142
- "LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC",
143
- "MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL",
144
- "NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER",
145
- "PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT",
146
- "REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM",
147
- "SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF",
148
- "TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA",
149
- "UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT",
150
- "WLF","WSM","YEM","YT","SRB","ZAF","ZMB","MNE","ZWE","A1","A2","O1",
151
- "ALA","GGY","IMN","JEY","BLM","MAF"
152
- );
 
 
 
 
 
 
153
  var $GEOIP_COUNTRY_NAMES = array(
154
- "", "Asia/Pacific Region", "Europe", "Andorra", "United Arab Emirates",
155
- "Afghanistan", "Antigua and Barbuda", "Anguilla", "Albania", "Armenia",
156
- "Netherlands Antilles", "Angola", "Antarctica", "Argentina", "American Samoa",
157
- "Austria", "Australia", "Aruba", "Azerbaijan", "Bosnia and Herzegovina",
158
- "Barbados", "Bangladesh", "Belgium", "Burkina Faso", "Bulgaria", "Bahrain",
159
- "Burundi", "Benin", "Bermuda", "Brunei Darussalam", "Bolivia", "Brazil",
160
- "Bahamas", "Bhutan", "Bouvet Island", "Botswana", "Belarus", "Belize",
161
- "Canada", "Cocos (Keeling) Islands", "Congo, The Democratic Republic of the",
162
- "Central African Republic", "Congo", "Switzerland", "Cote D'Ivoire", "Cook Islands",
163
- "Chile", "Cameroon", "China", "Colombia", "Costa Rica", "Cuba", "Cape Verde",
164
- "Christmas Island", "Cyprus", "Czech Republic", "Germany", "Djibouti",
165
- "Denmark", "Dominica", "Dominican Republic", "Algeria", "Ecuador", "Estonia",
166
- "Egypt", "Western Sahara", "Eritrea", "Spain", "Ethiopia", "Finland", "Fiji",
167
- "Falkland Islands (Malvinas)", "Micronesia, Federated States of", "Faroe Islands",
168
- "France", "France, Metropolitan", "Gabon", "United Kingdom",
169
- "Grenada", "Georgia", "French Guiana", "Ghana", "Gibraltar", "Greenland",
170
- "Gambia", "Guinea", "Guadeloupe", "Equatorial Guinea", "Greece", "South Georgia and the South Sandwich Islands",
171
- "Guatemala", "Guam", "Guinea-Bissau",
172
- "Guyana", "Hong Kong", "Heard Island and McDonald Islands", "Honduras",
173
- "Croatia", "Haiti", "Hungary", "Indonesia", "Ireland", "Israel", "India",
174
- "British Indian Ocean Territory", "Iraq", "Iran, Islamic Republic of",
175
- "Iceland", "Italy", "Jamaica", "Jordan", "Japan", "Kenya", "Kyrgyzstan",
176
- "Cambodia", "Kiribati", "Comoros", "Saint Kitts and Nevis", "Korea, Democratic People's Republic of",
177
- "Korea, Republic of", "Kuwait", "Cayman Islands",
178
- "Kazakhstan", "Lao People's Democratic Republic", "Lebanon", "Saint Lucia",
179
- "Liechtenstein", "Sri Lanka", "Liberia", "Lesotho", "Lithuania", "Luxembourg",
180
- "Latvia", "Libyan Arab Jamahiriya", "Morocco", "Monaco", "Moldova, Republic of",
181
- "Madagascar", "Marshall Islands", "Macedonia",
182
- "Mali", "Myanmar", "Mongolia", "Macau", "Northern Mariana Islands",
183
- "Martinique", "Mauritania", "Montserrat", "Malta", "Mauritius", "Maldives",
184
- "Malawi", "Mexico", "Malaysia", "Mozambique", "Namibia", "New Caledonia",
185
- "Niger", "Norfolk Island", "Nigeria", "Nicaragua", "Netherlands", "Norway",
186
- "Nepal", "Nauru", "Niue", "New Zealand", "Oman", "Panama", "Peru", "French Polynesia",
187
- "Papua New Guinea", "Philippines", "Pakistan", "Poland", "Saint Pierre and Miquelon",
188
- "Pitcairn Islands", "Puerto Rico", "Palestinian Territory",
189
- "Portugal", "Palau", "Paraguay", "Qatar", "Reunion", "Romania",
190
- "Russian Federation", "Rwanda", "Saudi Arabia", "Solomon Islands",
191
- "Seychelles", "Sudan", "Sweden", "Singapore", "Saint Helena", "Slovenia",
192
- "Svalbard and Jan Mayen", "Slovakia", "Sierra Leone", "San Marino", "Senegal",
193
- "Somalia", "Suriname", "Sao Tome and Principe", "El Salvador", "Syrian Arab Republic",
194
- "Swaziland", "Turks and Caicos Islands", "Chad", "French Southern Territories",
195
- "Togo", "Thailand", "Tajikistan", "Tokelau", "Turkmenistan",
196
- "Tunisia", "Tonga", "Timor-Leste", "Turkey", "Trinidad and Tobago", "Tuvalu",
197
- "Taiwan", "Tanzania, United Republic of", "Ukraine",
198
- "Uganda", "United States Minor Outlying Islands", "United States", "Uruguay",
199
- "Uzbekistan", "Holy See (Vatican City State)", "Saint Vincent and the Grenadines",
200
- "Venezuela", "Virgin Islands, British", "Virgin Islands, U.S.",
201
- "Vietnam", "Vanuatu", "Wallis and Futuna", "Samoa", "Yemen", "Mayotte",
202
- "Serbia", "South Africa", "Zambia", "Montenegro", "Zimbabwe",
203
- "Anonymous Proxy","Satellite Provider","Other",
204
- "Aland Islands","Guernsey","Isle of Man","Jersey","Saint Barthelemy","Saint Martin"
 
 
 
 
205
  );
 
206
  }
207
 
208
  function cpd_geoip_load_shared_mem ($file) {
@@ -223,7 +256,7 @@ function cpd_geoip_load_shared_mem ($file) {
223
  shmop_close ($shmid);
224
  }
225
 
226
- function cpd_setup_segments($gi){
227
  $gi->databaseType = GEOIP_COUNTRY_EDITION;
228
  $gi->record_length = STANDARD_RECORD_LENGTH;
229
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
@@ -242,15 +275,32 @@ function cpd_setup_segments($gi){
242
  } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
243
  ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
244
  || ($gi->databaseType == GEOIP_ORG_EDITION)
 
 
 
245
  || ($gi->databaseType == GEOIP_ISP_EDITION)
246
- || ($gi->databaseType == GEOIP_ASNUM_EDITION)){
 
 
 
 
 
 
 
 
 
 
247
  $gi->databaseSegments = 0;
248
  $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
249
  for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
250
  $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
251
  }
252
- if (($gi->databaseType == GEOIP_ORG_EDITION)||
253
- ($gi->databaseType == GEOIP_ISP_EDITION)) {
 
 
 
 
254
  $gi->record_length = ORG_RECORD_LENGTH;
255
  }
256
  }
@@ -260,6 +310,7 @@ function cpd_setup_segments($gi){
260
  }
261
  }
262
  if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
 
263
  ($gi->databaseType == GEOIP_PROXY_EDITION)||
264
  ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
265
  $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
@@ -276,18 +327,37 @@ function cpd_setup_segments($gi){
276
  }
277
  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
278
  $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
279
- } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0) ||
280
- ($gi->databaseType == GEOIP_CITY_EDITION_REV1) ||
281
- ($gi->databaseType == GEOIP_ORG_EDITION) ||
282
- ($gi->databaseType == GEOIP_ISP_EDITION) ||
283
- ($gi->databaseType == GEOIP_ASNUM_EDITION)){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  $gi->databaseSegments = 0;
285
  $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
286
  for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
287
  $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
288
  }
289
- if ($gi->databaseType == GEOIP_ORG_EDITION ||
290
- $gi->databaseType == GEOIP_ISP_EDITION) {
 
 
 
 
291
  $gi->record_length = ORG_RECORD_LENGTH;
292
  }
293
  }
@@ -297,6 +367,7 @@ function cpd_setup_segments($gi){
297
  }
298
  }
299
  if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
 
300
  ($gi->databaseType == GEOIP_PROXY_EDITION)||
301
  ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
302
  $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
@@ -307,7 +378,7 @@ function cpd_setup_segments($gi){
307
  }
308
 
309
  function cpd_geoip_open($filename, $flags) {
310
- $gi = new GeoIPCpD;
311
  $gi->flags = $flags;
312
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
313
  $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
@@ -319,7 +390,7 @@ function cpd_geoip_open($filename, $flags) {
319
  }
320
  }
321
 
322
- $gi = cpd_setup_segments($gi);
323
  return $gi;
324
  }
325
 
@@ -331,6 +402,18 @@ function cpd_geoip_close($gi) {
331
  return fclose($gi->filehandle);
332
  }
333
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  function cpd_geoip_country_id_by_name($gi, $name) {
335
  $addr = gethostbyname($name);
336
  if (!$addr || $addr == $name) {
@@ -339,6 +422,14 @@ function cpd_geoip_country_id_by_name($gi, $name) {
339
  return cpd_geoip_country_id_by_addr($gi, $addr);
340
  }
341
 
 
 
 
 
 
 
 
 
342
  function cpd_geoip_country_code_by_name($gi, $name) {
343
  $country_id = cpd_geoip_country_id_by_name($gi,$name);
344
  if ($country_id !== false) {
@@ -347,6 +438,14 @@ function cpd_geoip_country_code_by_name($gi, $name) {
347
  return false;
348
  }
349
 
 
 
 
 
 
 
 
 
350
  function cpd_geoip_country_name_by_name($gi, $name) {
351
  $country_id = cpd_geoip_country_id_by_name($gi,$name);
352
  if ($country_id !== false) {
@@ -355,9 +454,22 @@ function cpd_geoip_country_name_by_name($gi, $name) {
355
  return false;
356
  }
357
 
 
 
 
 
 
358
  function cpd_geoip_country_id_by_addr($gi, $addr) {
359
  $ipnum = ip2long($addr);
360
- return cpd_geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
 
 
 
 
 
 
 
 
361
  }
362
 
363
  function cpd_geoip_country_code_by_addr($gi, $addr) {
@@ -375,6 +487,14 @@ function cpd_geoip_country_code_by_addr($gi, $addr) {
375
  return false;
376
  }
377
 
 
 
 
 
 
 
 
 
378
  function cpd_geoip_country_name_by_addr($gi, $addr) {
379
  if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
380
  $record = cpd_geoip_record_by_addr($gi,$addr);
@@ -388,14 +508,76 @@ function cpd_geoip_country_name_by_addr($gi, $addr) {
388
  return false;
389
  }
390
 
391
- function cpd_geoip_seek_country($gi, $ipnum) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  $offset = 0;
393
  for ($depth = 31; $depth >= 0; --$depth) {
394
  if ($gi->flags & GEOIP_MEMORY_CACHE) {
 
 
 
 
 
395
  $buf = substr($gi->memory_buffer,
396
  2 * $gi->record_length * $offset,
397
  2 * $gi->record_length);
398
- } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
 
 
399
  $buf = @shmop_read ($gi->shmid,
400
  2 * $gi->record_length * $offset,
401
  2 * $gi->record_length );
@@ -426,77 +608,107 @@ function cpd_geoip_seek_country($gi, $ipnum) {
426
  return false;
427
  }
428
 
429
- //function cpd_get_org($gi,$ipnum){
430
- // $seek_org = cpd_geoip_seek_country($gi,$ipnum);
431
- // if ($seek_org == $gi->databaseSegments) {
432
- // return NULL;
433
- // }
434
- // $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
435
- // if ($gi->flags & GEOIP_SHARED_MEMORY) {
436
- // $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
437
- // } else {
438
- // fseek($gi->filehandle, $record_pointer, SEEK_SET);
439
- // $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
440
- // }
441
- // $org_buf = substr($org_buf, 0, strpos($org_buf, 0));
442
- // return $org_buf;
443
- //}
444
- //
445
- //function cpd_geoip_org_by_addr ($gi,$addr) {
446
- // if ($addr == NULL) {
447
- // return 0;
448
- // }
449
- // $ipnum = ip2long($addr);
450
- // return cpd_get_org($gi, $ipnum);
451
- //}
452
-
453
- //function cpd_get_region($gi,$ipnum){
454
- // if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
455
- // $seek_region = cpd_geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
456
- // if ($seek_region >= 1000){
457
- // $country_code = "US";
458
- // $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
459
- // } else {
460
- // $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
461
- // $region = "";
462
- // }
463
- // return array ($country_code,$region);
464
- // } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
465
- // $seek_region = cpd_geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
466
- // //print $seek_region;
467
- // if ($seek_region < US_OFFSET){
468
- // $country_code = "";
469
- // $region = "";
470
- // } else if ($seek_region < CANADA_OFFSET) {
471
- // $country_code = "US";
472
- // $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
473
- // } else if ($seek_region < WORLD_OFFSET) {
474
- // $country_code = "CA";
475
- // $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
476
- // } else {
477
- // $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
478
- // $region = "";
479
- // }
480
- // return array ($country_code,$region);
481
- // }
482
- //}
483
-
484
- //function cpd_geoip_region_by_addr ($gi,$addr) {
485
- // if ($addr == NULL) {
486
- // return 0;
487
- // }
488
- // $ipnum = ip2long($addr);
489
- // return cpd_get_region($gi, $ipnum);
490
- //}
491
-
492
- //function cpd_getdnsattributes ($l,$ip){
493
- // $r = new Net_DNS_Resolver();
494
- // $r->nameservers = array("ws1.maxmind.com");
495
- // $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
496
- // $str = is_object($p->answer[0])?$p->answer[0]->string():'';
497
- // ereg("\"(.*)\"",$str,$regs);
498
- // $str = $regs[1];
499
- // return $str;
500
- //}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
501
 
502
  ?>
52
  define("GEOIP_DIALUP_SPEED", 1);
53
  define("GEOIP_CABLEDSL_SPEED", 2);
54
  define("GEOIP_CORPORATE_SPEED", 3);
55
+ define("GEOIP_DOMAIN_EDITION", 11);
56
+ define("GEOIP_COUNTRY_EDITION_V6", 12);
57
+ define("GEOIP_LOCATIONA_EDITION", 13);
58
+ define("GEOIP_ACCURACYRADIUS_EDITION", 14);
59
+ define("GEOIP_CITYCOMBINED_EDITION", 15);
60
+ define("GEOIP_CITY_EDITION_REV1_V6", 30);
61
+ define("GEOIP_CITY_EDITION_REV0_V6",31);
62
+ define("GEOIP_NETSPEED_EDITION_REV1",32);
63
+ define("GEOIP_NETSPEED_EDITION_REV1_V6",33);
64
+ define("GEOIP_USERTYPE_EDITION",28);
65
+ define("GEOIP_USERTYPE_EDITION_V6",29);
66
+ define("GEOIP_ASNUM_EDITION_V6",21);
67
+ define("GEOIP_ISP_EDITION_V6",22);
68
+ define("GEOIP_ORG_EDITION_V6",23);
69
+ define("GEOIP_DOMAIN_EDITION_V6",24);
70
+
71
+ define("CITYCOMBINED_FIXED_RECORD", 7 );
72
 
73
  class GeoIPCpd {
74
  var $flags;
79
  var $record_length;
80
  var $shmid;
81
  var $GEOIP_COUNTRY_CODE_TO_NUMBER = array(
82
+ "" => 0, "AP" => 1, "EU" => 2, "AD" => 3, "AE" => 4, "AF" => 5,
83
+ "AG" => 6, "AI" => 7, "AL" => 8, "AM" => 9, "CW" => 10, "AO" => 11,
84
+ "AQ" => 12, "AR" => 13, "AS" => 14, "AT" => 15, "AU" => 16, "AW" => 17,
85
+ "AZ" => 18, "BA" => 19, "BB" => 20, "BD" => 21, "BE" => 22, "BF" => 23,
86
+ "BG" => 24, "BH" => 25, "BI" => 26, "BJ" => 27, "BM" => 28, "BN" => 29,
87
+ "BO" => 30, "BR" => 31, "BS" => 32, "BT" => 33, "BV" => 34, "BW" => 35,
88
+ "BY" => 36, "BZ" => 37, "CA" => 38, "CC" => 39, "CD" => 40, "CF" => 41,
89
+ "CG" => 42, "CH" => 43, "CI" => 44, "CK" => 45, "CL" => 46, "CM" => 47,
90
+ "CN" => 48, "CO" => 49, "CR" => 50, "CU" => 51, "CV" => 52, "CX" => 53,
91
+ "CY" => 54, "CZ" => 55, "DE" => 56, "DJ" => 57, "DK" => 58, "DM" => 59,
92
+ "DO" => 60, "DZ" => 61, "EC" => 62, "EE" => 63, "EG" => 64, "EH" => 65,
93
+ "ER" => 66, "ES" => 67, "ET" => 68, "FI" => 69, "FJ" => 70, "FK" => 71,
94
+ "FM" => 72, "FO" => 73, "FR" => 74, "SX" => 75, "GA" => 76, "GB" => 77,
95
+ "GD" => 78, "GE" => 79, "GF" => 80, "GH" => 81, "GI" => 82, "GL" => 83,
96
+ "GM" => 84, "GN" => 85, "GP" => 86, "GQ" => 87, "GR" => 88, "GS" => 89,
97
+ "GT" => 90, "GU" => 91, "GW" => 92, "GY" => 93, "HK" => 94, "HM" => 95,
98
+ "HN" => 96, "HR" => 97, "HT" => 98, "HU" => 99, "ID" => 100, "IE" => 101,
99
+ "IL" => 102, "IN" => 103, "IO" => 104, "IQ" => 105, "IR" => 106, "IS" => 107,
100
+ "IT" => 108, "JM" => 109, "JO" => 110, "JP" => 111, "KE" => 112, "KG" => 113,
101
+ "KH" => 114, "KI" => 115, "KM" => 116, "KN" => 117, "KP" => 118, "KR" => 119,
102
+ "KW" => 120, "KY" => 121, "KZ" => 122, "LA" => 123, "LB" => 124, "LC" => 125,
103
+ "LI" => 126, "LK" => 127, "LR" => 128, "LS" => 129, "LT" => 130, "LU" => 131,
104
+ "LV" => 132, "LY" => 133, "MA" => 134, "MC" => 135, "MD" => 136, "MG" => 137,
105
+ "MH" => 138, "MK" => 139, "ML" => 140, "MM" => 141, "MN" => 142, "MO" => 143,
106
+ "MP" => 144, "MQ" => 145, "MR" => 146, "MS" => 147, "MT" => 148, "MU" => 149,
107
  "MV" => 150, "MW" => 151, "MX" => 152, "MY" => 153, "MZ" => 154, "NA" => 155,
108
+ "NC" => 156, "NE" => 157, "NF" => 158, "NG" => 159, "NI" => 160, "NL" => 161,
109
+ "NO" => 162, "NP" => 163, "NR" => 164, "NU" => 165, "NZ" => 166, "OM" => 167,
110
+ "PA" => 168, "PE" => 169, "PF" => 170, "PG" => 171, "PH" => 172, "PK" => 173,
111
+ "PL" => 174, "PM" => 175, "PN" => 176, "PR" => 177, "PS" => 178, "PT" => 179,
112
+ "PW" => 180, "PY" => 181, "QA" => 182, "RE" => 183, "RO" => 184, "RU" => 185,
113
+ "RW" => 186, "SA" => 187, "SB" => 188, "SC" => 189, "SD" => 190, "SE" => 191,
114
+ "SG" => 192, "SH" => 193, "SI" => 194, "SJ" => 195, "SK" => 196, "SL" => 197,
115
+ "SM" => 198, "SN" => 199, "SO" => 200, "SR" => 201, "ST" => 202, "SV" => 203,
116
+ "SY" => 204, "SZ" => 205, "TC" => 206, "TD" => 207, "TF" => 208, "TG" => 209,
117
+ "TH" => 210, "TJ" => 211, "TK" => 212, "TM" => 213, "TN" => 214, "TO" => 215,
118
+ "TL" => 216, "TR" => 217, "TT" => 218, "TV" => 219, "TW" => 220, "TZ" => 221,
119
+ "UA" => 222, "UG" => 223, "UM" => 224, "US" => 225, "UY" => 226, "UZ" => 227,
120
  "VA" => 228, "VC" => 229, "VE" => 230, "VG" => 231, "VI" => 232, "VN" => 233,
121
+ "VU" => 234, "WF" => 235, "WS" => 236, "YE" => 237, "YT" => 238, "RS" => 239,
122
+ "ZA" => 240, "ZM" => 241, "ME" => 242, "ZW" => 243, "A1" => 244, "A2" => 245,
123
  "O1" => 246, "AX" => 247, "GG" => 248, "IM" => 249, "JE" => 250, "BL" => 251,
124
+ "MF" => 252, "BQ" => 253,
125
  );
126
  var $GEOIP_COUNTRY_CODES = array(
127
+ "","AP","EU","AD","AE","AF","AG","AI","AL","AM","CW",
128
+ "AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB",
129
+ "BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO",
130
+ "BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD",
131
+ "CF","CG","CH","CI","CK","CL","CM","CN","CO","CR",
132
+ "CU","CV","CX","CY","CZ","DE","DJ","DK","DM","DO",
133
+ "DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ",
134
+ "FK","FM","FO","FR","SX","GA","GB","GD","GE","GF",
135
+ "GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT",
136
+ "GU","GW","GY","HK","HM","HN","HR","HT","HU","ID",
137
+ "IE","IL","IN","IO","IQ","IR","IS","IT","JM","JO",
138
+ "JP","KE","KG","KH","KI","KM","KN","KP","KR","KW",
139
+ "KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT",
140
+ "LU","LV","LY","MA","MC","MD","MG","MH","MK","ML",
141
+ "MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV",
142
+ "MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI",
143
+ "NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF",
144
+ "PG","PH","PK","PL","PM","PN","PR","PS","PT","PW",
145
+ "PY","QA","RE","RO","RU","RW","SA","SB","SC","SD",
146
+ "SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO",
147
+ "SR","ST","SV","SY","SZ","TC","TD","TF","TG","TH",
148
+ "TJ","TK","TM","TN","TO","TL","TR","TT","TV","TW",
149
+ "TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE",
150
+ "VG","VI","VN","VU","WF","WS","YE","YT","RS","ZA",
151
+ "ZM","ME","ZW","A1","A2","O1","AX","GG","IM","JE",
152
+ "BL","MF", "BQ");
153
  var $GEOIP_COUNTRY_CODES3 = array(
154
+ "","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","CUW",
155
+ "AGO","ATA","ARG","ASM","AUT","AUS","ABW","AZE","BIH","BRB",
156
+ "BGD","BEL","BFA","BGR","BHR","BDI","BEN","BMU","BRN","BOL",
157
+ "BRA","BHS","BTN","BVT","BWA","BLR","BLZ","CAN","CCK","COD",
158
+ "CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI",
159
+ "CUB","CPV","CXR","CYP","CZE","DEU","DJI","DNK","DMA","DOM",
160
+ "DZA","ECU","EST","EGY","ESH","ERI","ESP","ETH","FIN","FJI",
161
+ "FLK","FSM","FRO","FRA","SXM","GAB","GBR","GRD","GEO","GUF",
162
+ "GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","SGS","GTM",
163
+ "GUM","GNB","GUY","HKG","HMD","HND","HRV","HTI","HUN","IDN",
164
+ "IRL","ISR","IND","IOT","IRQ","IRN","ISL","ITA","JAM","JOR",
165
+ "JPN","KEN","KGZ","KHM","KIR","COM","KNA","PRK","KOR","KWT",
166
+ "CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU",
167
+ "LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI",
168
+ "MMR","MNG","MAC","MNP","MTQ","MRT","MSR","MLT","MUS","MDV",
169
+ "MWI","MEX","MYS","MOZ","NAM","NCL","NER","NFK","NGA","NIC",
170
+ "NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER","PYF",
171
+ "PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW",
172
+ "PRY","QAT","REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN",
173
+ "SWE","SGP","SHN","SVN","SJM","SVK","SLE","SMR","SEN","SOM",
174
+ "SUR","STP","SLV","SYR","SWZ","TCA","TCD","ATF","TGO","THA",
175
+ "TJK","TKL","TKM","TUN","TON","TLS","TUR","TTO","TUV","TWN",
176
+ "TZA","UKR","UGA","UMI","USA","URY","UZB","VAT","VCT","VEN",
177
+ "VGB","VIR","VNM","VUT","WLF","WSM","YEM","MYT","SRB","ZAF",
178
+ "ZMB","MNE","ZWE","A1","A2","O1","ALA","GGY","IMN","JEY",
179
+ "BLM","MAF", "BES"
180
+ );
181
  var $GEOIP_COUNTRY_NAMES = array(
182
+ "","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Curacao",
183
+ "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados",
184
+ "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia",
185
+ "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the",
186
+ "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica",
187
+ "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic",
188
+ "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji",
189
+ "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","Sint Maarten (Dutch part)","Gabon","United Kingdom","Grenada","Georgia","French Guiana",
190
+ "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala",
191
+ "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia",
192
+ "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan",
193
+ "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait",
194
+ "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania",
195
+ "Luxembourg","Latvia","Libya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali",
196
+ "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives",
197
+ "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua",
198
+ "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia",
199
+ "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau",
200
+ "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan",
201
+ "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname",
202
+ "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand",
203
+ "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan",
204
+ "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela",
205
+ "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa",
206
+ "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey",
207
+ "Saint Barthelemy","Saint Martin", "Bonaire, Saint Eustatius and Saba"
208
+ );
209
+
210
+ var $GEOIP_CONTINENT_CODES = array(
211
+ "--", "AS","EU","EU","AS","AS","NA","NA","EU","AS","NA",
212
+ "AF","AN","SA","OC","EU","OC","NA","AS","EU","NA",
213
+ "AS","EU","AF","EU","AS","AF","AF","NA","AS","SA",
214
+ "SA","NA","AS","AN","AF","EU","NA","NA","AS","AF",
215
+ "AF","AF","EU","AF","OC","SA","AF","AS","SA","NA",
216
+ "NA","AF","AS","AS","EU","EU","AF","EU","NA","NA",
217
+ "AF","SA","EU","AF","AF","AF","EU","AF","EU","OC",
218
+ "SA","OC","EU","EU","NA","AF","EU","NA","AS","SA",
219
+ "AF","EU","NA","AF","AF","NA","AF","EU","AN","NA",
220
+ "OC","AF","SA","AS","AN","NA","EU","NA","EU","AS",
221
+ "EU","AS","AS","AS","AS","AS","EU","EU","NA","AS",
222
+ "AS","AF","AS","AS","OC","AF","NA","AS","AS","AS",
223
+ "NA","AS","AS","AS","NA","EU","AS","AF","AF","EU",
224
+ "EU","EU","AF","AF","EU","EU","AF","OC","EU","AF",
225
+ "AS","AS","AS","OC","NA","AF","NA","EU","AF","AS",
226
+ "AF","NA","AS","AF","AF","OC","AF","OC","AF","NA",
227
+ "EU","EU","AS","OC","OC","OC","AS","NA","SA","OC",
228
+ "OC","AS","AS","EU","NA","OC","NA","AS","EU","OC",
229
+ "SA","AS","AF","EU","EU","AF","AS","OC","AF","AF",
230
+ "EU","AS","AF","EU","EU","EU","AF","EU","AF","AF",
231
+ "SA","AF","NA","AS","AF","NA","AF","AN","AF","AS",
232
+ "AS","OC","AS","AF","OC","AS","EU","NA","OC","AS",
233
+ "AF","EU","AF","OC","NA","SA","AS","EU","NA","SA",
234
+ "NA","NA","AS","OC","OC","OC","AS","AF","EU","AF",
235
+ "AF","EU","AF","--","--","--","EU","EU","EU","EU",
236
+ "NA","NA","NA"
237
  );
238
+
239
  }
240
 
241
  function cpd_geoip_load_shared_mem ($file) {
256
  shmop_close ($shmid);
257
  }
258
 
259
+ function _setup_segments($gi){
260
  $gi->databaseType = GEOIP_COUNTRY_EDITION;
261
  $gi->record_length = STANDARD_RECORD_LENGTH;
262
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
275
  } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)||
276
  ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
277
  || ($gi->databaseType == GEOIP_ORG_EDITION)
278
+ || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
279
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
280
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
281
  || ($gi->databaseType == GEOIP_ISP_EDITION)
282
+ || ($gi->databaseType == GEOIP_ISP_EDITION_V6)
283
+ || ($gi->databaseType == GEOIP_USERTYPE_EDITION)
284
+ || ($gi->databaseType == GEOIP_USERTYPE_EDITION_V6)
285
+ || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
286
+ || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
287
+ || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
288
+ || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
289
+ || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1)
290
+ || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6)
291
+ || ($gi->databaseType == GEOIP_ASNUM_EDITION)
292
+ || ($gi->databaseType == GEOIP_ASNUM_EDITION_V6)){
293
  $gi->databaseSegments = 0;
294
  $buf = @shmop_read ($gi->shmid, $offset, SEGMENT_RECORD_LENGTH);
295
  for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
296
  $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
297
  }
298
+ if (($gi->databaseType == GEOIP_ORG_EDITION)
299
+ || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
300
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
301
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
302
+ || ($gi->databaseType == GEOIP_ISP_EDITION)
303
+ || ($gi->databaseType == GEOIP_ISP_EDITION_V6)) {
304
  $gi->record_length = ORG_RECORD_LENGTH;
305
  }
306
  }
310
  }
311
  }
312
  if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
313
+ ($gi->databaseType == GEOIP_COUNTRY_EDITION_V6)||
314
  ($gi->databaseType == GEOIP_PROXY_EDITION)||
315
  ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
316
  $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
327
  }
328
  else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1){
329
  $gi->databaseSegments = GEOIP_STATE_BEGIN_REV1;
330
+ } else if (($gi->databaseType == GEOIP_CITY_EDITION_REV0)
331
+ || ($gi->databaseType == GEOIP_CITY_EDITION_REV1)
332
+ || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
333
+ || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
334
+ || ($gi->databaseType == GEOIP_ORG_EDITION)
335
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION)
336
+ || ($gi->databaseType == GEOIP_ISP_EDITION)
337
+ || ($gi->databaseType == GEOIP_ORG_EDITION_V6)
338
+ || ($gi->databaseType == GEOIP_DOMAIN_EDITION_V6)
339
+ || ($gi->databaseType == GEOIP_ISP_EDITION_V6)
340
+ || ($gi->databaseType == GEOIP_LOCATIONA_EDITION)
341
+ || ($gi->databaseType == GEOIP_ACCURACYRADIUS_EDITION)
342
+ || ($gi->databaseType == GEOIP_CITY_EDITION_REV0_V6)
343
+ || ($gi->databaseType == GEOIP_CITY_EDITION_REV1_V6)
344
+ || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1)
345
+ || ($gi->databaseType == GEOIP_NETSPEED_EDITION_REV1_V6)
346
+ || ($gi->databaseType == GEOIP_USERTYPE_EDITION)
347
+ || ($gi->databaseType == GEOIP_USERTYPE_EDITION_V6)
348
+ || ($gi->databaseType == GEOIP_ASNUM_EDITION)
349
+ || ($gi->databaseType == GEOIP_ASNUM_EDITION_V6)){
350
  $gi->databaseSegments = 0;
351
  $buf = fread($gi->filehandle,SEGMENT_RECORD_LENGTH);
352
  for ($j = 0;$j < SEGMENT_RECORD_LENGTH;$j++){
353
  $gi->databaseSegments += (ord($buf[$j]) << ($j * 8));
354
  }
355
+ if ( ( $gi->databaseType == GEOIP_ORG_EDITION )
356
+ || ( $gi->databaseType == GEOIP_DOMAIN_EDITION )
357
+ || ( $gi->databaseType == GEOIP_ISP_EDITION )
358
+ || ( $gi->databaseType == GEOIP_ORG_EDITION_V6 )
359
+ || ( $gi->databaseType == GEOIP_DOMAIN_EDITION_V6 )
360
+ || ( $gi->databaseType == GEOIP_ISP_EDITION_V6 )) {
361
  $gi->record_length = ORG_RECORD_LENGTH;
362
  }
363
  }
367
  }
368
  }
369
  if (($gi->databaseType == GEOIP_COUNTRY_EDITION)||
370
+ ($gi->databaseType == GEOIP_COUNTRY_EDITION_V6)||
371
  ($gi->databaseType == GEOIP_PROXY_EDITION)||
372
  ($gi->databaseType == GEOIP_NETSPEED_EDITION)){
373
  $gi->databaseSegments = GEOIP_COUNTRY_BEGIN;
378
  }
379
 
380
  function cpd_geoip_open($filename, $flags) {
381
+ $gi = new GeoIPCpd;
382
  $gi->flags = $flags;
383
  if ($gi->flags & GEOIP_SHARED_MEMORY) {
384
  $gi->shmid = @shmop_open (GEOIP_SHM_KEY, "a", 0, 0);
390
  }
391
  }
392
 
393
+ $gi = _setup_segments($gi);
394
  return $gi;
395
  }
396
 
402
  return fclose($gi->filehandle);
403
  }
404
 
405
+ function cpd_geoip_country_id_by_name_v6($gi, $name) {
406
+ $rec = dns_get_record($name, DNS_AAAA);
407
+ if ( !$rec ) {
408
+ return false;
409
+ }
410
+ $addr = $rec[0]["ipv6"];
411
+ if (!$addr || $addr == $name) {
412
+ return false;
413
+ }
414
+ return cpd_geoip_country_id_by_addr_v6($gi, $addr);
415
+ }
416
+
417
  function cpd_geoip_country_id_by_name($gi, $name) {
418
  $addr = gethostbyname($name);
419
  if (!$addr || $addr == $name) {
422
  return cpd_geoip_country_id_by_addr($gi, $addr);
423
  }
424
 
425
+ function cpd_geoip_country_code_by_name_v6($gi, $name) {
426
+ $country_id = cpd_geoip_country_id_by_name_v6($gi,$name);
427
+ if ($country_id !== false) {
428
+ return $gi->GEOIP_COUNTRY_CODES[$country_id];
429
+ }
430
+ return false;
431
+ }
432
+
433
  function cpd_geoip_country_code_by_name($gi, $name) {
434
  $country_id = cpd_geoip_country_id_by_name($gi,$name);
435
  if ($country_id !== false) {
438
  return false;
439
  }
440
 
441
+ function cpd_geoip_country_name_by_name_v6($gi, $name) {
442
+ $country_id = cpd_geoip_country_id_by_name_v6($gi,$name);
443
+ if ($country_id !== false) {
444
+ return $gi->GEOIP_COUNTRY_NAMES[$country_id];
445
+ }
446
+ return false;
447
+ }
448
+
449
  function cpd_geoip_country_name_by_name($gi, $name) {
450
  $country_id = cpd_geoip_country_id_by_name($gi,$name);
451
  if ($country_id !== false) {
454
  return false;
455
  }
456
 
457
+ function cpd_geoip_country_id_by_addr_v6($gi, $addr) {
458
+ $ipnum = inet_pton($addr);
459
+ return _cpd_geoip_seek_country_v6($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
460
+ }
461
+
462
  function cpd_geoip_country_id_by_addr($gi, $addr) {
463
  $ipnum = ip2long($addr);
464
+ return _cpd_geoip_seek_country($gi, $ipnum) - GEOIP_COUNTRY_BEGIN;
465
+ }
466
+
467
+ function cpd_geoip_country_code_by_addr_v6($gi, $addr) {
468
+ $country_id = cpd_geoip_country_id_by_addr_v6($gi,$addr);
469
+ if ($country_id !== false) {
470
+ return $gi->GEOIP_COUNTRY_CODES[$country_id];
471
+ }
472
+ return false;
473
  }
474
 
475
  function cpd_geoip_country_code_by_addr($gi, $addr) {
487
  return false;
488
  }
489
 
490
+ function cpd_geoip_country_name_by_addr_v6($gi, $addr) {
491
+ $country_id = cpd_geoip_country_id_by_addr_v6($gi,$addr);
492
+ if ($country_id !== false) {
493
+ return $gi->GEOIP_COUNTRY_NAMES[$country_id];
494
+ }
495
+ return false;
496
+ }
497
+
498
  function cpd_geoip_country_name_by_addr($gi, $addr) {
499
  if ($gi->databaseType == GEOIP_CITY_EDITION_REV1) {
500
  $record = cpd_geoip_record_by_addr($gi,$addr);
508
  return false;
509
  }
510
 
511
+ function _cpd_geoip_seek_country_v6($gi, $ipnum) {
512
+
513
+ # arrays from unpack start with offset 1
514
+ # yet another php mystery. array_merge work around
515
+ # this broken behaviour
516
+ $v6vec = array_merge(unpack( "C16", $ipnum));
517
+
518
+ $offset = 0;
519
+ for ($depth = 127; $depth >= 0; --$depth) {
520
+ if ($gi->flags & GEOIP_MEMORY_CACHE) {
521
+ // workaround php's broken substr, strpos, etc handling with
522
+ // mbstring.func_overload and mbstring.internal_encoding
523
+ $enc = mb_internal_encoding();
524
+ mb_internal_encoding('ISO-8859-1');
525
+
526
+ $buf = substr($gi->memory_buffer,
527
+ 2 * $gi->record_length * $offset,
528
+ 2 * $gi->record_length);
529
+
530
+ mb_internal_encoding($enc);
531
+ } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
532
+ $buf = @shmop_read ($gi->shmid,
533
+ 2 * $gi->record_length * $offset,
534
+ 2 * $gi->record_length );
535
+ } else {
536
+ fseek($gi->filehandle, 2 * $gi->record_length * $offset, SEEK_SET) == 0
537
+ or die("fseek failed");
538
+ $buf = fread($gi->filehandle, 2 * $gi->record_length);
539
+ }
540
+ $x = array(0,0);
541
+ for ($i = 0; $i < 2; ++$i) {
542
+ for ($j = 0; $j < $gi->record_length; ++$j) {
543
+ $x[$i] += ord($buf[$gi->record_length * $i + $j]) << ($j * 8);
544
+ }
545
+ }
546
+
547
+ $bnum = 127 - $depth;
548
+ $idx = $bnum >> 3;
549
+ $b_mask = 1 << ( $bnum & 7 ^ 7 );
550
+ if (($v6vec[$idx] & $b_mask) > 0) {
551
+ if ($x[1] >= $gi->databaseSegments) {
552
+ return $x[1];
553
+ }
554
+ $offset = $x[1];
555
+ } else {
556
+ if ($x[0] >= $gi->databaseSegments) {
557
+ return $x[0];
558
+ }
559
+ $offset = $x[0];
560
+ }
561
+ }
562
+ trigger_error("error traversing database - perhaps it is corrupt?", E_USER_ERROR);
563
+ return false;
564
+ }
565
+
566
+ function _cpd_geoip_seek_country($gi, $ipnum) {
567
  $offset = 0;
568
  for ($depth = 31; $depth >= 0; --$depth) {
569
  if ($gi->flags & GEOIP_MEMORY_CACHE) {
570
+ // workaround php's broken substr, strpos, etc handling with
571
+ // mbstring.func_overload and mbstring.internal_encoding
572
+ $enc = mb_internal_encoding();
573
+ mb_internal_encoding('ISO-8859-1');
574
+
575
  $buf = substr($gi->memory_buffer,
576
  2 * $gi->record_length * $offset,
577
  2 * $gi->record_length);
578
+
579
+ mb_internal_encoding($enc);
580
+ } elseif ($gi->flags & GEOIP_SHARED_MEMORY) {
581
  $buf = @shmop_read ($gi->shmid,
582
  2 * $gi->record_length * $offset,
583
  2 * $gi->record_length );
608
  return false;
609
  }
610
 
611
+ function _cpd_common_get_org($gi, $seek_org){
612
+ $record_pointer = $seek_org + (2 * $gi->record_length - 1) * $gi->databaseSegments;
613
+ if ($gi->flags & GEOIP_SHARED_MEMORY) {
614
+ $org_buf = @shmop_read ($gi->shmid, $record_pointer, MAX_ORG_RECORD_LENGTH);
615
+ } else {
616
+ fseek($gi->filehandle, $record_pointer, SEEK_SET);
617
+ $org_buf = fread($gi->filehandle,MAX_ORG_RECORD_LENGTH);
618
+ }
619
+ // workaround php's broken substr, strpos, etc handling with
620
+ // mbstring.func_overload and mbstring.internal_encoding
621
+ $enc = mb_internal_encoding();
622
+ mb_internal_encoding('ISO-8859-1');
623
+ $org_buf = substr($org_buf, 0, strpos($org_buf, "\0"));
624
+ mb_internal_encoding($enc);
625
+ return $org_buf;
626
+ }
627
+
628
+ function _cpd_get_org_v6($gi,$ipnum){
629
+ $seek_org = _cpd_geoip_seek_country_v6($gi,$ipnum);
630
+ if ($seek_org == $gi->databaseSegments) {
631
+ return NULL;
632
+ }
633
+ return _cpd_common_get_org($gi, $seek_org);
634
+ }
635
+
636
+ function _cpd_get_org($gi,$ipnum){
637
+ $seek_org = _cpd_geoip_seek_country($gi,$ipnum);
638
+ if ($seek_org == $gi->databaseSegments) {
639
+ return NULL;
640
+ }
641
+ return _cpd_common_get_org($gi, $seek_org);
642
+ }
643
+
644
+
645
+
646
+ function cpd_geoip_name_by_addr_v6 ($gi,$addr) {
647
+ if ($addr == NULL) {
648
+ return 0;
649
+ }
650
+ $ipnum = inet_pton($addr);
651
+ return _cpd_get_org_v6($gi, $ipnum);
652
+ }
653
+
654
+ function cpd_geoip_name_by_addr ($gi,$addr) {
655
+ if ($addr == NULL) {
656
+ return 0;
657
+ }
658
+ $ipnum = ip2long($addr);
659
+ return _cpd_get_org($gi, $ipnum);
660
+ }
661
+
662
+ function cpd_geoip_org_by_addr ($gi,$addr) {
663
+ return cpd_geoip_name_by_addr($gi, $addr);
664
+ }
665
+
666
+ function _cpd_get_region($gi,$ipnum){
667
+ if ($gi->databaseType == GEOIP_REGION_EDITION_REV0){
668
+ $seek_region = _cpd_geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV0;
669
+ if ($seek_region >= 1000){
670
+ $country_code = "US";
671
+ $region = chr(($seek_region - 1000)/26 + 65) . chr(($seek_region - 1000)%26 + 65);
672
+ } else {
673
+ $country_code = $gi->GEOIP_COUNTRY_CODES[$seek_region];
674
+ $region = "";
675
+ }
676
+ return array ($country_code,$region);
677
+ } else if ($gi->databaseType == GEOIP_REGION_EDITION_REV1) {
678
+ $seek_region = _cpd_geoip_seek_country($gi,$ipnum) - GEOIP_STATE_BEGIN_REV1;
679
+ //print $seek_region;
680
+ if ($seek_region < US_OFFSET){
681
+ $country_code = "";
682
+ $region = "";
683
+ } else if ($seek_region < CANADA_OFFSET) {
684
+ $country_code = "US";
685
+ $region = chr(($seek_region - US_OFFSET)/26 + 65) . chr(($seek_region - US_OFFSET)%26 + 65);
686
+ } else if ($seek_region < WORLD_OFFSET) {
687
+ $country_code = "CA";
688
+ $region = chr(($seek_region - CANADA_OFFSET)/26 + 65) . chr(($seek_region - CANADA_OFFSET)%26 + 65);
689
+ } else {
690
+ $country_code = $gi->GEOIP_COUNTRY_CODES[($seek_region - WORLD_OFFSET) / FIPS_RANGE];
691
+ $region = "";
692
+ }
693
+ return array ($country_code,$region);
694
+ }
695
+ }
696
+
697
+ function cpd_geoip_region_by_addr ($gi,$addr) {
698
+ if ($addr == NULL) {
699
+ return 0;
700
+ }
701
+ $ipnum = ip2long($addr);
702
+ return _cpd_get_region($gi, $ipnum);
703
+ }
704
+
705
+ function cpd_getdnsattributes ($l,$ip){
706
+ $r = new Net_DNS_Resolver();
707
+ $r->nameservers = array("ws1.maxmind.com");
708
+ $p = $r->search($l."." . $ip .".s.maxmind.com","TXT","IN");
709
+ $str = is_object($p->answer[0])?$p->answer[0]->string():'';
710
+ $str = substr( $str, 1, -1 );
711
+ return $str;
712
+ }
713
 
714
  ?>
geoip/geoip.php CHANGED
@@ -21,15 +21,18 @@ function getCountry( $ip )
21
  {
22
  global $cpd_path;
23
 
 
 
 
 
24
  $gi = cpd_geoip_open($cpd_path.'/geoip/GeoIP.dat', GEOIP_STANDARD);
25
- $c = strtolower(cpd_geoip_country_code_by_addr($gi, $ip));
26
 
27
  if ( empty($c) )
28
  $c = 'unknown';
29
- $cname = cpd_geoip_country_name_by_addr($gi, $ip);
30
- $country = array( $c, '<div class="cpd-flag cpd-flag-'.$c.'" title="'.$cname.'"></div>', $cname );
31
  cpd_geoip_close($gi);
32
-
33
  return $country;
34
  }
35
 
@@ -52,17 +55,33 @@ function updateDB()
52
  foreach ($res as $r)
53
  {
54
  $c = '';
55
- $ip = explode('.', $r->realip);
56
- if ( $ip[0] == 10
57
- || $ip[0] == 127
58
- || ($ip[0] == 169 && $ip[1] == 254)
59
- || ($ip[0] == 172 && $ip[1] >= 16 && $ip[1] <= 31)
60
- || ($ip[0] == 192 && $ip[1] == 168) )
61
- // set local IPs to '-'
62
- $c = '-';
 
 
 
 
 
 
 
63
  else
64
- // get country
65
- $c = strtolower(cpd_geoip_country_code_by_addr($gi, $r->realip));
 
 
 
 
 
 
 
 
 
66
 
67
  if ( !empty($c) )
68
  $count_per_day->mysqlQuery('', "UPDATE $wpdb->cpd_counter SET country = '$c' WHERE ip = '$r->ip'", 'GeoIP updateDB '.__LINE__);
@@ -89,7 +108,8 @@ function updateGeoIpFile()
89
  if ( !function_exists('gzopen') )
90
  return __('Sorry, necessary functions (zlib) not installed or enabled in php.ini.', 'cpd');
91
 
92
- $gzfile = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz';
 
93
  $file = $cpd_path.'/geoip/GeoIP.dat';
94
 
95
  // get remote file
@@ -118,4 +138,3 @@ function updateGeoIpFile()
118
 
119
 
120
  }
121
- ?>
21
  {
22
  global $cpd_path;
23
 
24
+ // IPv4 > IPv6
25
+ if( strpos($ip,'.') !== false )
26
+ $ip = "::$ip";
27
+
28
  $gi = cpd_geoip_open($cpd_path.'/geoip/GeoIP.dat', GEOIP_STANDARD);
29
+ $c = strtolower(cpd_geoip_country_code_by_addr_v6($gi, $ip));
30
 
31
  if ( empty($c) )
32
  $c = 'unknown';
33
+ $cname = cpd_geoip_country_name_by_addr_v6($gi, $ip);
 
34
  cpd_geoip_close($gi);
35
+ $country = array( $c, '<div class="cpd-flag cpd-flag-'.$c.'" title="'.$cname.'"></div>', $cname );
36
  return $country;
37
  }
38
 
55
  foreach ($res as $r)
56
  {
57
  $c = '';
58
+ if ( strpos($r->realip,'.') !== false && strpos($r->realip,':') === false)
59
+ {
60
+ // IPv4
61
+ $ip = explode('.', $r->realip);
62
+ if ( $ip[0] == 10
63
+ || $ip[0] == 127
64
+ || ($ip[0] == 169 && $ip[1] == 254)
65
+ || ($ip[0] == 172 && $ip[1] >= 16 && $ip[1] <= 31)
66
+ || ($ip[0] == 192 && $ip[1] == 168) )
67
+ // set local IPs to '-'
68
+ $c = '-';
69
+ else
70
+ // get country
71
+ $c = strtolower(cpd_geoip_country_code_by_addr_v6($gi, '::'.$r->realip));
72
+ }
73
  else
74
+ {
75
+ // IPv6
76
+ if ( strpos($r->realip, '::1') === 0
77
+ || strpos($r->realip, 'fc00::') === 0
78
+ )
79
+ // set local IPs to '-'
80
+ $c = '-';
81
+ else
82
+ // get country
83
+ $c = strtolower(cpd_geoip_country_code_by_addr_v6($gi, $r->realip));
84
+ }
85
 
86
  if ( !empty($c) )
87
  $count_per_day->mysqlQuery('', "UPDATE $wpdb->cpd_counter SET country = '$c' WHERE ip = '$r->ip'", 'GeoIP updateDB '.__LINE__);
108
  if ( !function_exists('gzopen') )
109
  return __('Sorry, necessary functions (zlib) not installed or enabled in php.ini.', 'cpd');
110
 
111
+ // $gzfile = 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz';
112
+ $gzfile = 'http://geolite.maxmind.com/download/geoip/database/GeoIPv6.dat.gz';
113
  $file = $cpd_path.'/geoip/GeoIP.dat';
114
 
115
  // get remote file
138
 
139
 
140
  }
 
img/cpd_flags.png CHANGED
Binary file
locale/cpd-sr_RS.mo ADDED
Binary file
locale/cpd-sr_RS.po ADDED
@@ -0,0 +1,1119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Count Per Day\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2008-11-02 12:13+0100\n"
6
+ "PO-Revision-Date: 2013-04-13 12:52+0100\n"
7
+ "Last-Translator: Diana <diana@wpdiscounts.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
13
+ "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
16
+ "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
+ "X-Poedit-Basepath: P:/xampp/htdocs/wp/wp-content/plugins/count-per-day\n"
18
+ "X-Textdomain-Support: yes\n"
19
+ "Language: sr_RS\n"
20
+ "X-Generator: Poedit 1.5.5\n"
21
+ "X-Poedit-SearchPath-0: .\n"
22
+
23
+ # @ cpd
24
+ #: Copy of counter-options.php:50 counter-options.php:52
25
+ msgid "Options updated"
26
+ msgstr "Opcije azurirane "
27
+
28
+ # @ cpd
29
+ #: Copy of counter-options.php:111 counter-options.php:113
30
+ #, php-format
31
+ msgid "Database cleaned. %s rows deleted."
32
+ msgstr "Baza podataka ociscena. %s redova izbrisano"
33
+
34
+ # @ cpd
35
+ #: Copy of counter-options.php:126 counter-options.php:839
36
+ #: counter-options.php:128 counter-options.php:693
37
+ msgid "UNINSTALL Count per Day"
38
+ msgstr "DEINSTALIRANJE broj po danu"
39
+
40
+ # @ cpd
41
+ #: Copy of counter-options.php:131 counter-options.php:132
42
+ #: counter-options.php:133 counter-options.php:134 counter-options.php:135
43
+ #, php-format
44
+ msgid "Table %s deleted"
45
+ msgstr "Tabla %s izbrisana"
46
+
47
+ # @ cpd
48
+ #: Copy of counter-options.php:134 counter-options.php:136
49
+ msgid "Options deleted"
50
+ msgstr "Opcije izbrisane"
51
+
52
+ # @ cpd
53
+ #: Copy of counter-options.php:321 counter-options.php:825
54
+ #: counter-options.php:362 counter-options.php:679
55
+ msgid "Uninstall"
56
+ msgstr "Deinstalirati"
57
+
58
+ # @ cpd
59
+ #: Copy of counter-options.php:322 counter-options.php:363
60
+ msgid "Click here"
61
+ msgstr "Kliknite ovde"
62
+
63
+ # @ cpd
64
+ #: Copy of counter-options.php:322 counter-options.php:363
65
+ msgid "to finish the uninstall and to deactivate \"Count per Day\"."
66
+ msgstr "Da bi zavrsili deinstaliranje i aktivirali \"Brojanje po danu\"."
67
+
68
+ # @ cpd
69
+ #: Copy of counter-options.php:359 counter-options.php:726
70
+ msgid "Online time"
71
+ msgstr "Vreme online"
72
+
73
+ # @ cpd
74
+ #: Copy of counter-options.php:360 counter-options.php:727
75
+ msgid ""
76
+ "Seconds for online counter. Used for \"Visitors online\" on dashboard page."
77
+ msgstr ""
78
+ "Sekunde online kauntera. Koricseno za \"Posetioci online\" na strani "
79
+ "kontrolna tabla "
80
+
81
+ # @ cpd
82
+ #: Copy of counter-options.php:363 counter-options.php:730
83
+ msgid "Logged on Users"
84
+ msgstr "Ulogovani korisnici"
85
+
86
+ # @ cpd
87
+ #: Copy of counter-options.php:365 counter-options.php:732
88
+ msgid "count too"
89
+ msgstr "Brojanje takodje"
90
+
91
+ # @ cpd
92
+ #: Copy of counter-options.php:377 counter-options.php:744
93
+ msgid "Auto counter"
94
+ msgstr "Auto brojanje"
95
+
96
+ # @ cpd
97
+ #: Copy of counter-options.php:378 counter-options.php:745
98
+ msgid ""
99
+ "Counts automatically single-posts and pages, no changes on template needed."
100
+ msgstr ""
101
+ "Broji automatski samostalne postove i stranice, nisu potrebne izmene sablona"
102
+
103
+ # @ cpd
104
+ #: Copy of counter-options.php:381 counter-options.php:748
105
+ msgid "Bots to ignore"
106
+ msgstr "Botovi za ignorisanje"
107
+
108
+ # @ cpd
109
+ #: Copy of counter-options.php:559 counter-options.php:926
110
+ msgid "Update options"
111
+ msgstr "Azuriraj opcije "
112
+
113
+ # @ cpd
114
+ #: Copy of counter-options.php:685 counter-options.php:694
115
+ #: counter-options.php:540 counter-options.php:548
116
+ msgid "Clean the database"
117
+ msgstr "Ocisti bazu podataka"
118
+
119
+ # @ cpd
120
+ #: Copy of counter-options.php:688 counter-options.php:543
121
+ msgid ""
122
+ "You can clean the counter table by delete the \"spam data\".<br />If you add "
123
+ "new bots above the old \"spam data\" keeps in the database.<br />Here you "
124
+ "can run the bot filter again and delete the visits of the bots."
125
+ msgstr ""
126
+ "Mozete izbrisati tablu brojaca brisanjem e \"spam data\".<br />Ukoliko "
127
+ "dodate nove botoce izned starih \"spam data\" se zadrzava u bazi podataka. "
128
+ "<br /> Ovde mozete pokrenuti bot filter ponovo i izbrisati posete botova"
129
+
130
+ # @ cpd
131
+ #: Copy of counter-options.php:828 counter-options.php:682
132
+ msgid ""
133
+ "If \"Count per Day\" only disabled the tables in the database will be "
134
+ "preserved."
135
+ msgstr ""
136
+ "Ukoliko \"Brojac po danu\" bude samo onesposobljen table u bazi podataka ce "
137
+ "biti sacuvane "
138
+
139
+ # @ cpd
140
+ #: Copy of counter-options.php:829 counter-options.php:683
141
+ msgid "Here you can delete the tables and disable \"Count per Day\"."
142
+ msgstr "Ovde mozete izbrisati table i onesposobiti \"Brojac po danu\"."
143
+
144
+ # @ cpd
145
+ #: Copy of counter-options.php:832 counter-options.php:686
146
+ msgid "WARNING"
147
+ msgstr "UPOZORENJE"
148
+
149
+ # @ cpd
150
+ #: Copy of counter-options.php:833 counter-options.php:687
151
+ msgid "These tables (with ALL counter data) will be deleted."
152
+ msgstr "Ove table (sa svim podacima brojanja) bice izbrisane"
153
+
154
+ # @ cpd
155
+ #: Copy of counter-options.php:835 counter-options.php:689
156
+ msgid "If \"Count per Day\" re-installed, the counter starts at 0."
157
+ msgstr "Ako je \"brojac po danu\" reinstaliran, brojac pocinje od 0. "
158
+
159
+ # @ cpd
160
+ #: Copy of counter-options.php:815 counter-options.php:838
161
+ #: counter-options.php:669 counter-options.php:692
162
+ msgid "Yes"
163
+ msgstr "Da"
164
+
165
+ # @ cpd
166
+ #: Copy of counter-options.php:839 counter-options.php:693
167
+ msgid "You are sure to disable Count per Day and delete all data?"
168
+ msgstr ""
169
+ "Sigurni ste da zelite da onesposobiti Brojac po danu i izbrisete sve "
170
+ "podatke? "
171
+
172
+ # @ cpd
173
+ #: counter-core.php:844 counter.php:1232
174
+ msgid "Statistics"
175
+ msgstr "Statistike "
176
+
177
+ # @ cpd
178
+ #: counter-core.php:812 counter.php:190 counter.php:1118 counter.php:1310
179
+ msgid "Total visitors"
180
+ msgstr "Ukupno poseta"
181
+
182
+ # @ cpd
183
+ #: counter.php:191 counter.php:1316
184
+ msgid "Visitors currently online"
185
+ msgstr "Posetioci trenutno online"
186
+
187
+ # @ cpd
188
+ #: counter.php:192 counter.php:1311
189
+ msgid "Visitors today"
190
+ msgstr "Posetioci danas"
191
+
192
+ # @ cpd
193
+ #: counter.php:193 counter.php:1312
194
+ msgid "Visitors yesterday"
195
+ msgstr "Posetioci juce"
196
+
197
+ # @ cpd
198
+ #: counter.php:194 counter.php:1313
199
+ msgid "Visitors last week"
200
+ msgstr "Posetioci prosle nedelje"
201
+
202
+ # @ cpd
203
+ #: counter.php:197 counter.php:877 counter.php:1317
204
+ msgid "Counter starts on"
205
+ msgstr "Projac pocinje"
206
+
207
+ # @ cpd
208
+ #: counter-core.php:818 counter.php:196 counter.php:295 counter.php:1120
209
+ #: counter.php:1315 userperspan.php:34
210
+ msgid "Visitors per day"
211
+ msgstr "Posetioca po danu"
212
+
213
+ # @ cpd
214
+ #: counter-core.php:814 counter.php:1314
215
+ msgid "Visitors per month"
216
+ msgstr "Posetioca po mesecu "
217
+
218
+ # @ cpd
219
+ #: Copy of counter-options.php:441 counter-core.php:816
220
+ #: counter-options.php:808
221
+ msgid "Visitors per post"
222
+ msgstr "Posetioca po postu "
223
+
224
+ # @ cpd
225
+ #: Copy of counter-options.php:121 counter-options.php:123
226
+ msgid "Counter reseted."
227
+ msgstr "Brojac resetovan "
228
+
229
+ # @ cpd
230
+ #: Copy of counter-options.php:442 counter-options.php:446
231
+ #: counter-options.php:809 counter-options.php:813
232
+ msgid "How many posts do you want to see on dashboard page?"
233
+ msgstr "Koliko postova zelite da vidite na kontrolnoj tabli? "
234
+
235
+ # @ cpd
236
+ #: Copy of counter-options.php:445 counter-options.php:812
237
+ msgid "Latest Counts - Posts"
238
+ msgstr "Najnoviji brojaci - Postovi "
239
+
240
+ # @ cpd
241
+ #: Copy of counter-options.php:449 counter-options.php:816
242
+ msgid "Latest Counts - Days"
243
+ msgstr "Najnoviji brojaci - Dani"
244
+
245
+ # @ cpd
246
+ #: Copy of counter-options.php:450 counter-options.php:454
247
+ #: counter-options.php:476 counter-options.php:817 counter-options.php:821
248
+ #: counter-options.php:843
249
+ msgid "How many days do you want look back?"
250
+ msgstr "Koliko dana unazad zelite da pogledate? "
251
+
252
+ # @ cpd
253
+ #: Copy of counter-options.php:490 counter-options.php:857
254
+ msgid "Show in lists"
255
+ msgstr "POkazi u listama"
256
+
257
+ # @ cpd
258
+ #: Copy of counter-options.php:491 counter-options.php:858
259
+ msgid "Show \"Reads per Post\" in a new column in post management views."
260
+ msgstr ""
261
+ "Pokazi \"Citanja po Postu\" u novoj koloni u upravljanju pogleda posta"
262
+
263
+ # @ cpd
264
+ #: Copy of counter-options.php:806 counter-options.php:816
265
+ #: counter-options.php:660 counter-options.php:670
266
+ msgid "Reset the counter"
267
+ msgstr "Resetuj brojac"
268
+
269
+ # @ cpd
270
+ #: Copy of counter-options.php:809 counter-options.php:663
271
+ msgid ""
272
+ "You can reset the counter by empty the table. ALL TO 0!<br />Make a backup "
273
+ "if you need the current data!"
274
+ msgstr ""
275
+ "Mozete resetovati brojac praznjenjem table. SVE ZA 0!<br /> Napravite "
276
+ "rezervnu kopiju ukoliko vam trebaju trenutni podaci "
277
+
278
+ # @ cpd
279
+ #: counter.php:708
280
+ #, php-format
281
+ msgid "The %s most visited posts in last %s days:"
282
+ msgstr "%s najposeceniji postovi u poslednjih %s dana"
283
+
284
+ # @ default
285
+ #: Copy of counter-options.php:346 counter-options.php:563
286
+ #: counter-core.php:649 counter-options.php:386 counter-options.php:714
287
+ msgid "Settings"
288
+ msgstr "Podesavanja"
289
+
290
+ # @ cpd
291
+ #: Copy of counter-options.php:396 counter-core.php:714
292
+ #: counter-options.php:763 counter.php:189 counter.php:927
293
+ msgid "Reads"
294
+ msgstr "Citanja"
295
+
296
+ # @ cpd
297
+ #: counter-core.php:817
298
+ msgid "Latest Counts"
299
+ msgstr "Poslednji brojaci "
300
+
301
+ # @ cpd
302
+ #: Copy of counter-options.php:453 counter-options.php:820
303
+ msgid "Chart - Days"
304
+ msgstr "Grafikon - Dani"
305
+
306
+ # @ cpd
307
+ #: Copy of counter-options.php:457 counter-options.php:824
308
+ msgid "Chart - Height"
309
+ msgstr "Grafikon - Visina"
310
+
311
+ # @ cpd
312
+ #: Copy of counter-options.php:458 counter-options.php:825
313
+ msgid "Height of the biggest bar"
314
+ msgstr "Visina najviseg bara"
315
+
316
+ # @ cpd
317
+ #: counter.php:1304
318
+ msgid "This post"
319
+ msgstr "Ovaj post"
320
+
321
+ # @ default
322
+ #: Copy of counter-options.php:406 counter-options.php:773
323
+ msgid "Dashboard"
324
+ msgstr "KOntrolna tabla"
325
+
326
+ # @ cpd
327
+ #: counter.php:294
328
+ msgid "Reads per day"
329
+ msgstr "Citanja po danu "
330
+
331
+ # @ cpd
332
+ #: Copy of counter-options.php:61 counter-options.php:63
333
+ #, php-format
334
+ msgid "Countries updated. <b>%s</b> entries in %s without country left"
335
+ msgstr "Zemlje azurirane. <b>%s</b> unosa u %s bez ostale zemlje "
336
+
337
+ # @ cpd
338
+ #: Copy of counter-options.php:64 counter-options.php:66
339
+ msgid "update next"
340
+ msgstr "Azuriraj sledece"
341
+
342
+ # @ cpd
343
+ #: Copy of counter-options.php:756 counter-options.php:610
344
+ msgid "GeoIP - Countries"
345
+ msgstr "GeoIP - Zemlje "
346
+
347
+ # @ cpd
348
+ #: Copy of counter-options.php:765 counter-options.php:619
349
+ msgid "Update old counter data"
350
+ msgstr "Azuriraj stare podatke brojaca"
351
+
352
+ # @ cpd
353
+ #: Copy of counter-options.php:777 counter-options.php:631
354
+ msgid "Update GeoIP database"
355
+ msgstr "Azuriraj GeoIP bazu podataka"
356
+
357
+ # @ cpd
358
+ #: Copy of counter-options.php:772 counter-options.php:626
359
+ msgid "Download a new version of GeoIP.dat file."
360
+ msgstr "SKini novu verziju GeoIP.dat fajla"
361
+
362
+ # @ cpd
363
+ #: Copy of counter-options.php:782 counter-options.php:636
364
+ msgid "More informations about GeoIP"
365
+ msgstr "Vise informacija o GeoIP"
366
+
367
+ # @ cpd
368
+ #: counter-core.php:828
369
+ msgid "Reads per Country"
370
+ msgstr "Citanja po zemlji "
371
+
372
+ # @ cpd
373
+ #: geoip/geoip.php:114
374
+ msgid "New GeoIP database installed."
375
+ msgstr "Nova GeoIP baza podataka instalirana"
376
+
377
+ # @ cpd
378
+ #: geoip/geoip.php:116
379
+ msgid ""
380
+ "Sorry, an error occurred. Try again or check the access rights of directory "
381
+ "\"geoip\" is 777."
382
+ msgstr ""
383
+ "Izvinite, doslo je do greske. Pokusajte ponovo ili proverite prava pristupa "
384
+ "direktorijumu \"geoip\" je 777."
385
+
386
+ # @ cpd
387
+ #: geoip/geoip.php:90
388
+ msgid "Sorry, necessary functions (zlib) not installed or enabled in php.ini."
389
+ msgstr ""
390
+ "Izvinite, neophodne funkcije (zlib) nisu instalirate ili omogucene u php.ini"
391
+
392
+ # @ cpd
393
+ #: Copy of counter-options.php:462 counter-options.php:829
394
+ msgid "Countries"
395
+ msgstr "Zemlje"
396
+
397
+ # @ cpd
398
+ #: Copy of counter-options.php:463 counter-options.php:830
399
+ msgid "How many countries do you want to see on dashboard page?"
400
+ msgstr "Koliko zemalja zelite da vidite na kontrolnoj tabli? "
401
+
402
+ # @ cpd
403
+ #: Copy of counter-options.php:104 counter-options.php:106
404
+ #, php-format
405
+ msgid "Mass Bots cleaned. %s counts deleted."
406
+ msgstr "Mass Botoci ocisceni. %s zemlje izbrisane"
407
+
408
+ # @ cpd
409
+ #: Copy of counter-options.php:578 counter-options.php:402 massbots.php:36
410
+ msgid "Mass Bots"
411
+ msgstr "Mass botovi "
412
+
413
+ # @ cpd
414
+ #: Copy of counter-options.php:582 counter-options.php:406
415
+ #, php-format
416
+ msgid "Show all IPs with more than %s page views per day"
417
+ msgstr "Pokazi sve IP sa vise od %s pogleda po danu "
418
+
419
+ # @ cpd
420
+ #: Copy of counter-options.php:583 counter-options.php:407 notes.php:71
421
+ #: userperspan.php:44
422
+ msgid "show"
423
+ msgstr "pokazi "
424
+
425
+ # @ cpd
426
+ #: Copy of counter-options.php:609 counter-options.php:625
427
+ #: counter-options.php:433 counter-options.php:449
428
+ #, php-format
429
+ msgid "Delete these %s counts"
430
+ msgstr "Izbrisi ove %s brojace"
431
+
432
+ # @ cpd
433
+ #: counter.php:865
434
+ msgid "Other"
435
+ msgstr "druge"
436
+
437
+ # @ default
438
+ #: counter.php:1054 massbots.php:53 userperspan.php:63
439
+ msgid "Front page displays"
440
+ msgstr "Displej naslovne stranice "
441
+
442
+ # @ cpd
443
+ #: Copy of counter-options.php:467 counter-core.php:823
444
+ #: counter-options.php:834
445
+ msgid "Browsers"
446
+ msgstr "Pretrazivaci "
447
+
448
+ # @ cpd
449
+ #: Copy of counter-options.php:591 counter-options.php:415
450
+ msgid "IP"
451
+ msgstr "IP"
452
+
453
+ # @ cpd
454
+ # @ default
455
+ #: Copy of counter-options.php:592 counter-options.php:416 notes.php:75
456
+ msgid "Date"
457
+ msgstr "Datum"
458
+
459
+ # @ cpd
460
+ #: Copy of counter-options.php:593 counter-options.php:417
461
+ msgid "Client"
462
+ msgstr "Klijent"
463
+
464
+ # @ cpd
465
+ #: Copy of counter-options.php:594 counter-options.php:418
466
+ msgid "Views"
467
+ msgstr "Pogledi "
468
+
469
+ # @ cpd
470
+ #: Copy of counter-options.php:498 counter-options.php:865
471
+ msgid "Start Values"
472
+ msgstr "Pocetne vrednosti "
473
+
474
+ # @ cpd
475
+ #: Copy of counter-options.php:502 counter-options.php:869
476
+ msgid "Here you can change the date of first count and add a start count."
477
+ msgstr "Ovde mozete promeniti datum prvog brojanja i dodati startno brojanje"
478
+
479
+ # @ cpd
480
+ #: Copy of counter-options.php:506 counter-options.php:873
481
+ msgid "Start date"
482
+ msgstr "Pocetni datum"
483
+
484
+ # @ cpd
485
+ #: Copy of counter-options.php:507 counter-options.php:874
486
+ msgid "Your old Counter starts at?"
487
+ msgstr "Vas stari brojac pocinje na? "
488
+
489
+ # @ cpd
490
+ #: Copy of counter-options.php:510 counter-options.php:514
491
+ #: counter-options.php:877 counter-options.php:881
492
+ msgid "Start count"
493
+ msgstr "Pocni brojanje"
494
+
495
+ # @ cpd
496
+ #: Copy of counter-options.php:511 counter-options.php:878
497
+ msgid "Add this value to \"Total visitors\"."
498
+ msgstr "Dodaj ovu vrednost u \"Ukupni posetioci\""
499
+
500
+ # @ cpd
501
+ #: Copy of counter-options.php:743 counter-options.php:701
502
+ msgid "Support"
503
+ msgstr "Podrska"
504
+
505
+ # @ cpd
506
+ #: counter-core.php:778
507
+ msgid "Bug? Problem? Question? Hint? Praise?"
508
+ msgstr "Bag? Problem? Pitanje? Savet? Pohvala?"
509
+
510
+ # @ cpd
511
+ #: counter-core.php:779
512
+ #, php-format
513
+ msgid "Write a comment on the <a href=\"%s\">plugin page</a>."
514
+ msgstr "Napisite komentar o <a href=\"%s\">plagin strana</a>."
515
+
516
+ # @ default
517
+ #: counter.php:824
518
+ msgid "Show"
519
+ msgstr "Pokazi "
520
+
521
+ # @ default
522
+ #: counter.php:1039
523
+ msgid "Edit Post"
524
+ msgstr "Izmeni postove "
525
+
526
+ # @ cpd
527
+ #: counter-core.php:777
528
+ #, php-format
529
+ msgid "Time for Count per Day: <code>%s</code>."
530
+ msgstr "Vreme za brojac po danu: <code>%s</code>."
531
+
532
+ # @ cpd
533
+ #: Copy of counter-options.php:366 counter-options.php:733
534
+ msgid "until User Level"
535
+ msgstr "Jedinica nivoa korisnika "
536
+
537
+ # @ default
538
+ #: counter-core.php:820
539
+ msgid "Plugin"
540
+ msgstr "Plagin"
541
+
542
+ # @ cpd
543
+ #: counter.php:826 notes.php:42 notes.php:76
544
+ msgid "Notes"
545
+ msgstr "Beleske"
546
+
547
+ # @ default
548
+ #: notes.php:77
549
+ msgid "Action"
550
+ msgstr "Akcija"
551
+
552
+ # @ cpd
553
+ #: notes.php:82
554
+ msgid "add"
555
+ msgstr "Dodaj"
556
+
557
+ # @ cpd
558
+ #: notes.php:98
559
+ msgid "save"
560
+ msgstr "sacuvaj"
561
+
562
+ # @ cpd
563
+ #: notes.php:99
564
+ msgid "delete"
565
+ msgstr "izbrisi "
566
+
567
+ # @ cpd
568
+ #: notes.php:110
569
+ msgid "edit"
570
+ msgstr "izmeni"
571
+
572
+ # @ cpd
573
+ #: Copy of counter-options.php:515 counter-options.php:882
574
+ msgid "Add this value to \"Total reads\"."
575
+ msgstr "Dodaj ovu vrednost u \"Ukupni pregledi\"."
576
+
577
+ # @ cpd
578
+ #: counter.php:185 counter.php:1305
579
+ msgid "Total reads"
580
+ msgstr "Ukupni pregledi "
581
+
582
+ # @ cpd
583
+ #: counter.php:186 counter.php:1306
584
+ msgid "Reads today"
585
+ msgstr "Pregledi danas"
586
+
587
+ # @ cpd
588
+ #: counter.php:187 counter.php:1307
589
+ msgid "Reads yesterday"
590
+ msgstr "Pregledi juce"
591
+
592
+ # @ cpd
593
+ #: counter.php:385 counter.php:1149
594
+ msgid "Map"
595
+ msgstr "Mapa"
596
+
597
+ # @ cpd
598
+ #: Copy of counter-options.php:385 counter-options.php:752
599
+ msgid "Anonymous IP"
600
+ msgstr "Anonimni IP"
601
+
602
+ # @ cpd
603
+ #: Copy of counter-options.php:389 counter-options.php:756
604
+ msgid "Cache"
605
+ msgstr "Kes"
606
+
607
+ # @ cpd
608
+ #: Copy of counter-options.php:390 counter-options.php:757
609
+ msgid "I use a cache plugin. Count these visits with ajax."
610
+ msgstr "Koristim plagin za kes. Prebroj ove posete uz pomoc ajaxa."
611
+
612
+ # @ cpd
613
+ #: Copy of counter-options.php:468 counter-options.php:835
614
+ msgid "Substring of the user agent, separated by comma"
615
+ msgstr "Podred agenta korisnika, razdvojen zapetom "
616
+
617
+ # @ cpd
618
+ #: counter-core.php:829
619
+ msgid "Visitors per Country"
620
+ msgstr "Posetioca po zemlji "
621
+
622
+ # @ cpd
623
+ #: Copy of counter-options.php:552 counter-options.php:919
624
+ msgid "Debug mode"
625
+ msgstr "Debug mod"
626
+
627
+ # @ cpd
628
+ #: Copy of counter-options.php:554 counter-options.php:921
629
+ msgid "Show debug informations at the bottom of all pages."
630
+ msgstr "Pokazi debug informacije na dnu ove strane "
631
+
632
+ # @ cpd
633
+ #: userperspan.php:38
634
+ msgid "Start"
635
+ msgstr "Start"
636
+
637
+ # @ cpd
638
+ #: userperspan.php:40
639
+ msgid "End"
640
+ msgstr "Kraj"
641
+
642
+ # @ cpd
643
+ #: userperspan.php:42
644
+ msgid "PostID"
645
+ msgstr "PostID "
646
+
647
+ # @ cpd
648
+ #: userperspan.php:50
649
+ msgid "no data found"
650
+ msgstr "Nema pronadjenih podataka"
651
+
652
+ # @ cpd
653
+ #: Copy of counter-options.php:759 counter-options.php:613
654
+ msgid ""
655
+ "You can get the country data for all entries in database by checking the IP "
656
+ "adress against the GeoIP database. This can take a while!"
657
+ msgstr ""
658
+ "Mozete dobiti podatke o zemlji za sve unose u bazi podataka proveravanjem IP "
659
+ "adrese iz GeoIP baze podataka. Ovo moze malo potrajati. "
660
+
661
+ # @ cpd
662
+ #: Copy of counter-options.php:355 counter-options.php:722
663
+ msgid "Counter"
664
+ msgstr "Brojac"
665
+
666
+ # @ cpd
667
+ #: Copy of counter-options.php:479 counter-options.php:846
668
+ msgid "Local URLs"
669
+ msgstr "Lokalno URL"
670
+
671
+ # @ cpd
672
+ #: Copy of counter-options.php:480 counter-options.php:847
673
+ msgid "Show local referrers too."
674
+ msgstr "Pokazi lokalne reference takodje"
675
+
676
+ # @ default
677
+ #: Copy of counter-options.php:487 counter-options.php:854
678
+ msgid "Posts"
679
+ msgstr "Postovi "
680
+
681
+ # @ default
682
+ #: Copy of counter-options.php:487 counter-options.php:854
683
+ msgid "Pages"
684
+ msgstr "Stranice"
685
+
686
+ # @ default
687
+ #: counter.php:1048
688
+ msgid "Category"
689
+ msgstr "Kategorije"
690
+
691
+ # @ default
692
+ #: counter.php:1051
693
+ msgid "Tag"
694
+ msgstr "Tagovi"
695
+
696
+ # @ default
697
+ #: counter-core.php:780
698
+ msgid "License"
699
+ msgstr "Dozvole "
700
+
701
+ # @ cpd
702
+ #: counter-core.php:824
703
+ msgid "Referrer"
704
+ msgstr "Reference "
705
+
706
+ # @ default
707
+ #: counter.php:1328
708
+ msgid "Title"
709
+ msgstr "Naslov"
710
+
711
+ # @ cpd
712
+ #: Copy of counter-options.php:396 counter-options.php:763
713
+ msgid ""
714
+ "Save and show clients and referrers.<br />Needs a lot of space in the "
715
+ "database but gives you more detailed informations of your visitors."
716
+ msgstr ""
717
+ "Sacuvaj i pokazi klijente i reference. <br /> Treba puno mesta u bazi "
718
+ "podataka ali dobijate mnogo detaljnije informacije o vasim posetiocima "
719
+
720
+ # @ cpd
721
+ #: Copy of counter-options.php:393 counter-options.php:760
722
+ msgid "Clients and referrers"
723
+ msgstr "Klijenti i reference"
724
+
725
+ # @ cpd
726
+ #: counter.php:188 counter.php:1308
727
+ msgid "Reads last week"
728
+ msgstr "Citanja prosle nedelje"
729
+
730
+ # @ cpd
731
+ #: counter-core.php:815 counter.php:1309
732
+ msgid "Reads per month"
733
+ msgstr "Citanja po mesecu "
734
+
735
+ # @ cpd
736
+ #: Copy of counter-options.php:471 counter-options.php:838
737
+ msgid "Referrers - Entries"
738
+ msgstr "Reference - unosi"
739
+
740
+ # @ cpd
741
+ #: Copy of counter-options.php:472 counter-options.php:839
742
+ msgid "How many referrers do you want to see on dashboard page?"
743
+ msgstr "Koliko referenci zelite videti na kontrolnoj tabli?"
744
+
745
+ # @ cpd
746
+ #: Copy of counter-options.php:475 counter-options.php:842
747
+ msgid "Referrers - Days"
748
+ msgstr "Reference - Dani "
749
+
750
+ # @ cpd
751
+ #: counter.php:897
752
+ #, php-format
753
+ msgid "The %s referrers in last %s days:"
754
+ msgstr "%s reference u zadnjih %s dana "
755
+
756
+ # @ cpd
757
+ #: counter-core.php:813
758
+ msgid "Visitors online"
759
+ msgstr "Posetioci online"
760
+
761
+ # @ cpd
762
+ #: Copy of counter-options.php:522 counter-options.php:889
763
+ msgid "Stylesheet"
764
+ msgstr "Stil prikaza"
765
+
766
+ # @ cpd
767
+ #: Copy of counter-options.php:525 counter-options.php:892
768
+ msgid "NO Stylesheet in Frontend"
769
+ msgstr "Nema stila prikaza u Frontendu"
770
+
771
+ # @ cpd
772
+ #: Copy of counter-options.php:526 counter-options.php:893
773
+ msgid "Do not load the stylesheet \"counter.css\" in frontend."
774
+ msgstr "nemojte ucitavati stil prikaza \"counter.css\" u frontendu "
775
+
776
+ # @ cpd
777
+ #: Copy of counter-options.php:422 counter-options.php:789
778
+ msgid "Who can see it"
779
+ msgstr "Ko moze videti "
780
+
781
+ # @ cpd
782
+ #: Copy of counter-options.php:431 counter-options.php:798
783
+ msgid "custom"
784
+ msgstr "prilagodjen"
785
+
786
+ # @ cpd
787
+ #: Copy of counter-options.php:433 counter-options.php:800
788
+ msgid "and higher are allowed to see the statistics page."
789
+ msgstr "i vise mogu videti stranicu sa statistikama"
790
+
791
+ # @ cpd
792
+ #: Copy of counter-options.php:435 counter-options.php:802
793
+ #, php-format
794
+ msgid "Set the %s capability %s a user need:"
795
+ msgstr "Podesi %s sposobnost %s posetiocu treba:"
796
+
797
+ # @ cpd
798
+ #: counter-core.php:252
799
+ #, php-format
800
+ msgid "\"Count per Day\" updated to version %s."
801
+ msgstr "\"brojac po danu\" azuriran na verziju %s"
802
+
803
+ # @ cpd
804
+ #: counter-core.php:1016
805
+ msgid "Backup failed! Cannot open file"
806
+ msgstr "Bekap neuspesan! Ne mogu otvoriti fajl"
807
+
808
+ # @ cpd
809
+ #: counter-core.php:1042
810
+ #, php-format
811
+ msgid "Backup of %s entries in progress. Every point complies %s entries."
812
+ msgstr "Bekap %s unosa je u toku. Svaka tacka oznacava %s unos"
813
+
814
+ # @ cpd
815
+ #: counter-core.php:1133 counter-core.php:1141
816
+ #, php-format
817
+ msgid "Backup of counter table saved in %s."
818
+ msgstr "Bekap table brojaca sacuvan na %s"
819
+
820
+ # @ cpd
821
+ #: counter-core.php:1135 counter-core.php:1143
822
+ #, php-format
823
+ msgid "Backup of counter options and collection saved in %s."
824
+ msgstr "Bekap opcija brojaca i kolekcije sacuvan na %s."
825
+
826
+ # @ cpd
827
+ #: Copy of counter-options.php:169
828
+ msgid "Collection in progress..."
829
+ msgstr "Kolekcija u toku..."
830
+
831
+ # @ cpd
832
+ #: Copy of counter-options.php:245 counter-options.php:263
833
+ msgid "Get Visitors per Post..."
834
+ msgstr "Dobijte posetioce po postu"
835
+
836
+ # @ cpd
837
+ #: Copy of counter-options.php:266 counter-options.php:284
838
+ msgid "Delete old data..."
839
+ msgstr "Izbirsi stare podatke"
840
+
841
+ # @ cpd
842
+ #: Copy of counter-options.php:290 counter-options.php:308
843
+ #, php-format
844
+ msgid ""
845
+ "Counter entries until %s collected and counter table %s optimized (size "
846
+ "before = %s &gt; size after = %s)."
847
+ msgstr ""
848
+ "Unosi brojaca do %s sakupljeni i tabla brojaca %s optimizirana (velicina "
849
+ "pre = %s &gt; velicina posle= %s)."
850
+
851
+ # @ cpd
852
+ #: Copy of counter-options.php:299 counter-options.php:317
853
+ msgid "Installation of \"Count per Day\" checked"
854
+ msgstr "Instalacija \"Brojac po Danu\" proverena"
855
+
856
+ # @ default
857
+ #: Copy of counter-options.php:347 counter-options.php:564
858
+ #: counter-options.php:385 counter-options.php:713
859
+ msgid "Tools"
860
+ msgstr "Alati"
861
+
862
+ # @ cpd
863
+ #: Copy of counter-options.php:398 counter-options.php:765
864
+ msgid "Save URL only, no query string."
865
+ msgstr "Sacuvaj samo URL bez reda za ispitivanje"
866
+
867
+ # @ cpd
868
+ #: Copy of counter-options.php:533 counter-options.php:637
869
+ #: counter-options.php:461 counter-options.php:900
870
+ msgid "Backup"
871
+ msgstr "Bekap"
872
+
873
+ # @ cpd
874
+ #: Copy of counter-options.php:536 counter-options.php:903
875
+ msgid "Entries per pass"
876
+ msgstr "Unosi po pass-u"
877
+
878
+ # @ cpd
879
+ #: Copy of counter-options.php:539 counter-options.php:906
880
+ msgid "How many entries should be saved per pass? Default: 10000"
881
+ msgstr ""
882
+ "Koliko unosa bi trebalo da bude sacuvano po pass-u? Predodredjeno: 10000"
883
+
884
+ # @ cpd
885
+ #: Copy of counter-options.php:544 counter-options.php:911
886
+ msgid ""
887
+ "If your PHP memory limit less then 50 MB and you get a white page or error "
888
+ "messages try a smaller value."
889
+ msgstr ""
890
+ "Ako je limit vase PHP memorije manji od 50MB i dobijete belu stranicu ili "
891
+ "poruke s greskom probajte manju vrednost"
892
+
893
+ # @ cpd
894
+ #: Copy of counter-options.php:641 counter-options.php:465
895
+ #, php-format
896
+ msgid ""
897
+ "Create a backup of the counter table %s in your wp-content directory (if "
898
+ "writable)."
899
+ msgstr ""
900
+ "Kreirajte bekap table brojaca %s u vasem wp-sadrzaj direktorijumu (ukoliko "
901
+ "je upisiv)"
902
+
903
+ # @ cpd
904
+ #: Copy of counter-options.php:648 counter-options.php:472
905
+ msgid "Backup the database"
906
+ msgstr "Kreiraj bekap baze podataka"
907
+
908
+ # @ cpd
909
+ #: Copy of counter-options.php:703 counter-options.php:735
910
+ #: counter-options.php:565 counter-options.php:597
911
+ msgid "Collect old data"
912
+ msgstr "Sakupi stare podatke"
913
+
914
+ # @ cpd
915
+ #: Copy of counter-options.php:708 counter-options.php:570
916
+ #, php-format
917
+ msgid "Current size of your counter table %s is %s."
918
+ msgstr "Trenutna velicine vase table brojaca %s je %s"
919
+
920
+ # @ cpd
921
+ #: Copy of counter-options.php:710 counter-options.php:572
922
+ msgid ""
923
+ "You can collect old data and clean up the counter table.<br/>Reads and "
924
+ "visitors will be saved per month, per country and per post.<br/>Clients and "
925
+ "referrers will deleted."
926
+ msgstr ""
927
+ "Mozete da sakupite podatke i ocistite tablu brojaca. <br/> Citanja i "
928
+ "posetioci ce biti sacuvani po mesecu, po zemlji i po postu. <br/> Klijenti i "
929
+ "reference ce biti izbrisane"
930
+
931
+ # @ cpd
932
+ #: Copy of counter-options.php:715 counter-options.php:577
933
+ #, php-format
934
+ msgid "Currently your collection contains data until %s."
935
+ msgstr "Trenutno vasa kolekcija sadrzi podatke do %s"
936
+
937
+ # @ cpd
938
+ #: Copy of counter-options.php:719 counter-options.php:581
939
+ msgid "Normally new data will be added to the collection."
940
+ msgstr "Normalno novi podaci bice dodati kolekciji "
941
+
942
+ # @ cpd
943
+ #: Copy of counter-options.php:725 counter-options.php:587
944
+ msgid ""
945
+ "Delete old collection and create a new one which contains only the data "
946
+ "currently in counter table."
947
+ msgstr ""
948
+ "Izbrisi staru kolekciju i kreiraj novu koja sadrzi samo podatke koji su "
949
+ "trenutno na tabli brojaca"
950
+
951
+ # @ cpd
952
+ #: Copy of counter-options.php:726 counter-options.php:588
953
+ #, php-format
954
+ msgid "All collected data until %s will deleted."
955
+ msgstr "Svi prikupljeni podaci do %s ce biti izbrisani "
956
+
957
+ # @ cpd
958
+ #: Copy of counter-options.php:731 counter-options.php:593
959
+ #, php-format
960
+ msgid "Keep entries of last %s full months + current month in counter table."
961
+ msgstr "Sacuvaj unose od zadnjih %s meseci + tekuci mesec u tabli brojaca"
962
+
963
+ # @ cpd
964
+ #: Copy of counter-options.php:790 counter-options.php:644
965
+ msgid "ReActivation"
966
+ msgstr "Reaktivacija"
967
+
968
+ # @ cpd
969
+ #: Copy of counter-options.php:793 counter-options.php:647
970
+ msgid ""
971
+ "Here you can start the installation functions manually.<br/>Same as "
972
+ "deactivate and reactivate the plugin."
973
+ msgstr ""
974
+ "Ovde mozete poceti instalaciju funckija rucno. <br/> Isto kao akticiranje i "
975
+ "deaktiviranje plagina"
976
+
977
+ # @ cpd
978
+ #: Copy of counter-options.php:798 counter-options.php:652
979
+ msgid "ReActivate the plugin"
980
+ msgstr "Reaktivirajte plagin"
981
+
982
+ # @ cpd
983
+ #: counter.php:195 counter.php:951
984
+ msgid "Visitors"
985
+ msgstr "Posetioci"
986
+
987
+ # @ cpd
988
+ #: counter.php:198 counter.php:199
989
+ msgid "Most visited day"
990
+ msgstr "Najposeceniji dan"
991
+
992
+ # @ cpd
993
+ #: counter.php:1347
994
+ msgid "drag and drop to sort"
995
+ msgstr "POvuci i spusti da bi sortirali "
996
+
997
+ # @ cpd
998
+ #: counter-core.php:1129
999
+ msgid "Your can download the backup files here and now."
1000
+ msgstr "Mozete skinuti bekap fajlove ovde i sada."
1001
+
1002
+ # @ cpd
1003
+ #: Copy of counter-options.php:644 counter-options.php:468
1004
+ msgid "Download only"
1005
+ msgstr "Samo download"
1006
+
1007
+ # @ default
1008
+ #: Copy of counter-options.php:673 counter-options.php:519
1009
+ msgid "Delete"
1010
+ msgstr "Izbrisi "
1011
+
1012
+ # @ cpd
1013
+ #: Copy of counter-options.php:674 counter-options.php:520
1014
+ #, php-format
1015
+ msgid "Delete the backup file %s ?"
1016
+ msgstr "Izbrisati bekap fajl %s?"
1017
+
1018
+ # @ cpd
1019
+ #: counter-core.php:819 counter-options.php:838 counter-options.php:842
1020
+ msgid "Search strings"
1021
+ msgstr "Trazi redove"
1022
+
1023
+ # @ cpd
1024
+ #: counter-core.php:1199
1025
+ msgid "Error while reading backup file!"
1026
+ msgstr "Greska u citanju bekap fajla!"
1027
+
1028
+ # @ cpd
1029
+ #: counter-core.php:1203
1030
+ #, php-format
1031
+ msgid "The backup was added to counter table %s."
1032
+ msgstr "Bekap je dodat tabli brojaca %s."
1033
+
1034
+ # @ cpd
1035
+ #: counter-core.php:1205
1036
+ #, php-format
1037
+ msgid "The counter table %s was restored from backup."
1038
+ msgstr "Tabla brojaca %s je povracena s bekapa"
1039
+
1040
+ # @ cpd
1041
+ #: counter-core.php:1222
1042
+ msgid "Options restored from backup."
1043
+ msgstr "Opcije povracene s bekapa"
1044
+
1045
+ # @ cpd
1046
+ #: counter-options.php:501
1047
+ msgid "Settings and collections"
1048
+ msgstr "Podesavanja i kolekcije"
1049
+
1050
+ # @ cpd
1051
+ #: counter-options.php:506
1052
+ #, php-format
1053
+ msgid "Counter table %s"
1054
+ msgstr "Tabla brojaca %s"
1055
+
1056
+ # @ cpd
1057
+ #: counter-options.php:513
1058
+ #, php-format
1059
+ msgid "Add data from the backup file %s to existing counter table?"
1060
+ msgstr "Dodati podatke s bekap fajla %s postojecoj tabli brojaca? "
1061
+
1062
+ # @ cpd
1063
+ #: counter-options.php:517
1064
+ #, php-format
1065
+ msgid "Restore data from the backup file %s ?"
1066
+ msgstr "POvratiti podatke s bekap fajla %s?"
1067
+
1068
+ # @ default
1069
+ #: counter-options.php:517
1070
+ msgid "Restore"
1071
+ msgstr "Povrati "
1072
+
1073
+ # @ cpd
1074
+ #: counter-options.php:526
1075
+ msgid "add backup to current counter table"
1076
+ msgstr "dodaj bekap trenutnoj tabli brojaca"
1077
+
1078
+ # @ cpd
1079
+ #: counter-options.php:527
1080
+ msgid "replace current counter table with with backup"
1081
+ msgstr "Zameni trenutnu tablu brojaca s bekapom"
1082
+
1083
+ # @ cpd
1084
+ #: counter-options.php:528
1085
+ msgid "delete backup file"
1086
+ msgstr "izbrisi bekap fajl"
1087
+
1088
+ # @ cpd
1089
+ #: counter.php:1094
1090
+ #, php-format
1091
+ msgid "The %s most searched strings:"
1092
+ msgstr "%s najtrazeniji redovi "
1093
+
1094
+ # @ cpd
1095
+ #: counter.php:1103
1096
+ #, php-format
1097
+ msgid "The search strings of the last %s days:"
1098
+ msgstr "Trazeni redovi u poslednjih %s dana"
1099
+
1100
+ # @ cpd
1101
+ #: counter-options.php:332
1102
+ msgid "Old search strings deleted"
1103
+ msgstr "Stari trazeni redovi izbrisani "
1104
+
1105
+ # @ cpd
1106
+ #: counter-options.php:554
1107
+ #, php-format
1108
+ msgid "Delete search strings older than %s days."
1109
+ msgstr "Izbrisi trazene redove starije od %s dana"
1110
+
1111
+ # @ cpd
1112
+ #: counter-options.php:556
1113
+ msgid "Delete search strings"
1114
+ msgstr "Izbrisi trazene redove"
1115
+
1116
+ # @ cpd
1117
+ #: counter-options.php:513
1118
+ msgid "Add"
1119
+ msgstr "Dodaj "
massbots.php CHANGED
@@ -6,10 +6,10 @@ require_once($cpd_wp.'wp-load.php');
6
  // check user
7
  $o = get_option('count_per_day');
8
  $can_see = str_replace(
9
- // administrator, editor, author, contributor, subscriber
10
- array(10, 7, 2, 1, 0),
11
- array('manage_options', 'moderate_comments', 'edit_published_posts', 'edit_posts', 'read'),
12
- $o['show_in_lists']);
13
  if ( !current_user_can($can_see) )
14
  die();
15
 
@@ -27,7 +27,7 @@ if ( isset($_GET['dmbip']) && isset($_GET['dmbdate']) )
27
  ON t.term_id = 0 - c.page
28
  LEFT JOIN $wpdb->term_taxonomy x
29
  ON x.term_id = t.term_id
30
- WHERE c.ip = %d
31
  AND c.date = %s
32
  ORDER BY p.ID",
33
  $_GET['dmbip'], $_GET['dmbdate'] );
@@ -35,10 +35,10 @@ if ( isset($_GET['dmbip']) && isset($_GET['dmbdate']) )
35
  }
36
  ?>
37
 
38
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
39
- <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="de-DE">
40
  <head>
41
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
42
  <title>Count per Day</title>
43
  <link rel="stylesheet" type="text/css" href="counter.css" />
44
  </head>
6
  // check user
7
  $o = get_option('count_per_day');
8
  $can_see = str_replace(
9
+ // administrator, editor, author, contributor, subscriber
10
+ array(10, 7, 2, 1, 0),
11
+ array('manage_options', 'moderate_comments', 'edit_published_posts', 'edit_posts', 'read'),
12
+ $o['show_in_lists']);
13
  if ( !current_user_can($can_see) )
14
  die();
15
 
27
  ON t.term_id = 0 - c.page
28
  LEFT JOIN $wpdb->term_taxonomy x
29
  ON x.term_id = t.term_id
30
+ WHERE c.ip = %s
31
  AND c.date = %s
32
  ORDER BY p.ID",
33
  $_GET['dmbip'], $_GET['dmbdate'] );
35
  }
36
  ?>
37
 
38
+ <!DOCTYPE html>
39
+ <html <?php language_attributes(); ?>>
40
  <head>
41
+ <meta charset="UTF-8" />
42
  <title>Count per Day</title>
43
  <link rel="stylesheet" type="text/css" href="counter.css" />
44
  </head>
notes.php CHANGED
@@ -44,10 +44,10 @@ else if ( isset($_POST['delete']) )
44
  update_option('count_per_day_notes', $n);
45
  ?>
46
 
47
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
48
- <html xmlns="http://www.w3.org/1999/xhtml">
49
  <head>
50
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
51
  <title>CountPerDay</title>
52
  <link rel="stylesheet" type="text/css" href="counter.css" />
53
  </head>
44
  update_option('count_per_day_notes', $n);
45
  ?>
46
 
47
+ <!DOCTYPE html>
48
+ <html <?php language_attributes(); ?>>
49
  <head>
50
+ <meta charset="UTF-8" />
51
  <title>CountPerDay</title>
52
  <link rel="stylesheet" type="text/css" href="counter.css" />
53
  </head>
readme.txt CHANGED
@@ -2,13 +2,15 @@
2
  Contributors: Tom Braider
3
  Tags: counter, count, posts, visits, reads, dashboard, widget, shortcode
4
  Requires at least: 3.0
5
- Tested up to: 3.5
6
- Stable tag: 3.2.5
7
  License: Postcardware :)
8
  Donate link: http://www.tomsdimension.de/postcards
9
 
10
  Visit Counter, shows reads and visitors per page, visitors today, yesterday, last week, last months and other statistics.
11
 
 
 
12
  == Description ==
13
 
14
  * count reads and visitors
@@ -24,30 +26,31 @@ Visit Counter, shows reads and visitors per page, visitors today, yesterday, las
24
  = Languages, Translators =
25
 
26
  - up to date translations:
27
- - Bulgarian - joro - http://www.joro711.com
28
- - German - Tom - http://www.tomsdimension.de
29
- - Japanese - Juno Hayami http://juno.main.jp/blog/
30
- - Portuguese - Beto Ribeiro - http://www.sevenarts.com.br
31
- - Russian - Ilya Pshenichny - http://iluhis.com
 
32
 
33
  - older, incomplete translations:
34
- - Azerbaijani - Bohdan Zograf - http://wwww.webhostingrating.com
35
- - Belarusian - Alexander Alexandrov - http://www.designcontest.com
36
- - Dansk - Jonas Thomsen - http://jonasthomsen.com
37
- - Dutch NL - Rene - http://wpwebshop.com
38
- - Espanol - Juan Carlos del R&iacute;o -
39
- - Finnish - Jani Alha - http://www.wysiwyg.fi
40
- - France - Bjork - http://www.habbzone.fr
41
- - Greek - Essetai_Imar - http://www.elliniki-grothia.com
42
- - Hindi - Love Chandel - http://outshinesolutions.com
43
- - Italian - Gianni Diurno - http://gidibao.net
44
- - Lithuanian - Nata Strazda - http://www.webhostinghub.com
45
- - Norwegian - Stein Ivar Johnsen - http://iDyrøy.no
46
- - Polish - LeXuS - http://intrakardial.de
47
- - Romanian - Alexander Ovsov - http://webhostinggeeks.com
48
- - Swedish - Magnus Suther - http://www.magnussuther.se
49
- - Turkish - Emrullah Tahir Ekmek&ccedil;i - http://emrullahekmekci.com.tr
50
- - Ukrainian - Iflexion design - http://iflexion.com
51
 
52
 
53
  == Installation ==
@@ -70,12 +73,16 @@ See the Options Page and check the default values.
70
 
71
  read and write comments on http://www.tomsdimension.de/wp-plugins/count-per-day
72
 
 
 
73
  == Screenshots ==
74
 
75
  1. Statistics on Count-per-Day Dashboard
76
  2. Options
77
  3. Widget sample
78
 
 
 
79
  == Arbitrary section ==
80
 
81
  **Shortcodes**
@@ -101,22 +108,26 @@ To use the shortcodes within a text widget you have to add 'add_filter("widget_t
101
  [CPD_VISITORS_PER_DAY]
102
  [CPD_VISITORS_PER_POST]
103
  [CPD_FIRST_COUNT]
104
- [CPD_MOST_VISITED_POSTS]
105
  [CPD_POSTS_ON_DAY]
106
  [CPD_CLIENTS]
107
  [CPD_COUNTRIES]
108
  [CPD_COUNTRIES_USERS]
109
  [CPD_REFERERS]
 
 
 
 
 
110
  [CPD_POSTS_ON_DAY date="2010-10-06" limit="3"]
111
  - date (optional), format: year-month-day, default = today
112
- - limit (optional): max records to show, default = all
113
  [CPD_MAP width="500" height="340" what="reads" min=1]
114
  - width and height: size, default 500x340 px
115
  - what: map content - reads|visitors|online, default reads
116
  - min: 1 (disable title, legend and zoombar), default 0
117
  [CPD_SEARCHES days="14" limit="20"]
118
  - days (optional), show last x days
119
- - limit (optional): show x most searched strings
120
 
121
  **Functions**
122
 
@@ -153,7 +164,7 @@ show( $before, $after, $show, $count, $page )'
153
  * $return: 0 echo, 1 return output
154
 
155
  'getReadsAll( $return )'
156
-
157
  * shows number of total reads
158
  * $return: 0 echo, 1 return output
159
 
@@ -163,7 +174,7 @@ show( $before, $after, $show, $count, $page )'
163
  * $return: 0 echo, 1 return output
164
 
165
  'getReadsYesterday( $return )'
166
-
167
  * shows number of reads yesterday
168
  * $return: 0 echo, 1 return output
169
 
@@ -200,7 +211,7 @@ show( $before, $after, $show, $count, $page )'
200
  * $return: 0 echo, 1 return output
201
 
202
  'getUserYesterday( $return )'
203
-
204
  * shows number of visitors yesterday
205
  * $return: 0 echo, 1 return output
206
 
@@ -226,7 +237,7 @@ show( $before, $after, $show, $count, $page )'
226
  * $frontend: 1 no links
227
  * $return: 0 echo, 1 return output
228
 
229
- 'getMostVisitedPosts( $days, $limits, $frontend, $postsonly, $return )'
230
 
231
  * shows a list with the most visited posts in the last days
232
  * $days = days to calc (last days), 0: get option from DB
@@ -234,6 +245,7 @@ show( $before, $after, $show, $count, $page )'
234
  * $frontend: 1 no links
235
  * $postsonly: 0 show, 1 don't show categories and taxonomies
236
  * $return: 0 echo, 1 return output
 
237
 
238
  'getVisitedPostsOnDay( $date, $limit, $show_form, $show_notes, $frontend, $return )'
239
 
@@ -290,8 +302,21 @@ show( $before, $after, $show, $count, $page )'
290
  * If the automatically update don't work download <a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz">GeoIP.dat.gz</a> and extract it to the "geoip" directory.
291
  * More information about GeoIP on http://www.maxmind.com/app/geoip_country
292
 
 
 
293
  == Changelog ==
294
 
 
 
 
 
 
 
 
 
 
 
 
295
  = 3.2.5 =
296
  + Bugfix: compatibility fix for WordPress 3.5
297
 
@@ -309,7 +334,7 @@ show( $before, $after, $show, $count, $page )'
309
  = 3.2.1 =
310
  + Bugfix: massbot delete error
311
  + Bugfix: search words array sometimes corrupt
312
- + Bugfix: add collected data to reads per post, thanks to Suzakura Karin http://yumeneko.pmfan.jp / http://is.gd/VWNyLq
313
  + Language update: Japanese, thanks to Juno Hayami
314
  + Language update: Portuguese, thanks to Beto Ribeiro
315
  + Language update: Russian, thanks to Ilya Pshenichny
2
  Contributors: Tom Braider
3
  Tags: counter, count, posts, visits, reads, dashboard, widget, shortcode
4
  Requires at least: 3.0
5
+ Tested up to: 3.6
6
+ Stable tag: 3.2.6
7
  License: Postcardware :)
8
  Donate link: http://www.tomsdimension.de/postcards
9
 
10
  Visit Counter, shows reads and visitors per page, visitors today, yesterday, last week, last months and other statistics.
11
 
12
+
13
+
14
  == Description ==
15
 
16
  * count reads and visitors
26
  = Languages, Translators =
27
 
28
  - up to date translations:
29
+ - Bulgarian - joro - http://www.joro711.com
30
+ - German - Tom - http://www.tomsdimension.de
31
+ - Japanese - Juno Hayami - http://juno.main.jp/blog/
32
+ - Portuguese - Beto Ribeiro - http://www.sevenarts.com.br
33
+ - Russian - Ilya Pshenichny - http://iluhis.com
34
+ - Serbian - Diana - http://wpdiscounts.com
35
 
36
  - older, incomplete translations:
37
+ - Azerbaijani - Bohdan Zograf - http://wwww.webhostingrating.com
38
+ - Belarusian - Alexander Alexandrov - http://www.designcontest.com
39
+ - Dansk - Jonas Thomsen - http://jonasthomsen.com
40
+ - Dutch NL - Rene - http://wpwebshop.com
41
+ - Espanol - Juan Carlos del R&iacute;o -
42
+ - Finnish - Jani Alha - http://www.wysiwyg.fi
43
+ - France - Bjork - http://www.habbzone.fr
44
+ - Greek - Essetai_Imar - http://www.elliniki-grothia.com
45
+ - Hindi - Love Chandel - http://outshinesolutions.com
46
+ - Italian - Gianni Diurno - http://gidibao.net
47
+ - Lithuanian - Nata Strazda - http://www.webhostinghub.com
48
+ - Norwegian - Stein Ivar Johnsen - http://iDyrøy.no
49
+ - Polish - LeXuS - http://intrakardial.de
50
+ - Romanian - Alexander Ovsov - http://webhostinggeeks.com
51
+ - Swedish - Magnus Suther - http://www.magnussuther.se
52
+ - Turkish - Emrullah Tahir Ekmek&ccedil;i - http://emrullahekmekci.com.tr
53
+ - Ukrainian - Iflexion design - http://iflexion.com
54
 
55
 
56
  == Installation ==
73
 
74
  read and write comments on http://www.tomsdimension.de/wp-plugins/count-per-day
75
 
76
+
77
+
78
  == Screenshots ==
79
 
80
  1. Statistics on Count-per-Day Dashboard
81
  2. Options
82
  3. Widget sample
83
 
84
+
85
+
86
  == Arbitrary section ==
87
 
88
  **Shortcodes**
108
  [CPD_VISITORS_PER_DAY]
109
  [CPD_VISITORS_PER_POST]
110
  [CPD_FIRST_COUNT]
 
111
  [CPD_POSTS_ON_DAY]
112
  [CPD_CLIENTS]
113
  [CPD_COUNTRIES]
114
  [CPD_COUNTRIES_USERS]
115
  [CPD_REFERERS]
116
+ [CPD_MOST_VISITED_POSTS limit="5" days="30" postsonly="1" posttypes="posts,pages"]
117
+ - limit (optional): max records to show, default = all
118
+ - days (optional), show last x days
119
+ - postsonly (optional), 1 = don't show index pages
120
+ - posttypes (optional), show this posttypes only, sets postsonly to 1
121
  [CPD_POSTS_ON_DAY date="2010-10-06" limit="3"]
122
  - date (optional), format: year-month-day, default = today
123
+ - limit (optional): max records to show, default = all
124
  [CPD_MAP width="500" height="340" what="reads" min=1]
125
  - width and height: size, default 500x340 px
126
  - what: map content - reads|visitors|online, default reads
127
  - min: 1 (disable title, legend and zoombar), default 0
128
  [CPD_SEARCHES days="14" limit="20"]
129
  - days (optional), show last x days
130
+ - limit (optional): show x most searched strings
131
 
132
  **Functions**
133
 
164
  * $return: 0 echo, 1 return output
165
 
166
  'getReadsAll( $return )'
167
+
168
  * shows number of total reads
169
  * $return: 0 echo, 1 return output
170
 
174
  * $return: 0 echo, 1 return output
175
 
176
  'getReadsYesterday( $return )'
177
+
178
  * shows number of reads yesterday
179
  * $return: 0 echo, 1 return output
180
 
211
  * $return: 0 echo, 1 return output
212
 
213
  'getUserYesterday( $return )'
214
+
215
  * shows number of visitors yesterday
216
  * $return: 0 echo, 1 return output
217
 
237
  * $frontend: 1 no links
238
  * $return: 0 echo, 1 return output
239
 
240
+ 'getMostVisitedPosts( $days, $limits, $frontend, $postsonly, $return, $posttypes )'
241
 
242
  * shows a list with the most visited posts in the last days
243
  * $days = days to calc (last days), 0: get option from DB
245
  * $frontend: 1 no links
246
  * $postsonly: 0 show, 1 don't show categories and taxonomies
247
  * $return: 0 echo, 1 return output
248
+ * $posttypes: comma separated list of post types, default: empty to show all
249
 
250
  'getVisitedPostsOnDay( $date, $limit, $show_form, $show_notes, $frontend, $return )'
251
 
302
  * If the automatically update don't work download <a href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz">GeoIP.dat.gz</a> and extract it to the "geoip" directory.
303
  * More information about GeoIP on http://www.maxmind.com/app/geoip_country
304
 
305
+
306
+
307
  == Changelog ==
308
 
309
+ = 3.2.6 =
310
+ + New: posts only parameters for [CPD_MOST_VISITED_POSTS]
311
+ + New: don't count password protected posts without password
312
+ + New: translate widget titles if possible
313
+ + New: flags of Cambodia, Nigeria and Sudan
314
+ + Bugfix: massbot post list has not show all post
315
+ + Bugfix: security fix, XSS
316
+ + Bugfix: problems while adding widgets
317
+ + Bugfix: start session only in backend
318
+ + Bugfix: empty database query
319
+
320
  = 3.2.5 =
321
  + Bugfix: compatibility fix for WordPress 3.5
322
 
334
  = 3.2.1 =
335
  + Bugfix: massbot delete error
336
  + Bugfix: search words array sometimes corrupt
337
+ + Bugfix: add collected data to reads per post, thanks to Suzakura Karin http://yumeneko.pmfan.jp / http://is.gd/VWNyLq
338
  + Language update: Japanese, thanks to Juno Hayami
339
  + Language update: Portuguese, thanks to Beto Ribeiro
340
  + Language update: Russian, thanks to Ilya Pshenichny
userperspan.php CHANGED
@@ -17,25 +17,27 @@ $cpd_datemin = ( !empty($_REQUEST['datemin']) ) ? wp_strip_all_tags($_REQUEST['d
17
  $cpd_datemax = ( !empty($_REQUEST['datemax']) ) ? wp_strip_all_tags($_REQUEST['datemax']) : date_i18n('Y-m-d');
18
  $cpd_page = ( isset($_REQUEST['page']) ) ? intval($_REQUEST['page']) : 0;
19
 
20
- $sql = "SELECT p.post_title,
 
21
  COUNT(*) AS count,
22
  c.page,
23
  c.date
24
  FROM $wpdb->cpd_counter c
25
  LEFT JOIN $wpdb->posts p
26
  ON p.ID = c.page
27
- WHERE c.page = '$cpd_page'
28
- AND c.date >= '$cpd_datemin'
29
- AND c.date <= '$cpd_datemax'
30
  GROUP BY c.date
31
- ORDER BY c.date desc";
 
32
  $cpd_visits = $count_per_day->mysqlQuery('rows', $sql, 'getUserPerPostSpan '.__LINE__);
33
  ?>
34
 
35
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
36
- <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="de-DE">
37
  <head>
38
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
39
  <title>Count per Day</title>
40
  <link rel="stylesheet" type="text/css" href="counter.css" />
41
  </head>
17
  $cpd_datemax = ( !empty($_REQUEST['datemax']) ) ? wp_strip_all_tags($_REQUEST['datemax']) : date_i18n('Y-m-d');
18
  $cpd_page = ( isset($_REQUEST['page']) ) ? intval($_REQUEST['page']) : 0;
19
 
20
+ $sql = $wpdb->prepare(
21
+ "SELECT p.post_title,
22
  COUNT(*) AS count,
23
  c.page,
24
  c.date
25
  FROM $wpdb->cpd_counter c
26
  LEFT JOIN $wpdb->posts p
27
  ON p.ID = c.page
28
+ WHERE c.page = %s
29
+ AND c.date >= %s
30
+ AND c.date <= %s
31
  GROUP BY c.date
32
+ ORDER BY c.date desc",
33
+ $cpd_page, $cpd_datemin, $cpd_datemax);
34
  $cpd_visits = $count_per_day->mysqlQuery('rows', $sql, 'getUserPerPostSpan '.__LINE__);
35
  ?>
36
 
37
+ <!DOCTYPE html>
38
+ <html <?php language_attributes(); ?>>
39
  <head>
40
+ <meta charset="UTF-8" />
41
  <title>Count per Day</title>
42
  <link rel="stylesheet" type="text/css" href="counter.css" />
43
  </head>