public override bool Run(CommandParameter commandParam, ref string result) { //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { if (commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return(false); } } if (!commandParam.CheckRequiredParams("uid,page_size,page_index")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } int uid = commandParam.GetIntParam("uid"); int pageSize = commandParam.GetIntParam("page_size", 10); int pageIndex = commandParam.GetIntParam("page_index", 1); pageSize = pageSize < 1 ? 10 : pageSize; pageIndex = pageIndex < 1 ? 1 : pageIndex; List <PrivateMessageInfo> list = PrivateMessages.GetPrivateMessageCollection(uid, 0, pageSize, pageIndex, 1); List <Message> newList = new List <Message>(); foreach (PrivateMessageInfo pm in list) { Message m = new Message(); m.MessageId = pm.Pmid; m.From = pm.Msgfrom; m.FromId = pm.Msgfromid; m.MessageContent = pm.Message; m.PostDateTime = pm.Postdatetime; m.Subject = pm.Subject; newList.Add(m); } MessageGetResponse mgr = new MessageGetResponse(); mgr.Count = PrivateMessages.GetPrivateMessageCount(uid, 0, 1); mgr.List = true; mgr.Messages = newList.ToArray(); result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(mgr) : Util.AddMessageCDATA(SerializationHelper.Serialize(mgr)); return(true); }
/* * Description: * 该接口需要能关联到一个论坛用户,不允许游客操作,如果validate=true或者接口类型为桌面程序,则只获取session_info中的uid,若无则返回API_EC_SESSIONKEY */ public override bool Run(CommandParameter commandParam, ref string result) { //如果validate为true,则校验数据的合法性,包括广告强力屏蔽,是否含有需审核的,以及非法内容.和当前用户的发帖权限 bool validate = commandParam.GetIntParam("validate") == 1 || commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP; //如果validate是true或者桌面程序则需要验证用户身份 if (validate && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } if (!commandParam.CheckRequiredParams("topic_info,tid")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } Topic topic; try { topic = JavaScriptConvert.DeserializeObject<Topic>(commandParam.GetDNTParam("topic_info").ToString()); } catch { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } if (topic == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } //文档中应说明title长度范围和内容范围 if (!Util.AreParamsNullOrZeroOrEmptyString(topic.Title) && topic.Title.Length > 60) { result = Util.CreateErrorMessage(ErrorType.API_EC_TITLE_INVALID, commandParam.ParamList); return false; } //编辑主题必须要能关联到一个用户 ShortUserInfo userInfo = Users.GetShortUserInfo(validate || topic.UId == null ? commandParam.LocalUid : (int)topic.UId); if (userInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_EDIT_NOUSER, commandParam.ParamList); return false; } TopicInfo topicInfo = Discuz.Forum.Topics.GetTopicInfo(commandParam.GetIntParam("tid", 0)); if (topicInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_TOPIC_NOT_EXIST, commandParam.ParamList); return false; } ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(topic.Fid ?? topicInfo.Fid); if (forumInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_FORUM_NOT_EXIST, commandParam.ParamList); return false; } UserGroupInfo userGroupInfo = UserGroups.GetUserGroupInfo(userInfo.Groupid); AdminGroupInfo adminInfo = AdminGroups.GetAdminGroupInfo(userGroupInfo.Groupid); //是否受审核、过滤、灌水等限制权限 int disablePost = adminInfo != null ? adminInfo.Disablepostctrl : userGroupInfo.Disableperiodctrl; bool hasAudit = false; if (validate) { string title = topic.Title ?? ""; string message = topic.Message ?? ""; ErrorType et = TopicsCommandUtils.GeneralValidate(title, message, userInfo, userGroupInfo, forumInfo, commandParam, disablePost); if (et != ErrorType.API_EC_NONE) { result = Util.CreateErrorMessage(et, commandParam.ParamList); return false; } //如果主题作者与当前用户不一样且当前用户不是管理员 if (topicInfo.Posterid != commandParam.LocalUid && userInfo.Adminid != 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_EDIT_PERM, commandParam.ParamList); return false; } //如果当前用户是管理组成员,则跳过编辑时间限制校验 if (!Moderators.IsModer(userInfo.Adminid, commandParam.LocalUid, forumInfo.Fid)) { if (commandParam.GeneralConfig.Edittimelimit == -1) { result = Util.CreateErrorMessage(ErrorType.API_EC_EDIT_PERM, commandParam.ParamList); return false; } if (commandParam.GeneralConfig.Edittimelimit > 0 && Utils.StrDateDiffSeconds(topicInfo.Postdatetime, commandParam.GeneralConfig.Edittimelimit) > 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_EDIT_PERM, commandParam.ParamList); return false; } } if (!string.IsNullOrEmpty(title + message)) { if (ForumUtils.HasAuditWord(title) || ForumUtils.HasAuditWord(message)) hasAudit = true; if (disablePost != 1) { topic.Title = ForumUtils.BanWordFilter(topic.Title); topic.Message = ForumUtils.BanWordFilter(topic.Message); } } } topic.Iconid = topic.Iconid ?? 0; topic.Iconid = topic.Iconid > 15 || topic.Iconid < 0 ? 0 : topic.Iconid; topicInfo.Fid = topic.Fid ?? topicInfo.Fid; topicInfo.Iconid = (int)topic.Iconid; topicInfo.Title = topic.Title != null ? Utils.HtmlEncode(topic.Title) : topicInfo.Title; topicInfo.Displayorder = hasAudit ? -2 : topicInfo.Displayorder; if (topic.Message != null) { bool htmlon = topic.Message.Length != Utils.RemoveHtml(topic.Message).Length && userGroupInfo.Allowhtml == 1; topic.Message = htmlon ? Utils.HtmlDecode(topic.Message) : topic.Message; } bool enabletag = (commandParam.GeneralConfig.Enabletag & forumInfo.Allowtag) == 1; string tags = string.Empty; string[] tagArray = null; if (!string.IsNullOrEmpty(topic.Tags)) { //标签(Tag)操作 tags = topic.Tags.Trim(); tagArray = Utils.SplitString(tags, ",", true, 2, 10); if (enabletag) { if (topicInfo.Magic == 0) topicInfo.Magic = 10000; topicInfo.Magic = Utils.StrToInt(topicInfo.Magic.ToString() + "1", 0); } } if (forumInfo.Applytopictype == 1) { if (Discuz.Forum.Forums.IsCurrentForumTopicType(topic.Typeid.ToString(), forumInfo.Topictypes)) { topicInfo.Typeid = (int)topic.Typeid; } else if (forumInfo.Postbytopictype == 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } } int editResult = Discuz.Forum.Topics.UpdateTopic(topicInfo); if (enabletag && tagArray != null && tagArray.Length > 0) { if (disablePost == 1 || !ForumUtils.HasBannedWord(tags)) ForumTags.CreateTopicTags(tagArray, topicInfo.Tid, userInfo.Uid, topicInfo.Postdatetime); } PostInfo postInfo = Discuz.Forum.Posts.GetPostInfo(topicInfo.Tid, Discuz.Forum.Posts.GetFirstPostId(topicInfo.Tid)); if (topic.Fid != null) postInfo.Fid = forumInfo.Fid; if (topic.Title != null) { postInfo.Title = topicInfo.Title; postInfo.Topictitle = topicInfo.Title; } postInfo.Message = topic.Message ?? postInfo.Message; editResult = Posts.UpdatePost(postInfo); TopicEditResponse ter = new TopicEditResponse(); ter.Successfull = editResult; result = commandParam.Format == FormatType.JSON ? (editResult == 1).ToString().ToLower() : SerializationHelper.Serialize(ter); return true; }
public override bool Run(CommandParameter commandParam, ref string result) { if (!commandParam.CheckRequiredParams("topic_ids")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } string topicIds = commandParam.GetDNTParam("topic_ids").ToString(); if (!Utils.IsNumericList(topicIds)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } if (topicIds.Split(',').Length > 20) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } int forumId = commandParam.GetIntParam("fid"); //桌面程序需要验证当前登录用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { if (!commandParam.CheckRequiredParams("fid")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } if (commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } ShortUserInfo user = Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid); if (user == null || !Moderators.IsModer(user.Adminid, commandParam.LocalUid, forumId)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return false; } if (!Discuz.Forum.Topics.InSameForum(topicIds, forumId)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } } bool deleteResult = Discuz.Forum.TopicAdmins.DeleteTopics(topicIds, false) > 0; TopicDeleteResponse tdr = new TopicDeleteResponse(); tdr.Successfull = deleteResult ? 1 : 0; result = commandParam.Format == FormatType.JSON ? string.Format("\"{0}\"", result.ToString().ToLower()) : SerializationHelper.Serialize(tdr); return true; }
public override bool Run(CommandParameter commandParam, ref string result) { //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } if (!commandParam.CheckRequiredParams("fid,page_size,page_index")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } int fid = commandParam.GetIntParam("fid", 0); int pageSize = commandParam.GetIntParam("page_size", commandParam.GeneralConfig.Tpp); int pageIndex = commandParam.GetIntParam("page_index", 1); pageSize = pageSize < 1 ? commandParam.GeneralConfig.Tpp : pageSize; pageIndex = pageIndex < 1 ? 1 : pageIndex; int count = Discuz.Forum.Topics.GetAttentionTopicCount(fid.ToString(), string.Empty); List<TopicInfo> topicList = Discuz.Forum.Topics.GetAttentionTopics(fid.ToString(), pageSize, pageIndex, string.Empty); TopicGetListResponse tglr = new TopicGetListResponse(); List<ForumTopic> list = new List<ForumTopic>(); foreach (TopicInfo topicInfo in topicList) { ForumTopic topic = new ForumTopic(); topic.Author = topicInfo.Poster; topic.AuthorId = topicInfo.Posterid; topic.LastPosterId = topicInfo.Lastposterid; topic.LastPostTime = DateTime.Parse(topicInfo.Lastpost).ToString("yyyy-MM-dd HH:mm:ss"); topic.ReplyCount = topicInfo.Replies; topic.ViewCount = topicInfo.Views; topic.Title = topicInfo.Title; topic.TopicId = topicInfo.Tid; topic.Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + Discuz.Forum.Urls.ShowTopicAspxRewrite(topic.TopicId, 0); list.Add(topic); } tglr.Count = count; tglr.Topics = list.ToArray(); tglr.List = true; result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(tglr) : SerializationHelper.Serialize(tglr); return true; }
public override bool Run(CommandParameter commandParam, ref string result) { //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } if (!commandParam.CheckRequiredParams("fid,page_size,page_index")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } int fid = commandParam.GetIntParam("fid"); ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(fid); if (forumInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_FORUM_NOT_EXIST, commandParam.ParamList); return false; } int pageSize = commandParam.GetIntParam("page_size", commandParam.GeneralConfig.Tpp); int pageIndex = commandParam.GetIntParam("page_index", 1); pageSize = pageSize < 1 ? commandParam.GeneralConfig.Tpp : pageSize; pageIndex = pageIndex < 1 ? 1 : pageIndex; //主题分类条件idlist string topicTypeIdList = commandParam.GetDNTParam("type_id_list").ToString(); string condition = string.Empty;//查询主题的条件 //如果条件不为空且是逗号分割的list,则添加condition条件 if (!string.IsNullOrEmpty(topicTypeIdList) && Utils.IsNumericList(topicTypeIdList)) condition = " AND [typeid] IN (" + topicTypeIdList + ") "; int count = Discuz.Forum.Topics.GetTopicCount(fid, true, string.Empty); List<TopicInfo> topicList = Discuz.Forum.Topics.GetTopicList(fid, pageSize, pageIndex, 0, 600, commandParam.GeneralConfig.Hottopic, forumInfo.Autoclose, forumInfo.Topictypeprefix, condition); TopicGetListResponse tglr = new TopicGetListResponse(); List<ForumTopic> list = new List<ForumTopic>(); foreach (TopicInfo topicInfo in topicList) { ForumTopic topic = new ForumTopic(); topic.Author = topicInfo.Poster; topic.AuthorId = topicInfo.Posterid; topic.LastPosterId = topicInfo.Lastposterid; topic.LastPostTime = DateTime.Parse(topicInfo.Lastpost).ToString("yyyy-MM-dd HH:mm:ss"); topic.ReplyCount = topicInfo.Replies; topic.ViewCount = topicInfo.Views; topic.Title = topicInfo.Title; topic.TopicId = topicInfo.Tid; topic.Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + Discuz.Forum.Urls.ShowTopicAspxRewrite(topic.TopicId, 0); list.Add(topic); } tglr.Count = count; tglr.Topics = list.ToArray(); tglr.List = true; result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(tglr) : SerializationHelper.Serialize(tglr); return true; }
public override bool Run(CommandParameter commandParam, ref string result) { //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } if (!commandParam.CheckRequiredParams("fid,tid,page_size,page_index")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } int fid = commandParam.GetIntParam("fid"); ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(fid); if (forumInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_FORUM_NOT_EXIST, commandParam.ParamList); return false; } int tid = commandParam.GetIntParam("tid"); TopicInfo topicInfo = Discuz.Forum.Topics.GetTopicInfo(tid); if (topicInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_TOPIC_NOT_EXIST, commandParam.ParamList); return false; } int pageSize = commandParam.GetIntParam("page_size", commandParam.GeneralConfig.Ppp); int pageIndex = commandParam.GetIntParam("page_index", 1); pageSize = pageSize < 1 ? commandParam.GeneralConfig.Ppp : pageSize; pageIndex = pageIndex < 1 ? 1 : pageIndex; PostpramsInfo postPramsInfo = TopicsCommandUtils.GetPostParamInfo(commandParam.LocalUid, topicInfo, forumInfo, pageSize, pageIndex); System.Data.DataTable lastpostlist = Posts.GetPagedLastDataTable(postPramsInfo); List<Post> list = new List<Post>(); foreach (System.Data.DataRow dr in lastpostlist.Rows) { Post post = new Post(); post.AdIndex = Utils.StrToInt(dr["adindex"], 0); post.Invisible = Utils.StrToInt(dr["invisible"], 0); post.Layer = Utils.StrToInt(dr["layer"], 0); post.Message = dr["message"].ToString(); post.Pid = Utils.StrToInt(dr["pid"], 0); post.PostDateTime = DateTime.Parse(dr["postdatetime"].ToString()).ToString("yyyy-MM-dd HH:mm:ss"); post.PosterAvator = dr["avatar"].ToString().Replace("\\", "/"); post.PosterAvatorWidth = Utils.StrToInt(dr["avatarwidth"], 0); post.PosterAvatorHeight = Utils.StrToInt(dr["avatarheight"], 0); post.PosterEmail = dr["email"].ToString().Trim(); post.PosterId = Utils.StrToInt(dr["posterid"], 0); post.PosterLocation = dr["location"].ToString(); post.PosterName = dr["poster"].ToString(); post.PosterShowEmail = Utils.StrToInt(dr["showemail"], 0); post.PosterSignature = dr["signature"].ToString(); post.Rate = Utils.StrToInt(dr["rate"], 0); post.RateTimes = Utils.StrToInt(dr["ratetimes"], 0); post.UseSignature = Utils.StrToInt(dr["usesig"], 0); list.Add(post); } TopicGetRencentRepliesResponse tgrrr = new TopicGetRencentRepliesResponse(); tgrrr.List = true; tgrrr.Count = topicInfo.Replies; tgrrr.Posts = list.ToArray(); result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(tgrrr) : Util.AddMessageCDATA(SerializationHelper.Serialize(tgrrr)); return true; }
public override bool Run(CommandParameter commandParam, ref string result) { if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.WEB) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return false; } if (commandParam.LocalUid > 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_ONLINE, commandParam.ParamList); return false; } if (!commandParam.CheckRequiredParams("user_name,password")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } if (LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), false) >= 5) { result = Util.CreateErrorMessage(ErrorType.API_EC_MORE_LOGIN_FAILED, commandParam.ParamList); return false; } string loginName = commandParam.GetDNTParam("user_name").ToString(); string password = commandParam.GetDNTParam("password").ToString(); string passwordFormat = commandParam.CheckRequiredParams("password_format") ? commandParam.GetDNTParam("password_format").ToString() : ""; int expires = commandParam.GetIntParam("expires"); expires = expires > 0 ? expires : 999; int userId = -1; ShortUserInfo userInfo = new ShortUserInfo(); if (commandParam.GeneralConfig.Emaillogin == 1 && Utils.IsValidEmail(loginName)) { DataTable dt = Users.GetUserInfoByEmail(loginName); if (dt.Rows.Count == 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_NOT_EXIST, commandParam.ParamList); return false; } if (dt.Rows.Count > 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SAME_USER_EMAIL, commandParam.ParamList); return false; } loginName = dt.Rows[0]["username"].ToString(); userId = TypeConverter.ObjectToInt(dt.Rows[0]["uid"]); userInfo.Uid = userId; userInfo.Username = loginName; userInfo.Groupid = TypeConverter.ObjectToInt(dt.Rows[0]["groupid"]); userInfo.Groupexpiry = TypeConverter.ObjectToInt(dt.Rows[0]["groupexpiry"]); userInfo.Credits = TypeConverter.ObjectToInt(dt.Rows[0]["credits"]); userInfo.Email = dt.Rows[0]["email"].ToString(); userInfo.Password = dt.Rows[0]["password"].ToString(); } else { userId = Users.GetUserId(loginName); if (userId < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_NOT_EXIST, commandParam.ParamList); return false; } userInfo = Users.GetShortUserInfo(userId); } int uid = -1; if (passwordFormat == "") { switch (commandParam.GeneralConfig.Passwordmode) { case 0://默认模式 { uid = Users.CheckPassword(loginName, password, true); break; } case 1://动网兼容模式 { uid = Users.CheckDvBbsPassword(loginName, password); break; } } } else { uid = userInfo.Password == password ? userInfo.Uid : -1; } if (uid != userInfo.Uid) { LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), true); result = Util.CreateErrorMessage(ErrorType.API_EC_WRONG_PASSWORD, commandParam.ParamList); return false; } #region 当前用户所在用户组为"禁止访问"或"等待激活"时 if ((userInfo.Groupid == 4 || userInfo.Groupid == 5) && userInfo.Groupexpiry != 0 && userInfo.Groupexpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0)) { //根据当前用户的积分获取对应积分用户组 UserGroupInfo groupInfo = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits); Users.UpdateUserGroup(userInfo.Uid, userInfo.Groupid); } #endregion if (userInfo.Groupid == 5 || userInfo.Groupid == 8)// 5-禁止访问或者需要激活帐号的用户 { result = Util.CreateErrorMessage(ErrorType.API_EC_BANNED_USERGROUP, commandParam.ParamList); return false; } #region 无延迟更新在线信息和相关用户信息 ForumUtils.WriteUserCookie(userInfo.Uid, expires, commandParam.GeneralConfig.Passwordkey, 0, -1); OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(commandParam.GeneralConfig.Passwordkey, commandParam.GeneralConfig.Onlinetimeout, userInfo.Uid, ""); OnlineUsers.UpdateAction(oluserinfo.Olid, UserAction.Login.ActionID, 0); LoginLogs.DeleteLoginLog(DNTRequest.GetIP()); Users.UpdateUserCreditsAndVisit(userInfo.Uid, DNTRequest.GetIP()); #endregion result = "success"; result = commandParam.Format == FormatType.JSON ? string.Format("\"{0}\"", result) : SerializationHelper.Serialize(result); return true; }
public override bool Run(CommandParameter commandParam, ref string result) { int uid = commandParam.GetIntParam("uid"); //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { if (commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } if (commandParam.LocalUid != uid) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return false; } } if (!commandParam.CheckRequiredParams("uid,original_password,new_password,confirm_new_password")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } string originalPassword = commandParam.GetDNTParam("original_password").ToString(); string newPassword = commandParam.GetDNTParam("new_password").ToString(); string confirmNewPassword = commandParam.GetDNTParam("confirm_new_password").ToString(); if (newPassword != confirmNewPassword) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } bool isMD5Passwd = commandParam.GetDNTParam("password_format") != null && commandParam.GetDNTParam("password_format").ToString().ToLower() == "md5"; ShortUserInfo user = Discuz.Forum.Users.GetShortUserInfo(uid); if (!isMD5Passwd) originalPassword = Utils.MD5(originalPassword); if (user.Password != originalPassword) { result = Util.CreateErrorMessage(ErrorType.API_EC_ORI_PASSWORD_EQUAL_FALSE, commandParam.ParamList); return false; } bool updateSuccess = Discuz.Forum.Users.UpdateUserPassword(uid, newPassword, !isMD5Passwd); if (commandParam.Format == FormatType.JSON) result = string.Format("\"{0}\"", updateSuccess.ToString().ToLower()); else { ChangePasswordResponse cpr = new ChangePasswordResponse(); cpr.Successfull = updateSuccess ? 1 : 0; result = SerializationHelper.Serialize(cpr); } return true; }
public override bool Run(CommandParameter commandParam, ref string result) { if (!commandParam.CheckRequiredParams("post_ids,tid")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } string successfulIds = string.Empty; int tid = commandParam.GetIntParam("tid"); //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { if (commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } ShortUserInfo userInfo = Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid); TopicInfo topicInfo = Discuz.Forum.Topics.GetTopicInfo(tid); if (!Discuz.Forum.Moderators.IsModer(userInfo.Adminid, commandParam.LocalUid, topicInfo.Fid)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return false; } } int i = 0; string postTableId = Discuz.Forum.Posts.GetPostTableId(tid); foreach (string s in commandParam.GetDNTParam("post_ids").ToString().Split(',')) { int pid = TypeConverter.StrToInt(s); if (pid < 1) continue; if (Discuz.Forum.Posts.DeletePost(postTableId, pid, false, true) > 0) successfulIds += (pid + ","); if (++i >= 20) break; } if (successfulIds.Length > 0) successfulIds = successfulIds.Remove(successfulIds.Length - 1); if (commandParam.Format == FormatType.JSON) result = string.Format("\"{0}\"", successfulIds); else { TopicDeleteRepliesResponse tdrr = new TopicDeleteRepliesResponse(); tdrr.Result = successfulIds; result = SerializationHelper.Serialize(tdrr); } return true; }
/* * 每个用户UID 30秒内只能调用一次该接口 */ public override bool Run(CommandParameter commandParam, ref string result) { //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return(false); } if (!commandParam.CheckRequiredParams("subject,message,to_ids")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } string ids = commandParam.GetDNTParam("to_ids").ToString(); if (!Utils.IsNumericList(ids)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } string[] idArray = ids.Split(','); if (idArray.Length > 10) { result = Util.CreateErrorMessage(ErrorType.API_EC_PM_TOID_OVERFLOW, commandParam.ParamList); return(false); } //桌面应用程序用户强制使用session_info.uid int fromId = commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP ? commandParam.LocalUid : commandParam.GetIntParam("from_id", commandParam.LocalUid); ShortUserInfo fromUserInfo = Discuz.Forum.Users.GetShortUserInfo(fromId); if (fromUserInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_PM_FROMID_NOT_EXIST, commandParam.ParamList); return(false); } //如果发送用户不是管理员,且在30秒内调用了该接口 if (fromUserInfo.Adminid != 1 && !CommandCacheQueue <SendMessageItem> .EnQueue(new SendMessageItem(fromUserInfo.Uid, DateTime.Now.Ticks))) { result = Util.CreateErrorMessage(ErrorType.API_EC_PM_VISIT_TOOFAST, commandParam.ParamList); return(false); } string message = UBB.ParseUrl(Utils.EncodeHtml(commandParam.GetDNTParam("message").ToString())); string successfulIds = string.Empty; foreach (string id in ids.Split(',')) { int toUid = TypeConverter.StrToInt(id); if (toUid < 1 || toUid == fromId) { continue; } ShortUserInfo toUserInfo = Discuz.Forum.Users.GetShortUserInfo(toUid); if (toUserInfo == null) { continue; } PrivateMessageInfo pm = new PrivateMessageInfo(); pm.Folder = 0; pm.Message = message; pm.Msgfrom = fromUserInfo.Username; pm.Msgfromid = fromId; pm.Msgto = toUserInfo.Username; pm.Msgtoid = TypeConverter.StrToInt(id); pm.New = 1; pm.Postdatetime = Utils.GetDateTime(); pm.Subject = commandParam.GetDNTParam("subject").ToString(); successfulIds += (PrivateMessages.CreatePrivateMessage(pm, 0) > 0) ? (id + ",") : ""; } successfulIds = successfulIds.Length > 0 ? successfulIds.Remove(successfulIds.Length - 1) : successfulIds; if (commandParam.Format == FormatType.JSON) { result = string.Format("\"{0}\"", successfulIds); } else { MessageSendResponse nsr = new MessageSendResponse(); nsr.Result = successfulIds; result = SerializationHelper.Serialize(nsr); } return(true); }
public override bool Run(CommandParameter commandParam, ref string result) { int uid = commandParam.GetIntParam("uid"); //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { if (commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return(false); } if (commandParam.LocalUid != uid) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return(false); } } if (!commandParam.CheckRequiredParams("uid,original_password,new_password,confirm_new_password")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } string originalPassword = commandParam.GetDNTParam("original_password").ToString(); string newPassword = commandParam.GetDNTParam("new_password").ToString(); string confirmNewPassword = commandParam.GetDNTParam("confirm_new_password").ToString(); if (newPassword != confirmNewPassword) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } bool isMD5Passwd = commandParam.GetDNTParam("password_format") != null && commandParam.GetDNTParam("password_format").ToString().ToLower() == "md5"; ShortUserInfo user = Discuz.Forum.Users.GetShortUserInfo(uid); if (!isMD5Passwd) { originalPassword = Utils.MD5(originalPassword); } if (user.Password != originalPassword) { result = Util.CreateErrorMessage(ErrorType.API_EC_ORI_PASSWORD_EQUAL_FALSE, commandParam.ParamList); return(false); } bool updateSuccess = Discuz.Forum.Users.UpdateUserPassword(uid, newPassword, !isMD5Passwd); if (commandParam.Format == FormatType.JSON) { result = string.Format("\"{0}\"", updateSuccess.ToString().ToLower()); } else { ChangePasswordResponse cpr = new ChangePasswordResponse(); cpr.Successfull = updateSuccess ? 1 : 0; result = SerializationHelper.Serialize(cpr); } return(true); }
public override bool Run(CommandParameter commandParam, ref string result) { if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return(false); } if (!commandParam.CheckRequiredParams("user_info")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } UserForEditing ufe; try { ufe = JavaScriptConvert.DeserializeObject <UserForEditing>(commandParam.GetDNTParam("user_info").ToString()); } catch { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } #region 用户信息读取及权限校验 int uid = commandParam.GetIntParam("uid"); uid = uid > 0 ? uid : commandParam.LocalUid; if (uid <= 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } UserInfo localUserInfo = null; //终端应用程序需要校验当前用户权限,不是管理员则只能修改自己的资料 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { localUserInfo = Users.GetUserInfo(commandParam.LocalUid); if (localUserInfo == null || (localUserInfo.Uid != uid && localUserInfo.Adminid != 1)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return(false); } } UserInfo userInfo = localUserInfo != null && localUserInfo.Uid == uid ? localUserInfo : Users.GetUserInfo(uid); if (userInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_NOT_EXIST, commandParam.ParamList); return(false); } #endregion if (!string.IsNullOrEmpty(ufe.Email)) { if (!UserCommandUtils.CheckEmail(ufe.Email, commandParam.GeneralConfig.Accessemail)) { result = Util.CreateErrorMessage(ErrorType.API_EC_EMAIL, commandParam.ParamList); return(false); } userInfo.Email = ufe.Email; } if (!string.IsNullOrEmpty(ufe.Password)) { userInfo.Password = ufe.Password; } if (!string.IsNullOrEmpty(ufe.Bio)) { userInfo.Bio = ufe.Bio; } if (!string.IsNullOrEmpty(ufe.Birthday)) { userInfo.Bday = ufe.Birthday; } if (!string.IsNullOrEmpty(ufe.ExtCredits1)) { userInfo.Extcredits1 = Utils.StrToFloat(ufe.ExtCredits1, 0); } if (!string.IsNullOrEmpty(ufe.ExtCredits2)) { userInfo.Extcredits2 = Utils.StrToFloat(ufe.ExtCredits2, 0); } if (!string.IsNullOrEmpty(ufe.ExtCredits3)) { userInfo.Extcredits3 = Utils.StrToFloat(ufe.ExtCredits3, 0); } if (!string.IsNullOrEmpty(ufe.ExtCredits4)) { userInfo.Extcredits4 = Utils.StrToFloat(ufe.ExtCredits4, 0); } if (!string.IsNullOrEmpty(ufe.ExtCredits5)) { userInfo.Extcredits5 = Utils.StrToFloat(ufe.ExtCredits5, 0); } if (!string.IsNullOrEmpty(ufe.ExtCredits6)) { userInfo.Extcredits6 = Utils.StrToFloat(ufe.ExtCredits6, 0); } if (!string.IsNullOrEmpty(ufe.ExtCredits7)) { userInfo.Extcredits7 = Utils.StrToFloat(ufe.ExtCredits7, 0); } if (!string.IsNullOrEmpty(ufe.ExtCredits8)) { userInfo.Extcredits8 = Utils.StrToFloat(ufe.ExtCredits8, 0); } if (!string.IsNullOrEmpty(ufe.Gender)) { userInfo.Gender = Utils.StrToInt(ufe.Gender, 0); } if (!string.IsNullOrEmpty(ufe.Icq)) { userInfo.Icq = ufe.Icq; } if (!string.IsNullOrEmpty(ufe.IdCard)) { userInfo.Idcard = ufe.IdCard; } if (!string.IsNullOrEmpty(ufe.Location)) { userInfo.Location = ufe.Location; } if (!string.IsNullOrEmpty(ufe.Mobile)) { userInfo.Mobile = ufe.Mobile; } if (!string.IsNullOrEmpty(ufe.Msn)) { userInfo.Msn = ufe.Msn; } if (!string.IsNullOrEmpty(ufe.NickName)) { userInfo.Nickname = ufe.NickName; } if (!string.IsNullOrEmpty(ufe.Phone)) { userInfo.Phone = ufe.Phone; } if (!string.IsNullOrEmpty(ufe.Qq)) { userInfo.Qq = ufe.Qq; } if (!string.IsNullOrEmpty(ufe.RealName)) { userInfo.Realname = ufe.RealName; } if (!string.IsNullOrEmpty(ufe.Skype)) { userInfo.Skype = ufe.Skype; } if (!string.IsNullOrEmpty(ufe.SpaceId)) { userInfo.Spaceid = Utils.StrToInt(ufe.SpaceId, 0); } if (!string.IsNullOrEmpty(ufe.WebSite)) { userInfo.Website = ufe.WebSite; } if (!string.IsNullOrEmpty(ufe.Yahoo)) { userInfo.Yahoo = ufe.Yahoo; } try { Users.UpdateUser(userInfo); } catch { result = Util.CreateErrorMessage(ErrorType.API_EC_UNKNOWN, commandParam.ParamList); return(false); } if (commandParam.Format == FormatType.JSON) { result = "true"; } else { SetInfoResponse sir = new SetInfoResponse(); sir.Successfull = 1; result = SerializationHelper.Serialize(sir); } return(true); }
public override bool Run(CommandParameter commandParam, ref string result) { //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { if (commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } //如果当前用户不是管理员 if (Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid).Groupid).Radminid != 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return false; } } if (!commandParam.CheckRequiredParams("notification")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } //给当前登录用户发送通知可以将to_ids设置为空 if (commandParam.LocalUid < 1 && (!commandParam.CheckRequiredParams("to_ids") || !Utils.IsNumericList(commandParam.GetDNTParam("to_ids").ToString()))) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } string ids = commandParam.GetDNTParam("to_ids").ToString(); string notification = commandParam.GetDNTParam("notification").ToString(); string[] to_ids; if (ids == string.Empty) { to_ids = new string[1]; to_ids[0] = commandParam.LocalUid.ToString(); } else { to_ids = commandParam.GetDNTParam("to_ids").ToString().Split(','); } string successfulIds = string.Empty; ShortUserInfo shortUserInfo = null; if (commandParam.LocalUid > 0) shortUserInfo = Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid); foreach (string id in to_ids) { if (Utils.StrToInt(id, 0) < 1) continue; NoticeInfo noticeinfo = new NoticeInfo(); noticeinfo.Uid = Utils.StrToInt(id, 0); noticeinfo.New = 1; noticeinfo.Postdatetime = Utils.GetDateTime(); //如果应用程序没有指定来源id,则会将当前应用程序id的hash值作为来源ID,若不指定来源id,用户的通知列表中只存在一条最新的应用程序通知 noticeinfo.Fromid = commandParam.GetIntParam("from_id", Utils.BKDEHash(commandParam.AppInfo.APIKey, 113)); //如果应用程序指定了来源id,则通知类型为“应用程序自定义通知”,否则是“应用程序通知” noticeinfo.Type = commandParam.CheckRequiredParams("from_id") ? NoticeType.ApplicationCustomNotice : NoticeType.ApplicationNotice; if (commandParam.LocalUid > 0) { noticeinfo.Poster = shortUserInfo == null ? "" : shortUserInfo.Username; noticeinfo.Posterid = commandParam.LocalUid; } else { noticeinfo.Poster = ""; noticeinfo.Posterid = 0; } noticeinfo.Note = Utils.EncodeHtml(notification);//需要做ubb标签转换 if (Notices.CreateNoticeInfo(noticeinfo) > 0) successfulIds += (id + ","); } if (successfulIds.Length > 0) successfulIds = successfulIds.Remove(successfulIds.Length - 1); if (commandParam.Format == FormatType.JSON) { result = string.Format("\"{0}\"", successfulIds); } else { NotificationSendResponse nsr = new NotificationSendResponse(); nsr.Result = successfulIds; result = SerializationHelper.Serialize(nsr); } return true; }
public override bool Run(CommandParameter commandParam, ref string result) { //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } if (!commandParam.CheckRequiredParams("tid,page_size,page_index")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } int tid = commandParam.GetIntParam("tid"); TopicInfo topicInfo = Discuz.Forum.Topics.GetTopicInfo(tid); if (topicInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_TOPIC_NOT_EXIST, commandParam.ParamList); return false; } ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(topicInfo.Fid); int pageSize = commandParam.GetIntParam("page_size", commandParam.GeneralConfig.Tpp); int pageIndex = commandParam.GetIntParam("page_index", 1); pageSize = pageSize < 1 ? commandParam.GeneralConfig.Tpp : pageSize; pageIndex = pageIndex < 1 ? 1 : pageIndex; PostpramsInfo postPramsInfo = TopicsCommandUtils.GetPostParamInfo(commandParam.LocalUid, topicInfo, forumInfo, pageSize, pageIndex); List<ShowtopicPageAttachmentInfo> attachmentList = new List<ShowtopicPageAttachmentInfo>(); List<ShowtopicPagePostInfo> postList = Posts.GetPostList(postPramsInfo, out attachmentList, false); List<Post> list = new List<Post>(); foreach (ShowtopicPagePostInfo postInfo in postList) { Post post = new Post(); post.AdIndex = postInfo.Adindex; post.Invisible = postInfo.Invisible; post.Layer = postInfo.Layer; post.Message = postInfo.Message; post.Pid = postInfo.Pid; post.PostDateTime = postInfo.Postdatetime; post.PosterAvator = postInfo.Avatar; post.PosterAvatorWidth = postInfo.Avatarwidth; post.PosterAvatorHeight = postInfo.Avatarheight; post.PosterEmail = postInfo.Email; post.PosterId = postInfo.Posterid; post.PosterLocation = postInfo.Location; post.PosterName = postInfo.Poster; post.PosterShowEmail = postInfo.Showemail; post.PosterSignature = postInfo.Signature; post.Rate = postInfo.Rate; post.RateTimes = postInfo.Ratetimes; post.UseSignature = postInfo.Usesig; list.Add(post); } TopicGetResponse tgr = new TopicGetResponse(); tgr.Author = topicInfo.Poster; tgr.AuthorId = topicInfo.Posterid; tgr.Fid = topicInfo.Fid; tgr.Iconid = topicInfo.Iconid; tgr.LastPosterId = topicInfo.Lastposterid; tgr.LastPostTime = topicInfo.Lastpost; tgr.List = list.Count > 1; tgr.ReplyCount = topicInfo.Replies; tgr.Tags = ForumTags.GetTagsByTopicId(topicInfo.Tid); tgr.Title = topicInfo.Title; tgr.TopicId = topicInfo.Tid; tgr.Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + Discuz.Forum.Urls.ShowTopicAspxRewrite(topicInfo.Tid, 0); tgr.ViewCount = topicInfo.Views; tgr.TypeId = topicInfo.Typeid; SortedList<int, string> topicTypeList = Caches.GetTopicTypeArray(); topicTypeList.TryGetValue(topicInfo.Typeid, out tgr.TypeName); tgr.Posts = list.ToArray(); tgr.Attachments = TopicsCommandUtils.ConvertAttachmentArray(attachmentList); result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(tgr) : Util.AddTitleCDATA(Util.AddMessageCDATA(SerializationHelper.Serialize(tgr))); return true; }
/* * Description: * 桌面程序强制validate=true,且必须是在线用户 */ public override bool Run(CommandParameter commandParam, ref string result) { //桌面程序因为安全需要,游客不允许操作 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } //如果validate为true,则校验数据的合法性,包括广告强力屏蔽,是否含有需审核的,以及非法内容.和当前用户的发帖权限,桌面程序强制验证 bool validate = commandParam.GetIntParam("validate") == 1 || commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP; if (!commandParam.CheckRequiredParams("topic_info")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } Topic topic; try { topic = JavaScriptConvert.DeserializeObject<Topic>(commandParam.GetDNTParam("topic_info").ToString()); } catch { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } if (topic == null || Util.AreParamsNullOrZeroOrEmptyString(topic.Fid, topic.Title, topic.Message)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } //文档中应说明title长度范围和内容范围 if (topic.Title.Length > 60) { result = Util.CreateErrorMessage(ErrorType.API_EC_TITLE_INVALID, commandParam.ParamList); return false; } ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(topic.Fid ?? 0); if (forumInfo == null || forumInfo.Layer == 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_FORUM_NOT_EXIST, commandParam.ParamList); return false; } //如果validate为true,则强制读取当前用户 ShortUserInfo userInfo = Discuz.Forum.Users.GetShortUserInfo(validate || (topic.UId == null) ? commandParam.LocalUid : (int)topic.UId); userInfo = userInfo == null ? TopicsCommandUtils.GetGuestUserInfo() : userInfo; UserGroupInfo userGroupInfo = UserGroups.GetUserGroupInfo(userInfo.Groupid); AdminGroupInfo adminInfo = AdminGroups.GetAdminGroupInfo(userGroupInfo.Groupid); //是否受审核、过滤、灌水等限制权限 int disablePost = adminInfo != null ? adminInfo.Disablepostctrl : userGroupInfo.Disableperiodctrl; bool hasAudit = false; if (validate) { ErrorType et = TopicsCommandUtils.GeneralValidate(topic.Title, topic.Message, userInfo, userGroupInfo, forumInfo, commandParam, disablePost); if (et != ErrorType.API_EC_NONE) { result = Util.CreateErrorMessage(et, commandParam.ParamList); return false; } string str = ""; //是否允许发主题 if (!UserAuthority.PostAuthority(forumInfo, userGroupInfo, userInfo.Uid, ref str)) { result = Util.CreateErrorMessage(ErrorType.API_EC_POST_PERM, commandParam.ParamList); return false; } if (disablePost != 1) { et = TopicsCommandUtils.PostTimeAndRepostMessageValidate(userInfo, topic.Title + topic.Message); if (et != ErrorType.API_EC_NONE) { result = Util.CreateErrorMessage(et, commandParam.ParamList); return false; } //内容中是否含有需审核的词汇 if (ForumUtils.HasAuditWord(topic.Title + topic.Message)) hasAudit = true; //过滤非法词汇 topic.Title = ForumUtils.BanWordFilter(topic.Title); topic.Message = ForumUtils.BanWordFilter(topic.Message); } } //主题图标id int iconId = topic.Iconid ?? 0; //图标id值域仅为0-15 iconId = (iconId > 15 || iconId < 0) ? 0 : iconId; TopicInfo topicInfo = new TopicInfo(); topicInfo.Fid = forumInfo.Fid; topicInfo.Iconid = iconId; topicInfo.Title = Utils.HtmlEncode(topic.Title); bool htmlon = topic.Message.Length != Utils.RemoveHtml(topic.Message).Length && userGroupInfo.Allowhtml == 1; //支持html标签? if (!htmlon) topic.Message = Utils.HtmlEncode(topic.Message); string curDateTime = Utils.GetDateTime(); //发帖主题分类校验和绑定 topicInfo.Typeid = 0; if (forumInfo.Applytopictype == 1) { if (Discuz.Forum.Forums.IsCurrentForumTopicType(topic.Typeid.ToString(), forumInfo.Topictypes)) topicInfo.Typeid = (int)topic.Typeid; else if (forumInfo.Postbytopictype == 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } } topicInfo.Readperm = 0; topicInfo.Price = 0; topicInfo.Poster = userInfo.Username; topicInfo.Posterid = userInfo.Uid; topicInfo.Postdatetime = curDateTime; topicInfo.Lastpost = curDateTime; topicInfo.Lastposter = userInfo.Username; topicInfo.Views = 0; topicInfo.Replies = 0; topicInfo.Displayorder = (forumInfo.Modnewtopics == 1) ? -2 : 0; if (topicInfo.Displayorder != -2 && (hasAudit || Scoresets.BetweenTime(commandParam.GeneralConfig.Postmodperiods))) topicInfo.Displayorder = -2; topicInfo.Highlight = ""; topicInfo.Digest = 0; topicInfo.Rate = 0; topicInfo.Hide = 0; topicInfo.Attachment = 0; topicInfo.Moderated = 0; topicInfo.Closed = 0; string tags = string.Empty; string[] tagArray = null; //是否使用tag bool enableTag = (commandParam.GeneralConfig.Enabletag & forumInfo.Allowtag) == 1; if (!string.IsNullOrEmpty(topic.Tags)) { //标签(Tag)操作 tags = topic.Tags.Trim(); tagArray = Utils.SplitString(tags, ",", true, 2, 10); if (enableTag) { if (topicInfo.Magic == 0) topicInfo.Magic = 10000; topicInfo.Magic = Utils.StrToInt(topicInfo.Magic.ToString() + "1", 0); } } int topicId = Discuz.Forum.Topics.CreateTopic(topicInfo); if (enableTag && tagArray != null && tagArray.Length > 0) { //若当前用户不受过滤,审核约束 if (!validate || disablePost == 1 || !ForumUtils.HasBannedWord(tags)) ForumTags.CreateTopicTags(tagArray, topicId, userInfo.Uid, curDateTime); } PostInfo postInfo = new PostInfo(); postInfo.Fid = forumInfo.Fid; postInfo.Tid = topicId; postInfo.Parentid = 0; postInfo.Layer = 0; postInfo.Poster = userInfo.Username; postInfo.Posterid = userInfo.Uid; postInfo.Title = topicInfo.Title; postInfo.Postdatetime = curDateTime; postInfo.Message = topic.Message; postInfo.Ip = DNTRequest.GetIP(); postInfo.Lastedit = ""; postInfo.Invisible = topicInfo.Displayorder == -2 ? 1 : 0; postInfo.Usesig = 0; postInfo.Htmlon = htmlon ? 1 : 0; postInfo.Smileyoff = 1 - forumInfo.Allowsmilies; postInfo.Bbcodeoff = 1; if (userGroupInfo.Allowcusbbcode == 1 && forumInfo.Allowbbcode == 1) postInfo.Bbcodeoff = 0; postInfo.Parseurloff = 0; postInfo.Attachment = 0; postInfo.Rate = 0; postInfo.Ratetimes = 0; postInfo.Topictitle = topicInfo.Title; int postid = 0; try { postid = Posts.CreatePost(postInfo); } catch { TopicAdmins.DeleteTopics(topicId.ToString(), false); result = Util.CreateErrorMessage(ErrorType.API_EC_UNKNOWN, commandParam.ParamList); return false; } Discuz.Forum.Topics.AddParentForumTopics(forumInfo.Parentidlist.Trim(), 1); TopicCreateResponse tcr = new TopicCreateResponse(); tcr.TopicId = topicId; tcr.Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + Discuz.Forum.Urls.ShowTopicAspxRewrite(topicId, 0); tcr.NeedAudit = topicInfo.Displayorder == -2; #region 更新积分 //设置用户的积分 ///首先读取版块内自定义积分 ///版设置了自定义积分则使用,否则使用论坛默认积分 //float[] values = null; //if (!string.IsNullOrEmpty(forumInfo.Postcredits)) //{ // int index = 0; // float tempval = 0; // values = new float[8]; // foreach (string ext in Utils.SplitString(forumInfo.Postcredits, ",")) // { // if (index == 0) // { // if (!ext.Equals("True")) // { // values = null; // break; // } // index++; // continue; // } // tempval = Utils.StrToFloat(ext, 0); // values[index - 1] = tempval; // index++; // if (index > 8) // break; // } //} if (userInfo.Adminid == 1 || !tcr.NeedAudit) CreditsFacade.PostTopic(userInfo.Uid, forumInfo); //TopicsCommandUtils.UpdateScore(userInfo.Uid, values); #endregion //同步到其他应用程序 Sync.NewTopic(topicId.ToString(), topicInfo.Title, topicInfo.Poster, topicInfo.Posterid.ToString(), topicInfo.Fid.ToString(), commandParam.AppInfo.APIKey); result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(tcr) : SerializationHelper.Serialize(tcr); return true; }
public override bool Run(CommandParameter commandParam, ref string result) { if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } if (!commandParam.CheckRequiredParams("user_info")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } UserForEditing ufe; try { ufe = JavaScriptConvert.DeserializeObject<UserForEditing>(commandParam.GetDNTParam("user_info").ToString()); } catch { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } #region 用户信息读取及权限校验 int uid = commandParam.GetIntParam("uid"); uid = uid > 0 ? uid : commandParam.LocalUid; if (uid <= 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } UserInfo localUserInfo = null; //终端应用程序需要校验当前用户权限,不是管理员则只能修改自己的资料 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { localUserInfo = Users.GetUserInfo(commandParam.LocalUid); if (localUserInfo == null || (localUserInfo.Uid != uid && localUserInfo.Adminid != 1)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return false; } } UserInfo userInfo = localUserInfo != null && localUserInfo.Uid == uid ? localUserInfo : Users.GetUserInfo(uid); if (userInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_NOT_EXIST, commandParam.ParamList); return false; } #endregion if (!string.IsNullOrEmpty(ufe.Email)) { if (!UserCommandUtils.CheckEmail(ufe.Email, commandParam.GeneralConfig.Accessemail)) { result = Util.CreateErrorMessage(ErrorType.API_EC_EMAIL, commandParam.ParamList); return false; } userInfo.Email = ufe.Email; } if (!string.IsNullOrEmpty(ufe.Password)) userInfo.Password = ufe.Password; if (!string.IsNullOrEmpty(ufe.Bio)) userInfo.Bio = ufe.Bio; if (!string.IsNullOrEmpty(ufe.Birthday)) userInfo.Bday = ufe.Birthday; if (!string.IsNullOrEmpty(ufe.ExtCredits1)) userInfo.Extcredits1 = Utils.StrToFloat(ufe.ExtCredits1, 0); if (!string.IsNullOrEmpty(ufe.ExtCredits2)) userInfo.Extcredits2 = Utils.StrToFloat(ufe.ExtCredits2, 0); if (!string.IsNullOrEmpty(ufe.ExtCredits3)) userInfo.Extcredits3 = Utils.StrToFloat(ufe.ExtCredits3, 0); if (!string.IsNullOrEmpty(ufe.ExtCredits4)) userInfo.Extcredits4 = Utils.StrToFloat(ufe.ExtCredits4, 0); if (!string.IsNullOrEmpty(ufe.ExtCredits5)) userInfo.Extcredits5 = Utils.StrToFloat(ufe.ExtCredits5, 0); if (!string.IsNullOrEmpty(ufe.ExtCredits6)) userInfo.Extcredits6 = Utils.StrToFloat(ufe.ExtCredits6, 0); if (!string.IsNullOrEmpty(ufe.ExtCredits7)) userInfo.Extcredits7 = Utils.StrToFloat(ufe.ExtCredits7, 0); if (!string.IsNullOrEmpty(ufe.ExtCredits8)) userInfo.Extcredits8 = Utils.StrToFloat(ufe.ExtCredits8, 0); if (!string.IsNullOrEmpty(ufe.Gender)) userInfo.Gender = Utils.StrToInt(ufe.Gender, 0); if (!string.IsNullOrEmpty(ufe.Icq)) userInfo.Icq = ufe.Icq; if (!string.IsNullOrEmpty(ufe.IdCard)) userInfo.Idcard = ufe.IdCard; if (!string.IsNullOrEmpty(ufe.Location)) userInfo.Location = ufe.Location; if (!string.IsNullOrEmpty(ufe.Mobile)) userInfo.Mobile = ufe.Mobile; if (!string.IsNullOrEmpty(ufe.Msn)) userInfo.Msn = ufe.Msn; if (!string.IsNullOrEmpty(ufe.NickName)) userInfo.Nickname = ufe.NickName; if (!string.IsNullOrEmpty(ufe.Phone)) userInfo.Phone = ufe.Phone; if (!string.IsNullOrEmpty(ufe.Qq)) userInfo.Qq = ufe.Qq; if (!string.IsNullOrEmpty(ufe.RealName)) userInfo.Realname = ufe.RealName; if (!string.IsNullOrEmpty(ufe.Skype)) userInfo.Skype = ufe.Skype; if (!string.IsNullOrEmpty(ufe.SpaceId)) userInfo.Spaceid = Utils.StrToInt(ufe.SpaceId, 0); if (!string.IsNullOrEmpty(ufe.WebSite)) userInfo.Website = ufe.WebSite; if (!string.IsNullOrEmpty(ufe.Yahoo)) userInfo.Yahoo = ufe.Yahoo; try { Users.UpdateUser(userInfo); } catch { result = Util.CreateErrorMessage(ErrorType.API_EC_UNKNOWN, commandParam.ParamList); return false; } if (commandParam.Format == FormatType.JSON) result = "true"; else { SetInfoResponse sir = new SetInfoResponse(); sir.Successfull = 1; result = SerializationHelper.Serialize(sir); } return true; }
public override bool Run(CommandParameter commandParam, ref string result) { //如果validate为true,则校验数据的合法性,包括广告强力屏蔽,是否含有需审核的,以及非法内容.和当前用户的发帖权限 bool validate = commandParam.GetIntParam("validate") == 1 || commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP; //桌面程序因为安全需要,游客不允许操作 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP && commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return false; } if (!commandParam.CheckRequiredParams("reply_info")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } Reply reply; try { reply = JavaScriptConvert.DeserializeObject<Reply>(commandParam.GetDNTParam("reply_info").ToString()); } catch { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } if (reply == null || Util.AreParamsNullOrZeroOrEmptyString(reply.Tid, reply.Fid, reply.Message)) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return false; } if (reply.Title == null) reply.Title = string.Empty; if (reply.Title.IndexOf(" ") != -1 || reply.Title.Length > 60) { result = Util.CreateErrorMessage(ErrorType.API_EC_TITLE_INVALID, commandParam.ParamList); return false; } if (reply.Message.Length < commandParam.GeneralConfig.Minpostsize || reply.Message.Length > commandParam.GeneralConfig.Maxpostsize) { result = Util.CreateErrorMessage(ErrorType.API_EC_MESSAGE_LENGTH, commandParam.ParamList); return false; } ForumInfo forumInfo = Discuz.Forum.Forums.GetForumInfo(reply.Fid); if (forumInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_FORUM_NOT_EXIST, commandParam.ParamList); return false; } TopicInfo topicInfo = Discuz.Forum.Topics.GetTopicInfo(reply.Tid); if (topicInfo == null) { result = Util.CreateErrorMessage(ErrorType.API_EC_TOPIC_NOT_EXIST, commandParam.ParamList); return false; } //validate=true或未指定回帖uid时则默认读取当前用户uid,游客为-1 ShortUserInfo userInfo = Discuz.Forum.Users.GetShortUserInfo(validate || reply.Uid == null ? commandParam.LocalUid : (int)reply.Uid); userInfo = userInfo == null ? TopicsCommandUtils.GetGuestUserInfo() : userInfo; UserGroupInfo userGroupInfo = Discuz.Forum.UserGroups.GetUserGroupInfo(userInfo.Groupid); AdminGroupInfo adminInfo = AdminGroups.GetAdminGroupInfo(userGroupInfo.Groupid); //是否受审核、过滤、灌水等限制权限 int disablePost = adminInfo != null ? adminInfo.Disablepostctrl : userGroupInfo.Disableperiodctrl; bool hasAudit = false; if (validate) { ErrorType et = TopicsCommandUtils.GeneralValidate(reply.Title, reply.Message, userInfo, userGroupInfo, forumInfo, commandParam, disablePost); if (et != ErrorType.API_EC_NONE) { result = Util.CreateErrorMessage(et, commandParam.ParamList); return false; } //是否有回复的权限 if (!UserAuthority.PostReply(forumInfo, commandParam.LocalUid, userGroupInfo, topicInfo)) { result = Util.CreateErrorMessage(topicInfo.Closed >= 1 ? ErrorType.API_EC_TOPIC_CLOSED : ErrorType.API_EC_REPLY_PERM, commandParam.ParamList); return false; } if (disablePost != 1) { et = TopicsCommandUtils.PostTimeAndRepostMessageValidate(userInfo, reply.Title + reply.Message); if (et != ErrorType.API_EC_NONE) { result = Util.CreateErrorMessage(et, commandParam.ParamList); return false; } //内容中是否含有需审核的词汇 if (ForumUtils.HasAuditWord(reply.Title + reply.Message)) hasAudit = true; reply.Title = ForumUtils.BanWordFilter(reply.Title); reply.Message = ForumUtils.BanWordFilter(reply.Message); } } PostInfo postInfo = TopicsCommandUtils.PostReply(reply, userGroupInfo, userInfo, forumInfo, topicInfo.Title, disablePost, hasAudit); if (topicInfo.Replies < (commandParam.GeneralConfig.Ppp + 9)) { ForumUtils.DeleteTopicCacheFile(topicInfo.Tid); } TopicReplyResponse trr = new TopicReplyResponse(); trr.PostId = postInfo.Pid; trr.Url = Utils.GetRootUrl(BaseConfigs.GetForumPath) + string.Format("showtopic.aspx?topicid={0}&postid={1}#{1}", reply.Tid, trr.PostId); trr.NeedAudit = postInfo.Invisible == 1; //同步到其他应用程序 Sync.Reply(postInfo.Pid.ToString(), postInfo.Tid.ToString(), postInfo.Topictitle, postInfo.Poster, postInfo.Posterid.ToString(), postInfo.Fid.ToString(), commandParam.AppInfo.APIKey); result = commandParam.Format == FormatType.JSON ? JavaScriptConvert.SerializeObject(trr) : SerializationHelper.Serialize(trr); return true; }
public override bool Run(CommandParameter commandParam, ref string result) { //如果是桌面程序则需要验证用户身份 if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.DESKTOP) { if (commandParam.LocalUid < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SESSIONKEY, commandParam.ParamList); return(false); } //如果当前用户不是管理员 if (Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid).Groupid).Radminid != 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return(false); } } if (!commandParam.CheckRequiredParams("notification")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } //给当前登录用户发送通知可以将to_ids设置为空 if (commandParam.LocalUid < 1 && (!commandParam.CheckRequiredParams("to_ids") || !Utils.IsNumericList(commandParam.GetDNTParam("to_ids").ToString()))) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } string ids = commandParam.GetDNTParam("to_ids").ToString(); string notification = commandParam.GetDNTParam("notification").ToString(); string[] to_ids; if (ids == string.Empty) { to_ids = new string[1]; to_ids[0] = commandParam.LocalUid.ToString(); } else { to_ids = commandParam.GetDNTParam("to_ids").ToString().Split(','); } string successfulIds = string.Empty; ShortUserInfo shortUserInfo = null; if (commandParam.LocalUid > 0) { shortUserInfo = Discuz.Forum.Users.GetShortUserInfo(commandParam.LocalUid); } foreach (string id in to_ids) { if (Utils.StrToInt(id, 0) < 1) { continue; } NoticeInfo noticeinfo = new NoticeInfo(); noticeinfo.Uid = Utils.StrToInt(id, 0); noticeinfo.New = 1; noticeinfo.Postdatetime = Utils.GetDateTime(); //如果应用程序没有指定来源id,则会将当前应用程序id的hash值作为来源ID,若不指定来源id,用户的通知列表中只存在一条最新的应用程序通知 noticeinfo.Fromid = commandParam.GetIntParam("from_id", Utils.BKDEHash(commandParam.AppInfo.APIKey, 113)); //如果应用程序指定了来源id,则通知类型为“应用程序自定义通知”,否则是“应用程序通知” noticeinfo.Type = commandParam.CheckRequiredParams("from_id") ? NoticeType.ApplicationCustomNotice : NoticeType.ApplicationNotice; if (commandParam.LocalUid > 0) { noticeinfo.Poster = shortUserInfo == null ? "" : shortUserInfo.Username; noticeinfo.Posterid = commandParam.LocalUid; } else { noticeinfo.Poster = ""; noticeinfo.Posterid = 0; } noticeinfo.Note = Utils.EncodeHtml(notification);//需要做ubb标签转换 if (Notices.CreateNoticeInfo(noticeinfo) > 0) { successfulIds += (id + ","); } } if (successfulIds.Length > 0) { successfulIds = successfulIds.Remove(successfulIds.Length - 1); } if (commandParam.Format == FormatType.JSON) { result = string.Format("\"{0}\"", successfulIds); } else { NotificationSendResponse nsr = new NotificationSendResponse(); nsr.Result = successfulIds; result = SerializationHelper.Serialize(nsr); } return(true); }
public override bool Run(CommandParameter commandParam, ref string result) { if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.WEB) { result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList); return(false); } if (commandParam.LocalUid > 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_ONLINE, commandParam.ParamList); return(false); } if (!commandParam.CheckRequiredParams("user_name,password")) { result = Util.CreateErrorMessage(ErrorType.API_EC_PARAM, commandParam.ParamList); return(false); } if (LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), false) >= 5) { result = Util.CreateErrorMessage(ErrorType.API_EC_MORE_LOGIN_FAILED, commandParam.ParamList); return(false); } string loginName = commandParam.GetDNTParam("user_name").ToString(); string password = commandParam.GetDNTParam("password").ToString(); string passwordFormat = commandParam.CheckRequiredParams("password_format") ? commandParam.GetDNTParam("password_format").ToString() : ""; int expires = commandParam.GetIntParam("expires"); expires = expires > 0 ? expires : 999; int userId = -1; ShortUserInfo userInfo = new ShortUserInfo(); if (commandParam.GeneralConfig.Emaillogin == 1 && Utils.IsValidEmail(loginName)) { DataTable dt = Users.GetUserInfoByEmail(loginName); if (dt.Rows.Count == 0) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_NOT_EXIST, commandParam.ParamList); return(false); } if (dt.Rows.Count > 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_SAME_USER_EMAIL, commandParam.ParamList); return(false); } loginName = dt.Rows[0]["username"].ToString(); userId = TypeConverter.ObjectToInt(dt.Rows[0]["uid"]); userInfo.Uid = userId; userInfo.Username = loginName; userInfo.Groupid = TypeConverter.ObjectToInt(dt.Rows[0]["groupid"]); userInfo.Groupexpiry = TypeConverter.ObjectToInt(dt.Rows[0]["groupexpiry"]); userInfo.Credits = TypeConverter.ObjectToInt(dt.Rows[0]["credits"]); userInfo.Email = dt.Rows[0]["email"].ToString(); userInfo.Password = dt.Rows[0]["password"].ToString(); } else { userId = Users.GetUserId(loginName); if (userId < 1) { result = Util.CreateErrorMessage(ErrorType.API_EC_USER_NOT_EXIST, commandParam.ParamList); return(false); } userInfo = Users.GetShortUserInfo(userId); } int uid = -1; if (passwordFormat == "") { switch (commandParam.GeneralConfig.Passwordmode) { case 0: //默认模式 { uid = Users.CheckPassword(loginName, password, true); break; } case 1: //动网兼容模式 { uid = Users.CheckDvBbsPassword(loginName, password); break; } } } else { uid = userInfo.Password == password ? userInfo.Uid : -1; } if (uid != userInfo.Uid) { LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), true); result = Util.CreateErrorMessage(ErrorType.API_EC_WRONG_PASSWORD, commandParam.ParamList); return(false); } #region 当前用户所在用户组为"禁止访问"或"等待激活"时 if ((userInfo.Groupid == 4 || userInfo.Groupid == 5) && userInfo.Groupexpiry != 0 && userInfo.Groupexpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0)) { //根据当前用户的积分获取对应积分用户组 UserGroupInfo groupInfo = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits); Users.UpdateUserGroup(userInfo.Uid, userInfo.Groupid); } #endregion if (userInfo.Groupid == 5 || userInfo.Groupid == 8)// 5-禁止访问或者需要激活帐号的用户 { result = Util.CreateErrorMessage(ErrorType.API_EC_BANNED_USERGROUP, commandParam.ParamList); return(false); } #region 无延迟更新在线信息和相关用户信息 ForumUtils.WriteUserCookie(userInfo.Uid, expires, commandParam.GeneralConfig.Passwordkey, 0, -1); OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(commandParam.GeneralConfig.Passwordkey, commandParam.GeneralConfig.Onlinetimeout, userInfo.Uid, ""); OnlineUsers.UpdateAction(oluserinfo.Olid, UserAction.Login.ActionID, 0); LoginLogs.DeleteLoginLog(DNTRequest.GetIP()); Users.UpdateUserCreditsAndVisit(userInfo.Uid, DNTRequest.GetIP()); #endregion result = "success"; result = commandParam.Format == FormatType.JSON ? string.Format("\"{0}\"", result) : SerializationHelper.Serialize(result); return(true); }