訪客計數器

餅乾大事紀 那兒看到了一個純文字的訪客計數器 Counterize,可以顯示的參數相當多,您可以參考本站下方

Total Hits:37 | Total Hits Today:2 | IP Visited:29 | Unique referers:17
Total Hit:本站點擊數
Total Hits Today:今日點擊數
IP Visited:IP 訪問數
Unique referers:被連結數

而這一個 Plug-in 的安裝方式可以參考 Counterize Installation,或是參考本站的安裝說明:
1.先取得 Counterize 原始程式(另存新檔後,存為 counterize.php),並放至 wp-content/plugins/Counterize
2.取得以下四個圖檔,並存至 wp-content/plugins/Counterize 目錄下
image1 | image2 | image3 | image4
3.在管理頁面啟用這個 Plugin
4.啟用後可能會遇到錯誤訊息,那是因為記錄 Countrize 資料表沒有被正確建立,這時候需要進入資料庫手動建立 Countrize 資料表
create table %sCounterize
(
id integer not null auto_increment,
IP varchar(16) not null default ‘unknown’,
timestamp datetime not null default ‘now()’,
url varchar(255) not null default ‘unknown’,
referer varchar(255) not null default ‘unknown’,
useragent text,
primary key(id)
)

將 %s 取代為你的 WordPress 前置字串,例如 wp_Counterize
如果在建立資料表的時候,遇到錯誤訊息
#1067 – Invalid default value for ‘timestamp’
原因是你的資料庫無法在 datetime 欄位中接受 now() 的預設值,請改用以下的 SQL Command

CREATE TABLE `wp_Counterize` (
`id` int(11) NOT NULL auto_increment,
`IP` varchar(16) NOT NULL default ‘unknown’,
`timestamp` datetime NOT NULL,
`url` varchar(255) NOT NULL default ‘unknown’,
`referer` varchar(255) NOT NULL default ‘unknown’,
`useragent` text,
PRIMARY KEY (`id`)
)

5.接下來,就是決定要把計數器顯示到畫面的那一個地方了,在這裡,你需要決定要顯示的參數,然後把這個參數寫到模版(外觀 -> 佈景主題編輯器)中,例如本站的參數
“.counterize_getamount() .
“ | Total Hits Today:“.counterize_gethitstoday() .
| IP Visited:“.counterize_getuniqueamount() .
| Unique referers:" . counterize_getuniquereferers()."“;
?>

6.Countrize 計數器參數列表
echo counterize_getuniqueurl()
– Returns amount of unique URl’s that have been shown

echo counterize_getamount()
– Returns total hits seen by Counterize.

echo counterize_gethitstoday()
– Returns total hits registered today.

echo counterize_getuniquebrowsers()
– Returns amount of unique browser-strings that have visited.

echo counterize_getuniquereferers()
– Returns amount of unique referers that’s registered.

echo counterize_getlatest7days()
– Returns total amount of hits from the last 7 days.

echo counterize_getuniqueamount()
– Returns total unique IP’s that’s been seen.

echo counterize_getfromcurrentip()
– Returns total hits from the IP that’s visiting.

echo counterize_getuniquehitstoday()
– Returns the number of different IP’s registered today.

echo counterize_gethitstodayfromcurrentip()
– Returns daily hits from the IP that’s visiting.

echo counterize_return_first_hit()
– Returns the date of the first registrated entry in the database.

counterize_most_visited_pages()
– Create graph of most visited pages.

counterize_most_visited_ips()
– Create graph of most active IPs.

counterize_most_used_browsers()
– Create graph of most seen useragents.