Esempio n. 1
0
        /// <summary>
        /// 检查登录和权限
        /// </summary>
        protected void CheckLoginAndPermission()
        {
            if (!IsLogin)
            {
                HttpContext.Current.Response.Redirect("/admin/login?returnurl=" + HttpContext.Current.Server.UrlEncode(Jqpress.Framework.Web.PressRequest.CurrentUrl));
                HttpContext.Current.Response.End();
            }
            else
            {
                UserInfo user = new UserService().GetUser(CurrentUserId);

                if (user == null)       //删除已登陆用户时有效
                {
                    RemoveUserCookie();
                    HttpContext.Current.Response.Redirect("/admin/login?returnurl=" + HttpContext.Current.Server.UrlEncode(Jqpress.Framework.Web.PressRequest.CurrentUrl));

                }

                if (Jqpress.Framework.Utils.EncryptHelper.MD5(user.UserId + HttpContext.Current.Server.UrlEncode(user.UserName) + user.Password) != CurrentKey)
                {
                    RemoveUserCookie();
                    HttpContext.Current.Response.Redirect("/admin/login?returnurl=" + HttpContext.Current.Server.UrlEncode(Jqpress.Framework.Web.PressRequest.CurrentUrl));
                }

                if (CurrentUser.Status == 0)
                {
                    ResponseError("您的用户名已停用", "您的用户名已停用,请与管理员联系!");
                }

                string[] plist = new string[] { "theme/list", "theme/edit", "link/list", "user/list", "setting", "category/list", "tag/list", "comment" };
                if (CurrentUser.Role == (int)UserRole.Author)
                {
                    string pageName = System.IO.Path.GetFileName(HttpContext.Current.Request.Url.ToString()).ToLower();

                    foreach (string p in plist)
                    {
                        if (pageName == p)
                        {
                            ResponseError("没有权限", "您没有权限使用此功能,请与管理员联系!");
                        }
                    }
                }

            }
        }
Esempio n. 2
0
 public ActionResult Setup(InstallModel model)
 {
     if (string.IsNullOrEmpty(model.SiteName))
         {
             ViewData["Err_SiteName"] = "请输入站点名称";
         }
         if (string.IsNullOrEmpty(model.UserName))
         {
             ViewData["Err_UserName"] = "******";
         }
         if (string.IsNullOrEmpty(model.PassWord))
         {
             ViewData["Err_PassWord"] = "******";
         }
         if (model.PassWord!=model.ConfirmPassword)
         {
             ViewData["Err_ConfirmPassword"] = "******";
         }
         if (ViewData.Count==0)
         {
             var config = SiteConfig.GetSetting();
             config.SiteName = model.SiteName;
             config.MetaKeywords = model.SiteName;
             config.MetaDescription = model.SiteName;
             config.IsInstalled = true;
             SiteConfig.UpdateSetting();
             var userService = new UserService();
             if (userService.GetUser(model.UserName)==null)
             {
                 var user = new UserInfo
                     {
                         UserName = model.UserName,
                         Password = EncryptHelper.MD5(model.PassWord),
                         Role = (int)UserRole.Administrator
                     };
                 userService.InsertUser(user);
             }
             return View("Success");
         }
         else
         {
             return View();
         }
 }
Esempio n. 3
0
        /// <summary>
        /// 发邮件
        /// </summary>
        /// <param name="post"></param>
        public void SendEmail(PostInfo post)
        {
            if (SiteConfig.GetSetting().SendMailAuthorByPost == 1)
            {
                List<UserInfo> list = new UserService().GetUserList();
                List<string> emailList = new List<string>();

                foreach (UserInfo user in list)
                {
                    if (!Jqpress.Framework.Utils.Validate.IsEmail(user.Email))
                    {
                        continue;
                    }
                    //自己不用发
                    //if (CurrentUser.Email == user.Email)
                    //{
                    //    continue;
                    //}
                    ////不重复发送
                    //if (emailList.Contains(user.Email))
                    //{
                    //    continue;
                    //}
                    //emailList.Add(user.Email);

                    //string subject = string.Empty;
                    //string body = string.Empty;

                    //subject = string.Format("[新文章通知]{0}", post.Title);
                    //body += string.Format("{0}有新文章了:<br/>", BlogConfig.GetSetting().SiteName);
                    //body += "<hr/>";
                    //body += "<br />标题: " + post.Link;
                    //body += post.Detail;
                    //body += "<hr/>";
                    //body += "<br />作者: " + CurrentUser.Link;
                    //body += "<br />时间: " + post.PostTime;
                    //body += "<br />文章连接: " + post.Link;
                    //body += "<br />注:系统自动通知邮件,不要回复。";

                    // EmailHelper.SendAsync(user.Email, subject, body);
                }
            }
        }