Exemplo n.º 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("后台登陆", "登录失败,用户名或密码错误!", "", "");
                    }
                }
            }
        }
Exemplo n.º 2
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("评论信息", "非法的参数!", "", "");
            }
        }