国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > Discuz > 正文

asp.net DiscuzNT登錄,退出的代碼

2024-09-11 09:06:34
字體:
來源:轉載
供稿:網友
代碼如下:
using System;
using System.Collections.Generic;
using System.Text;
using Discuz.Common;
using Discuz.Forum;
using Discuz.Config;
using Discuz.Entity;
namespace DiscuzIntegration
{
public class Integration
{
public static void Login(string username, string password)
{
try
{
Discuz.Config.GeneralConfigInfo config = Discuz.Config.GeneralConfigs.GetConfig();
int uid = Users.GetUserID(username);
if (uid == -1 || !Users.Exists(uid))
{
Regedit(username, password);
uid = Users.GetUserID(username);
}
//刪除之前的錯誤登錄信息
LoginLogs.DeleteLoginLog(DNTRequest.GetIP());
//根據積分公式刷新用戶總積分
UserCredits.UpdateUserCredits(uid);
//寫入用戶登錄后的cookie
ForumUtils.WriteUserCookie(uid, Utils.StrToInt(DNTRequest.GetString("expires"), -1), config.Passwordkey, DNTRequest.GetInt("templateid", 0), DNTRequest.GetInt("loginmode", -1));
//更新用戶最后動作,如不需要可不執行
//OnlineUsers.UpdateAction(olid, UserAction.Login.ActionID, 0, config.Onlinetimeout);
//更新該用戶最后訪問時間
Users.UpdateUserLastvisit(uid, DNTRequest.GetIP());
}
catch
{
}
}
public static void Logout(string username)
{
try
{
int uid = Users.GetUserID(username);
int olid = OnlineUsers.GetOlidByUid(uid);
OnlineUsers.DeleteRows(olid);
ForumUtils.ClearUserCookie();
}
catch
{
}
}
public static bool Regedit(string tmpUsername, string password)
{
try
{
//以下為用戶注冊代碼
Discuz.Config.GeneralConfigInfo config = Discuz.Config.GeneralConfigs.GetConfig();
UserGroupInfo usergroupinfo = new UserGroupInfo();
usergroupinfo.Groupid = 10; //新手上路
//如果用戶名符合注冊規則, 則判斷是否已存在
if (Users.Exists(tmpUsername))
{
//
// 這里提示錯誤信息"用戶名已經存在!"
//
return false;
}
UserInfo __userinfo = new UserInfo();
__userinfo.Username = Utils.HtmlEncode(tmpUsername);
__userinfo.Nickname = Utils.HtmlEncode(DNTRequest.GetString(""));
__userinfo.Password = Utils.MD5(password);
__userinfo.Secques = "";// ForumUtils.GetUserSecques(DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
__userinfo.Gender = DNTRequest.GetInt("gender", 0);
__userinfo.Adminid = 0;
__userinfo.Groupexpiry = 0;
__userinfo.Extgroupids = "";
__userinfo.Regip = DNTRequest.GetIP();
__userinfo.Joindate = Utils.GetDateTime();
__userinfo.Lastip = DNTRequest.GetIP();
__userinfo.Lastvisit = Utils.GetDateTime();
__userinfo.Lastactivity = Utils.GetDateTime();
__userinfo.Lastpost = Utils.GetDateTime();
__userinfo.Lastpostid = 0;
__userinfo.Lastposttitle = "";
__userinfo.Posts = 0;
__userinfo.Digestposts = 0;
__userinfo.Oltime = 0;
__userinfo.Pageviews = 0;
__userinfo.Credits = 0;
__userinfo.Extcredits1 = Scoresets.GetScoreSet(1).Init;
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 铁力市| 鄢陵县| 汤原县| 屏东县| 封开县| 盘锦市| 盐津县| 西青区| 沙湾县| 北碚区| 安仁县| 安阳县| 灌南县| 雷山县| 出国| 文化| 手机| 泌阳县| 沙湾县| 乌鲁木齐市| 静宁县| 台山市| 资溪县| 黑龙江省| 辽阳县| 克什克腾旗| 黄骅市| 韶山市| 辽宁省| 根河市| 无为县| 崇左市| 故城县| 铁岭市| 绥阳县| 宜城市| 安达市| 磴口县| 陈巴尔虎旗| 密云县| 永济市|