/// <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) { CreditsFacade.PostTopic(TypeConverter.ObjectToInt(topicInfo["posterid"]), Forums.GetForumInfo(TypeConverter.ObjectToInt(topicInfo["fid"]))); //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="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); foreach (string uid in Utils.SplitString(useridlist, ",")) { if (intValue > 0) { CreditsFacade.SetDigest(TypeConverter.StrToInt(uid)); } else { CreditsFacade.UnDigest(TypeConverter.StrToInt(uid)); } } } } return(mount); }
/// <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 = CreditsFacade.GetCreditsUserGroupId(info.Credits); Discuz.Data.Users.UpdateUserOnlineInfo(userGroupInfo.Groupid, uid); Discuz.Data.Users.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()); CreditsFacade.UpdateUserCredits(uid); CreditsFacade.UpdateUserCredits(posterid); return(Discuz.Data.PaymentLogs.CreatePaymentLog(uid, tid, posterid, price, netamount)); }
public static void ConvertInviteCodeToCredits(InviteCodeInfo inviteCode, int inviteCodePayCount) { int num = inviteCode.SuccessCount - inviteCodePayCount; if (num > -1) { CreditsFacade.Invite(inviteCode.CreatorId, inviteCode.SuccessCount); } }
/// <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)//如果邀请码使用次数超过了加分线,则做加分操作 { CreditsFacade.Invite(inviteCode.CreatorId, inviteCode.SuccessCount); } }
/// <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); } 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); CreditsFacade.UnDigest(TypeConverter.ObjectToInt(dr["posterid"])); } } List <PostInfo> list = Posts.GetPostList(topicList); if (list != null && list.Count != 0) { int lastFid = 0; ForumInfo forumInfo = null; foreach (PostInfo postInfo in list) { //如果与上一个帖子是同一版块,将不再重新读取版块信息 if (lastFid != postInfo.Fid) { lastFid = postInfo.Fid; forumInfo = Forums.GetForumInfo(lastFid); } CreditsFacade.DeletePost(postInfo, forumInfo, reserveAttach); } } 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> /// 通过待验证的主题 /// </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 tidList.Split(',')) { TopicInfo topic = Topics.GetTopicInfo(int.Parse(tid)); //获取主题信息 CreditsFacade.PostTopic(topic.Posterid, Forums.GetForumInfo(topic.Fid)); //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="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 (CreditsFacade.Search(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(CreditsFacade.UpdateUserExtCredits(GetUserListWithPostlist(tid, postidlist), extcreditslist)); }
public static int BuyTopic(int uid, int tid, int posterid, int price, float netamount) { if (price > Scoresets.GetMaxIncPerTopic()) { Scoresets.GetMaxIncPerTopic(); } var user = User.FindByID(uid); if (user == null) { return(-2); } if (PaymentLogs.GetUserExtCredits(user, Scoresets.GetTopicAttachCreditsTrans()) < (float)price) { return(-1); } Discuz.Data.Users.BuyTopic(uid, tid, posterid, price, netamount, Scoresets.GetTopicAttachCreditsTrans()); CreditsFacade.UpdateUserCredits(uid); CreditsFacade.UpdateUserCredits(posterid); return(Discuz.Data.PaymentLogs.CreatePaymentLog(uid, tid, posterid, price, netamount)); }
/// <summary> /// 通过指定值更新用户积分 /// </summary> /// <param name="uid">用户ID</param> /// <param name="values">积分变动值,应保证是一个长度为8的数组,对应8种扩展积分的变动值</param> /// <param name="allowMinus">是否允许被扣成负分,true允许,false不允许并且不进行扣分返回-1</param> /// <returns></returns> public static int UpdateUserExtCredits(int uid, float[] values, bool allowMinus) { if (uid < 1 || Discuz.Data.Users.GetUserInfo(uid) == null) { return(0); } if (values.Length < 8) { return(-1); } if (!allowMinus)//不允许扣成负分时要进行判断积分是否足够被减 { // 如果要减扩展积分, 首先判断扩展积分是否足够被减 if (!Discuz.Data.UserCredits.CheckUserCreditsIsEnough(uid, values)) { return(-1); } } Discuz.Data.UserCredits.UpdateUserExtCredits(uid, values); CreditsFacade.UpdateUserCredits(uid); //向应用同步扩展积分 for (int i = 0; i < values.Length; i++) { if (values[i] != 0.0) { Sync.UpdateCredits(uid, i + 1, values[i].ToString(), ""); } } ///更新用户积分 return(1); }
/// <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; isopenconnect = DiscuzCloud.GetCloudServiceEnableStatus("connect"); isbindconnect = isopenconnect ? DiscuzCloud.OnlineUserIsBindConnect(userid) : false; //确保头像可以取到 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 = CreditsFacade.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> /// <param name="extCredits">使用的积分规则</param> /// <param name="mount">更新数量,比如由上传2个附件引发此操作,那么此参数值应为2</param> /// <param name="creditsOperationType">积分操作类型,如发帖等</param> /// <param name="pos">加或减标志(正数为加,负数为减,通常被传入1或者-1)</param> /// <param name="allowMinus">是否允许被扣成负分,true允许,false不允许并且不进行扣分返回-1</param> /// <returns></returns> private static int UpdateUserExtCredits(int uid, float[] extCredits, int mount, CreditsOperationType creditsOperationType, int pos, bool allowMinus) { if (uid == -1)//如果当前用户为游客,则直接返回-1 { return(-1); } //float[] extCredits = Scoresets.GetUserExtCredits(creditsOperationType); float extCredit = 0; foreach (float e in extCredits)//此循环用于校验当前积分操作是否需要更新用户积分 { if (e != 0) { extCredit = e; break; } } if (extCredit == 0)//如果搜索积分设置中全部为0,即不操作积分,则直接返回1 { return(1); } // 如果要减扩展积分, 首先判断扩展积分是否足够被减 if (pos < 0) { //当不是删除主题或回复时 if (creditsOperationType != CreditsOperationType.PostTopic && creditsOperationType != CreditsOperationType.PostReply) { if (!allowMinus && !Discuz.Data.UserCredits.CheckUserCreditsIsEnough(uid, extCredits, pos, mount)) { return(-1); } } } else { if (creditsOperationType == CreditsOperationType.DownloadAttachment || creditsOperationType == CreditsOperationType.Search)//临时性解决用户搜索扣分可以为负数的问题,当积分系统被重新开发时,该判断代码可根据实际情况拿掉 { if (!allowMinus && !Discuz.Data.UserCredits.CheckUserCreditsIsEnough(uid, extCredits, -1, mount)) { return(-1); } } } Discuz.Data.UserCredits.UpdateUserExtCredits(uid, extCredits, pos, mount); for (int i = 0; i < extCredits.Length; i++) { if (extCredits[i] != 0.0) { Sync.UpdateCredits(uid, i + 1, extCredits[i].ToString(), ""); } } //根据积分公式更新用户积分,并且受分数变动影响有可能会更改用户所属的用户组 CreditsFacade.UpdateUserCredits(uid); ///更新用户积分 return(1); }