Ejemplo n.º 1
0
        public void Approval(string topicid, string replyid, string jsonform)
        {
            var form = HttpUtility.UrlDecode(jsonform);

            System.Collections.Specialized.NameValueCollection formresult = HttpUtility.ParseQueryString(form);
            string reason     = formresult["ctl00$txtReason"];
            int    adminmodid = Convert.ToInt32(formresult["ctl00$hdnModerator"]);

            if (!String.IsNullOrEmpty(topicid))
            {
                Topics.SetTopicStatus(Convert.ToInt32(topicid), (int)Enumerators.PostStatus.Open);
            }
            if (!String.IsNullOrEmpty(replyid))
            {
                Replies.SetReplyStatus(Convert.ToInt32(replyid), (int)Enumerators.PostStatus.Open);
                ReplyInfo reply = Replies.GetReply(Convert.ToInt32(replyid));
                var       topic = Topics.GetTopic(Convert.ToInt32(reply.TopicId));
                topic.UnModeratedReplies -= 1;
                Topics.Update(topic);
            }
            if (!string.IsNullOrEmpty(reason) && Config.UseEmail)
            {
                ProcessModeration(1, Convert.ToInt32(topicid), Convert.ToInt32(replyid), adminmodid, reason);
            }
        }
Ejemplo n.º 2
0
        private void SetupForEditMessage()
        {
            string msg = String.Empty;

            //fetch original message from db
            switch (_type)
            {
            case "reply":
                ReplyInfo reply = Replies.GetReply(_recId);
                SubjectDiv.Visible = false;
                ForumDiv.Visible   = false;
                msg = HttpUtility.HtmlDecode(reply.Message);
                break;

            case "topics":
                ForumDiv.Visible = (IsAdministrator || (_inModeratedList && !Config.RestrictModeratorMove));

                ForumDropDown.SelectedValue = _thisTopic.ForumId.ToString();
                SubjectDiv.Visible          = true;
                tbxSubject.Text             = HttpUtility.HtmlDecode(_thisTopic.Subject);
                string poll = "";
                if (_thisTopic.PollId != null)
                {
                    poll = Polls.GetTopicPollString(_thisTopic.PollId);
                }
                msg = poll + HttpUtility.HtmlDecode(_thisTopic.Message);
                break;
            }

            Message.Text = msg;
        }
Ejemplo n.º 3
0
        public void ProcessTopicSubscriptions(int topicid, int replyid, HttpContext context)
        {
            TopicInfo topic = Topics.GetTopic(topicid);
            ReplyInfo reply = Replies.GetReply(replyid);

            var t = new Thread(() => SendSubscriptions(Enumerators.Subscription.TopicSubscription, topic, reply, context))
            {
                IsBackground = true
            };

            t.Start();
        }
Ejemplo n.º 4
0
        public void AppendItems(System.Text.StringBuilder oBuilder, ForumInfo forum)
        {
            foreach (TopicInfo row in Forums.GetForumTopics(forum.Id, 0, 10).OrderByDescending(t => t.LastPostDate))
            {
                int       topicId = row.Id;
                TopicInfo topic   = Topics.GetTopic(topicId);
                string    sTitle  = topic.Subject;
                string    sGuid   = string.Format("{0}Content/Forums/Topic/{1}", Config.ForumUrl, topicId);
                string    sLink   = string.Format("{0}Content/Forums/topic.aspx?TOPIC={1}&whichpage=-1", Config.ForumUrl, topicId);
                if (topic.LastReplyId > 0)
                {
                    sLink += "#" + topic.LastReplyId;
                }

                string sDescription = topic.Message; //topic.Message.Length > 512 ? topic.Message.Substring(0, 512) + " ... " : topic.Message;
                string sPubDate     = topic.LastPostDate.Value.ToISO8601Date(false, null);
                string author       = topic.AuthorName;
                if (topic.LastReplyId > 0)
                {
                    if (topic.LastReplyId != null)
                    {
                        ReplyInfo rep = Replies.GetReply((int)topic.LastReplyId);
                        author       = rep.AuthorName;
                        sDescription = rep.Message;  //rep.Message.Length > 256 ? rep.Message.Substring(0, 256) + " ... " : rep.Message;
                    }
                }

                oBuilder.Append("<item>");
                oBuilder.Append("<category>");
                oBuilder.Append(forum.Subject.WrapCData());
                oBuilder.Append("</category>");
                oBuilder.Append("<title>");
                oBuilder.Append(sTitle.WrapCData());
                oBuilder.Append("</title>");
                oBuilder.Append("<author>");
                oBuilder.Append(author);
                oBuilder.Append("</author>");
                oBuilder.Append("<link>");
                oBuilder.Append(sLink);
                oBuilder.Append("</link>");
                oBuilder.Append("<guid isPermaLink=\"true\">");
                oBuilder.Append(sGuid);
                oBuilder.Append("</guid>");
                oBuilder.Append("<description>");
                oBuilder.Append(sDescription.ParseTags().WrapCData());
                oBuilder.Append("</description>");
                oBuilder.Append("<pubDate>");
                oBuilder.Append(sPubDate);
                oBuilder.Append("</pubDate>");
                oBuilder.Append("</item>");
            }
        }
Ejemplo n.º 5
0
        private string GetQuotedMessage()
        {
            switch (_type)
            {
            case "reply":
                ReplyInfo reply = Replies.GetReply(_recId);
                return(String.Format("[quote=\"{0}\"]{1}[/quote]", reply.AuthorName, reply.Message));

            case "topics":
                return(String.Format("[quote=\"{0}\"]{1}[/quote]", _thisTopic.AuthorName, _thisTopic.Message));
            }
            return(String.Empty);
        }
Ejemplo n.º 6
0
        public static Message ApplyAndDisplay(ArcadeUser user, DailyResultFlag flag)
        {
            long           reward = Reward;
            string         header = $"{Reward:##,0}";
            ImmutableColor color  = ImmutableColor.GammaGreen;
            var            icon   = "+ 💸";

            switch (flag)
            {
            case DailyResultFlag.Cooldown:
                TimeSpan sinceLast = StatHelper.SinceLast(user, CooldownVars.Daily);
                TimeSpan rem       = Cooldown - sinceLast;
                DateTime time      = DateTime.UtcNow.Add(rem);

                color  = GammaPalette.Amber[Gamma.Max];
                header = Format.Countdown(rem);
                icon   = Icons.GetClock(time.Hour);
                break;

            case DailyResultFlag.Reset:
                color = GammaPalette.NeonRed[Gamma.Max];
                user.SetVar(Stats.DailyStreak, 0);
                break;

            case DailyResultFlag.Bonus:
                color   = GammaPalette.Glass[Gamma.Max];
                header += $" + {Bonus:##,0}";
                reward += Bonus;
                break;
            }

            if (flag != DailyResultFlag.Cooldown)
            {
                user.SetVar(CooldownVars.Daily, DateTime.UtcNow.Ticks);
                user.AddToVar(Stats.DailyStreak);
                user.AddToVar(Stats.TimesDaily);
                Var.SetIfGreater(user, Stats.LongestDailyStreak, Stats.DailyStreak);
                user.Give(reward);
            }

            var message  = new MessageBuilder();
            var embedder = Embedder.Default;

            embedder.Color   = color;
            embedder.Header  = $"**{icon} {header}**";
            message.Content  = $"*\"{Replies.GetReply(flag)}\"*";
            message.Embedder = embedder;

            return(message.Build());
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Data != null)
            {
                string[] ids = ((string)Data).Split(',');
                if (ids.Any())
                {
                    if (ids.Count() == 3)
                    {
                        ReplyInfo reply = Replies.GetReply(Convert.ToInt32(ids[2]));
                        lblPosted.Text   = String.Format("Posted by:{0} on {1}", reply.AuthorName, reply.Date);
                        msgBody.CssClass = "bbcode";
                        msgBody.Text     = reply.Message;
                        hdnTopic.Value   = ids[1];
                        hdnReply.Value   = reply.Id.ToString();
                    }
                    else
                    {
                        TopicInfo topic = Topics.GetTopic(Convert.ToInt32(ids[1]));
                        lblPosted.Text   = String.Format("Posted by:{0} on {1}", topic.AuthorName, topic.Date);
                        msgBody.CssClass = "bbcode";
                        msgBody.Text     = topic.Message;
                        hdnTopic.Value   = topic.Id.ToString();
                        hdnReply.Value   = "0";
                    }
                }
                var mod = Membership.GetUser(Page.User.Identity.Name);
                hdnModerator.Value       = mod.ProviderUserKey.ToString();
                btnApprove.OnClientClick = String.Format("ApprovePost('{0}','{1}');return false;", hdnTopic.Value,
                                                         hdnReply.Value);
                btnHold.OnClientClick = String.Format("OnHold('{0}','{1}');return false;", hdnTopic.Value,
                                                      hdnReply.Value);
                btnDelete.OnClientClick = String.Format("DeletePost('{0}','{1}');return false;", hdnTopic.Value,
                                                        hdnReply.Value);
                pnlMessage.Visible = Convert.ToBoolean(ids[0]);
            }

            string theme = Session["PageTheme"] == null ? "Light" : Session["PageTheme"].ToString();

            if (pnlMessage.Visible)
            {
                this.StartupScript =
                    "$('.bbcode').each(function () {$(this).html(parseBBCode(parseEmoticon($(this).text(), '" + theme +
                    "')));});";
            }
        }
Ejemplo n.º 8
0
        public void BookMarkReply(int replyid, int page)
        {
            ReplyInfo     r    = Replies.GetReply(replyid);
            TopicInfo     rt   = Topics.GetTopic(r.TopicId);
            var           user = HttpContext.Current.User.Identity.Name;
            ProfileCommon prof = ProfileCommon.GetUserProfile(user);

            string           rurl       = String.Format("~/Content/Forums/topic.aspx?TOPIC={0}&whichpage={1}&#{2}", r.TopicId, page + 1, r.Id);
            List <SnitzLink> rbookmarks = prof.BookMarks;

            if (!rbookmarks.Contains(new SnitzLink(rt.Subject, rurl, 0)))
            {
                rbookmarks.Add(new SnitzLink(rt.Subject, rurl, rbookmarks.Count));
                prof.BookMarks = rbookmarks;
                prof.Save();
            }
        }
Ejemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Data != null)
            {
                string[] data = Regex.Split(Data.ToString(), ",", RegexOptions.ExplicitCapture);
                _replyid = Convert.ToInt32(data[0]);
                ReplyInfo reply   = Replies.GetReply(_replyid);
                int       topicid = reply.TopicId;

                splitTopicId.Value = topicid.ToString();
                if (data.Length > 1)
                {
                    _sortDirection = data[1];
                }
                _topic = Topics.GetTopic(Convert.ToInt32(topicid));
                ddlForum.DataSource = Forums.GetAllForums();
                ddlForum.DataBind();
                if (!IsPostBack)
                {
                    ddlForum.SelectedValue = _topic.ForumId.ToString();
                }
                ddlSort.SelectedValue = _sortDirection;
                switch (_sortDirection)
                {
                case "asc":
                    ddlSort.Attributes.Add("onchange", String.Format(
                                               "mainScreen.LoadServerControlHtml('Split Topic',{{'pageID':6,'data':'{0},desc'}}, 'methodHandlers.BeginRecieve');return false;", _replyid));
                    break;

                case "desc":
                    ddlSort.Attributes.Add("onchange", String.Format(
                                               "mainScreen.LoadServerControlHtml('Split Topic',{{'pageID':6,'data':'{0},asc'}}, 'methodHandlers.BeginRecieve');return false;", _replyid));

                    break;
                }
                BindForm();
                StartupScript = "jQuery(\"abbr.timeago\").timeago();";
            }
        }
Ejemplo n.º 10
0
        private void ProcessModeration(int mode, int topicid, int replyid, int adminmodid, string comments)
        {
            ReplyInfo      reply = null;
            MembershipUser author;

            var moderator = Membership.GetUser(adminmodid);

            int forumId;

            var topic = Topics.GetTopic(topicid);

            if (replyid > 0)
            {
                reply = Replies.GetReply(replyid);
            }
            if (reply == null)
            {
                forumId = topic.ForumId;
                author  = Membership.GetUser(topic.AuthorId, false);
            }
            else
            {
                forumId = reply.ForumId;
                author  = Membership.GetUser(reply.AuthorId, false);
            }
            var forum = Forums.GetForum(forumId);

            var strSubject = new StringBuilder();

            strSubject.AppendFormat("{0} - Your post ", Regex.Replace(Config.ForumTitle, @"&\w+;", ""));
            if (mode == 1)
            {
                strSubject.AppendLine("has been approved ");
            }
            else if (mode == 2)
            {
                strSubject.AppendLine("has been placed on hold ");
            }
            else
            {
                strSubject.AppendLine("has been rejected ");
            }
            var strMessage = new StringBuilder();

            strMessage.AppendFormat("Hello {0}.", author.UserName).AppendLine().AppendLine();
            strMessage.Append("You made a ");

            if (replyid == 0)
            {
                strMessage.Append("post ");
            }
            else
            {
                strMessage.Append("reply to the post ");
            }
            strMessage.AppendFormat("in the {0} forum entitled {1}. {2} has decided to ", forum.Subject, moderator.UserName);

            if (mode == 1)
            {
                strMessage.Append("approve your post ");
            }
            else if (mode == 2)
            {
                strMessage.Append("place your post on hold ");
            }
            else
            {
                strMessage.Append("reject your post ");
            }
            strMessage.AppendLine("for the following reason:").AppendLine();
            strMessage.AppendLine(comments).AppendLine();
            strMessage.AppendFormat("If you have any questions, please contact {0} at {1}", moderator.UserName, moderator.Email).AppendLine();

            var mailsender = new SnitzEmail
            {
                toUser   = new MailAddress(author.Email, author.UserName),
                FromUser = "******",
                IsHtml   = false,
                subject  = strSubject.ToString(),
                msgBody  = strMessage.ToString()
            };

            mailsender.Send();
        }
Ejemplo n.º 11
0
        public string SplitTopic(string jsonform)
        {
            var test = HttpUtility.UrlDecode(jsonform);

            System.Collections.Specialized.NameValueCollection formresult = HttpUtility.ParseQueryString(test);
            var replyIDs = new List <int>();

            foreach (string key in formresult.AllKeys)
            {
                if (key.EndsWith("cbxRow"))
                {
                    replyIDs.Add(Convert.ToInt32(formresult[key]));
                }
            }

            int    topicid = Convert.ToInt32(formresult["ctl00$splitTopicId"]);
            int    forumId = Convert.ToInt32(formresult["ctl00$ddlForum"]);
            string sort    = formresult["ctl00$ddlSort"];

            string subject = formresult["ctl00$tbxSubject"];

            if (String.IsNullOrEmpty(subject))
            {
                return("No subject supplied");
            }

            TopicInfo oldtopic = Topics.GetTopic(topicid);
            ForumInfo forum    = Forums.GetForum(forumId);

            if (replyIDs.Count == 0)
            {
                return("No replies selected");
            }
            int       lastreplyid = sort == "desc" ? replyIDs[replyIDs.Count - 1] : replyIDs[0];
            ReplyInfo lastreply   = Replies.GetReply(lastreplyid);

            //get the reply details
            var topic = new TopicInfo
            {
                Subject            = subject,
                Message            = lastreply.Message,
                Date               = lastreply.Date,
                UseSignatures      = lastreply.UseSignatures,
                IsSticky           = false,
                PosterIp           = lastreply.PosterIp,
                Views              = 0,
                ReplyCount         = replyIDs.Count - 1,
                Status             = (int)Enumerators.PostStatus.Open,
                UnModeratedReplies = 0,
                ForumId            = forumId,
                AuthorId           = lastreply.AuthorId,
                CatId              = forum.CatId
            };

            bool isModeratedForum = forum.ModerationLevel != (int)Enumerators.Moderation.UnModerated;

            if (isModeratedForum)
            {
                if (forum.ModerationLevel == (int)Enumerators.Moderation.AllPosts ||
                    forum.ModerationLevel == (int)Enumerators.Moderation.Topics)
                {
                    topic.Status = (int)Enumerators.PostStatus.UnModerated;
                }
            }

            int newtopicid = Topics.Add(topic);

            //delete the reply used as topic
            Replies.DeleteReply(lastreplyid);
            //move the other replies to this topic
            Replies.MoveReplies(newtopicid, replyIDs);
            //update the original topic count/dates
            Topics.Update(oldtopic.Id);

            Snitz.BLL.Admin.UpdateForumCounts();

            return("Selected replies were moved to a new topic");
        }
Ejemplo n.º 12
0
        public Message ApplyAndDisplay(ArcadeUser user)
        {
            ImmutableColor color = ImmutableColor.GammaGreen;
            string         type  = IsSuccess ? "+" : "-";
            long           value = IsSuccess ? Reward : Wager;

            user.AddToVar(TickStats.TotalBet, Wager);
            user.AddToVar(TickStats.TimesPlayed);

            user.ChipBalance -= Wager;

            switch (Flag)
            {
            case TickResultFlag.Exact:
            case TickResultFlag.Win:
                user.SetVar(TickStats.CurrentLossStreak, 0);

                user.AddToVar(TickStats.TimesWon);
                user.AddToVar(TickStats.TotalWon, Reward);

                if (ExpectedTick == ActualTick)
                {
                    user.AddToVar(TickStats.TimesWonExact);
                }

                user.AddToVar(TickStats.CurrentWinStreak);
                user.AddToVar(TickStats.CurrentWinAmount, Reward);

                Var.SetIfGreater(user, TickStats.LongestWin, TickStats.CurrentWinStreak);
                Var.SetIfGreater(user, TickStats.LargestWin, TickStats.CurrentWinAmount);
                Var.SetIfGreater(user, TickStats.LargestWinSingle, Reward);
                break;

            case TickResultFlag.Lose:
                Var.Clear(user, TickStats.CurrentWinStreak, TickStats.CurrentWinAmount);
                user.AddToVar(TickStats.TimesLost);
                user.AddToVar(TickStats.CurrentLossStreak);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(Flag));
            }

            if (IsSuccess)
            {
                user.ChipBalance += CurrencyHelper.BoostValue(user, Reward, BoostType.Chips);
            }

            string header = $"**{type} 🧩 {value:##,0}**";

            string content = Replies.GetReply(Flag, user, this);
            //GetQuote(ExpectedTick, ActualTick, Multiplier, Reward, IsSuccess);

            var embedder = new Embedder
            {
                Header = header,
                Color  = color
            };

            var builder = new MessageBuilder();

            builder.WithEmbedder(embedder)
            .WithContent(content);

            return(builder.Build());
        }
Ejemplo n.º 13
0
        public Message ApplyAndDisplay(ArcadeUser user)
        {
            var builder  = new MessageBuilder();
            var embedder = new Embedder();

            string         icon  = "💸";
            string         type  = "+";
            string         quote = Replies.GetReply(Flag, user, this);
            long           value = Reward;
            ImmutableColor color = ImmutableColor.GammaGreen;

            Var.Add(user, 1, GimiStats.TimesPlayed);

            switch (Flag)
            {
            case GimiResultFlag.Win:
            case GimiResultFlag.Gold:
                Var.Clear(user, GimiStats.CurrentCurseStreak, GimiStats.CurrentLossStreak, GimiStats.CurrentLossAmount);
                Var.Add(user, 1, GimiStats.TimesWon, GimiStats.CurrentWinStreak);
                Var.Add(user, Reward, GimiStats.TotalWon, GimiStats.CurrentWinAmount);
                Var.SetIfGreater(user, GimiStats.LongestWin, GimiStats.CurrentWinStreak);
                Var.SetIfGreater(user, GimiStats.LargestWin, GimiStats.CurrentWinAmount);

                if (Flag == GimiResultFlag.Gold)
                {
                    icon  = "💎";
                    type  = "+";
                    color = GammaPalette.Glass[Gamma.Max];

                    ItemHelper.GiveItem(user, Items.PocketLawyer);

                    if (RandomProvider.Instance.Next(0, 1001) == 1000)
                    {
                        ItemHelper.GiveItem(user, Items.PaletteGold);
                    }

                    Var.Add(user, 1, GimiStats.TimesGold, GimiStats.CurrentGoldStreak);
                    Var.SetIfGreater(user, GimiStats.LongestGold, GimiStats.CurrentGoldStreak);
                }
                else
                {
                    Var.Clear(user, GimiStats.CurrentGoldStreak);
                    Reward = CurrencyHelper.BoostValue(user, Reward, BoostType.Money);
                }
                long debt = user.Debt;
                user.Give(Reward);

                if (debt > Reward)
                {
                    icon  = "📃";
                    type  = "-";
                    quote = Replies.Recover.Length > 0 ? (string)Randomizer.Choose(Replies.Recover) : Replies.RecoverGeneric;
                }
                else if (debt > 0 && Reward - debt == 0)
                {
                    icon  = "📧";
                    type  = "";
                    quote = Replies.EvenGeneric;
                }

                break;

            case GimiResultFlag.Lose:
            case GimiResultFlag.Curse:
                type  = "-";
                color = ImmutableColor.NeonRed;

                Var.Clear(user, GimiStats.CurrentGoldStreak, GimiStats.CurrentWinStreak, GimiStats.CurrentWinAmount);
                Var.Add(user, 1, GimiStats.TimesLost, GimiStats.CurrentLossStreak);
                Var.Add(user, Reward, GimiStats.TotalLost, GimiStats.CurrentLossAmount);
                Var.SetIfGreater(user, GimiStats.LongestLoss, GimiStats.CurrentLossStreak);
                Var.SetIfGreater(user, GimiStats.LargestLoss, GimiStats.CurrentLossAmount);

                if (Flag == GimiResultFlag.Curse)
                {
                    icon  = "🌕";
                    type  = "-";
                    color = GammaPalette.Alconia[Gamma.Standard];

                    Var.Add(user, 1, GimiStats.TimesCursed, GimiStats.CurrentCurseStreak);
                    Var.SetIfGreater(user, GimiStats.LongestCurse, GimiStats.CurrentCurseStreak);
                }
                else
                {
                    Var.Clear(user, GimiStats.CurrentCurseStreak);
                    Reward = CurrencyHelper.BoostValue(user, Reward, BoostType.Money);
                }

                long balance = user.Balance;
                user.Take(Reward);

                if (balance < Reward)
                {
                    icon  = "📃";
                    type  = "+";
                    value = Reward - balance;
                    quote = Replies.Debt.Length > 0 ? (string)Randomizer.Choose(Replies.Debt) : Replies.DebtGeneric;
                }
                else if (balance > 0 && Reward - balance == 0)
                {
                    icon  = "📧";
                    value = Reward - balance;
                    type  = "";
                    quote = Replies.EvenGeneric;
                }
                break;
            }

            if (!string.IsNullOrWhiteSpace(type))
            {
                type += ' ';
            }

            string header  = $"**{type}{icon} {value:##,0}**";
            string content = $"*\"{quote}\"*";

            embedder.Header  = header;
            embedder.Color   = color;
            builder.Embedder = embedder;
            builder.Content  = content;

            return(builder.Build());
        }