Count per Day - Version 3.2

Version Description

  • New: save search strings
  • New shortcode: CPD_COUNTRIES_USERS
  • New: flags for Bahamas, Mongolia, Cameroon and Kazakhstan
  • Bugfix: can't move widgets
  • Bugfix: visitors per post list
  • Bugfix: "Clean Database" deleted collection too
  • Bugfix: browser summary Chrome/Safari fixed
  • Bugfix: get real remote IP address, not local server
  • Bugfix: security fixes
  • Change: create collection functions optimized
  • New language: Romanian, thanks to Alexander Ovsov
  • New language: Hindi, thanks to Love Chandel
  • New language: Finnish, thanks to Jani Alha
  • Language update: Ukrainain, thanks to Iflexion design
Download this release

Release Info

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

Code changes from version 3.1.1 to 3.2

ajax.php CHANGED
@@ -1,10 +1,17 @@
1
<?php
2
if ( $_GET['f'] == 'count' )
3
{
4
if (!session_id()) session_start();
5
$cpd_wp = (!empty($_SESSION['cpd_wp'])) ? $_SESSION['cpd_wp'] : '../../../';
6
require_once($cpd_wp.'wp-load.php');
7
-
8
$cpd_funcs = array ( 'show',
9
'getReadsAll', 'getReadsToday', 'getReadsYesterday', 'getReadsLastWeek', 'getReadsThisMonth',
10
'getUserAll', 'getUserToday', 'getUserYesterday', 'getUserLastWeek', 'getUserThisMonth',
1
<?php
2
if ( $_GET['f'] == 'count' )
3
{
4
+ // answer only for 20 seconds after calling
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();
12
$cpd_wp = (!empty($_SESSION['cpd_wp'])) ? $_SESSION['cpd_wp'] : '../../../';
13
require_once($cpd_wp.'wp-load.php');
14
+
15
$cpd_funcs = array ( 'show',
16
'getReadsAll', 'getReadsToday', 'getReadsYesterday', 'getReadsLastWeek', 'getReadsThisMonth',
17
'getUserAll', 'getUserToday', 'getUserYesterday', 'getUserLastWeek', 'getUserThisMonth',
counter-core.php CHANGED
@@ -30,7 +30,7 @@ var $installed = false; // CpD installed in subblogs?
30
function init()
31
{
32
// variables
33
- global $wpdb, $cpd_path, $cpd_dir_name;
34
35
define('CPD_METABOX', 'cpd_metaboxes');
36
@@ -66,8 +66,11 @@ function init()
66
// javascript to count cached posts
67
if ($this->options['ajax'])
68
{
69
- wp_enqueue_script('jquery');
70
- add_action('wp_footer', array(&$this,'addAjaxScript'));
71
}
72
73
if (is_admin())
@@ -88,7 +91,6 @@ function init()
88
// add_filter('manage_posts_columns', array(&$this,'cpdColumn'));
89
add_filter('manage_edit-post_columns', array(&$this,'cpdColumn'));
90
// add_filter('manage_edit-post_sortable_columns', array(&$this,'cpdSortableColumns'));
91
-
92
// add_filter('request', array(&$this,'cpdReadsOrderby'));
93
94
// adds javascript
@@ -118,7 +120,7 @@ function init()
118
register_update_hook(ABSPATH.PLUGINDIR.'/count-per-day/counter.php', array(&$this,'checkVersion'));
119
120
// uninstall hook
121
- register_uninstall_hook($cpd_path.'counter.php', 'count_per_day_uninstall');
122
123
// query times debug
124
if ($this->options['debug'])
@@ -132,13 +134,25 @@ function init()
132
133
// thickbox in backend only
134
if (strpos($_SERVER['SCRIPT_NAME'], '/wp-admin/') !== false )
135
- {
136
- wp_enqueue_script('thickbox');
137
- wp_enqueue_script('cpd_flot', $this->dir.'/js/jquery.flot.min.js', 'jQuery');
138
- }
139
140
// Session
141
add_action('init', array(&$this,'startSession'), 1);
142
}
143
144
function cpdReadsOrderby( $vars )
@@ -153,8 +167,6 @@ function cpdReadsOrderby( $vars )
153
return $vars;
154
}
155
156
-
157
-
158
/**
159
* starts session to provide WP variables to "addons"
160
*/
@@ -176,9 +188,8 @@ function mysqlQuery( $kind = '', $sql, $func = '' )
176
global $wpdb;
177
$t = microtime(true);
178
$con = $wpdb->dbh;
179
-
180
$preparedSql = $wpdb->prepare($sql);
181
-
182
if ($kind == 'var')
183
$r = $wpdb->get_var( $preparedSql );
184
else if ($kind == 'count')
@@ -186,11 +197,13 @@ function mysqlQuery( $kind = '', $sql, $func = '' )
186
$sql = 'SELECT COUNT(*) FROM ('.trim($sql,';').') t';
187
$r = $wpdb->get_var( $wpdb->prepare($sql) );
188
}
189
- else if ($kind = 'rows')
190
$r = $wpdb->get_results( $preparedSql );
191
else
192
$wpdb->query( $preparedSql );
193
-
194
if ( $this->options['debug'] )
195
{
196
$d = number_format( microtime(true) - $t , 5);
@@ -376,7 +389,7 @@ function createTables()
376
{
377
$queries = array (
378
"ALTER TABLE `$cpd_c` ADD `ip2` INT(10) UNSIGNED NOT NULL AFTER `ip`",
379
- "UPDATE `$cpd_c` SET ip2 = INET_ATON(ip)",
380
"ALTER TABLE `$cpd_c` DROP `ip`",
381
"ALTER TABLE `$cpd_c` CHANGE `ip2` `ip` INT( 10 ) UNSIGNED NOT NULL",
382
"ALTER TABLE `$cpd_c` CHANGE `date` `date` date NOT NULL",
@@ -431,10 +444,7 @@ function createTables()
431
$this->mysqlQuery('', "DROP TABLE IF EXISTS `$cpd_n`", 'table notes '.__LINE__);
432
433
// update options to array
434
- $this->UpdateOptions();
435
-
436
- // set directory mode
437
- @chmod(ABSPATH.PLUGINDIR.'/count-per-day/geoip', 0777);
438
}
439
440
/**
@@ -451,7 +461,7 @@ function register_widgets()
451
function showQueries()
452
{
453
global $wpdb, $cpd_path, $cpd_version;
454
- echo '<div style="position:absolute;margin:10px;padding:10px;border:1px red solid">
455
<b>Count per Day - DEBUG: '.round($this->queries[0], 3).' s</b><ol>'."\n";
456
echo '<li>'
457
.'<b>Server:</b> '.$_SERVER['SERVER_SOFTWARE'].'<br/>'
@@ -516,7 +526,8 @@ function addCss()
516
*/
517
function addJS()
518
{
519
- echo '<!--[if IE]><script type="text/javascript" src="'.$this->dir.'/js/excanvas.min.js"></script><![endif]-->'."\n";
520
}
521
522
/**
@@ -525,33 +536,27 @@ function addJS()
525
function addAjaxScript()
526
{
527
$this->getPostID();
528
echo <<< JSEND
529
<script type="text/javascript">
530
// Count per Day
531
//<![CDATA[
532
jQuery(document).ready( function($)
533
{
534
- jQuery.get('{$this->dir}/ajax.php?f=count&page={$this->page}', function(text)
535
{
536
var cpd_funcs = text.split('|');
537
for(var i = 0; i < cpd_funcs.length; i++)
538
{
539
var cpd_daten = cpd_funcs[i].split('===');
540
var cpd_fields = document.getElementById('cpd_number_' + cpd_daten[0].toLowerCase());
541
- if (!cpd_fields) { cpd_fields.innerHTML = cpd_daten[1]; }
542
}
543
});
544
} );
545
//]]>
546
</script>
547
JSEND;
548
-
549
- // name not valide in span or div...
550
- // var cpd_fields = document.getElementsByName('cpd_number_' + cpd_daten[0].toLowerCase());
551
- // for(var x = 0; x < cpd_fields.length; x++)
552
- // {
553
- // cpd_fields[x].innerHTML = cpd_daten[1];
554
- // }
555
}
556
557
/**
@@ -571,7 +576,7 @@ function cleanDB()
571
// delete by ip
572
foreach( $bots as $ip )
573
if ( ip2long($ip) !== false )
574
- $this->mysqlQuery('', "DELETE FROM $wpdb->cpd_counter WHERE INET_NTOA(ip) LIKE '".$ip."%%", 'clenaDB_ip'.__LINE__);
575
576
// delete by client
577
foreach ($bots as $bot)
@@ -635,7 +640,7 @@ function updateOptions()
635
'chart_days' => 60,
636
'chart_height' => 100,
637
'countries' => 20,
638
- 'startdate' => '',
639
'startcount' => '',
640
'startreads' => '',
641
'anoip' => 0,
@@ -662,7 +667,8 @@ function updateOptions()
662
*/
663
function dashboardWidgetSetup()
664
{
665
- wp_add_dashboard_widget( 'cpdDashboardWidget', 'Count per Day', array(&$this,'dashboardWidget') );
666
}
667
668
/**
@@ -755,6 +761,7 @@ function getReferersMeta() { $this->getReferers(0, false, 0); }
755
function getUserOnlineMeta() { $this->getUserOnline(false, true); }
756
function getUserPerMonthMeta() { $this->getUserPerMonth(); }
757
function getReadsPerMonthMeta() { $this->getReadsPerMonth(); }
758
759
/**
760
* will be executed if wordpress core detects this page has to be rendered
@@ -775,6 +782,7 @@ function onLoadPage()
775
add_meta_box('reads_per_post', '<span class="cpd_icon cpd_post">&nbsp;</span> '.__('Visitors per post', 'cpd'), array(&$this,'getUserPerPostMeta'), $this->pagehook, 'cpdrow3', 'default');
776
add_meta_box('last_reads', '<span class="cpd_icon cpd_calendar">&nbsp;</span> '.__('Latest Counts', 'cpd'), array(&$this,'getMostVisitedPostsMeta'), $this->pagehook, 'cpdrow4', 'default');
777
add_meta_box('day_reads', '<span class="cpd_icon cpd_day">&nbsp;</span> '.__('Visitors per day', 'cpd'), array(&$this,'getVisitedPostsOnDayMeta'), $this->pagehook, 'cpdrow4', 'default');
778
add_meta_box('cpd_info', '<span class="cpd_icon cpd_help">&nbsp;</span> '.__('Plugin'), array(&$this,'cpdInfo'), $this->pagehook, 'cpdrow1', 'low');
779
if ($this->options['referers'])
780
{
@@ -804,7 +812,7 @@ function onShowPage()
804
wp_nonce_field('cpd-metaboxes');
805
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
806
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
807
- $css = 'style="width:'.round(98 / $screen_layout_columns, 1).'%;"';
808
$this->getFlotChart();
809
?>
810
<div id="dashboard-widgets" class="metabox-holder cpd-dashboard">
@@ -850,12 +858,14 @@ function addShortcodes()
850
add_shortcode('CPD_VISITORS_PER_MONTH', array(&$this,'shortUserPerMonth'));
851
add_shortcode('CPD_VISITORS_PER_POST', array(&$this,'shortUserPerPost'));
852
add_shortcode('CPD_COUNTRIES', array(&$this,'shortCountries'));
853
add_shortcode('CPD_MOST_VISITED_POSTS', array(&$this,'shortMostVisitedPosts'));
854
add_shortcode('CPD_REFERERS', array(&$this,'shortReferers'));
855
add_shortcode('CPD_POSTS_ON_DAY', array(&$this,'shortPostsOnDay'));
856
add_shortcode('CPD_MAP', array(&$this,'shortShowMap'));
857
add_shortcode('CPD_DAY_MOST_READS', array(&$this,'shortDayWithMostReads'));
858
add_shortcode('CPD_DAY_MOST_USERS', array(&$this,'shortDayWithMostUsers'));
859
}
860
function shortShow() { return $this->show('', '', false, false); }
861
function shortReadsTotal() { return $this->getReadsAll(true); }
@@ -876,10 +886,19 @@ function shortClients() { return $this->getClients(true); }
876
function shortUserPerMonth() { return $this->getUserPerMonth(true, true); }
877
function shortUserPerPost() { return $this->getUserPerPost(0, true, true); }
878
function shortCountries() { return $this->getCountries(0, true, false, true); }
879
function shortMostVisitedPosts(){ return $this->getMostVisitedPosts(0, 0, true, false, true); }
880
function shortReferers() { return $this->getReferers(0, true, 0); }
881
function shortDayWithMostReads(){ return $this->getDayWithMostReads(true, true); }
882
function shortDayWithMostUsers(){ return $this->getDayWithMostUsers(true, true); }
883
function shortPostsOnDay( $atts )
884
{
885
extract( shortcode_atts( array(
@@ -927,7 +946,7 @@ function getMassBots( $limit )
927
{
928
global $wpdb;
929
$sql = $wpdb->prepare("
930
- SELECT t.id, t.ip AS longip, INET_NTOA(t.ip) AS ip, t.date, t.posts, c.client
931
FROM ( SELECT id, ip, date, count(*) posts
932
FROM $wpdb->cpd_counter
933
GROUP BY ip, date
@@ -957,15 +976,14 @@ function backup()
957
// open file
958
$f = ($gz) ? gzopen($path,'w9') : fopen($path,'w');
959
960
- @ob_start();
961
-
962
if (!$f) :
963
echo '<div class="error"><p>'.__('Backup failed! Cannot open file', 'cpd').' '.$path.'.</p></div>';
964
else :
965
set_time_limit(300);
966
967
// write backup to file
968
- $d = "DROP TABLE IF EXISTS `$t`;\n";
969
($gz) ? gzwrite($f, $d) : fwrite($f, $d);
970
if ( $res = $this->mysqlQuery('rows', "SHOW CREATE TABLE `$t`", 'backupCollect'.__LINE__) )
971
{
@@ -1026,7 +1044,6 @@ function backup()
1026
}
1027
}
1028
}
1029
- // echo $this->formatBytes(memory_get_peak_usage());
1030
echo '| ';
1031
$this->flush_buffers();
1032
}
@@ -1097,6 +1114,82 @@ function backup()
1097
}
1098
1099
1100
1101
function addCollectionToCountries( $visitors, $limit = false )
1102
{
@@ -1119,6 +1212,7 @@ function addCollectionToCountries( $visitors, $limit = false )
1119
ORDER BY c DESC";
1120
$res = $this->mysqlQuery('rows', $sql, 'getCountries '.__LINE__);
1121
1122
foreach ( $res as $r )
1123
$temp[$r->country] = $r->c;
1124
@@ -1231,7 +1325,7 @@ function updateFirstCount()
1231
$s = get_option('count_per_day_summary', array());
1232
if ( empty($s['firstcount']) )
1233
{
1234
- // first day from table ORDER BY date LIMIT 1
1235
$res = $this->mysqlQuery('var', "SELECT MIN(date) FROM $wpdb->cpd_counter", 'getFirstCount'.__LINE__);
1236
if ($res)
1237
{
@@ -1272,12 +1366,18 @@ function formatBytes( $size )
1272
*/
1273
function flush_buffers()
1274
{
1275
- if (ob_get_length())
1276
{
1277
- @ob_end_flush();
1278
- @ob_flush();
1279
- @flush();
1280
- }
1281
@ob_start();
1282
}
1283
@@ -1298,4 +1398,25 @@ function getBytes($val) {
1298
return $val;
1299
}
1300
1301
} // class
30
function init()
31
{
32
// variables
33
+ global $wpdb, $path, $cpd_dir_name;
34
35
define('CPD_METABOX', 'cpd_metaboxes');
36
66
// javascript to count cached posts
67
if ($this->options['ajax'])
68
{
69
+ // wp_enqueue_script('jquery');
70
+ add_action('wp_enqueue_scripts', array(&$this,'addJquery'));
71
+ add_action('wp_footer', array(&$this,'addAjaxScript'));
72
+ // auch in addJQuery?
73
+
74
}
75
76
if (is_admin())
91
// add_filter('manage_posts_columns', array(&$this,'cpdColumn'));
92
add_filter('manage_edit-post_columns', array(&$this,'cpdColumn'));
93
// add_filter('manage_edit-post_sortable_columns', array(&$this,'cpdSortableColumns'));
94
// add_filter('request', array(&$this,'cpdReadsOrderby'));
95
96
// adds javascript
120
register_update_hook(ABSPATH.PLUGINDIR.'/count-per-day/counter.php', array(&$this,'checkVersion'));
121
122
// uninstall hook
123
+ register_uninstall_hook($path.'counter.php', 'count_per_day_uninstall');
124
125
// query times debug
126
if ($this->options['debug'])
134
135
// thickbox in backend only
136
if (strpos($_SERVER['SCRIPT_NAME'], '/wp-admin/') !== false )
137
+ add_action('admin_enqueue_scripts', array(&$this,'addThickbox'));
138
139
// Session
140
add_action('init', array(&$this,'startSession'), 1);
141
+
142
+ $this->aton = 'INET_ATON';
143
+ $this->ntoa = 'INET_NTOA';
144
+ }
145
+
146
+ function addJquery()
147
+ {
148
+ wp_enqueue_script('jquery');
149
+ }
150
+
151
+ function addThickbox()
152
+ {
153
+ wp_enqueue_script('thickbox');
154
+ if (strpos($_SERVER['QUERY_STRING'], 'cpd_metaboxes') !== false)
155
+ wp_enqueue_script('cpd_flot', $this->dir.'/js/jquery.flot.min.js', 'jQuery');
156
}
157
158
function cpdReadsOrderby( $vars )
167
return $vars;
168
}
169
170
/**
171
* starts session to provide WP variables to "addons"
172
*/
188
global $wpdb;
189
$t = microtime(true);
190
$con = $wpdb->dbh;
191
$preparedSql = $wpdb->prepare($sql);
192
+ $r = false;
193
if ($kind == 'var')
194
$r = $wpdb->get_var( $preparedSql );
195
else if ($kind == 'count')
197
$sql = 'SELECT COUNT(*) FROM ('.trim($sql,';').') t';
198
$r = $wpdb->get_var( $wpdb->prepare($sql) );
199
}
200
+ else if ($kind == 'rows')
201
+ {
202
$r = $wpdb->get_results( $preparedSql );
203
+ }
204
else
205
$wpdb->query( $preparedSql );
206
+
207
if ( $this->options['debug'] )
208
{
209
$d = number_format( microtime(true) - $t , 5);
389
{
390
$queries = array (
391
"ALTER TABLE `$cpd_c` ADD `ip2` INT(10) UNSIGNED NOT NULL AFTER `ip`",
392
+ "UPDATE `$cpd_c` SET ip2 = $this->aton(ip)",
393
"ALTER TABLE `$cpd_c` DROP `ip`",
394
"ALTER TABLE `$cpd_c` CHANGE `ip2` `ip` INT( 10 ) UNSIGNED NOT NULL",
395
"ALTER TABLE `$cpd_c` CHANGE `date` `date` date NOT NULL",
444
$this->mysqlQuery('', "DROP TABLE IF EXISTS `$cpd_n`", 'table notes '.__LINE__);
445
446
// update options to array
447
+ $this->updateOptions();
448
}
449
450
/**
461
function showQueries()
462
{
463
global $wpdb, $cpd_path, $cpd_version;
464
+ echo '<div style="position:absolute;margin:10px;padding:10px;border:1px red solid;background:#fff;clear:both">
465
<b>Count per Day - DEBUG: '.round($this->queries[0], 3).' s</b><ol>'."\n";
466
echo '<li>'
467
.'<b>Server:</b> '.$_SERVER['SERVER_SOFTWARE'].'<br/>'
526
*/
527
function addJS()
528
{
529
+ if (strpos($_SERVER['QUERY_STRING'], 'cpd_metaboxes') !== false )
530
+ echo '<!--[if IE]><script type="text/javascript" src="'.$this->dir.'/js/excanvas.min.js"></script><![endif]-->'."\n";
531
}
532
533
/**
536
function addAjaxScript()
537
{
538
$this->getPostID();
539
+ $time = time();
540
echo <<< JSEND
541
<script type="text/javascript">
542
// Count per Day
543
//<![CDATA[
544
jQuery(document).ready( function($)
545
{
546
+ jQuery.get('{$this->dir}/ajax.php?f=count&page={$this->page}&time={$time}', function(text)
547
{
548
var cpd_funcs = text.split('|');
549
for(var i = 0; i < cpd_funcs.length; i++)
550
{
551
var cpd_daten = cpd_funcs[i].split('===');
552
var cpd_fields = document.getElementById('cpd_number_' + cpd_daten[0].toLowerCase());
553
+ if (!cpd_fields && cpd_fields != null) { cpd_fields.innerHTML = cpd_daten[1]; }
554
}
555
});
556
} );
557
//]]>
558
</script>
559
JSEND;
560
}
561
562
/**
576
// delete by ip
577
foreach( $bots as $ip )
578
if ( ip2long($ip) !== false )
579
+ $this->mysqlQuery('', "DELETE FROM $wpdb->cpd_counter WHERE $this->ntoa(ip) LIKE '".$ip."%%", 'clenaDB_ip'.__LINE__);
580
581
// delete by client
582
foreach ($bots as $bot)
640
'chart_days' => 60,
641
'chart_height' => 100,
642
'countries' => 20,
643
+ 'startdate' => '2000-01-01',
644
'startcount' => '',
645
'startreads' => '',
646
'anoip' => 0,
667
*/
668
function dashboardWidgetSetup()
669
{
670
+ if ( current_user_can($this->options['show_in_lists']) )
671
+ wp_add_dashboard_widget( 'cpdDashboardWidget', 'Count per Day', array(&$this,'dashboardWidget') );
672
}
673
674
/**
761
function getUserOnlineMeta() { $this->getUserOnline(false, true); }
762
function getUserPerMonthMeta() { $this->getUserPerMonth(); }
763
function getReadsPerMonthMeta() { $this->getReadsPerMonth(); }
764
+ function getSearchesMeta() { $this->getSearches(); }
765
766
/**
767
* will be executed if wordpress core detects this page has to be rendered
782
add_meta_box('reads_per_post', '<span class="cpd_icon cpd_post">&nbsp;</span> '.__('Visitors per post', 'cpd'), array(&$this,'getUserPerPostMeta'), $this->pagehook, 'cpdrow3', 'default');
783
add_meta_box('last_reads', '<span class="cpd_icon cpd_calendar">&nbsp;</span> '.__('Latest Counts', 'cpd'), array(&$this,'getMostVisitedPostsMeta'), $this->pagehook, 'cpdrow4', 'default');
784
add_meta_box('day_reads', '<span class="cpd_icon cpd_day">&nbsp;</span> '.__('Visitors per day', 'cpd'), array(&$this,'getVisitedPostsOnDayMeta'), $this->pagehook, 'cpdrow4', 'default');
785
+ add_meta_box('searches', '<span class="cpd_icon cpd_help">&nbsp;</span> '.__('Search strings', 'cpd'), array(&$this,'getSearchesMeta'), $this->pagehook, 'cpdrow1', 'default');
786
add_meta_box('cpd_info', '<span class="cpd_icon cpd_help">&nbsp;</span> '.__('Plugin'), array(&$this,'cpdInfo'), $this->pagehook, 'cpdrow1', 'low');
787
if ($this->options['referers'])
788
{
812
wp_nonce_field('cpd-metaboxes');
813
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
814
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
815
+ $css = 'style="width:'.round(100 / $screen_layout_columns, 1).'%;"';
816
$this->getFlotChart();
817
?>
818
<div id="dashboard-widgets" class="metabox-holder cpd-dashboard">
858
add_shortcode('CPD_VISITORS_PER_MONTH', array(&$this,'shortUserPerMonth'));
859
add_shortcode('CPD_VISITORS_PER_POST', array(&$this,'shortUserPerPost'));
860
add_shortcode('CPD_COUNTRIES', array(&$this,'shortCountries'));
861
+ add_shortcode('CPD_COUNTRIES_USERS', array(&$this,'shortCountriesUsers'));
862
add_shortcode('CPD_MOST_VISITED_POSTS', array(&$this,'shortMostVisitedPosts'));
863
add_shortcode('CPD_REFERERS', array(&$this,'shortReferers'));
864
add_shortcode('CPD_POSTS_ON_DAY', array(&$this,'shortPostsOnDay'));
865
add_shortcode('CPD_MAP', array(&$this,'shortShowMap'));
866
add_shortcode('CPD_DAY_MOST_READS', array(&$this,'shortDayWithMostReads'));
867
add_shortcode('CPD_DAY_MOST_USERS', array(&$this,'shortDayWithMostUsers'));
868
+ add_shortcode('CPD_SEARCHSTRINGS', array(&$this,'shortGetSearches'));
869
}
870
function shortShow() { return $this->show('', '', false, false); }
871
function shortReadsTotal() { return $this->getReadsAll(true); }
886
function shortUserPerMonth() { return $this->getUserPerMonth(true, true); }
887
function shortUserPerPost() { return $this->getUserPerPost(0, true, true); }
888
function shortCountries() { return $this->getCountries(0, true, false, true); }
889
+ function shortCountriesUsers(){ return $this->getCountries(0, true, true, true); }
890
function shortMostVisitedPosts(){ return $this->getMostVisitedPosts(0, 0, true, false, true); }
891
function shortReferers() { return $this->getReferers(0, true, 0); }
892
function shortDayWithMostReads(){ return $this->getDayWithMostReads(true, true); }
893
function shortDayWithMostUsers(){ return $this->getDayWithMostUsers(true, true); }
894
+ function shortGetSearches( $atts )
895
+ {
896
+ extract( shortcode_atts( array(
897
+ 'limit' => 0,
898
+ 'days' => 0
899
+ ), $atts) );
900
+ return $this->getSearches( $limit, $days, true );
901
+ }
902
function shortPostsOnDay( $atts )
903
{
904
extract( shortcode_atts( array(
946
{
947
global $wpdb;
948
$sql = $wpdb->prepare("
949
+ SELECT t.id, t.ip AS longip, $this->ntoa(t.ip) AS ip, t.date, t.posts, c.client
950
FROM ( SELECT id, ip, date, count(*) posts
951
FROM $wpdb->cpd_counter
952
GROUP BY ip, date
976
// open file
977
$f = ($gz) ? gzopen($path,'w9') : fopen($path,'w');
978
979
if (!$f) :
980
echo '<div class="error"><p>'.__('Backup failed! Cannot open file', 'cpd').' '.$path.'.</p></div>';
981
else :
982
set_time_limit(300);
983
+ $this->flush_buffers();
984
985
// write backup to file
986
+ $d = '';
987
($gz) ? gzwrite($f, $d) : fwrite($f, $d);
988
if ( $res = $this->mysqlQuery('rows', "SHOW CREATE TABLE `$t`", 'backupCollect'.__LINE__) )
989
{
1044
}
1045
}
1046
}
1047
echo '| ';
1048
$this->flush_buffers();
1049
}
1114
}
1115
1116
1117
+ /**
1118
+ * restores backup data to the counter table or options
1119
+ */
1120
+ function restore ()
1121
+ {
1122
+ global $wpdb;
1123
+
1124
+ if ( empty($_GET['_wpnonce']) || !wp_verify_nonce($_GET['_wpnonce'], 'cpdnonce')
1125
+ || ( empty($_GET['cpdrestore']) && empty($_GET['cpdadding']) ) )
1126
+ return;
1127
+
1128
+ $doadding = (isset($_GET['cpdadding'])) ? 1 : 0;
1129
+ $path = WP_CONTENT_DIR.'/'.(($doadding) ? $_GET['cpdadding'] : $_GET['cpdrestore']);
1130
+
1131
+ if ( isset($path) && preg_match('/count_per_day|cpd_counter/i', $path) && file_exists($path) )
1132
+ {
1133
+ $gz = (substr($path, -3) == '.gz') ? 1 : 0;
1134
+ $f = ($gz) ? gzopen($path, 'r') : fopen($path, 'r');
1135
+
1136
+ if ( strpos($path, 'counter_backup') )
1137
+ {
1138
+ // counter table
1139
+ $cpd_sep = array('DROP TABLE', 'CREATE TABLE', 'INSERT INTO', 'REPAIR TABLE');
1140
+ $sql = '';
1141
+ while ( ($cpd_line = ($gz)?gzgets($f):fgets($f)) !== false )
1142
+ {
1143
+ // new query?
1144
+ $newsql = 0;
1145
+ foreach ( $cpd_sep as $s )
1146
+ if ( strpos($cpd_line, $s) !== false && strpos($cpd_line, $s) < 5 )
1147
+ $newsql = 1;
1148
+ if ($newsql)
1149
+ {
1150
+ // execute query, do not recreate table while adding data
1151
+ if (!empty($sql))
1152
+ {
1153
+ if ($doadding)
1154
+ $sql = str_replace('INSERT INTO', 'REPLACE INTO', $sql);
1155
+ if ( !$doadding || ( strpos($sql, 'DROP TABLE') === false && strpos($sql, 'CREATE TABLE') === false ) )
1156
+ $this->mysqlQuery('', $sql, 'restoreSql '.__LINE__);
1157
+ }
1158
+ $sql = $cpd_line;
1159
+ }
1160
+ else
1161
+ $sql .= $cpd_line;
1162
+ }
1163
+ if (!feof($f)) {
1164
+ echo '<div class="error"><p>'.__('Error while reading backup file!', 'cpd')."</p></div>\n";
1165
+ }
1166
+ unset($sql);
1167
+ if ($doadding)
1168
+ echo '<div class="updated"><p>'.sprintf(__('The backup was added to counter table %s.', 'cpd'), "<code>$wpdb->cpd_counter</code>")."</p></div>\n";
1169
+ else
1170
+ echo '<div class="updated"><p>'.sprintf(__('The counter table %s was restored from backup.', 'cpd'), "<code>$wpdb->cpd_counter</code>")."</p></div>\n";
1171
+ }
1172
+ elseif ( strpos($path, 'count_per_day_options') )
1173
+ {
1174
+ // options
1175
+ $backup = ($gz) ? gzread($f, 500000) : fread($f, filesize($path));
1176
+ $entries = array('count_per_day', 'count_per_day_summary', 'count_per_day_collected', 'count_per_day_posts', 'count_per_day_notes');
1177
+ foreach ( $entries as $entry )
1178
+ {
1179
+ $s = strpos($backup, "=== begin $entry ===") + strlen($entry) + 14;
1180
+ $e = strpos($backup, "=== end $entry ===");
1181
+ $option = trim(substr($backup, $s, $e - $s));
1182
+ update_option($entry, unserialize($option));
1183
+ }
1184
+ $this->options = get_option('count_per_day');
1185
+ unset($backup);
1186
+ unset($option);
1187
+ echo '<div class="updated"><p>'.__('Options restored from backup.', 'cpd')."</p></div>\n";
1188
+ }
1189
+ ($gz) ? gzclose($f) : fclose($f);
1190
+ }
1191
+
1192
+ }
1193
1194
function addCollectionToCountries( $visitors, $limit = false )
1195
{
1212
ORDER BY c DESC";
1213
$res = $this->mysqlQuery('rows', $sql, 'getCountries '.__LINE__);
1214
1215
+ $temp = array();
1216
foreach ( $res as $r )
1217
$temp[$r->country] = $r->c;
1218
1325
$s = get_option('count_per_day_summary', array());
1326
if ( empty($s['firstcount']) )
1327
{
1328
+ // first day from table
1329
$res = $this->mysqlQuery('var', "SELECT MIN(date) FROM $wpdb->cpd_counter", 'getFirstCount'.__LINE__);
1330
if ($res)
1331
{
1366
*/
1367
function flush_buffers()
1368
{
1369
+ echo "\n<!--".str_repeat(' ', 4100)."-->\n";
1370
+ $levels = ob_get_level();
1371
+ for ( $i = 0; $i < $levels; $i++ )
1372
{
1373
+ $b = ob_get_status();
1374
+ if ( strpos($b['name'], 'zlib') === false )
1375
+ {
1376
+ @ob_end_flush();
1377
+ @ob_flush();
1378
+ @flush();
1379
+ }
1380
+ }
1381
@ob_start();
1382
}
1383
1398
return $val;
1399
}
1400
1401
+ /**
1402
+ * try to get the search strings from referrer
1403
+ */
1404
+ function getSearchString()
1405
+ {
1406
+ if (empty($_SERVER['HTTP_REFERER']))
1407
+ return false;
1408
+ $ref = parse_url(rawurldecode($_SERVER['HTTP_REFERER']));
1409
+ if ( empty($ref['host']) || empty($ref['query']) )
1410
+ return false;
1411
+ $keys = array('p','q','s','query','search','prev','qkw','qry');
1412
+ parse_str($ref['query'], $query);
1413
+ foreach ($keys as $key)
1414
+ if (isset($query[$key]))
1415
+ $search = str_ireplace(array('/search?q=','/images?q='), '', $query[$key]);
1416
+ if (empty($search) || is_numeric($search)) // non WordPress postID
1417
+ $search = '';
1418
+ return $search;
1419
+ }
1420
+
1421
+
1422
} // class
counter-options.php CHANGED
@@ -4,6 +4,8 @@
4
* Count Per Day - Options and Administration
5
*/
6
7
// check form
8
if(!empty($_POST['do']))
9
{
@@ -57,7 +59,7 @@ if(!empty($_POST['do']))
57
$count_per_day->queries[] = 'cpd_countries - class "CpdGeoIp" exists';
58
$rest = CpdGeoIp::updateDB();
59
echo '<div class="updated">
60
- <form name="cpdcountries" method="post" action="'.$_SERVER['REQUEST_URI'].'">
61
<p>'.sprintf(__('Countries updated. <b>%s</b> entries in %s without country left', 'cpd'), $rest, $wpdb->cpd_counter);
62
if ( $rest > 0 )
63
echo '<input type="hidden" name="do" value="cpd_countries" />
@@ -97,7 +99,7 @@ if(!empty($_POST['do']))
97
$sum = 0;
98
foreach ($bots as $r)
99
{
100
- $count_per_day->mysqlQuery('', "DELETE FROM $wpdb->cpd_counter WHERE ip = INET_ATON('$r->ip') AND date = '$r->date'", 'deleteMassbots '.__LINE__);
101
$sum += $r->posts;
102
}
103
if ( $sum )
@@ -108,9 +110,6 @@ if(!empty($_POST['do']))
108
// clean database
109
case 'cpd_clean' :
110
$rows = $count_per_day->cleanDB();
111
- delete_option('count_per_day_summary');
112
- delete_option('count_per_day_collected');
113
- delete_option('count_per_day_posts');
114
echo '<div class="updated"><p>'.sprintf(__('Database cleaned. %s rows deleted.', 'cpd'), $rows).'</p></div>';
115
break;
116
@@ -166,57 +165,79 @@ if(!empty($_POST['do']))
166
$s = array( // summary
167
'reads' => $count_per_day->getCollectedReads(),
168
'users' => $count_per_day->getCollectedUsers() );
169
- $mold = 0; // current month
170
- $countryold = '#'; // current country
171
172
echo '<div id="cpd_progress_collection" class="updated"><p>'.__('Collection in progress...', 'cpd').' ';
173
$count_per_day->flush_buffers();
174
175
- $sql = "
176
SELECT LEFT(date,7) month, COUNT(*) c, country
177
FROM $wpdb->cpd_counter
178
- WHERE date < DATE_SUB( DATE_FORMAT(CURDATE(), '%%Y-%%m-01'), INTERVAL $keep MONTH )
179
- GROUP BY date, country, ip
180
- ORDER BY LEFT(date,7), country";
181
- $res = $count_per_day->mysqlQuery('rows', $sql, 'getReadsPerMonthsCompress '.__LINE__);
182
-
183
foreach ($res as $r)
184
{
185
- $reads = (int) $r->c;
186
- $s['reads'] += $reads;
187
- $s['users'] += 1;
188
$country = ($r->country) ? $r->country : '-';
189
-
190
- if ( $r->month != $mold )
191
- {
192
- // new month row
193
- $month = str_replace('-','',$r->month);
194
- $d[$month]['reads'] = $reads;
195
- $d[$month]['users'] = 1;
196
- $t[$month][$country]['reads'] = $reads;
197
- $t[$month][$country]['users'] = 1;
198
- $mold = $r->month;
199
- echo "| ";
200
- $count_per_day->flush_buffers();
201
- }
202
- else if ( $country != $countryold )
203
- {
204
- // new country
205
- $d[$month]['reads'] += $reads;
206
- $d[$month]['users'] += 1;
207
- $t[$month][$country]['reads'] = $reads;
208
- $t[$month][$country]['users'] = 1;
209
- $countryold = $country;
210
- }
211
- else
212
- {
213
- // new visitor/ip
214
- $d[$month]['reads'] += $reads;
215
- $d[$month]['users'] += 1;
216
- $t[$month][$country]['reads'] += $reads;
217
- $t[$month][$country]['users'] += 1;
218
- }
219
}
220
221
// format country data as "country:reads|visitors;"
222
foreach ($t as $month => $cdata)
@@ -242,13 +263,13 @@ if(!empty($_POST['do']))
242
echo "<br />".__('Get Visitors per Post...', 'cpd')."\n";
243
$count_per_day->flush_buffers();
244
245
- $sql = "
246
SELECT COUNT(*) count, page
247
FROM $wpdb->cpd_counter
248
- WHERE date < DATE_SUB( DATE_FORMAT(CURDATE(), '%%Y-%%m-01'), INTERVAL $keep MONTH )
249
AND page
250
GROUP BY page";
251
- $res = $count_per_day->mysqlQuery('rows', $sql, 'getUsersPerPostCompress '.__LINE__);
252
253
$p = get_option('count_per_day_posts',array());
254
foreach ($res as $r)
@@ -272,10 +293,10 @@ if(!empty($_POST['do']))
272
273
// delete entries
274
$sizeold = $count_per_day->getTableSize($wpdb->cpd_counter);
275
- $sql = "
276
DELETE FROM $wpdb->cpd_counter
277
- WHERE date < DATE_SUB( DATE_FORMAT(CURDATE(), '%%Y-%%m-01'), INTERVAL $keep MONTH )";
278
- $count_per_day->mysqlQuery('', $sql, 'deleteAfterCollection '.__LINE__);
279
$count_per_day->mysqlQuery('', "REPAIR TABLE `$wpdb->cpd_counter`", 'repairTable '.__LINE__);
280
$sizenew = $count_per_day->getTableSize($wpdb->cpd_counter);
281
@@ -295,6 +316,20 @@ if(!empty($_POST['do']))
295
$count_per_day->checkVersion();
296
echo '<div class="updated"><p>'.__('Installation of "Count per Day" checked', 'cpd').'</p></div>';
297
break;
298
299
default:
300
break;
@@ -307,6 +342,15 @@ if ( isset($_GET['dmbip']) && isset($_GET['dmbdate']) )
307
308
if ( empty($mode) )
309
$mode = '';
310
311
switch($mode) {
312
// deactivation
@@ -333,233 +377,16 @@ switch($mode) {
333
update_option('count_per_day', $o);
334
}
335
?>
336
- <div id="cpdsettings" class="wrap">
337
- <h2><img src="<?php echo $count_per_day->img('cpd_menu.gif') ?>" alt="" style="width:24px;height:24px" /> Count per Day</h2>
338
-
339
- <div id="poststuff" class="cpd_settings">
340
-
341
- <div class="postbox">
342
- <h3>
343
- <span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Settings') ?> |
344
- <span class="cpd_icon cpd_tools">&nbsp;</span> <a href="#cpdtools"><?php _e('Tools') ?></a>
345
- </h3>
346
- </div>
347
-
348
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
349
-
350
- <?php // counter ?>
351
- <fieldset>
352
- <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Counter', 'cpd') ?></legend>
353
-
354
- <table class="form-table">
355
- <tr>
356
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Online time', 'cpd') ?>:</th>
357
- <td><input class="code" type="text" name="cpd_onlinetime" size="3" value="<?php echo $o['onlinetime']; ?>" /> <?php _e('Seconds for online counter. Used for "Visitors online" on dashboard page.', 'cpd') ?></td>
358
- </tr>
359
- <tr>
360
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Logged on Users', 'cpd') ?>:</th>
361
- <td>
362
- <label for="cpd_user"><input type="checkbox" name="cpd_user" id="cpd_user" <?php if($o['user']==1) echo 'checked="checked"'; ?> /> <?php _e('count too', 'cpd') ?></label>
363
- - <?php _e('until User Level', 'cpd') ?>
364
- <select name="cpd_user_level">
365
- <option value="10" <?php selected($o['user_level'], 10) ?>><?php echo translate_user_role('Administrator') ?> (10)</option>
366
- <option value="7" <?php selected($o['user_level'], 7) ?>><?php echo translate_user_role('Editor') ?> (7)</option>
367
- <option value="2" <?php selected($o['user_level'], 2) ?>><?php echo translate_user_role('Author') ?> (2)</option>
368
- <option value="1" <?php selected($o['user_level'], 1) ?>><?php echo translate_user_role('Contributor') ?> (1)</option>
369
- <option value="0" <?php selected($o['user_level'], 0) ?>><?php echo translate_user_role('Subscriber') ?> (0)</option>
370
- </select>
371
- </td>
372
- </tr>
373
- <tr>
374
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Auto counter', 'cpd') ?>:</th>
375
- <td><label for="cpd_autocount"><input type="checkbox" name="cpd_autocount" id="cpd_autocount" <?php checked($o['autocount'], 1) ?> /> <?php _e('Counts automatically single-posts and pages, no changes on template needed.', 'cpd') ?></label></td>
376
- </tr>
377
- <tr>
378
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Bots to ignore', 'cpd') ?>:</th>
379
- <td><textarea name="cpd_bots" cols="50" rows="10"><?php echo $o['bots']; ?></textarea></td>
380
- </tr>
381
- <tr>
382
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Anonymous IP', 'cpd') ?>:</th>
383
- <td><label for="cpd_anoip"><input type="checkbox" name="cpd_anoip" id="cpd_anoip" <?php checked($o['anoip'], 1) ?> /> a.b.c.d &gt; a.b.c.x</label></td>
384
- </tr>
385
- <tr>
386
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Cache', 'cpd') ?> (beta):</th>
387
- <td><label for="cpd_ajax"><input type="checkbox" name="cpd_ajax" id="cpd_ajax" <?php checked($o['ajax'], 1) ?> /> <?php _e('I use a cache plugin. Count these visits with ajax.', 'cpd') ?></label></td>
388
- </tr>
389
- <tr>
390
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Clients and referrers', 'cpd') ?>:</th>
391
- <td>
392
- <label for="cpd_referers"><input type="checkbox" name="cpd_referers" id="cpd_referers" <?php checked($o['referers'], 1) ?> />
393
- <?php _e('Save and show clients and referrers.<br />Needs a lot of space in the database but gives you more detailed informations of your visitors.', 'cpd') ?> (1000000 <?php _e('Reads', 'cpd') ?> ~ 130 MB)</label><br/>
394
- <label for="cpd_referers_cut"><input type="checkbox" name="cpd_referers_cut" id="cpd_referers_cut" <?php checked($o['referers_cut'], 1) ?> />
395
- <?php _e('Save URL only, no query string.', 'cpd') ?> <code>http://example.com/webhp?hl=de#sclient=psy&amp;hl=de...</code> &gt; <code>http://example.com/webhp</code></label>
396
- </td>
397
- </tr>
398
- </table>
399
- </fieldset>
400
-
401
- <?php // dashboard ?>
402
- <fieldset>
403
- <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Dashboard') ?></legend>
404
-
405
- <script type="text/javascript">
406
- function checkcustom()
407
- {
408
- var b = document.getElementById('cpd_whocansee');
409
- var i = document.getElementById('cpd_whocansee_custom_div');
410
- if ( b.value == 'custom' )
411
- i.style.display = 'block';
412
- else
413
- i.style.display = 'none';
414
- }
415
- </script>
416
-
417
- <table class="form-table">
418
- <tr>
419
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Who can see it', 'cpd') ?>:</th>
420
- <td>
421
- <?php $cus = (in_array($o['whocansee'], array('manage_options','manage_links','publish_posts','edit_posts','read'))) ? 0 : 1 ?>
422
- <select id="cpd_whocansee" name="cpd_whocansee" onchange="checkcustom()">
423
- <option value="manage_options" <?php selected($o['whocansee'], 'manage_options') ?>><?php echo translate_user_role('Administrator') ?> </option>
424
- <option value="manage_links" <?php selected($o['whocansee'], 'manage_links') ?>><?php echo translate_user_role('Editor') ?></option>
425
- <option value="publish_posts" <?php selected($o['whocansee'], 'publish_posts') ?>><?php echo translate_user_role('Author') ?></option>
426
- <option value="edit_posts" <?php selected($o['whocansee'], 'edit_posts') ?>><?php echo translate_user_role('Contributor') ?></option>
427
- <option value="read" <?php selected($o['whocansee'], 'read') ?>><?php echo translate_user_role('Subscriber') ?></option>
428
- <option value="custom" <?php selected($cus) ?>>- <?php echo _e('custom', 'cpd') ?> -</option>
429
- </select>
430
- <?php _e('and higher are allowed to see the statistics page.', 'cpd') ?>
431
- <div id="cpd_whocansee_custom_div" <?php if (!$cus) echo 'style="display:none"' ?>>
432
- <?php printf(__('Set the %s capability %s a user need:', 'cpd'), '<a href="https://codex.wordpress.org/Roles_and_Capabilities">', '</a>'); ?>
433
- <input type="text" name="cpd_whocansee_custom" value="<?php echo $o['whocansee'] ?>" />
434
- </div>
435
- </td>
436
- </tr>
437
- <tr>
438
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Visitors per post', 'cpd') ?>:</th>
439
- <td><input class="code" type="text" name="cpd_dashboard_posts" size="3" value="<?php echo $o['dashboard_posts']; ?>" /> <?php _e('How many posts do you want to see on dashboard page?', 'cpd') ?></td>
440
- </tr>
441
- <tr>
442
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Latest Counts - Posts', 'cpd') ?>:</th>
443
- <td><input class="code" type="text" name="cpd_dashboard_last_posts" size="3" value="<?php echo $o['dashboard_last_posts']; ?>" /> <?php _e('How many posts do you want to see on dashboard page?', 'cpd') ?></td>
444
- </tr>
445
- <tr>
446
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Latest Counts - Days', 'cpd') ?>:</th>
447
- <td><input class="code" type="text" name="cpd_dashboard_last_days" size="3" value="<?php echo $o['dashboard_last_days']; ?>" /> <?php _e('How many days do you want look back?', 'cpd') ?></td>
448
- </tr>
449
- <tr>
450
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Chart - Days', 'cpd') ?>:</th>
451
- <td><input class="code" type="text" name="cpd_chart_days" size="3" value="<?php echo $o['chart_days']; ?>" /> <?php _e('How many days do you want look back?', 'cpd') ?></td>
452
- </tr>
453
- <tr>
454
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Chart - Height', 'cpd') ?>:</th>
455
- <td><input class="code" type="text" name="cpd_chart_height" size="3" value="<?php echo $o['chart_height']; ?>" /> px - <?php _e('Height of the biggest bar', 'cpd') ?></td>
456
- </tr>
457
- <?php if ($cpd_geoip) { ?>
458
- <tr>
459
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Countries', 'cpd') ?>:</th>
460
- <td><input class="code" type="text" name="cpd_countries" size="3" value="<?php echo $o['countries']; ?>" /> <?php _e('How many countries do you want to see on dashboard page?', 'cpd') ?></td>
461
- </tr>
462
- <?php } ?>
463
- <tr>
464
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Browsers', 'cpd') ?>:</th>
465
- <td><input class="code" type="text" name="cpd_clients" size="50" value="<?php echo $o['clients']; ?>" /> <?php _e('Substring of the user agent, separated by comma', 'cpd') ?></td>
466
- </tr>
467
- <tr>
468
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Referrers - Entries', 'cpd') ?>:</th>
469
- <td><input class="code" type="text" name="cpd_dashboard_referers" size="3" value="<?php echo $o['dashboard_referers']; ?>" /> <?php _e('How many referrers do you want to see on dashboard page?', 'cpd') ?></td>
470
- </tr>
471
- <tr>
472
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Referrers - Days', 'cpd') ?>:</th>
473
- <td><input class="code" type="text" name="cpd_referers_last_days" size="3" value="<?php echo $o['referers_last_days']; ?>" /> <?php _e('How many days do you want look back?', 'cpd') ?></td>
474
- </tr>
475
- <tr>
476
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Local URLs', 'cpd') ?>:</th>
477
- <td><label for="cpd_localref"><input type="checkbox" name="cpd_localref" id="cpd_localref" <?php checked($o['localref'], 1) ?> /> <?php _e('Show local referrers too.', 'cpd') ?> (<?php echo bloginfo('url') ?>/...)</label></td>
478
- </tr>
479
- </table>
480
- </fieldset>
481
-
482
- <?php // lists ?>
483
- <fieldset>
484
- <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Posts') ?> / <?php _e('Pages') ?></legend>
485
- <table class="form-table">
486
- <tr>
487
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Show in lists', 'cpd') ?>:</th>
488
- <td><label for="cpd_show_in_lists"><input type="checkbox" name="cpd_show_in_lists" id="cpd_show_in_lists" <?php checked($o['show_in_lists'], 1) ?> /> <?php _e('Show "Reads per Post" in a new column in post management views.', 'cpd') ?></label></td>
489
- </tr>
490
- </table>
491
- </fieldset>
492
-
493
- <?php // start values ?>
494
- <fieldset>
495
- <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Start Values', 'cpd') ?></legend>
496
- <table class="form-table">
497
- <tr>
498
- <th colspan="2">
499
- <?php _e('Here you can change the date of first count and add a start count.', 'cpd')?>
500
- </th>
501
- </tr>
502
- <tr>
503
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Start date', 'cpd') ?>:</th>
504
- <td><input class="code" type="text" name="cpd_startdate" size="10" value="<?php echo $o['startdate']; ?>" /> <?php _e('Your old Counter starts at?', 'cpd') ?> [yyyy-mm-dd]</td>
505
- </tr>
506
- <tr>
507
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Start count', 'cpd') ?>:</th>
508
- <td><input class="code" type="text" name="cpd_startcount" size="10" value="<?php echo $o['startcount']; ?>" /> <?php _e('Add this value to "Total visitors".', 'cpd') ?></td>
509
- </tr>
510
- <tr>
511
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Start count', 'cpd') ?>:</th>
512
- <td><input class="code" type="text" name="cpd_startreads" size="10" value="<?php echo $o['startreads']; ?>" /> <?php _e('Add this value to "Total reads".', 'cpd') ?></td>
513
- </tr>
514
- </table>
515
- </fieldset>
516
-
517
- <?php // stylesheet ?>
518
- <fieldset>
519
- <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Stylesheet', 'cpd') ?></legend>
520
- <table class="form-table">
521
- <tr>
522
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('NO Stylesheet in Frontend', 'cpd') ?>:</th>
523
- <td><label for="cpd_no_front_css"><input type="checkbox" name="cpd_no_front_css" id="cpd_no_front_css" <?php checked($o['no_front_css'], 1) ?> /> <?php _e('Do not load the stylesheet "counter.css" in frontend.', 'cpd') ?></label></td>
524
- </tr>
525
- </table>
526
- </fieldset>
527
-
528
- <?php // backup ?>
529
- <fieldset>
530
- <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Backup', 'cpd') ?></legend>
531
- <table class="form-table">
532
- <tr>
533
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Entries per pass', 'cpd') ?>:</th>
534
- <td>
535
- <input class="code" type="text" name="cpd_backup_part" size="10" value="<?php echo $o['backup_part']; ?>" />
536
- <?php _e('How many entries should be saved per pass? Default: 10000', 'cpd') ?><br/>
537
- </td>
538
- </tr>
539
- <tr>
540
- <td colspan="2">
541
- <?php _e('If your PHP memory limit less then 50 MB and you get a white page or error messages try a smaller value.', 'cpd') ?>
542
- </td>
543
- </tr>
544
- </table>
545
- </fieldset>
546
-
547
- <?php // debug ?>
548
- <fieldset>
549
- <legend style="color:red"><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Debug mode', 'cpd') ?></legend>
550
- <p style="margin-top:15px;margin-left:10px">
551
- <label for="cpd_debug"><input type="checkbox" name="cpd_debug" id="cpd_debug" <?php checked($o['debug'], 1) ?> /> <?php _e('Show debug informations at the bottom of all pages.', 'cpd') ?></label>
552
- </p>
553
- </fieldset>
554
-
555
- <input type="hidden" name="do" value="cpd_update" />
556
- <input type="submit" name="update" value="<?php _e('Update options', 'cpd') ?>" class="button-primary" style="margin-left: 5px;" />
557
- </form>
558
559
- <div id="cpdtools" class="postbox" style="margin-top:40px">
560
- <h3><span class="cpd_icon cpd_settings">&nbsp;</span> <a href="#cpdsettings"><?php _e('Settings') ?></a> |
561
- <span class="cpd_icon cpd_tools">&nbsp;</span> <?php _e('Tools') ?></h3>
562
- </div>
563
564
<?php // mass bots ?>
565
<div class="postbox">
@@ -574,14 +401,14 @@ switch($mode) {
574
?>
575
<h3><span class="cpd_icon cpd_massbots">&nbsp;</span> <?php _e('Mass Bots', 'cpd') ?></h3>
576
<div class="inside">
577
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>#cpdtools">
578
<p>
579
<?php printf(__('Show all IPs with more than %s page views per day', 'cpd'), $limit_input) ?>
580
<input type="submit" name="showmassbots" value="<?php _e('show', 'cpd') ?>" class="button" />
581
</p>
582
</form>
583
584
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
585
<table class="widefat post">
586
<thead>
587
<tr>
@@ -633,7 +460,7 @@ switch($mode) {
633
<div class="postbox">
634
<h3><span class="cpd_icon cpd_backup">&nbsp;</span> <?php _e('Backup', 'cpd') ?></h3>
635
<div class="inside">
636
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
637
<p>
638
<?php printf(__('Create a backup of the counter table %s in your wp-content directory (if writable).', 'cpd'), '<code>'.$wpdb->cpd_counter.'</code>') ?>
639
</p>
@@ -645,12 +472,9 @@ switch($mode) {
645
<input type="submit" name="backup" value="<?php _e('Backup the database', 'cpd') ?>" class="button" />
646
</p>
647
</form>
648
- <p>
649
<?php
650
if ( is_writable(WP_CONTENT_DIR) )
651
{
652
- $nonce = wp_create_nonce('cpdnonce');
653
-
654
// delete file?
655
if ( isset($_GET['cpddel']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'cpdnonce') )
656
$delfile = WP_CONTENT_DIR.'/'.$_GET['cpddel'];
@@ -664,15 +488,47 @@ switch($mode) {
664
$dirarray[] = $entry;
665
$d->close();
666
sort($dirarray); // sort by names on all servers
667
foreach ( $dirarray as $entry )
668
if ( preg_match('/count_per_day|cpd_counter/i', $entry) )
669
- echo '<a href="?page=count-per-day/counter-options.php&amp;_wpnonce='.$nonce.'&amp;cpddel='.$entry.'"
670
- style="color:red;font-weight:bold;text-decoration:none" title="'.__('Delete').'"
671
- onclick="return confirm(\''.sprintf(__('Delete the backup file %s ?','cpd'), '\n'.$entry).'\')">X</a>
672
- <a href="'.content_url().'/'.$entry.'" style="text-decoration:none">'.$entry.'</a> - '.$count_per_day->formatbytes(filesize(WP_CONTENT_DIR.'/'.$entry)).'<br/>';
673
}
674
?>
675
- </p>
676
</div>
677
</div>
678
@@ -684,13 +540,20 @@ switch($mode) {
684
<p>
685
<?php _e('You can clean the counter table by delete the "spam data".<br />If you add new bots above the old "spam data" keeps in the database.<br />Here you can run the bot filter again and delete the visits of the bots.', 'cpd') ?>
686
</p>
687
-
688
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
689
<p>
690
<input type="hidden" name="do" value="cpd_clean" />
691
<input type="submit" name="clean" value="<?php _e('Clean the database', 'cpd') ?>" class="button" />
692
</p>
693
</form>
694
</div>
695
</div>
696
<?php endif; ?>
@@ -699,7 +562,7 @@ switch($mode) {
699
<div class="postbox">
700
<h3><span class="cpd_icon cpd_collection">&nbsp;</span> <?php _e('Collect old data', 'cpd') ?></h3>
701
<div class="inside">
702
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
703
<p>
704
<?php
705
printf(__('Current size of your counter table %s is %s.', 'cpd'), '<code>'.$wpdb->cpd_counter.'</code>', $count_per_day->getTableSize($wpdb->cpd_counter));
@@ -735,14 +598,6 @@ switch($mode) {
735
</div>
736
</div>
737
738
- <!-- Plugin page -->
739
- <div class="postbox">
740
- <h3><span class="cpd_icon cpd_help">&nbsp;</span> <?php _e('Support', 'cpd') ?></h3>
741
- <div class="inside">
742
- <?php $count_per_day->cpdInfo() ?>
743
- </div>
744
- </div>
745
-
746
</div> <!-- left column -->
747
748
<!-- right column -->
@@ -756,7 +611,7 @@ switch($mode) {
756
<?php _e('You can get the country data for all entries in database by checking the IP adress against the GeoIP database. This can take a while!', 'cpd') ?>
757
</p>
758
<?php if ( $cpd_geoip ) { ?>
759
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
760
<p>
761
<input type="hidden" name="do" value="cpd_countries" />
762
<input type="submit" name="updcon" value="<?php _e('Update old counter data', 'cpd') ?>" class="button" />
@@ -768,7 +623,7 @@ switch($mode) {
768
// install or update database
769
echo '<p>'.__('Download a new version of GeoIP.dat file.', 'cpd').'</p>';
770
?>
771
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
772
<p>
773
<input type="hidden" name="do" value="cpd_countrydb" />
774
<input type="submit" name="updcondb" value="<?php _e('Update GeoIP database', 'cpd') ?>" class="button" />
@@ -789,7 +644,7 @@ switch($mode) {
789
<p>
790
<?php _e('Here you can start the installation functions manually.<br/>Same as deactivate and reactivate the plugin.', 'cpd') ?>
791
</p>
792
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
793
<p>
794
<input type="hidden" name="do" value="cpd_activate" />
795
<input type="submit" name="activate" value="<?php _e('ReActivate the plugin', 'cpd') ?>" class="button" />
@@ -806,7 +661,7 @@ switch($mode) {
806
<?php _e('You can reset the counter by empty the table. ALL TO 0!<br />Make a backup if you need the current data!', 'cpd') ?>
807
</p>
808
809
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
810
<p>
811
<input type="hidden" name="do" value="cpd_reset" />
812
<input type="checkbox" name="reset_cpd_yes" value="yes" />&nbsp;<?php _e('Yes', 'cpd'); ?> &nbsp;
@@ -817,7 +672,7 @@ switch($mode) {
817
</div>
818
819
<!-- Uninstall -->
820
- <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
821
<div class="postbox">
822
<h3><span class="cpd_icon cpd_uninstall">&nbsp;</span> <?php _e('Uninstall', 'cpd') ?></h3>
823
<div class="inside">
@@ -838,9 +693,236 @@ switch($mode) {
838
</div>
839
</div>
840
</form>
841
-
842
</div> <!-- right column -->
843
- <div class="clear"></div>
844
845
</div><!-- poststuff -->
846
</div><!-- wrap -->
4
* Count Per Day - Options and Administration
5
*/
6
7
+ $mysiteurl = substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'counter-options.php') + 19);
8
+
9
// check form
10
if(!empty($_POST['do']))
11
{
59
$count_per_day->queries[] = 'cpd_countries - class "CpdGeoIp" exists';
60
$rest = CpdGeoIp::updateDB();
61
echo '<div class="updated">
62
+ <form name="cpdcountries" method="post" action="'.$mysiteurl.'">
63
<p>'.sprintf(__('Countries updated. <b>%s</b> entries in %s without country left', 'cpd'), $rest, $wpdb->cpd_counter);
64
if ( $rest > 0 )
65
echo '<input type="hidden" name="do" value="cpd_countries" />
99
$sum = 0;
100
foreach ($bots as $r)
101
{
102
+ $count_per_day->mysqlQuery('', "DELETE FROM $wpdb->cpd_counter WHERE ip = $this->aton('$r->ip') AND date = '$r->date'", 'deleteMassbots '.__LINE__);
103
$sum += $r->posts;
104
}
105
if ( $sum )
110
// clean database
111
case 'cpd_clean' :
112
$rows = $count_per_day->cleanDB();
113
echo '<div class="updated"><p>'.sprintf(__('Database cleaned. %s rows deleted.', 'cpd'), $rows).'</p></div>';
114
break;
115
165
$s = array( // summary
166
'reads' => $count_per_day->getCollectedReads(),
167
'users' => $count_per_day->getCollectedUsers() );
168
169
echo '<div id="cpd_progress_collection" class="updated"><p>'.__('Collection in progress...', 'cpd').' ';
170
$count_per_day->flush_buffers();
171
172
+ $today = date('Y-m-01');
173
+
174
+ // reads per month
175
+ $cpd_sql = "
176
+ SELECT LEFT(date,7) month, COUNT(*) c
177
+ FROM $wpdb->cpd_counter
178
+ WHERE date < DATE_SUB( '$today', INTERVAL $keep MONTH )
179
+ GROUP BY LEFT(date,7)";
180
+ $res = $count_per_day->mysqlQuery('rows', $cpd_sql, "getReadsPerMonthCompress ".__LINE__);
181
+ foreach ($res as $r)
182
+ {
183
+ $month = str_replace('-','',$r->month);
184
+ $d[$month]['reads'] = $r->c;
185
+ $s['reads'] += $r->c;
186
+ }
187
+ unset($res);
188
+
189
+ // visitors per month
190
+ $cpd_sql = "
191
+ SELECT LEFT(date,7) month, COUNT(*) c
192
+ FROM (
193
+ SELECT date
194
+ FROM $wpdb->cpd_counter
195
+ WHERE date < DATE_SUB( '$today', INTERVAL $keep MONTH )
196
+ GROUP BY date, ip
197
+ ) AS t
198
+ GROUP BY LEFT(date,7)";
199
+ $res = $count_per_day->mysqlQuery('rows', $cpd_sql, "getVisitorsPerMonthCompress ".__LINE__);
200
+ foreach ($res as $r)
201
+ {
202
+ $month = str_replace('-','',$r->month);
203
+ $d[$month]['users'] = $r->c;
204
+ $s['users'] += $r->c;
205
+ }
206
+ unset($res);
207
+
208
+ // reads per month and country
209
+ $cpd_sql = "
210
SELECT LEFT(date,7) month, COUNT(*) c, country
211
FROM $wpdb->cpd_counter
212
+ WHERE date < DATE_SUB( '$today', INTERVAL $keep MONTH )
213
+ GROUP BY LEFT(date,7), country";
214
+ $res = $count_per_day->mysqlQuery('rows', $cpd_sql, "getReadsPerCountryCompress ".__LINE__);
215
foreach ($res as $r)
216
{
217
+ $month = str_replace('-','',$r->month);
218
$country = ($r->country) ? $r->country : '-';
219
+ $t[$month][$country]['reads'] = $r->c;
220
+ }
221
+ unset($res);
222
+
223
+ // visitors per month and country
224
+ $cpd_sql = "
225
+ SELECT LEFT(date,7) month, COUNT(*) c, country
226
+ FROM (
227
+ SELECT date, country
228
+ FROM $wpdb->cpd_counter
229
+ WHERE date < DATE_SUB( '$today', INTERVAL $keep MONTH )
230
+ GROUP BY date, ip, country
231
+ ) AS t
232
+ GROUP BY LEFT(date,7), country";
233
+ $res = $count_per_day->mysqlQuery('rows', $cpd_sql, "getVisitorsPerCountryCompress ".__LINE__);
234
+ foreach ($res as $r)
235
+ {
236
+ $month = str_replace('-','',$r->month);
237
+ $country = ($r->country) ? $r->country : '-';
238
+ $t[$month][$country]['users'] = $r->c;
239
}
240
+ unset($res);
241
242
// format country data as "country:reads|visitors;"
243
foreach ($t as $month => $cdata)
263
echo "<br />".__('Get Visitors per Post...', 'cpd')."\n";
264
$count_per_day->flush_buffers();
265
266
+ $cpd_sql = "
267
SELECT COUNT(*) count, page
268
FROM $wpdb->cpd_counter
269
+ WHERE date < DATE_SUB( '$today', INTERVAL $keep MONTH )
270
AND page
271
GROUP BY page";
272
+ $res = $count_per_day->mysqlQuery('rows', $cpd_sql, 'getUsersPerPostCompress '.__LINE__);
273
274
$p = get_option('count_per_day_posts',array());
275
foreach ($res as $r)
293
294
// delete entries
295
$sizeold = $count_per_day->getTableSize($wpdb->cpd_counter);
296
+ $cpd_sql = "
297
DELETE FROM $wpdb->cpd_counter
298
+ WHERE date < DATE_SUB( '$today', INTERVAL $keep MONTH )";
299
+ $count_per_day->mysqlQuery('', $cpd_sql, 'deleteAfterCollection '.__LINE__);
300
$count_per_day->mysqlQuery('', "REPAIR TABLE `$wpdb->cpd_counter`", 'repairTable '.__LINE__);
301
$sizenew = $count_per_day->getTableSize($wpdb->cpd_counter);
302
316
$count_per_day->checkVersion();
317
echo '<div class="updated"><p>'.__('Installation of "Count per Day" checked', 'cpd').'</p></div>';
318
break;
319
+
320
+ // delete search strings
321
+ case 'cpd_searchclean' :
322
+ $days = intval($_POST['cpd_keepsearch']);
323
+ $deldate = date('Y-m-d', time() - $days * 86400);
324
+ $searches = get_option('count_per_day_search', array());
325
+ foreach ( $searches as $k => $v )
326
+ {
327
+ if ( $k < $deldate )
328
+ unset($searches[$k]);
329
+ }
330
+ update_option('count_per_day_search', $searches);
331
+ unset($searches);
332
+ echo '<div class="updated"><p>'.__('Old search strings deleted', 'cpd').'</p></div>';
333
334
default:
335
break;
342
343
if ( empty($mode) )
344
$mode = '';
345
+
346
+ $nonce = wp_create_nonce('cpdnonce');
347
+
348
+ // restore from backup file
349
+ if ( isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'cpdnonce')
350
+ && ( isset($_GET['cpdrestore']) || isset($_GET['cpdadding']) ) )
351
+ {
352
+ $count_per_day->restore();
353
+ }
354
355
switch($mode) {
356
// deactivation
377
update_option('count_per_day', $o);
378
}
379
?>
380
+ <div id="cpdtools" style="position:absolute;top:-31px;height:0x;"></div>
381
+ <div id="cpdtoolccs" class="wrap">
382
383
+ <h2 class="nav-tab-wrapper" style="padding-bottom:0;margin-bottom:20px;">
384
+ <img src="<?php echo $count_per_day->img('cpd_menu.gif') ?>" alt="" style="width:24px;height:24px" /> Count per Day
385
+ <a class="nav-tab nav-tab-active" href="#cpdtools"><span class="cpd_icon cpd_tools">&nbsp;</span> <?php _e('Tools') ?></a>
386
+ <a class="nav-tab" href="#cpdsettings"><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Settings') ?></a>
387
+ </h2>
388
+
389
+ <div id="poststuff" class="cpd_settings">
390
391
<?php // mass bots ?>
392
<div class="postbox">
401
?>
402
<h3><span class="cpd_icon cpd_massbots">&nbsp;</span> <?php _e('Mass Bots', 'cpd') ?></h3>
403
<div class="inside">
404
+ <form method="post" action="<?php echo $mysiteurl ?>#cpdtools">
405
<p>
406
<?php printf(__('Show all IPs with more than %s page views per day', 'cpd'), $limit_input) ?>
407
<input type="submit" name="showmassbots" value="<?php _e('show', 'cpd') ?>" class="button" />
408
</p>
409
</form>
410
411
+ <form method="post" action="<?php echo $mysiteurl ?>">
412
<table class="widefat post">
413
<thead>
414
<tr>
460
<div class="postbox">
461
<h3><span class="cpd_icon cpd_backup">&nbsp;</span> <?php _e('Backup', 'cpd') ?></h3>
462
<div class="inside">
463
+ <form method="post" action="<?php echo $mysiteurl ?>">
464
<p>
465
<?php printf(__('Create a backup of the counter table %s in your wp-content directory (if writable).', 'cpd'), '<code>'.$wpdb->cpd_counter.'</code>') ?>
466
</p>
472
<input type="submit" name="backup" value="<?php _e('Backup the database', 'cpd') ?>" class="button" />
473
</p>
474
</form>
475
<?php
476
if ( is_writable(WP_CONTENT_DIR) )
477
{
478
// delete file?
479
if ( isset($_GET['cpddel']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'cpdnonce') )
480
$delfile = WP_CONTENT_DIR.'/'.$_GET['cpddel'];
488
$dirarray[] = $entry;
489
$d->close();
490
sort($dirarray); // sort by names on all servers
491
+ $captionO = 0;
492
+ $captionB = 0;
493
+ $link = '<td><a href="?page=count-per-day/counter-options.php&amp;_wpnonce='.$nonce.'&amp;';
494
+ echo "<table class='cpd_backups'>\n";
495
foreach ( $dirarray as $entry )
496
if ( preg_match('/count_per_day|cpd_counter/i', $entry) )
497
+ {
498
+ if ( strpos($entry, 'count_per_day_options') !== false && !$captionO )
499
+ {
500
+ echo '<tr><td colspan="5" style="font-weight:bold;background:#EAEAEA">'.__('Settings and collections', 'cpd')."</td></tr>\n";
501
+ $captionO = 1;
502
+ }
503
+ else if ( strpos($entry, 'cpd_counter_backup') !== false && !$captionB )
504
+ {
505
+ echo '<tr><td colspan="5" style="font-weight:bold;background:#EAEAEA">'.sprintf(__('Counter table %s', 'cpd'), "<code>$wpdb->cpd_counter</code>")."</td></tr>\n";
506
+ $captionB = 1;
507
+ }
508
+ echo '<tr><td><a href="'.content_url().'/'.$entry.'" style="text-decoration:none">'.$entry."</a></td>\n";
509
+ echo '<td style="text-align:right">'.$count_per_day->formatbytes(filesize(WP_CONTENT_DIR.'/'.$entry))."&nbsp; </td>\n";
510
+ if ( strpos($entry, 'cpd_counter_backup') !== false )
511
+ echo $link.'cpdadding='.$entry.'" class="cpd_green"
512
+ onclick="return confirm(\''.sprintf(__('Add data from the backup file %s to existing counter table?','cpd'), '\n'.$entry).'\')" title="'.__('Add', 'cpd').'">+</a></td>'."\n";
513
+ else
514
+ echo "<td>&nbsp;</td>\n";
515
+ echo $link.'cpdrestore='.$entry.'" class="cpd_green"
516
+ onclick="return confirm(\''.sprintf(__('Restore data from the backup file %s ?','cpd'), '\n'.$entry).'\')" title="'.__('Restore').'">&uArr;</a></td>'."\n";
517
+ echo $link.'cpddel='.$entry.'"
518
+ style="color:red;font-weight:bold" title="'.__('Delete').'"
519
+ onclick="return confirm(\''.sprintf(__('Delete the backup file %s ?','cpd'), '\n'.$entry).'\')">X</a></td>'."\n";
520
+ echo "</tr>\n";
521
+ }
522
+ echo "</table>\n";
523
+ ?>
524
+ <p>
525
+ <span class="cpd_green">+</span> <?php _e('add backup to current counter table', 'cpd') ?><br/>
526
+ <span class="cpd_green">&uArr;</span> <?php _e('replace current counter table with with backup', 'cpd') ?><br/>
527
+ <span style="color:red;font-weight:bold">X&nbsp;</span> <?php _e('delete backup file', 'cpd') ?>
528
+ </p>
529
+ <?php
530
}
531
?>
532
</div>
533
</div>
534
540
<p>
541
<?php _e('You can clean the counter table by delete the "spam data".<br />If you add new bots above the old "spam data" keeps in the database.<br />Here you can run the bot filter again and delete the visits of the bots.', 'cpd') ?>
542
</p>
543
+ <form method="post" action="<?php echo $mysiteurl ?>">
544
<p>
545
<input type="hidden" name="do" value="cpd_clean" />
546
<input type="submit" name="clean" value="<?php _e('Clean the database', 'cpd') ?>" class="button" />
547
</p>
548
</form>
549
+
550
+ <form method="post" action="<?php echo $mysiteurl ?>">
551
+ <p>
552
+ <?php printf(__('Delete search strings older than %s days.', 'cpd'), '<input type="text" size="2" name="cpd_keepsearch" value="14" class="code" />') ?><br/>
553
+ <input type="hidden" name="do" value="cpd_searchclean" />
554
+ <input type="submit" name="clean" value="<?php _e('Delete search strings', 'cpd') ?>" class="button" />
555
+ </p>
556
+ </form>
557
</div>
558
</div>
559
<?php endif; ?>
562
<div class="postbox">
563
<h3><span class="cpd_icon cpd_collection">&nbsp;</span> <?php _e('Collect old data', 'cpd') ?></h3>
564
<div class="inside">
565
+ <form method="post" action="<?php echo $mysiteurl ?>">
566
<p>
567
<?php
568
printf(__('Current size of your counter table %s is %s.', 'cpd'), '<code>'.$wpdb->cpd_counter.'</code>', $count_per_day->getTableSize($wpdb->cpd_counter));
598
</div>
599
</div>
600
601
</div> <!-- left column -->
602
603
<!-- right column -->
611
<?php _e('You can get the country data for all entries in database by checking the IP adress against the GeoIP database. This can take a while!', 'cpd') ?>
612
</p>
613
<?php if ( $cpd_geoip ) { ?>
614
+ <form method="post" action="<?php echo $mysiteurl ?>">
615
<p>
616
<input type="hidden" name="do" value="cpd_countries" />
617
<input type="submit" name="updcon" value="<?php _e('Update old counter data', 'cpd') ?>" class="button" />
623
// install or update database
624
echo '<p>'.__('Download a new version of GeoIP.dat file.', 'cpd').'</p>';
625
?>
626
+ <form method="post" action="<?php echo $mysiteurl ?>">
627
<p>
628
<input type="hidden" name="do" value="cpd_countrydb" />
629
<input type="submit" name="updcondb" value="<?php _e('Update GeoIP database', 'cpd') ?>" class="button" />
644
<p>
645
<?php _e('Here you can start the installation functions manually.<br/>Same as deactivate and reactivate the plugin.', 'cpd') ?>
646
</p>
647
+ <form method="post" action="<?php echo $mysiteurl ?>">
648
<p>
649
<input type="hidden" name="do" value="cpd_activate" />
650
<input type="submit" name="activate" value="<?php _e('ReActivate the plugin', 'cpd') ?>" class="button" />
661
<?php _e('You can reset the counter by empty the table. ALL TO 0!<br />Make a backup if you need the current data!', 'cpd') ?>
662
</p>
663
664
+ <form method="post" action="<?php echo $mysiteurl ?>">
665
<p>
666
<input type="hidden" name="do" value="cpd_reset" />
667
<input type="checkbox" name="reset_cpd_yes" value="yes" />&nbsp;<?php _e('Yes', 'cpd'); ?> &nbsp;
672
</div>
673
674
<!-- Uninstall -->
675
+ <form method="post" action="<?php echo $mysiteurl ?>">
676
<div class="postbox">
677
<h3><span class="cpd_icon cpd_uninstall">&nbsp;</span> <?php _e('Uninstall', 'cpd') ?></h3>
678
<div class="inside">
693
</div>
694
</div>
695
</form>
696
+
697
+ <!-- Plugin page -->
698
+ <div class="postbox">
699
+ <h3><span class="cpd_icon cpd_help">&nbsp;</span> <?php _e('Support', 'cpd') ?></h3>
700
+ <div class="inside">
701
+ <?php $count_per_day->cpdInfo() ?>
702
+ </div>
703
+ </div>
704
+
705
</div> <!-- right column -->
706
+
707
+ <div class="clear" id="cpdsettings" style="margin-bottom:41px"></div>
708
+
709
+ <h2 class="nav-tab-wrapper" style="padding-bottom:0;font-size:23px;">
710
+ <img src="<?php echo $count_per_day->img('cpd_menu.gif') ?>" alt="" style="width:24px;height:24px" /> Count per Day
711
+ <a class="nav-tab" href="#cpdtools"><span class="cpd_icon cpd_tools">&nbsp;</span> <?php _e('Tools') ?></a>
712
+ <a class="nav-tab nav-tab-active" href="#cpdsettings"><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Settings') ?></a>
713
+ </h2>
714
+
715
+
716
+ <form method="post" action="<?php echo $mysiteurl ?>">
717
+
718
+ <?php // counter ?>
719
+ <fieldset>
720
+ <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Counter', 'cpd') ?></legend>
721
+
722
+ <table class="form-table">
723
+ <tr>
724
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Online time', 'cpd') ?>:</th>
725
+ <td><input class="code" type="text" name="cpd_onlinetime" size="3" value="<?php echo $o['onlinetime']; ?>" /> <?php _e('Seconds for online counter. Used for "Visitors online" on dashboard page.', 'cpd') ?></td>
726
+ </tr>
727
+ <tr>
728
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Logged on Users', 'cpd') ?>:</th>
729
+ <td>
730
+ <label for="cpd_user"><input type="checkbox" name="cpd_user" id="cpd_user" <?php if($o['user']==1) echo 'checked="checked"'; ?> /> <?php _e('count too', 'cpd') ?></label>
731
+ - <?php _e('until User Level', 'cpd') ?>
732
+ <select name="cpd_user_level">
733
+ <option value="10" <?php selected($o['user_level'], 10) ?>><?php echo translate_user_role('Administrator') ?> (10)</option>
734
+ <option value="7" <?php selected($o['user_level'], 7) ?>><?php echo translate_user_role('Editor') ?> (7)</option>
735
+ <option value="2" <?php selected($o['user_level'], 2) ?>><?php echo translate_user_role('Author') ?> (2)</option>
736
+ <option value="1" <?php selected($o['user_level'], 1) ?>><?php echo translate_user_role('Contributor') ?> (1)</option>
737
+ <option value="0" <?php selected($o['user_level'], 0) ?>><?php echo translate_user_role('Subscriber') ?> (0)</option>
738
+ </select>
739
+ </td>
740
+ </tr>
741
+ <tr>
742
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Auto counter', 'cpd') ?>:</th>
743
+ <td><label for="cpd_autocount"><input type="checkbox" name="cpd_autocount" id="cpd_autocount" <?php checked($o['autocount'], 1) ?> /> <?php _e('Counts automatically single-posts and pages, no changes on template needed.', 'cpd') ?></label></td>
744
+ </tr>
745
+ <tr>
746
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Bots to ignore', 'cpd') ?>:</th>
747
+ <td><textarea name="cpd_bots" cols="50" rows="10"><?php echo $o['bots']; ?></textarea></td>
748
+ </tr>
749
+ <tr>
750
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Anonymous IP', 'cpd') ?>:</th>
751
+ <td><label for="cpd_anoip"><input type="checkbox" name="cpd_anoip" id="cpd_anoip" <?php checked($o['anoip'], 1) ?> /> a.b.c.d &gt; a.b.c.x</label></td>
752
+ </tr>
753
+ <tr>
754
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Cache', 'cpd') ?> (beta):</th>
755
+ <td><label for="cpd_ajax"><input type="checkbox" name="cpd_ajax" id="cpd_ajax" <?php checked($o['ajax'], 1) ?> /> <?php _e('I use a cache plugin. Count these visits with ajax.', 'cpd') ?></label></td>
756
+ </tr>
757
+ <tr>
758
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Clients and referrers', 'cpd') ?>:</th>
759
+ <td>
760
+ <label for="cpd_referers"><input type="checkbox" name="cpd_referers" id="cpd_referers" <?php checked($o['referers'], 1) ?> />
761
+ <?php _e('Save and show clients and referrers.<br />Needs a lot of space in the database but gives you more detailed informations of your visitors.', 'cpd') ?> (1000000 <?php _e('Reads', 'cpd') ?> ~ 130 MB)</label><br/>
762
+ <label for="cpd_referers_cut"><input type="checkbox" name="cpd_referers_cut" id="cpd_referers_cut" <?php checked($o['referers_cut'], 1) ?> />
763
+ <?php _e('Save URL only, no query string.', 'cpd') ?> <code>http://example.com/webhp?hl=de#sclient=psy&amp;hl=de...</code> &gt; <code>http://example.com/webhp</code></label>
764
+ </td>
765
+ </tr>
766
+ </table>
767
+ </fieldset>
768
+
769
+ <?php // dashboard ?>
770
+ <fieldset>
771
+ <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Dashboard') ?></legend>
772
+
773
+ <script type="text/javascript">
774
+ function checkcustom()
775
+ {
776
+ var b = document.getElementById('cpd_whocansee');
777
+ var i = document.getElementById('cpd_whocansee_custom_div');
778
+ if ( b.value == 'custom' )
779
+ i.style.display = 'block';
780
+ else
781
+ i.style.display = 'none';
782
+ }
783
+ </script>
784
+
785
+ <table class="form-table">
786
+ <tr>
787
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Who can see it', 'cpd') ?>:</th>
788
+ <td>
789
+ <?php $cus = (in_array($o['whocansee'], array('manage_options','manage_links','publish_posts','edit_posts','read'))) ? 0 : 1 ?>
790
+ <select id="cpd_whocansee" name="cpd_whocansee" onchange="checkcustom()">
791
+ <option value="manage_options" <?php selected($o['whocansee'], 'manage_options') ?>><?php echo translate_user_role('Administrator') ?> </option>
792
+ <option value="manage_links" <?php selected($o['whocansee'], 'manage_links') ?>><?php echo translate_user_role('Editor') ?></option>
793
+ <option value="publish_posts" <?php selected($o['whocansee'], 'publish_posts') ?>><?php echo translate_user_role('Author') ?></option>
794
+ <option value="edit_posts" <?php selected($o['whocansee'], 'edit_posts') ?>><?php echo translate_user_role('Contributor') ?></option>
795
+ <option value="read" <?php selected($o['whocansee'], 'read') ?>><?php echo translate_user_role('Subscriber') ?></option>
796
+ <option value="custom" <?php selected($cus) ?>>- <?php echo _e('custom', 'cpd') ?> -</option>
797
+ </select>
798
+ <?php _e('and higher are allowed to see the statistics page.', 'cpd') ?>
799
+ <div id="cpd_whocansee_custom_div" <?php if (!$cus) echo 'style="display:none"' ?>>
800
+ <?php printf(__('Set the %s capability %s a user need:', 'cpd'), '<a href="https://codex.wordpress.org/Roles_and_Capabilities">', '</a>'); ?>
801
+ <input type="text" name="cpd_whocansee_custom" value="<?php echo $o['whocansee'] ?>" />
802
+ </div>
803
+ </td>
804
+ </tr>
805
+ <tr>
806
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Visitors per post', 'cpd') ?>:</th>
807
+ <td><input class="code" type="text" name="cpd_dashboard_posts" size="3" value="<?php echo $o['dashboard_posts']; ?>" /> <?php _e('How many posts do you want to see on dashboard page?', 'cpd') ?></td>
808
+ </tr>
809
+ <tr>
810
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Latest Counts - Posts', 'cpd') ?>:</th>
811
+ <td><input class="code" type="text" name="cpd_dashboard_last_posts" size="3" value="<?php echo $o['dashboard_last_posts']; ?>" /> <?php _e('How many posts do you want to see on dashboard page?', 'cpd') ?></td>
812
+ </tr>
813
+ <tr>
814
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Latest Counts - Days', 'cpd') ?>:</th>
815
+ <td><input class="code" type="text" name="cpd_dashboard_last_days" size="3" value="<?php echo $o['dashboard_last_days']; ?>" /> <?php _e('How many days do you want look back?', 'cpd') ?></td>
816
+ </tr>
817
+ <tr>
818
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Chart - Days', 'cpd') ?>:</th>
819
+ <td><input class="code" type="text" name="cpd_chart_days" size="3" value="<?php echo $o['chart_days']; ?>" /> <?php _e('How many days do you want look back?', 'cpd') ?></td>
820
+ </tr>
821
+ <tr>
822
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Chart - Height', 'cpd') ?>:</th>
823
+ <td><input class="code" type="text" name="cpd_chart_height" size="3" value="<?php echo $o['chart_height']; ?>" /> px - <?php _e('Height of the biggest bar', 'cpd') ?></td>
824
+ </tr>
825
+ <?php if ($cpd_geoip) { ?>
826
+ <tr>
827
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Countries', 'cpd') ?>:</th>
828
+ <td><input class="code" type="text" name="cpd_countries" size="3" value="<?php echo $o['countries']; ?>" /> <?php _e('How many countries do you want to see on dashboard page?', 'cpd') ?></td>
829
+ </tr>
830
+ <?php } ?>
831
+ <tr>
832
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Browsers', 'cpd') ?>:</th>
833
+ <td><input class="code" type="text" name="cpd_clients" size="50" value="<?php echo $o['clients']; ?>" /> <?php _e('Substring of the user agent, separated by comma', 'cpd') ?></td>
834
+ </tr>
835
+ <tr>
836
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Search strings', 'cpd') ?>/<?php _e('Referrers - Entries', 'cpd') ?>:</th>
837
+ <td><input class="code" type="text" name="cpd_dashboard_referers" size="3" value="<?php echo $o['dashboard_referers']; ?>" /> <?php _e('How many referrers do you want to see on dashboard page?', 'cpd') ?></td>
838
+ </tr>
839
+ <tr>
840
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Search strings', 'cpd') ?>/<?php _e('Referrers - Days', 'cpd') ?>:</th>
841
+ <td><input class="code" type="text" name="cpd_referers_last_days" size="3" value="<?php echo $o['referers_last_days']; ?>" /> <?php _e('How many days do you want look back?', 'cpd') ?></td>
842
+ </tr>
843
+ <tr>
844
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Local URLs', 'cpd') ?>:</th>
845
+ <td><label for="cpd_localref"><input type="checkbox" name="cpd_localref" id="cpd_localref" <?php checked($o['localref'], 1) ?> /> <?php _e('Show local referrers too.', 'cpd') ?> (<?php echo bloginfo('url') ?>/...)</label></td>
846
+ </tr>
847
+ </table>
848
+ </fieldset>
849
+
850
+ <?php // lists ?>
851
+ <fieldset>
852
+ <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Posts') ?> / <?php _e('Pages') ?></legend>
853
+ <table class="form-table">
854
+ <tr>
855
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Show in lists', 'cpd') ?>:</th>
856
+ <td><label for="cpd_show_in_lists"><input type="checkbox" name="cpd_show_in_lists" id="cpd_show_in_lists" <?php checked($o['show_in_lists'], 1) ?> /> <?php _e('Show "Reads per Post" in a new column in post management views.', 'cpd') ?></label></td>
857
+ </tr>
858
+ </table>
859
+ </fieldset>
860
+
861
+ <?php // start values ?>
862
+ <fieldset>
863
+ <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Start Values', 'cpd') ?></legend>
864
+ <table class="form-table">
865
+ <tr>
866
+ <th colspan="2">
867
+ <?php _e('Here you can change the date of first count and add a start count.', 'cpd')?>
868
+ </th>
869
+ </tr>
870
+ <tr>
871
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Start date', 'cpd') ?>:</th>
872
+ <td><input class="code" type="text" name="cpd_startdate" size="10" value="<?php echo $o['startdate']; ?>" /> <?php _e('Your old Counter starts at?', 'cpd') ?> [yyyy-mm-dd]</td>
873
+ </tr>
874
+ <tr>
875
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Start count', 'cpd') ?>:</th>
876
+ <td><input class="code" type="text" name="cpd_startcount" size="10" value="<?php echo $o['startcount']; ?>" /> <?php _e('Add this value to "Total visitors".', 'cpd') ?></td>
877
+ </tr>
878
+ <tr>
879
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Start count', 'cpd') ?>:</th>
880
+ <td><input class="code" type="text" name="cpd_startreads" size="10" value="<?php echo $o['startreads']; ?>" /> <?php _e('Add this value to "Total reads".', 'cpd') ?></td>
881
+ </tr>
882
+ </table>
883
+ </fieldset>
884
+
885
+ <?php // stylesheet ?>
886
+ <fieldset>
887
+ <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Stylesheet', 'cpd') ?></legend>
888
+ <table class="form-table">
889
+ <tr>
890
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('NO Stylesheet in Frontend', 'cpd') ?>:</th>
891
+ <td><label for="cpd_no_front_css"><input type="checkbox" name="cpd_no_front_css" id="cpd_no_front_css" <?php checked($o['no_front_css'], 1) ?> /> <?php _e('Do not load the stylesheet "counter.css" in frontend.', 'cpd') ?></label></td>
892
+ </tr>
893
+ </table>
894
+ </fieldset>
895
+
896
+ <?php // backup ?>
897
+ <fieldset>
898
+ <legend><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Backup', 'cpd') ?></legend>
899
+ <table class="form-table">
900
+ <tr>
901
+ <th scope="row" style="vertical-align:middle;white-space:nowrap"><?php _e('Entries per pass', 'cpd') ?>:</th>
902
+ <td>
903
+ <input class="code" type="text" name="cpd_backup_part" size="10" value="<?php echo $o['backup_part']; ?>" />
904
+ <?php _e('How many entries should be saved per pass? Default: 10000', 'cpd') ?><br/>
905
+ </td>
906
+ </tr>
907
+ <tr>
908
+ <td colspan="2">
909
+ <?php _e('If your PHP memory limit less then 50 MB and you get a white page or error messages try a smaller value.', 'cpd') ?>
910
+ </td>
911
+ </tr>
912
+ </table>
913
+ </fieldset>
914
+
915
+ <?php // debug ?>
916
+ <fieldset>
917
+ <legend style="color:red"><span class="cpd_icon cpd_settings">&nbsp;</span> <?php _e('Debug mode', 'cpd') ?></legend>
918
+ <p style="margin-top:15px;margin-left:10px">
919
+ <label for="cpd_debug"><input type="checkbox" name="cpd_debug" id="cpd_debug" <?php checked($o['debug'], 1) ?> /> <?php _e('Show debug informations at the bottom of all pages.', 'cpd') ?></label>
920
+ </p>
921
+ </fieldset>
922
+
923
+ <input type="hidden" name="do" value="cpd_update" />
924
+ <input type="submit" name="update" value="<?php _e('Update options', 'cpd') ?>" class="button-primary" style="margin-left: 5px;" />
925
+ </form>
926
927
</div><!-- poststuff -->
928
</div><!-- wrap -->
counter.css CHANGED
@@ -11,6 +11,36 @@
11
12
/* settings */
13
14
.cpd_halfsize {
15
width: 49%;
16
float: left;
@@ -114,7 +144,11 @@
114
}
115
116
.cpd-dashboard .inside {
117
- padding: 5px;
118
}
119
120
.cpd-dashboard .cpd_front_list {
@@ -395,3 +429,7 @@
395
.cpd-flag-me{background-position:0 -1534px;}
396
.cpd-flag-md{background-position:0 -1547px;}
397
.cpd-flag-np{background-position:0 -1560px;}
11
12
/* settings */
13
14
+ h2 .cpd_icon {
15
+ vertical-align: top;
16
+ margin-top:5px;
17
+ }
18
+
19
+ .cpd_backups {
20
+ width: 100%;
21
+ border: 1px #ccc solid;
22
+ border-collapse: collapse;
23
+ }
24
+
25
+ .cpd_backups tr:nth-child(2n) {
26
+ background: #fff;
27
+ }
28
+
29
+ .cpd_backups td {
30
+ border-bottom: 1px #ccc solid;
31
+ }
32
+
33
+ .cpd_backups a {
34
+ text-decoration: none;
35
+ }
36
+
37
+ .cpd_green {
38
+ font-size: 16px;
39
+ font-weight: bold;
40
+ color: green;
41
+ margin-right: 3px;
42
+ }
43
+
44
.cpd_halfsize {
45
width: 49%;
46
float: left;
144
}
145
146
.cpd-dashboard .inside {
147
+ padding: 0 5px;
148
+ }
149
+
150
+ .cpd-dashboard .postbox {
151
+ min-width: 0 !important;
152
}
153
154
.cpd-dashboard .cpd_front_list {
429
.cpd-flag-me{background-position:0 -1534px;}
430
.cpd-flag-md{background-position:0 -1547px;}
431
.cpd-flag-np{background-position:0 -1560px;}
432
+ .cpd-flag-bs{background-position:0 -1573px;}
433
+ .cpd-flag-cm{background-position:0 -1586px;}
434
+ .cpd-flag-mn{background-position:0 -1599px;}
435
+ .cpd-flag-kz{background-position:0 -1612px;}
counter.php CHANGED
@@ -2,15 +2,15 @@
2
/*
3
Plugin Name: Count Per Day
4
Plugin URI: http://www.tomsdimension.de/wp-plugins/count-per-day
5
- Description: Counter, shows reads per page; today, yesterday, last week, last months ... on dashboard, per shortcode or in widget.
6
- Version: 3.1.1
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.1.1';
14
15
$cpd_path = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH.PLUGINDIR.'/'.$cpd_dir_name.'/');
16
include_once($cpd_path.'counter-core.php');
@@ -102,7 +102,16 @@ function count( $x, $page = 'x' )
102
// only count if: non bot, Logon is ok
103
if ( !$isBot && $countUser && isset($page) )
104
{
105
- $userip = $this->anonymize_ip($_SERVER['REMOTE_ADDR']);
106
$client = ($this->options['referers']) ? $_SERVER['HTTP_USER_AGENT'] : '';
107
$referer = ($this->options['referers'] && isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
108
if ($this->options['referers_cut'])
@@ -110,7 +119,7 @@ function count( $x, $page = 'x' )
110
$date = date_i18n('Y-m-d');
111
112
// new visitor on page?
113
- $count = $this->mysqlQuery('var', $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->cpd_counter WHERE ip=INET_ATON(%s) AND date=%s AND page=%d", $userip, $date, $page), 'count check '.__LINE__);
114
if ( !$count )
115
{
116
// save count
@@ -120,18 +129,34 @@ function count( $x, $page = 'x' )
120
$gi = cpd_geoip_open($cpd_path.'geoip/GeoIP.dat', GEOIP_STANDARD);
121
$country = strtolower(cpd_geoip_country_code_by_addr($gi, $userip));
122
$this->mysqlQuery('', $wpdb->prepare("INSERT INTO $wpdb->cpd_counter (page, ip, client, date, country, referer)
123
- VALUES (%s, INET_ATON(%s), %s, %s, %s, %s)", $page, $userip, $client, $date, $country, $referer), 'count insert '.__LINE__);
124
}
125
else
126
// without country
127
$this->mysqlQuery('', $wpdb->prepare("INSERT INTO $wpdb->cpd_counter (page, ip, client, date, referer)
128
- VALUES (%s, INET_ATON(%s), %s, %s, %s)", $page, $userip, $client, $date, $referer), 'count insert '.__LINE__);
129
}
130
// online counter
131
- $oc = get_option('count_per_day_online', array());
132
$oc[$userip] = array( time(), $page );
133
update_option('count_per_day_online', $oc);
134
}
135
}
136
137
/**
@@ -677,7 +702,7 @@ function getMostVisitedPosts( $days = 0, $limit = 0, $frontend = false, $postson
677
ORDER BY count DESC
678
LIMIT %d",
679
$date, $limit);
680
- $r = '<small>'.sprintf(__('The %s most visited posts in last %s days:', 'cpd'), $limit, $days).'<br/>&nbsp;</small>';
681
$r .= $this->getUserPer_SQL( $sql, 'getMostVisitedPosts', $frontend );
682
if ($return) return $r; else echo $r;
683
}
@@ -818,19 +843,31 @@ function getClients( $return = false )
818
return;
819
$all = max(1, (int) $res);
820
$rest = 100;
821
- $r = '<ul id="cpd_clients" class="cpd_front_list">';
822
foreach ($clients as $c)
823
{
824
$c = trim($c);
825
- $count = $this->mysqlQuery('var', "SELECT COUNT(*) FROM $wpdb->cpd_counter WHERE client like '%%".$c."%%'", 'getClients_'.$c.'_ '.__LINE__);
826
$percent = number_format(100 * $count / $all, 0);
827
$rest -= $percent;
828
- $r .= '<li class="cpd-client-logo cpd-client-'.strtolower($c).'">'.$c.' <b>'.$percent.' %</b></li>';
829
}
830
if ( $rest > 0 )
831
- $r .= '<li>'.__('Other', 'cpd').' <b>'.$rest.' %</b></li>';
832
$r .= '</ul>';
833
-
834
$res = $this->mysqlQuery('var', "SELECT MIN(date) FROM ".$wpdb->cpd_counter, 'getClients_date '.__LINE__);
835
$r .= '<small>'.__('Counter starts on', 'cpd').': '.mysql2date(get_option('date_format'), $res ).'</small>';
836
if ($return) return $r; else echo $r;
@@ -852,13 +889,13 @@ function getReferers( $limit = 0, $return = false, $days = 0 )
852
853
$localref = ($this->options['localref']) ? '' : " AND referer NOT LIKE '".get_bloginfo('url')."%%' ";
854
$res = $this->mysqlQuery('rows', "SELECT COUNT(*) count, referer FROM $wpdb->cpd_counter WHERE referer > '' $dayfiltre $localref GROUP BY referer ORDER BY count DESC LIMIT $limit", 'getReferers '.__LINE__);
855
- $r = '<small>'.sprintf(__('The %s referrers in last %s days:', 'cpd'), $limit, $days).'<br/>&nbsp;</small>';
856
$r .= '<ul id="cpd_referrers" class="cpd_front_list">';
857
if ($res)
858
foreach ( $res as $row )
859
{
860
$ref = str_replace('&', '&amp;', $row->referer);
861
- $ref2 = str_replace('http://', '', $ref);
862
$r .= '<li><a href="'.$ref.'">'.$ref2.'</a> <b>'.$row->count.'</b></li>';
863
}
864
$r .= '</ul>';
@@ -936,7 +973,7 @@ function getUserPer_SQL( $sql, $name = '', $frontend = false, $limit = 0 )
936
$pid = 'p'.$r->page;
937
if ( isset($p[$pid]) )
938
$p[$pid] += (int) $r->count;
939
- else
940
$p[$pid] = (int) $r->count;
941
}
942
// max $limit
@@ -956,24 +993,33 @@ function getUserPer_SQL( $sql, $name = '', $frontend = false, $limit = 0 )
956
$if .= " WHEN ".str_replace('p', '', $id)." THEN $count";
957
958
$sql = "
959
- SELECT CASE p.id $if ELSE 0 END as count,
960
- p.id post_id,
961
- p.post_title post,
962
- t.name tag_cat_name,
963
- t.slug tag_cat_slug,
964
- x.taxonomy tax
965
- FROM $wpdb->posts p,
966
- $wpdb->terms t
967
- LEFT JOIN $wpdb->term_taxonomy x
968
- ON x.term_id = t.term_id
969
- WHERE p.id IN ($list)
970
- OR -t.term_id IN ($list)
971
- GROUP BY p.id
972
- ORDER BY count DESC";
973
-
974
$m = $this->mysqlQuery('rows', $sql, $name.' '.__LINE__);
975
if (!$m)
976
- return;
977
}
978
979
@@ -982,21 +1028,20 @@ function getUserPer_SQL( $sql, $name = '', $frontend = false, $limit = 0 )
982
{
983
$r .= '<li>';
984
// link only for editors in backend
985
- if ( current_user_can('editor') && !$frontend )
986
- // if ( isset($userdata->user_level) && (int) $userdata->user_level >= 7 && !$frontend)
987
{
988
if ( $row->post_id > 0 )
989
$r .= '<a href="post.php?action=edit&amp;post='.$row->post_id.'"><img src="'.$this->img('cpd_pen.png').'" alt="[e]" title="'.__('Edit Post').'" style="width:9px;height:12px;" /></a> '
990
.'<a href="'.$this->dir.'/userperspan.php?page='.$row->post_id.'&amp;KeepThis=true&amp;TB_iframe=true" class="thickbox" title="Count per Day"><img src="'.$this->img('cpd_calendar.png').'" alt="[v]" style="width:12px;height:12px;" /></a> ';
991
else
992
- $r .= '<img src="'.$this->img('cpd_trans.png').'" alt="" style="width:25px;height:12px;" /> ';
993
}
994
995
$r .= '<a href="'.get_bloginfo('url');
996
- if ( $row->post_id < 0 && $row->tax == 'category' )
997
- //category
998
$r .= '?cat='.abs($row->post_id).'">- '.$row->tag_cat_name.' ('.__('Category').') -';
999
- else if ( $row->post_id < 0 )
1000
// tag
1001
$r .= '?tag='.$row->tag_cat_slug.'">- '.$row->tag_cat_name.' ('.__('Tag').') -';
1002
else if ( $row->post_id == 0 )
@@ -1013,6 +1058,51 @@ function getUserPer_SQL( $sql, $name = '', $frontend = false, $limit = 0 )
1013
return $r;
1014
}
1015
1016
/**
1017
* creates the little widget on dashboard
1018
*/
@@ -1230,7 +1320,7 @@ class CountPerDay_Widget extends WP_Widget
1230
echo '
1231
<ul id="cpdwidgetlist'.$field_id.'">
1232
<li class="cpd_widget_item cpd_widget_title">
1233
- <label for="'.$field_id.'">'.__('Title').':<label>
1234
<input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance['title'] ).'" />
1235
</li>';
1236
@@ -1301,6 +1391,8 @@ function count_per_day_uninstall()
1301
delete_option('count_per_day_collected');
1302
delete_option('count_per_day_online');
1303
delete_option('count_per_day_notes');
1304
$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '%_cpd_metaboxes%';");
1305
}
1306
2
/*
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
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';
14
15
$cpd_path = str_replace('/', DIRECTORY_SEPARATOR, ABSPATH.PLUGINDIR.'/'.$cpd_dir_name.'/');
16
include_once($cpd_path.'counter-core.php');
102
// only count if: non bot, Logon is ok
103
if ( !$isBot && $countUser && isset($page) )
104
{
105
+ if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
106
+ {
107
+ // get real IP, not local IP
108
+ $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
109
+ $real_ip = $ips[0];
110
+ }
111
+ else
112
+ $real_ip = $_SERVER['REMOTE_ADDR'];
113
+
114
+ $userip = $this->anonymize_ip($real_ip);
115
$client = ($this->options['referers']) ? $_SERVER['HTTP_USER_AGENT'] : '';
116
$referer = ($this->options['referers'] && isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
117
if ($this->options['referers_cut'])
119
$date = date_i18n('Y-m-d');
120
121
// new visitor on page?
122
+ $count = $this->mysqlQuery('var', $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->cpd_counter WHERE ip=$this->aton(%s) AND date=%s AND page=%d", $userip, $date, $page), 'count check '.__LINE__);
123
if ( !$count )
124
{
125
// save count
129
$gi = cpd_geoip_open($cpd_path.'geoip/GeoIP.dat', GEOIP_STANDARD);
130
$country = strtolower(cpd_geoip_country_code_by_addr($gi, $userip));
131
$this->mysqlQuery('', $wpdb->prepare("INSERT INTO $wpdb->cpd_counter (page, ip, client, date, country, referer)
132
+ VALUES (%s, $this->aton(%s), %s, %s, %s, %s)", $page, $userip, $client, $date, $country, $referer), 'count insert '.__LINE__);
133
}
134
else
135
// without country
136
$this->mysqlQuery('', $wpdb->prepare("INSERT INTO $wpdb->cpd_counter (page, ip, client, date, referer)
137
+ VALUES (%s, $this->aton(%s), %s, %s, %s)", $page, $userip, $client, $date, $referer), 'count insert '.__LINE__);
138
}
139
// online counter
140
+ $oc = get_option('count_per_day_online', array());
141
$oc[$userip] = array( time(), $page );
142
update_option('count_per_day_online', $oc);
143
}
144
+
145
+ // save searchstring if exists
146
+ $s = $this->getSearchString();
147
+ if ($s)
148
+ {
149
+ $search = get_option('count_per_day_search', array());
150
+ if (isset($search[$date]))
151
+ {
152
+ if (!in_array($s, $search[$date]))
153
+ $search[$date][] = $s;
154
+ }
155
+ else
156
+ $search[$date] = array($s);
157
+ update_option('count_per_day_search', $search);
158
+ unset($search);
159
+ }
160
}
161
162
/**
702
ORDER BY count DESC
703
LIMIT %d",
704
$date, $limit);
705
+ $r = '<small>'.sprintf(__('The %s most visited posts in last %s days:', 'cpd'), $limit, $days).'</small>';
706
$r .= $this->getUserPer_SQL( $sql, 'getMostVisitedPosts', $frontend );
707
if ($return) return $r; else echo $r;
708
}
843
return;
844
$all = max(1, (int) $res);
845
$rest = 100;
846
foreach ($clients as $c)
847
{
848
$c = trim($c);
849
+ $sql = "SELECT COUNT(*) FROM $wpdb->cpd_counter WHERE client LIKE '%%".$c."%%'";
850
+ if ( strtolower($c) == 'safari' ) // don't count chrome too while counting safari
851
+ $sql .= " AND client NOT LIKE '%%chrome%%'";
852
+ $count = $this->mysqlQuery('var', $sql, 'getClients_'.$c.'_ '.__LINE__);
853
$percent = number_format(100 * $count / $all, 0);
854
$rest -= $percent;
855
+ $cl_percent[] = $percent;
856
+ $cl_name[] = $c;
857
}
858
if ( $rest > 0 )
859
+ {
860
+ $cl_percent[] = $rest;
861
+ $cl_name[] = __('Other', 'cpd');
862
+ }
863
+ array_multisort($cl_percent, SORT_NUMERIC, SORT_DESC, $cl_name);
864
+ $r = '<ul id="cpd_clients" class="cpd_front_list">';
865
+ for ($i = 0; $i < count($cl_percent); $i++)
866
+ {
867
+ $r .= '<li class="cpd-client-logo cpd-client-'.strtolower($cl_name[$i]).'">'.$cl_name[$i].' <b>'.$cl_percent[$i].' %</b></li>';
868
+ }
869
$r .= '</ul>';
870
+
871
$res = $this->mysqlQuery('var', "SELECT MIN(date) FROM ".$wpdb->cpd_counter, 'getClients_date '.__LINE__);
872
$r .= '<small>'.__('Counter starts on', 'cpd').': '.mysql2date(get_option('date_format'), $res ).'</small>';
873
if ($return) return $r; else echo $r;
889
890
$localref = ($this->options['localref']) ? '' : " AND referer NOT LIKE '".get_bloginfo('url')."%%' ";
891
$res = $this->mysqlQuery('rows', "SELECT COUNT(*) count, referer FROM $wpdb->cpd_counter WHERE referer > '' $dayfiltre $localref GROUP BY referer ORDER BY count DESC LIMIT $limit", 'getReferers '.__LINE__);
892
+ $r = '<small>'.sprintf(__('The %s referrers in last %s days:', 'cpd'), $limit, $days).'</small>';
893
$r .= '<ul id="cpd_referrers" class="cpd_front_list">';
894
if ($res)
895
foreach ( $res as $row )
896
{
897
$ref = str_replace('&', '&amp;', $row->referer);
898
+ $ref2 = str_replace(array('http://', 'https://'), '', $ref);
899
$r .= '<li><a href="'.$ref.'">'.$ref2.'</a> <b>'.$row->count.'</b></li>';
900
}
901
$r .= '</ul>';
973
$pid = 'p'.$r->page;
974
if ( isset($p[$pid]) )
975
$p[$pid] += (int) $r->count;
976
+ else if ( $r->count )
977
$p[$pid] = (int) $r->count;
978
}
979
// max $limit
993
$if .= " WHEN ".str_replace('p', '', $id)." THEN $count";
994
995
$sql = "
996
+ SELECT temp_outer.* FROM (
997
+ SELECT CASE p.id $if ELSE 0 END count,
998
+ p.id post_id,
999
+ p.post_title post,
1000
+ '' tag_cat_name,
1001
+ '' tag_cat_slug,
1002
+ '' tax
1003
+ FROM $wpdb->posts p
1004
+ WHERE p.id IN ($list)
1005
+ GROUP BY p.id
1006
+ UNION
1007
+ SELECT CASE -t.term_id $if ELSE 0 END count,
1008
+ t.term_id post_id,
1009
+ '' post,
1010
+ t.name tag_cat_name,
1011
+ t.slug tag_cat_slug,
1012
+ x.taxonomy tax
1013
+ FROM $wpdb->terms t
1014
+ LEFT JOIN $wpdb->term_taxonomy x
1015
+ ON x.term_id = t.term_id
1016
+ WHERE -t.term_id IN ($list)
1017
+ GROUP BY t.term_id
1018
+ ) temp_outer
1019
+ ORDER BY count DESC";
1020
$m = $this->mysqlQuery('rows', $sql, $name.' '.__LINE__);
1021
if (!$m)
1022
+ return;
1023
}
1024
1025
1028
{
1029
$r .= '<li>';
1030
// link only for editors in backend
1031
+ if ( current_user_can('manage_links') && !$frontend )
1032
{
1033
if ( $row->post_id > 0 )
1034
$r .= '<a href="post.php?action=edit&amp;post='.$row->post_id.'"><img src="'.$this->img('cpd_pen.png').'" alt="[e]" title="'.__('Edit Post').'" style="width:9px;height:12px;" /></a> '
1035
.'<a href="'.$this->dir.'/userperspan.php?page='.$row->post_id.'&amp;KeepThis=true&amp;TB_iframe=true" class="thickbox" title="Count per Day"><img src="'.$this->img('cpd_calendar.png').'" alt="[v]" style="width:12px;height:12px;" /></a> ';
1036
else
1037
+ $r .= '<img src="'.$this->img('cpd_trans.png').'" alt="" style="width:25px;height:12px;" />';
1038
}
1039
1040
$r .= '<a href="'.get_bloginfo('url');
1041
+ if ( $row->tax == 'category' )
1042
+ // category
1043
$r .= '?cat='.abs($row->post_id).'">- '.$row->tag_cat_name.' ('.__('Category').') -';
1044
+ else if ( $row->tax )
1045
// tag
1046
$r .= '?tag='.$row->tag_cat_slug.'">- '.$row->tag_cat_name.' ('.__('Tag').') -';
1047
else if ( $row->post_id == 0 )
1058
return $r;
1059
}
1060
1061
+ /**
1062
+ * shows searchstrings
1063
+ */
1064
+ function getSearches( $limit = 0, $days = 0, $return = false )
1065
+ {
1066
+ $search = get_option('count_per_day_search');
1067
+ if (!$search)
1068
+ return;
1069
+
1070
+ if ( $limit == 0 )
1071
+ $limit = $this->options['dashboard_referers'];
1072
+ if ( $days == 0 )
1073
+ $days = $this->options['referers_last_days'];
1074
+
1075
+ // most searched
1076
+ $c = array();
1077
+ foreach ( $search as $day => $strings )
1078
+ {
1079
+ foreach ( $strings as $s )
1080
+ {
1081
+ if (isset($c[$s]))
1082
+ $c[$s]++;
1083
+ else
1084
+ $c[$s] = 1;
1085
+ }
1086
+ }
1087
+ arsort($c);
1088
+ $c = array_slice($c, 0, $limit);
1089
+ $r = '<small>'.sprintf(__('The %s most searched strings:', 'cpd'), $limit).'</small>';
1090
+ $r .= '<ul class="cpd_front_list">';
1091
+ foreach ( $c as $string => $count )
1092
+ $r .= '<li>'.$string.' <b>'.$count.'</b></li>'."\n";
1093
+ $r .= '</ul>';
1094
+
1095
+ // last days
1096
+ krsort($search);
1097
+ $search = array_slice($search, 0, $days);
1098
+ $r .= '<small>'.sprintf(__('The search strings of the last %s days:', 'cpd'), $days).'</small>';
1099
+ $r .= '<ul class="cpd_front_list">';
1100
+ foreach ( $search as $day => $s )
1101
+ $r .= '<li><div style="font-weight:bold">'.$day.'</div> '.implode(', ', $s).'</li>'."\n";
1102
+ $r .= '</ul>';
1103
+ if ($return) return $r; else echo $r;
1104
+ }
1105
+
1106
/**
1107
* creates the little widget on dashboard
1108
*/
1320
echo '
1321
<ul id="cpdwidgetlist'.$field_id.'">
1322
<li class="cpd_widget_item cpd_widget_title">
1323
+ <label for="'.$field_id.'">'.__('Title').':</label>
1324
<input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.esc_attr( $instance['title'] ).'" />
1325
</li>';
1326
1391
delete_option('count_per_day_collected');
1392
delete_option('count_per_day_online');
1393
delete_option('count_per_day_notes');
1394
+ delete_option('count_per_day_posts');
1395
+ delete_option('count_per_day_search');
1396
$wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '%_cpd_metaboxes%';");
1397
}
1398
download.php CHANGED
@@ -14,7 +14,3 @@ $name = stripslashes($_GET['n']);
14
(substr($name, -2) == 'gz') ? header('Content-Type: application/x-gzip') : header('Content-Type: text/plain');
15
header("Content-Disposition: attachment; filename=\"$name\"");
16
readfile($file);
17
-
18
-
19
-
20
-
14
(substr($name, -2) == 'gz') ? header('Content-Type: application/x-gzip') : header('Content-Type: text/plain');
15
header("Content-Disposition: attachment; filename=\"$name\"");
16
readfile($file);
geoip/GeoIP.dat CHANGED
Binary file
geoip/geoip.php CHANGED
@@ -46,7 +46,7 @@ function updateDB()
46
$count_per_day->mysqlQuery('', "ALTER TABLE $wpdb->cpd_counter ADD `country` CHAR( 2 ) NOT NULL", 'GeoIP updateDB create column '.__LINE__);
47
48
$limit = 20;
49
- $res = $count_per_day->mysqlQuery('rows', "SELECT ip, INET_NTOA(ip) realip FROM $wpdb->cpd_counter WHERE country LIKE '' GROUP BY ip LIMIT $limit", 'GeoIP updateDB '.__LINE__);
50
$gi = cpd_geoip_open($cpd_path.'/geoip/GeoIP.dat', GEOIP_STANDARD);
51
52
foreach ($res as $r)
@@ -82,9 +82,6 @@ function updateGeoIpFile()
82
{
83
global $cpd_path;
84
85
- // set directory mode
86
- @chmod($cpd_path.'/geoip', 0777);
87
-
88
// function checks
89
if ( !ini_get('allow_url_fopen') )
90
return 'Sorry, <code>allow_url_fopen</code> is disabled!';
@@ -112,7 +109,7 @@ function updateGeoIpFile()
112
fwrite($h, $content);
113
fclose($h);
114
115
- @chmod($file, 0777);
116
if (is_file($file) && $del)
117
return __('New GeoIP database installed.', 'cpd');
118
else
46
$count_per_day->mysqlQuery('', "ALTER TABLE $wpdb->cpd_counter ADD `country` CHAR( 2 ) NOT NULL", 'GeoIP updateDB create column '.__LINE__);
47
48
$limit = 20;
49
+ $res = $count_per_day->mysqlQuery('rows', "SELECT ip, $count_per_day->ntoa(ip) realip FROM $wpdb->cpd_counter WHERE country LIKE '' GROUP BY ip LIMIT $limit", 'GeoIP updateDB '.__LINE__);
50
$gi = cpd_geoip_open($cpd_path.'/geoip/GeoIP.dat', GEOIP_STANDARD);
51
52
foreach ($res as $r)
82
{
83
global $cpd_path;
84
85
// function checks
86
if ( !ini_get('allow_url_fopen') )
87
return 'Sorry, <code>allow_url_fopen</code> is disabled!';
109
fwrite($h, $content);
110
fclose($h);
111
112
+ @chmod($file, 0755);
113
if (is_file($file) && $del)
114
return __('New GeoIP database installed.', 'cpd');
115
else
img/cpd_flags.png CHANGED
Binary file
locale/cpd-de_DE.mo CHANGED
Binary file
locale/cpd-de_DE.po CHANGED
@@ -1,9 +1,9 @@
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: \n"
7
"Last-Translator: Tom Braider <post@tomsdimension.de>\n"
8
"Language-Team: \n"
9
"MIME-Version: 1.0\n"
@@ -19,523 +19,604 @@ msgstr ""
19
"X-Poedit-SearchPath-0: .\n"
20
"X-Textdomain-Support: yes"
21
22
- #: counter-options.php:50
23
#@ cpd
24
msgid "Options updated"
25
msgstr "Einstellungen aktualisiert"
26
27
- #: counter-options.php:114
28
#, php-format
29
#@ cpd
30
msgid "Database cleaned. %s rows deleted."
31
msgstr "Datenbank aufger&auml;umt. %s Datens&auml;tze gel&ouml;scht."
32
33
- #: counter-options.php:129
34
- #: counter-options.php:836
35
#@ cpd
36
msgid "UNINSTALL Count per Day"
37
msgstr "DEINSTALLIERE Count per Day"
38
39
#: counter-options.php:134
40
#: counter-options.php:135
41
- #: counter-options.php:136
42
#, php-format
43
#@ cpd
44
msgid "Table %s deleted"
45
msgstr "Tabelle %s gel&ouml;scht"
46
47
- #: counter-options.php:137
48
#@ cpd
49
msgid "Options deleted"
50
msgstr "Einstellungen gel&ouml;scht"
51
52
- #: counter-options.php:318
53
- #: counter-options.php:822
54
#@ cpd
55
msgid "Uninstall"
56
msgstr "Deinstallation"
57
58
- #: counter-options.php:319
59
#@ cpd
60
msgid "Click here"
61
msgstr "Klick hier"
62
63
- #: counter-options.php:319
64
#@ cpd
65
msgid "to finish the uninstall and to deactivate \"Count per Day\"."
66
msgstr "um die Deinstallation zu beenden und \"Count per Day\" zu deaktivieren."
67
68
- #: counter-options.php:356
69
#@ cpd
70
msgid "Online time"
71
msgstr "Onlinezeit"
72
73
- #: counter-options.php:357
74
#@ cpd
75
msgid "Seconds for online counter. Used for \"Visitors online\" on dashboard page."
76
msgstr "Sekunden f&uuml;r Onlinecounter. Wird f&uuml;r die Anzeige der \"Besucher momentan online\" im Dashboard verwendet."
77
78
- #: counter-options.php:360
79
#@ cpd
80
msgid "Logged on Users"
81
msgstr "Angemeldete Benutzer"
82
83
- #: counter-options.php:362
84
#@ cpd
85
msgid "count too"
86
msgstr "auch mit z&auml;hlen"
87
88
- #: counter-options.php:374
89
#@ cpd
90
msgid "Auto counter"
91
msgstr "Auto-Counter"
92
93
- #: counter-options.php:375
94
#@ cpd
95
msgid "Counts automatically single-posts and pages, no changes on template needed."
96
msgstr "Z&auml;hlt automatisch Besuche auf Single-Posts und Seiten ohne &Auml;nderungen am Template."
97