Esempio n. 1
0
 protected void LO2_LoggedOut(object sender, EventArgs e)
 {
     FormsAuthentication.SignOut();
     Session.Abandon();
     SnitzCookie.LogOut();
     Response.Redirect(Config.ForumUrl, true);
 }
Esempio n. 2
0
        protected static string TopicPageLinks(object replyCount, object topicId)
        {
            string retVal = "";

            if (!Config.ShowPaging)
            {
                return(retVal);
            }

            if ((int)replyCount > Config.TopicPageSize)
            {
                int pageNum = (int)replyCount / Config.TopicPageSize;
                int rem     = (int)replyCount % Config.TopicPageSize;
                if (rem > 0)
                {
                    pageNum += 1;
                }
                retVal = " ... ";
                for (int x = Math.Max(2, SnitzCookie.LastTopicPage((int)topicId) + 1); x < pageNum + 1; x++)
                {
                    retVal += "<a href='/Content/Forums/topic.aspx?TOPIC=" + topicId + "&whichpage=" + x + "'><span class='topicPageLnk' >" + x + "</span></a> ";
                }
            }
            return(retVal);
        }
Esempio n. 3
0
    private void MarkReadClick(object sender, ImageClickEventArgs e)
    {
        if (IsAuthenticated)
        {
            if (Session["_LastVisit"] == null)
            {
                HttpContext.Current.Session.Add("_LastVisit", hdnLastOpened.Value);
            }
            else
            {
                Session["_LastVisit"] = hdnLastOpened.Value;
                Session["_LastVisit"] = hdnLastOpened.Value;
            }
            var since = SnitzCookie.GetLastVisitDate();
            if (since != null)
            {
                SnitzCookie.SetLastVisitCookie("0");
            }

            Response.Redirect(Request.RawUrl);
        }
        else
        {
            Session["_LastVisit"] = DateTime.UtcNow.ToForumDateStr();
        }
    }
Esempio n. 4
0
    protected void DdlPageRefreshSelectedIndexChanged(object sender, EventArgs e)
    {
        //store the variable in a cookie.
        SnitzCookie.SetActiveRefresh(ddlPageRefresh.SelectedIndex.ToString());

        if (ddlPageRefresh.SelectedIndex == 0)
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "clearrefresh", "cancelRefresh();", true);
        }
        else if (ddlPageRefresh.SelectedValue != null)
        {
            int reloadTime = 60000 * Convert.ToInt32(ddlPageRefresh.SelectedValue);
            if (reloadTime > 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "refresh", "setRefresh('" + reloadTime + "');", true);
            }
        }
    }
Esempio n. 5
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (Session["CurrentProfile"] != null)
        {
            Session.Remove("CurrentProfile");
        }
        Session.Timeout = 20;

        ActiveTable.PageSize = Config.TopicPageSize;
        if (!Page.IsPostBack)
        {
            var TopicSinceIndex = SnitzCookie.GetTopicSince();
            var refreshIndex    = SnitzCookie.GetActiveRefresh();

            if (TopicSinceIndex != null)
            {
                ddlTopicsSince.SelectedIndex = Int32.Parse(TopicSinceIndex);
            }
            if (refreshIndex != null)
            {
                ddlPageRefresh.SelectedIndex = Int32.Parse(refreshIndex);
                if (ddlPageRefresh.SelectedValue != "")
                {
                    int reloadTime = 60000 * Convert.ToInt32(ddlPageRefresh.SelectedValue);
                    ScriptManager.RegisterClientScriptBlock(this, GetType(), "refresh", "setRefresh('" + reloadTime + "');", true);
                }
            }
        }
        string pagedescription = String.Format("{0}:{1}", Config.ForumTitle, webResources.ttlActivePage);

        metadescription.Text = String.Format("<meta name=\"description\" content=\"{0}\">", pagedescription.Substring(0, Math.Min(160, pagedescription.Length)));

        TopicUpdatePanel.Triggers.Add(new AsyncPostBackTrigger {
            ControlID = ddlPageRefresh.UniqueID
        });
        TopicUpdatePanel.Triggers.Add(new AsyncPostBackTrigger {
            ControlID = ddlTopicsSince.UniqueID
        });
        if (Config.TopicAvatar)
        {
            FolderImg.Visible = false;
        }
    }
Esempio n. 6
0
        private void PagerLinkClick(object sender, EventArgs e)
        {
            var lnk = sender as LinkButton;

            if (lnk != null)
            {
                if (lnk.Text.IsNumeric())
                {
                    CurrentPage = int.Parse(lnk.Text) - 1;
                }
                else
                {
                    if (lnk.Text.Contains("&gt;"))
                    {
                        CurrentPage += 1;
                    }
                    else if (lnk.Text.Contains("&lt;"))
                    {
                        CurrentPage -= 1;
                    }
                    else if (lnk.Text.Contains("&raquo;"))
                    {
                        CurrentPage = ReplyPager.PageCount - 1;
                    }
                    else
                    {
                        CurrentPage = 0;
                    }
                }
                if (CurrentPage < 0)
                {
                    CurrentPage = 0;
                }
                if (CurrentPage >= ReplyPager.PageCount)
                {
                    CurrentPage = ReplyPager.PageCount - 1;
                }
            }
            SnitzCookie.TrackIt(_topic.Id, CurrentPage);
            ReplyPager.CurrentIndex = CurrentPage;
        }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack)
        {
            string postbackbtn = Request.Form["__EVENTTARGET"];
            string argument    = Request.Form["__EVENTARGUMENT"];
            int    id;
            switch (postbackbtn)
            {
            case "LockTopic":
                id = Convert.ToInt32(argument);
                LockTopic(id);
                break;

            case "UnLockTopic":
                id = Convert.ToInt32(argument);
                UnLockTopic(id);
                break;

            case "DeleteTopic":
                id = Convert.ToInt32(argument);
                DeleteTopic(id);
                break;
            }
        }
        if (!Page.IsPostBack)
        {
            hdnLastOpened.Value = DateTime.UtcNow.ToForumDateStr();
            Session["FORUM"]    = "";
            lblHotTopic.Text    = string.Format(webResources.lblHotTopics, Config.HotTopicNum);
        }
        if (ddlPageRefresh.SelectedIndex == 0)
        {
            SnitzCookie.SetActiveRefresh("0");
            ScriptManager.RegisterStartupScript(this, GetType(), "clearrefresh", "cancelRefresh();", true);
        }
        BindActiveTopics();
    }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CurrentPage == -1)
            {
                CurrentPage = 0;
            }


            if (Request.Form["__EVENTTARGET"] != null)
            {
                //let's check what async call posted back and see if we need to refresh the page
                string target        = Request.Form["__EVENTTARGET"];
                var    listOfStrings = new List <string> {
                    "TopicSend", "DeleteTopic", "DeleteReply"
                };
                bool refreshAfterPostback = listOfStrings.Any(target.EndsWith);
                if (refreshAfterPostback)
                {
                    ReplyPager.CurrentIndex = CurrentPage;
                }
            }

            if (!Page.IsPostBack)
            {
                TopicInfo topic   = _topic;
                string    session = "FORUM" + topic.ForumId;

                if (IsAuthenticated)
                {
                    //do we have access to this forum
                    if (!Forums.IsUserInForumRole(Member.Username, topic.Forum.Id))
                    {
                        if (Session[session] == null || Session[session].ToString() != "true")
                        {
                            if (topic.Forum.Password != null &&
                                !String.IsNullOrEmpty(topic.Forum.Password.Trim()))
                            {
                                if (Session[session] == null || Session[session].ToString() == "")
                                {
                                    Response.Redirect("~/Content/Forums/forum.aspx?FORUM=" + topic.ForumId);
                                }
                                else
                                {
                                    if (Session[session].ToString() != "true")
                                    {
                                        throw new SecurityException("You are not authorised to view this forum");
                                    }
                                }
                            }
                        }
                        if (topic.Forum.Roles.Contains("All") || topic.Forum.Roles.Count == 0)
                        {
                            if (String.IsNullOrEmpty(topic.Forum.Password))
                            {
                                WriteShareItScriptTags();
                            }
                        }
                    }
                    else
                    {
                        Session[session] = "true";
                    }
                }
                else if (topic.Forum.Roles.Contains("All") || topic.Forum.Roles.Count == 0)
                {
                    Session[session] = "true";
                    WriteShareItScriptTags();
                }
                else if (topic.Forum.Roles.Count > 0 && !topic.Forum.Roles.Contains("All"))
                {
                    if (Session[session] == null || Session[session].ToString() != "true")
                    {
                        throw new SecurityException("You must be logged in to view this forum");
                    }
                }

                Topics.UpdateViewCount(_topic.Id);
                int pagejump = 0;

                if (Request.QueryString["LastVisit"] != null)
                {
                    pagejump = SnitzCookie.LastTopicPage(topic.Id);
                }
                if (pagejump == 0)
                {
                    if ((Request.Params["whichpage"] != null))
                    {
                        pagejump = Int32.Parse(Request.Params["whichpage"]);
                    }
                }
                if (pagejump != 0)
                {
                    if (pagejump == -1)
                    {
                        //jump to last page
                        int pagenum = topic.ReplyCount / Config.TopicPageSize;
                        if (topic.ReplyCount % Config.TopicPageSize == 0)
                        {
                            if (topic.ReplyCount > 0)
                            {
                                pagenum -= 1;
                            }
                        }
                        CurrentPage             = pagenum;
                        ReplyPager.CurrentIndex = pagenum;
                    }
                    else
                    {
                        int pagenum = pagejump - 1;
                        CurrentPage             = pagenum;
                        ReplyPager.CurrentIndex = pagenum;
                    }
                }
                else
                {
                    ReplyPager.CurrentIndex = CurrentPage;
                }
                SnitzCookie.TrackIt(_topic.Id, CurrentPage);
            }

            //TopicView.Visible = ReplyPager.CurrentIndex == 0;

            if (Request.Params["reply"] != null)
            {
                string reply = Request.Params["reply"];
                if (reply != "0")
                {
                    JumpToReply(reply);
                }
            }
        }
Esempio n. 9
0
 protected void DdlTopicsSinceSelectedIndexChanged(object sender, EventArgs e)
 {
     SnitzCookie.SetTopicSince(ddlTopicsSince.SelectedIndex.ToString());
 }