PostgreSQL也可以用\r
資料庫部分:
PostgreSQL版
代碼: 選擇全部
首先,新增資料表 phpbb_visit_counter
[code]CREATE TABLE phpbb_visit_counter();
代碼: 選擇全部
ALTER TABLE phpbb_visit_counter ADD vc_count int8;
代碼: 選擇全部
ALTER TABLE phpbb_visit_counter ALTER vc_count set NOT NULL;
代碼: 選擇全部
ALTER TABLE phpbb_visit_counter ALTER vc_count set DEFAULT 0;
代碼: 選擇全部
INSERT INTO phpbb_visit_counter VALUES ('0');
初始化完成。
[/code]
MySQL版
代碼: 選擇全部
新增一個資料庫表格(Table), 可以利用phpMyAdmin, 執行以下的script:
代碼:
CREATE TABLE phpbb_visit_counter (
vc_count int(11) NOT NULL default '0'
)
初始化phpbb_visit_counter資料庫表格
代碼:
INSERT INTO phpbb_visit_counter VALUES ('');
接著修改index.php
找到這段:
代碼: 選擇全部
//
// If you don't use these stats on your index
// you may want to consider removing them since
// it will reduce the number of queries speeding
// up page generation a little
//
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];
代碼: 選擇全部
// 更新計數器
$cookiename = $board_config['cookie_name'];
if ( !isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || !isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
{
$sql = "UPDATE $table_prefix" . "visit_counter SET vc_count = vc_count + 1";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, '資料庫錯誤', '', __LINE__, __FILE__, $sql);
}
}
// 取得目前參觀;人數
$sql = "SELECT vc_count FROM $table_prefix" . "visit_counter"; \r
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, '資料庫錯誤', '', __LINE__, __FILE__, $sql);
}
// Fetch sql result into a row
$row = mysql_fetch_array($result);
$vc_count = $row['vc_count'];
代碼: 選擇全部
$row = mysql_fetch_array($result);
代碼: 選擇全部
$row = pg_fetch_array($result);
接下來請找\r
代碼: 選擇全部
$template->assign_vars(array(
"TOTAL_POSTS" => sprintf($l_total_post_s, $total_posts),
"TOTAL_USERS" => sprintf($l_total_user_s, $total_users),
"NEWEST_USER" => sprintf($lang['Newest_user'], '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$newest_uid") . '">', $newest_user, '</a>'),
"FORUM_IMG" => $images['forum'],
"FORUM_NEW_IMG" => $images['forum_new'],
"FORUM_LOCKED_IMG" => $images['forum_locked'],
"L_MODERATOR" => $lang['Moderators'],
"L_FORUM_LOCKED" => $lang['Forum_is_locked'],
"L_MARK_FORUMS_READ" => $lang['Mark_all_forums'],
"U_MARK_READ" => append_sid("index.$phpEx?mark=forums"))
);
代碼: 選擇全部
"L_MARK_FORUMS_READ" => $lang['Mark_all_forums'],
"U_MARK_READ" => append_sid("index.$phpEx?mark=forums"))
代碼: 選擇全部
"VC_COUNT" => $vc_count,
再來,開啟/templates/subSilver/index_body.tpl
找到\r
代碼: 選擇全部
<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE}<br />
{LOGGED_IN_USER_LIST}</span></td>
代碼: 選擇全部
<td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE}<br />
{LOGGED_IN_USER_LIST}</span><br />
<span class="gensmall"> 參觀人數: {VC_COUNT}</span></td>