這篇教學將為您展示如何整合 phpBB3 sessions 到您已存在的網站。
大家好!
如果您有一個現有的網站,您可能想使用 phpBB3 的 sessions。為什麼呢?好的,您可以檢查看看會員是否已經登入、會員有什麼權限等等。
注意:這篇文章是整合 phpBB3 Sessions 到您現有的網站 - 如果您只是需要另一個網頁,看起來像 phpBB3 的樣式,那麼參考這篇文章:添加一個新的自訂 PHPBB 頁面。
讓我們開始吧!
步驟 1
整合 phpBB3 到您的網站之第一步是重新命名現有檔案的副檔名為 .php(如有必要) --
例如,您需要重新命名 mypage.html 為 mypage.php。
當然,這將破壞任何現有的連結,所以必須確定更新連結點到新的 mypage.php 檔案。
步驟 2
您需要新增底下代碼到每個您想要增加 phpBB sessions 的頁面之上頭。
代碼: 選擇全部
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
?>
您現有的頁面在這裡
代碼: 選擇全部
$user->setup();
代碼: 選擇全部
$user->setup('base-name-of-language-file-here');
例如: 如果您想要載入 viewtopic.php 語言檔,那麼使用底下的代碼:
代碼: 選擇全部
$user->setup('viewtopic');
步驟 3 -- 例子
檢查看看會員是否已經登入
一個簡單的例子:檢查看看會員是否已經登入 -- 如果他或她已經登入,那麼顯示感謝的訊息,伴隨著他們的會員名稱;
如果他們尚未登入,那麼顯示要求其登入的相關訊息。
代碼: 選擇全部
<?php
if ($user->data['user_id'] == ANONYMOUS)
{
echo 'Please login!';
}
else
{
echo 'Thanks for logging in, ' . $user->data['username_clean'];
}
?>
- user_id - ID number of the user
- user_type - 2
- group_id - 1
- user_permissions - 00000000003khra6tc
i1cjyo000000
i1cjyo000000 - user_perm_from - 0
- user_ip -
- user_regdate - UNIX timestamp of the user's registration date
- username - user's username
- username_clean - clean version of the username
- user_password - MD5 encoded version of the user's password
- user_passchg - 0
- user_pass_convert - 0
- user_email - user's email address
- user_email_hash - 0
- user_birthday -
- user_lastvisit - 0
- user_lastmark - 0
- user_lastpost_time - 0
- user_lastpage -
- user_last_confirm_key -
- user_last_search - UNIX timestamp of the last search the user performed
- user_warnings - total number of warnings
- user_last_warning - UNIX timestamp of last warning
- user_login_attempts - number of login attempts this session
- user_inactive_reason - 0
- user_inactive_time - 0
- user_posts - total number of posts made by the user
- user_lang - user's language
- user_timezone - 0.00
- user_dst - 0
- user_dateformat - d M Y H:i
- user_style - 1
- user_rank - 0
- user_colour -
- user_new_privmsg - 0
- user_unread_privmsg - 0
- user_last_privmsg - 0
- user_message_rules - 0
- user_full_folder - -3
- user_emailtime - 0
- user_topic_show_days - 0
- user_topic_sortby_type - t
- user_topic_sortby_dir - d
- user_post_show_days - 0
- user_post_sortby_type - t
- user_post_sortby_dir - a
- user_notify - 0
- user_notify_pm - 1
- user_notify_type - 0
- user_allow_pm - 1
- user_allow_viewonline - 1
- user_allow_viewemail - 1
- user_allow_massemail - 0
- user_options - 895
- user_avatar -
- user_avatar_type - 0
- user_avatar_width - 0
- user_avatar_height - 0
- user_sig - the user's signature
- user_sig_bbcode_uid -
- user_sig_bbcode_bitfield -
- user_from - user's location
- user_icq - user's ICQ address
- user_aim - user's AIM address
- user_yim - user's Yahoo Messenger address
- user_msnm - user's MSN Live address
- user_jabber - user's Jabber address
- user_website - user's website
- user_occ - user's occupation
- user_interests -
- user_actkey -
- user_newpasswd -
- session_id - cf4eaea2eb0a0a1257bada05cd901ca7
- session_user_id - 1
- session_last_visit - UNIX timestamp of when the user last logged in
- session_start - UNIX timestamp of when the user logged in
- session_time - UNIX timestamp of the last time the user clicked on a page
- session_ip - current IP address
- session_browser - Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7
- session_forwarded_for -
- session_page - test.php
- session_viewonline - 1
- session_autologin - 0
- session_admin - 0
- is_registered -
- is_bot -
請享用!
--
http://www.phpbb.com/kb/article/phpbb3- ... tegration/