/// <summary> /// 对比指定的论坛版块的新老信息,将作出相应的调整 /// </summary> /// <param name="oldmoderators">老版主名称(注:用","号分割)</param> /// <param name="newmoderators">新版主名称(注:用","号分割)</param> /// <param name="currentfid">当前论坛版块的fid</param> public static void CompareOldAndNewModerator(string oldmoderators, string newmoderators, int currentfid) { if ((oldmoderators == null) || (oldmoderators == "")) { return; } //在新的版主名单中查找老的版主是否存在 foreach (string oldmoderator in oldmoderators.Split(',')) { if ((oldmoderator != "") && ("," + newmoderators + ",").IndexOf("," + oldmoderator + ",") < 0) //当不存在,则表示当前老的版主已被删除,则执行删除当前老版主 { DataTable dt = DatabaseProvider.GetInstance().GetUidAdminIdByUsername(oldmoderator); if (dt.Rows.Count > 0) //当前用户存在 { int uid = Convert.ToInt32(dt.Rows[0][0].ToString()); int radminid = Convert.ToInt32(dt.Rows[0][1].ToString()); dt = DatabaseProvider.GetInstance().GetUidInModeratorsByUid(currentfid, uid); //在其他版块未曾设置为版主 注:(当大于0时则表示在其它版还有相应的版主身份,则不作任何处理) if ((dt.Rows.Count == 0) && (radminid != 1)) { UserInfo __userinfo = Users.GetUserInfo(uid); UserGroupInfo __usergroupinfo = UserCredits.GetCreditsUserGroupID(__userinfo.Credits); DatabaseProvider.GetInstance().UpdateUserOnlineInfo(__usergroupinfo.Groupid, uid); DatabaseProvider.GetInstance().UpdateUserOtherInfo(__usergroupinfo.Groupid, uid); } } } } }
/// <summary> /// 购买主题 /// </summary> /// <param name="uid">用户id</param> /// <param name="tid">主题id</param> /// <param name="posterid">发帖者用户id</param> /// <param name="price">价格</param> /// <param name="netamount"></param> /// <returns></returns> public static int BuyTopic(int uid, int tid, int posterid, int price, float netamount) { int tmpprice = price; if (price > Scoresets.GetMaxIncPerTopic()) { tmpprice = Scoresets.GetMaxIncPerTopic(); } ShortUserInfo userInfo = Discuz.Data.Users.GetShortUserInfo(uid); if (userInfo == null) { return(-2); } if (GetUserExtCredits(userInfo, Scoresets.GetTopicAttachCreditsTrans()) < price) { return(-1); } Discuz.Data.Users.BuyTopic(uid, tid, posterid, price, netamount, Scoresets.GetTopicAttachCreditsTrans()); UserCredits.UpdateUserCredits(uid); UserCredits.UpdateUserCredits(posterid); return(Discuz.Data.PaymentLogs.CreatePaymentLog(uid, tid, posterid, price, netamount)); }
/// <summary> /// 对比指定的论坛版块的新老信息,将作出相应的调整 /// </summary> /// <param name="oldmoderators">老版主名称(注:用","号分割)</param> /// <param name="newmoderators">新版主名称(注:用","号分割)</param> /// <param name="currentfid">当前论坛版块的fid</param> public static void CompareOldAndNewModerator(string oldmoderators, string newmoderators, int currentfid) { if ((oldmoderators == null) || (oldmoderators == "")) { return; } //在新的版主名单中查找老的版主是否存在 foreach (string oldmoderator in oldmoderators.Split(',')) { if ((oldmoderator != "") && ("," + newmoderators + ",").IndexOf("," + oldmoderator + ",") < 0) //当不存在,则表示当前老的版主已被删除,则执行删除当前老版主 { UserInfo info = Users.GetUserInfo(oldmoderator); if (info != null) //当前用户存在 { int uid = info.Uid; int radminid = info.Adminid; DataTable dt = Discuz.Data.Moderators.GetUidInModeratorsByUid(currentfid, uid); //在其他版块未曾设置为版主 注:(当大于0时则表示在其它版还有相应的版主身份,则不作任何处理) if ((dt.Rows.Count == 0) && (radminid != 1)) { UserGroupInfo userGroupInfo = UserCredits.GetCreditsUserGroupId(info.Credits); Discuz.Data.Users.UpdateUserOnlineInfo(userGroupInfo.Groupid, uid); Discuz.Data.Users.UpdateUserOtherInfo(userGroupInfo.Groupid, uid); } } } } }
/// <summary> /// 设置待验证的主题,包括通过,忽略,删除等操作 /// </summary> /// <param name="postTableId">回复表ID</param> /// <param name="ignore">忽略的主题列表</param> /// <param name="validate">验证通过的主题列表</param> /// <param name="delete">删除的主题列表</param> /// <param name="fidlist">版块列表</param> public static void PassAuditNewTopic(string postTableId, string ignore, string validate, string delete, string fidlist) { if (!Utils.IsNumeric(postTableId) || (!string.IsNullOrEmpty(ignore) && !Utils.IsNumericList(ignore)) || (!string.IsNullOrEmpty(validate) && !Utils.IsNumericList(validate)) || (!string.IsNullOrEmpty(delete) && !Utils.IsNumericList(delete)) || (!string.IsNullOrEmpty(fidlist) && !Utils.IsNumericList(fidlist))) { return; } Data.Topics.PassAuditNewTopic(postTableId, ignore, validate, delete, fidlist); //获取验证通过的主题列表信息,为用户增加发主题的扩展积分 if (!string.IsNullOrEmpty(validate)) { foreach (DataRow topicInfo in Topics.GetTopicList(validate).Rows) { ForumInfo forumInfo = Forums.GetForumInfo(TypeConverter.ObjectToInt(topicInfo["fid"]));//获取主题的版块信息 float[] forumPostcredits = Forums.GetValues(forumInfo.Postcredits); if (forumPostcredits != null) //使用版块内积分 { UserCredits.UpdateUserCreditsByPostTopic(TypeConverter.ObjectToInt(topicInfo["posterid"]), forumPostcredits); } else //使用默认积分 { UserCredits.UpdateUserCreditsByPostTopic(TypeConverter.ObjectToInt(topicInfo["posterid"])); } } } }
/// <summary> /// 用户搜索时更新用户的积分 /// </summary> /// <param name="uid">用户id</param> public static int UpdateUserCreditsBySearch(int uid) { int result = UpdateUserExtCredits(uid, 1, CreditsOperationType.Search, 1, false); UserCredits.UpdateUserCredits(uid); return(result); }
/// <summary> /// 将邀请码信息兑换为用户积分 /// </summary> /// <param name="inviteCode">邀请码信息</param> /// <param name="addScoreLine"></param> public static void ConvertInviteCodeToCredits(InviteCodeInfo inviteCode, int inviteCodePayCount) { int mount = inviteCode.SuccessCount - inviteCodePayCount; if (mount > -1)//如果邀请码使用次数超过了加分线,则做加分操作 { UserCredits.UpdateUserCreditsByInvite(inviteCode.CreatorId, inviteCode.SuccessCount); } }
/// <summary> /// 通过待验证的主题 /// </summary> /// <param name="postTableId">当前帖子分表Id</param> /// <param name="tid">主题Id</param> public static void PassAuditNewTopic(string tidList) { string[] tidarray = tidList.Split(','); float[] values = null; ForumInfo forum = null; TopicInfo topic = null; int fid = -1; foreach (string tid in tidarray) { topic = Topics.GetTopicInfo(int.Parse(tid)); //获取主题信息 if (fid != topic.Fid) //当上一个和当前主题不在一个版块内时,重新读取版块的积分设置 { fid = topic.Fid; forum = Discuz.Forum.Forums.GetForumInfo(fid); if (!forum.Postcredits.Equals("")) { int index = 0; float tempval = 0; values = new float[8]; foreach (string ext in Utils.SplitString(forum.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 (values != null) //使用版块内积分 { UserCredits.UpdateUserCreditsByPostTopic(topic.Posterid, values); } else //使用默认积分 { UserCredits.UpdateUserCreditsByPostTopic(topic.Posterid); } } Data.Topics.PassAuditNewTopic(PostTables.GetPostTableId(), tidList); }
/// <summary> /// 用户交易成功时更新用户的积分 /// </summary> /// <param name="uid">用户id</param> public static int UpdateUserCreditsByTradefinished(int userid) { if (userid > 0) { UpdateUserExtCredits(userid, 1, CreditsOperationType.TradeSucceed, 1, false); return(UserCredits.UpdateUserCredits(userid)); } else { return(0); } }
/// <summary> /// 用户发送短消息时更新用户的积分 /// </summary> /// <param name="uid">用户id</param> public static int UpdateUserCreditsBySendpms(int uid) { if (uid > 0) { int result = UpdateUserExtCredits(uid, 1, CreditsOperationType.SendMessage, 1, false); UserCredits.UpdateUserCredits(uid); return(result); } else { return(-1); } }
/// <summary> /// 根据用户列表,一次更新多个用户的积分(此方法只在删除主题时使用过) /// </summary> /// <param name="uidlist">用户ID列表</param> /// <param name="mountlist">操作的次数,用来记录增减积分的次数;例如删帖:删一个帖子(也就是一个操作),mountlist为1;删除两个帖子,两个帖子分别都有两个附件,也就是两次操作,mountlist值就为2</param> /// <param name="creditsOperationType">积分操作类型,如发帖等</param> /// <param name="pos">加或减标志(正数为加,负数为减,通常被传入1或者-1)</param> public static int UpdateUserCredits(int[] uidlist, int[] mountlist, CreditsOperationType creditsOperationType, int pos) { ///根据公式计算用户的总积分,并更新 int reval = 0; for (int i = 0; i < uidlist.Length; i++) { if (uidlist[i] > 0) { reval = reval + UpdateUserExtCredits(uidlist[i], mountlist[i], creditsOperationType, pos, true); } UserCredits.UpdateUserCredits(uidlist[i]); } return(reval); }
/// <summary> /// 将主题设置精华/解除精华 /// </summary> /// <param name="topiclist">要设置的主题列表</param> /// <param name="intValue">精华级别( 0 为解除精华)</param> /// <returns>更新主题个数</returns> public static int SetDigest(string topiclist, int intValue) { string useridlist = GetUserListWithDigestTopiclist(topiclist, intValue > 0 ? 1 : 0); int mount = SetTopicStatus(topiclist, "digest", intValue); if (mount > 0) { if (Utils.IsNumericList(useridlist)) { Discuz.Data.Users.UpdateUserDigest(useridlist); } if (!string.IsNullOrEmpty(useridlist) && Utils.IsNumericList(useridlist)) { UserCredits.UpdateUserCreditsAndExtCredits(useridlist, CreditsOperationType.Digest, intValue > 0 ? 1 : -1); } } return(mount); }
/// <summary> /// 搜索权限判断 /// </summary> /// <param name="userid"></param> /// <param name="lastsearchtime"></param> /// <param name="useradminid"></param> /// <param name="usergroupinfo"></param> /// <param name="msg"></param> /// <returns></returns> public static bool Search(int userid, string lastsearchtime, int useradminid, UserGroupInfo usergroupinfo, ref string msg) { // 如果当前用户非管理员并且论坛设定了禁止全文搜索时间段,当前时间如果在其中的一个时间段内,不允许全文搜索 if (useradminid != 1 && DNTRequest.GetInt("keywordtype", 0) == 1 && usergroupinfo.Disableperiodctrl != 1) { string visittime = ""; if (Scoresets.BetweenTime(GeneralConfigs.GetConfig().Searchbanperiods, out visittime)) { msg = "在此时间段( " + visittime + " )内用户不可以进行全文搜索"; return(false); } } if (useradminid != 1) { //判断一分钟内搜索的次数是不是超过限制值 if (!Statistics.CheckSearchCount(GeneralConfigs.GetConfig().Maxspm)) { msg = "抱歉,系统在一分钟内搜索的次数超过了系统安全设置的上限,请稍候再试"; return(false); } int Interval = Utils.StrDateDiffSeconds(lastsearchtime, GeneralConfigs.GetConfig().Searchctrl); if (Interval <= 0) { msg = "系统规定搜索间隔为" + GeneralConfigs.GetConfig().Searchctrl + "秒, 您还需要等待 " + (Interval * -1) + " 秒"; return(false); } //不是管理员,则如果设置搜索扣积分时扣除用户积分 if (UserCredits.UpdateUserCreditsBySearch(userid) == -1) { string addExtCreditsTip = ""; if (EPayments.IsOpenEPayments()) { addExtCreditsTip = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>"; } msg = "您的积分不足, 不能执行搜索操作" + addExtCreditsTip; return(false); } } return(true); }
/// <summary> /// 给指定帖子评分 /// </summary> /// <param name="postidlist">帖子列表</param> /// <param name="score">要加/减的分值列表</param> /// <param name="extcredits">对应的扩展积分列表</param> /// <returns>更新数量</returns> public static int RatePosts(int tid, string postidlist, string score, string extcredits, int userid, string username, string reason) { if (!Utils.IsNumericList(postidlist)) { return(0); } float[] extcreditslist = new float[] { 0, 0, 0, 0, 0, 0, 0, 0 }; string[] tmpScorelist = Utils.SplitString(score, ","); string[] tmpExtcreditslist = Utils.SplitString(extcredits, ","); int tempExtc = 0; string posttableid = Data.PostTables.GetPostTableId(tid); for (int i = 0; i < tmpExtcreditslist.Length; i++) { tempExtc = TypeConverter.StrToInt(tmpExtcreditslist[i], -1); if (tempExtc > 0 && tempExtc < extcreditslist.Length) { extcreditslist[tempExtc - 1] = TypeConverter.StrToInt(tmpScorelist[i]); //更新相应帖子的积分数 foreach (string pid in Utils.SplitString(postidlist, ",")) { if (pid.Trim() != string.Empty) { SetPostRate(posttableid, TypeConverter.StrToInt(pid), TypeConverter.StrToInt(tmpExtcreditslist[i]), TypeConverter.StrToFloat(tmpScorelist[i]), true); } } AdminRateLogs.InsertLog(postidlist, userid, username, tempExtc, TypeConverter.StrToFloat(tmpScorelist[i]), reason); } } return(UserCredits.UpdateUserExtCredits(GetUserListWithPostlist(tid, postidlist), extcreditslist)); }
/// <summary> /// 根据用户列表,一次更新多个用户的积分 /// </summary> /// <param name="uidlist">用户ID列表</param> /// <param name="creditsOperationType">积分操作类型,如发帖等</param> /// <param name="pos">加或减标志(正数为加,负数为减,通常被传入1或者-1)</param> public static int UpdateUserCreditsAndExtCredits(string uidlist, CreditsOperationType creditsOperationType, int pos) { int reval = -1; if (Utils.IsNumericList(uidlist)) { reval = 0; ///根据公式计算用户的总积分,并更新 foreach (string uid in Utils.SplitString(uidlist, ",")) { if (TypeConverter.StrToInt(uid, 0) > 0) { reval = reval + UpdateUserExtCredits(TypeConverter.StrToInt(uid), 1, creditsOperationType, pos, false); } UserCredits.UpdateUserCredits(TypeConverter.StrToInt(uid)); } } return(reval); }
public static bool UpdateAuthStr(string authStr) { DataTable dt = Discuz.Data.Users.GetUserIdByAuthStr(authStr); if (dt.Rows.Count > 0) { int uid = TypeConverter.ObjectToInt(dt.Rows[0][0]); //将用户调整到相应的用户组 UserGroupInfo tempGroupInfo = UserCredits.GetCreditsUserGroupId(0); if (tempGroupInfo != null) { Users.UpdateUserGroup(uid, tempGroupInfo.Groupid); //添加注册用户审核机制后需要修改 } //更新激活字段 Users.UpdateAuthStr(uid, "", 0); ForumUtils.WriteUserCookie(uid, TypeConverter.StrToInt(DNTRequest.GetString("expires"), -1), GeneralConfigs.GetConfig().Passwordkey); return(true); } return(false); }
/// <summary> /// 购买主题 /// </summary> /// <param name="uid">用户id</param> /// <param name="tid">主题id</param> /// <param name="posterid">发帖者用户id</param> /// <param name="price">价格</param> /// <param name="netamount"></param> /// <returns></returns> public static int BuyTopic(int uid, int tid, int posterid, int price, float netamount) { int tmpprice = price; if (price > Scoresets.GetMaxIncPerTopic()) { tmpprice = Scoresets.GetMaxIncPerTopic(); } IDataReader reader = Users.GetShortUserInfoToReader(uid); if (reader == null) { return(-2); } if (!reader.Read()) { reader.Close(); return(-2); } if (Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0) < price) { reader.Close(); return(-1); } reader.Close(); DatabaseProvider.GetInstance().BuyTopic(uid, tid, posterid, price, netamount, Scoresets.GetCreditsTrans()); UserCredits.UpdateUserCredits(uid); UserCredits.UpdateUserCredits(posterid); return(DatabaseProvider.GetInstance().AddPaymentLog(uid, tid, posterid, price, netamount)); }
/// <summary> /// 用户发表回复时更新用户的积分 /// </summary> /// <param name="uid">用户id</param> /// <param name="values">积分变动值,应保证是一个长度为8的数组,对应8种扩展积分的变动值</param> public static void UpdateUserCreditsByPosts(int uid, float[] values) { UpdateUserExtCredits(uid, values, false); UserCredits.UpdateUserCredits(uid); }
/// <summary> /// 更新用户积分和最后登录时间 /// </summary> /// <param name="uid">用户id</param> public static void UpdateUserCreditsAndVisit(int uid, string ip) { UserCredits.UpdateUserCredits(uid); Discuz.Data.Users.UpdateUserLastvisit(uid, ip); }
/// <summary> /// 在数据库中删除指定主题 /// </summary> /// <param name="topiclist">主题列表</param> /// <param name="subtractCredits">是否减少用户积分(0不减少,1减少)</param> /// <returns>删除个数</returns> public static int DeleteTopics(string topicList, int subTractCredits, bool reserveAttach) { if (!Utils.IsNumericList(topicList)) { return(-1); } GeneralConfigInfo configinfo = GeneralConfigs.GetConfig(); DataTable dt = Topics.GetTopicList(topicList); if (dt == null) { return(-1); } foreach (DataRow dr in dt.Rows) { if (TypeConverter.ObjectToInt(dr["digest"]) > 0) { UserCredits.UpdateUserExtCredits(TypeConverter.ObjectToInt(dr["posterid"]), -1, CreditsOperationType.Digest, 1, true); UserCredits.UpdateUserCredits(TypeConverter.ObjectToInt(dr["posterid"])); } } dt = Posts.GetPostList(topicList); if (dt != null) { Hashtable attUidCount = new Hashtable(); foreach (DataRow dr in dt.Rows) { //后台设置的项为多少天外的老帖删除不减积分,而不是多少天内删帖可以不减分 if (configinfo.Losslessdel == 0 || Utils.StrDateDiffHours(dr["postdatetime"].ToString(), configinfo.Losslessdel * 24) < 0) { CreditsOperationType creditsOperationType = TypeConverter.ObjectToInt(dr["layer"]) == 0 ? CreditsOperationType.PostTopic : CreditsOperationType.PostReply; //获取版块积分规则 float[] creditsValue = Forums.GetValues( creditsOperationType == CreditsOperationType.PostTopic ? Forums.GetForumInfo(TypeConverter.ObjectToInt(dr["fid"])).Postcredits : Forums.GetForumInfo(TypeConverter.ObjectToInt(dr["fid"])).Replycredits ); //如果未定义版块积分规则 if (creditsValue == null) { creditsValue = Scoresets.GetUserExtCredits(creditsOperationType); } UserCredits.UpdateUserExtCredits(TypeConverter.ObjectToInt(dr["posterid"]), creditsValue, 1, creditsOperationType, -1, true); int attCount = Attachments.GetAttachmentCountByPid(TypeConverter.ObjectToInt(dr["pid"])); if (attCount > 0) { int posterid = TypeConverter.ObjectToInt(dr["posterid"]); if (attUidCount.ContainsKey(posterid)) { attUidCount[posterid] = (int)attUidCount[posterid] + attCount; } else { attUidCount.Add(TypeConverter.ObjectToInt(dr["posterid"]), attCount); } } } UserCredits.UpdateUserCredits(TypeConverter.ObjectToInt(dr["posterid"])); } int i = 0; int[] tuidlist = new int[attUidCount.Count]; int[] attcountlist = new int[attUidCount.Count]; foreach (DictionaryEntry de in attUidCount) { tuidlist[i] = (int)de.Key; attcountlist[i] = (int)de.Value; i++; } UserCredits.UpdateUserCredits(tuidlist, attcountlist, CreditsOperationType.UploadAttachment, -1); } int reval = 0; foreach (string posttableid in Posts.GetPostTableIdArray(topicList)) { reval = Discuz.Data.TopicAdmins.DeleteTopicByTidList(topicList, posttableid); } if (reval > 0 && !reserveAttach) { Attachments.DeleteAttachmentByTid(topicList); } return(reval); }
/// <summary> /// BasePage类构造函数 /// </summary> public PageBase() { if (recordPageView) { PageViewStatistic(pagename); } config = GeneralConfigs.GetConfig(); if (SpacePluginProvider.GetInstance() == null) { config.Enablespace = 0; } if (AlbumPluginProvider.GetInstance() == null) { config.Enablealbum = 0; } if (MallPluginProvider.GetInstance() == null) { config.Enablemall = 0; } LoadUrlConfig(); userid = Utils.StrToInt(ForumUtils.GetCookie("userid"), -1); //清空当前页面查询统计 #if DEBUG Discuz.Data.DbHelper.QueryCount = 0; Discuz.Data.DbHelper.QueryDetail = ""; #endif // 如果启用游客页面缓存,则对游客输出缓存页 if (userid == -1 && config.Guestcachepagetimeout > 0 && GetUserCachePage(pagename)) { return; } AddMetaInfo(config.Seokeywords, config.Seodescription, config.Seohead); if (config.Nocacheheaders == 1) { System.Web.HttpContext.Current.Response.BufferOutput = false; System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); System.Web.HttpContext.Current.Response.Expires = 0; System.Web.HttpContext.Current.Response.CacheControl = "no-cache"; System.Web.HttpContext.Current.Response.Cache.SetNoStore(); } //当为forumlist.aspx或forumindex.aspx,可能出现在线并发问题,这时系统会延时2秒 if ((pagename != "forumlist.aspx") && (pagename != "forumindex.aspx")) { oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout); } else { try { oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout); } catch { System.Threading.Thread.Sleep(2000); oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout); } } if (config.PostTimeStorageMedia == 1 && Utils.GetCookie("lastposttime") != "")//如果最后发帖时间cookie不为空,则在此修改用户的该属性 { oluserinfo.Lastposttime = Utils.GetCookie("lastposttime"); } userid = oluserinfo.Userid; usergroupid = oluserinfo.Groupid; username = oluserinfo.Username; password = oluserinfo.Password; userkey = password.Length > 16 ? password.Substring(4, 8).Trim() : ""; lastposttime = oluserinfo.Lastposttime; lastpostpmtime = oluserinfo.Lastpostpmtime; lastsearchtime = oluserinfo.Lastsearchtime; olid = oluserinfo.Olid; //确保头像可以取到 if (userid > 0) { useravatar = Avatars.GetAvatarUrl(userid, AvatarSize.Small); } if (Utils.InArray(DNTRequest.GetString("selectedtemplateid"), Templates.GetValidTemplateIDList())) { templateid = DNTRequest.GetInt("selectedtemplateid", 0); } else if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList())) { templateid = Utils.StrToInt(Utils.GetCookie(Utils.GetTemplateCookieName()), config.Templateid); } if (templateid == 0) { templateid = config.Templateid; } pmsound = Utils.StrToInt(ForumUtils.GetCookie("pmsound"), 0); //已登录用户检测用户组状态,如果是禁言或禁止访问状态时间到期,则自动解禁 if (usergroupid == 4 || usergroupid == 5) { //int groupExpiry = Users.GetShortUserInfo(userid).Groupexpiry; //if (groupExpiry != 0 && groupExpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0)) //{ // //先改为第一个积分组 // usergroupid = 11; // //usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid); // Users.UpdateUserGroup(userid, 11); //} ShortUserInfo userInfo = Users.GetShortUserInfo(userid); if (userInfo.Groupexpiry != 0 && userInfo.Groupexpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0)) { UserGroupInfo groupInfo = UserCredits.GetCreditsUserGroupId(userInfo.Credits); usergroupid = groupInfo.Groupid != 0 ? groupInfo.Groupid : usergroupid; Users.UpdateUserGroup(userid, usergroupid); } } usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid); // 取得用户权限id,1管理员,2超版,3版主,0普通组,-1特殊组 useradminid = usergroupinfo.Radminid; string tips = ForumUtils.GetUserCreditsCookie(userid, usergroupinfo.Grouptitle); if (tips != "") { string[] userinfotipsList = tips.Split(',');//因为考虑到应用程序做单点登录时获取不到userinfotips,封装了此方法 userinfotips = "<p><a class=\"drop\" onmouseover=\"showMenu(this.id);\" href=\"" + BaseConfigs.GetForumPath + "usercpcreditspay.aspx\" id=\"extcreditmenu\">" + userinfotipsList[0] + "</a> "; userinfotips += "<span class=\"pipe\">|</span>用户组: <a class=\"xi2\" id=\"g_upmine\" href=\"" + BaseConfigs.GetForumPath + "usercp.aspx\">" + userinfotipsList[1].Split(':')[1] + "</a></p>"; userinfotips += "<ul id=\"extcreditmenu_menu\" class=\"p_pop\" style=\"display:none;\">"; for (int i = 2; i < userinfotipsList.Length; i++) { userinfotips += string.Format("<li><a> {0}</a></li>", userinfotipsList[i]); } userinfotips += "</ul>"; } mainnavigation = Navs.GetNavigationString(userid, useradminid); subnavigation = Navs.GetSubNavigation(); mainnavigationhassub = Navs.GetMainNavigationHasSub(); // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页 if (config.Closed == 1 && pagename != "login.aspx" && pagename != "logout.aspx" && pagename != "register.aspx" && useradminid != 1) { ShowMessage(1); return; } if (!Utils.InArray(pagename, "attachment.aspx"))//加入附件页面判断减少性能消耗 { onlineusercount = (userid != -1) ? OnlineUsers.GetOnlineAllUserCount() : OnlineUsers.GetCacheOnlineAllUserCount(); } //校验用户是否可以访问论坛 if (!ValidateUserPermission()) { return; } //更新用户在线时长 if (userid != -1 && !Utils.InArray(pagename, "attachment.aspx"))//加入附件页面判断减少性能消耗 { OnlineUsers.UpdateOnlineTime(config.Oltimespan, userid); } TemplateInfo templateInfo = Templates.GetTemplateItem(templateid); templatepath = templateInfo.Directory; if (templateInfo.Templateurl.ToLower().StartsWith("http://")) { imagedir = templateInfo.Templateurl.TrimEnd('/') + "/images"; cssdir = templateInfo.Templateurl.TrimEnd('/'); } else { imagedir = forumpath + "templates/" + templateInfo.Directory + "/images"; cssdir = forumpath + "templates/" + templateInfo.Directory; } if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Topicidentifydir)) { topicidentifydir = EntLibConfigs.GetConfig().Topicidentifydir.TrimEnd('/'); } else { topicidentifydir = forumpath + "images/identify"; } if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Posticondir)) { posticondir = EntLibConfigs.GetConfig().Posticondir.TrimEnd('/'); } else { posticondir = forumpath + "images/posticons"; } if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Jsdir)) { jsdir = EntLibConfigs.GetConfig().Jsdir.TrimEnd('/'); } else { jsdir = rooturl + "javascript"; } nowdate = Utils.GetDate(); nowtime = Utils.GetTime(); nowdatetime = Utils.GetDateTime(); ispost = DNTRequest.IsPost(); isget = DNTRequest.IsGet(); link = ""; script = ""; templatelistboxoptions = Caches.GetTemplateListBoxOptionsCache(); string originalTemplate = string.Format("<li><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">", "", BaseConfigs.GetForumPath, templateid); string newTemplate = string.Format("<li class=\"current\"><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">", BaseConfigs.GetForumPath, templateid); templatelistboxoptions = templatelistboxoptions.Replace(originalTemplate, newTemplate); isLoginCode = config.Seccodestatus.Contains("login.aspx"); //当该页面设置了验证码检验,并且当前用户的用户组没有给予忽略验证码的权限,则isseccode=true; isseccode = Utils.InArray(pagename, config.Seccodestatus) && usergroupinfo.Ignoreseccode == 0; headerad = Advertisements.GetOneHeaderAd("", 0); footerad = Advertisements.GetOneFooterAd("", 0); //设定当前页面的显示样式 if (config.Allowchangewidth == 0) { Utils.WriteCookie("allowchangewidth", ""); } if (pagename != "website.aspx") { if (Utils.GetCookie("allowchangewidth") == "0" || (string.IsNullOrEmpty(Utils.GetCookie("allowchangewidth")) && config.Showwidthmode == 1)) { isnarrowpage = true; } } //校验验证码 if (isseccode && ispost && !ValidateVerifyCode()) { return; } newtopicminute = config.Viewnewtopicminute; m_starttick = DateTime.Now; ShowPage(); m_processtime = DateTime.Now.Subtract(m_starttick).TotalMilliseconds / 1000; querycount = Discuz.Data.DbHelper.QueryCount; Discuz.Data.DbHelper.QueryCount = 0; #if DEBUG querydetail = Discuz.Data.DbHelper.QueryDetail; Discuz.Data.DbHelper.QueryDetail = ""; #endif }
/// <summary> /// 用户发表回复时更新用户的积分 /// </summary> /// <param name="uid">用户id</param> public static void UpdateUserCreditsByPosts(int uid) { UpdateUserExtCredits(uid, 1, CreditsOperationType.PostReply, 1, false); UserCredits.UpdateUserCredits(uid); }
/// <summary> /// 用户发表回复时更新用户的积分 /// </summary> /// <param name="uid">用户id</param> public static void UpdateUserCreditsByDeletePosts(int uid) { UpdateUserExtCredits(uid, 1, CreditsOperationType.DeletePost, -1, false); UserCredits.UpdateUserCredits(uid); }