Пример #1
0
        protected override void Page_Show()
        {
            pagetitle = "投递文章";
            UserInfo userinfo = GetUserInfo();

            if (userinfo == null)
            {
                ShowError("投递文章", "请登录后再投递文章,谢谢~", "", "login.aspx");
            }
            columnlist = Columns.GetColumnCollection();
            if (YRequest.IsPost())
            {
                int    columnid = YRequest.GetInt("columnid", 0);
                string title    = Utils.RemoveHtml(YRequest.GetString("title"));
                string summary  = Utils.RemoveHtml(YRequest.GetString("summary"));
                string content  = Utils.RemoveUnsafeHtml(YRequest.GetString("content"));

                ArticleInfo articleinfo = new ArticleInfo();
                articleinfo.Columnid = columnid;
                articleinfo.Title    = title;
                //articleinfo.Highlight = ddlHightlight.SelectedValue;
                articleinfo.Summary  = summary.Length > 160 ? summary.Substring(0, 159) : summary;
                articleinfo.Content  = content;
                articleinfo.Postdate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                articleinfo.Uid      = userinfo.Uid;
                articleinfo.Username = userinfo.Username;
                Articles.CreateArticle(articleinfo);
                Articles.RemoveArtilceCache();
                ShowMsg("投递文章", "发布成功,跳转到栏目列表.", "", string.Format("showcolumn-{0}-1.aspx", articleinfo.Columnid));
            }
        }
Пример #2
0
        protected override void Page_Show()
        {
            pagetitle = "注册用户";
            UserInfo userinfo = GetUserInfo();

            if (userinfo != null)
            {
                ShowError("注册用户", "您已经登录了,请不要重复注册帐号!", "", "usercontrolpanel.aspx");
            }
            if (ispost)
            {
                string email       = YRequest.GetString("email");
                string password    = YRequest.GetString("password");
                string username    = YRequest.GetString("username");
                string secquestion = YRequest.GetString("secretquestion");
                string secanswer   = YRequest.GetString("secretanswer");

                if (email != string.Empty && password != string.Empty && username != string.Empty)
                {
                    if (Users.GetUserInfo(username, 1) != null)
                    {
                        ShowError("注册用户", "注册失败,用户名已存在!", "", "");
                    }
                    else if (Users.GetUserInfo(email, 0) != null)
                    {
                        ShowError("注册用户", "注册失败,Email已存在!", "", "");
                    }
                    if (secquestion == string.Empty || secanswer == string.Empty)
                    {
                        ShowError("注册用户", "注册失败,找回密码提示或答案为空.请填写完整以保障帐号安全!", "", "");
                    }
                    UserInfo info = new UserInfo();
                    info.Adminid      = 0;
                    info.Articlecount = 0;
                    info.Bdday        = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                    info.Del          = 0;
                    info.Email        = email;
                    info.Secquestion  = secquestion;
                    info.Secanswer    = Natsuhime.Common.Utils.MD5(secanswer);
                    info.Groupid      = 1;
                    info.Hi           = "";
                    info.Lastlogdate  = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                    info.Lastlogip    = "";
                    info.Msn          = "";
                    info.Nickname     = username;
                    info.Password     = Natsuhime.Common.Utils.MD5(password);
                    info.Qq           = "";
                    info.Realname     = "";
                    info.Regdate      = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                    info.Regip        = YRequest.GetIP();
                    info.Replycount   = 0;
                    info.Topiccount   = 0;
                    info.Username     = username;

                    Users.AddUser(info);
                    ShowMsg("注册用户", "注册帐号成功,跳转到用户中心.", "", "usercontrolpanel.aspx");
                }
            }
        }
Пример #3
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("后台登陆", "登录失败,用户名或密码错误!", "", "");
                    }
                }
            }
        }
Пример #4
0
        protected override void Page_Show()
        {
            pagetitle = "用户登录";
            if (userid > 0)
            {
                ShowMsg("登录消息", "您已经登录了,请不要重复登录!", "", "usercontrolpanel.aspx");
            }
            if (ispost)
            {
                string loginid  = YRequest.GetString("loginid");
                string password = YRequest.GetString("password");
                if (loginid != string.Empty && password != string.Empty)
                {
                    UserInfo info = Users.GetUserInfo(loginid, Natsuhime.Common.Utils.MD5(password), 0);
                    if (info != null)
                    {
                        YCookies cookie = new YCookies("cmsnt");
                        cookie.WriteCookieValue("userid", info.Uid.ToString());
                        cookie.WriteCookieValue("password", info.Password);
                        cookie.WriteCookieValue("username", info.Username);
                        cookie.WriteCookieValue("adminid", info.Adminid.ToString());
                        cookie.AddCookieExpiresTime(30 * 3600 * 24);
                        cookie.SaveCookie();

                        #region 插件登录
                        bool pluglogin = false;
                        if (pluglogin)
                        {
                            Plugin.IUserProvider provider = Plugin.ProviderUtitily.GetUserProvider("DNT");
                            int uid = provider.IsUserExits(info.Username);
                            if (uid > 0)
                            {
                                provider.Login(info.Username, password, false, 16000, "");
                            }
                            else
                            {
                                provider.Register(info.Username, info.Password, info.Email, true);
                            }
                        }
                        #endregion
                        ShowMsg("登录消息", "登录成功,跳转到用户中心.", "", "usercontrolpanel.aspx");
                    }
                    else
                    {
                        ShowError("登录消息", "登录失败,帐号或密码错误!", "", "");
                    }
                }
                else
                {
                    ShowError("登录消息", "登录失败,用户名或密码为空,请检查输入框是否填写!", "", "");
                }
            }
        }
Пример #5
0
        protected override void Page_Show()
        {
            UserInfo userinfo = GetUserInfo();

            if (userinfo == null)
            {
                ShowError("上传文件", "请登录后再上传文件,谢谢~", "", "login.aspx");
            }
            if (ispost)
            {
                int filecount = System.Web.HttpContext.Current.Request.Files.Count;
                for (int i = 0; i < filecount; i++)
                {
                    System.Web.HttpPostedFile postedfile = System.Web.HttpContext.Current.Request.Files[i];
                    if (postedfile.FileName != string.Empty)
                    {
                        string fileext      = Path.GetExtension(postedfile.FileName).ToLower();
                        string savepath     = Path.Combine("upload", DateTime.Now.ToString("yyMM"));
                        string filename     = string.Format("{0}{1}{2}", DateTime.Now.ToString("yyMMddhhmm"), Guid.NewGuid().ToString(), fileext);
                        string fullsavename = Path.Combine(savepath, filename);

                        bool     canUpload         = false;
                        string[] allowedextensions = { ".gif", ".png", ".jpeg", ".jpg", ".zip", ".rar" };
                        foreach (string allowextname in allowedextensions)
                        {
                            if (fileext == allowextname)
                            {
                                canUpload = true;
                                break;
                            }
                        }

                        if (canUpload == true)
                        {
                            YRequest.SaveRequestFile(System.Web.HttpContext.Current.Request.Files[i], Server.MapPath("~/" + fullsavename));

                            AttachmentInfo info = new AttachmentInfo();
                            info.Filename    = filename;
                            info.Filepath    = fullsavename;
                            info.Filetype    = 0;
                            info.Posterid    = userinfo.Uid;
                            info.Description = "";
                            Attachments.CreateAttachment(info);

                            string result = JavaScriptConvert.SerializeObject(info);
                            currentcontext.Response.Write(result);
                            currentcontext.Response.End();
                        }
                    }
                }
                //System.Web.HttpContext.Current.Response.Redirect("uploadfile.aspx?filename=" + uploadedfilename.Trim(','));
            }
        }
Пример #6
0
        protected override void Page_Show()
        {
            string type = YRequest.GetString("type").ToLower();

            messageheader = Utils.HtmlEncode(YRequest.GetString("header"));
            messagefooter = Utils.HtmlEncode(YRequest.GetString("footer"));
            messagebody   = Utils.HtmlEncode(YRequest.GetString("body"));
            redirecturl   = YRequest.GetString("redirecturl") == string.Empty ? "javascript:history.back(-1);" : Utils.HtmlEncode(YRequest.GetString("redirecturl"));

            isautoredirect = type.ToLower() == "error" ? false : true;

            pagetitle = "系统提示";
        }
Пример #7
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     = "热门文章";
            }
        }
Пример #8
0
        protected override void Page_Show()
        {
            int articleid = YRequest.GetQueryInt("id", 1);

            articleinfo = Articles.GetArticleInfo(articleid);
            if (articleinfo == null)
            {
                ShowError("查看文章", "错误,不存在的文章!", "", "");
            }
            pagetitle = string.Format("{0} - {1}", Natsuhime.Web.Utils.RemoveHtml(articleinfo.Title), articleinfo.Columnname);

            int commentpageid = YRequest.GetQueryInt("commentpageid", 1);

            commentlist = Comments.GetCommentCollection(articleid, 8, commentpageid);
            int commentpagecount = Comments.GetCommentCollectionPageCount(articleid, 8);

            commentcounthtml = config.Urlrewrite == 1 ? Natsuhime.Web.Utils.GetStaticPageNumbersHtml(commentpageid, commentpagecount, string.Format("showarticle-{0}", articleid), ".aspx", 8) : Utils.GetPageNumbersHtml(commentpageid, commentpagecount, string.Format("showarticle.aspx?id={0}", articleid), 8, "commentpageid", "");
        }
Пример #9
0
        protected override void Page_Show()
        {
            if (userid > 0)
            {
                ShowError("找回密码失败!错误原因:", "您已经登录了本站,如果需要修改密码,请在用户中心修改!", "", "usercontrolpanel.aspx");
            }
            if (ispost)
            {
                findusername = YRequest.GetString("loginid");

                if (findusername == string.Empty)
                {
                    ShowError("找回密码失败!错误原因:", "输入框为空,请填写完整表格!", "", "");
                }
                UserInfo info = Users.GetUserInfo(findusername, 0);
                if (info != null)
                {
                    string secans = YRequest.GetString("secretanswer");
                    if (secans == string.Empty)
                    {
                        findusername = info.Email;
                        secques      = info.Secquestion;
                    }
                    else
                    {
                        string newpassword = YRequest.GetString("password");
                        if (newpassword == string.Empty)
                        {
                            ShowError("找回密码失败!错误原因:", "密码框为空,请填写新的密码!", "", "");
                        }
                        if (Natsuhime.Common.Utils.MD5(secans) == info.Secanswer)
                        {
                            info.Password = Natsuhime.Common.Utils.MD5(newpassword);
                            Users.EditUser(info);
                            ShowMsg("找回密码消息", "重设密码成功,请用新的密码登录系统.", "", "login.aspx");
                        }
                        else
                        {
                            ShowError("找回密码失败!错误原因:", "验证问答错误!", "", "");
                        }
                    }
                }
            }
        }
Пример #10
0
        protected override void Page_Show()
        {
            userinfo = GetUserInfo();
            if (userinfo == null)
            {
                ShowError("用户中心", "身份验证失败,请登录后再访问用户中心,谢谢~", "", "login.aspx");
            }
            else
            {
                pagetitle = string.Format("{0}的用户中心", userinfo.Username);
                int pageid    = YRequest.GetInt("pageid", 1);
                int pagecount = Articles.GetUserArticleCollectionPageCount(userinfo.Uid, 8);
                pagecounthtml = Utils.GetPageNumbersHtml(pageid, pagecount, "usercontrolpanel.aspx", 8, "pageid", "");
                myarticlelist = Articles.GetUserArticleCollection(userinfo.Uid, 8, pageid);

                if (ispost)
                {
                    string oldpassword  = YRequest.GetString("oldpassword");
                    string newpassword  = YRequest.GetString("newpassword");
                    string newpassword2 = YRequest.GetString("newpassword2");
                    if (newpassword == newpassword2)
                    {
                        string newMD5Password = Natsuhime.Common.Utils.MD5(oldpassword);
                        if (newMD5Password == userinfo.Password)
                        {
                            userinfo.Password = newMD5Password;
                            Users.EditUser(userinfo);
                            ShowMsg("用户中心", "", "修改密码修改成功.", "");
                        }
                        else
                        {
                            ShowError("用户中心", "修改密码失败,旧密码验证错误!请检查是否输入正确,大小写锁定键是否被打开等.", "", "");
                        }
                    }
                    else
                    {
                        ShowError("用户中心", "修改密码失败,两次输入的新密码不一致.", "", "");
                    }
                }
            }
        }
Пример #11
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("站内搜索", "参数异常!", "", "");
            }
        }
Пример #12
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("评论信息", "非法的参数!", "", "");
            }
        }
Пример #13
0
        protected override void Page_Show()
        {
            base.IsAdminLogined();
            if (admininfo != null)
            {
                string url = "";
                //string adminpath = YRequest.GetString("path") == string.Empty ? "admin" : YRequest.GetString("path");
                string action = YRequest.GetString("action");
                int    id     = YRequest.GetInt("id", 0);
                string name   = YRequest.GetString("name");

                if (action == "postarticle")
                {
                    url = string.Format("{0}/postarticle.aspx", adminpath);
                }
                else if (action == "editarticle")
                {
                    url = string.Format("{0}/postarticle.aspx?id={1}&action=edit", adminpath, id);
                }
                else if (action == "deletearticle")
                {
                    url = string.Format("{0}/deleteadmin.aspx?articleid={1}", adminpath, id);
                }
                else if (action == "listarticle")
                {
                    url = string.Format("{0}/articlelist.aspx?cid={1}", adminpath, id);
                }
                else if (action == "mgrcolumn")
                {
                    url = string.Format("{0}/columnlist.aspx", adminpath);
                }
                else if (action == "mainsetting")
                {
                    url = string.Format("{0}/mainsetting.aspx", adminpath);
                }
                else if (action == "template")
                {
                    url = string.Format("{0}/template.aspx", adminpath);
                }
                else if (action == "settemplate")
                {
                    url = string.Format("{0}/template.aspx?action=settemplate&folder={1}", adminpath, name);
                }
                else if (action == "createtemplate")
                {
                    url = string.Format("{0}/template.aspx?action=create&folder={1}", adminpath, name);
                }
                else if (action == "")
                {
                }
                else if (action == "")
                {
                }
                else if (action == "default")
                {
                    url = string.Format("{0}/articlelist.aspx?cid={1}", adminpath, id);
                }
                else
                {
                    url = "";
                }
                Server.Transfer(url);
            }
            else
            {
                currentcontext.Response.Redirect("admincp.aspx");
            }
        }