這是本文件的舊版!
Views: <?php global $ID; $counter_dir = DOKU_CONF . 'pagecounters/'; if (!is_dir($counter_dir)) @mkdir($counter_dir, 0755, true);
$counter_file = $counter_dir . md5($ID) . '.txt'; $count = file_exists($counter_file) ? (int)file_get_contents($counter_file) : 0;
// Increment only for real users (ignore most bots)
if (!isset($_SERVER['HTTP_USER_AGENT']) ||
!preg_match('/bot|crawl|spider|slurp|pingdom|semrush|ahrefs/i', $_SERVER['HTTP_USER_AGENT'])) {
$count++;
file_put_contents($counter_file, $count);
}
echo $count; ?>