最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

DiscuzNT 論壇與主站的同步登錄與退出

 更新時間:2009年03月13日 00:16:09   作者:  
首先我先說明一下,我參考了這篇文章:http://nt.discuz.net/showtopic-49836.html,在這篇文章啟發(fā)下簡單化。 我裝的是2.5Beta版
論壇域名是:forum.web.net(虛擬)
網(wǎng)站域名是:www.web.net(虛擬too)
先用管理員帳戶進入論壇后臺在基本設(shè)置中,將“身份驗證Cookie域:”設(shè)置為.web.net
論壇配置好后,復(fù)制bin文件夾的 Discuz.Forum.dll,Discuz.Entity.dll,Discuz.Data.dll,Discuz.Data.SqlServer.dll 和Discuz.Common.dll到網(wǎng)站的bin下。同樣,DNT.Config也放到網(wǎng)站根目錄
貼個代碼看,更清楚些。
復(fù)制代碼 代碼如下:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using Discuz.Forum;
using Discuz.Common;
using Discuz.Entity;

namespace WebSite
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//下面的判斷作用是:檢測cookie中是不是有論壇的userid,如果有就說明有用戶登錄
if (Request.Cookies["dnt"] != null && Request.Cookies["dnt"].Values["userid"] != null)
{
//從cookie中獲得UserID
int uid = Convert.ToInt32(Request.Cookies["dnt"].Values["userid"].ToString());
//得到這個用戶的全部信息
UserInfo a = Discuz.Forum.Users.GetUserInfo(uid);
//打印出來看看對不對。
Response.Write(a.Username);
//這句代碼是退出!清除Cookie?。?!
ForumUtils.ClearUserCookie();
}
else //沒有用戶?看我怎么登錄的!
{
//先設(shè)倆變量
string uname = "rohan";
string upass = "mypassword";
//驗證用戶登錄 如果正確返回UserID,否則返回-1
int uid = Users.CheckPassword(uname, upass, true);
if (uid!=-1)
{
//下面都是官方整合說明文檔里的內(nèi)容了
LoginLogs.DeleteLoginLog(DNTRequest.GetIP());
//根據(jù)積分公式刷新用戶總積分
UserCredits.UpdateUserCredits(uid);
//寫入用戶登錄后的cookie
//××××××注意××××××這里有點特殊,原文是
//ForumUtils.WriteUserCookie(uid, Utils.StrToInt(DNTRequest.GetString("expires"), -1), config.Passwordkey, DNTRequest.GetInt("templateid", 0), DNTRequest.GetInt("loginmode", -1));
//這里我把config.Passwordkey直接從論壇config文件夾下的general.config文件的節(jié)點提取出來了。這樣就不用把論壇的相關(guān)文件拷貝到網(wǎng)站上了
ForumUtils.WriteUserCookie(uid, Utils.StrToInt(DNTRequest.GetString("expires"), -1), "R254842J4Z", DNTRequest.GetInt("templateid", 0), DNTRequest.GetInt("loginmode", -1));

//更新該用戶最后訪問時間
Users.UpdateUserLastvisit(uid, DNTRequest.GetIP());

}
}

}

}
}

相關(guān)文章

最新評論

靖安县| 无棣县| 龙口市| 临沧市| 阿尔山市| 广昌县| 和龙市| 乌兰察布市| 云梦县| 上饶县| 明星| 溧阳市| 耿马| 扶绥县| 德州市| 廊坊市| 馆陶县| 隆德县| 天等县| 法库县| 扶绥县| 崇礼县| 汝城县| 乌拉特后旗| 亳州市| 城口县| 桂阳县| 温宿县| 珲春市| 安仁县| 鹤庆县| 喀喇沁旗| 麻江县| 东台市| 平远县| 昭苏县| 临汾市| 新余市| 黄陵县| 临江市| 新蔡县|