greystar - 2007-9-2 15:51:00
using Discuz.Common;
using Discuz.Forum;
using Discuz.Config;
static bool CreateBBSUser(string username,string nickname,string pwd,string mail)
{
// 用户名这里为tmpUsername
// 判断用户名是否已被注册
if (Discuz.Forum.Users.Exists(username))
{
// 这里提示该用户名已经被使用
return false;
}
else if (!Utils.IsSafeSqlString(username))
{
// 提示用户名中存在非法字符
return false;
}
//else if (username.Trim() == PrivateMessageFactory.SystemUserName || ForumUtils.IsBanUsername(username, config.Censoruser))
//{
// //提示用户名属于禁止名单, 或者与负责发送新用户注册欢迎信件的用户名称相同...
// return false;
//}
else if (ForumUtils.InBanWordArray(username))
{
//提示用户名含有论坛禁止的词语, 请更换
return false;
}
if (Users.FindUserEmail(mail) != -1)
{
//提示email已经被其它用户注册使用
return false;
}
// 你也可以增加更多你自己的检测规则, 尽量保证用户信息的合法和安全......
Discuz.Forum.Entity.UserInfo info3 = new Discuz.Forum.Entity.UserInfo();
info3.Username = Utils.HtmlEncode(username);
info3.Nickname = Utils.HtmlEncode(nickname);
info3.Password = Utils.MD5(pwd);
info3.Secques = ForumUtils.GetUserSecques(0,"");
info3.Gender = 0;
info3.Adminid = 0;
info3.Groupexpiry = 0;
info3.Extgroupids = "";
info3.Regip = DNTRequest.GetIP();
info3.Joindate = Utils.GetDateTime();
info3.Lastip = DNTRequest.GetIP();
info3.Lastvisit = Utils.GetDateTime();
info3.Lastactivity = Utils.GetDateTime();
info3.Lastpost = Utils.GetDateTime();
info3.Lastpostid = 0;
info3.Lastposttitle = "";
info3.Posts = 0;
info3.Digestposts = 0;
info3.Oltime = 0;
info3.Pageviews = 0;
info3.Credits = 0;
info3.Extcredits1 = Scoresets.GetScoreSet(1).Init;
info3.Extcredits2 = Scoresets.GetScoreSet(2).Init;
info3.Extcredits3 = Scoresets.GetScoreSet(3).Init;
info3.Extcredits4 = Scoresets.GetScoreSet(4).Init;
info3.Extcredits5 = Scoresets.GetScoreSet(5).Init;
info3.Extcredits6 = Scoresets.GetScoreSet(6).Init;
info3.Extcredits7 = Scoresets.GetScoreSet(7).Init;
info3.Extcredits8 = Scoresets.GetScoreSet(8).Init;
info3.Avatarshowid = 0;
info3.Email = mail;
info3.Bday = "";
info3.Sigstatus = 0;
info3.Tpp = 0;
info3.Ppp =0;
info3.Templateid =1;
info3.Pmsound = 0;
info3.Showemail = 0;
info3.Invisible =0;
info3.Newpm = 0;
info3.Medals = "";
info3.Accessmasks = 0;
info3.Website ="";
info3.Icq ="";
info3.Qq = "";
info3.Yahoo ="";
info3.Msn = "";
info3.Skype = "";
info3.Location ="";
info3.Customstatus = "";
info3.Avatar = @"avatars\common\0.gif";
info3.Avatarwidth = 0;
info3.Avatarheight = 0;
info3.Bio = "";
info3.Signature = "";
info3.Sightml = "";
info3.Authtime = Utils.GetDateTime();
info3.Authstr = "";
info3.Authflag = 0;
info3.Groupid = UserCredits.GetCreditsUserGroupID(0f).Groupid;
info3.Realname = "";
info3.Idcard = "";
info3.Mobile ="";
info3.Phone ="";
int uid = Users.CreateUser(info3);
return true;
}
public static bool LoginBBS(string username, string pwd)
{
int uid = Discuz.Forum.Users.CheckPassword(username, pwd, true);
if (uid == -1)
return false;
LoginLogs.DeleteLoginLog(DNTRequest.GetIP());
UserCredits.UpdateUserCredits(uid);
string pk = GeneralConfigs.GetConfig().Passwordkey;
ForumUtils.WriteUserCookie(uid, -1, pk, 0, -1);
int olid = OnlineUsers.UpdateInfo(pk, 10).Olid;
OnlineUsers.UpdateAction(olid, UserAction.Login.ActionID, 0, 10);
Users.UpdateUserLastvisit(uid, DNTRequest.GetIP());
return true;
}
上面代码通过测试,已成功实现单点登录
greystar - 2007-9-2 15:52:00
下面要实现的功能是取TOP N topic
greystar - 2007-9-2 16:00:00
public static DataTable GetHotTopicList()
{
//获取热帖,前十个,查看次数大于30;
DataTable dt= Focuses.GetHotTopicList(10, 30);
return dt;
}
greystar - 2007-9-4 8:31:00
本人的系统已成功实现整合.整合花的时间大约为30分种搞定.没有文档的情况下,最好的方式就是反编译.
greystar - 2007-9-4 8:31:00
大家顶一下啊.
greystar - 2007-9-4 8:43:00
现在最大的问题就是所有站点的config不能共享.官方应该想到这个功能.我不可能在所有的站点内都放上相同的文件,这样维护起来可不方便,希望官方能提供这样的功能.
lshlfyf - 2007-9-4 8:54:00
高
如果要调用空间和相册的最近发布信息怎么做。
zacard - 2007-9-6 11:12:00
命名空间Discuz.Forum中不存在类型或命名空间名称user
步行天下 - 2007-9-6 14:41:00
命名空间Discuz.Forum中不存在类型或命名空间名称user
可以使用
Discuz.Forum.Users.UpdateUserLastvisit(uid, DNTRequest.GetIP());
zacard - 2007-9-6 15:06:00
我可以实现注册了,登陆那里,明明在论坛的在线列表里显示登陆了,但在论坛的最顶那个还是显示没登陆,也就是发表不了贴子..什么问题啊
zacard - 2007-9-6 15:08:00
我可以实现注册了,登陆还有问题,明明在论坛的在线列表里显示登陆了,但在论坛的最顶那个还是显示没登陆,也就是发表不了贴子..什么问题啊
michaelau888 - 2007-9-7 23:08:00
该用户帖子内容已被屏蔽
luyinhu - 2007-9-18 15:26:00
求助:
登陆
错误:请检查DNT.config中Dbtype节点数据库类型是否正确,例如:SqlServer、Access、MySql
论坛放在:
http://www.1.com/bbs登陆地址:
http://www.1.com/login.aspxhttp://www.1.com下放有DNT.config<?xml version="1.0"?>
<BaseConfigInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Dbconnectstring>Data Source=210.72.225.78,2433;User ID=zuowen;Password=luyinhu;Initial Catalog=zuowen;Pooling=true</Dbconnectstring>
<Tableprefix>bbs_</Tableprefix>
<Forumpath>/bbs/</Forumpath>
<Dbtype>SqlServer</Dbtype>
<Founderuid>1</Founderuid>
</BaseConfigInfo>
luyinhu - 2007-9-18 15:27:00
请高手帮看看是那错了.