Count per Day - Version 2.16

Version Description

  • New: more modern charts (jQuery flot plugin)
  • New: widgets now sortable
  • New: GeoIP database included, non extra download after plugin update necessary
  • New: list "Visitors online" per country
  • New: option to limit the referrers list
  • New: option to not load stylesheet in frontend
  • New: function 'getMostVisitedPostIDs', can create a "related posts" list
  • Bugfix: GeoIP functions renamed, conflicts with other plugins
  • New Language: Greek, thanks to Essetai_Imar
Download this release

Release Info

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

Code changes from version 1.5 to 2.16

Files changed (61) hide show
  1. ajax.php +27 -0
  2. counter-options.php +443 -52
  3. counter-rtl.css +20 -0
  4. counter.css +345 -11
  5. counter.php +2135 -334
  6. geoip/GeoIP.dat +0 -0
  7. geoip/geoip.inc +502 -0
  8. geoip/geoip.php +139 -0
  9. img/cpd_blau.png +0 -0
  10. img/cpd_calendar.png +0 -0
  11. img/cpd_clients.png +0 -0
  12. img/cpd_flags.png +0 -0
  13. img/cpd_menu.gif +0 -0
  14. img/cpd_pen.png +0 -0
  15. img/cpd_rot.png +0 -0
  16. img/cpd_trans.png +0 -0
  17. js/excanvas.min.js +1 -0
  18. js/jquery.flot.min.js +1 -0
  19. locale/cpd-bg_BG.mo +0 -0
  20. locale/cpd-bg_BG.po +785 -0
  21. locale/cpd-da_DK.mo +0 -0
  22. locale/cpd-da_DK.po +785 -0
  23. locale/cpd-de_DE.mo +0 -0
  24. locale/cpd-de_DE.po +800 -0
  25. locale/cpd-el.mo +0 -0
  26. locale/cpd-el.po +786 -0
  27. locale/cpd-es_ES.mo +0 -0
  28. locale/cpd-es_ES.po +785 -0
  29. locale/cpd-fr_FR.mo +0 -0
  30. locale/cpd-fr_FR.po +784 -0
  31. locale/cpd-it_IT.mo +0 -0
  32. locale/cpd-it_IT.po +784 -0
  33. locale/cpd-nl_NL.mo +0 -0
  34. locale/cpd-nl_NL.po +784 -0
  35. locale/cpd-pl_PL.mo +0 -0
  36. locale/cpd-pl_PL.po +785 -0
  37. locale/cpd-pt_BR.mo +0 -0
  38. locale/cpd-pt_BR.po +785 -0
  39. locale/cpd-ru_RU.mo +0 -0
  40. locale/cpd-ru_RU.po +784 -0
  41. locale/cpd-sv_SE.mo +0 -0
  42. locale/cpd-sv_SE.po +784 -0
  43. locale/de_DE.mo +0 -0
  44. locale/de_DE.po +0 -177
  45. locale/it_IT.mo +0 -0
  46. locale/it_IT.po +0 -169
  47. locale/pt_BR.mo +0 -0
  48. locale/pt_BR.po +0 -175
  49. map/ammap.swf +0 -0
  50. map/data.xml.php +81 -0
  51. map/map.php +25 -0
  52. map/settings.xml.php +60 -0
  53. map/swfobject.js +8 -0
  54. map/world.swf +0 -0
  55. massbots.php +67 -0
  56. notes.php +125 -0
  57. readme.txt +353 -90
  58. screenshot-1.png +0 -0
  59. screenshot-2.png +0 -0
  60. screenshot-3.png +0 -0
  61. userperspan.php +105 -0
ajax.php ADDED
@@ -0,0 +1,27 @@
1
+ <?php
2
+ if ( $_GET['f'] == 'count' )
3
+ {
4
+ if (!session_id()) session_start();
5
+ require_once($_SESSION['cpd_wp'].'wp-load.php');
6
+
7
+ $cpd_funcs = CountPerDay_Widget::getWidgetFuncs();
8
+ $page = intval($_GET['page']);
9
+ if ( is_numeric($page) )
10
+ {
11
+ $count_per_day->count( '', $page );
12
+ foreach ( $cpd_funcs as $f )
13
+ {
14
+ if ( ($f == 'show' && $page) || $f != 'show' )
15
+ {
16
+ echo $f.'===';
17
+ if ( $f == 'getUserPerDay' )
18
+ eval('echo $count_per_day->getUserPerDay('.$count_per_day->options['dashboard_last_days'].');');
19
+ else if ( $f == 'show' )
20
+ eval('echo $count_per_day->show("", "", false, false, '.$page.');');
21
+ else
22
+ eval('echo $count_per_day->'.$f.'();');
23
+ echo '|';
24
+ }
25
+ }
26
+ }
27
+ }
counter-options.php CHANGED
@@ -1,136 +1,527 @@
1
<?php
2
/**
3
* Filename: counter-options.php
4
- * Count Per Day - Options and Uninstall
5
*/
6
7
- // Form auswerten
8
if(!empty($_POST['do']))
9
{
10
switch($_POST['do'])
11
{
12
// update options
13
case 'cpd_update' :
14
- update_option( 'cpd_onlinetime', $_POST['cpd_onlinetime'] );
15
- $u = empty( $_POST['cpd_user'] ) ? 0 : 1 ;
16
- update_option( 'cpd_user', $u );
17
- $a = empty( $_POST['cpd_autocount'] ) ? 0 : 1 ;
18
- update_option( 'cpd_autocount', $a );
19
- update_option( 'cpd_bots', $_POST['cpd_bots'] );
20
echo '<div id="message" class="updated fade"><p>'.__('Options updated', 'cpd').'</p></div>';
21
break;
22
// clean database
23
case 'cpd_clean' :
24
- $rows = cpdCleanDB();
25
echo '<div id="message" class="updated fade"><p>'.sprintf(__('Database cleaned. %s rows deleted.', 'cpd'), $rows).'</p></div>';
26
break;
27
// uninstall plugin
28
case __('UNINSTALL Count per Day', 'cpd') :
29
if(trim($_POST['uninstall_cpd_yes']) == 'yes')
30
{
31
- $wpdb->query("DROP TABLE IF EXISTS ".CPD_C_TABLE.";");
32
- $wpdb->query("DROP TABLE IF EXISTS ".CPD_CO_TABLE.";");
33
- delete_option('cpd_cdb_version');
34
- delete_option('cpd_codb_version');
35
- delete_option('cpd_onlinetime');
36
- delete_option('cpd_user');
37
- delete_option('cpd_autocount');
38
- delete_option('cpd_bots');
39
echo '<div id="message" class="updated fade"><p>';
40
printf(__('Table %s deleted', 'cpd'), CPD_C_TABLE);
41
echo '<br/>';
42
printf(__('Table %s deleted', 'cpd'), CPD_CO_TABLE);
43
echo '<br/>';
44
echo __('Options deleted', 'cpd').'</p></div>';
45
$mode = 'end-UNINSTALL';
46
}
47
break;
48
default:
49
break;
50
}
51
}
52
53
switch($mode) {
54
- // Deaktivierung
55
case 'end-UNINSTALL':
56
- $deactivate_url = 'plugins.php?action=deactivate&amp;plugin='.dirname(plugin_basename(__FILE__)).'/counter.php';
57
if ( function_exists('wp_nonce_url') )
58
- $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_'.dirname(plugin_basename(__FILE__)).'/counter.php');
59
echo '<div class="wrap">';
60
echo '<h2>'.__('Uninstall', 'cpd').' "Count per Day"</h2>';
61
echo '<p><strong><a href="'.$deactivate_url.'">'.__('Click here', 'cpd').'</a> '.__('to finish the uninstall and to deactivate "Count per Day".', 'cpd').'</strong></p>';
62
echo '</div>';
63
break;
64
- // Seite anzeigen
65
default:
66
?>
67
<div class="wrap">
68
- <h2>Count per Day - <?php _e('Options', 'cpd') ?></h2>
69
-
70
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
71
<table class="form-table">
72
<tr>
73
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Online time', 'cpd') ?>:</th>
74
- <td><input class="code" type="text" name="cpd_onlinetime" size="3" value="<?php echo get_option('cpd_onlinetime'); ?>" /> <?php _e('Seconds for online counter. Used for "Visitors online" on dashboard page.', 'cpd') ?></td>
75
- </tr><tr>
76
- <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Loged on Users', 'cpd') ?>:</th>
77
- <td><input type="checkbox" name="cpd_user" id="cpd_user" <?php if(get_option('cpd_user')==1) echo 'checked="checked"'; ?> /> <label for="cpd_user"><?php _e('count too', 'cpd') ?></label></td>
78
- </tr><tr>
79
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Auto counter', 'cpd') ?>:</th>
80
- <td><input type="checkbox" name="cpd_autocount" id="cpd_autocount" <?php if(get_option('cpd_autocount')==1) echo 'checked="checked"'; ?> /> <label for="cpd_autocount"><?php _e('Counts automatically single-posts and pages, no changes on template needed.', 'cpd') ?></label></td>
81
- </tr><tr>
82
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Bots to ignore', 'cpd') ?>:</th>
83
- <td><textarea name="cpd_bots" cols="50" rows="10"><?php echo get_option('cpd_bots'); ?></textarea></td>
84
</tr>
85
</table>
86
- <p class="submit">
87
- <input type="hidden" name="do" value="cpd_update" />
88
- <input type="submit" name="update" value="<?php _e('Update options', 'cpd') ?>" class="button-primary" />
89
- </p>
90
</form>
91
</div>
92
93
94
- <!-- Cleaner -->
95
- <div class="wrap" style="margin-top: 50px;">
96
- <h2>Count per Day - <?php _e('Clean the database', 'cpd') ?></h2>
97
98
<p>
99
- <?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') ?>
100
</p>
101
102
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
103
<p class="submit">
104
- <input type="hidden" name="do" value="cpd_clean" />
105
- <input type="submit" name="clean" value="<?php _e('Clean the database', 'cpd') ?>" class="button" />
106
</p>
107
</form>
108
</div>
109
-
110
111
<!-- Uninstall -->
112
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
113
- <div class="wrap" style="margin-top: 100px;">
114
- <h2>Count per Day - <?php _e('Uninstall', 'cpd') ?></h2>
115
<p>
116
- <b><?php _e('Since WP 2.7 you can delete the plugin directly after deactivation on the plugins page.', 'cpd') ?></b><br />
117
<?php _e('If "Count per Day" only disabled the tables in the database will be preserved.', 'cpd') ?><br/>
118
<?php _e('Here you can delete the tables and disable "Count per Day".', 'cpd') ?>
119
</p>
120
- <p style="text-align: left; color: red">
121
<strong><?php _e('WARNING', 'cpd') ?>:</strong><br />
122
<?php _e('These tables (with ALL counter data) will be deleted.', 'cpd') ?><br />
123
- <b><?php echo CPD_C_TABLE.', '.CPD_CO_TABLE; ?></b><br />
124
<?php _e('If "Count per Day" re-installed, the counter starts at 0.', 'cpd') ?>
125
</p>
126
<p>&nbsp;</p>
127
- <p class="submit" style="text-align: center;">
128
<input type="checkbox" name="uninstall_cpd_yes" value="yes" />&nbsp;<?php _e('Yes', 'cpd'); ?><br /><br />
129
<input type="submit" name="do" value="<?php _e('UNINSTALL Count per Day', 'cpd') ?>" class="button" onclick="return confirm('<?php _e('You are sure to disable Count per Day and delete all data?', 'cpd') ?>')" />
130
</p>
131
- </div>
132
</form>
133
134
- <?php
135
- } // End switch($mode)
136
- ?>
1
<?php
2
/**
3
* Filename: counter-options.php
4
+ * Count Per Day - Options and Administration
5
*/
6
7
+ // check form
8
if(!empty($_POST['do']))
9
{
10
switch($_POST['do'])
11
{
12
// update options
13
case 'cpd_update' :
14
+ $count_per_day->options['onlinetime'] = $_POST['cpd_onlinetime'];
15
+ $count_per_day->options['user'] = empty( $_POST['cpd_user'] ) ? 0 : 1 ;
16
+ $count_per_day->options['user_level'] = $_POST['cpd_user_level'];
17
+ $count_per_day->options['autocount'] = empty( $_POST['cpd_autocount'] ) ? 0 : 1 ;
18
+ $count_per_day->options['bots'] = $_POST['cpd_bots'];
19
+ $count_per_day->options['dashboard_posts'] = $_POST['cpd_dashboard_posts'];
20
+ $count_per_day->options['dashboard_last_posts'] = $_POST['cpd_dashboard_last_posts'];
21
+ $count_per_day->options['dashboard_last_days'] = $_POST['cpd_dashboard_last_days'];
22
+ $count_per_day->options['show_in_lists'] = empty( $_POST['cpd_show_in_lists'] ) ? 0 : 1 ;
23
+ $count_per_day->options['chart_days'] = $_POST['cpd_chart_days'];
24
+ $count_per_day->options['chart_height'] = $_POST['cpd_chart_height'];
25
+ $count_per_day->options['startdate'] = $_POST['cpd_startdate'];
26
+ $count_per_day->options['startcount'] = $_POST['cpd_startcount'];
27
+ $count_per_day->options['startreads'] = $_POST['cpd_startreads'];
28
+ $count_per_day->options['anoip'] = empty( $_POST['cpd_anoip'] ) ? 0 : 1 ;
29
+ $count_per_day->options['clients'] = $_POST['cpd_clients'];
30
+ $count_per_day->options['ajax'] = empty( $_POST['cpd_ajax'] ) ? 0 : 1 ;
31
+ $count_per_day->options['debug'] = empty( $_POST['cpd_debug'] ) ? 0 : 1 ;
32
+ $count_per_day->options['localref'] = empty( $_POST['cpd_localref'] ) ? 0 : 1 ;
33
+ $count_per_day->options['referrers'] = empty( $_POST['cpd_referrers'] ) ? 0 : 1 ;
34
+ $count_per_day->options['dashboard_referers'] = $_POST['cpd_dashboard_referers'];
35
+ $count_per_day->options['referers_last_days'] = $_POST['cpd_referers_last_days'];
36
+ $count_per_day->options['chart_old'] = empty( $_POST['cpd_chart_old'] ) ? 0 : 1 ;
37
+ $count_per_day->options['no_front_css'] = empty( $_POST['cpd_no_front_css'] ) ? 0 : 1 ;
38
+
39
+ if (empty($count_per_day->options['clients']))
40
+ $count_per_day->options['clients'] = 'Firefox, MSIE, Chrome, Safari, Opera';
41
+
42
+ if ( isset($_POST['cpd_countries']) )
43
+ $count_per_day->options['countries'] = $_POST['cpd_countries'];
44
+
45
+ update_option('count_per_day', $count_per_day->options);
46
+
47
echo '<div id="message" class="updated fade"><p>'.__('Options updated', 'cpd').'</p></div>';
48
break;
49
+
50
+ // update countries
51
+ case 'cpd_countries' :
52
+ if ( class_exists('CpdGeoIp') )
53
+ {
54
+ $count_per_day->queries[] = 'cpd_countries - class "CpdGeoIp" exists';
55
+ $rest = CpdGeoIp::updateDB();
56
+ echo '<div id="message" class="updated fade">
57
+ <form name="cpdcountries" method="post" action="'.$_SERVER['REQUEST_URI'].'">
58
+ <p>'.sprintf(__('Countries updated. <b>%s</b> entries in %s without country left', 'cpd'), $rest, CPD_C_TABLE);
59
+ if ( $rest > 100 )
60
+ {
61
+ // reload page per javascript until less than 100 entries without country
62
+ echo '<input type="hidden" name="do" value="cpd_countries" />
63
+ <input type="submit" name="updcon" value="'.__('update next', 'cpd').'" class="button" />';
64
+ if ( !$count_per_day->options['debug'] )
65
+ echo '<script type="text/javascript">document.cpdcountries.submit();</script>';
66
+ }
67
+ echo '</p>
68
+ </form>
69
+ </div>';
70
+ if ( $rest > 100 )
71
+ while (@ob_end_flush());
72
+ }
73
+ else
74
+ $count_per_day->queries[] = '<span style="color:red">cpd_countries - class "CpdGeoIp" NOT exists</span>';
75
+ break;
76
+
77
+ // download new GeoIP database
78
+ case 'cpd_countrydb' :
79
+ if ( class_exists('CpdGeoIp') )
80
+ {
81
+ $count_per_day->getQuery("SELECT country FROM ".CPD_C_TABLE, 'geoip_select');
82
+ if ((int) mysql_errno() == 1054)
83
+ // add row 'country' to counter db
84
+ $count_per_day->getQuery("ALTER TABLE `".CPD_C_TABLE."` ADD `country` CHAR(2) NOT NULL", 'geoip_alter');
85
+
86
+ $result = CpdGeoIp::updateGeoIpFile();
87
+ echo '<div id="message" class="updated fade"><p>'.$result.'</p></div>';
88
+ if ( file_exists($cpd_path.'geoip/GeoIP.dat') )
89
+ $cpd_geoip = 1;
90
+ }
91
+ break;
92
+
93
+ // delete massbots
94
+ case 'cpd_delete_massbots' :
95
+ if ( isset($_POST['limit']) )
96
+ {
97
+ $bots = $count_per_day->getMassBots($_POST['limit']);
98
+ $sum = 0;
99
+ while ( $row = mysql_fetch_array($bots) )
100
+ {
101
+ $count_per_day->getQuery("DELETE FROM ".CPD_C_TABLE." WHERE ip = INET_ATON('".$row['ip']."') AND date = '".$row['date']."'", 'deleteMassbots');
102
+ $sum += $row['posts'];
103
+ }
104
+ if ( $sum )
105
+ echo '<div id="message" class="updated fade"><p>'.sprintf(__('Mass Bots cleaned. %s counts deleted.', 'cpd'), $sum).'</p></div>';
106
+ }
107
+ break;
108
+
109
// clean database
110
case 'cpd_clean' :
111
+ $rows = $count_per_day->cleanDB();
112
echo '<div id="message" class="updated fade"><p>'.sprintf(__('Database cleaned. %s rows deleted.', 'cpd'), $rows).'</p></div>';
113
break;
114
+
115
+ // reset counter
116
+ case 'cpd_reset' :
117
+ $wpdb->query('TRUNCATE TABLE '.CPD_C_TABLE);
118
+ echo '<div id="message" class="updated fade"><p>'.sprintf(__('Counter reseted.', 'cpd'), $rows).'</p></div>';
119
+ break;
120
+
121
// uninstall plugin
122
case __('UNINSTALL Count per Day', 'cpd') :
123
if(trim($_POST['uninstall_cpd_yes']) == 'yes')
124
{
125
+ count_per_day_uninstall();
126
echo '<div id="message" class="updated fade"><p>';
127
printf(__('Table %s deleted', 'cpd'), CPD_C_TABLE);
128
echo '<br/>';
129
printf(__('Table %s deleted', 'cpd'), CPD_CO_TABLE);
130
echo '<br/>';
131
+ printf(__('Table %s deleted', 'cpd'), CPD_N_TABLE);
132
+ echo '<br/>';
133
echo __('Options deleted', 'cpd').'</p></div>';
134
$mode = 'end-UNINSTALL';
135
}
136
break;
137
+
138
default:
139
break;
140
}
141
}
142
143
+ // delete one massbots per click on X
144
+ if ( isset($_GET['dmbip']) && isset($_GET['dmbdate']) )
145
+ $count_per_day->getQuery("DELETE FROM ".CPD_C_TABLE." WHERE ip = '".$_GET['dmbip']."' AND date = '".$_GET['dmbdate']."'", 'deleteMassbot');
146
+
147
+ if ( empty($mode) )
148
+ $mode = '';
149
+
150
switch($mode) {
151
+ // deactivation
152
case 'end-UNINSTALL':
153
+ $deactivate_url = 'plugins.php?action=deactivate&amp;plugin='.$cpd_dir_name.'/counter.php';
154
if ( function_exists('wp_nonce_url') )
155
+ $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_'.$cpd_dir_name.'/counter.php');
156
echo '<div class="wrap">';
157
echo '<h2>'.__('Uninstall', 'cpd').' "Count per Day"</h2>';
158
echo '<p><strong><a href="'.$deactivate_url.'">'.__('Click here', 'cpd').'</a> '.__('to finish the uninstall and to deactivate "Count per Day".', 'cpd').'</strong></p>';
159
echo '</div>';
160
break;
161
+
162
default:
163
+ // show options page
164
+
165
+ $o = $count_per_day->options;
166
+
167
+ // save massbot limit
168
+ if(isset($_POST['limit']))
169
+ {
170
+ $o['massbotlimit'] = $_POST['limit'];
171
+ update_option('count_per_day', $o);
172
+ }
173
?>
174
<div class="wrap">
175
+ <h2><img src="<?php echo $count_per_day->getResource('cpd_menu.gif') ?>" alt="" style="width:24px;height:24px" /> Count per Day</h2>
176
+
177
+ <div id="poststuff">
178
+
179
+ <div class="postbox cpd_settings">
180
+ <h3><?php _e('Options', 'cpd') ?></h3>
181
+ <div class="inside">
182
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
183
+
184
+ <!-- counter -->
185
+
186
+ <fieldset>
187
+ <legend><?php _e('Counter', 'cpd') ?></legend>
188
+
189
<table class="form-table">
190
<tr>
191
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Online time', 'cpd') ?>:</th>
192
+ <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>
193
+ </tr>
194
+ <tr>
195
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Logged on Users', 'cpd') ?>:</th>
196
+ <td>
197
+ <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>
198
+ - <?php _e('until User Level', 'cpd') ?>
199
+ <select name="cpd_user_level">
200
+ <option value="10" <?php if ($o['user_level'] == 10) echo 'selected="selected"' ?>><?php echo translate_user_role('Administrator') ?> (10)</option>
201
+ <option value="7" <?php if ($o['user_level'] == 7) echo 'selected="selected"' ?>><?php echo translate_user_role('Editor') ?> (7)</option>
202
+ <option value="2" <?php if ($o['user_level'] == 2) echo 'selected="selected"' ?>><?php echo translate_user_role('Author') ?> (2)</option>
203
+ <option value="1" <?php if ($o['user_level'] == 1) echo 'selected="selected"' ?>><?php echo translate_user_role('Contributor') ?> (1)</option>
204
+ <option value="0" <?php if ($o['user_level'] == 0) echo 'selected="selected"' ?>><?php echo translate_user_role('Subscriber') ?> (0)</option>
205
+ </select>
206
+ </td>
207
+ </tr>
208
+ <tr>
209
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Auto counter', 'cpd') ?>:</th>
210
+ <td><label for="cpd_autocount"><input type="checkbox" name="cpd_autocount" id="cpd_autocount" <?php if($o['autocount']==1) echo 'checked="checked"'; ?> /> <?php _e('Counts automatically single-posts and pages, no changes on template needed.', 'cpd') ?></label></td>
211
+ </tr>
212
+ <tr>
213
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Bots to ignore', 'cpd') ?>:</th>
214
+ <td><textarea name="cpd_bots" cols="50" rows="10"><?php echo $o['bots']; ?></textarea></td>
215
+ </tr>
216
+ <tr>
217
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Anonymous IP', 'cpd') ?>:</th>
218
+ <td><label for="cpd_anoip"><input type="checkbox" name="cpd_anoip" id="cpd_anoip" <?php if($o['anoip']==1) echo 'checked="checked"'; ?> /> a.b.c.d &gt; a.b.c.x</label></td>
219
+ </tr>
220
+ <tr>
221
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Cache', 'cpd') ?> (beta):</th>
222
+ <td><label for="cpd_ajax"><input type="checkbox" name="cpd_ajax" id="cpd_ajax" <?php if($o['ajax']==1) echo 'checked="checked"'; ?> /> <?php _e('I use a cache plugin. Count these visits with ajax.', 'cpd') ?></label></td>
223
+ </tr>
224
+ <tr>
225
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Clients and referrers', 'cpd') ?>:</th>
226
+ <td><label for="cpd_referrers"><input type="checkbox" name="cpd_referrers" id="cpd_referrers" <?php if($o['referrers']==1) echo 'checked="checked"'; ?> /> <?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></td>
227
</tr>
228
</table>
229
+ </fieldset>
230
+
231
+ <!-- dashboard -->
232
+
233
+ <fieldset>
234
+ <legend><?php _e('Dashboard') ?></legend>
235
+ <table class="form-table">
236
+ <tr>
237
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Visitors per post', 'cpd') ?>:</th>
238
+ <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>
239
+ </tr>
240
+ <tr>
241
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Latest Counts - Posts', 'cpd') ?>:</th>
242
+ <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>
243
+ </tr>
244
+ <tr>
245
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Latest Counts - Days', 'cpd') ?>:</th>
246
+ <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>
247
+ </tr>
248
+ <tr>
249
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Chart - Days', 'cpd') ?>:</th>
250
+ <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>
251
+ </tr>
252
+ <tr>
253
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Chart - Height', 'cpd') ?>:</th>
254
+ <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>
255
+ </tr>
256
+ <tr>
257
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Old Charts', 'cpd') ?>:</th>
258
+ <td><label for="cpd_chart_old"><input type="checkbox" name="cpd_chart_old" id="cpd_chart_old" <?php if($o['chart_old']==1) echo 'checked="checked"'; ?> /> <?php _e('Show old bar charts.', 'cpd') ?></label></td>
259
+ </tr>
260
+ <?php if ($cpd_geoip) { ?>
261
+ <tr>
262
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Countries', 'cpd') ?>:</th>
263
+ <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>
264
+ </tr>
265
+ <?php } ?>
266
+ <tr>
267
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Browsers', 'cpd') ?>:</th>
268
+ <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>
269
+ </tr>
270
+ <tr>
271
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Referrers - Entries', 'cpd') ?>:</th>
272
+ <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>
273
+ </tr>
274
+ <tr>
275
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Referrers - Days', 'cpd') ?>:</th>
276
+ <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>
277
+ </tr>
278
+ <tr>
279
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Local URLs', 'cpd') ?>:</th>
280
+ <td><label for="cpd_localref"><input type="checkbox" name="cpd_localref" id="cpd_localref" <?php if($o['localref']==1) echo 'checked="checked"'; ?> /> <?php _e('Show local referrers too.', 'cpd') ?> (<?php echo bloginfo('url') ?>/...)</label></td>
281
+ </tr>
282
+ </table>
283
+ </fieldset>
284
+
285
+ <!-- lists -->
286
+
287
+ <fieldset>
288
+ <legend><?php _e('Posts') ?> / <?php _e('Pages') ?></legend>
289
+ <table class="form-table">
290
+ <tr>
291
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Show in lists', 'cpd') ?>:</th>
292
+ <td><label for="cpd_show_in_lists"><input type="checkbox" name="cpd_show_in_lists" id="cpd_show_in_lists" <?php if($o['show_in_lists']==1) echo 'checked="checked"'; ?> /> <?php _e('Show "Reads per Post" in a new column in post management views.', 'cpd') ?></label></td>
293
+ </tr>
294
+ </table>
295
+ </fieldset>
296
+
297
+ <!-- start values -->
298
+
299
+ <fieldset>
300
+ <legend><?php _e('Start Values', 'cpd') ?></legend>
301
+ <table class="form-table">
302
+ <tr>
303
+ <th colspan="2">
304
+ <?php _e('Here you can change the date of first count and add a start count.', 'cpd')?>
305
+ </th>
306
+ </tr>
307
+ <tr>
308
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Start date', 'cpd') ?>:</th>
309
+ <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>
310
+ </tr>
311
+ <tr>
312
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Start count', 'cpd') ?>:</th>
313
+ <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>
314
+ </tr>
315
+ <tr>
316
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Start count', 'cpd') ?>:</th>
317
+ <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>
318
+ </tr>
319
+ </table>
320
+ </fieldset>
321
+
322
+ <!-- Stylesheet -->
323
+
324
+ <fieldset>
325
+ <legend><?php _e('Stylesheet') ?></legend>
326
+ <table class="form-table">
327
+ <tr>
328
+ <th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('NO Stylesheet in Frontend', 'cpd') ?>:</th>
329
+ <td><label for="cpd_no_front_css"><input type="checkbox" name="cpd_no_front_css" id="cpd_no_front_css" <?php if($o['no_front_css']==1) echo 'checked="checked"'; ?> /> <?php _e('Do not load the stylesheet "counter.css" in frontend.', 'cpd') ?></label></td>
330
+ </tr>
331
+ </table>
332
+ </fieldset>
333
+
334
+ <!-- debug -->
335
+
336
+ <fieldset>
337
+ <legend style="color:red"><?php _e('Debug mode', 'cpd') ?></legend>
338
+ <p style="margin-top:15px;">
339
+ <label for="cpd_debug"><input type="checkbox" name="cpd_debug" id="cpd_debug" <?php if($o['debug']==1) echo 'checked="checked"'; ?> /> <?php _e('Show debug informations at the bottom of all pages.', 'cpd') ?></label>
340
+ </p>
341
+ </fieldset>
342
+
343
+ <input type="hidden" name="do" value="cpd_update" />
344
+ <input type="submit" name="update" value="<?php _e('Update options', 'cpd') ?>" class="button-primary" style="margin-left: 5px;" />
345
+
346
</form>
347
+
348
+ </div>
349
</div>
350
351
+ <!-- Countries -->
352
+ <div class="postbox">
353
+ <h3><?php _e('GeoIP - Countries', 'cpd') ?></h3>
354
+ <div class="inside">
355
356
+ <table class="form-table">
357
+ <?php if ( $cpd_geoip ) { ?>
358
+ <tr>
359
+ <td>
360
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
361
+ <input type="hidden" name="do" value="cpd_countries" />
362
+ <input type="submit" name="updcon" value="<?php _e('Update old counter data', 'cpd') ?>" class="button" />
363
+ </form>
364
+ </td>
365
+ <td><?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') ?></td>
366
+ </tr>
367
+ <?php } ?>
368
369
+ <?php if ( class_exists('CpdGeoIp') && ini_get('allow_url_fopen') && function_exists('gzopen') ) {
370
+ // install or update database ?>
371
+ <tr>
372
+ <td width="10">
373
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
374
+ <input type="hidden" name="do" value="cpd_countrydb" />
375
+ <input type="submit" name="updcondb" value="<?php _e('Update GeoIP database', 'cpd') ?>" class="button" />
376
+ </form>
377
+ </td>
378
+ <td><?php _e('Download a new version of GeoIP.dat file.', 'cpd') ?></td>
379
+ </tr>
380
+ <?php } ?>
381
+ </table>
382
+
383
<p>
384
+ <span class="cpd-r"><?php _e('More informations about GeoIP', 'cpd') ?>:
385
+ <a href="http://www.maxmind.com/app/geoip_country">www.maxmind.com</a></span>&nbsp;
386
+ </p>
387
+
388
+ </div>
389
+ </div>
390
+
391
+ <!-- Mass Bots -->
392
+ <div class="postbox">
393
+ <?php
394
+ $limit = (isset($o['massbotlimit'])) ? $o['massbotlimit'] : 25;
395
+ $limit = (isset($_POST['limit'])) ? $_POST['limit'] : $limit;
396
+ $limit_input = '<input type="text" size="3" name="limit" value="'.$limit.'" />';
397
+ $bots = $count_per_day->getMassBots($limit);
398
+ ?>
399
+ <h3><?php _e('Mass Bots', 'cpd') ?></h3>
400
+ <div class="inside">
401
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
402
+ <p>
403
+ <?php printf(__('Show all IPs with more than %s page views per day', 'cpd'), $limit_input) ?>
404
+ <input type="submit" name="showmassbots" value="<?php _e('show', 'cpd') ?>" class="button" />
405
+ </p>
406
+ </form>
407
+
408
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
409
+ <table class="widefat post">
410
+ <thead>
411
+ <tr>
412
+ <th><?php _e('IP', 'cpd') ?></th>
413
+ <th><?php _e('Date', 'cpd') ?></th>
414
+ <th><?php _e('Client', 'cpd') ?></th>
415
+ <th><?php _e('Views', 'cpd') ?></th>
416
+ </tr>
417
+ </thead>
418
+ <?php
419
+ $sum = 0;
420
+ if ( !mysql_errno() ) :
421
+ while ( $row = mysql_fetch_assoc($bots) )
422
+ {
423
+ $ip = $row['ip'];
424
+ echo '<tr><td style="white-space:nowrap">';
425
+ if ( $cpd_geoip )
426
+ {
427
+ $c = CpdGeoIp::getCountry($ip);
428
+ echo $c[1].' &nbsp;';
429
+ }
430
+ echo '<a href="?page=count-per-day/counter-options.php&amp;dmbip='.$row['longip'].'&amp;dmbdate='.$row['date'].'"
431
+ title="'.sprintf(__('Delete these %s counts', 'cpd'), $row['posts']).'"
432
+ style="color:red; font-weight: bold;">X</a> &nbsp;';
433
+ echo '<a href="http://www.easywhois.com/index.php?mode=iplookup&amp;domain='.$ip.'">'.$ip.'</a></td>'
434
+ .'<td style="white-space:nowrap;">'.mysql2date(get_option('date_format'), $row['date'] ).'</td>'
435
+ .'<td>'.$row['client'].'</td>'
436
+ .'<td style="text-align:right;"><a href="'.$count_per_day->dir.'/massbots.php?dmbip='.$row['longip'].'&amp;dmbdate='.$row['date'].'&amp;KeepThis=true&amp;TB_iframe=true" title="Count per Day" class="thickbox">'
437
+ .$row['posts'].'</a></td>'
438
+ .'</tr>';
439
+ $sum += $row['posts'];
440
+ }
441
+ endif;
442
+ ?>
443
+ </table>
444
+ <?php if ( $sum ) { ?>
445
+ <p class="submit">
446
+ <input type="hidden" name="do" value="cpd_delete_massbots" />
447
+ <input type="hidden" name="limit" value="<?php echo $limit ?>" />
448
+ <input type="submit" name="clean" value="<?php printf(__('Delete these %s counts', 'cpd'), $sum) ?>" class="button" />
449
+ </p>
450
+ <?php } ?>
451
+ </form>
452
+ </div>
453
+ </div>
454
+
455
+ <!-- Cleaner -->
456
+ <?php if ( $count_per_day->options['referrers'] ) : ?>
457
+ <div class="postbox">
458
+ <h3><?php _e('Clean the database', 'cpd') ?></h3>
459
+ <div class="inside">
460
+ <p>
461
+ <?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') ?>
462
+ </p>
463
+
464
+ <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
465
+ <p class="submit">
466
+ <input type="hidden" name="do" value="cpd_clean" />
467
+ <input type="submit" name="clean" value="<?php _e('Clean the database', 'cpd') ?>" class="button" />
468
+ </p>
469
+ </form>
470
+ </div>
471
+ </div>
472
+ <?php endif; ?>
473
+
474
+ <!-- Reset DBs -->
475
+ <div class="postbox">
476
+ <h3><?php _e('Reset the counter', 'cpd') ?></h3>
477
+ <div class="inside">
478
+ <p style="color: red">
479
+ <?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') ?>
480
</p>
481
482
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
483
<p class="submit">
484
+ <input type="hidden" name="do" value="cpd_reset" />
485
+ <input type="submit" name="clean" value="<?php _e('Reset the counter', 'cpd') ?>" class="button" />
486
</p>
487
</form>
488
</div>
489
+ </div>
490
491
<!-- Uninstall -->
492
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
493
+ <div class="postbox">
494
+ <h3><?php _e('Uninstall', 'cpd') ?></h3>
495
+ <div class="inside">
496
<p>
497
<?php _e('If "Count per Day" only disabled the tables in the database will be preserved.', 'cpd') ?><br/>
498
<?php _e('Here you can delete the tables and disable "Count per Day".', 'cpd') ?>
499
</p>
500
+ <p style="color: red">
501
<strong><?php _e('WARNING', 'cpd') ?>:</strong><br />
502
<?php _e('These tables (with ALL counter data) will be deleted.', 'cpd') ?><br />
503
+ <b><?php echo CPD_C_TABLE.', '.CPD_CO_TABLE.', '.CPD_N_TABLE; ?></b><br />
504
<?php _e('If "Count per Day" re-installed, the counter starts at 0.', 'cpd') ?>
505
</p>
506
<p>&nbsp;</p>
507
+ <p class="submit">
508
<input type="checkbox" name="uninstall_cpd_yes" value="yes" />&nbsp;<?php _e('Yes', 'cpd'); ?><br /><br />
509
<input type="submit" name="do" value="<?php _e('UNINSTALL Count per Day', 'cpd') ?>" class="button" onclick="return confirm('<?php _e('You are sure to disable Count per Day and delete all data?', 'cpd') ?>')" />
510
</p>
511
+ </div>
512
+ </div>
513
</form>
514
+
515
+ <!-- Plugin page -->
516
+ <div class="postbox">
517
+ <h3><?php _e('Support', 'cpd') ?></h3>
518
+ <div class="inside">
519
+ <?php $count_per_day->cpdInfo() ?>
520
+ </div>
521
+ </div>
522
+
523
+
524
+ </div><!-- poststuff -->
525
+ </div><!-- wrap -->
526
527
+ <?php } // End switch($mode)
counter-rtl.css ADDED
@@ -0,0 +1,20 @@
1
+ .cpd_front_list,
2
+ .cpd_front_list li
3
+ {
4
+ margin-right: 0 !important;
5
+ }
6
+
7
+ .cpd_front_list li,
8
+ .cpd-l,
9
+ .cpd-notes td,
10
+ .cpd-notes th
11
+ {
12
+ text-align: right;
13
+ }
14
+
15
+ .cpd_front_list li b,
16
+ .cpd-dashboard li b,
17
+ .cpd-r
18
+ {
19
+ float: left;
20
+ }
counter.css CHANGED
@@ -1,26 +1,360 @@
1
- .cpd_table {
2
- width: 100%;
3
}
4
5
- .cpd_table td {
6
- padding-right: 10px;
7
- vertical-align: top;
8
}
9
10
- .cpd_table li {
11
color: #777;
12
}
13
14
- .cpd_table li b {
15
font-family: Georgia,"Times New Roman",Times,serif;
16
- color: #2583ad;
17
font-size: 18px;
18
}
19
20
- .cpd_table li span {
21
color: #f00;
22
}
23
24
- .cpd_table ul {
25
- list-style: none;
26
}
1
+ /* frontend */
2
+
3
+ .cpd_front_list, .cpd_front_list li {
4
+ list-style-type: none !important;
5
+ margin-left: 0 !important;
6
}
7
8
+ .cpd_front_list li b { /* values */
9
+ float: right;
10
+ }
11
+
12
+ .cpd_front_chart {
13
+ padding-bottom: 5px;
14
+ }
15
+
16
+ .cpd_front_chart p {
17
+ padding: 0 !important;
18
+ }
19
+
20
+ .cpd_front_chart img {
21
+ vertical-align: bottom;
22
+ }
23
+
24
+ /* settings */
25
+
26
+ .cpd_settings fieldset {
27
+ margin: 10px 5px 20px;
28
+ padding: 0 10px 10px;
29
+ border: 1px solid #dfdfdf;
30
+ border-radius: 6px;
31
+ -moz-border-radius: 6px;
32
+ -webkit-border-radius: 6px;
33
+ }
34
+
35
+ .cpd_settings legend {
36
+ background: #dfdfdf;
37
+ border-radius: 10px;
38
+ -moz-border-radius: 10px;
39
+ -webkit-border-radius: 10px;
40
+ margin: 0 10px;
41
+ padding: 5px 10px;
42
+ text-shadow: 0 1px 0 #fff;
43
+ font-weight: bold;
44
+ }
45
+
46
+ /* dashboard */
47
+
48
+ #cpd-flot-place {
49
+ padding: 5px;
50
+ background: #fff;
51
+ border-radius: 6px;
52
+ border: 1px #ccc solid;
53
+ }
54
+
55
+ #cpd-flot-choice {
56
+ padding: 5px;
57
+ text-align: center;
58
}
59
60
+ #cpd-flot {
61
+ overflow: hidden;
62
+ }
63
+ #cpd-tooltip {
64
+ position: absolute;
65
+ z-index: 10;
66
+ display: none;
67
+ text-align: center;
68
+ padding: 2px 4px;
69
+ border: 1px solid #ddd;
70
+ border-radius: 4px;
71
+ background-color: #fff;
72
+ box-shadow: 3px 3px 4px rgba(0, 0, 0, 0.4);
73
+ }
74
+
75
+ .cpd-list-chart {
76
+ margin-bottom: 10px;
77
+ height: 50px;
78
+ border: 1px solid #ddd;
79
+ background: -moz-linear-gradient(top, #ccc 0, #fff 80%);
80
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #005), color-stop(81%, #4a7eb8), color-stop(82%, #5A646D), color-stop(87%, #fafafa));
81
+ }
82
+
83
+ .cpd-dashboard .inside {
84
+ padding: 5px;
85
+ }
86
+
87
+ .cpd-dashboard .cpd_front_list {
88
+ padding-right: 5px;
89
+ max-height: 200px;
90
+ overflow-y: auto;
91
+ }
92
+
93
+ .cpd-dashboard li {
94
color: #777;
95
+ padding-bottom: 2px;
96
+ border-bottom: 1px #ddd dotted;
97
+ overflow: hidden;
98
}
99
100
+ .cpd-dashboard li b {
101
+ float: right;
102
font-family: Georgia,"Times New Roman",Times,serif;
103
font-size: 18px;
104
+ color: #2583ad;
105
}
106
107
+ .cpd-dashboard li span {
108
color: #f00;
109
}
110
111
+ .cpd-dashboard a {
112
+ text-decoration: none;
113
+ }
114
+ /* column on post and page lists */
115
+ .column-cpd_reads {
116
+ width: 50px;
117
+ white-space: nowrap;
118
+ overflow: visible;
119
+ }
120
+
121
+ .cpd-l {}
122
+
123
+ .cpd-r {
124
+ float: right;
125
}
126
+
127
+ /* widget */
128
+
129
+ .cpd_widget_item {
130
+ padding: 2px 5px;
131
+ height: 25x;
132
+ background: #eee;
133
+ cursor: move;
134
+ border-radius: 4px;
135
+ }
136
+
137
+ .cpd_widget_title {
138
+ cursor:auto;
139
+ }
140
+
141
+ .cpd_widget_item .widefat {
142
+ width: 235px !important;
143
+ margin-left: 15px;
144
+ }
145
+
146
+ /* thickbox */
147
+
148
+ .cpd-thickbox {
149
+ background-color: #F7F6F1;
150
+ font-size: 13px;
151
+ }
152
+
153
+ .cpd-thickbox h2 {
154
+ font: italic 1.5em Georgia,"Times New Roman","Bitstream Charter",Times,serif;
155
+ margin: 0;
156
+ padding: 0;
157
+ color: #093E56;
158
+ }
159
+
160
+ .cpd-thickbox li {
161
+ padding-bottom: 5px;
162
+ border-top: none;
163
+ }
164
+
165
+ /* notes thickbox */
166
+
167
+ .cpd-notes {
168
+ width: 100%;
169
+ width: auto;
170
+ margin: 1px;
171
+ border-color: #000;
172
+ border-collapse: collapse;
173
+ }
174
+
175
+ .cpd-notes td, .cpd-notes th {
176
+ vertical-align: top;
177
+ text-align: left;
178
+ padding: 2px;
179
+ font: 12px Verdana, Arial, Helvetica, sans-serif;
180
+ border-bottom: 1px #aaa solid;
181
+ }
182
+
183
+ .cpd-notes th {
184
+ background-color: #8cbdd5;
185
+ font-weight: bold;
186
+ }
187
+
188
+ .cpd-notes .nowrap {
189
+ white-space: nowrap;
190
+ }
191
+
192
+ .cpd-notes .red {
193
+ background-color: #f00;
194
+ color: #ff0;
195
+ }
196
+
197
+ .cpd-notes .green {
198
+ background-color: #0a0;
199
+ color: #ff0;
200
+ }
201
+
202
+ .cpd-notes input {
203
+ width: 97%;
204
+ font: 12px Verdana, Arial, Helvetica, sans-serif;
205
+ }
206
+
207
+ /* clients */
208
+
209
+ .cpd-client-logo {
210
+ padding-left: 25px;
211
+ background: url(img/cpd_clients.png) no-repeat left -25px;
212
+ }
213
+
214
+ .cpd-client-chrome{background-position:0 0;}
215
+ .cpd-client-firefox{background-position:0 -49px;}
216
+ .cpd-client-msie{background-position:0 -98px;}
217
+ .cpd-client-opera{background-position:0 -147px;}
218
+ .cpd-client-safari{background-position:0 -196px;}
219
+
220
+ /*referrers */
221
+
222
+ #cpd_referrers li a {
223
+ width: 85%;
224
+ display: block;
225
+ float: left;
226
+ white-space: nowrap;
227
+ overflow: hidden;
228
+ }
229
+
230
+ /* flags */
231
+
232
+ .cpd-flag {
233
+ display: inline-block;
234
+ float: left;
235
+ width: 23px;
236
+ height: 12px;
237
+ margin-top: 3px;
238
+ background-image: url(img/cpd_flags.png);
239
+ background-repeat: no-repeat;
240
+ }
241
+
242
+ .cpd-flag-ae {background-position:0 0;}
243
+ .cpd-flag-af, .cpd-flag-xh, .cpd-flag-zu {background-position:0 -13px;}
244
+ .cpd-flag-al {background-position:0 -26px;}
245
+ .cpd-flag-am {background-position:0 -39px;}
246
+ .cpd-flag-ar {background-position:0 -52px;}
247
+ .cpd-flag-at {background-position:0 -65px;}
248
+ .cpd-flag-au {background-position:0 -78px;}
249
+ .cpd-flag-az {background-position:0 -91px;}
250
+ .cpd-flag-ba {background-position:0 -104px;}
251
+ .cpd-flag-bd {background-position:0 -117px;}
252
+ .cpd-flag-be {background-position:0 -130px;}
253
+ .cpd-flag-bg {background-position:0 -143px;}
254
+ .cpd-flag-bh {background-position:0 -156px;}
255
+ .cpd-flag-bn {background-position:0 -169px;}
256
+ .cpd-flag-bo {background-position:0 -182px;}
257
+ .cpd-flag-br {background-position:0 -195px;}
258
+ .cpd-flag-by {background-position:0 -208px;}
259
+ .cpd-flag-bz {background-position:0 -221px;}
260
+ .cpd-flag-ca {background-position:0 -234px;}
261
+ .cpd-flag-ch {background-position:0 -247px;}
262
+ .cpd-flag-ci {background-position:0 -260px;}
263
+ .cpd-flag-cl {background-position:0 -273px;}
264
+ .cpd-flag-cn {background-position:0 -286px;}
265
+ .cpd-flag-co {background-position:0 -299px;}
266
+ .cpd-flag-cr {background-position:0 -312px;}
267
+ .cpd-flag-cs {background-position:0 -325px;}
268
+ .cpd-flag-cy, .cpd-flag-el, .cpd-flag-gr {background-position:0 -338px;}
269
+ .cpd-flag-cz {background-position:0 -351px;}
270
+ .cpd-flag-da, .cpd-flag-dk {background-position:0 -364px;}
271
+ .cpd-flag-de {background-position:0 -377px;}
272
+ .cpd-flag-do {background-position:0 -390px;}
273
+ .cpd-flag-dz {background-position:0 -403px;}
274
+ .cpd-flag-ec {background-position:0 -416px;}
275
+ .cpd-flag-ee {background-position:0 -429px;}
276
+ .cpd-flag-eg {background-position:0 -442px;}
277
+ .cpd-flag-en, .cpd-flag-us {background-position:0 -455px;}
278
+ .cpd-flag-eo {background-position:0 -468px;}
279
+ .cpd-flag-es {background-position:0 -481px;}
280
+ .cpd-flag-eu {background-position:0 -494px;}
281
+ .cpd-flag-fi {background-position:0 -507px;}
282
+ .cpd-flag-fo {background-position:0 -520px;}
283
+ .cpd-flag-fr {background-position:0 -533px;}
284
+ .cpd-flag-gb {background-position:0 -546px;}
285
+ .cpd-flag-ge {background-position:0 -559px;}
286
+ .cpd-flag-gt {background-position:0 -572px;}
287
+ .cpd-flag-hk {background-position:0 -585px;}
288
+ .cpd-flag-hn {background-position:0 -598px;}
289
+ .cpd-flag-hr {background-position:0 -611px;}
290
+ .cpd-flag-hu {background-position:0 -624px;}
291
+ .cpd-flag-id {background-position:0 -637px;}
292
+ .cpd-flag-ie {background-position:0 -650px;}
293
+ .cpd-flag-il {background-position:0 -663px;}
294
+ .cpd-flag-in {background-position:0 -676px;}
295
+ .cpd-flag-iq {background-position:0 -689px;}
296
+ .cpd-flag-ir {background-position:0 -702px;}
297
+ .cpd-flag-is {background-position:0 -715px;}
298
+ .cpd-flag-it {background-position:0 -728px;}
299
+ .cpd-flag-ja, .cpd-flag-jp {background-position:0 -741px;}
300
+ .cpd-flag-jm {background-position:0 -754px;}
301
+ .cpd-flag-jo {background-position:0 -767px;}
302
+ .cpd-flag-kk {background-position:0 -780px;}
303
+ .cpd-flag-kp {background-position:0 -793px;}
304
+ .cpd-flag-kr {background-position:0 -806px;}
305
+ .cpd-flag-kw {background-position:0 -819px;}
306
+ .cpd-flag-ky {background-position:0 -832px;}
307
+ .cpd-flag-lb {background-position:0 -845px;}
308
+ .cpd-flag-li {background-position:0 -858px;}
309
+ .cpd-flag-lk {background-position:0 -871px;}
310
+ .cpd-flag-ls {background-position:0 -884px;}
311
+ .cpd-flag-lt {background-position:0 -897px;}
312
+ .cpd-flag-lu {background-position:0 -910px;}
313
+ .cpd-flag-lv {background-position:0 -923px;}
314
+ .cpd-flag-ly {background-position:0 -936px;}
315
+ .cpd-flag-ma {background-position:0 -949px;}
316
+ .cpd-flag-mk {background-position:0 -962px;}
317
+ .cpd-flag-mm {background-position:0 -975px;}
318
+ .cpd-flag-mo {background-position:0 -988px;}
319
+ .cpd-flag-mt {background-position:0 -1001px;}
320
+ .cpd-flag-mx {background-position:0 -1014px;}
321
+ .cpd-flag-my {background-position:0 -1027px;}
322
+ .cpd-flag-nb, .cpd-flag-nn, .cpd-flag-no {background-position:0 -1040px;}
323
+ .cpd-flag-ni {background-position:0 -1053px;}
324
+ .cpd-flag-nl {background-position:0 -1066px;}
325
+ .cpd-flag-nz {background-position:0 -1079px;}
326
+ .cpd-flag-om {background-position:0 -1092px;}
327
+ .cpd-flag-pa {background-position:0 -1105px;}
328
+ .cpd-flag-pe {background-position:0 -1118px;}
329
+ .cpd-flag-ph {background-position:0 -1131px;}
330
+ .cpd-flag-pk {background-position:0 -1144px;}
331
+ .cpd-flag-pl {background-position:0 -1157px;}
332
+ .cpd-flag-pr {background-position:0 -1170px;}
333
+ .cpd-flag-pt {background-position:0 -1183px;}
334
+ .cpd-flag-py {background-position:0 -1196px;}
335
+ .cpd-flag-qa {background-position:0 -1209px;}
336
+ .cpd-flag-ro {background-position:0 -1222px;}
337
+ .cpd-flag-rs {background-position:0 -1235px;}
338
+ .cpd-flag-ru {background-position:0 -1248px;}
339
+ .cpd-flag-sa {background-position:0 -1261px;}
340
+ .cpd-flag-se {background-position:0 -1274px;}
341
+ .cpd-flag-sg {background-position:0 -1287px;}
342
+ .cpd-flag-si {background-position:0 -1300px;}
343
+ .cpd-flag-sk {background-position:0 -1313px;}
344
+ .cpd-flag-sv {background-position:0 -1326px;}
345
+ .cpd-flag-sy {background-position:0 -1339px;}
346
+ .cpd-flag-th {background-position:0 -1352px;}
347
+ .cpd-flag-tn {background-position:0 -1365px;}
348
+ .cpd-flag-tr {background-position:0 -1378px;}
349
+ .cpd-flag-tt {background-position:0 -1391px;}
350
+ .cpd-flag-tw {background-position:0 -1404px;}
351
+ .cpd-flag-tz {background-position:0 -1417px;}
352
+ .cpd-flag-ua {background-position:0 -1430px;}
353
+ .cpd-flag-unknown, .cpd-flag-a1, .cpd-flag-a2, .cpd-flag-o1 {background-position:0 -1443px;}
354
+ .cpd-flag-uy {background-position:0 -1456px;}
355
+ .cpd-flag-uz {background-position:0 -1469px;}
356
+ .cpd-flag-ve {background-position:0 -1482px;}
357
+ .cpd-flag-vn {background-position:0 -1495px;}
358
+ .cpd-flag-ye {background-position:0 -1508px;}
359
+ .cpd-flag-za {background-position:0 -1521px;}
360
+ .cpd-flag-me {background-position:0 -1534px;}
counter.php CHANGED
@@ -2,19 +2,194 @@
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.
6
- Version: 1.5
7
- License: GPL
8
Author: Tom Braider
9
Author URI: http://www.tomsdimension.de
10
*/
11
12
13
/**
14
*/
15
- global $table_prefix;
16
- define('CPD_C_TABLE', $table_prefix.'cpd_counter');
17
- define('CPD_CO_TABLE', $table_prefix.'cpd_counter_useronline');
18
19
/**
20
* counts and shows visits
@@ -23,483 +198,2109 @@ define('CPD_CO_TABLE', $table_prefix.'cpd_counter_useronline');
23
* @param string $after string after the number
24
* @param boolean $show "echo" (true, standard) or "return"
25
* @param boolean $count count visits (true, standard) or only show vistis
26
* @return string counter string
27
*/
28
- function cpdShow( $before='', $after=' reads', $show = true, $count = true )
29
{
30
- global $wpdb;
31
- $page = get_the_ID();
32
- // only count once
33
- if ( $count == true && get_option('cpd_autocount') == 0 )
34
- cpdCount();
35
- $visits = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE page='$page';");
36
- $visits_per_page = count($visits);
37
- if ( $show == true )
38
- echo $before.$visits_per_page.$after;
39
else
40
- return $visits_per_page;
41
}
42
43
/**
44
- * shows visits (without counting)
45
*/
46
- function cpdCount()
47
{
48
global $wpdb;
49
- cpdCreateTables(); // create tables if necessary
50
-
51
- // find PostID
52
- if ( get_option('cpd_autocount') == 1 )
53
- {
54
- if (have_posts()) : while ( have_posts() && $page == 0 ) : the_post();
55
- $page = get_the_ID();
56
- endwhile; endif;
57
- rewind_posts();
58
}
59
- else if ( is_single() || is_page() )
60
- $page = get_the_ID();
61
else
62
- $page = 0;
63
64
- $countUser = ( get_option('cpd_user') == 0 && is_user_logged_in() == true ) ? 0 : 1;
65
66
- // only count if: non bot, PostID exists, Logon is ok
67
- if ( cpdIsBot() == false && !empty($page) && $countUser == 1 )
68
- {
69
- $userip = $_SERVER['REMOTE_ADDR'];
70
- $client = $_SERVER['HTTP_USER_AGENT'];
71
- $date = date('ymd');
72
- // memorize UserIP
73
- $user_ip = $wpdb->get_results("SELECT * FROM ".CPD_C_TABLE." WHERE ip='$userip' AND date='$date' AND page='$page';");
74
- if ( count($user_ip) == 0 )
75
- $wpdb->query("INSERT INTO ".CPD_C_TABLE." (page, ip, client, date) VALUES ('"
76
- .$wpdb->escape($page)."', '".$wpdb->escape($userip)."', '"
77
- .$wpdb->escape($client)."', '".$wpdb->escape($date)."');");
78
-
79
- $timestamp = time();
80
- $timeout = $timestamp - get_option('cpd_onlinetime');
81
-
82
- $wpdb->query("REPLACE INTO ".CPD_CO_TABLE." (timestamp, ip, page) VALUES ('".$wpdb->escape($timestamp)."','".$wpdb->escape($userip)."','".$wpdb->escape($page)."');");
83
- $wpdb->query("DELETE FROM ".CPD_CO_TABLE." WHERE timestamp < $timeout;");
84
- }
85
}
86
87
/**
88
- * bot or human?
89
- * @param string $client USER_AGENT
90
- * @param array $bots strings to check
91
*/
92
- function cpdIsBot( $client = '', $bots = '' )
93
{
94
- if ( empty($bots) )
95
- // load pattern
96
- $bots = explode( "\n", get_option('cpd_bots') );
97
- $isBot = false;
98
- foreach ( $bots as $bot )
99
{
100
- $b = trim($bot);
101
- if ( !empty($b) )
102
{
103
- if ( empty($client) )
104
- {
105
- if ( strpos( strtolower($_SERVER['HTTP_USER_AGENT']), strtolower($b) ) !== false )
106
- $isBot = true;
107
- }
108
- else
109
- {
110
- if ( strpos( strtolower($client), strtolower($b) ) !== false )
111
- $isBot = true;
112
- }
113
}
114
}
115
- return $isBot;
116
- }
117
118
119
/**
120
- * create tables if not exists
121
*/
122
- function cpdCreateTables() {
123
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
124
- global $wpdb;
125
126
- if ( $wpdb->get_var( "SHOW TABLES LIKE '".CPD_C_TABLE."'" ) != CPD_C_TABLE )
127
{
128
- // table "counter" is not exists
129
- $sql ="CREATE TABLE IF NOT EXISTS `".CPD_C_TABLE."` (
130
- `id` int(10) NOT NULL auto_increment,
131
- `ip` varchar(15) NOT NULL,
132
- `client` varchar(100) NOT NULL,
133
- `date` char(6) NOT NULL,
134
- `page` int(11) NOT NULL,
135
- PRIMARY KEY (`id`)
136
- );";
137
- dbDelta($sql);
138
- add_option('cpd_cdb_version', '1.0');
139
}
140
141
- if ( $wpdb->get_var( "SHOW TABLES LIKE '".CPD_CO_TABLE."'" ) != CPD_CO_TABLE )
142
{
143
- // table "counter-online" is not exists
144
- $sql ="CREATE TABLE IF NOT EXISTS `".CPD_CO_TABLE."` (
145
- `timestamp` int(15) NOT NULL default '0',
146
- `ip` varchar(15) NOT NULL default '',
147
- `page` int(11) NOT NULL default '0',
148
- PRIMARY KEY (`ip`)
149
- );";
150
- dbDelta($sql);
151
- add_option('cpd_codb_version', '1.0');
152
}
153
154
- add_option( 'cpd_onlinetime', 300 );
155
- add_option( 'cpd_user', 0 );
156
- add_option( 'cpd_autocount', 0 );
157
- add_option( 'cpd_bots', "bot\nspider\nsearch\ncrawler\nask.com\nvalidator\nsnoopy\n".
158
- "suchen.de\nsuchbaer.de\nshelob\nsemager\nxenu\nsuch_de\nia_archiver\nMicrosoft URL Control\nnetluchs" );
159
}
160
161
- register_activation_hook(__FILE__,'cpdCreateTables');
162
-
163
164
/**
165
- * statistics page
166
*/
167
- function cpdDashbord()
168
{
169
- ?>
170
- <div class="wrap">
171
- <h2>Count per Day - <?php _e('Statistics', 'cpd') ?></h2>
172
- <table class="cpd_table"><tr>
173
- <td>
174
- <table class="widefat">
175
- <thead><tr><th><?php _e('Reads at all', 'cpd') ?></th></tr></thead>
176
- <tbody><tr><td>
177
- <ul>
178
- <li><?php _e('Reads at all', 'cpd') ?>: <b><span><?php cpdGetUserAll(); ?></span></b></li>
179
- <li><?php _e('Visitors currently online', 'cpd') ?>: <b><span><?php cpdGetUserOnline(); ?></span></b></li>
180
- <li><?php _e('Reads today', 'cpd') ?>: <b><?php cpdGetUserToday(); ?></b></li>
181
- <li><?php _e('Reads yesterday', 'cpd') ?>: <b><?php cpdGetUserYesterday(); ?></b></li>
182
- <li><?php _e('Reads last week', 'cpd') ?>: <b><?php cpdGetUserLastWeek(); ?></b></li>
183
- <li><?php _e('Counter starts at', 'cpd') ?>: <b><?php cpdGetFirstCount(); ?></b></li>
184
- <li>&Oslash; <?php _e('Reads per day', 'cpd') ?>: <b><?php cpdGetUserPerDay(); ?></b></li>
185
- </ul>
186
- </td></tr></tbody>
187
- </table>
188
- </td>
189
- <td>
190
- <table class="widefat">
191
- <thead><tr><th><?php _e('Reads per month', 'cpd') ?></th></tr></thead>
192
- <tbody><tr><td><?php cpdGetUserPerMonth(); ?></td></tr></tbody>
193
- </table>
194
- </td>
195
- <td>
196
- <table class="widefat">
197
- <thead><tr><th><?php _e('Reads per post', 'cpd') ?></th></tr></thead>
198
- <tbody><tr><td><?php cpdGetUserPerPost(50); ?></td></tr></tbody>
199
- </table>
200
- </td>
201
- </tr></table>
202
203
- </div>
204
- <?php
205
}
206
207
- // statistic functions, you can use is in your template too
208
209
/**
210
- * shows current visitors
211
*/
212
- function cpdGetUserOnline()
213
{
214
global $wpdb;
215
- $v = $wpdb->get_var("SELECT count(page) FROM ".CPD_CO_TABLE.";");
216
- echo $v;
217
}
218
219
/**
220
- * shows all visitors
221
*/
222
- function cpdGetUserAll()
223
{
224
- global $wpdb;
225
- $v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." GROUP BY ip, date;");
226
- echo count($v);
227
}
228
229
/**
230
- * shows today visitors
231
*/
232
- function cpdGetUserToday()
233
{
234
- global $wpdb;
235
- $date = date('ymd',time());
236
- $v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE date = '$date' GROUP BY ip;");
237
- echo count($v);
238
}
239
240
/**
241
- * shows yesterday visitors
242
*/
243
- function cpdGetUserYesterday()
244
{
245
- global $wpdb;
246
- $date = date('ymd',time()-60*60*24);
247
- $v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE date = '$date' GROUP BY ip;");
248
- echo count($v);
249
}
250
251
/**
252
- * shows last week visitors (last 7 days)
253
*/
254
- function cpdGetUserLastWeek()
255
{
256
- global $wpdb;
257
- $date = date('ymd',time()-60*60*24*7);
258
- $v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE date >= '$date' GROUP BY ip;");
259
- echo count($v);
260
}
261
262
/**
263
- * shows visitors per month
264
*/
265
- function cpdGetUserPerMonth()
266
{
267
- global $wpdb;
268
- $m = $wpdb->get_results("SELECT left(date,4) as month FROM ".CPD_C_TABLE." GROUP BY left(date,4) ORDER BY date desc");
269
- echo '<ul>';
270
- foreach ( $m as $row )
271
- {
272
- $v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE left(date,4) = ".$row->month." GROUP BY ip, date;");
273
- echo '<li>20'.substr($row->month,0,2).'/'.substr($row->month,2,2).': <b>'.count($v).'</b></li>'."\n";
274
- }
275
- echo '</ul>';
276
}
277
278
/**
279
- * shows visitors per post
280
- *
281
- * @param integer $limit Sql-Limit, 0 = kein Limit
282
*/
283
- function cpdGetUserPerPost( $limit = 0 )
284
{
285
global $wpdb;
286
- global $table_prefix;
287
- $sql = " SELECT count(".CPD_C_TABLE.".id) as count,
288
- ".$table_prefix."posts.post_title as post,
289
- ".$table_prefix."posts.ID as post_id
290
- FROM ".CPD_C_TABLE."
291
- LEFT JOIN ".$table_prefix."posts
292
- ON ".$table_prefix."posts.id = ".CPD_C_TABLE.".page
293
- GROUP BY ".CPD_C_TABLE.".page
294
- ORDER BY count DESC";
295
- if ( $limit > 0 )
296
- $sql .= " LIMIT ".$limit;
297
- $m = $wpdb->get_results($sql);
298
- echo '<ul>';
299
- foreach ( $m as $row )
300
- echo '<li><a href="'.get_bloginfo('url').'?p='.$row->post_id.'">'.$row->post.'</a>: <b>'.$row->count.'</b></li>'."\n";
301
- echo '</ul>';
302
}
303
304
/**
305
- * shows counter start, first day
306
*/
307
- function cpdGetFirstCount()
308
{
309
- global $wpdb;
310
- global $wp_locale;
311
- $v = $wpdb->get_var("SELECT date FROM ".CPD_C_TABLE." ORDER BY date LIMIT 1;");
312
- $date = strtotime( '20'.substr($v,0,2).'-'.substr($v,2,2).'-'.substr($v,4,2) );
313
- echo date('j. ', $date) . $wp_locale->get_month( substr($v,2,2) ) . date(' Y', $date);
314
}
315
316
/**
317
- * shows averaged visitors per day
318
*/
319
- function cpdGetUserPerDay()
320
{
321
- global $wpdb;
322
- $v = $wpdb->get_results("SELECT MIN(date) as min, MAX(date) as max FROM ".CPD_C_TABLE.";");
323
- foreach ($v as $row)
324
- {
325
- $min = strtotime( '20'.substr($row->min,0,2).'-'.substr($row->min,2,2).'-'.substr($row->min,4,2) );
326
- $max = strtotime( '20'.substr($row->max,0,2).'-'.substr($row->max,2,2).'-'.substr($row->max,4,2) );
327
- $tage = (($max - $min) / 86400 + 1);
328
- }
329
- $v = $wpdb->get_results('SELECT page FROM '.CPD_C_TABLE.' GROUP BY ip, date');
330
- $count = count($v) / $tage;
331
- if ( $count < 5 )
332
- echo number_format($count, 2);
333
- else
334
- echo number_format($count, 0);
335
}
336
337
/**
338
- * deletes spam in table, if you add new bot pattern you can clean the db
339
*/
340
- function cpdCleanDB()
341
{
342
- global $wpdb;
343
344
- $bots = explode( "\n", get_option('cpd_bots') );
345
- $rows = 0;
346
- $v = $wpdb->get_results('SELECT * FROM '.CPD_C_TABLE);
347
- foreach ($v as $row)
348
{
349
- if ( cpdIsBot($row->client, $bots) )
350
- {
351
- $wpdb->query('DELETE FROM '.CPD_C_TABLE.' WHERE id = '.$row->id);
352
- $rows++;
353
- }
354
}
355
- return $rows;
356
}
357
358
/**
359
- * adds stylesheet
360
*/
361
- function cpdAddCSS() {
362
- $this_dir = get_bloginfo('wpurl').'/'.PLUGINDIR.'/'.dirname(plugin_basename(__FILE__));
363
- wp_enqueue_style('cpd_css', $this_dir.'/counter.css', array());
364
- wp_print_styles('cpd_css');
365
}
366
367
- // only on statistics page
368
- if ( eregi( 'count-per-day', $_REQUEST['page']) )
369
- add_action( 'admin_head', 'cpdAddCSS', 100 );
370
-
371
/**
372
- * adss menu
373
- * @param string $content WP-"Content"
374
*/
375
- function cpdMenu($content)
376
{
377
- global $wp_version;
378
- if (function_exists('add_options_page'))
379
{
380
- $menutitle = '';
381
- if ( version_compare( $wp_version, '2.6.999', '>' ) )
382
- $menutitle = '<img src="'.cpdGetResource('cpd_menu_2.gif').'" alt="" /> ';
383
- $menutitle .= 'Count per Day';
384
385
- add_options_page('CountPerDay', $menutitle, 'manage_options', dirname(plugin_basename(__FILE__)).'/counter-options.php') ;
386
- add_submenu_page('index.php','CountPerDay',$menutitle,1,__FILE__,'cpdDashbord');
387
388
- // $plugin = plugin_basename(__FILE__);
389
- // add_filter( 'plugin_action_links_' . $plugin, 'cpd_plugin_actions' );
390
391
}
392
}
393
394
- if ( is_admin() )
395
- add_action('admin_menu', 'cpdMenu');
396
-
397
-
398
/**
399
- * adds an action link to the plugins page
400
*/
401
- function cpdPluginActions($links, $file)
402
{
403
- if( $file == plugin_basename(__FILE__) )
404
- {
405
- $link = '<a href="options-general.php?page='.dirname(plugin_basename(__FILE__)).'/counter-options.php">'.__('Settings').'</a>';
406
- array_unshift( $links, $link );
407
- }
408
- return $links;
409
}
410
-
411
- add_filter('plugin_action_links', 'cpdPluginActions', 10, 2);
412
-
413
414
/**
415
- * adds locale support
416
*/
417
- function cpdInitLocale()
418
{
419
- $locale = get_locale();
420
- $mofile = dirname(__FILE__) . "/locale/".$locale.".mo";
421
- load_textdomain('cpd', $mofile);
422
- load_plugin_textdomain('cpd', dirname(__FILE__));
423
}
424
425
- add_action('init', 'cpdInitLocale', 98);
426
427
428
/**
429
- * loads automatic counter
430
*/
431
- function cpdAutocount( )
432
{
433
- if ( is_single() || is_page() )
434
- cpdCount();