protected void Page_Load(object sender, EventArgs e)
        {
            //if (CurrentAccount == null) // 用户未登录
            //{
            //    Header1.ShowInfoNav = true;
            //    Header1.ShowBigNav = false;
            //    Header1.ShowSearch = false;
            //}
            //else // 登录后
            //{
            //    Header1.ShowInfoNav = false;
            //    Header1.ShowBigNav = true;
            //    Header1.ShowSearch = true;
            //}

            if (!Page.IsPostBack)
            {
                string cipherEmail = Request.QueryString["e"];
                string cipherDateTime = Request.QueryString["d"];
                if (string.IsNullOrEmpty(cipherDateTime) || string.IsNullOrEmpty(cipherEmail))
                {
                    base.ShowAlert("错误提示", "您的请求无效!", false, "", false);
                    ExecuteClientScript("setTimeout(function(){ window.location.href='Login.aspx'; }, 3000);");
                    return;
                }

                try
                {
                    CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
                    string email = sh.Decrypt(HttpUtility.UrlDecode(cipherEmail), CY.Security.EncryptionAlgorithm.TripleDes);
                    //string dtTicks = sh.Decrypt(HttpUtility.UrlDecode(cipherDateTime), CY.Security.EncryptionAlgorithm.TripleDes);
                    DateTime expiredDateTime;
                    long ticks;
                    if (long.TryParse(cipherDateTime, out ticks))
                    {
                        expiredDateTime = new DateTime(ticks);

                        if (expiredDateTime < DateTime.Now)
                        {
                            base.ShowAlert("错误提示", "您的请求已失效!", false, "", false);
                            ExecuteClientScript("setTimeout(function(){ window.location.href='Login.aspx'; }, 3000);");
                            return;
                        }

                        LblEmail.Text = email;
                    }
                    else
                    {
                        base.ShowAlert("错误提示", "您的请求无效!", false, "", false);
                        ExecuteClientScript("setTimeout(function(){ window.location.href='Login.aspx'; }, 3000);");
                        return;
                    }
                }
                catch
                {
                    base.ShowAlert("错误提示", "服务器忙,请稍后再试!", false, "", false);
                    ExecuteClientScript("setTimeout(function(){ window.location.href='Login.aspx'; }, 3000);");
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string albumID = context.Request.Params["albumId"];
            string password = context.Request.Params["password"];
            int albumId = 0;

            //if (!String.IsNullOrEmpty(albumID)||!String.IsNullOrEmpty(password))
            //{
            //    context.Response.Write("{information:false,msg:'无法找到该相册'}");
            //    return;
            //}

            if (!int.TryParse(albumID, out albumId))
            {
                context.Response.Write("{information:false,msg:'参数转换有误'}");
            }

            CY.UME.Core.Business.Album album = CY.UME.Core.Business.Album.Load(albumId);

            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
            if (sh.ComputeMD5Hash(password) == album.ViewPassword)
            {

              context.Response.Write("{information:true}");
            }
            else
            {
                context.Response.Write("{information:false,msg:'密码错误'}");
            }
        }
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            string pwd = TxtPassword.Text;
            string pwdConfirm = TxtPasswordConfim.Text;
            if (pwd.Length < 6 || pwd.Length > 20)
            {
                base.ShowAlert("错误提示", "密码长度必须在6至20个字符之间", false, "", false);
                return;
            }
            if (pwdConfirm != pwd)
            {
                base.ShowAlert("错误提示", "两次密码不一致", false, "", false);
                return;
            }

            CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(LblEmail.Text);
            if (ae == null)
            {
                ShowAlert("错误提示", "请求无效!");
                return;
            }

            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
            ae.Password = sh.ComputeMD5Hash(pwd);
            ae.Save();

            base.ShowAlert("成功", "修改密码成功,现在系统将引导你重新登录...", true, "", false);
            ExecuteClientScript("setTimeout(function(){ window.location.href='Login.aspx'; }, 2000);");
        }
Exemple #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["sid"] != null)
            {
                string[] saa = Request.Cookies["sid"].Value.Split(':');
                lblsid.Text = saa[0] + " | " + saa[1] + " | " + saa[2] + " | " + saa[3];
            }

            if (Request.Cookies["sso"] == null)
            {
                return;
            }

            String sid = Request.Cookies["sso"].Value;
            string[] sa = sid.Split(':');
            if (sa.Length == 4)
            {
                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                try
                {
                    string email;
                    string password;
                    string ip;
                    string expectedIP = CY.Utility.Common.RequestUtility.ClientIP;
                    DateTime dateExpire;

                    email = sa[0];
                    password = sa[1];
                    string dt = sa[2];
                    ip = sa[3];

                    if (expectedIP != ip)
                    {
                        return;
                    }

                    long tick;
                    if (long.TryParse(dt, out tick))
                    {
                        dateExpire = new DateTime(tick);
                        if (dateExpire > DateTime.Now)
                        {
                            lblmessage.Text = "用户名:" + email + "<br/> 密  码:" + password;
                        }
                    }
                    else
                    {
                        lblmessage.Text = "没有";
                    }
                }
                catch { }
            }
            else
            {
                lblmessage.Text = "没有";
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbName.Text.Trim()))
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('姓名不能为空');</script>");
                tbName.Focus();
                return;
            }
            else if (string.IsNullOrEmpty(tbPass.Text.Trim()) || string.IsNullOrEmpty(tbPassConfirm.Text.Trim()))
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('密码不能为空');</script>");
                tbPass.Focus();
                return;
            }
            else if (!string.Equals(tbPass.Text.Trim(), tbPassConfirm.Text.Trim()))
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('二次密码不相同');</script>");
                tbPassConfirm.Focus();
                return;
            }
            else
            {
                try
                {
                    CY.UME.Core.Business.AccountExtend aTemp = CY.UME.Core.Business.AccountExtend.Load(tbEmail.Text.Trim());

                    if (aTemp== null)
                    {
                        CY.UME.Core.Business.Account account = new CY.UME.Core.Business.Account();
                        account.Name = tbName.Text.Trim();
                        account.IsPublic = true;
                        account.DateCreated = DateTime.Now;
                        account.Save();

                        CY.UME.Core.Business.AccountExtend accountExtent = CY.UME.Core.Business.AccountExtend.Load(account.Id);

                        accountExtent.IsEmailChecked = true;
                        accountExtent.Email = tbEmail.Text.Trim();
                        CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
                        accountExtent.Password = sh.ComputeMD5Hash(tbPass.Text.Trim());
                        accountExtent.IsShow = 0;
                        accountExtent.Save();
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('新增成功');window.location.href='PublicAccount.aspx'</script>");
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('邮箱不能重复');</script>");
                        tbEmail.Focus();
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('" + ex.Message + "');</script>");
                    return;
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// 用户登录成功后保存用户信息到cookie,默认保存1小时。
        /// </summary>
        /// <param name="email">用户名</param>
        /// <param name="password">密码</param>
        public void SaveAccountCookie(string email, string password)
        {
            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            string emailTemp = email;
            string passwordTemp = sh.ComputeMD5Hash(password); ;
            string ticks = DateTime.Now.AddDays(7).Ticks.ToString();
            string ClientIP = CY.Utility.Common.RequestUtility.ClientIP;

            CY.UME.Core.Business.Account.WriteStayCookie(emailTemp, passwordTemp, "sso", 1, ticks, ClientIP);
        }
 public ActionResult Create(Core.Business.Account model)
 {
     if (model == null)
     {
         TempData["HintMessage"] = new HintMessage { Content = "操作失败,系统发生了一个错误" };
         return RedirectToAction("Add");
     }
     CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
     model.Password = sh.ComputeMD5Hash(model.Password);
     model.Save();
     TempData["HintMessage"] = new HintMessage { Content = string.Format("人员({0})添加成功", model.Name) };
     return RedirectToAction("Index");
 }
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            string validateCode = string.Empty;
            string originalPassword = TxtOrignalPassword.Text;
            string newPassword = TxtNewPassword.Text;
            string newPasswordConfirm = TxtNewPasswordConfirm.Text;

            CY.UME.Core.Business.AccountExtend ae = base.CurrentAccount.ExtendInfo;

            if (Session["CaptchaImageText"] != null)
            {
                validateCode = Session["CaptchaImageText"].ToString();
            }
            if (TxtVCode.Text != validateCode)
            {
                Response.Write("<script language='javascript'>alert('验证码错误!');</script>");
                return;
            }
            if (newPassword.Length < 6 || newPassword.Length > 20)
            {
                Response.Write("<script language='javascript'>alert('密码长度必须在6至20之间!');</script>");
                return;
            }
            if (newPassword != newPasswordConfirm)
            {
                Response.Write("<script language='javascript'>alert('再次密码不一致,请重新输入!');</script>");
                return;
            }

            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            if (ae.Password != sh.ComputeMD5Hash(originalPassword))
            {
                Response.Write("<script language='javascript'>alert('原密码不正确,请重新输入!');</script>");
                return;
            }
            else
            {
                string ciperPassword = sh.ComputeMD5Hash(newPassword);
                ae.Password = ciperPassword;
                ae.Save();
                Response.Write("<script language='javascript'>alert('您的密码已更新成功,现在系统将引导您重新登录...');</script>");
                ExecuteClientScript("setTimeout(function(){window.location.href='Logout.aspx';}, 2000)");
            }
        }
Exemple #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "applciation/json";

            string Type = context.Request.Form["Type"].ToString();

            try
            {
                switch (Type)
                {
                    case "md5":
                        #region MD5
                        string _ = context.Request.Form["_"].ToString();

                        CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                        context.Response.Write("{success:true ,md5:'" + sh.ComputeMD5Hash(_) + "'}");
                        return;
                        #endregion
                    case "Guid":
                        #region Guide
                        context.Response.Write("{success:true,Guide:'" + Guid.NewGuid() + "'}");
                        return;
                        #endregion
                    case "Msg":
                        string Telephone = context.Request.Form["tel"];
                        string msgcontent = context.Request.Form["msg"];
                        string flag = String.Empty;

                        if(CY.UME.Core.Global.TrySendMessage(Telephone, msgcontent, out flag))
                            context.Response.Write("{success:true,msg:'发送成功'}");
                        else
                            context.Response.Write("{success:false,msg:'发送失败'}");

                        return;
                    default:
                        break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{success:flase ,msg:'" + ex.Message + "'}");
                return;
            }
        }
Exemple #10
0
        protected void Validate(object sender, EventArgs e)
        {
            if (ViewState["spaceAccountId"] == null || ViewState["albumId"] == null)
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '发生意外错误'})</script>");
                return;
            }

            CY.UME.Core.Business.Album album = CY.UME.Core.Business.Album.Load(int.Parse(ViewState["albumId"].ToString()));

            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            if (sh.ComputeMD5Hash(TBXPassword.Text.Trim()) == album.ViewPassword)
            {
                Session["AlbumPassword"] = sh.ComputeMD5Hash(TBXPassword.Text.Trim());
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>window.location.href='PictureList.aspx?albumId=" + album.Id.ToString() + "&SpaceId=" +ViewState["spaceAccountId"].ToString() + "'</script>");
            }
            else
            {
                LblError.Text = "密码错误";
            }
        }
Exemple #11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            string AccountIdTemp = context.Request.Params["accountId"];
            string albumIdTemp = context.Request.Params["albumId"];
            string albumName = context.Request.Params["albumName"];
            string selViewPermission = context.Request.Params["selViewPermission"];
            string viewPassword = context.Request.Params["ViewPassword"];

            int viewPermission = 0;
            long accountId = 0;
            long albumId = 0;

            CY.UME.Core.Business.Album album = null;

            int.TryParse(selViewPermission, out viewPermission);

            if (albumName.Length == 0)
            {
                context.Response.Write("{success:false,msg:'相册名称不能为空!'}");
                return;
            }

            if (!long.TryParse(AccountIdTemp, out accountId))
            {
                return;
            }

            if (albumIdTemp != "0" && long.TryParse(albumIdTemp, out albumId))
            {//编辑相册
                album = Core.Business.Album.Load(albumId);
            }
            else
            {//添加相册
                album = new Core.Business.Album();
                album.DateCreated = DateTime.Now;
            }

            album.AccountId = accountId;

            album.LastModifiedTime = DateTime.Now;
            album.Name = albumName;

            album.ViewPermission = viewPermission;
            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
            if (viewPermission == 2)
            {
                if (viewPassword != "" && viewPassword.Length > 0)
                {
                    album.ViewPassword = sh.ComputeMD5Hash(viewPassword);
                }
            }
            album.Save();

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("{success:true,msg:'操作成功!',Album:[");

            if (album.ViewPermission == 2)
            {
                album.CoverPath = CY.UME.Core.Global.AlbumCoverNoPublishAddress;
            }
            else if (album.PhotoCount == 0)
                album.CoverPath = CY.UME.Core.Global.AlbumCoverAddress;

            sb.Append("{Id:");
            sb.Append(album.Id);
            sb.Append(",Name:'");
            sb.Append(album.Name);
            sb.Append("',CoverPath:'");
            sb.Append(album.CoverPath);
            sb.Append("',ViewPermission:'");
            sb.Append(album.ViewPermission);
            sb.Append("',ViewPassword:'******',DateCreated:'");
            sb.Append(album.DateCreated.ToString("yyyy年MM月dd日"));
            sb.Append("',LastModifiedTime:'");
            sb.Append(album.LastModifiedTime.ToString("yyyy年MM月dd日"));
            sb.Append("',PicCount:'");
            sb.Append(album.PhotoCount.ToString());
            sb.Append("',IsAvatar:");

            if (album.IsAvatar)
                sb.Append("true");
            else
                sb.Append("false");

            sb.Append("}]}");

            context.Response.Write(sb.ToString());
        }
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            if (bindingContext == null)
            {
                throw new ArgumentNullException("bindingContext");
            }

            Account obj = null;

            int accountId = ModelBinderHelper.FromPostedData<Int32>(bindingContext, "Key");
            if (accountId < 1)
            {
                accountId = 0;
                obj = (Account)(bindingContext.Model ?? new Account(accountId));
                obj.IsLocked = false;
                obj.IsAuthenticated = false;
                obj.LoginName = ModelBinderHelper.FromPostedData<String>(bindingContext, "LoginName").Trim().ToLower();

                string password = ModelBinderHelper.FromPostedData<String>(bindingContext, "Password");
                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
                obj.Password = sh.ComputeMD5Hash(password);
            }
            else
            {
                obj = RepositoryFactory.GetRepository<IAccountRepository, Account>().FindBy(accountId);
            }

            obj.Name = ModelBinderHelper.FromPostedData<String>(bindingContext, "Name");
            obj.Telephone = ModelBinderHelper.FromPostedData<String>(bindingContext, "Telephone");
            obj.Address = ModelBinderHelper.FromPostedData<String>(bindingContext, "Address");
            //obj.AvatarPath = ModelBinderHelper.FromPostedData<String>(bindingContext, "AvatarPath");
            //obj.SignPath = ModelBinderHelper.FromPostedData<String>(bindingContext, "SignPath");

            int gender = ModelBinderHelper.FromPostedData<Int32>(bindingContext, "Gender");
            obj.Gender = (Gender)gender;

            string birth = ModelBinderHelper.FromPostedData<String>(bindingContext, "Birthday");
            DateTime birthday;
            if (DateTime.TryParse(birth, out birthday))
            {
                obj.Birthday = birthday;
            }
            else
            {
                obj.Birthday = new DateTime?();
            }

            string companyId = ModelBinderHelper.FromPostedData<string>(bindingContext, "DC");
            if (!string.IsNullOrEmpty(companyId))
            {
                obj.DetectionCompany = RepositoryFactory.GetRepository<IDetectionCompanyRepository, DetectionCompany>().FindBy(companyId);

                string groupId = ModelBinderHelper.FromPostedData<string>(bindingContext, "DG");
                if (!string.IsNullOrEmpty(groupId))
                {
                    obj.DetectionGroup = RepositoryFactory.GetRepository<IDetectionGroupRepository, DetectionGroup>().FindBy(groupId);
                }
                else
                {
                    obj.DetectionGroup = null;
                }
            }
            else
            {
                obj.DetectionCompany = null;
                obj.DetectionGroup = null;
            }

            return obj;
        }
        public int ValidateUserNameAndPsw(long accountId, string password)
        {
            CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(accountId);

            if (ae == null)
            {
                return 0;
            }

            Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            if (password == ae.Password)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
Exemple #14
0
        void HandleAutoLogin()
        {
            CY.UME.Core.Business.Account account;

            account = CY.UME.Core.Global.GetCurrentAccount();

            if (account != null)
            {
                HF_AccountId.Value = account.Id.ToString();
                LBL_UserName.Text = account.Name;
                LBL_Email.Text = account.Email;

                LBL_Login.Text = "<a href='Home.aspx?uid=" + account.Id + "'>" + account.Name + "</a> | <a href='javascript:void(0);' id='logout'>退出</a>";

                //base.ExecuteClientScript("$('#logout').click(function(){if(confirm('你确定要退出吗?')){window.location.href='logout';}}).removeAttr('id');");
            }

            if (Request.Cookies["sid"] == null)
            {
                return;
            }

            String sid = Request.Cookies["sid"].Value;
            string[] sa = sid.Split(':');
            if (sa.Length == 4)
            {
                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                try
                {
                    string email;
                    string password;
                    string ip;
                    string expectedIP = sh.ComputeMD5Hash(CY.Utility.Common.RequestUtility.ClientIP);
                    DateTime dateExpire;

                    email = sh.Decrypt(sa[0], CY.Security.EncryptionAlgorithm.TripleDes);
                    password = sh.Decrypt(sa[1], CY.Security.EncryptionAlgorithm.TripleDes);
                    string dt = sh.Decrypt(sa[2], CY.Security.EncryptionAlgorithm.TripleDes);
                    ip = sa[3];

                    if (expectedIP != ip)
                    {
                        return;
                    }

                    long tick;
                    if (long.TryParse(dt, out tick))
                    {
                        dateExpire = new DateTime(tick);
                        if (dateExpire > DateTime.Now)
                        {
                            bool valid = CY.UME.Core.Business.Account.IsLoginValid(email, password, out account);
                            if (valid)
                            {
                                Session.Add("user", account.Id.ToString());
                                SaveAccountCookie(email, password);//保存Cookie用于问问吧登录

                                AddLoginCredit(account);
                                int num = CY.UME.Core.Business.Friendship.GetFriendshipCount(account) + CY.UME.Core.Business.Friendship.GetRequestFriendShipCount(account);
                                if (num <= 1)
                                {
                                    Response.Redirect("~/Index.aspx");
                                    return;
                                }
                                else
                                {
                                    HttpCookie CurrentUrl = CY.Utility.Common.RequestUtility.GetCookie("CurrentUrl");
                                    if (CurrentUrl != null)
                                    {
                                        Response.Redirect(CurrentUrl.Value);//转到用户之前登录的页面
                                        return;
                                    }
                                    else
                                    {
                                        Response.Redirect("~/Index");
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
                catch { }
            }
        }
        void ResetByEmail(CY.UME.Core.Business.Account account)
        {
            CY.UME.Core.Business.SystemSetting siteUrlSetting = CY.UME.Core.Business.SystemSetting.Load("SiteUrl");
            if (siteUrlSetting == null || string.IsNullOrEmpty(siteUrlSetting.Value))
            {
                base.ShowAlert("错误提示", "服务器忙,请稍后再试", false, "", false);
                return;
            }

            /*
            SystemSetting gmailAccountSetting = SystemSetting.Load("GmailAccount");
            SystemSetting gmailAccountPasswordSetting = SystemSetting.Load("GmailAccountPassword");

            if (gmailAccountSetting == null ||
                gmailAccountPasswordSetting == null ||
                string.IsNullOrEmpty(gmailAccountSetting.Value) ||
                string.IsNullOrEmpty(gmailAccountPasswordSetting.Value))
            {
                ShowAlert("错误提示", "服务器忙,请稍后再试");
                return;
            }
            */

            try
            {
                long dateExpireTicks = DateTime.Now.AddDays(1).Ticks;
                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
                string cipherEmail = sh.Encrypt(account.ExtendInfo.Email, CY.Security.EncryptionAlgorithm.TripleDes);
                string cipherDt = sh.Encrypt(dateExpireTicks.ToString(), CY.Security.EncryptionAlgorithm.TripleDes);
                string encodedEmail = HttpUtility.UrlEncode(cipherEmail);
                string encodedDt = HttpUtility.UrlEncode(cipherDt);

                string url = siteUrlSetting.Value + "/ResetPassword.aspx?e=" + encodedEmail + "&d=" + dateExpireTicks;

                StringBuilder sb = new StringBuilder();
                sb.Append(account.Name);
                sb.Append(":<br />您好,请在24小时内点击如下链接更改您的UME密码");
                sb.Append("<a target='_blank' href='");
                sb.Append(url);
                sb.Append("'>");
                sb.Append(url);
                sb.Append("</a>");

                bool succeed;
                /*
                 * succeed = CY.Utility.Common.EmailUtility.SendEmailThroughGmail(
                     gmailAccountSetting.Value,
                     gmailAccountPasswordSetting.Value,
                     account.ExtendInfo.Email,
                     "重置您的UME密码",
                     sb.ToString(),
                     string.Empty);
                */

                succeed = Core.Global.TrySendMail(
                    account.ExtendInfo.Email,
                    "重置您的UME密码",
                    sb.ToString(),
                    string.Empty);

                if (succeed)
                {
                    base.ShowAlert("成功", "您的请求已提交,请注意查收您的邮件。", true, "", false);
                    ExecuteClientScript("setTimeout(function(){ window.location.href='Login.aspx'; }, 3000);");
                }
                else
                {
                    base.ShowAlert("错误提示", "服务器忙,请稍后再试", false, "", false);
                    return;
                }
            }
            catch
            {
                ShowAlert("错误提示", "服务器忙,请稍后再试");
                return;
            }
        }
Exemple #16
0
        void HandleAutoLogin()
        {
            CY.UME.Core.Business.Account account;

            if (Session["user"] != null)
            {
                long accountId;

                bool succeed = long.TryParse(Session["user"].ToString(),
                    out accountId);

                if (succeed)
                {
                    account = Core.Business.Account.Load(accountId);
                    if (account != null)
                    {
                        int num = CY.UME.Core.Business.Friendship.GetFriendshipCount(account) + CY.UME.Core.Business.Friendship.GetRequestFriendShipCount(account);
                        if (num <= 1)
                        {
                            Response.Redirect("~/Guide.aspx");
                            return;
                        }
                        Response.Redirect("~/Index.aspx");
                        return;
                    }
                }
            }

            if (Request.Cookies["sid"] == null)
            {
                return;
            }

            String sid = Request.Cookies["sid"].Value;
            string[] sa = sid.Split(':');
            if (sa.Length == 4)
            {
                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                try
                {
                    string email;
                    string password;
                    string ip;
                    string expectedIP = sh.ComputeMD5Hash(CY.Utility.Common.RequestUtility.ClientIP);
                    DateTime dateExpire;

                    email = sh.Decrypt(sa[0], CY.Security.EncryptionAlgorithm.TripleDes);
                    password = sh.Decrypt(sa[1], CY.Security.EncryptionAlgorithm.TripleDes);
                    string dt = sh.Decrypt(sa[2], CY.Security.EncryptionAlgorithm.TripleDes);
                    ip = sa[3];

                    if (expectedIP != ip)
                    {
                        return;
                    }

                    long tick;
                    if (long.TryParse(dt, out tick))
                    {
                        dateExpire = new DateTime(tick);
                        if (dateExpire > DateTime.Now)
                        {
                            bool valid = CY.UME.Core.Business.Account.IsLoginValid(email, password, out account);
                            if (valid)
                            {
                                Session.Add("user", account.Id.ToString());
                                SaveAccountCookie(email, password);//保存Cookie用于问问吧登录

                                AddLoginCredit(account);
                                int num = CY.UME.Core.Business.Friendship.GetFriendshipCount(account) + CY.UME.Core.Business.Friendship.GetRequestFriendShipCount(account);
                                if (num <= 1)
                                {
                                    Response.Redirect("~/Guide.aspx?uid=" + account.Id);
                                    return;
                                }
                                else
                                {
                                    Response.Redirect("~/Index.aspx?uid=" + account.Id);
                                    return;
                                }
                            }
                        }
                    }
                }
                catch { }
            }
        }
Exemple #17
0
        //在不退出的情况下保存7天
        void WriteStayLoginCookie(string email, string password)
        {
            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            string emailTemp = sh.Encrypt(email, CY.Security.EncryptionAlgorithm.TripleDes);
            string passwordTemp = sh.Encrypt(password, CY.Security.EncryptionAlgorithm.TripleDes);
            string ticks = sh.Encrypt(DateTime.Now.AddDays(7).Ticks.ToString(), CY.Security.EncryptionAlgorithm.TripleDes);
            string ClientIP = sh.ComputeMD5Hash(CY.Utility.Common.RequestUtility.ClientIP);

            CY.UME.Core.Business.Account.WriteStayCookie(emailTemp, passwordTemp, "sid", 0, ticks, ClientIP);
        }
        public ActionResult Login(Core.Business.Account model)
        {
            if (string.IsNullOrEmpty(model.LoginName) || string.IsNullOrEmpty(model.Password))
            {
                TempData["HintMessage"] = new HintMessage { Content = "登录失败,请检查用户名和密码是否匹配" };
                return this.ReLogin("登录失败,请检查用户名和密码是否匹配!");
            }
            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            string oldPwd = sh.ComputeMD5Hash(model.Password);
            Core.Business.Account account = Core.Business.Account.FindBy(model.LoginName.ToLower(), oldPwd.ToLower());
            if (account == null)
            {
                TempData["HintMessage"] = new HintMessage { Content = "登录失败,请检查用户名和密码是否匹配" };
                return this.ReLogin("登录失败,请检查用户名和密码是否匹配!");
            }
            else
            {
                PhotoGallery.Application.UserSession.OnlineAccount = account;
                TempData["HintMessage"] = new HintMessage { Content = string.Format("登录成功,{0},欢迎您的到来!", account.Name) };
                return RedirectToAction("Index", "Home");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            string strAlbumId;
            CY.UME.Core.Business.Album album;
            CY.UME.Core.Business.Account account;
            long albumId = 0;

            if (context.Request.QueryString["albumId"] == null || CY.UME.Core.Global.GetCurrentAccount() == null)
            {
                return;
            }
            strAlbumId = context.Request.QueryString["albumId"].ToString();
            account = CY.UME.Core.Global.GetCurrentAccount();
            if (!long.TryParse(strAlbumId, out albumId) || account == null)
            {
                return;
            }

            album = CY.UME.Core.Business.Album.Load(albumId);

            if (album == null || album.Id == 0)
            {
                return;
            }

            string picPath = album.CoverPath;
            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            if (album.ViewPermission == 2)
            {
                picPath = CY.UME.Core.Global.AlbumCoverNoPublishAddress;
            }
            else if (album.PhotoCount == 0)
            {
                picPath = CY.UME.Core.Global.AlbumCoverAddress;
            }

            try
            {
                if (!File.Exists(CY.Utility.Common.SiteUtility.CurSitePath + picPath))
                {
                    picPath = CY.UME.Core.Global.AlbumCoverAddress;
                }

                Image img = Bitmap.FromFile(CY.Utility.Common.SiteUtility.CurSitePath + picPath);

                context.Response.Clear();
                TimeSpan cacheDuration = TimeSpan.FromDays(1);
                context.Response.Cache.SetCacheability(HttpCacheability.Public);
                context.Response.Cache.SetExpires(DateTime.Now.Add(cacheDuration));
                context.Response.Cache.SetMaxAge(cacheDuration);
                context.Response.Cache.AppendCacheExtension("must-revalidate, proxy-revalidate");

                switch (CY.Utility.Common.FileUtility.GetFileExtension(picPath))
                {
                    case ".gif":
                        context.Response.ContentType = "image/gif";
                        img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
                        break;
                    case ".jpg":
                    case ".jpeg":
                        context.Response.ContentType = "image/jpeg";
                        img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                        break;
                    default:
                        context.Response.ContentType = "image/jpeg";
                        img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                        break;
                }
            }
            catch
            {
                ;
            }
        }
        public ActionResult UpdatePassword(int? id, string loginName, string oldPwd, string newPwd)
        {
            if (!string.IsNullOrEmpty(loginName))
            {
                if (string.IsNullOrEmpty(newPwd))
                {
                    return Json(new { success = false, message = "当前输入的新密码不能为空" });
                }

                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                oldPwd = sh.ComputeMD5Hash(oldPwd);

                Core.Business.Account account = Core.Business.Account.Load(UserSession.OnlineAccount.Id);

                if (account == null)
                    return Json(new { success = true, message = "请确认用户是否存在!", JsonRequestBehavior.AllowGet });

                if (account != null && account.LoginName.Equals(loginName) && account.Password.Equals(oldPwd))
                {
                    // 修改密码
                    newPwd = sh.ComputeMD5Hash(newPwd);
                    account.LoginName = loginName;
                    account.Password = newPwd;
                    account.LoginName = loginName;
                    return Json(new { success = true, message = "修改密码已成功", JsonRequestBehavior.AllowGet });
                }
                else
                {
                    return Json(new { success = false, message = "原密码错误" });
                }
            }
            else
            {
                return Json(new { success = false, message = "当前用户登录名不能为空" });
            }
        }
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LBSubmint_Click(object sender, EventArgs e)
        {
            try
            {
                if (TxtEmail.Text.Length == 0)
                {
                    return;
                }
                log.Info("注册开始");
                if (Session["CaptchaImageText"] == null)
                {
                    ShowAlert("注册失败", "服务器忙,请稍后再试!");
                    return;
                }

                string validateCode = Session["CaptchaImageText"].ToString();
                if (TxtValidCode.Text != validateCode)
                {
                    ShowAlert("注册失败", "验证码错误!");
                    return;
                }
                if (string.IsNullOrEmpty(TxtSudentCode.Text))
                {
                    ShowAlert("注册失败", "学号不能为空");
                    return;
                }
                if (string.IsNullOrEmpty(TxtUserName.Text))
                {
                    ShowAlert("注册失败", "姓名不能为空");
                    return;
                }
                if (TxtUserPassword.Text.Length < 6 ||
                    TxtUserPassword.Text.Length > 20)
                {
                    ShowAlert("注册失败", "密码长度必须在6至20之间");
                    return;
                }
                String ZipRegex = @"/^\w{0,19}$/";
                if (System.Text.RegularExpressions.Regex.IsMatch(TxtUserPassword.Text, ZipRegex))
                {
                    ShowAlert("注册失败", "密码含有非法字符,只能输入数字、字母和\"_\"的组合。");
                    return;
                }
                if (String.Compare(TxtUserPassword.Text.Trim(), TxtUserPasswordAgain.Text.Trim()) != 0)
                {
                    ShowAlert("注册失败", "两次密码输入不一致,请重新输入。");
                    return;
                }
                if (!RBGenderFemale.Checked && !RBGenderMale.Checked)
                {
                    ShowAlert("注册失败", "性别不能为空");
                    return;
                }

                if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
                {
                    ;
                }
                else if ( YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0")
                {
                    ShowAlert("提示", "请完善您的生日信息!");
                    return;
                }

                Guid id = new Guid(Request.QueryString["id"]);
                CY.UME.Core.Business.AccountInviteInfo aii = CY.UME.Core.Business.AccountInviteInfo.Load(id);
                if (aii == null)
                {
                    ShowAlert("注册失败", "邀请已失效!");
                    return;
                }

                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                CY.UME.Core.Business.Account account = new CY.UME.Core.Business.Account();
                account.Code = TxtSudentCode.Text;
                account.DateCreated = DateTime.Now;
                account.HasAvatar = false;
                account.IsTeacher = false;
                account.Name = TxtUserName.Text;
                account.NickName = string.Empty;
                account.ViewNumber = 0;
                account.Save();

                // extend info
                CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(account.Id);

                if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
                {
                    ae.Birthday = UME.Core.Global.MinDateTime;
                }
                else if (YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0")
                {
                    ShowAlert("提示", "请完善您的生日信息!");
                    return;
                }
                else
                {
                    int day = 0, month = 0, year = 0;
                    if (int.TryParse(DayHF.Value, out day))
                        ae.BirthDate = day;
                    if (int.TryParse(MonthHF.Value, out month))
                        ae.BirthMonth = month;
                    if (int.TryParse(YearHF.Value, out year))
                        ae.BirthYear = year;

                    ae.Birthday = new DateTime(year, month, day);//生日
                }
                ae.Email = TxtEmail.Text;
                ae.Gender = RBGenderMale.Checked ? 1 : 0;
                ae.IsEmailChecked = true;
                //ae.LibUserId = 0;
                ae.Password = sh.ComputeMD5Hash(TxtUserPassword.Text);
                ae.UniversityId = CY.Utility.Common.ConvertUtility.ConvertToInt(selUniversity.Value, -1);// 学校
                ae.CollegeId = CY.Utility.Common.ConvertUtility.ConvertToInt(selCollege.Value, -1);// 学院
                ae.GradeId = int.Parse(DDLGrades.SelectedValue);
                ae.Save();

                // add friendship
                CY.UME.Core.Business.Friendship fs = new CY.UME.Core.Business.Friendship();
                fs.AccountId = aii.InviterId;
                fs.DateCreated = DateTime.Now;
                fs.CommunicateNum = 0;
                fs.FriendId = account.Id;
                fs.IsChecked = true;
                fs.Remark = string.Empty;
                fs.Save();

                fs = new CY.UME.Core.Business.Friendship();
                fs.AccountId = account.Id;
                fs.CommunicateNum = 0;
                fs.DateCreated = DateTime.Now;
                fs.FriendId = aii.InviterId;
                fs.IsChecked = true;
                fs.Remark = string.Empty;
                fs.Save();

                aii.IsAccepted = true;
                aii.Save();

                #region 更新邀请人的积分

                int inviteFriendCredit;
                if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount", out inviteFriendCredit) &&
                    (inviteFriendCredit != 0))
                {
                    CY.UME.Core.Business.Account invitor = CY.UME.Core.Business.Account.Load(aii.InviterId);
                    if (invitor != null)
                    {
                        int orgCredit = invitor.Credit;
                        int modifiedCredit = orgCredit + inviteFriendCredit;

                        invitor.Credit = modifiedCredit;
                        invitor.Save();

                        CreditHistory ch = new CreditHistory();
                        ch.AccountId = invitor.Id;
                        ch.DateCreated = DateTime.Now;
                        ch.Id = Guid.NewGuid();
                        ch.InstanceId = aii.Id.ToString();
                        ch.Original = orgCredit;
                        ch.Modified = modifiedCredit;
                        ch.Variation = inviteFriendCredit;
                        ch.Type = "invitefriend";
                        ch.Description = "成功邀请用户 " + account.Name;
                        ch.Save();

                        // 邀请层级效应
                        CY.UME.Core.Business.Account invitor2 = invitor.GetInviter();
                        if (invitor2 != null)
                        {
                            int inviteFriendCredit2;
                            if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount2", out inviteFriendCredit2) &&
                                (inviteFriendCredit2 != 0))
                            {
                                orgCredit = invitor2.Credit;
                                modifiedCredit = orgCredit + inviteFriendCredit2;
                                invitor2.Credit = modifiedCredit;
                                invitor2.Save();

                                ch = new CreditHistory();
                                ch.AccountId = invitor2.Id;
                                ch.DateCreated = DateTime.Now;
                                ch.Id = Guid.NewGuid();
                                ch.InstanceId = aii.Id.ToString();
                                ch.Original = orgCredit;
                                ch.Modified = modifiedCredit;
                                ch.Variation = inviteFriendCredit2;
                                ch.Type = "invitefriend";
                                ch.Description = "所邀请用户 " + invitor.Name + " 成功邀请了 " + account.Name;
                                ch.Save();
                            }
                        }
                    }
                }

                #endregion
                log.Info("注册结束");

                if (Session["user"] != null)
                {
                    Session["user"] = account.Id.ToString();
                }
                else
                {
                    Session.Add("user", account.Id.ToString());
                }

                ShowAlert("注册成功", "恭喜您已经成功注册UME账号,现在系统将引导您至完善个人信息页面");
                ExecuteClientScript("setTimeout(function(){window.location.href='UploadAvatar.aspx?type=firstNum'}, 2000)");
            }
            catch (Exception ex)
            {
                log.Error("用户注册失败:" + ex.Message);
            }
        }
        public JsonResult UpdatePwd(string loginName, string oldPwd, string newPwd)
        {
            if (!string.IsNullOrEmpty(loginName))
            {
                if (string.IsNullOrEmpty(newPwd))
                {
                    return Json(new { success = false, message = "当前输入的新密码不能为空" });
                }

                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                oldPwd = sh.ComputeMD5Hash(oldPwd);

                Account account = repository.FindBy(loginName.ToLower(), oldPwd.ToLower());
                if (account != null)
                {
                    // 修改密码
                    newPwd = sh.ComputeMD5Hash(newPwd);
                    account.Password = newPwd;
                    repository[account.Key] = account;
                    unitOfWork.Commit();

                    return Json(new { success = true, message = "修改密码已成功", JsonRequestBehavior.AllowGet });
                }
                else
                {
                    return Json(new { success = false, message = "原密码错误" });
                }
            }
            else
            {
                return Json(new { success = false, message = "当前用户登录名不能为空" });
            }
        }
Exemple #23
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LB_Next_Click(object sender, EventArgs e)
        {
            if (TxtEmail.Text.Length == 0)
            {
                return;
            }

            CY.UME.Core.Business.SystemLog.SaveLog("Info", "注册开始");

            if (Session["CaptchaImageText"] == null)// 验证码
            {
                ShowAlert("注册失败", "服务器忙,请稍后再试!");
                return;
            }

            string validateCode = Session["CaptchaImageText"].ToString();

            if (TxtValidCode.Text != validateCode)
            {
                ShowAlert("注册失败", "验证码错误!");
                return;
            }
            if (string.IsNullOrEmpty(TxtSudentCode.Text))
            {
                ShowAlert("注册失败", "学号不能为空");
                return;
            }
            if (string.IsNullOrEmpty(TxtUserName.Text))
            {
                ShowAlert("注册失败", "姓名不能为空");
                return;
            }
            if (TxtUserPassword.Text.Length < 6 ||
                TxtUserPassword.Text.Length > 20)
            {
                ShowAlert("注册失败", "密码长度必须在6至20之间");
                return;
            }
            String ZipRegex = @"/^\w{0,19}$/";
            if (System.Text.RegularExpressions.Regex.IsMatch(TxtUserPassword.Text, ZipRegex))
            {
                ShowAlert("注册失败", "密码含有非法字符,只能输入数字、字母和\"_\"的组合。");
                return;
            }
            if (String.Compare(TxtUserPassword.Text.Trim(), TxtUserPasswordAgain.Text.Trim()) != 0)
            {
                ShowAlert("注册失败", "两次密码输入不一致,请重新输入。");
                return;
            }
            if (!RBGenderFemale.Checked && !RBGenderMale.Checked)
            {
                ShowAlert("注册失败", "性别不能为空");
                return;
            }

            if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
            {
                ;
            }
            else if (YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0")
            {
                ShowAlert("提示", "请完善您的生日信息!");
                return;
            }

            CY.UME.Core.Business.AccountExtend aeTemp = CY.UME.Core.Business.AccountExtend.Load(TxtEmail.Text.Trim());
            if (aeTemp != null)
            {
                ShowAlert("提示", "该邮箱已被使用!");
                return;
            }

            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            CY.UME.Core.Business.Account account = new CY.UME.Core.Business.Account();
            account.Code = TxtSudentCode.Text;
            account.DateCreated = DateTime.Now;
            account.HasAvatar = false;
            account.IsTeacher = false;
            account.Name = TxtUserName.Text;
            account.NickName = string.Empty;
            account.ViewNumber = 0;
            account.Save();

            // extend info
            CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(account.Id);

            if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
            {
                ae.Birthday = UME.Core.Global.MinDateTime;
            }
            else
            {
                int day = 0, month = 0, year = 0;
                if (int.TryParse(DayHF.Value, out day))
                    ae.BirthDate = day;
                if (int.TryParse(MonthHF.Value, out month))
                    ae.BirthMonth = month;
                if (int.TryParse(YearHF.Value, out year))
                    ae.BirthYear = year;

                ae.Birthday = new DateTime(year, month, day);//生日
            }
            ae.Email = TxtEmail.Text.Trim();
            ae.Gender = RBGenderMale.Checked ? 1 : 0;
            ae.IsEmailChecked = true;
            //ae.LibUserId = 0;
            ae.Password = sh.ComputeMD5Hash(TxtUserPassword.Text);
            ae.UniversityId = CY.Utility.Common.ConvertUtility.ConvertToInt(HFUniversity.Value, -1);// 学校
            ae.CollegeId = CY.Utility.Common.ConvertUtility.ConvertToInt(HFCollege.Value, -1);// 学院
            ae.GradeId = int.Parse(DDLGrades.SelectedValue);
            ae.IsShow = 0;
            ae.Save();

            try
            {
                /**************************************************废除的代码/*************************************************/
                /************************MySQL数据库同步开始*************************
                CY.UME.Core.Business.Ask_members members = new CY.UME.Core.Business.Ask_members();
                members.Id = account.Id;
                members.Username = ae.Email;
                members.Password = ae.Password;
                //members.Secques = "";
                members.Save();

                CY.UME.Core.Business.Ask_memberfields memberfields = new CY.UME.Core.Business.Ask_memberfields();
                memberfields.Id = account.Id;
                memberfields.Username = ae.Email;
                memberfields.Email = ae.Email;
                memberfields.Nickname = account.NickName;
                memberfields.Realname = account.Name;//HFURLEncodeName.Value;
                memberfields.Gender = ae.Gender;
                memberfields.Birthday = 0;
                memberfields.Score = 200;//后面去改
                memberfields.Save();
                /************************MySQL数据库同步结束*************************/
            }
            catch (Exception ex)
            {
                CY.UME.Core.Business.SystemLog.SaveLog("Error", "用户同步失败:" + ex.Message);
            }

            CY.UME.Core.Business.SystemLog.SaveLog("Info", account.Name + "注册成功");

            if (Session["user"] != null)
            {
                Session["user"] = account.Id.ToString();
            }
            else
            {
                Session.Add("user", account.Id.ToString());
            }
            try
            {
                if (!string.IsNullOrEmpty(Request.QueryString["inviterId"]))
                {
                    long inviterId = CY.Utility.Common.ConvertUtility.ConvertToLong(Request.QueryString["inviterId"], -1);

                    if (inviterId != -1)
                    {
                        Core.Business.Account InviteFriendAccount = Core.Business.Account.Load(inviterId);

                        if (InviteFriendAccount != null)
                        {//邀请用户须存在
                            AccountInviteInfo ai = new AccountInviteInfo();
                            ai.Id = Guid.NewGuid();
                            ai.InviterId = inviterId;
                            ai.InviteeEmail = ae.Email;
                            ai.DateCreated = account.DateCreated;
                            ai.IsAccepted = true;
                            ai.Remark = "从活动过来的";
                            ai.Save();

                            CY.UME.Core.Business.Friendship fs = new Friendship();

                            fs.AccountId = account.Id;
                            fs.DateCreated = DateTime.Now;
                            fs.FriendId = InviteFriendAccount.Id;
                            fs.IsChecked = true;
                            fs.Remark = "活动邀请";
                            fs.Save();

                            CY.UME.Core.Business.Friendship fs2 = new Friendship();

                            fs2.AccountId = InviteFriendAccount.Id;
                            fs2.FriendId = account.Id;
                            fs2.DateCreated = DateTime.Now;
                            fs2.IsChecked = true;
                            fs2.Remark = "活动邀请";
                            fs2.Save();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(Request.QueryString["invId"]))
                {
                    long invId = CY.Utility.Common.ConvertUtility.ConvertToLong(Request.QueryString["invId"], -1);

                    if (invId != -1)
                    {
                        Core.Business.AccountInviteInfo InviteAccount = new AccountInviteInfo();
                        InviteAccount.Id = Guid.NewGuid();
                        InviteAccount.InviterId = invId;
                        InviteAccount.DateCreated = DateTime.Now;
                        InviteAccount.InviteeEmail = ae.Email;
                        InviteAccount.IsAccepted = true;
                        InviteAccount.Save();

                        #region 更新邀请人的积分

                        int inviteFriendCredit;
                        if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount", out inviteFriendCredit) &&
                            (inviteFriendCredit != 0))
                        {
                            CY.UME.Core.Business.Account invitor = CY.UME.Core.Business.Account.Load(invId);
                            if (invitor != null)
                            {
                                CY.UME.Core.Business.Friendship fs = new Friendship();

                                fs.AccountId = account.Id;
                                fs.DateCreated = DateTime.Now;
                                fs.FriendId = invitor.Id;
                                fs.IsChecked = true;
                                fs.Remark = "被链接邀请";
                                fs.Save();

                                CY.UME.Core.Business.Friendship fs2 = new Friendship();

                                fs2.AccountId = invitor.Id;
                                fs2.FriendId = account.Id;
                                fs2.DateCreated = DateTime.Now;
                                fs2.IsChecked = true;
                                fs2.Remark = "链接邀请";
                                fs2.Save();

                                int orgCredit = invitor.Credit;
                                int modifiedCredit = orgCredit + inviteFriendCredit;

                                invitor.Credit = modifiedCredit;
                                invitor.Save();

                                CreditHistory ch = new CreditHistory();
                                ch.AccountId = invitor.Id;
                                ch.DateCreated = DateTime.Now;
                                ch.Id = Guid.NewGuid();
                                ch.InstanceId = invId.ToString();
                                ch.Original = orgCredit;
                                ch.Modified = modifiedCredit;
                                ch.Variation = inviteFriendCredit;
                                ch.Type = "invitefriend";
                                ch.Description = "成功邀请用户 " + account.Name;
                                ch.AssistAccountId = account.Id;
                                ch.Save();

                                // 邀请层级效应
                                CY.UME.Core.Business.Account invitor2 = invitor.GetInviter();
                                if (invitor2 != null)
                                {
                                    int inviteFriendCredit2;
                                    if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount2", out inviteFriendCredit2) &&
                                        (inviteFriendCredit2 != 0))
                                    {
                                        orgCredit = invitor2.Credit;
                                        modifiedCredit = orgCredit + inviteFriendCredit2;
                                        invitor2.Credit = modifiedCredit;
                                        invitor2.Save();

                                        ch = new CreditHistory();
                                        ch.AccountId = invitor2.Id;
                                        ch.DateCreated = DateTime.Now;
                                        ch.Id = Guid.NewGuid();
                                        ch.InstanceId = invId.ToString();
                                        ch.Original = orgCredit;
                                        ch.Modified = modifiedCredit;
                                        ch.Variation = inviteFriendCredit2;
                                        ch.Type = "invitefriend";
                                        ch.Description = "所邀请用户 " + invitor.Name + " 成功邀请了 " + account.Name;
                                        ch.Save();
                                    }
                                }
                            }
                        }

                        #endregion
                    }
                }

            }
            catch (Exception)
            { }

            //ShowAlert("注册成功", "恭喜您已经成功注册UME账号,现在系统将引导您至完善个人信息页面");
            //ExecuteClientScript("setTimeout(function(){window.location.href='UploadAvatar.aspx?type=firstNum'}, 1000)")
            SaveAccountCookie(TxtEmail.Text.Trim(), sh.ComputeMD5Hash(TxtUserPassword.Text));//保存Cookie用于问问吧登录
            Server.Transfer("UploadAvatar.aspx?type=firstNum");
        }
Exemple #24
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (ViewState["accountId"] == null)
            {
                throw new Exception("系统异常");
            }

            CY.UME.Core.Business.Album alb = new CY.UME.Core.Business.Album();
            if (ViewState["albumId"] != null && ViewState["IsModify"] != null && bool.Parse(ViewState["IsModify"].ToString()))
            {
                alb = CY.UME.Core.Business.Album.Load(long.Parse(ViewState["albumId"].ToString()));

            }
            else
            {
                alb.AccountId = int.Parse(ViewState["accountId"].ToString());
                alb.DateCreated = DateTime.Now;
                alb.CoverPath = CY.UME.Core.Global.AlbumCoverAddress;
            }
            alb.LastModifiedTime = DateTime.Now;
            alb.Name = TBXAlbumName.Text.Trim();

            if (alb.ViewPermission==2 && alb.ViewPermission != int.Parse(SelViewPermission.Value))
            {
                alb.ViewPassword = String.Empty;

            }
            alb.ViewPermission = int.Parse(SelViewPermission.Value);

            if (SelViewPermission.Value == "2")
            {
                if (TBXpassword.Text.Trim().Length == 0)
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '密码不能为空'})</script>");
                    return;
                }
                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                alb.ViewPassword =sh.ComputeMD5Hash(TBXpassword.Text.Trim());
                alb.CoverPath = CY.UME.Core.Global.AlbumCoverNoPublishAddress;
            }
            else
            {
                CY.UME.Core.PagingInfo pageinfo = new CY.UME.Core.PagingInfo();
                pageinfo.CurrentPage=1;
                pageinfo.PageSize =1;

                List<CY.UME.Core.Business.Picture> picList = CY.UME.Core.Business.Picture.GetAllPicture(album, pageinfo);
                if (picList != null && picList.Count > 0)
                    alb.CoverPath = picList[0].MiddlePath;
            }
            try
            {
                alb.Save();
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '提示', content: '修改成功'});window.location.href='AlbumList.aspx?spaceId=" + long.Parse(ViewState["accountId"].ToString()) + "'</script>");
            }
            catch
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({title: '错误', content: '保存失败,发生意外错误'});</script>");
            }
        }
Exemple #25
0
        public void ProcessRequest(HttpContext context)
        {
            long pictureId;
            int groupId = 0;
            string password;
            string mark;
            string strPictureId;
            string strGroupId;

            CY.UME.Core.Business.Picture picture;
            CY.UME.Core.Business.Account account;
            CY.UME.Core.Business.Album album;
            CY.UME.Core.Business.AlbumExtend ae;
            CY.UME.Core.Business.Group group;

            #region Validation

            if (context.Request.QueryString["pictureId"] == null || context.Request.QueryString["mark"] == null)
            {
                return;
            }
            strPictureId = context.Request.QueryString["pictureId"].ToString();
            mark = context.Request.QueryString["mark"].ToString().Trim();
            strGroupId = context.Request.QueryString["groupId"].ToString().Trim();

            if (!CY.Utility.Common.ParseUtility.TryParseInt64(strPictureId, out pictureId))
            {
                return;
            }

            picture = CY.UME.Core.Business.Picture.Load(pictureId);
            album = CY.UME.Core.Business.Album.Load(picture.AlbumId);
            ae = CY.UME.Core.Business.AlbumExtend.Load(album.Id);

            if (picture == null || album == null || album.Id == 0)
            {
                return;
            }

            account = CY.UME.Core.Global.GetCurrentAccount();

            if (ae == null || ae.Id == 0)
            {
                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
                if (album.ViewPermission == 1)//好友浏览
                {
                    CY.UME.Core.Business.Account spaceAccount = CY.UME.Core.Business.Account.Load(album.AccountId);
                    if (account == null || !account.HasFriendshipWith(spaceAccount))
                    {
                        return;
                    }
                }
                else if (album.ViewPermission == 2)//凭密码访问
                {
                    if (account == null || album.AccountId != account.Id)
                    {
                        if (context.Session["AlbumPassword"] == null)
                        {
                            return;
                        }
                        password = context.Session["AlbumPassword"].ToString().Trim();
                        if (password != sh.ComputeMD5Hash(album.ViewPassword))
                        {
                            return;
                        }
                    }
                }
                else if (album.ViewPermission == 3)//仅自己访问
                {
                    if (account == null || album.Id != account.Id)
                    {
                        return;
                    }
                }
            }
            else
            {
                if (ae.Type == "group")
                {
                    int.TryParse(strGroupId, out groupId);
                    group = CY.UME.Core.Business.Group.Load(groupId);
                    if (album.ViewPermission == 1)  //群成员浏览
                    {
                        if (!group.CheckIsGroupMember(account))
                        {
                            return;
                        }
                    }
                }
            }

            #endregion

            try
            {
                string picPath = picture.BigPath;

                context.Response.Clear();
                TimeSpan cacheDuration = TimeSpan.FromDays(1);
                context.Response.Cache.SetCacheability(HttpCacheability.Public);
                context.Response.Cache.SetExpires(DateTime.Now.Add(cacheDuration));
                context.Response.Cache.SetMaxAge(cacheDuration);
                context.Response.Cache.AppendCacheExtension("must-revalidate, proxy-revalidate");

                switch (mark)
                {
                    case "small":
                        picPath = picture.MiddlePath;//图片列表中的图片
                        break;
                    case "big":
                        picPath = picture.BigPath;//大图片
                        break;
                    case "middle":
                        picPath = picture.SmallPath;
                        break;
                    case "cover":
                        picPath = album.CoverPath;//封面
                        break;
                    default:
                        picPath = picture.BigPath;
                        break;
                }
                Image img = Bitmap.FromFile(CY.Utility.Common.SiteUtility.CurSitePath + picPath);
                switch (CY.Utility.Common.FileUtility.GetFileExtension(picPath))
                {
                    case ".gif":
                        context.Response.ContentType = "image/gif";
                        img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
                        break;
                    case ".jpg":
                    case ".jpeg":
                        context.Response.ContentType = "image/jpeg";
                        img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                        break;
                    default:
                        context.Response.ContentType = "image/jpeg";
                        img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                        break;
                }

                img.Dispose();
            }
            catch
            {
                ;
            }
        }
        void ResetByPhone(CY.UME.Core.Business.Account account)
        {
            string phone = account.ExtendInfo.Telephone;
            if (string.IsNullOrEmpty(phone))
            {
                base.ShowAlert("错误提示", "您尚不是手机绑定用户,不能进行此操作!", false, "", false);
                return;
            }

            string newPwd = CY.Utility.Common.StringUtility.GenerateRandomText(8);
            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();
            account.ExtendInfo.Password = sh.ComputeMD5Hash(newPwd);
            account.ExtendInfo.Save();

            StringBuilder sbContent = new StringBuilder();
            sbContent.Append(account.Name);
            sbContent.Append(",您的UME密码已更新为");
            sbContent.Append(newPwd);
            sbContent.Append("。登录后您可以在");
            sbContent.Append(SiteUrl);
            sbContent.Append("/ChangePassword.aspx页面更改密码");
            string code;
            bool succeed = CY.UME.Core.Global.TrySendMessage(phone, sbContent.ToString(), out code);

            base.ShowAlert("成功", "您的新密码将发送到您手机上,请注意查收...", true, "", false);
        }