Пример #1
0
 private void SendEmail(SiteSettings settings, string email)
 {
     try
     {
         string     text       = HiContext.Current.CreateVerifyCode(4);
         ConfigData configData = new ConfigData(HiCryptographer.Decrypt(settings.EmailSettings));
         string     body       = string.Format("尊敬的会员{0}您好:欢迎使用" + settings.SiteName + "系统,此次验证码为:{1},请在3分钟内完成验证", HiContext.Current.User.Username, text);
         System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage
         {
             IsBodyHtml      = true,
             Priority        = System.Net.Mail.MailPriority.High,
             SubjectEncoding = System.Text.Encoding.UTF8,
             BodyEncoding    = System.Text.Encoding.UTF8,
             Body            = body,
             Subject         = "来自" + settings.SiteName
         };
         mailMessage.To.Add(email);
         EmailSender emailSender = EmailSender.CreateInstance(settings.EmailSender, configData.SettingsXml);
         if (emailSender.Send(mailMessage, System.Text.Encoding.GetEncoding(HiConfiguration.GetConfig().EmailEncoding)))
         {
             this.message = "{\"success\":true,\"msg\":\"发送邮件成功,请查收\"}";
             HiCache.Insert(email + "email", text, 10800);
         }
         else
         {
             this.message = "{\"success\":false,\"msg\":\"发送邮件失败,请检查邮箱账号是否存在\"}";
         }
     }
     catch (System.Exception)
     {
         this.message = "{\"success\":false,\"msg\":\"发送失败,请检查邮箱账号是否存在\"}";
     }
 }
Пример #2
0
        private void Application_BeginRequest(object source, EventArgs e)
        {
            this.currentApplicationType = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;
            HttpApplication application = (HttpApplication)source;
            HttpContext     context     = application.Context;

            if (context.Request.RawUrl.IndexOfAny(new char[] { '<', '>', '\'', '"' }) != -1)
            {
                context.Response.Redirect(context.Request.RawUrl.Replace("<", "%3c").Replace(">", "%3e").Replace("'", "%27").Replace("\"", "%22"), false);
            }
            else
            {
                this.CheckInstall(context);
                if (this.currentApplicationType != ApplicationType.Installer)
                {
                    CheckSSL(HiConfiguration.GetConfig().SSL, context);
                    HiContext.Create(context, new UrlReWriterDelegate(HiHttpModule.ReWriteUrl));
                    if (HiContext.Current.SiteSettings.IsDistributorSettings && !((!HiContext.Current.SiteSettings.Disabled || (this.currentApplicationType != ApplicationType.Common)) || urlReg.IsMatch(context.Request.Url.AbsolutePath)))
                    {
                        context.Response.Write("站点维护中,暂停访问!");
                        context.Response.End();
                    }
                }
            }
        }
Пример #3
0
 public static void SendQueuedEmails(int failureInterval, int maxNumberOfTries, SiteSettings settings)
 {
     if (settings != null)
     {
         HiConfiguration config = HiConfiguration.GetConfig();
         System.Collections.Generic.Dictionary <System.Guid, System.Net.Mail.MailMessage> dictionary = new EmailQueueDao().DequeueEmail();
         System.Collections.Generic.IList <System.Guid> list = new System.Collections.Generic.List <System.Guid>();
         EmailSender emailSender = Messenger.CreateEmailSender(settings);
         if (emailSender != null)
         {
             int   num = 0;
             short smtpServerConnectionLimit = config.SmtpServerConnectionLimit;
             foreach (System.Guid current in dictionary.Keys)
             {
                 if (Messenger.SendMail(dictionary[current], emailSender))
                 {
                     new EmailQueueDao().DeleteQueuedEmail(current);
                     if (smtpServerConnectionLimit != -1 && ++num >= (int)smtpServerConnectionLimit)
                     {
                         System.Threading.Thread.Sleep(new System.TimeSpan(0, 0, 0, 15, 0));
                         num = 0;
                     }
                 }
                 else
                 {
                     list.Add(current);
                 }
             }
             if (list.Count > 0)
             {
                 new EmailQueueDao().QueueSendingFailure(list, failureInterval, maxNumberOfTries);
             }
         }
     }
 }
Пример #4
0
        private void btnEditPassWordOK_Click(object sender, EventArgs e)
        {
            ManagerInfo manager = ManagerHelper.GetManager(this.userId);

            if ((Globals.GetCurrentManagerUserId() == this.userId) && (manager.Password != HiCryptographer.Md5Encrypt(this.txtOldPassWord.Text)))
            {
                this.ShowMsg("旧密码输入不正确", false);
            }
            else if ((string.IsNullOrEmpty(this.txtNewPassWord.Text) || (this.txtNewPassWord.Text.Length > 20)) || (this.txtNewPassWord.Text.Length < 6))
            {
                this.ShowMsg("密码不能为空,长度限制在6-20个字符之间", false);
            }
            else if (string.Compare(this.txtNewPassWord.Text, this.txtPassWordCompare.Text) != 0)
            {
                this.ShowMsg("两次输入的密码不一样", false);
            }
            else
            {
                HiConfiguration config = HiConfiguration.GetConfig();
                if ((string.IsNullOrEmpty(this.txtNewPassWord.Text) || (this.txtNewPassWord.Text.Length < 6)) || (this.txtNewPassWord.Text.Length > config.PasswordMaxLength))
                {
                    this.ShowMsg(string.Format("管理员登录密码的长度只能在{0}和{1}个字符之间", 6, config.PasswordMaxLength), false);
                }
                else
                {
                    manager.Password = HiCryptographer.Md5Encrypt(this.txtNewPassWord.Text);
                    if (ManagerHelper.Update(manager))
                    {
                        this.ShowMsg("成功修改了管理员登录密码", true);
                    }
                }
            }
        }
Пример #5
0
        private void Application_BeginRequest(object source, System.EventArgs e)
        {
            this.currentApplicationType = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;
            HttpApplication httpApplication = (HttpApplication)source;
            HttpContext     context         = httpApplication.Context;

            if (context.Request.RawUrl.IndexOfAny(new char[]
            {
                '<',
                '>',
                '\'',
                '"'
            }) != -1)
            {
                context.Response.Redirect(context.Request.RawUrl.Replace("<", "%3c").Replace(">", "%3e").Replace("'", "%27").Replace("\"", "%22"), false);
            }
            else
            {
                this.CheckInstall(context);
                if (this.currentApplicationType != ApplicationType.Installer)
                {
                    HiHttpModule.CheckSSL(HiConfiguration.GetConfig().SSL, context);
                    HiContext.Create(context, new UrlReWriterDelegate(HiHttpModule.ReWriteUrl));
                }
            }
        }
Пример #6
0
 public static void ValidateSecureConnection(SSLSettings ssl, HttpContext context)
 {
     if (HiConfiguration.GetConfig().SSL == ssl)
     {
         RedirectToSSL(context);
     }
 }
Пример #7
0
 public static void SendQueuedEmails(int failureInterval, int maxNumberOfTries, SiteSettings settings)
 {
     if (settings != null)
     {
         HiConfiguration config = HiConfiguration.GetConfig();
         Dictionary <Guid, MailMessage> dictionary = EmailQueueProvider.Instance().DequeueEmail();
         IList <Guid> list   = new List <Guid>();
         EmailSender  sender = Messenger.CreateEmailSender(settings);
         if (sender != null)
         {
             int   num = 0;
             short smtpServerConnectionLimit = config.SmtpServerConnectionLimit;
             foreach (Guid guid in dictionary.Keys)
             {
                 if (Messenger.SendMail(dictionary[guid], sender))
                 {
                     EmailQueueProvider.Instance().DeleteQueuedEmail(guid);
                     if ((smtpServerConnectionLimit != -1) && (++num >= smtpServerConnectionLimit))
                     {
                         Thread.Sleep(new TimeSpan(0, 0, 0, 15, 0));
                         num = 0;
                     }
                 }
                 else
                 {
                     list.Add(guid);
                 }
             }
             if (list.Count > 0)
             {
                 EmailQueueProvider.Instance().QueueSendingFailure(list, failureInterval, maxNumberOfTries);
             }
         }
     }
 }
Пример #8
0
        private void btnSetPassword_Click(object sender, EventArgs e)
        {
            string     userName   = Globals.StripAllTags(this.txtUserName.Text.Trim());
            MemberInfo memberInfo = MemberProcessor.FindMemberByUsername(userName);
            bool       flag       = false;

            if (string.IsNullOrEmpty(this.txtPassword.Text.Trim()) || string.IsNullOrEmpty(this.txtRePassword.Text.Trim()))
            {
                this.ShowMessage("密码不允许为空!", false, "", 1);
            }
            else if (this.txtPassword.Text.Trim() != this.txtRePassword.Text.Trim())
            {
                this.ShowMessage("两次输入的密码需一致", false, "", 1);
            }
            else if (this.txtPassword.Text.Length < 6 || this.txtPassword.Text.Length > HiConfiguration.GetConfig().PasswordMaxLength)
            {
                this.ShowMessage($"密码的长度只能在{6}和{HiConfiguration.GetConfig().PasswordMaxLength}个字符之间", false, "", 1);
            }
            else if (MemberProcessor.ChangePassword(memberInfo, this.txtPassword.Text))
            {
                Messenger.UserPasswordForgotten(memberInfo, this.txtPassword.Text);
                this.Page.Response.Redirect($"/ForgotPasswordSuccess?UserName={memberInfo.UserName}");
            }
            else
            {
                this.ShowMessage("登录密码修改失败,请重试", false, "", 1);
            }
        }
Пример #9
0
 static RoleHelper()
 {
     RoleHelper.defaultRoles = null;
     RoleHelper.rolesConfig  = null;
     RoleHelper.rolesConfig  = HiConfiguration.GetConfig().RolesConfiguration;
     RoleHelper.defaultRoles = RoleHelper.rolesConfig.RoleList();
 }
Пример #10
0
        protected System.Collections.Generic.IList <ManageThemeInfo> LoadThemes()
        {
            System.Web.HttpContext context     = Hidistro.Membership.Context.HiContext.Current.Context;
            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            System.Collections.Generic.IList <ManageThemeInfo> list = new System.Collections.Generic.List <ManageThemeInfo>();
            string path = context.Request.PhysicalApplicationPath + HiConfiguration.GetConfig().FilesPath + "\\Templates\\library";

            string[] array  = System.IO.Directory.Exists(path) ? System.IO.Directory.GetDirectories(path) : null;
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string path2 = array2[i];
                System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(path2);
                string text = directoryInfo.Name.ToLower(System.Globalization.CultureInfo.InvariantCulture);
                if (text.Length > 0 && !text.StartsWith("_"))
                {
                    System.IO.FileInfo[] files  = directoryInfo.GetFiles(text + ".xml");
                    System.IO.FileInfo[] array3 = files;
                    for (int j = 0; j < array3.Length; j++)
                    {
                        System.IO.FileInfo   fileInfo        = array3[j];
                        ManageThemeInfo      manageThemeInfo = new ManageThemeInfo();
                        System.IO.FileStream fileStream      = fileInfo.OpenRead();
                        xmlDocument.Load(fileStream);
                        fileStream.Close();
                        manageThemeInfo.Name        = xmlDocument.SelectSingleNode("ManageTheme/Name").InnerText;
                        manageThemeInfo.ThemeImgUrl = xmlDocument.SelectSingleNode("ManageTheme/ImageUrl").InnerText;
                        manageThemeInfo.ThemeName   = text;
                        list.Add(manageThemeInfo);
                    }
                }
            }
            return(list);
        }
Пример #11
0
        protected IList <ManageThemeInfo> LoadThemes(string currentThemeName)
        {
            XmlDocument             document = new XmlDocument();
            IList <ManageThemeInfo> list     = new List <ManageThemeInfo>();
            string path = HttpContext.Current.Request.PhysicalApplicationPath + HiConfiguration.GetConfig().FilesPath + @"\Templates\vshop";

            string[]        strArray = Directory.Exists(path) ? Directory.GetDirectories(path) : null;
            ManageThemeInfo item     = null;

            foreach (string str3 in strArray)
            {
                DirectoryInfo info2 = new DirectoryInfo(str3);
                string        str2  = info2.Name.ToLower(CultureInfo.InvariantCulture);
                if ((str2.Length > 0) && !str2.StartsWith("_"))
                {
                    foreach (FileInfo info3 in info2.GetFiles("template.xml"))
                    {
                        item = new ManageThemeInfo();
                        FileStream inStream = info3.OpenRead();
                        document.Load(inStream);
                        inStream.Close();
                        item.Name        = document.SelectSingleNode("root/Name").InnerText;
                        item.ThemeImgUrl = Globals.ApplicationPath + "/Templates/vshop/" + str2 + "/" + document.SelectSingleNode("root/ImageUrl").InnerText;
                        item.ThemeName   = str2;
                        if (string.Compare(item.ThemeName, currentThemeName) == 0)
                        {
                            this.litThemeName.Text = item.ThemeName;
                        }
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Пример #12
0
        public void CheckMemberEmail(ValidationResults results)
        {
            HiConfiguration config = HiConfiguration.GetConfig();

            if (string.IsNullOrEmpty(this.Email) || (this.Email.Length > 0x100))
            {
                results.AddResult(new ValidationResult("电子邮件不能为空且长度必须小于256个字符", this, "", "", null));
            }
            else if (!Regex.IsMatch(this.Email, config.EmailRegex))
            {
                results.AddResult(new ValidationResult("电子邮件的格式错误", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.QQ) || (((this.QQ.Length <= 20) && (this.QQ.Length >= 3)) && Regex.IsMatch(this.QQ, "^[0-9]*$"))))
            {
                results.AddResult(new ValidationResult("QQ号长度限制在3-20个字符之间,只能输入数字", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.Wangwang) || ((this.Wangwang.Length <= 20) && (this.Wangwang.Length >= 3))))
            {
                results.AddResult(new ValidationResult("旺旺长度限制在3-20个字符之间", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.CellPhone) || (((this.CellPhone.Length <= 20) && (this.CellPhone.Length >= 3)) && Regex.IsMatch(this.CellPhone, "^[0-9]*$"))))
            {
                results.AddResult(new ValidationResult("手机号码长度限制在3-20个字符之间,只能输入数字", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.TelPhone) || (((this.TelPhone.Length <= 20) && (this.TelPhone.Length >= 3)) && Regex.IsMatch(this.TelPhone, "^[0-9-]*$"))))
            {
                results.AddResult(new ValidationResult("电话号码长度限制在3-20个字符之间,只能输入数字和字符“-”", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.MSN) || (((this.MSN.Length <= 0x100) && (this.MSN.Length >= 1)) && Regex.IsMatch(this.MSN, config.EmailRegex))))
            {
                results.AddResult(new ValidationResult("请输入正确MSN帐号,长度在1-256个字符以内", this, "", "", null));
            }
        }
Пример #13
0
        private void btnSetPassword_Click(object sender, EventArgs e)
        {
            MemberInfo user = HiContext.Current.User;
            bool       flag = false;

            if (string.IsNullOrEmpty(this.txtPassword.Text.Trim()) || string.IsNullOrEmpty(this.txtRePassword.Text.Trim()))
            {
                this.ShowMessage("密码不允许为空!", false, "", 1);
            }
            else if (this.txtPassword.Text.Trim() != this.txtRePassword.Text.Trim())
            {
                this.ShowMessage("两次输入的密码需一致", false, "", 1);
            }
            else if (this.txtPassword.Text.Length < 6 || this.txtPassword.Text.Length > HiConfiguration.GetConfig().PasswordMaxLength)
            {
                this.ShowMessage($"密码的长度只能在{6}和{HiConfiguration.GetConfig().PasswordMaxLength}个字符之间", false, "", 1);
            }
            else if (MemberProcessor.ChangeTradePassword(user, this.txtPassword.Text))
            {
                Messenger.UserDealPasswordChanged(user, this.txtPassword.Text);
                string text = "/User/UserOrders?orderStatus=1";
                text = ((!(this.source == "bdraw")) ? ((!(this.source == "sdraw")) ? (string.IsNullOrEmpty(this.orderId) ? "/User/UserOrders?orderStatus=1" : "/User/UserOrders?orderStatus=1") : "/User/SplittinDraws") : "/User/RequestBalanceDraw");
                this.ShowMessage("交易密码重置成功", true, text, 2);
            }
            else
            {
                this.ShowMessage("交易密码修改失败,请重试", false, "", 1);
            }
        }
Пример #14
0
        protected IList <ManageThemeInfo> LoadThemes(string path)
        {
            HttpContext             context  = HiContext.Current.Context;
            XmlDocument             document = new XmlDocument();
            IList <ManageThemeInfo> list     = new List <ManageThemeInfo>();
            string str = context.Request.PhysicalApplicationPath + HiConfiguration.GetConfig().FilesPath + @"\Templates\" + path;

            string[]        strArray = Directory.Exists(str) ? Directory.GetDirectories(str) : null;
            ManageThemeInfo item     = null;

            foreach (string str3 in strArray)
            {
                DirectoryInfo info2 = new DirectoryInfo(str3);
                string        str2  = info2.Name.ToLower(CultureInfo.InvariantCulture);
                if ((str2.Length > 0) && !str2.StartsWith("_"))
                {
                    foreach (FileInfo info3 in info2.GetFiles(str2 + ".xml"))
                    {
                        item = new ManageThemeInfo();
                        FileStream inStream = info3.OpenRead();
                        document.Load(inStream);
                        inStream.Close();
                        item.Name        = document.SelectSingleNode("ManageTheme/Name").InnerText;
                        item.ThemeImgUrl = document.SelectSingleNode("ManageTheme/ImageUrl").InnerText;
                        item.ThemeName   = str2;
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Пример #15
0
        private ExtensionContainer()
        {
            ExtensionContainer.Extensions.Clear();
            HiConfiguration config        = HiContext.Current.Config;
            XmlNode         configSection = config.GetConfigSection("Ecdev/Extensions");

            if (configSection != null)
            {
                foreach (XmlNode xmlNode in configSection.ChildNodes)
                {
                    if (xmlNode.NodeType != XmlNodeType.Comment && xmlNode.Name.Equals("add"))
                    {
                        string       value        = xmlNode.Attributes["name"].Value;
                        string       value2       = xmlNode.Attributes["type"].Value;
                        XmlAttribute xmlAttribute = xmlNode.Attributes["enabled"];
                        if (xmlAttribute == null || !(xmlAttribute.Value == "false"))
                        {
                            System.Type type = System.Type.GetType(value2);
                            if (type == null)
                            {
                                throw new System.Exception(value2 + " does not exist");
                            }
                            IExtension extension = System.Activator.CreateInstance(type) as IExtension;
                            if (extension == null)
                            {
                                throw new System.Exception(value2 + " does not implement IExtension or is not configured correctly");
                            }
                            extension.Init();
                            ExtensionContainer.Extensions.Add(value, extension);
                        }
                    }
                }
            }
        }
Пример #16
0
        private void btnEditPassWordOK_Click(object sender, EventArgs e)
        {
            SiteManager manager = ManagerHelper.GetManager(userId);

            if ((string.IsNullOrEmpty(txtNewPassWord.Text) || (txtNewPassWord.Text.Length > 20)) || (txtNewPassWord.Text.Length < 6))
            {
                ShowMsg("密码不能为空,长度限制在6-20个字符之间", false);
            }
            else if (string.Compare(txtNewPassWord.Text, txtPassWordCompare.Text) != 0)
            {
                ShowMsg("两次输入的密码不一样", false);
            }
            else
            {
                HiConfiguration config = HiConfiguration.GetConfig();
                if ((string.IsNullOrEmpty(txtNewPassWord.Text) || (txtNewPassWord.Text.Length < System.Web.Security.Membership.Provider.MinRequiredPasswordLength)) || (txtNewPassWord.Text.Length > config.PasswordMaxLength))
                {
                    ShowMsg(string.Format("管理员登录密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, config.PasswordMaxLength), false);
                }
                else if (userId == HiContext.Current.User.UserId)
                {
                    if (manager.ChangePassword(txtOldPassWord.Text, txtNewPassWord.Text))
                    {
                        ShowMsg("密码修改成功", true);
                    }
                    else
                    {
                        ShowMsg("修改密码失败,您输入的旧密码有误", false);
                    }
                }
                else
                {
                    HttpContext context  = HiContext.Current.Context;
                    XmlDocument document = new XmlDocument();
                    string      filename = context.Request.MapPath(Globals.ApplicationPath + "/config/key.config");
                    string      str2     = context.Request.MapPath(Globals.ApplicationPath + "/config/key.config.bak");
                    try
                    {
                        document.Load(filename);
                    }
                    catch
                    {
                        document.Load(str2);
                    }
                    if (int.Parse(document.SelectSingleNode("Settings/Token").InnerText) == userId)
                    {
                        ShowMsg("系统安装时管理员的密码只能由他自己修改", false);
                    }
                    else if (manager.ChangePassword(txtNewPassWord.Text))
                    {
                        ShowMsg("密码修改成功", true);
                    }
                    else
                    {
                        ShowMsg("修改密码失败,您输入的旧密码有误", false);
                    }
                }
            }
        }
Пример #17
0
        /// <summary>
        /// 加载模板
        /// </summary>
        /// <param name="currentThemeName"></param>
        /// <returns></returns>
        protected IList <ManageThemeInfo> LoadThemes(string currentThemeName)
        {
            HttpContext context = HiContext.Current.Context;

            XmlDocument document = new XmlDocument();

            IList <ManageThemeInfo> list = new List <ManageThemeInfo>();

            string themesPath = context.Request.PhysicalApplicationPath + HiConfiguration.GetConfig().FilesPath + @"\Templates\sites\" + HiContext.Current.User.UserId.ToString();

            if (Directory.Exists(themesPath))
            {
                string[] themeList = Directory.GetDirectories(themesPath);

                ManageThemeInfo item = null;

                DirectoryInfo themeInfo = null;

                string themeName = string.Empty;

                foreach (string theme in themeList)
                {
                    themeInfo = new DirectoryInfo(theme);

                    themeName = themeInfo.Name.ToLower();

                    if (themeName.Length > 0 && !themeName.StartsWith("_"))
                    {
                        foreach (FileInfo fileInfo in themeInfo.GetFiles(themeName + ".xml"))
                        {
                            item = new ManageThemeInfo();

                            using (FileStream inStream = fileInfo.OpenRead())
                            {
                                document.Load(inStream);
                            }

                            item.Name = document.SelectSingleNode("ManageTheme/Name").InnerText;

                            item.ThemeImgUrl = document.SelectSingleNode("ManageTheme/ImageUrl").InnerText;

                            item.ThemeName = themeName;

                            if (string.Compare(item.ThemeName, currentThemeName) == 0)
                            {
                                litThemeName.Text = item.ThemeName;

                                imgThemeImgUrl.ImageUrl = string.Concat(Globals.ApplicationPath, "/Templates/sites/", HiContext.Current.User.UserId, "/", themeName, "/", document.SelectSingleNode("ManageTheme/ImageUrl").InnerText);

                                Image1.ImageUrl = string.Concat(Globals.ApplicationPath, "/Templates/sites/", HiContext.Current.User.UserId, "/", themeName, "/", document.SelectSingleNode("ManageTheme/BigImageUrl").InnerText);
                            }

                            list.Add(item);
                        }
                    }
                }
            }
            return(list);
        }
Пример #18
0
 public static string GetAdminAbsolutePath(string path)
 {
     if (path.StartsWith("/"))
     {
         return(ApplicationPath + "/" + HiConfiguration.GetConfig().AdminFolder + path);
     }
     return(ApplicationPath + "/" + HiConfiguration.GetConfig().AdminFolder + "/" + path);
 }
Пример #19
0
        protected IList <ManageThemeInfo> LoadThemes(string currentThemeName)
        {
            HttpContext context = HiContext.Current.Context;

            XmlDocument document = new XmlDocument();

            IList <ManageThemeInfo> themesList = new List <ManageThemeInfo>();

            string path = context.Request.PhysicalApplicationPath + HiConfiguration.GetConfig().FilesPath + @"\Templates\library";

            string[] fileList = Directory.Exists(path) ? Directory.GetDirectories(path) : null;

            ManageThemeInfo item = null;

            DirectoryInfo directoryInfo = null;

            string themeName = "";

            FileStream inStream = null;

            foreach (string file in fileList)
            {
                directoryInfo = new DirectoryInfo(file);

                themeName = directoryInfo.Name.ToLower();

                if ((themeName.Length > 0) && !themeName.StartsWith("_"))
                {
                    foreach (FileInfo info3 in directoryInfo.GetFiles(themeName + ".xml"))
                    {
                        item = new ManageThemeInfo();

                        using (inStream = info3.OpenRead())
                        {
                            document.Load(inStream);
                        }

                        item.Name = document.SelectSingleNode("ManageTheme/Name").InnerText;

                        item.ThemeImgUrl = document.SelectSingleNode("ManageTheme/ImageUrl").InnerText;

                        item.ThemeName = themeName;

                        if (string.Compare(item.ThemeName, currentThemeName) == 0)
                        {
                            litThemeName.Text = item.ThemeName;

                            imgThemeImgUrl.ImageUrl = Globals.ApplicationPath + "/Templates/library/" + themeName + "/" + document.SelectSingleNode("ManageTheme/ImageUrl").InnerText;

                            Image1.ImageUrl = Globals.ApplicationPath + "/Templates/library/" + themeName + "/" + document.SelectSingleNode("ManageTheme/BigImageUrl").InnerText;
                        }

                        themesList.Add(item);
                    }
                }
            }
            return(themesList);
        }
Пример #20
0
        public void CheckManagerPassword(ValidationResults results)
        {
            HiConfiguration config = HiConfiguration.GetConfig();

            if (string.IsNullOrEmpty(this.Password) || this.Password.Length < System.Web.Security.Membership.Provider.MinRequiredPasswordLength || this.Password.Length > config.PasswordMaxLength)
            {
                results.AddResult(new ValidationResult(string.Format("管理员登录密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, config.PasswordMaxLength), this, "", "", null));
            }
        }
Пример #21
0
        public static void SendSubsiteEmails(int failureInterval, int maxNumberOfTries)
        {
            HiConfiguration config = HiConfiguration.GetConfig();

            System.Collections.Generic.Dictionary <System.Guid, SubsiteMailMessage> dictionary = EmailQueueProvider.Instance().DequeueDistributorEmail();
            System.Collections.Generic.Dictionary <int, EmailSender> dictionary2 = new System.Collections.Generic.Dictionary <int, EmailSender>();
            System.Collections.Generic.IList <System.Guid>           list        = new System.Collections.Generic.List <System.Guid>();
            System.Collections.Generic.IList <int> list2 = new System.Collections.Generic.List <int>();
            int   num = 0;
            short smtpServerConnectionLimit = config.SmtpServerConnectionLimit;

            foreach (System.Guid current in dictionary.Keys)
            {
                int distributorUserId = dictionary[current].DistributorUserId;
                if (!list2.Contains(distributorUserId))
                {
                    EmailSender emailSender;
                    if (!dictionary2.ContainsKey(distributorUserId))
                    {
                        SiteSettings siteSettings = SettingsManager.GetSiteSettings(distributorUserId);
                        if (siteSettings == null)
                        {
                            list2.Add(distributorUserId);
                            continue;
                        }
                        emailSender = Messenger.CreateEmailSender(siteSettings);
                        if (emailSender == null)
                        {
                            list2.Add(distributorUserId);
                            continue;
                        }
                        dictionary2.Add(distributorUserId, emailSender);
                    }
                    else
                    {
                        emailSender = dictionary2[distributorUserId];
                    }
                    if (Messenger.SendMail(dictionary[current].Mail, emailSender))
                    {
                        EmailQueueProvider.Instance().DeleteDistributorQueuedEmail(current);
                        if (smtpServerConnectionLimit != -1 && ++num >= (int)smtpServerConnectionLimit)
                        {
                            System.Threading.Thread.Sleep(new System.TimeSpan(0, 0, 0, 15, 0));
                            num = 0;
                        }
                    }
                    else
                    {
                        list.Add(current);
                    }
                }
            }
            if (list.Count > 0)
            {
                EmailQueueProvider.Instance().QueueDistributorSendingFailure(list, failureInterval, maxNumberOfTries);
            }
        }
Пример #22
0
        private bool AddBuiltInRoles(out string errorMsg)
        {
            DbConnection  connection  = null;
            DbTransaction transaction = null;

            try
            {
                using (connection = new SqlConnection(this.GetConnectionString()))
                {
                    connection.Open();
                    DbCommand command = connection.CreateCommand();
                    transaction         = connection.BeginTransaction();
                    command.Connection  = connection;
                    command.Transaction = transaction;
                    command.CommandType = CommandType.Text;
                    command.CommandText = "INSERT INTO aspnet_Roles(RoleName, LoweredRoleName) VALUES(@RoleName, LOWER(@RoleName))";
                    DbParameter parameter = new SqlParameter("@RoleName", SqlDbType.NVarChar, 0x100);
                    command.Parameters.Add(parameter);
                    RolesConfiguration rolesConfiguration = HiConfiguration.GetConfig().RolesConfiguration;
                    command.Parameters["@RoleName"].Value = rolesConfiguration.Distributor;
                    command.ExecuteNonQuery();
                    command.Parameters["@RoleName"].Value = rolesConfiguration.Manager;
                    command.ExecuteNonQuery();
                    command.Parameters["@RoleName"].Value = rolesConfiguration.Member;
                    command.ExecuteNonQuery();
                    command.Parameters["@RoleName"].Value = rolesConfiguration.SystemAdministrator;
                    command.ExecuteNonQuery();
                    command.Parameters["@RoleName"].Value = rolesConfiguration.Underling;
                    command.ExecuteNonQuery();
                    transaction.Commit();
                    connection.Close();
                }
                errorMsg = null;
                return(true);
            }
            catch (SqlException exception)
            {
                errorMsg = exception.Message;
                if (transaction != null)
                {
                    try
                    {
                        transaction.Rollback();
                    }
                    catch (Exception exception2)
                    {
                        errorMsg = exception2.Message;
                    }
                }
                if ((connection != null) && (connection.State != ConnectionState.Closed))
                {
                    connection.Close();
                    connection.Dispose();
                }
                return(false);
            }
        }
Пример #23
0
        public static void SendSubsiteEmails(int failureInterval, int maxNumberOfTries)
        {
            HiConfiguration config = HiConfiguration.GetConfig();
            Dictionary <Guid, SubsiteMailMessage> dictionary  = EmailQueueProvider.Instance().DequeueDistributorEmail();
            Dictionary <int, EmailSender>         dictionary2 = new Dictionary <int, EmailSender>();
            IList <Guid> list  = new List <Guid>();
            IList <int>  list2 = new List <int>();
            int          num   = 0;
            short        smtpServerConnectionLimit = config.SmtpServerConnectionLimit;

            foreach (Guid guid in dictionary.Keys)
            {
                int distributorUserId = dictionary[guid].DistributorUserId;
                if (!list2.Contains(distributorUserId))
                {
                    EmailSender sender = null;
                    if (!dictionary2.ContainsKey(distributorUserId))
                    {
                        SiteSettings siteSettings = SettingsManager.GetSiteSettings(distributorUserId);
                        if (siteSettings == null)
                        {
                            list2.Add(distributorUserId);
                            continue;
                        }
                        sender = Messenger.CreateEmailSender(siteSettings);
                        if (sender == null)
                        {
                            list2.Add(distributorUserId);
                            continue;
                        }
                        dictionary2.Add(distributorUserId, sender);
                    }
                    else
                    {
                        sender = dictionary2[distributorUserId];
                    }
                    if (Messenger.SendMail(dictionary[guid].Mail, sender))
                    {
                        EmailQueueProvider.Instance().DeleteDistributorQueuedEmail(guid);
                        if ((smtpServerConnectionLimit != -1) && (++num >= smtpServerConnectionLimit))
                        {
                            Thread.Sleep(new TimeSpan(0, 0, 0, 15, 0));
                            num = 0;
                        }
                    }
                    else
                    {
                        list.Add(guid);
                    }
                }
            }
            if (list.Count > 0)
            {
                EmailQueueProvider.Instance().QueueDistributorSendingFailure(list, failureInterval, maxNumberOfTries);
            }
        }
Пример #24
0
        private void btnTestEmailSettings_Click(object sender, System.EventArgs e)
        {
            string     text;
            ConfigData configData = this.LoadConfig(out text);

            if (string.IsNullOrEmpty(text) || configData == null)
            {
                this.ShowMsg("请先选择发送方式并填写配置信息", false);
                return;
            }
            if (!configData.IsValid)
            {
                string text2 = "";
                foreach (string current in configData.ErrorMsgs)
                {
                    text2 += Formatter.FormatErrorMessage(current);
                }
                this.ShowMsg(text2, false);
                return;
            }
            if (string.IsNullOrEmpty(this.txtTestEmail.Text) || this.txtTestEmail.Text.Trim().Length == 0)
            {
                this.ShowMsg("请填写接收测试邮件的邮箱地址", false);
                return;
            }
            if (!System.Text.RegularExpressions.Regex.IsMatch(this.txtTestEmail.Text.Trim(), "([a-zA-Z\\.0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,4}){1,2})"))
            {
                this.ShowMsg("请填写正确的邮箱地址", false);
                return;
            }
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage
            {
                IsBodyHtml = true,
                Priority   = System.Net.Mail.MailPriority.High,
                Body       = "Success",
                Subject    = "This is a test mail"
            };
            mailMessage.To.Add(this.txtTestEmail.Text.Trim());
            EmailSender emailSender = EmailSender.CreateInstance(text, configData.SettingsXml);

            try
            {
                if (emailSender.Send(mailMessage, System.Text.Encoding.GetEncoding(HiConfiguration.GetConfig().EmailEncoding)))
                {
                    this.ShowMsg("发送测试邮件成功", true);
                }
                else
                {
                    this.ShowMsg("发送测试邮件失败", false);
                }
            }
            catch
            {
                this.ShowMsg("邮件配置错误", false);
            }
        }
Пример #25
0
        public void CheckDistributor(ValidationResults results)
        {
            HiConfiguration config = HiConfiguration.GetConfig();

            if ((string.IsNullOrEmpty(this.Username) || (this.Username.Length > config.UsernameMaxLength)) || (this.Username.Length < config.UsernameMinLength))
            {
                results.AddResult(new ValidationResult(string.Format("用户名不能为空,长度必须在{0}-{1}个字符之间", config.UsernameMinLength, config.UsernameMaxLength), this, "", "", null));
            }
            else if (!Regex.IsMatch(this.Username, config.UsernameRegex))
            {
                results.AddResult(new ValidationResult("用户名的格式错误", this, "", "", null));
            }
            if (string.IsNullOrEmpty(this.Email) || (this.Email.Length > 0x100))
            {
                results.AddResult(new ValidationResult("电子邮件不能为空,长度必须小于256个字符", this, "", "", null));
            }
            else if (!Regex.IsMatch(this.Email, config.EmailRegex))
            {
                results.AddResult(new ValidationResult("电子邮件的格式错误", this, "", "", null));
            }
            if (this.IsCreate)
            {
                if ((string.IsNullOrEmpty(this.Password) || (this.Password.Length > config.PasswordMaxLength)) || (this.Password.Length < 6))
                {
                    results.AddResult(new ValidationResult(string.Format("密码不能为空,长度必须在{0}-{1}个字符之间", 6, config.PasswordMaxLength), this, "", "", null));
                }
                if ((string.IsNullOrEmpty(this.TradePassword) || (this.TradePassword.Length > config.PasswordMaxLength)) || (this.TradePassword.Length < 6))
                {
                    results.AddResult(new ValidationResult(string.Format("交易密码不能为空,长度必须在{0}-{1}个字符之间", 6, config.PasswordMaxLength), this, "", "", null));
                }
            }
            if (!(string.IsNullOrEmpty(this.QQ) || (((this.QQ.Length <= 20) && (this.QQ.Length >= 3)) && Regex.IsMatch(this.QQ, "^[0-9]*$"))))
            {
                results.AddResult(new ValidationResult("QQ号长度限制在3-20个字符之间,只能输入数字", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.Zipcode) || (((this.Zipcode.Length <= 10) && (this.Zipcode.Length >= 3)) && Regex.IsMatch(this.Zipcode, "^[0-9]*$"))))
            {
                results.AddResult(new ValidationResult("邮编长度限制在3-10个字符之间,只能输入数字", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.Wangwang) || ((this.Wangwang.Length <= 20) && (this.Wangwang.Length >= 3))))
            {
                results.AddResult(new ValidationResult("旺旺长度限制在3-20个字符之间", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.MSN) || (((this.MSN.Length <= 0x100) && (this.MSN.Length >= 1)) && Regex.IsMatch(this.MSN, config.EmailRegex))))
            {
                results.AddResult(new ValidationResult("请输入正确MSN帐号,长度在1-256个字符以内", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.CellPhone) || (((this.CellPhone.Length <= 20) && (this.CellPhone.Length >= 3)) && Regex.IsMatch(this.CellPhone, "^[0-9]*$"))))
            {
                results.AddResult(new ValidationResult("手机号码长度限制在3-20个字符之间,只能输入数字", this, "", "", null));
            }
            if (!(string.IsNullOrEmpty(this.TelPhone) || (((this.TelPhone.Length <= 20) && (this.TelPhone.Length >= 3)) && Regex.IsMatch(this.TelPhone, "^[0-9-]*$"))))
            {
                results.AddResult(new ValidationResult("电话号码长度限制在3-20个字符之间,只能输入数字和字符“-”", this, "", "", null));
            }
        }
Пример #26
0
 public void Start()
 {
     Interlocked.Increment(ref Jobs._instancesOfParent);
     lock (this.jobList.SyncRoot)
     {
         if (this.jobList.Count == 0)
         {
             HiConfiguration config        = HiConfiguration.GetConfig();
             XmlNode         configSection = config.GetConfigSection("Ecdev/Jobs");
             bool            flag2         = true;
             XmlAttribute    xmlAttribute  = configSection.Attributes["singleThread"];
             if (xmlAttribute != null && !string.IsNullOrEmpty(xmlAttribute.Value) && string.Compare(xmlAttribute.Value, "false", true, CultureInfo.InvariantCulture) == 0)
             {
                 flag2 = false;
             }
             XmlAttribute xmlAttribute2 = configSection.Attributes["minutes"];
             if (xmlAttribute2 != null && !string.IsNullOrEmpty(xmlAttribute2.Value))
             {
                 int num = 1;
                 if (int.TryParse(xmlAttribute2.Value, out num))
                 {
                     this.Interval = num * 60000;
                 }
             }
             foreach (XmlNode xmlNode in configSection.ChildNodes)
             {
                 if (configSection.NodeType != XmlNodeType.Comment && xmlNode.NodeType != XmlNodeType.Comment)
                 {
                     XmlAttribute xmlAttribute3 = xmlNode.Attributes["type"];
                     XmlAttribute xmlAttribute4 = xmlNode.Attributes["name"];
                     Type         type          = Type.GetType(xmlAttribute3.Value);
                     if (type != null)
                     {
                         if (!this.jobList.Contains(xmlAttribute4.Value))
                         {
                             Job job = new Job(type, xmlNode);
                             if (flag2 && job.SingleThreaded)
                             {
                                 job.InitializeTimer();
                             }
                             else
                             {
                                 this.jobList[xmlAttribute4.Value] = job;
                             }
                         }
                     }
                 }
             }
             if (this.jobList.Count > 0)
             {
                 this.singleTimer = new Timer(new TimerCallback(this.call_back), null, this.Interval, this.Interval);
             }
         }
     }
 }
Пример #27
0
        private void btnTestEmailSettings_Click(object sender, EventArgs e)
        {
            string     text       = default(string);
            ConfigData configData = this.LoadConfig(out text);

            if (string.IsNullOrEmpty(text) || configData == null)
            {
                this.ShowMsg("请先选择发送方式并填写配置信息", false);
            }
            else if (!configData.IsValid)
            {
                string text2 = "";
                foreach (string errorMsg in configData.ErrorMsgs)
                {
                    text2 += Formatter.FormatErrorMessage(errorMsg);
                }
                this.ShowMsg(text2, false);
            }
            else if (string.IsNullOrEmpty(this.txtTestEmail.Text) || this.txtTestEmail.Text.Trim().Length == 0)
            {
                this.ShowMsg("请填写接收测试邮件的邮箱地址", false);
            }
            else if (!Regex.IsMatch(this.txtTestEmail.Text.Trim(), "([a-zA-Z\\.0-9_-])+@([a-zA-Z0-9_-])+((\\.[a-zA-Z0-9_-]{2,4}){1,2})"))
            {
                this.ShowMsg("请填写正确的邮箱地址", false);
            }
            else
            {
                MailMessage mailMessage = new MailMessage
                {
                    IsBodyHtml = true,
                    Priority   = MailPriority.High,
                    Body       = "Success",
                    Subject    = "This is a test mail"
                };
                mailMessage.To.Add(this.txtTestEmail.Text.Trim());
                EmailSender emailSender = EmailSender.CreateInstance(text, configData.SettingsXml);
                try
                {
                    if (emailSender.Send(mailMessage, Encoding.GetEncoding(HiConfiguration.GetConfig().EmailEncoding)))
                    {
                        this.ShowMsg("发送测试邮件成功", true);
                    }
                    else
                    {
                        this.ShowMsg("发送测试邮件失败", false);
                    }
                }
                catch (Exception ex)
                {
                    Globals.WriteExceptionLog(ex, null, "EmailSend");
                    this.ShowMsg("邮件配置错误", false);
                }
            }
        }
        private void btnTestEmailSettings_Click(object sender, EventArgs e)
        {
            string     str;
            ConfigData data = this.LoadConfig(out str);

            if (string.IsNullOrEmpty(str) || (data == null))
            {
                this.ShowMsg("请先选择发送方式并填写配置信息", false);
            }
            else if (!data.IsValid)
            {
                string msg = "";
                foreach (string str3 in data.ErrorMsgs)
                {
                    msg = msg + Formatter.FormatErrorMessage(str3);
                }
                this.ShowMsg(msg, false);
            }
            else if (string.IsNullOrEmpty(this.txtTestEmail.Text) || (this.txtTestEmail.Text.Trim().Length == 0))
            {
                this.ShowMsg("请填写接收测试邮件的邮箱地址", false);
            }
            else if (!Regex.IsMatch(this.txtTestEmail.Text.Trim(), @"([a-zA-Z\.0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,4}){1,2})"))
            {
                this.ShowMsg("请填写正确的邮箱地址", false);
            }
            else
            {
                MailMessage mail = new MailMessage
                {
                    IsBodyHtml = true,
                    Priority   = MailPriority.High,
                    Body       = "Success",
                    Subject    = "This is a test mail"
                };
                mail.To.Add(this.txtTestEmail.Text.Trim());
                EmailSender sender2 = EmailSender.CreateInstance(str, data.SettingsXml);
                try
                {
                    if (sender2.Send(mail, Encoding.GetEncoding(HiConfiguration.GetConfig().EmailEncoding)))
                    {
                        this.ShowMsg("发送测试邮件成功", true);
                    }
                    else
                    {
                        this.ShowMsg("发送测试邮件失败", false);
                    }
                }
                catch
                {
                    this.ShowMsg("邮件配置错误", false);
                }
            }
        }
Пример #29
0
        public void CheckManagerEmail(ValidationResults results)
        {
            HiConfiguration config = HiConfiguration.GetConfig();

            if (string.IsNullOrEmpty(this.Email) || (this.Email.Length > 0x100))
            {
                results.AddResult(new ValidationResult("电子邮件的长度必须小于256个字符", this, "", "", null));
            }
            else if (!Regex.IsMatch(this.Email, config.EmailRegex))
            {
                results.AddResult(new ValidationResult("电子邮件的格式错误", this, "", "", null));
            }
        }
Пример #30
0
 internal static bool SendMail(MailMessage email, EmailSender sender, out string msg)
 {
     try
     {
         msg = "";
         return(sender.Send(email, Encoding.GetEncoding(HiConfiguration.GetConfig().EmailEncoding)));
     }
     catch (Exception exception)
     {
         msg = exception.Message;
         return(false);
     }
 }