Version Description
Download this release
Release Info
Developer | Tom Braider |
Plugin | Count per Day |
Version | 1.1 |
Comparing to | |
See all releases |
Version 1.1
- counter-options.php +105 -0
- counter.css +31 -0
- counter.php +331 -0
- locale/de_DE.mo +0 -0
- locale/de_DE.po +148 -0
- readme.txt +93 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
counter-options.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Count Per Day - Options and Uninstall
|
4 |
+
*/
|
5 |
+
|
6 |
+
// Form auswerten
|
7 |
+
if(!empty($_POST['do']))
|
8 |
+
{
|
9 |
+
switch($_POST['do'])
|
10 |
+
{
|
11 |
+
// update options
|
12 |
+
case 'cpd_update' :
|
13 |
+
update_option( 'cpd_onlinetime', $_POST['cpd_onlinetime'] );
|
14 |
+
$u = empty( $_POST['cpd_user'] ) ? 0 : 1 ;
|
15 |
+
update_option( 'cpd_user', $u );
|
16 |
+
update_option( 'cpd_bots', $_POST['cpd_bots'] );
|
17 |
+
echo '<div id="message" class="updated fade"><p>'.__('Options updated', 'cpd').'</p></div>';
|
18 |
+
break;
|
19 |
+
// uninstall plugin
|
20 |
+
case __('UNINSTALL Count per Day', 'cpd') :
|
21 |
+
if(trim($_POST['uninstall_cpd_yes']) == 'yes')
|
22 |
+
{
|
23 |
+
$wpdb->query("DROP TABLE IF EXISTS ".CPD_C_TABLE.";");
|
24 |
+
$wpdb->query("DROP TABLE IF EXISTS ".CPD_CO_TABLE.";");
|
25 |
+
delete_option('cpd_cdb_version');
|
26 |
+
delete_option('cpd_codb_version');
|
27 |
+
delete_option('cpd_onlinetime');
|
28 |
+
delete_option('cpd_user');
|
29 |
+
delete_option('cpd_bots');
|
30 |
+
echo '<div id="message" class="updated fade" style="color:green;"><p>';
|
31 |
+
echo __('Table', 'cpd').' '.CPD_C_TABLE.' '.__('deleted', 'cpd').'<br/>';
|
32 |
+
echo __('Table', 'cpd').' '.CPD_CO_TABLE.' '.__('deleted', 'cpd').'<br/>';
|
33 |
+
echo __('Options', 'cpd').' '.__('deleted', 'cpd').'</p></div>';
|
34 |
+
$mode = 'end-UNINSTALL';
|
35 |
+
}
|
36 |
+
break;
|
37 |
+
default:
|
38 |
+
break;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
switch($mode) {
|
44 |
+
// Deaktivierung
|
45 |
+
case 'end-UNINSTALL':
|
46 |
+
$deactivate_url = 'plugins.php?action=deactivate&plugin='.dirname(plugin_basename(__FILE__)).'/counter.php';
|
47 |
+
if(function_exists('wp_nonce_url'))
|
48 |
+
$deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_'.dirname(plugin_basename(__FILE__)).'/counter.php');
|
49 |
+
echo '<div class="wrap">';
|
50 |
+
echo '<h2>'.__('Uninstall', 'cpd').' "Count per Day"</h2>';
|
51 |
+
echo '<p><strong><a href="'.$deactivate_url.'">'.__('Click here', 'cpd').'</a> '.__('to finish the uninstall and to deactivate "Count per Day".', 'cpd').'</strong></p>';
|
52 |
+
echo '</div>';
|
53 |
+
break;
|
54 |
+
// Seite anzeigen
|
55 |
+
default:
|
56 |
+
?>
|
57 |
+
<div class="wrap">
|
58 |
+
<h2>Count per Day - <?php _e('Options', 'cpd') ?></h2>
|
59 |
+
|
60 |
+
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
|
61 |
+
<table class="form-table">
|
62 |
+
<tr>
|
63 |
+
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Online time', 'cpd') ?>:</th>
|
64 |
+
<td><input class="code" type="text" name="cpd_onlinetime" size="3" value="<?php echo get_option('cpd_onlinetime'); ?>" /> <?php _e('Seconds for online counter', 'cpd') ?></td>
|
65 |
+
</tr><tr>
|
66 |
+
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Loged on Users', 'cpd') ?>:</th>
|
67 |
+
<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>
|
68 |
+
</tr><tr>
|
69 |
+
<th nowrap="nowrap" scope="row" style="vertical-align:middle;"><?php _e('Bots to ignore', 'cpd') ?>:</th>
|
70 |
+
<td><textarea name="cpd_bots" cols="50" rows="10"><?php echo get_option('cpd_bots'); ?></textarea></td>
|
71 |
+
</tr>
|
72 |
+
</table>
|
73 |
+
<p class="submit">
|
74 |
+
<input type="hidden" name="do" value="cpd_update" />
|
75 |
+
<input type="submit" name="update" value="<?php _e('Update options', 'cpd') ?>" class="button" />
|
76 |
+
</p>
|
77 |
+
</form>
|
78 |
+
</div>
|
79 |
+
|
80 |
+
|
81 |
+
<!-- Uninstall -->
|
82 |
+
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
|
83 |
+
<div class="wrap" style="margin-top: 100px;">
|
84 |
+
<h2>Count per Day - <?php _e('Uninstall', 'cpd') ?></h2>
|
85 |
+
<p>
|
86 |
+
<?php _e('If "Count per Day" only disabled the tables in the database will be preserved.', 'cpd') ?><br/>
|
87 |
+
<?php _e('Here you can delete the tables and disable "Count per Day".', 'cpd') ?>
|
88 |
+
</p>
|
89 |
+
<p style="text-align: left; color: red">
|
90 |
+
<strong><?php _e('WARNING', 'cpd') ?>:</strong><br />
|
91 |
+
<?php _e('These tables (with ALL counter data) will be deleted.', 'cpd') ?><br />
|
92 |
+
<b><?php echo CPD_C_TABLE.', '.CPD_CO_TABLE; ?></b><br />
|
93 |
+
<?php _e('If "Count per Day" re-installed, the counter starts at 0.', 'cpd') ?>
|
94 |
+
</p>
|
95 |
+
<p> </p>
|
96 |
+
<p style="text-align: center;">
|
97 |
+
<input type="checkbox" name="uninstall_cpd_yes" value="yes" /> <?php _e('Yes', 'cpd'); ?><br /><br />
|
98 |
+
<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') ?>')" />
|
99 |
+
</p>
|
100 |
+
</div>
|
101 |
+
</form>
|
102 |
+
|
103 |
+
<?php
|
104 |
+
} // End switch($mode)
|
105 |
+
?>
|
counter.css
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.cpd_table {
|
2 |
+
width:100%;
|
3 |
+
}
|
4 |
+
|
5 |
+
.cpd_table td {
|
6 |
+
padding: 5px;
|
7 |
+
vertical-align: top;
|
8 |
+
}
|
9 |
+
|
10 |
+
.cpd_table div {
|
11 |
+
padding: 2px;
|
12 |
+
border: 1px #ccc solid;
|
13 |
+
}
|
14 |
+
|
15 |
+
.cpd_table h3 {
|
16 |
+
padding: 5px;
|
17 |
+
margin-top: 0;
|
18 |
+
background-color: #CFEBF7;
|
19 |
+
}
|
20 |
+
|
21 |
+
.cpd_table span {
|
22 |
+
font-size: larger;
|
23 |
+
color: #f00;
|
24 |
+
}
|
25 |
+
|
26 |
+
.cpd_table ul {
|
27 |
+
padding-left: 10px;
|
28 |
+
list-style: none;
|
29 |
+
}
|
30 |
+
|
31 |
+
|
counter.php
ADDED
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Count Per Day
|
4 |
+
Plugin URI: http://www.tomsdimension.de/wp-plugins/countperday
|
5 |
+
Description: Counter, shows reads per page; today, yesterday, last week, last months ... on dashboard.
|
6 |
+
Version: 1.1
|
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 |
+
* Seitenaufruf z�hlen und Counter anzeigen
|
21 |
+
*
|
22 |
+
* @param String $before Text vor Z�hlerstand
|
23 |
+
* @param String $after Text nach Z�hlerstand
|
24 |
+
* @param boolean $show "echo" (true, standard) oder "return"
|
25 |
+
* @param boolean $count z�hlen (true, standard) oder nur anzeigen
|
26 |
+
* * @return String Z�hlerstand
|
27 |
+
*/
|
28 |
+
function cpdShow( $before='', $after=' reads', $show = true, $count = true )
|
29 |
+
{
|
30 |
+
global $wpdb;
|
31 |
+
$page = get_the_ID();
|
32 |
+
if ( $count == true )
|
33 |
+
cpdCount();
|
34 |
+
$visits = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE page='$page';");
|
35 |
+
$visits_per_page = count($visits);
|
36 |
+
if ( $show == true )
|
37 |
+
echo $before.$visits_per_page.$after;
|
38 |
+
else
|
39 |
+
return $visits_per_page;
|
40 |
+
}
|
41 |
+
|
42 |
+
// Seitenaufruf nur z�hlen, keine Anzeige
|
43 |
+
function cpdCount()
|
44 |
+
{
|
45 |
+
global $wpdb;
|
46 |
+
cpdCreateTables();
|
47 |
+
if ( function_exists('get_the_ID') )
|
48 |
+
$page = get_the_ID();
|
49 |
+
|
50 |
+
$countUser = ( get_option('cpd_user') == 0 && is_user_logged_in() == true ) ? 0 : 1;
|
51 |
+
|
52 |
+
// nur z�hlen wenn: kein Bot, PostID vorhanden, Anmeldung passt
|
53 |
+
if ( cpdIsBot() == false && !empty($page) && $countUser == 1 )
|
54 |
+
{
|
55 |
+
$userip = $_SERVER['REMOTE_ADDR'];
|
56 |
+
$client = $_SERVER['HTTP_USER_AGENT'];
|
57 |
+
$date = date('ymd');
|
58 |
+
// UserIP f�r merken
|
59 |
+
$user_ip = $wpdb->get_results("SELECT * FROM ".CPD_C_TABLE." WHERE ip='$userip' AND date='$date' AND page='$page';");
|
60 |
+
if ( count($user_ip) == 0 )
|
61 |
+
$wpdb->query("INSERT INTO ".CPD_C_TABLE." (page, ip, client, date) VALUES ('"
|
62 |
+
.$wpdb->escape($page)."', '".$wpdb->escape($userip)."', '"
|
63 |
+
.$wpdb->escape($client)."', '".$wpdb->escape($date)."');");
|
64 |
+
|
65 |
+
$timestamp = time();
|
66 |
+
$timeout = $timestamp - get_option('cpd_onlinetime');
|
67 |
+
|
68 |
+
$wpdb->query("REPLACE INTO ".CPD_CO_TABLE." (timestamp, ip, page) VALUES ('".$wpdb->escape($timestamp)."','".$wpdb->escape($userip)."','".$wpdb->escape($page)."');");
|
69 |
+
$wpdb->query("DELETE FROM ".CPD_CO_TABLE." WHERE timestamp < $timeout;");
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
// Bot oder Mensch?
|
74 |
+
function cpdIsBot()
|
75 |
+
{
|
76 |
+
// Strings die auf Suchmaschinen deuten
|
77 |
+
$bots = explode( "\n", get_option('cpd_bots') );
|
78 |
+
$isBot = false;
|
79 |
+
foreach ( $bots as $bot )
|
80 |
+
{
|
81 |
+
if ( strpos( $_SERVER['HTTP_USER_AGENT'], trim($bot) ) !== false )
|
82 |
+
$isBot = true;
|
83 |
+
}
|
84 |
+
return $isBot;
|
85 |
+
}
|
86 |
+
|
87 |
+
// Tabellen erstellen wenn nicht vorhanden
|
88 |
+
function cpdCreateTables() {
|
89 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
90 |
+
global $wpdb;
|
91 |
+
|
92 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '".CPD_C_TABLE."'" ) != CPD_C_TABLE )
|
93 |
+
{
|
94 |
+
// Counter-Tabelle existieren nicht - anlegen
|
95 |
+
$sql ="CREATE TABLE IF NOT EXISTS `".CPD_C_TABLE."` (
|
96 |
+
`id` int(10) NOT NULL auto_increment,
|
97 |
+
`ip` varchar(15) NOT NULL,
|
98 |
+
`client` varchar(100) NOT NULL,
|
99 |
+
`date` char(6) NOT NULL,
|
100 |
+
`page` int(11) NOT NULL,
|
101 |
+
PRIMARY KEY (`id`)
|
102 |
+
);";
|
103 |
+
dbDelta($sql);
|
104 |
+
add_option('cpd_cdb_version', '1.0');
|
105 |
+
}
|
106 |
+
|
107 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '".CPD_CO_TABLE."'" ) != CPD_CO_TABLE )
|
108 |
+
{
|
109 |
+
// CounterOnline-Tabelle existieren nicht - anlegen
|
110 |
+
$sql ="CREATE TABLE IF NOT EXISTS `".CPD_CO_TABLE."` (
|
111 |
+
`timestamp` int(15) NOT NULL default '0',
|
112 |
+
`ip` varchar(15) NOT NULL default '',
|
113 |
+
`page` int(11) NOT NULL default '0',
|
114 |
+
PRIMARY KEY (`ip`)
|
115 |
+
);";
|
116 |
+
dbDelta($sql);
|
117 |
+
add_option('cpd_codb_version', '1.0');
|
118 |
+
}
|
119 |
+
|
120 |
+
add_option( 'cpd_onlinetime', 300 );
|
121 |
+
add_option( 'cpd_user', 0 );
|
122 |
+
add_option( 'cpd_bots', "bot\nspider\nsearch\ncrawler\nask.com\nvalidator\nsnoopy\n".
|
123 |
+
"suchen.de\nsuchbaer.de\nshelob\nsemager\nxenu\nsuch_de\nia_archiver\nMicrosoft URL Control\nnetluchs" );
|
124 |
+
}
|
125 |
+
|
126 |
+
// Statistikseite
|
127 |
+
function cpdDashbord()
|
128 |
+
{
|
129 |
+
?>
|
130 |
+
<div class="wrap">
|
131 |
+
<h2>Count per Day - <?php _e('Statistics', 'cpd') ?></h2>
|
132 |
+
<table class="cpd_table">
|
133 |
+
<tr>
|
134 |
+
<td>
|
135 |
+
<div>
|
136 |
+
<h3><?php _e('Reads at all', 'cpd') ?></h3>
|
137 |
+
<ul>
|
138 |
+
<li><?php _e('Reads at all', 'cpd') ?>: <span><?php cpdGetUserAll(); ?></span></li>
|
139 |
+
<li><?php _e('Reads currently online', 'cpd') ?>: <span><?php cpdGetUserOnline(); ?></span></li>
|
140 |
+
<li><?php _e('Reads today', 'cpd') ?>: <b><?php cpdGetUserToday(); ?></b></li>
|
141 |
+
<li><?php _e('Reads yesterday', 'cpd') ?>: <b><?php cpdGetUserYesterday(); ?></b></li>
|
142 |
+
<li><?php _e('Reads last week', 'cpd') ?>: <b><?php cpdGetUserLastWeek(); ?></b></li>
|
143 |
+
<li><?php _e('Counter starts at', 'cpd') ?>: <b><?php cpdGetFirstCount(); ?></b></li>
|
144 |
+
<li>Ø <?php _e('Reads per day', 'cpd') ?>: <b><?php cpdGetUserPerDay(); ?></b></li>
|
145 |
+
</ul>
|
146 |
+
</div>
|
147 |
+
</td>
|
148 |
+
<td>
|
149 |
+
<div><h3><?php _e('Reads per Month', 'cpd') ?></h3><?php cpdGetUserPerMonth(); ?></div>
|
150 |
+
</td>
|
151 |
+
<td>
|
152 |
+
<div><h3><?php _e('Reads per post', 'cpd') ?></h3><?php cpdGetUserPerPost(50); ?></div>
|
153 |
+
</td>
|
154 |
+
</tr>
|
155 |
+
</table>
|
156 |
+
</div>
|
157 |
+
<?php
|
158 |
+
}
|
159 |
+
|
160 |
+
// Statistik-Funktionen
|
161 |
+
|
162 |
+
/**
|
163 |
+
* zeigt momentane Besucher
|
164 |
+
*/
|
165 |
+
function cpdGetUserOnline()
|
166 |
+
{
|
167 |
+
global $wpdb;
|
168 |
+
$v = $wpdb->get_var("SELECT count(page) FROM ".CPD_CO_TABLE.";");
|
169 |
+
echo $v;
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* zeigt gesamte Besucher
|
174 |
+
*/
|
175 |
+
function cpdGetUserAll()
|
176 |
+
{
|
177 |
+
global $wpdb;
|
178 |
+
$v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." GROUP BY ip, date;");
|
179 |
+
echo count($v);
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* zeigt heutige Besucher
|
184 |
+
*/
|
185 |
+
function cpdGetUserToday()
|
186 |
+
{
|
187 |
+
global $wpdb;
|
188 |
+
$date = date('ymd',time());
|
189 |
+
$v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE date = '$date' GROUP BY ip;");
|
190 |
+
echo count($v);
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* zeigt Besucher vom Vortag
|
195 |
+
*/
|
196 |
+
function cpdGetUserYesterday()
|
197 |
+
{
|
198 |
+
global $wpdb;
|
199 |
+
$date = date('ymd',time()-60*60*24);
|
200 |
+
$v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE date = '$date' GROUP BY ip;");
|
201 |
+
echo count($v);
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* zeigt Besucher der letzten Woche (7 Tage)
|
206 |
+
*/
|
207 |
+
function cpdGetUserLastWeek()
|
208 |
+
{
|
209 |
+
global $wpdb;
|
210 |
+
$date = date('ymd',time()-60*60*24*7);
|
211 |
+
$v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE date >= '$date' GROUP BY ip;");
|
212 |
+
echo count($v);
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* zeigt Besucher pro Monat
|
217 |
+
*/
|
218 |
+
function cpdGetUserPerMonth()
|
219 |
+
{
|
220 |
+
global $wpdb;
|
221 |
+
$m = $wpdb->get_results("SELECT left(date,4) as month FROM ".CPD_C_TABLE." GROUP BY left(date,4) ORDER BY date desc");
|
222 |
+
echo '<ul>';
|
223 |
+
foreach ( $m as $row )
|
224 |
+
{
|
225 |
+
$v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." WHERE left(date,4) = ".$row->month." GROUP BY ip, date;");
|
226 |
+
echo '<li>20'.substr($row->month,0,2).'/'.substr($row->month,2,2).': <b>'.count($v).'</b></li>'."\n";
|
227 |
+
}
|
228 |
+
echo '</ul>';
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* zeigt Besucher pro Artikel
|
233 |
+
*
|
234 |
+
* @param integer $limit Sql-Limit, 0 = kein Limit
|
235 |
+
*/
|
236 |
+
function cpdGetUserPerPost( $limit = 0 )
|
237 |
+
{
|
238 |
+
global $wpdb;
|
239 |
+
global $table_prefix;
|
240 |
+
$sql = " SELECT count(".CPD_C_TABLE.".id) as count,
|
241 |
+
".$table_prefix."posts.post_title as post,
|
242 |
+
".$table_prefix."posts.ID as post_id
|
243 |
+
FROM ".CPD_C_TABLE."
|
244 |
+
LEFT JOIN ".$table_prefix."posts
|
245 |
+
ON ".$table_prefix."posts.id = ".CPD_C_TABLE.".page
|
246 |
+
GROUP BY ".CPD_C_TABLE.".page
|
247 |
+
ORDER BY count DESC";
|
248 |
+
if ( $limit > 0 )
|
249 |
+
$sql .= " LIMIT ".$limit;
|
250 |
+
$m = $wpdb->get_results($sql);
|
251 |
+
echo '<ul>';
|
252 |
+
foreach ( $m as $row )
|
253 |
+
echo '<li><a href="'.get_bloginfo('wpurl').'?p='.$row->post_id.'">'.$row->post.'</a>: <b>'.$row->count.'</b></li>'."\n";
|
254 |
+
echo '</ul>';
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* zeigt Counterstart, erster Tag
|
259 |
+
*/
|
260 |
+
function cpdGetFirstCount()
|
261 |
+
{
|
262 |
+
global $wpdb;
|
263 |
+
global $wp_locale;
|
264 |
+
$v = $wpdb->get_var("SELECT date FROM ".CPD_C_TABLE." ORDER BY date LIMIT 1;");
|
265 |
+
$date = strtotime( '20'.substr($v,0,2).'-'.substr($v,2,2).'-'.substr($v,4,2) );
|
266 |
+
echo date('j. ', $date) . $wp_locale->get_month( substr($v,2,2) ) . date(' Y', $date);
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* zeigt Durchschnitt Besucher pro Tag
|
271 |
+
*/
|
272 |
+
function cpdGetUserPerDay()
|
273 |
+
{
|
274 |
+
global $wpdb;
|
275 |
+
$v = $wpdb->get_results("SELECT MIN(date) as min, MAX(date) as max FROM ".CPD_C_TABLE.";");
|
276 |
+
foreach ($v as $row)
|
277 |
+
{
|
278 |
+
$min = strtotime( '20'.substr($row->min,0,2).'-'.substr($row->min,2,2).'-'.substr($row->min,4,2) );
|
279 |
+
$max = strtotime( '20'.substr($row->max,0,2).'-'.substr($row->max,2,2).'-'.substr($row->max,4,2) );
|
280 |
+
$tage = (($max - $min) / 86400 + 1);
|
281 |
+
}
|
282 |
+
$v = $wpdb->get_results("SELECT page FROM ".CPD_C_TABLE." GROUP BY ip, date;");
|
283 |
+
$count = count($v) / $tage;
|
284 |
+
if ( $count < 5 )
|
285 |
+
echo number_format($count, 2);
|
286 |
+
else
|
287 |
+
echo number_format($count, 0);
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* f�gt Stylesheet in WP-Head ein
|
292 |
+
*
|
293 |
+
*/
|
294 |
+
function cpdAddCSS() {
|
295 |
+
echo '<link type="text/css" rel="stylesheet" href="'.get_bloginfo('wpurl').'/'.PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)).'/counter.css"></link>' . "\n";
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* erstellt Men�eintr�ge
|
300 |
+
* @param string $content WP-"Content"
|
301 |
+
*/
|
302 |
+
function cpdMenu($content)
|
303 |
+
{
|
304 |
+
if (function_exists('add_options_page')) {
|
305 |
+
add_options_page('CountPerDay', 'Count Per Day', 'manage_options', 'options-general.php?page='.dirname(plugin_basename(__FILE__)).'/counter-options.php') ;
|
306 |
+
// Dashboard Men�punkt
|
307 |
+
add_submenu_page('index.php','CountPerDay','Count per Day',1,__FILE__,'cpdDashbord');
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
|
312 |
+
/**
|
313 |
+
* l�dt lokale Sprachdatei
|
314 |
+
*/
|
315 |
+
function cpd_init_locale()
|
316 |
+
{
|
317 |
+
$locale = get_locale();
|
318 |
+
$mofile = dirname(__FILE__) . "/locale/".$locale.".mo";
|
319 |
+
load_textdomain('cpd', $mofile);
|
320 |
+
load_plugin_textdomain('cpd', dirname(__FILE__));
|
321 |
+
}
|
322 |
+
|
323 |
+
//if (eregi("phpmyadmin",$_REQUEST['page'])) {
|
324 |
+
//add_action('admin_head', 'silpstream_wp_phpmyadmin_add_style');
|
325 |
+
//}
|
326 |
+
|
327 |
+
add_action('init', 'cpd_init_locale', 98);
|
328 |
+
add_action( 'admin_head', 'cpdAddCSS', 1000 );
|
329 |
+
add_action('admin_menu', 'cpdMenu');
|
330 |
+
register_activation_hook(__FILE__,'cpdCreateTables');
|
331 |
+
?>
|
locale/de_DE.mo
ADDED
Binary file
|
locale/de_DE.po
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Count per Day\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2008-05-24 13:37+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"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"X-Poedit-Language: German\n"
|
13 |
+
"X-Poedit-Country: GERMANY\n"
|
14 |
+
"X-Poedit-KeywordsList: __;_e\n"
|
15 |
+
"X-Poedit-Basepath: P:\\xampp\\htdocs\\td\\wp\\wp-content\\plugins\\\n"
|
16 |
+
"X-Poedit-SearchPath-0: count-per-day\n"
|
17 |
+
|
18 |
+
#: count-per-day/counter-options.php:17
|
19 |
+
msgid "Options updated"
|
20 |
+
msgstr "Einstellungen aktualisiert"
|
21 |
+
|
22 |
+
#: count-per-day/counter-options.php:20
|
23 |
+
#: count-per-day/counter-options.php:98
|
24 |
+
msgid "UNINSTALL Count per Day"
|
25 |
+
msgstr "DEINSTALLIERE Count per Day"
|
26 |
+
|
27 |
+
#: count-per-day/counter-options.php:31
|
28 |
+
#: count-per-day/counter-options.php:32
|
29 |
+
msgid "Table"
|
30 |
+
msgstr "Tabelle"
|
31 |
+
|
32 |
+
#: count-per-day/counter-options.php:31
|
33 |
+
#: count-per-day/counter-options.php:32
|
34 |
+
#: count-per-day/counter-options.php:33
|
35 |
+
msgid "deleted"
|
36 |
+
msgstr "gelöscht"
|
37 |
+
|
38 |
+
#: count-per-day/counter-options.php:33
|
39 |
+
#: count-per-day/counter-options.php:58
|
40 |
+
msgid "Options"
|
41 |
+
msgstr "Einstellungen"
|
42 |
+
|
43 |
+
#: count-per-day/counter-options.php:50
|
44 |
+
#: count-per-day/counter-options.php:84
|
45 |
+
msgid "Uninstall"
|
46 |
+
msgstr "Deinstallation"
|
47 |
+
|
48 |
+
#: count-per-day/counter-options.php:51
|
49 |
+
msgid "Click here"
|
50 |
+
msgstr "Klick hier"
|
51 |
+
|
52 |
+
#: count-per-day/counter-options.php:51
|
53 |
+
msgid "to finish the uninstall and to deactivate \"Count per Day\"."
|
54 |
+
msgstr "um die Deinstallation zu beenden und \"Count per Day\" zu deaktivieren."
|
55 |
+
|
56 |
+
#: count-per-day/counter-options.php:63
|
57 |
+
msgid "Online time"
|
58 |
+
msgstr "Onlinezeit"
|
59 |
+
|
60 |
+
#: count-per-day/counter-options.php:64
|
61 |
+
msgid "Seconds for online counter"
|
62 |
+
msgstr "Sekunden für Onlinecounter"
|
63 |
+
|
64 |
+
#: count-per-day/counter-options.php:66
|
65 |
+
msgid "Loged on Users"
|
66 |
+
msgstr "Angemeldete Benutzer"
|
67 |
+
|
68 |
+
#: count-per-day/counter-options.php:67
|
69 |
+
msgid "count too"
|
70 |
+
msgstr "auch mit zählen"
|
71 |
+
|
72 |
+
#: count-per-day/counter-options.php:69
|
73 |
+
msgid "Bots to ignore"
|
74 |
+
msgstr "Bots ignorieren"
|
75 |
+
|
76 |
+
#: count-per-day/counter-options.php:75
|
77 |
+
msgid "Update options"
|
78 |
+
msgstr "Einstellungen aktualisieren"
|
79 |
+
|
80 |
+
#: count-per-day/counter-options.php:86
|
81 |
+
msgid "If \"Count per Day\" only disabled the tables in the database will be preserved."
|
82 |
+
msgstr "Wenn \"Count per Day\" nur deaktiviert wird, bleiben die Tabellen in der Datenbank erhalten."
|
83 |
+
|
84 |
+
#: count-per-day/counter-options.php:87
|
85 |
+
msgid "Here you can delete the tables and disable \"Count per Day\"."
|
86 |
+
msgstr "Hier kannst du \"Count per Day\" deinstallieren und die Tabellen löschen."
|
87 |
+
|
88 |
+
#: count-per-day/counter-options.php:90
|
89 |
+
msgid "WARNING"
|
90 |
+
msgstr "WARNUNG"
|
91 |
+
|
92 |
+
#: count-per-day/counter-options.php:91
|
93 |
+
msgid "These tables (with ALL counter data) will be deleted."
|
94 |
+
msgstr "Diese Tabellen werden mit ALLEN Zählerdaten gelöscht."
|
95 |
+
|
96 |
+
#: count-per-day/counter-options.php:93
|
97 |
+
msgid "If \"Count per Day\" re-installed, the counter starts at 0."
|
98 |
+
msgstr "Wenn \"Count per Day\" erneut installiert wird, beginnt der Zähler bei 0."
|
99 |
+
|
100 |
+
#: count-per-day/counter-options.php:97
|
101 |
+
msgid "Yes"
|
102 |
+
msgstr "Ja, los!"
|
103 |
+
|
104 |
+
#: count-per-day/counter-options.php:98
|
105 |
+
msgid "You are sure to disable Count per Day and delete all data?"
|
106 |
+
msgstr "Bist du sicher, dass du Count per Day deaktivieren und alle Daten löschen willst?"
|
107 |
+
|
108 |
+
#: count-per-day/counter.php:157
|
109 |
+
msgid "Statistics"
|
110 |
+
msgstr "Statistiken"
|
111 |
+
|
112 |
+
#: count-per-day/counter.php:162
|
113 |
+
#: count-per-day/counter.php:164
|
114 |
+
msgid "Reads at all"
|
115 |
+
msgstr "Besucher gesamt"
|
116 |
+
|
117 |
+
#: count-per-day/counter.php:165
|
118 |
+
msgid "Reads currently online"
|
119 |
+
msgstr "Besucher momentan online"
|
120 |
+
|
121 |
+
#: count-per-day/counter.php:166
|
122 |
+
msgid "Reads today"
|
123 |
+
msgstr "Besucher heute"
|
124 |
+
|
125 |
+
#: count-per-day/counter.php:167
|
126 |
+
msgid "Reads yesterday"
|
127 |
+
msgstr "Besucher gestern"
|
128 |
+
|
129 |
+
#: count-per-day/counter.php:168
|
130 |
+
msgid "Reads last week"
|
131 |
+
msgstr "Besucher letzte Woche"
|
132 |
+
|
133 |
+
#: count-per-day/counter.php:169
|
134 |
+
msgid "Counter starts at"
|
135 |
+
msgstr "gezählt ab"
|
136 |
+
|
137 |
+
#: count-per-day/counter.php:170
|
138 |
+
msgid "Reads per day"
|
139 |
+
msgstr "Besucher pro Tag"
|
140 |
+
|
141 |
+
#: count-per-day/counter.php:175
|
142 |
+
msgid "Reads per Month"
|
143 |
+
msgstr "Besucher pro Monat"
|
144 |
+
|
145 |
+
#: count-per-day/counter.php:178
|
146 |
+
msgid "Reads per post"
|
147 |
+
msgstr "Besucher pro Artikel"
|
148 |
+
|
readme.txt
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Count per Day ===
|
2 |
+
Contributors: Tom Braider
|
3 |
+
Donate link: http://www.unicef.org
|
4 |
+
Tags: counter, count, posts, visits, reads
|
5 |
+
Requires at least: 2.0
|
6 |
+
Tested up to: 2.5.1
|
7 |
+
Stable tag: 1.1
|
8 |
+
|
9 |
+
Visit Counter, shows reads per page; today, yesterday, last week, last months and other statistics on dashboard.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Visit Counter, shows reads per page; today, yesterday, last week, last months and other statistics on dashboard.
|
14 |
+
|
15 |
+
It counts 1 visit per IP per day. So any reload of the page don't increment the counter.
|
16 |
+
|
17 |
+
Languages: english, german
|
18 |
+
|
19 |
+
== Installation ==
|
20 |
+
|
21 |
+
1. unzip plugin directory into the "/wp-content/plugins/" directory
|
22 |
+
1. activate the plugin through the 'Plugins' menu in WordPress
|
23 |
+
1. place "cpdShow()" within post-loop (e.g. in single.php)<br>
|
24 |
+
<?php if(function_exists('cpdShow')) { cpdShow(); } ?>
|
25 |
+
|
26 |
+
First activation will create the 2 tables wp _ cpd _ counter and wp _ cpd _ counter _ useronline.
|
27 |
+
|
28 |
+
**Configuration**
|
29 |
+
|
30 |
+
see Options Page :)
|
31 |
+
|
32 |
+
Function parameters:
|
33 |
+
|
34 |
+
cpdShow( $before, $after, $show )
|
35 |
+
|
36 |
+
* $before = text before number e.g. "<p>"
|
37 |
+
* $after = text after number e.g. " reads</p>"
|
38 |
+
* $show = true/false, "echo" complete string (standard) or "return" number only
|
39 |
+
|
40 |
+
cpdCount()
|
41 |
+
|
42 |
+
* only count reads, without output
|
43 |
+
|
44 |
+
== Frequently Asked Questions ==
|
45 |
+
|
46 |
+
= no questions =
|
47 |
+
|
48 |
+
no answers
|
49 |
+
|
50 |
+
== Screenshots ==
|
51 |
+
|
52 |
+
1. Statistics on Count-per-Day-Dashboard (german)
|
53 |
+
2. Options (german)
|
54 |
+
|
55 |
+
== Arbitrary section ==
|
56 |
+
|
57 |
+
**Filelist**
|
58 |
+
|
59 |
+
* counter.php
|
60 |
+
* counter-options.php
|
61 |
+
* counter.css
|
62 |
+
* locale/de_DE.mo
|
63 |
+
* locale/de_DE.po
|
64 |
+
|
65 |
+
**Changelog (german)**
|
66 |
+
|
67 |
+
_Version 1.1_
|
68 |
+
|
69 |
+
+ Sprachen englisch, deutsch
|
70 |
+
+ HTTP _ USER _ AGENT wird mit gespeichert. Kann zur Identifikation von Suchmaschinen genutzt werden.
|
71 |
+
+ Stylesheet für Admin-Bereich in eigene Datei ausgelagert
|
72 |
+
+ Search-Bots erweitert, wir wollen ja nur echte Leser zählen
|
73 |
+
|
74 |
+
Funktionen:
|
75 |
+
|
76 |
+
+ cpdShow( $before='', $after=' reads', $show = true, $count = true ) - neuer Parameter $count: false = nicht zählen, nur anzeigen
|
77 |
+
+ cpdGetUserPerPost( $limit = 0 ) - Besucher pro Post, Limit = Maximale Anzahl
|
78 |
+
+ cpdGetFirstCount() - Zählerstart, erster Besucher-Eintrag
|
79 |
+
+ cpdGetUserPerDay() - Durchschnittliche Besucher pro Tag seit Zählerstart
|
80 |
+
+ cpdGetUserAll() - Gesamtzahl Besucher
|
81 |
+
|
82 |
+
_Version 1.0_
|
83 |
+
|
84 |
+
Funktionen:
|
85 |
+
|
86 |
+
+ cpdShow( $before='', $after=' reads', $show = true ) - zählt Besucher und zeigt Zählerstand an
|
87 |
+
+ cpdCount() - zählt Besucher, zeigt aber nichts an
|
88 |
+
+ cpdIsBot() - checkt HTTP_USER_AGENT mit angegebenen "Bot-Strings", TRUE wenn Bot
|
89 |
+
+ cpdGetUserOnline() - zeigt Online-Besucher
|
90 |
+
+ cpdGetUserToday() - zeigt heutige Besucher
|
91 |
+
+ cpdGetUserYesterday() - zeigt gestrige Besucher
|
92 |
+
+ cpdGetUserLastWeek() - zeigt Besucher der letzten Woche, 7 Tage
|
93 |
+
+ cpdGetUserPerMonth() - zeigt Besucher pro Monat
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|