discuz !NT 3.5 论坛整合 .net 网站用户登录,退出
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; }
}
discuz !NT 3.5 论坛整合 .net 网站用户登录,退出的更多相关文章
- 写了一个Windows服务,通过C#模拟网站用户登录并爬取BUG列表查询有没有新的BUG,并提醒我
写了一个Windows服务,通过C#模拟网站用户登录并爬取BUG列表查询有没有新的BUG,并提醒我 1.HttpUtil工具类,用于模拟用户登录以及爬取网页: using System; using ...
- Struts2整合Hibernate3实现用户登录功能
所用技术:struts2 ,hibernate,jsp,mysql 本DEMO仅仅实现用户登录功能,采用MVC思想,自己也觉得相对是比较简单,比较容易理解数据流向的一个例子,通过整合这个过程,能够清晰 ...
- C#模拟网站用户登录
我们在写灌水机器人.抓资源机器人和Web网游辅助工具的时候第一步要实现的就是用户登录.那么怎么用C#来模拟一个用户的登录拉?要实现用户的登录,那么首先就必须要了解一般网站中是怎么判断用户是否登录的. ...
- 使用C#实现网站用户登录
我们在写灌水机器人.抓资源机器人和Web网游辅助工具的时候第一步要实现的就是用户登录.那么怎么用C#来模拟一个用户的登录拉?要实现用户的登录,那么首先就必须要了解一般网站中是怎么判断用户是否登录的.H ...
- Ucenter整合Thinkphp 双向同步登录退出
1.整合初步工作: 1,安装Ucenter,完成后添加应用,填写要对接的网站地址 2,api , uc_client目录放置对接项目的根目录 3,通信对接,新建Ucenter组,confi文件填写在u ...
- springboot整合微软的ad域,采用ldap的api来整合,实现用户登录验证、
流程: 1.用户调登录接口,传用户名和密码2.用户名和密码在ad验证,验证通过后,返回当前用户的相关信息.(注:ldap为java自带的api不需要maven引入其他的)3.根据返回的用户信息,实现自 ...
- SpringBoot整合redis把用户登录信息存入redis
首先引入redis的jai包 <dependency> <groupId>org.springframework.boot</groupId> <artifa ...
- Discuz!NT 3.5.2正式版与Asp.net网站会员信息整合
Discuz!NT 提供了很多对外的接口利于与别的网站进行整合,经本人亲测,觉得开放的接口还是挺到位的.开发.测试一次通过,只不过api文档寻找无门,只能自己琢磨,费了不少周折,不过,功夫不负有心人, ...
- discuz论坛与其它网站登录注册整合
discuz论坛与其它网站登录注册整合 本文以discuz 7.0.0 php版本的论坛与 .net 2.0的网站注册登录整合为类.没有采用uc_center或第三方插件.以另类的方式实现.此方法实现 ...
随机推荐
- python 查询数据
查找课程不及格学生最多的前5名老师的id 表:student 字段名 类型 是否为空 主键 描述 StdID int 否 是 学生ID StdName varchar(100) 否 学生姓名 Gend ...
- Centos6.5配置阿里云yum源
很多时候,centos6.5 yum源可能无法访问,报404等等问题,一般情况下我们可以将yum源配置成阿里云的源,当然也可以配置成163的,简单说一下配置成阿里云的: 阿里云镜像源地址:http:/ ...
- Codeforces538F A Heap of Heaps(函数式线段树)
题意:给你一个数组a[n],对于数组每次建立一个完全k叉树,对于每个节点,如果父节点的值比这个节点的值大,那么就是一个违规点,统计出1~n-1完全叉树下的违规点的各自的个数. 一个直觉的思想就是暴力, ...
- os.path.isfile的错误
今天写了一个程序,读取子目录(source)下的所有文件,然后转换. 程序一部分代码如下: def DtoTab(dsrc, dtarget): try: for item in os.listdir ...
- pycharm配置pep8
可以使用外部工具,来检查代码是否符合pep8的风格: 1)下载 autopep8,这个简单,pip3 install pep8 2)在pychamr中配置: A)file-setting..-tool ...
- PHP使用AJax轮询实现新订单实时提醒
业务逻辑:Ajax每隔10秒钟请求一次接口,该接口会去查询数据库是否有新的订单,如果有则返回新订单的数量,后台收到声音提示,更改后台提醒数量 提醒框可链接到订单列表,后台更改完订单状态后会提醒会消失 ...
- 计蒜客 18487.Divisions-大数的所有因子个数-Miller_Rabin+Pollard_rho-超快的(大数质因解+因子个数求解公式) (German Collegiate Programming Contest 2015 ACM-ICPC Asia Training League 暑假第一阶段第三场 F)
这一场两个和大数有关的题目,都用到了米勒拉宾算法,有点东西,备忘一下. 题目传送门 F. Divisions 传送门 这个题是求一个数的所有因子个数,但是数据比较大,1e18,所以是大数的题目,正常的 ...
- codeforces-723D
题目连接:http://codeforces.com/contest/723/problem/D D. Lakes in Berland time limit per test 2 seconds m ...
- 第十四届华中科技大学程序设计竞赛 B Beautiful Trees Cutting【组合数学/费马小定理求逆元/快速幂】
链接:https://www.nowcoder.com/acm/contest/106/B 来源:牛客网 题目描述 It's universally acknowledged that there'r ...
- 浅析Oracle PL/SQL 学习--未完待续
这是一篇关于Oracle Pl/SQL数据库编程的课程学习分享... 首先说明几点: 学习这门课程之前,已经学过并且掌握一些基础的SQL语句.数据库结构分析.ER图设计等知识: 这里也只是较为大概地将 ...