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 网站用户登录,退出的更多相关文章

  1. 写了一个Windows服务,通过C#模拟网站用户登录并爬取BUG列表查询有没有新的BUG,并提醒我

    写了一个Windows服务,通过C#模拟网站用户登录并爬取BUG列表查询有没有新的BUG,并提醒我 1.HttpUtil工具类,用于模拟用户登录以及爬取网页: using System; using ...

  2. Struts2整合Hibernate3实现用户登录功能

    所用技术:struts2 ,hibernate,jsp,mysql 本DEMO仅仅实现用户登录功能,采用MVC思想,自己也觉得相对是比较简单,比较容易理解数据流向的一个例子,通过整合这个过程,能够清晰 ...

  3. C#模拟网站用户登录

    我们在写灌水机器人.抓资源机器人和Web网游辅助工具的时候第一步要实现的就是用户登录.那么怎么用C#来模拟一个用户的登录拉?要实现用户的登录,那么首先就必须要了解一般网站中是怎么判断用户是否登录的. ...

  4. 使用C#实现网站用户登录

    我们在写灌水机器人.抓资源机器人和Web网游辅助工具的时候第一步要实现的就是用户登录.那么怎么用C#来模拟一个用户的登录拉?要实现用户的登录,那么首先就必须要了解一般网站中是怎么判断用户是否登录的.H ...

  5. Ucenter整合Thinkphp 双向同步登录退出

    1.整合初步工作: 1,安装Ucenter,完成后添加应用,填写要对接的网站地址 2,api , uc_client目录放置对接项目的根目录 3,通信对接,新建Ucenter组,confi文件填写在u ...

  6. springboot整合微软的ad域,采用ldap的api来整合,实现用户登录验证、

    流程: 1.用户调登录接口,传用户名和密码2.用户名和密码在ad验证,验证通过后,返回当前用户的相关信息.(注:ldap为java自带的api不需要maven引入其他的)3.根据返回的用户信息,实现自 ...

  7. SpringBoot整合redis把用户登录信息存入redis

    首先引入redis的jai包 <dependency> <groupId>org.springframework.boot</groupId> <artifa ...

  8. Discuz!NT 3.5.2正式版与Asp.net网站会员信息整合

    Discuz!NT 提供了很多对外的接口利于与别的网站进行整合,经本人亲测,觉得开放的接口还是挺到位的.开发.测试一次通过,只不过api文档寻找无门,只能自己琢磨,费了不少周折,不过,功夫不负有心人, ...

  9. discuz论坛与其它网站登录注册整合

    discuz论坛与其它网站登录注册整合 本文以discuz 7.0.0 php版本的论坛与 .net 2.0的网站注册登录整合为类.没有采用uc_center或第三方插件.以另类的方式实现.此方法实现 ...

随机推荐

  1. Easy Install详细参数

    Easy Install Easy Install is a python module (easy_install) bundled with setuptools that lets you au ...

  2. selenium运行js下载文书网的文件

    from selenium import webdriver driver=webdriver.Chrome() driver.get("http://wenshu.court.gov.cn ...

  3. 【linux高级程序设计】(第十二章)Linux多线程编程

    线程与进程对比 1.用户空间对比 2.内核空间资源对比 在创建线程时,Linux内核仍然创建一个新的PCB来标识这个线程.内核并不认为进程与线程有差别. 进程是操作系统管理资源的基本单元,线程时Lin ...

  4. 打印PE目录数据信息

    printf("数据目录信息:\n"); PIMAGE_DATA_DIRECTORY MyDataDir; MyDataDir = PIMAGE_DATA_DIRECTORY((& ...

  5. java的unity单元测试

    import org.junit.After; import org.junit.Before; import org.junit.Test; public class TestUnit { publ ...

  6. [BZOJ1044][HAOI2008]木棍分割 二分+贪心+dp+前缀和优化

    1044: [HAOI2008]木棍分割 Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 4112  Solved: 1577 [Submit][St ...

  7. 洛谷 P1049 装箱问题【正难则反/01背包】

    题目描述 有一个箱子容量为V(正整数,0<=V<=20000),同时有n个物品(0<n<=30,每个物品有一个体积(正整数). 要求n个物品中,任取若干个装入箱内,使箱子的剩余 ...

  8. elasticsearch REST api

    elasticsearch REST api========================================命令模式:<REST Verb> /<Index>/ ...

  9. ES6 Promise的resolved深入理解

    Promise的概念在ES6标准推出来之前已经深入人心,很多框架和第三方库都有类似的实现.但在深入理解ES6的Promise对象的时候,受之前经验的影响,很多概念给人似是而非的感觉,其中有一个特别明显 ...

  10. [POI2014]Salad Bar

    题目大意: 一个长度为$n(n\leq10^6)$的字符串,每一位只会是$p$或$j$.你需要取出一个子串$S$(从左到右或从右到左一个一个取出),使得不管是从左往右还是从右往左取,都保证每时每刻已取 ...