Пример #1
0
        protected override void Page_Show()
        {
            if (YRequest.GetQueryString("action") == "logout")
            {
                HttpCookie admincookie = currentcontext.Request.Cookies["cmsntadmin"];
                if (admincookie != null)
                {
                    admincookie.Expires = DateTime.Now.AddYears(-1);
                    currentcontext.Response.AppendCookie(admincookie);
                }
                ShowMsg("注销管理状态", "管理员登录注销成功,跳转到前台首页.", "", "index.aspx");
            }
            UserInfo userinfo = GetUserInfo();

            if (userinfo == null)
            {
                ShowError("后台登陆", "发生错误,请先登录前台,然后再访问此页.", "", "login.aspx");
            }

            IsAdminLogined();
            if (admininfo != null)
            {
                string action = YRequest.GetString("action") == string.Empty ? "default" : YRequest.GetString("action");
                int    id     = YRequest.GetInt("id", 0);

                url = string.Format("frame.aspx?action={0}&id={1}", action, id);
            }
            else
            {
                url = "";
                if (ispost)
                {
                    //todo adminlogin
                    string name     = YRequest.GetFormString("loginname");
                    string password = YRequest.GetFormString("password");
                    string path     = YRequest.GetFormString("path");
                    admininfo = Admins.GetAdminInfo(name, Natsuhime.Common.Utils.MD5(password));

                    if (admininfo != null && admininfo.Uid == userinfo.Uid)
                    {
                        HttpCookie admincookie = new HttpCookie("cmsntadmin");
                        admincookie.Values["adminid"]  = admininfo.Adminid.ToString();
                        admincookie.Values["password"] = admininfo.Password;
                        admincookie.Values["path"]     = path;
                        admincookie.Expires            = DateTime.Now.AddMinutes(20d);
                        currentcontext.Response.AppendCookie(admincookie);

                        ShowMsg("后台登陆", "登录成功!开始跳转到后台首页", "", "admincp.aspx");
                    }
                    else
                    {
                        ShowError("后台登陆", "登录失败,用户名或密码错误!", "", "");
                    }
                }
            }
        }
Пример #2
0
        protected override void Page_Show()
        {
            int    columnid, pageid, pagecount;
            string type;

            columnid = YRequest.GetInt("cid", 0);
            pageid   = YRequest.GetInt("pageid", 1);
            type     = YRequest.GetQueryString("type");

            if (type == string.Empty)
            {//标准显示方式(按照栏目显示)
                pagecount = Articles.GetArticleCollectionPageCount(columnid, 15);
                if (pageid > pagecount)
                {
                    pageid = pagecount;
                }
                pagecounthtml = config.Urlrewrite == 1 ? Natsuhime.Web.Utils.GetStaticPageNumbersHtml(pageid, pagecount, string.Format("showcolumn-{0}", columnid), ".aspx", 8) : Utils.GetPageNumbersHtml(pageid, pagecount, string.Format("showcolumn.aspx?cid={0}", columnid), 8, "pageid", "");
                articlelist   = Articles.GetArticleCollection(columnid, 15, pageid);

                if (columnid > 0)
                {
                    pagetitle = Columns.GetColumnName(columnid);
                }
                else
                {
                    pagetitle = "所有文章列表";
                }
            }
            else if (type == "recommend")
            {//推荐主题显示
                pagecount = Articles.GetRecommendArticleCollectionPageCount(15);
                if (pageid > pagecount)
                {
                    pageid = pagecount;
                }
                pagecounthtml = config.Urlrewrite == 1 ? Utils.GetStaticPageNumbersHtml(pageid, pagecount, "showcolumn-recommend", ".aspx", 8) : Utils.GetPageNumbersHtml(pageid, pagecount, "showcolumn.aspx?type=recommend", 8, "pageid", "");
                articlelist   = Articles.GetRecommendArticles(15, pageid);
                pagetitle     = "推荐文章";
            }
            else if (type == "hot")
            {//热门主题显示
                pagecount = Articles.GetHotArticleCollectionPageCount(15);
                if (pageid > pagecount)
                {
                    pageid = pagecount;
                }
                pagecounthtml = config.Urlrewrite == 1 ? Utils.GetStaticPageNumbersHtml(pageid, pagecount, "showcolumn-hot", ".aspx", 8) : Utils.GetPageNumbersHtml(pageid, pagecount, "showcolumn.aspx?type=hot", 8, "pageid", "");
                articlelist   = Articles.GetHotArticles(15, pageid);
                pagetitle     = "热门文章";
            }
        }
Пример #3
0
        protected override void Page_Show()
        {
            UserInfo userinfo = GetUserInfo();

            if (userinfo == null)
            {
                ShowError("站内搜索", "请登录后再搜索文章,谢谢~", "", "login.aspx");
            }
            string searchkey = YRequest.GetQueryString("searchkey");

            if (searchkey != string.Empty && Natsuhime.Common.Utils.IsSafeSqlString(searchkey))
            {
                int pageid = YRequest.GetQueryInt("pageid", 1);
                int pagecount;
                pagecount        = Articles.GetSearchArticleCollectionPageCount(searchkey, 12);
                searchresultlist = Articles.GetSearchArticles(searchkey, 12, pageid);
                pagecounthtml    = config.Urlrewrite == 1 ? Natsuhime.Web.Utils.GetStaticPageNumbersHtml(pageid, pagecount, string.Format("search-{0}", searchkey), ".aspx", 8) : Utils.GetPageNumbersHtml(pageid, pagecount, string.Format("search.aspx?searchkey={0}", searchkey), 8, "pageid", "");
            }
            else
            {
                ShowError("站内搜索", "参数异常!", "", "");
            }
        }
Пример #4
0
        protected override void Page_Show()
        {
            UserInfo userinfo = GetUserInfo();

            if (userinfo == null)
            {
                ShowError("评论信息", "请登录后再留言评论.", "", "login.aspx");
            }
            string action = YRequest.GetQueryString("action");

            if (action == string.Empty)
            {
                currentcontext.Response.End();
            }
            if (action == "postcomment")
            {
                string content   = YRequest.GetFormString("commentcontent");
                int    articleid = YRequest.GetQueryInt("articleid", 0);
                if (content != string.Empty && articleid > 0)
                {
                    if (content != string.Empty)
                    {
                        CommentInfo info = new CommentInfo();
                        info.Articleid    = articleid;
                        info.Uid          = userinfo.Uid;
                        info.Username     = userinfo.Username;
                        info.Postdate     = DateTime.Now.ToString();
                        info.Del          = 0;
                        info.Content      = Utils.RemoveUnsafeHtml(content);
                        info.Goodcount    = 0;
                        info.Badcount     = 0;
                        info.Articletitle = Articles.GetArticleInfo(articleid).Title;
                        Comments.CreateComment(info);
                        Articles.ChangeCommentCount(articleid, 1, 1);
                        Articles.RemoveArtilceCache();
                        currentcontext.Response.Redirect(YRequest.GetUrlReferrer());
                    }
                }
                else
                {
                    currentcontext.Response.Write("参数为空.");
                    currentcontext.Response.End();
                    return;
                }
            }
            else if (action == "grade")
            {
                int commentid = YRequest.GetQueryInt("commentid", 0);
                if (commentid > 0)
                {
                    int type = YRequest.GetQueryInt("type", 0);
                    Comments.GradeComment(commentid, type);
                    Articles.RemoveArtilceCache();
                    currentcontext.Response.Redirect(YRequest.GetUrlReferrer());
                }
                else
                {
                    ShowError("评论信息", "参数为空,请检查输入!", "", "");
                }
            }
            else if (action == "del")
            {
                int commentid = YRequest.GetQueryInt("commentid", 0);
                if (commentid > 0)
                {
                    CommentInfo info = Comments.GetCommentInfo(commentid);
                    Comments.DeleteComment(info.Commentid);
                    Articles.ChangeCommentCount(info.Articleid, 1, -1);
                    Articles.RemoveArtilceCache();
                    currentcontext.Response.Redirect(YRequest.GetUrlReferrer());
                }
                else
                {
                    ShowError("评论信息", "参数为空,请检查输入!", "", "");
                }
            }
            else
            {
                ShowError("评论信息", "非法的参数!", "", "");
            }
        }