<?php # Simple page hit counter for pmwiki # 2004 bhoc@tiscali.ch # modified line 9 to accept path_info-ed page names # modified line 17 to convert file contents to an integer global $pagecount; $pagecount = IncrementCounter("$WikiDir/.".str_replace("/", ".", $pagename).".count"); $InlineReplacements['/\\[\\[\$pagecount\\]\\]/'] = $pagecount; function IncrementCounter($counterfile) { $actn = strtolower($_REQUEST["action"]); if ($actn == "") $actn="browse"; if (file_exists($counterfile)) { $file = fopen($counterfile, "r"); $count = intval(fgets($file)); fclose($file); } else $count = 0; if ($actn == "browse") { $file = fopen($counterfile, "w"); fputs($file, ++$count); fclose($file); } return $count; } ?>