您现在的位置是:首页 > cms教程 > Discuz教程Discuz教程
discuz的NT3.5论坛整合.net网站用户登录退出的方法
文子隐2025-06-29Discuz教程已有人查阅
导读using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls.WebParts;using System.Data;using System.Text;using Discuz.Toolkit;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using System.Text;
using Discuz.Toolkit;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
using System.Xml.Linq;
using System.IO;
using Discuz.Common;
using Discuz.Forum;
using Discuz.Config;
using Discuz.Entity;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
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);
this.denglu.Visible = false;
this.tuichu.Visible = true;
Label1.Text = a.Username ;
}
else
{
this.denglu.Visible = true;
this.tuichu.Visible = false;
}
}
//登录
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
string username = txtUserName.Text.Trim();
string password = txtPassWord.Text.Trim();
string apikey = "7c48cc03caede883471b42e5e9b533d8";//有Discuz后台管理扩展->通行证设置获得
string secret = "2ad48b05ac6cf0025011600d4e658db5";//同上
string url = "http://bbs.xxxx.com/";//你的bbs路径
string cookieDomain = "http://xxxx.com/";//你的域名
DiscuzSession ds = new DiscuzSession(apikey, secret, url);
int id = ds.GetUserID(username);//根据用户名获取用户ID
//用户名存在
if (id > 0)
{
//取得用户数据库中的密码
string dbpassword=ds.GetUserInfo(id).Password;
//判断数据库中的密码和输入的密码是否一致
if (dbpassword == FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5").ToLower())
{
//输入密码正确,则登录
ds.Login(id, password, true, 10000, cookieDomain);
Discuz.Config.GeneralConfigInfo config = Discuz.Config.GeneralConfigs.GetConfig();
//删除之前的错误登录信息
LoginLogs.DeleteLoginLog(DNTRequest.GetIP());
//根据积分公式刷新用户总积分
UserCredits.UpdateUserCredits(id);
//写入用户登录后的cookie
ForumUtils.WriteUserCookie(id, 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(id, DNTRequest.GetIP());
this.denglu.Visible = false;
this.tuichu.Visible = true;
Label1.Text = ds.GetUserInfo(id).UserName;
}
else
{
//密码输入错误
Label1.Text = "密码输入错误";
}
}
else
{
Label1.Text = "用户名不存在";
}
}
//退出
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
//string username = txtUserName.Text.Trim();
//string password = txtPassWord.Text.Trim();
if (Request.Cookies["dnt"] != null && Request.Cookies["dnt"].Values["userid"] != null)
{
int uid = Convert.ToInt32(Request.Cookies["dnt"].Values["userid"].ToString());
UserInfo a = Discuz.Forum.Users.GetUserInfo(uid);
string apikey = "7c48cc03caede883471b42e5e9b533d8";//有Discuz后台管理扩展->通行证设置获得
string secret = "2ad48b05ac6cf0025011600d4e658db5";//同上
string url = "http://bbs.xxxx.com/";//你的bbs路径
string cookieDomain = "http://xxxx.com/";//你的域名
DiscuzSession ds = new DiscuzSession(apikey, secret, url);
ds.Logout(cookieDomain);
int id = ds.GetUserID(a.Username);
int olid = OnlineUsers.GetOlidByUid(id);
OnlineUsers.DeleteRows(olid);
ForumUtils.ClearUserCookie();
this.denglu.Visible = true;
this.tuichu.Visible = false;
}
}
本文标签:
很赞哦! ()
相关教程
图文教程
为discuzx2.5添加mp4播放附件的方法
最近要做手机客户端,需要和论坛数据同步,因为iphone和andriod 能都支持的格式是mp3,mp4。所以论坛版块的音视频附件就限制为mp3,mp4格式。论坛本身支持mp3,可mp4不支持
Discuz!7.2 common.inc.php文件分析
//set_magic_quotes_runtime:所有的溢出字符,当遇到反斜杆、单引号,将会自动加上一个反斜杆,保护系统和数据库
Linux环境怎么搭建Discuz论坛
在Nginx服务器下面配置bbs的Vhostsvim /usr/local/nginx/conf/nginx.conf -->添加includechown -R nginx.nginx bbs/ -->涉及用户提交头像等操作,简单起见,先改为nginx,后进行修改
解决Discuz百度小程序搜索排名不佳的问题
面对Discuz百度小程序搜索排名不佳的问题,我们需要从多个角度来进行深入分析和优化。搜索排名不佳可能涉及到小程序的SEO、用户体验、内容质量以及百度算法的变化等多个方面。
相关源码
-
(PC+WAP)蓝色低碳环保隔断板装修装饰类网站pbootcms源码下载本款基于PbootCMS开发的网站模板为活动隔断板、装修装饰行业打造,特别适合移动隔断、环保隔断、办公分区等产品的展示与推广。查看源码 -
帝国cms题库问答学习平台模板知识付费网站源码+数据采集为教育机构、培训平台及在线学习场景设计,提供完整的题库管理与问答服务解决方案。支持多种题型展示与答案查询,满足不同层次的学习需求。查看源码 -
(自适应)pbootcms模板五金元件气缸气动系统源码下载基于PbootCMS核心开发的气缸气动系统网站模板,为五金元件、气动设备制造企业设计。采用响应式布局技术,自动适配手机、平板等移动设备,确保各类终端用户获得良好浏览体验。查看源码 -
(自适应响应式)蓝色勘察设计院机构单位商会协会pbootcms模板下载本模板基于PbootCMS系统开发,为勘察设计院所、工程咨询单位设计,特别适合展示设计成果、技术服务和项目案例。采用响应式技术,确保设计图纸和方案以及文案在不同设备上都能清晰展示。查看源码 -
(PC+WAP)绿色草坪地坪操场pbootcms网站模板该模板基于PbootCMS内核开发,专为人造草坪、地坪施工企业设计,采用绿色主题呼应行业属性,实现PC与WAP端全栈响应式适配,确保跨设备无缝浏览体验。查看源码 -
帝国cms自适应古诗词古籍名句网站整站带数据基于帝国CMS打造的专业古诗词文化网站模板,专注于古典文学内容的展示与传播。模板设计蕴含传统文化韵味,支持诗词鉴赏、名句赏析、古籍整理等特色功能,为诗词爱好者提供优质的在线阅读体验。查看源码
| 分享笔记 (共有 篇笔记) |
