====== Добавление счетчика в DokuWiki ====== Источник: [[http://wiki.erazor-zone.de/doku.php?id=wiki:projects:php:dokuwiki:counter]] ====== Count unique views for today ====== I patched the previos script because on my wiki I need to count unique views for today.\\ (Also I delete the PHP4 writing file support) \\ \\ Instructions: * Create the directory //wiki_dir/data/pages/_views// * Make sure //wiki_dir/data/pages/_views// is owned by the webserver user: chown -R www:www wiki_dir/data/pages/_views (or change www:www on your server's uid and gid) * Create the file //wiki_dir/inc/counter.php// and put this code in there: "; $ips = ""; $unique = true; $views = 0; $d = date("Ymd"); $file = realpath($conf["datadir"])."/_views/".$ID; if (file_exists($file)) { $content = file_get_contents($file); $pos = strpos($content, " "); if ($pos !== FALSE) { $views = substr($content, 0, $pos); $str = substr($content, $pos + 1); $pos = strpos($str, " "); if ($pos !== FALSE) { $old_d = substr($str, 0, $pos); $ips = substr($str, $pos + 1); if ($old_d != $d) { $views = 0; $ips = ""; } else if (strpos($ips, $myip) !== FALSE) { $unique = false; } } } } if (($ACT == "show") && ($INFO["exists"]) && ($unique)) { $ips.="\n".$myip; $content = ++$views." ".$d." ".$ips; file_put_contents($file, $content); } $fn.=" ($today_str $views $views_str) "; ?> * Edit function //tpl_pageinfo// in //wiki_dir/inc/template.php// to look like this: $fn = utf8_decodeFN($fn); $date = strftime($conf['dformat'],$INFO['lastmod']); // print it if($INFO['exists']){ ############################################### include("counter.php"); ############################################### print $fn; --ASCHE