public static void AuditPost(string validate, string delete, string ignore, string fidlist) { //BBX.Data.Posts.AuditPost(postTableId, validate, delete, ignore, fidlist); if (!delete.IsNullOrWhiteSpace()) { var list = Post.FindAllByIDs(delete); list.Delete(); } if (!ignore.IsNullOrWhiteSpace()) { var list = Post.FindAllByIDs(ignore); list.ForEach(e => e.Invisible = -3); list.Update(); } if (!string.IsNullOrEmpty(validate)) { Post.Pass(validate); var list = Post.FindAllByIDs(validate); foreach (var item in list) { CreditsFacade.PostReply(item.PosterID, item.Forum.ReplycrEdits); } //foreach (DataRow dataRow in Posts.GetPostListByCondition(BaseConfigs.GetTablePrefix + "posts" + postTableId, "[pid] IN (" + validate + ")").Rows) //{ // IXForum fm = XForum.FindByID((Int32)dataRow["fid"]); // CreditsFacade.PostReply((Int32)dataRow["posterid"], fm.ReplycrEdits); //} } }
public static void UpdateUserCreditsAndVisit(IUser user, string ip) { CreditsFacade.UpdateUserCredits(user.ID); //BBX.Data.Users.UpdateUserLastvisit(uid, ip); user.LastIP = ip; user.LastVisit = DateTime.Now; (user as IEntity).Save(); }
public static int DeletePost(Post pi, bool reserveAttach, bool chanagePostStatistic) { if (!reserveAttach) { //Attachments.DeleteAttachmentByPid(pid); Attachment.FindAllByPid(pi.ID).Delete(); } //RateLogs.DeleteRateLog(pid); //PostInfo postInfo = GetPostInfo(postTableId, pid); //var pi = Post.FindByID(pid); CreditsFacade.DeletePost(pi, reserveAttach); //return BBX.Data.Posts.DeletePost(postTableId, pid, chanagePostStatistic); //return DatabaseProvider.GetInstance().DeletePost(postTableId, pid, chanagePostStatistic); return pi.Delete(); }
//public static void DeleteAttchType(string idList) //{ // if (Utils.IsNumericList(idList)) // { // BBX.Data.Attachments.DeleteAttchType(idList); // //XCache.Remove(CacheKeys.FORUM_FORUM_SETTING_ATTACHMENT_TYPE); // } //} //public static void AddAttchType(string extension, string maxSize) //{ // BBX.Data.Attachments.AddAttchType(extension, maxSize); // //XCache.Remove(CacheKeys.FORUM_FORUM_SETTING_ATTACHMENT_TYPE); // //Attachments.GetAttachmentType(); //} //public static void UpdateAttchType(string extension, string maxSize, int id) //{ // if (id > 0) // { // BBX.Data.Attachments.UpdateAttchType(extension, maxSize, id); // } //} //public static DataTable GetAttachList(string condition, string postName) //{ // return BBX.Data.Attachments.GetAttachList(condition, postName); //} //public static string SearchAttachment(int forumid, string posttablename, string filesizemin, string filesizemax, string downloadsmin, string downloadsmax, string postdatetime, string filename, string description, string poster) //{ // return BBX.Data.Attachments.SearchAttachment(forumid, posttablename, filesizemin, filesizemax, downloadsmin, downloadsmax, postdatetime, filename, description, poster); //} //public static bool UpdateAttachment(Attachment[] attachs, int topicId, int postId, PostInfo postInfo, ref StringBuilder returnMsg, int userId, GeneralConfigInfo config, UserGroup userGroupInfo) //{ // if (attachs == null) return false; // if (attachs.Length > config.Maxattachments) // { // returnMsg = new StringBuilder(); // returnMsg.AppendFormat("您添加了{0}个图片/附件,多于系统设置的{1}个.<br/>请重新编辑该帖并删除多余图片/附件.", attachs.Length, config.Maxattachments); // return false; // } // int num = Attachments.BindAttachment(attachs, topicId, postId, userId, userGroupInfo); // int[] array = new int[attachs.Length]; // int num2 = 0; // for (int i = 0; i < attachs.Length; i++) // { // //Attachments.UpdateAttachment(attachs[i]); // attachs[i].Save(); // array[i] = attachs[i].ID; // num2 = ((num2 != 3 && attachs[i].FileType.ToLower().StartsWith("image")) ? ((num2 == 1) ? 3 : 2) : ((num2 == 2) ? 3 : 1)); // } // string text = Attachments.FilterLocalTags(array, attachs, postInfo.Message); // if (text != postInfo.Message) // { // postInfo.Message = text; // postInfo.Pid = postId; // Posts.UpdatePost(postInfo); // } // if (num > 0) // { // CreditsFacade.UploadAttachments(userId, num); // } // Attachments.UpdateTopicAndPostAttachmentType(topicId, postId, num2); // return true; //} public static bool UpdateAttachment(Attachment[] attachs, int topicId, int postId, Post postInfo, ref StringBuilder returnMsg, int userId, GeneralConfigInfo config, UserGroup userGroupInfo) { if (attachs == null) { return(false); } if (attachs.Length > config.Maxattachments) { returnMsg = new StringBuilder(); returnMsg.AppendFormat("您添加了{0}个图片/附件,多于系统设置的{1}个.<br/>请重新编辑该帖并删除多余图片/附件.", attachs.Length, config.Maxattachments); return(false); } int num = Attachments.BindAttachment(attachs, topicId, postId, userId, userGroupInfo); int[] array = new int[attachs.Length]; int num2 = 0; for (int i = 0; i < attachs.Length; i++) { //Attachments.UpdateAttachment(attachs[i]); attachs[i].Save(); array[i] = attachs[i].ID; num2 = ((num2 != 3 && attachs[i].FileType.ToLower().StartsWith("image")) ? ((num2 == 1) ? 3 : 2) : ((num2 == 2) ? 3 : 1)); } string text = Attachments.FilterLocalTags(array, attachs, postInfo.Message); if (text != postInfo.Message) { postInfo.Message = text; //postInfo.Pid = postId; //Posts.UpdatePost(postInfo); postInfo.Save(); } if (num > 0) { CreditsFacade.UploadAttachments(userId, num); } UpdateTopicAndPostAttachmentType(topicId, postId, num2); return(true); }
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[] array = new float[8]; float[] array2 = array; string[] scores = Utils.SplitString(score, ","); string[] extcreditses = Utils.SplitString(extcredits, ","); //string postTableId = TableList.GetPostTableId(tid); for (int i = 0; i < extcreditses.Length; i++) { int extid = extcreditses[i].ToInt(-1); if (extid > 0 && extid < array2.Length) { array2[extid - 1] = (float)scores[i].ToInt(); //string[] array5 = Utils.SplitString(postidlist, ","); //for (int j = 0; j < array5.Length; j++) //{ // string text = array5[j]; // if (text.Trim() != string.Empty) // { // TopicAdmins.SetPostRate(postTableId, text.ToInt(), extcreditses[i].ToInt(), TypeConverter.StrToFloat(scores[i]), true); // } //} //AdminRateLogs.InsertLog(postidlist, userid, username, extid, TypeConverter.StrToFloat(scores[i]), reason); var arr = postidlist.SplitAsInt(); for (int k = 0; k < arr.Length; k++) { SetPostRate(arr[i], extcreditses[i].ToInt(), scores[i].ToDouble(), true); var log = RateLog.Create(arr[i], userid, username, extid, scores[i].ToInt(), reason); } } } //return CreditsFacade.UpdateUserExtCredits(TopicAdmins.GetUserListWithPostlist(tid, postidlist), array2); var ps = Post.FindAllByIDs(postidlist); var uids = ps.Join(Post._.PosterID, ","); return(CreditsFacade.UpdateUserExtCredits(uids, array2)); }
//public static void DeleteRelatedTopics(Int32 topicId) //{ // TopicTagCaches.DeleteRelatedTopics(topicId); //} //public static void CreateDebateTopic(DebateInfo debateTopic) //{ // BBX.Data.Debates.CreateDebateTopic(debateTopic); //} public static void PassAuditNewTopic(string ignore, string validate, string delete, Int32[] fids) { if ((!string.IsNullOrEmpty(ignore) && !Utils.IsNumericList(ignore)) || (!string.IsNullOrEmpty(validate) && !Utils.IsNumericList(validate)) || (!string.IsNullOrEmpty(delete) && !Utils.IsNumericList(delete)) || fids == null || fids.Length == 0) { return; } //BBX.Data.Topics.PassAuditNewTopic(postTableId, ignore, validate, delete, fidlist); if (!ignore.IsNullOrWhiteSpace()) { var list = Topic.FindAllByIDs(ignore); list.ForEach(e => e.DisplayOrder = -3); list.Save(); } if (!delete.IsNullOrWhiteSpace()) { var list = Topic.FindAllByIDs(delete); list.Delete(); } if (!string.IsNullOrEmpty(validate)) { //foreach (DataRow dataRow in Topics.GetTopicList(validate).Rows) //{ // CreditsFacade.PostTopic(TypeConverter.ObjectToInt(dataRow["posterid"]), Forums.GetForumInfo(TypeConverter.ObjectToInt(dataRow["fid"]))); //} //foreach (var tp in Topic.FindAllByTidsAndDisplayOrder(validate, -10)) //{ // CreditsFacade.PostTopic(tp.ID, Forums.GetForumInfo(tp.Fid)); //} var list = Topic.FindAllByIDs(validate); foreach (var item in list) { item.Post.Invisible = 0; item.Post.Save(); if (item.DisplayOrder > -10) { CreditsFacade.PostTopic(item.ID, item.Forum); } } } }
public static bool Search(int userid, DateTime lastsearchtime, int useradminid, UserGroup usergroupinfo, ref string msg) { var config = GeneralConfigInfo.Current; if (useradminid != 1 && DNTRequest.GetInt("keywordtype", 0) == 1 && !usergroupinfo.DisablePeriodctrl) { string str = ""; if (Scoresets.BetweenTime(config.Searchbanperiods, out str)) { msg = "在此时间段( " + str + " )内用户不可以进行全文搜索"; return(false); } } if (useradminid != 1) { if (!Statistic.CheckSearchCount(config.Maxspm)) { msg = "抱歉,系统在一分钟内搜索的次数超过了系统安全设置的上限,请稍候再试"; return(false); } //int num = Utils.StrDateDiffSeconds(lastsearchtime, config.Searchctrl); var ts = lastsearchtime.AddSeconds(config.Searchctrl) - DateTime.Now; if (ts.TotalSeconds > 0) { msg = "系统规定搜索间隔为" + config.Searchctrl + "秒, 您还需要等待 " + ts.TotalSeconds + " 秒"; return(false); } if (userid != -1 && CreditsFacade.Search(userid) == -1) { string str2 = ""; if (EPayments.IsOpenEPayments()) { str2 = "<br/><span><a href=\"usercpcreditspay.aspx\">点击充值积分</a></span>"; } msg = "您的积分不足, 不能执行搜索操作" + str2; return(false); } } return(true); }
public static void CompareOldAndNewModerator(string oldmoderators, string newmoderators, int currentfid) { if (oldmoderators == null || String.IsNullOrEmpty(oldmoderators)) { return; } string[] array = oldmoderators.Split(','); for (int i = 0; i < array.Length; i++) { string name = array[i]; if (name != "" && ("," + newmoderators + ",").IndexOf("," + name + ",") < 0) { var user = User.FindByName(name); if (user != null) { int uid = user.ID; int adminid = user.AdminID; //DataTable uidInModeratorsByUid = BBX.Data.Moderators.GetUidInModeratorsByUid(currentfid, uid); //if (uidInModeratorsByUid.Rows.Count == 0 && adminid != 1) if (adminid != 1 && Moderator.FindByUidAndFid(uid, currentfid) == null) { var ug = CreditsFacade.GetCreditsUserGroupId((float)user.Credits); //BBX.Data.Users.UpdateUserOnlineInfo(ug.ID, uid); //BBX.Data.Users.UpdateUserOtherInfo(ug.ID, uid); user.AdminID = 0; user.GroupID = ug.ID; user.Save(); var online = Online.FindByUserID(user.ID); if (online != null) { online.AdminID = 0; online.GroupID = ug.ID; online.Save(); } } } } } }
protected override void OnLoad(EventArgs e) { LoadTemplate(); base.OnLoad(e); if (this.pagename != "forumlist.aspx" && this.pagename != "forumindex.aspx") { this.oluserinfo = Online.UpdateInfo(); } else { try { this.oluserinfo = Online.UpdateInfo(); } catch { Thread.Sleep(2000); this.oluserinfo = Online.UpdateInfo(); } } if (this.config.PostTimeStorageMedia == 1 && Utils.GetCookie("lastposttime") != "") { var lptime = DateTime.MinValue; if (DateTime.TryParse(Utils.GetCookie("lastposttime"), out lptime)) { this.oluserinfo.LastPostTime = lptime; } } if (userid > 0) { if (oluserinfo == null) { XTrace.WriteLine("发现Cookie记录ID={0}已登录,但是未检测到登录对象", userid); } else if (userid != oluserinfo.UserID) { XTrace.WriteLine("发现Cookie记录ID={0}已登录,实际登录对象ID={1}", userid, oluserinfo.UserID); } } this.userid = this.oluserinfo.UserID; this.usergroupid = (int)this.oluserinfo.GroupID; this.username = this.oluserinfo.UserName; this.password = this.oluserinfo.Password; //2014-1-20 增加判断password是否为null,初次使用时使用QQ登陆,密码会为空 this.userkey = password != null ? (this.password.Length > 16) ? this.password.Substring(4, 8).Trim() : "" : ""; this.lastposttime = this.oluserinfo.LastPostTime; this.lastpostpmtime = this.oluserinfo.LastPostpmTime; this.lastsearchtime = this.oluserinfo.LastSearchTime; this.olid = this.oluserinfo.ID; //this.isopenconnect = DiscuzCloud.GetCloudServiceEnableStatus("connect"); if (this.userid > 0) { this.useravatar = Avatars.GetAvatarUrl(this.userid, AvatarSize.Small); } this.pmsound = ForumUtils.GetCookie("pmsound").ToInt(0); if (this.usergroupid == 4 || this.usergroupid == 5) { var user = BBX.Entity.User.FindByID(this.userid); //var user2 = user as IUser; if (user.GroupExpiry != 0 && user.GroupExpiry <= DateTime.Now.ToString("yyyyMMdd").ToInt(0)) { var creditsUserGroupId = CreditsFacade.GetCreditsUserGroupId((float)user.Credits); this.usergroupid = ((creditsUserGroupId.ID != 0) ? creditsUserGroupId.ID : this.usergroupid); //Users.UpdateUserGroup(this.userid, this.usergroupid); user.GroupID = usergroupid; user.Save(); } } this.usergroupinfo = UserGroup.FindByID(this.usergroupid); this.useradminid = this.usergroupinfo.RadminID; string userCreditsCookie = ForumUtils.GetUserCreditsCookie(this.userid, this.usergroupinfo.GroupTitle); if (userCreditsCookie != "") { string[] array = userCreditsCookie.Split(','); this.userinfotips = "<p><a class=\"drop\" onmouseover=\"showMenu(this.id);\" href=\"" + BaseConfigs.GetForumPath + "usercpcreditspay.aspx\" id=\"extcreditmenu\">" + array[0] + "</a> "; string text = this.userinfotips; this.userinfotips = text + "<span class=\"pipe\">|</span>用户组: <a class=\"xi2\" id=\"g_upmine\" href=\"" + BaseConfigs.GetForumPath + "usercp.aspx\">" + array[1].Split(':')[1] + "</a></p>"; this.userinfotips += "<ul id=\"extcreditmenu_menu\" class=\"p_pop\" style=\"display:none;\">"; for (int i = 2; i < array.Length; i++) { this.userinfotips += string.Format("<li><a> {0}</a></li>", array[i]); } this.userinfotips += "</ul>"; } this.mainnavigation = Nav.GetNavigationString(this.userid, this.useradminid); this.subnavigation = Nav.GetSubNavigation(); this.mainnavigationhassub = Nav.Root.Childs.GetItem <Int32>(Nav._.ID).ToArray(); if (this.config.Closed == 1 && this.pagename != "login.aspx" && this.pagename != "logout.aspx" && this.pagename != "register.aspx" && this.useradminid != 1) { this.ShowMessage(1); return; } if (!Utils.InArray(this.pagename, "attachment.aspx")) { //this.onlineusercount = Online.Meta.Count; var st = Online.GetStat(); this.onlineusercount = st.Total; } if (!this.ValidateUserPermission()) { return; } if (this.userid != -1 && !Utils.InArray(this.pagename, "attachment.aspx")) { Online.UpdateOnlineTime(this.config.Oltimespan, this.userid); } var tmp = Template.FindByID(this.templateid); this.templatepath = tmp.Directory; if (!String.IsNullOrEmpty(tmp.Url) && tmp.Url.StartsWithIgnoreCase("http://")) { imagedir = tmp.Url.TrimEnd('/') + "/images"; cssdir = tmp.Url.TrimEnd('/'); } else { imagedir = forumpath + "templates/" + tmp.Directory + "/images"; cssdir = forumpath + "templates/" + tmp.Directory; } if (!config.ImageServer.IsNullOrEmpty()) { imagedir = config.ImageServer.TrimEnd("/") + imagedir; } if (!config.CssServer.IsNullOrEmpty()) { cssdir = config.CssServer.TrimEnd("/") + cssdir; } this.topicidentifydir = this.forumpath + "images/identify"; this.posticondir = this.forumpath + "images/posticons"; this.jsdir = "javascript"; if (!config.JsServer.IsNullOrEmpty()) { jsdir = config.JsServer.EnsureEnd("/") + jsdir; } else { jsdir = this.rooturl + jsdir; } //this.nowdatetime = Utils.GetDateTime(); //this.ispost = DNTRequest.IsPost(); //this.isget = DNTRequest.IsGet(); //this.link = ""; //this.script = ""; this.templatelistboxoptions = Caches.GetTemplateListBoxOptionsCache(); string oldValue = string.Format("<li><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">", "", BaseConfigs.GetForumPath, this.templateid); string newValue = string.Format("<li class=\"current\"><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">", BaseConfigs.GetForumPath, this.templateid); this.templatelistboxoptions = this.templatelistboxoptions.Replace(oldValue, newValue); this.isLoginCode = this.config.Seccodestatus.Contains("login.aspx"); this.isseccode = (Utils.InArray(this.pagename, this.config.Seccodestatus) && this.usergroupinfo.IgnoresecCode == 0); this.headerad = Advertisement.GetOneHeaderAd("", 0); this.footerad = Advertisement.GetOneFooterAd("", 0); if (this.config.Allowchangewidth == 0) { Utils.WriteCookie("allowchangewidth", ""); } if (this.pagename != "website.aspx" && (Utils.GetCookie("allowchangewidth") == "0" || (string.IsNullOrEmpty(Utils.GetCookie("allowchangewidth")) && this.config.Showwidthmode == 1))) { this.isnarrowpage = true; } if (this.isseccode && this.ispost && !this.ValidateVerifyCode()) { return; } this.newtopicminute = this.config.Viewnewtopicminute; CanShow = true; this.ShowPage(); }
public static int DeleteTopics(string topicList, int subTractCredits, bool reserveAttach) { if (!Utils.IsNumericList(topicList)) { return(-1); } //DataTable topicList2 = Topics.GetTopicList(topicList); //var topicList2 = Topic.FindAllByTidsAndDisplayOrder(topicList, -10).ToDataTable(false); //if (topicList2 == null) //{ // return -1; //} //foreach (DataRow dataRow in topicList2.Rows) //{ // if (TypeConverter.ObjectToInt(dataRow["digest"]) > 0) // { // CreditsFacade.UnDigest(TypeConverter.ObjectToInt(dataRow["posterid"])); // } //} var list = Topic.FindAllByIDs(topicList); if (list.Count == 0) { return(-1); } foreach (var item in list) { if (item.Digest > 0) { CreditsFacade.UnDigest(item.PosterID); } } //var postList = Posts.GetPostList(topicList); var postList = Post.FindAllByTid(topicList.SplitAsInt(",")); if (postList != null && postList.Count != 0) { //int fid = 0; //IXForum forumInfo = null; foreach (var pt in postList) { //if (fid != pt.Fid) //{ // fid = pt.Fid; // forumInfo = Forums.GetForumInfo(fid); //} CreditsFacade.DeletePost(pt, reserveAttach); } } //int num2 = 0; //string[] postTableIdArray = Posts.GetPostTableIdArray(topicList); //for (int i = 0; i < postTableIdArray.Length; i++) //{ // string postTableId = postTableIdArray[i]; // //num2 = BBX.Data.TopicAdmins.DeleteTopicByTidList(topicList, postTableId); // num2 = DatabaseProvider.GetInstance().DeleteTopicByTidList(topicList, postTableId, true); //} if (list.Delete() > 0 && !reserveAttach) { //Attachments.DeleteAttachmentByTid(topicList); Attachment.FindAllByTids(topicList).Delete(); } return(list.Count); }
public static int SetDigest(string topiclist, int val) { //string us = TopicAdmins.GetUserListWithDigestTopiclist(topiclist, (val > 0) ? 1 : 0); //int num = TopicAdmins.SetTopicStatus(topiclist, "digest", val); //if (num > 0) var list = Topic.FindAllByIDs(topiclist); if (list.Count > 0) { list.ToList().ForEach(e => e.Digest = val); list.Save(); // 过滤列表 if (val > 0) { list = list.FindAll(e => e.Digest <= 0); } else { list = list.FindAll(e => e.Digest > 0); } foreach (var item in list) { var user = item.PostUser; if (user == null) { continue; } user.DigestPosts = Topic.GetDigestCount(user.ID); user.Save(); if (val > 0) { CreditsFacade.SetDigest(user.ID); } else { CreditsFacade.UnDigest(user.ID); } } //if (Utils.IsNumericList(us)) //{ // // 更新用户有多少个主题被评分 // //BBX.Data.Users.UpdateUserDigest(us); // var users = User.FindAllByIdList(us); // foreach (var item in users) // { // item.DigestPosts = Topic.GetDigestCount(item.ID); // item.Save(); // } //} //if (!string.IsNullOrEmpty(us) && Utils.IsNumericList(us)) //{ // string[] array = Utils.SplitString(us, ","); // for (int i = 0; i < array.Length; i++) // { // string str = array[i]; // if (intValue > 0) // { // CreditsFacade.SetDigest(str.ToInt()); // } // else // { // CreditsFacade.UnDigest(str.ToInt()); // } // } //} } return(list.Count); }