public int QuickCreateUser(string username, string password, string email) { DiscuzUserInfo userinfo = new DiscuzUserInfo(); userinfo.Username = username; userinfo.Nickname = string.Empty;// Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("nickname"))); userinfo.Password = Utils.MD5(password); userinfo.Secques = string.Empty;// ForumUtils.GetUserSecques(DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer")); userinfo.Gender = 0;// DNTRequest.GetInt("gender", 0); userinfo.Adminid = 0; userinfo.Groupexpiry = 0; userinfo.Extgroupids = ""; userinfo.Regip = GetIP();// DNTRequest.GetIP(); userinfo.Joindate = DateTime.Now;//Utils.GetDateTime(); userinfo.Lastip = userinfo.Regip;// DNTRequest.GetIP(); userinfo.Lastvisit = DateTime.Now;// Utils.GetDateTime(); userinfo.Lastactivity = DateTime.Now;// Utils.GetDateTime(); userinfo.Lastpost = DateTime.Now;// Utils.GetDateTime(); userinfo.Lastpostid = 0; userinfo.Lastposttitle = ""; userinfo.Posts = 0; userinfo.Digestposts = 0; userinfo.Oltime = 0; userinfo.Pageviews = 0; userinfo.Credits = 0; userinfo.Extcredits1 = 0;// Scoresets.GetScoreSet(1).Init; userinfo.Extcredits2 = 0;//Scoresets.GetScoreSet(2).Init; userinfo.Extcredits3 = 0;//Scoresets.GetScoreSet(3).Init; userinfo.Extcredits4 = 0;//Scoresets.GetScoreSet(4).Init; userinfo.Extcredits5 = 0;//Scoresets.GetScoreSet(5).Init; userinfo.Extcredits6 = 0;//Scoresets.GetScoreSet(6).Init; userinfo.Extcredits7 = 0;//Scoresets.GetScoreSet(7).Init; userinfo.Extcredits8 = 0;//Scoresets.GetScoreSet(8).Init; userinfo.Avatarshowid = 0; userinfo.Email = email; userinfo.Bday = string.Empty;// tmpBday; userinfo.Sigstatus =1;// DNTRequest.GetInt("sigstatus", 0); //if (userinfo.Sigstatus != 0) //{ // userinfo.Sigstatus = 1; //} userinfo.Tpp = 0;// DNTRequest.GetInt("tpp", 0); userinfo.Ppp = 0;// DNTRequest.GetInt("ppp", 0); userinfo.Templateid = 0;// DNTRequest.GetInt("templateid", 0); userinfo.Pmsound = 1;// DNTRequest.GetInt("pmsound", 0); userinfo.Showemail = 1;// DNTRequest.GetInt("showemail", 0); //int receivepmsetting = 1; //foreach (string rpms in DNTRequest.GetString("receivesetting").Split(',')) //{ // if (rpms != string.Empty) // { // int tmp = int.Parse(rpms); // receivepmsetting = receivepmsetting | tmp; // } //} //if (config.Regadvance == 0) //{ // receivepmsetting = 7; //} userinfo.Newsletter = 7;// (ReceivePMSettingType)receivepmsetting; userinfo.Invisible = 0;// DNTRequest.GetInt("invisible", 0); userinfo.Newpm = 1; userinfo.Medals = ""; //if (config.Welcomemsg == 1) //{ // userinfo.Newpm = 1; //} userinfo.Accessmasks = 0;// DNTRequest.GetInt("accessmasks", 0); userinfo.Website = string.Empty;// Utils.HtmlEncode(DNTRequest.GetString("website")); userinfo.Icq = string.Empty;// Utils.HtmlEncode(DNTRequest.GetString("icq")); userinfo.Qq = string.Empty;//Utils.HtmlEncode(DNTRequest.GetString("qq")); userinfo.Yahoo = string.Empty;//Utils.HtmlEncode(DNTRequest.GetString("yahoo")); userinfo.Msn = string.Empty;//Utils.HtmlEncode(DNTRequest.GetString("msn")); userinfo.Skype = string.Empty;// Utils.HtmlEncode(DNTRequest.GetString("skype")); userinfo.Location = string.Empty;//Utils.HtmlEncode(DNTRequest.GetString("location")); //if (usergroupinfo.Allowcstatus == 1) //{ // userinfo.Customstatus = Utils.HtmlEncode(DNTRequest.GetString("customstatus")); //} //else //{ // userinfo.Customstatus = ""; //} userinfo.Customstatus = ""; userinfo.Avatar = @"avatars\common\0.gif"; userinfo.Avatarwidth = 0; userinfo.Avatarheight = 0; userinfo.Bio = string.Empty;//ForumUtils.BanWordFilter(DNTRequest.GetString("bio")); userinfo.Signature = string.Empty;//Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("signature"))); //PostpramsInfo postpramsinfo = new PostpramsInfo(); //postpramsinfo.Usergroupid = usergroupid; //postpramsinfo.Attachimgpost = config.Attachimgpost; //postpramsinfo.Showattachmentpath = config.Showattachmentpath; //postpramsinfo.Hide = 0; //postpramsinfo.Price = 0; //postpramsinfo.Sdetail = userinfo.Signature; //postpramsinfo.Smileyoff = 1; //postpramsinfo.Bbcodeoff = 1 - usergroupinfo.Allowsigbbcode; //postpramsinfo.Parseurloff = 1; //postpramsinfo.Showimages = usergroupinfo.Allowsigimgcode; //postpramsinfo.Allowhtml = 0; //postpramsinfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); //postpramsinfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(); //postpramsinfo.Smiliesmax = config.Smiliesmax; userinfo.Sightml = string.Empty;// UBB.UBBToHTML(postpramsinfo); // userinfo.Authtime = DateTime.Now;// Utils.GetDateTime(); ////邮箱激活链接验证 //if (config.Regverify == 1) //{ // userinfo.Authstr = ForumUtils.CreateAuthStr(20); // userinfo.Authflag = 1; // userinfo.Groupid = 8; // SendEmail(tmpUsername, DNTRequest.GetString("password").Trim(), DNTRequest.GetString("email").Trim(), userinfo.Authstr); //} ////系统管理员进行后台验证 //else if (config.Regverify == 2) //{ // userinfo.Authstr = DNTRequest.GetString("website"); // userinfo.Groupid = 8; // userinfo.Authflag = 1; //} //else //{ // userinfo.Authstr = ""; // userinfo.Authflag = 0; // userinfo.Groupid = UserCredits.GetCreditsUserGroupID(0).Groupid; //} userinfo.Authstr = ""; userinfo.Authflag = 0; userinfo.Groupid = 10;//default group is 10?//UserCredits.GetCreditsUserGroupID(0).Groupid; userinfo.Realname = "";// DNTRequest.GetString("realname"); userinfo.Idcard = "";// DNTRequest.GetString("idcard"); userinfo.Mobile = "";// DNTRequest.GetString("mobile"); userinfo.Phone = "";// DNTRequest.GetString("phone"); return CreateUser(userinfo); }
/// <summary> /// 创建新用户. /// </summary> /// <param name="__userinfo">用户信息</param> /// <returns>返回用户ID, 如果已存在该用户名或者错误则返回-1</returns> public int CreateUser(DiscuzUserInfo userinfo) { if (userinfo == null) return -1; if (string.IsNullOrEmpty(userinfo.Username)) return -1; if (ExistsUserName(userinfo.Username)) return -1; return DiscuzAccountDao.CreateUser(userinfo); }
internal static DiscuzUserInfo GetUserInfo(int uid) { DiscuzUserInfo m = new DiscuzUserInfo(); if (uid > 0) { m.Uid = uid; SafeProcedure.ExecuteAndMapRecords( Database.GetDatabase(D4DDefine.JaneBBSDBInstanceName), "newbbs.dnt_getuserinfo", delegate(IRecord record) { MapUserInfo(record, m); }, uid); } return m; }
internal static void MapUserInfo(IRecord record, DiscuzUserInfo userinfo) { int offset = 0; userinfo.Uid = record.GetInt32(offset++);// Int32.Parse(reader["uid"].ToString()); userinfo.Username = record.GetStringOrEmpty(offset++);// reader["username"].ToString(); userinfo.Nickname = record.GetStringOrEmpty(offset++);//reader["nickname"].ToString(); userinfo.Password = record.GetStringOrEmpty(offset++);//reader["password"].ToString(); userinfo.Secques = record.GetStringOrEmpty(offset++);//reader["secques"].ToString(); userinfo.Gender = record.GetInt32OrDefault(offset++, 0);// Int32.Parse(reader["gender"].ToString()); userinfo.Adminid = record.GetInt32OrDefault(offset++, 0);// Int32.Parse(reader["adminid"].ToString()); userinfo.Groupid = record.GetInt16OrDefault(offset++, 0);// Int16.Parse(reader["groupid"].ToString()); userinfo.Groupexpiry = record.GetInt32OrDefault(offset++, 0);// Int32.Parse(reader["groupexpiry"].ToString()); userinfo.Extgroupids = record.GetStringOrEmpty(offset++);// reader["extgroupids"].ToString(); userinfo.Regip = record.GetStringOrEmpty(offset++);// reader["regip"].ToString(); userinfo.Joindate = record.GetDateTimeOrEmpty(offset++);// reader["joindate"].ToString(); userinfo.Lastip = record.GetStringOrEmpty(offset++);// reader["lastip"].ToString(); userinfo.Lastvisit = record.GetDateTimeOrEmpty(offset++);//reader["lastvisit"].ToString(); userinfo.Lastactivity = record.GetDateTimeOrEmpty(offset++);//reader["lastactivity"].ToString(); userinfo.Lastpost = record.GetDateTimeOrEmpty(offset++);//reader["lastpost"].ToString(); userinfo.Lastpostid = record.GetInt32OrDefault(offset++, 0);// Int32.Parse(reader["lastpostid"].ToString()); userinfo.Lastposttitle = record.GetStringOrEmpty(offset++);// reader["lastposttitle"].ToString(); userinfo.Posts = record.GetInt32OrDefault(offset++, 0);// Int32.Parse(reader["posts"].ToString()); userinfo.Digestposts = record.GetInt16OrDefault(offset++, 0);//Int16.Parse(reader["digestposts"].ToString()); userinfo.Oltime = record.GetInt32OrDefault(offset++, 0);// Int32.Parse(reader["oltime"].ToString()); userinfo.Pageviews = record.GetInt32OrDefault(offset++, 0);// Int32.Parse(reader["pageviews"].ToString()); userinfo.Credits = record.GetDecimal(offset++); //Int32.Parse(reader["credits"].ToString()); userinfo.Extcredits1 = record.GetDecimal(offset++);// float.Parse(reader["extcredits1"].ToString()); userinfo.Extcredits2 = record.GetDecimal(offset++);//float.Parse(reader["extcredits2"].ToString()); userinfo.Extcredits3 = record.GetDecimal(offset++);//float.Parse(reader["extcredits3"].ToString()); userinfo.Extcredits4 = record.GetDecimal(offset++);//float.Parse(reader["extcredits4"].ToString()); userinfo.Extcredits5 = record.GetDecimal(offset++);//float.Parse(reader["extcredits5"].ToString()); userinfo.Extcredits6 = record.GetDecimal(offset++);//float.Parse(reader["extcredits6"].ToString()); userinfo.Extcredits7 = record.GetDecimal(offset++);//float.Parse(reader["extcredits7"].ToString()); userinfo.Extcredits8 = record.GetDecimal(offset++);// float.Parse(reader["extcredits8"].ToString()); userinfo.Avatarshowid = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["avatarshowid"].ToString()); userinfo.Email = record.GetStringOrEmpty(offset++);// reader["email"].ToString(); userinfo.Bday = record.GetStringOrEmpty(offset++);// reader["bday"].ToString(); userinfo.Sigstatus = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["sigstatus"].ToString()); userinfo.Tpp = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["tpp"].ToString()); userinfo.Ppp = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["ppp"].ToString()); userinfo.Templateid = record.GetInt16OrDefault(offset++, 0); // Int16.Parse(reader["templateid"].ToString()); userinfo.Pmsound = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["pmsound"].ToString()); userinfo.Showemail = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["showemail"].ToString()); userinfo.Invisible = record.GetInt32OrDefault(offset++, 0); // Int32.Parse(reader["invisible"].ToString()); userinfo.Newpm = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["newpm"].ToString()); userinfo.Newpmcount = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["newpmcount"].ToString()); userinfo.Accessmasks = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["accessmasks"].ToString()); userinfo.Onlinestate = record.GetInt32OrDefault(offset++, 0); //Int32.Parse(reader["onlinestate"].ToString()); userinfo.Spaceid = record.GetInt32OrDefault(offset++, 0);// Int32.Parse(reader["spaceid"].ToString()); userinfo.Newsletter = record.GetInt32OrDefault(offset++, 0); //(ReceivePMSettingType)Int32.Parse(reader["newsletter"].ToString()); offset++;//fields.userid userinfo.Website = record.GetStringOrEmpty(offset++); userinfo.Icq = record.GetStringOrEmpty(offset++); userinfo.Qq = record.GetStringOrEmpty(offset++); userinfo.Yahoo = record.GetStringOrEmpty(offset++); userinfo.Msn = record.GetStringOrEmpty(offset++); userinfo.Skype = record.GetStringOrEmpty(offset++); userinfo.Location = record.GetStringOrEmpty(offset++); userinfo.Customstatus = record.GetStringOrEmpty(offset++); userinfo.Avatar = record.GetStringOrEmpty(offset++); userinfo.Avatarwidth = record.GetInt32OrDefault(offset++, 0); userinfo.Avatarheight = record.GetInt32OrDefault(offset++, 0); userinfo.Medals = record.GetStringOrEmpty(offset++); userinfo.Authstr = record.GetStringOrEmpty(offset++); userinfo.Authtime = record.GetDateTimeOrEmpty(offset++); userinfo.Authflag = record.GetByteOrDefault(offset++,0); userinfo.Bio = record.GetStringOrEmpty(offset++); userinfo.Signature = record.GetStringOrEmpty(offset++); userinfo.Sightml = record.GetStringOrEmpty(offset++); userinfo.Realname = record.GetStringOrEmpty(offset++); userinfo.Idcard = record.GetStringOrEmpty(offset++); userinfo.Mobile = record.GetStringOrEmpty(offset++); userinfo.Phone = record.GetStringOrEmpty(offset++); }
internal static int CreateUser(DiscuzUserInfo userinfo) { int uid = -1; object resultId = SafeProcedure.ExecuteScalar(Database.GetDatabase(D4DDefine.JaneBBSDBInstanceName), "newbbs.dnt_createuser", delegate(IParameterSet parameters) { parameters.AddWithValue("@username", userinfo.Username); parameters.AddWithValue("@nickname", userinfo.Nickname); parameters.AddWithValue("@password", userinfo.Password); parameters.AddWithValue("@secques", userinfo.Secques); parameters.AddWithValue("@gender", userinfo.Gender); parameters.AddWithValue("@adminid", userinfo.Adminid); parameters.AddWithValue("@groupid", userinfo.Groupid); parameters.AddWithValue("@groupexpiry", userinfo.Groupexpiry); parameters.AddWithValue("@extgroupids", userinfo.Extgroupids); parameters.AddWithValue("@regip", userinfo.Regip); parameters.AddWithValue("@joindate", userinfo.Joindate.ToString("yyyy-MM-dd HH:mm:ss")); parameters.AddWithValue("@lastip", userinfo.Lastip); parameters.AddWithValue("@lastvisit", userinfo.Lastvisit.ToString("yyyy-MM-dd HH:mm:ss")); parameters.AddWithValue("@lastactivity", userinfo.Lastactivity.ToString("yyyy-MM-dd HH:mm:ss")); parameters.AddWithValue("@lastpost", userinfo.Lastpost.ToString("yyyy-MM-dd HH:mm:ss")); parameters.AddWithValue("@lastpostid", userinfo.Lastpostid); parameters.AddWithValue("@lastposttitle", userinfo.Lastposttitle); parameters.AddWithValue("@posts", userinfo.Posts); parameters.AddWithValue("@digestposts", userinfo.Digestposts); parameters.AddWithValue("@oltime", userinfo.Oltime); parameters.AddWithValue("@pageviews", userinfo.Pageviews); parameters.AddWithValue("@credits", userinfo.Credits); parameters.AddWithValue("@extcredits1", userinfo.Extcredits1); parameters.AddWithValue("@extcredits2", userinfo.Extcredits2); parameters.AddWithValue("@extcredits3", userinfo.Extcredits3); parameters.AddWithValue("@extcredits4", userinfo.Extcredits4); parameters.AddWithValue("@extcredits5", userinfo.Extcredits5); parameters.AddWithValue("@extcredits6", userinfo.Extcredits6); parameters.AddWithValue("@extcredits7", userinfo.Extcredits7); parameters.AddWithValue("@extcredits8", userinfo.Extcredits8); parameters.AddWithValue("@avatarshowid", userinfo.Avatarshowid); parameters.AddWithValue("@email", userinfo.Email); parameters.AddWithValue("@bday", userinfo.Bday); parameters.AddWithValue("@tpp", userinfo.Tpp); parameters.AddWithValue("@ppp", userinfo.Ppp); parameters.AddWithValue("@templateid", userinfo.Templateid); parameters.AddWithValue("@pmsound", userinfo.Pmsound); parameters.AddWithValue("@showemail", userinfo.Showemail); parameters.AddWithValue("@newsletter", userinfo.Newsletter); parameters.AddWithValue("@invisible", userinfo.Invisible); parameters.AddWithValue("@newpm", userinfo.Newpm); parameters.AddWithValue("@accessmasks", userinfo.Accessmasks); parameters.AddWithValue("@website", userinfo.Website); parameters.AddWithValue("@icq", userinfo.Icq); parameters.AddWithValue("@qq", userinfo.Qq); parameters.AddWithValue("@yahoo", userinfo.Yahoo); parameters.AddWithValue("@msn", userinfo.Msn); parameters.AddWithValue("@skype", userinfo.Skype); parameters.AddWithValue("@location", userinfo.Location); parameters.AddWithValue("@customstatus", userinfo.Customstatus); parameters.AddWithValue("@avatar", userinfo.Avatar); parameters.AddWithValue("@avatarwidth", userinfo.Avatarwidth); parameters.AddWithValue("@avatarheight", userinfo.Avatarheight); parameters.AddWithValue("@medals", userinfo.Medals); parameters.AddWithValue("@bio", userinfo.Bio); parameters.AddWithValue("@signature", userinfo.Signature); parameters.AddWithValue("@sightml", userinfo.Sightml); parameters.AddWithValue("@authstr", userinfo.Authstr); parameters.AddWithValue("@realname", userinfo.Realname); parameters.AddWithValue("@idcard", userinfo.Idcard); parameters.AddWithValue("@mobile", userinfo.Mobile); parameters.AddWithValue("@phone", userinfo.Phone); }); if (resultId!=null) uid = (int)resultId; return uid; }