Stats-Plugs u. Unique Pageviews
Im WordPress.org Wiki findest du eine handvoll Statistik Plugins. Es gibt ein Unique Pageviews Plug aber die Site ist leider down.
Hier der Code:
PHP
<?php
/*
Plugin Name: Unique Pageviews
Plugin URI: http://schot.xs4all.nl/plugs
Description: Views counter for posts
Version: .03b2
Author: Jan-Maarten Schot
Author URI: http://schot.xs4all.nl
*/
function views($state) {
$count_id = $_GET['p'];
if ($count_id == NULL) {
global $id;
$result = mysql_query("
select *
from wp_count
where count_id = '".$id."'");
if ($state == "1") {
$views = mysql_num_rows($result);
if ($views == NULL) {
$views = "0";
}
}
else {
while ($r = mysql_fetch_row($result)) {
$views += $r[0];
}
if ($views == NULL) {
$views = "0";
}
}
echo $views . " Aufrufe";
return;
}
/*
-------------------------------------------------------------
*/
global $HTTP_SERVER_VARS;
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$update = mysql_query("
update wp_count
set count = count+1
where count_id='".$count_id."'
and count_ip='".$ip."'");
$affected = mysql_affected_rows();
if ($affected == "0") {
$create = mysql_query("
insert into wp_count
(count, count_id, count_ip)".
"VALUES (1, '$count_id', '$ip')");
}
if ($state == "1" ) {
$result = mysql_query("
select *
from wp_count
where count_id='".$count_id."'");
$views = mysql_num_rows($result);
}
else {
$count = mysql_query("
select *
from wp_count
where count_id='".$count_id."'");
while ($r = mysql_fetch_array($count)) {
$views += $r[0];
}
}
echo $views . " Aufrufe";
}
?>
Alles anzeigen
Das Plug in den Ordner wp-include/plugins schieben und mit <?php views(0); ?> aufrufen.
Es sollte nicht allzu schwer sein ein Stats-Plug damit zu kombinieren.