Exemple #1
0
        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 message2 = new MailMessage();
                message2.IsBodyHtml = true;
                message2.Priority   = MailPriority.High;
                message2.Body       = "Success";
                message2.Subject    = "This is a test mail";
                MailMessage mail = message2;
                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);
                }
            }
        }
Exemple #2
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("Hishop/Jobs");
             bool            flag          = true;
             XmlAttribute    xmlAttribute  = configSection.Attributes["singleThread"];
             if (xmlAttribute != null && !string.IsNullOrEmpty(xmlAttribute.Value) && string.Compare(xmlAttribute.Value, "false", true, CultureInfo.InvariantCulture) == 0)
             {
                 flag = 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 childNode in configSection.ChildNodes)
             {
                 if (configSection.NodeType != XmlNodeType.Comment && childNode.NodeType != XmlNodeType.Comment)
                 {
                     XmlAttribute xmlAttribute3 = childNode.Attributes["type"];
                     XmlAttribute xmlAttribute4 = childNode.Attributes["name"];
                     Type         type          = Type.GetType(xmlAttribute3.Value);
                     if (type != (Type)null && !this.jobList.Contains(xmlAttribute4.Value))
                     {
                         Job job = new Job(type, childNode);
                         if (flag && job.SingleThreaded)
                         {
                             job.InitializeTimer();
                         }
                         else
                         {
                             this.jobList[xmlAttribute4.Value] = job;
                         }
                     }
                 }
             }
             if (this.jobList.Count > 0)
             {
                 this.singleTimer = new Timer(this.call_back, null, this.Interval, this.Interval);
             }
         }
     }
 }
Exemple #3
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);
     }
 }
Exemple #4
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));
            }
        }
Exemple #5
0
 public void Start()
 {
     Interlocked.Increment(ref _instancesOfParent);
     lock (this.jobList.SyncRoot)
     {
         if (this.jobList.Count == 0)
         {
             XmlNode      configSection = HiConfiguration.GetConfig().GetConfigSection("Hishop/Jobs");
             bool         flag          = true;
             XmlAttribute attribute     = configSection.Attributes["singleThread"];
             if (((attribute != null) && !string.IsNullOrEmpty(attribute.Value)) && (string.Compare(attribute.Value, "false", true, CultureInfo.InvariantCulture) == 0))
             {
                 flag = false;
             }
             XmlAttribute attribute2 = configSection.Attributes["minutes"];
             if ((attribute2 != null) && !string.IsNullOrEmpty(attribute2.Value))
             {
                 int result = 1;
                 if (int.TryParse(attribute2.Value, out result))
                 {
                     this.Interval = result * 0xea60;
                 }
             }
             foreach (XmlNode node2 in configSection.ChildNodes)
             {
                 if ((configSection.NodeType != XmlNodeType.Comment) && (node2.NodeType != XmlNodeType.Comment))
                 {
                     XmlAttribute attribute3 = node2.Attributes["type"];
                     XmlAttribute attribute4 = node2.Attributes["name"];
                     Type         ijob       = Type.GetType(attribute3.Value);
                     if ((ijob != null) && !this.jobList.Contains(attribute4.Value))
                     {
                         Job job = new Job(ijob, node2);
                         if (flag && job.SingleThreaded)
                         {
                             job.InitializeTimer();
                         }
                         else
                         {
                             this.jobList[attribute4.Value] = job;
                         }
                     }
                 }
             }
             if (this.jobList.Count > 0)
             {
                 this.singleTimer = new Timer(new TimerCallback(this.call_back), null, this.Interval, this.Interval);
             }
         }
     }
 }
        public static IHiCache CreateInstance()
        {
            string text = HiConfiguration.GetConfig().CachePolicy.ToLower();
            string a    = text;

            if (!(a == "redis"))
            {
                if (a == "memcached")
                {
                    return(new MemCached());
                }
                return(new AspNetCache());
            }
            return(new RedisCache());
        }
Exemple #7
0
 public void Init(HttpApplication application)
 {
     if (application != null)
     {
         application.BeginRequest     += new System.EventHandler(this.method_1);
         application.AuthorizeRequest += new System.EventHandler(this.method_0);
         this.bool_0            = (ConfigurationManager.AppSettings["Installer"] == null);
         this.applicationType_0 = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;
         this.method_2(application.Context);
         if (this.applicationType_0 != ApplicationType.Installer)
         {
             Jobs.Instance().Start();
             Class5.smethod_0();
         }
     }
 }
Exemple #8
0
        internal static bool SendMail(System.Net.Mail.MailMessage email, EmailSender sender, out string string_0)
        {
            bool result;

            try
            {
                string_0 = "";
                result   = sender.Send(email, System.Text.Encoding.GetEncoding(HiConfiguration.GetConfig().EmailEncoding));
            }
            catch (System.Exception ex)
            {
                string_0 = ex.Message;
                result   = false;
            }
            return(result);
        }
Exemple #9
0
 public void Init(HttpApplication application)
 {
     if (null != application)
     {
         application.BeginRequest     += new EventHandler(this.Application_BeginRequest);
         application.AuthorizeRequest += new EventHandler(this.Application_AuthorizeRequest);
         this.applicationInstalled     = ConfigurationManager.AppSettings["Installer"] == null;
         this.currentApplicationType   = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;
         this.CheckInstall(application.Context);
         if (this.currentApplicationType != ApplicationType.Installer)
         {
             Hidistro.Core.Jobs.Jobs.Instance().Start();
             ExtensionContainer.LoadExtensions();
         }
     }
 }
Exemple #10
0
        /// <summary>
        /// 验证用户
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        bool ValidateUser(out string msg)
        {
            msg = null;
            if ((string.IsNullOrEmpty(username) || string.IsNullOrEmpty(email)) || (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(password2)))
            {
                msg = "管理员账号信息不完整";
                return(false);
            }
            HiConfiguration config = HiConfiguration.GetConfig();

            if ((username.Length > config.UsernameMaxLength) || (username.Length < config.UsernameMinLength))
            {
                msg = string.Format("管理员用户名的长度只能在{0}和{1}个字符之间", config.UsernameMinLength, config.UsernameMaxLength);
                return(false);
            }
            if (string.Compare(username, "anonymous", true) == 0)
            {
                msg = "不能使用anonymous作为管理员用户名";
                return(false);
            }
            if (!Regex.IsMatch(username, config.UsernameRegex))
            {
                msg = "管理员用户名的格式不符合要求,用户名一般由字母、数字、下划线和汉字组成,且必须以汉字或字母开头";
                return(false);
            }
            if (email.Length > 0x100)
            {
                msg = "电子邮件的长度必须小于256个字符";
                return(false);
            }
            if (!Regex.IsMatch(email, config.EmailRegex))
            {
                msg = "电子邮件的格式错误";
                return(false);
            }
            if (password != password2)
            {
                msg = "管理员登录密码两次输入不一致";
                return(false);
            }
            if ((password.Length >= System.Web.Security.Membership.Provider.MinRequiredPasswordLength) && (password.Length <= config.PasswordMaxLength))
            {
                return(true);
            }
            msg = string.Format("管理员登录密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, config.PasswordMaxLength);
            return(false);
        }
Exemple #11
0
        private bool ValidateUser(out string msg)
        {
            msg = null;
            if (string.IsNullOrEmpty(this.username) || string.IsNullOrEmpty(this.email) || string.IsNullOrEmpty(this.password) || string.IsNullOrEmpty(this.password2))
            {
                msg = "管理员账号信息不完整";
                return(false);
            }
            HiConfiguration config = HiConfiguration.GetConfig();

            if (this.username.Length > config.UsernameMaxLength || this.username.Length < config.UsernameMinLength)
            {
                msg = $"管理员用户名的长度只能在{config.UsernameMinLength}和{config.UsernameMaxLength}个字符之间";
                return(false);
            }
            if (string.Compare(this.username, "anonymous", true) == 0)
            {
                msg = "不能使用anonymous作为管理员用户名";
                return(false);
            }
            if (!Regex.IsMatch(this.username, config.UsernameRegex))
            {
                msg = "管理员用户名的格式不符合要求,用户名一般由字母、数字、下划线和汉字组成,且必须以汉字或字母开头";
                return(false);
            }
            if (this.email.Length > 256)
            {
                msg = "电子邮件的长度必须小于256个字符";
                return(false);
            }
            if (!Regex.IsMatch(this.email, config.EmailRegex))
            {
                msg = "电子邮件的格式错误";
                return(false);
            }
            if (this.password != this.password2)
            {
                msg = "管理员登录密码两次输入不一致";
                return(false);
            }
            if (this.password.Length < 6 || this.password.Length > config.PasswordMaxLength)
            {
                msg = $"管理员登录密码的长度只能在{6}和{config.PasswordMaxLength}个字符之间";
                return(false);
            }
            return(true);
        }
Exemple #12
0
        private bool ValidateUser(out string msg)
        {
            msg = null;
            if (string.IsNullOrEmpty(this.username) || string.IsNullOrEmpty(this.email) || string.IsNullOrEmpty(this.password) || string.IsNullOrEmpty(this.password2))
            {
                msg = "管理员账号信息不完整";
                return(false);
            }
            HiConfiguration config = HiConfiguration.GetConfig();

            if (this.username.Length > config.UsernameMaxLength || this.username.Length < config.UsernameMinLength)
            {
                msg = string.Format("管理员用户名的长度只能在{0}和{1}个字符之间", config.UsernameMinLength, config.UsernameMaxLength);
                return(false);
            }
            if (string.Compare(this.username, "anonymous", true) == 0)
            {
                msg = "不能使用anonymous作为管理员用户名";
                return(false);
            }
            if (!System.Text.RegularExpressions.Regex.IsMatch(this.username, config.UsernameRegex))
            {
                msg = "管理员用户名的格式不符合要求,用户名一般由字母、数字、下划线和汉字组成,且必须以汉字或字母开头";
                return(false);
            }
            if (this.email.Length > 256)
            {
                msg = "电子邮件的长度必须小于256个字符";
                return(false);
            }
            if (!System.Text.RegularExpressions.Regex.IsMatch(this.email, config.EmailRegex))
            {
                msg = "电子邮件的格式错误";
                return(false);
            }
            if (this.password != this.password2)
            {
                msg = "管理员登录密码两次输入不一致";
                return(false);
            }
            if (this.password.Length < System.Web.Security.Membership.Provider.MinRequiredPasswordLength || this.password.Length > config.PasswordMaxLength)
            {
                msg = string.Format("管理员登录密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, config.PasswordMaxLength);
                return(false);
            }
            return(true);
        }
Exemple #13
0
        public void CheckManagerName(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 (string.Compare(this.Username, "anonymous", true) == 0)
            {
                results.AddResult(new ValidationResult("不能使用anonymous作为用户名", this, "", "", null));
            }
            else if (!Regex.IsMatch(this.Username, config.UsernameRegex))
            {
                results.AddResult(new ValidationResult("用户名的格式不符合要求,用户名一般由字母、数字、下划线和汉字组成,且必须以汉字或字母开头", this, "", "", null));
            }
        }
Exemple #14
0
        /// <summary>
        /// 网站模块入口
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        void Application_BeginRequest(object source, EventArgs e)
        {
            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
            {
                //检查是否已经安装了网站
                CheckInstall(context);

                if (currentApplicationType != ApplicationType.Installer)
                {
                    //后台域名验证
                    if (currentApplicationType == ApplicationType.Admin && string.Compare(Globals.DomainName, HiContext.Current.SiteSettings.SiteUrl, true) != 0)
                    {
                        context.Response.Redirect(Globals.GetSiteUrls().Home, true);
                    }
                    else
                    {
                        CheckSSL(HiConfiguration.GetConfig().SSL, context);

                        HiContext.Create(context, new UrlReWriterDelegate(HiHttpModule.ReWriteUrl));

                        if (HiContext.Current.SiteSettings.IsDistributorSettings)
                        {
                            if (!((!HiContext.Current.SiteSettings.Disabled || (currentApplicationType != ApplicationType.Common)) || urlReg.IsMatch(context.Request.Url.AbsolutePath)))
                            {
                                context.Response.Write("站点维护中,暂停访问!");
                                context.Response.End();
                            }
                            else if (currentApplicationType == ApplicationType.Admin)
                            {
                                context.Response.Redirect(Globals.GetSiteUrls().Home, false);
                            }
                        }
                    }
                }
            }
        }
        private void btnEditPassWordOK_Click(object sender, EventArgs e)
        {
            ManagerInfo  manager        = Users.GetManager(this.userId);
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();

            if (manager != null && manager.UserName.ToLower() == "admin" && masterSettings.IsDemoSite)
            {
                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($"管理员登录密码的长度只能在{6}和{config.PasswordMaxLength}个字符之间", false);
                }
                else if (this.userId == HiContext.Current.ManagerId)
                {
                    HttpContext context = HiContext.Current.Context;
                    if (ManagerHelper.ChangePassword(manager, manager.Password, this.txtNewPassWord.Text))
                    {
                        this.ShowMsg("密码修改成功", true);
                    }
                    else
                    {
                        this.ShowMsg("修改密码失败,您输入的旧密码有误", false);
                    }
                }
                else if (ManagerHelper.ChangePassword(manager, this.txtOldPassWord.Text, this.txtNewPassWord.Text))
                {
                    this.ShowMsg("密码修改成功", true);
                }
                else
                {
                    this.ShowMsg("修改密码失败,您输入的旧密码有误", false);
                }
            }
        }
        protected IList <ManageThemeInfo> LoadThemes()
        {
            HttpContext context = HiContext.Current.Context;

            XmlDocument document = new XmlDocument();

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

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

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);                         //判断路径是否存在
            }
            string[] subDirList = Directory.Exists(path) ? Directory.GetDirectories(path) : null;

            ManageThemeInfo item      = null;
            string          themeName = "";
            DirectoryInfo   dirInfo   = null;

            foreach (string subDir in subDirList)
            {
                dirInfo = new DirectoryInfo(subDir);

                themeName = dirInfo.Name.ToLower();

                if ((themeName.Length > 0) && !themeName.StartsWith("_"))
                {
                    foreach (FileInfo fileInfo in dirInfo.GetFiles(themeName + ".xml"))
                    {
                        item = new ManageThemeInfo();
                        FileStream inStream = fileInfo.OpenRead();
                        document.Load(inStream);
                        inStream.Close();
                        item.Name        = document.SelectSingleNode("ManageTheme/Name").InnerText;
                        item.ThemeImgUrl = document.SelectSingleNode("ManageTheme/ImageUrl").InnerText;
                        item.ThemeName   = themeName;
                        list.Add(item);
                    }
                }
            }

            return(list);
        }
        private void btnEditPassWordOK_Click(object sender, EventArgs e)
        {
            SiteManager manager = ManagerHelper.GetManager(this.userId);

            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 < Membership.Provider.MinRequiredPasswordLength)) || (this.txtNewPassWord.Text.Length > config.PasswordMaxLength))
                {
                    this.ShowMsg(string.Format("管理员登录密码的长度只能在{0}和{1}个字符之间", Membership.Provider.MinRequiredPasswordLength, config.PasswordMaxLength), false);
                }
                else if (this.userId == HiContext.Current.User.UserId)
                {
                    if (manager.ChangePassword(this.txtOldPassWord.Text, this.txtNewPassWord.Text))
                    {
                        this.ShowMsg("密码修改成功", true);
                    }
                    else
                    {
                        this.ShowMsg("修改密码失败,您输入的旧密码有误", false);
                    }
                }
                else
                {
                    HttpContext context = HiContext.Current.Context;
                    if (manager.ChangePassword(this.txtNewPassWord.Text))
                    {
                        this.ShowMsg("密码修改成功", true);
                    }
                    else
                    {
                        this.ShowMsg("修改密码失败,您输入的旧密码有误", false);
                    }
                }
            }
        }
Exemple #18
0
        public void CheckMemberEmail(ValidationResults results)
        {
            HiConfiguration config = HiConfiguration.GetConfig();

            //if (string.IsNullOrEmpty(this.Email) || this.Email.Length > 256)
            //{
            //    results.AddResult(new ValidationResult("电子邮件不能为空且长度必须小于256个字符", this, "", "", null));
            //}
            //else
            //{
            //    if (!Regex.IsMatch(this.Email, config.EmailRegex))
            //    {
            //        results.AddResult(new ValidationResult("电子邮件的格式错误", this, "", "", null));
            //    }
            //}
            if (!string.IsNullOrWhiteSpace(this.Email))
            {
                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 > 256 || this.MSN.Length < 1 || !Regex.IsMatch(this.MSN, config.UsernameRegex)))
            {
                results.AddResult(new ValidationResult("请输入正确的微信号码,长度在1-256个字符以内", this, "", "", null));
            }
        }
Exemple #19
0
        private static string RootPath()
        {
            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
            string newValue      = Path.DirectorySeparatorChar.ToString();

            baseDirectory = baseDirectory.Replace("/", newValue);
            string filesPath = HiConfiguration.GetConfig().FilesPath;

            if (filesPath == null)
            {
                return(baseDirectory);
            }
            filesPath = filesPath.Replace("/", newValue);
            if (((filesPath.Length > 0) && filesPath.StartsWith(newValue)) && baseDirectory.EndsWith(newValue))
            {
                return(baseDirectory + filesPath.Substring(1));
            }
            return(baseDirectory + filesPath);
        }
Exemple #20
0
        private void method_1(object sender, System.EventArgs e)
        {
            this.applicationType_0 = HiConfiguration.GetConfig().AppLocation.CurrentApplicationType;
            HttpApplication httpApplication = (HttpApplication)sender;
            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);
                return;
            }
            this.method_2(context);
            if (this.applicationType_0 != ApplicationType.Installer)
            {
                if (this.applicationType_0 == ApplicationType.Admin && string.Compare(Globals.DomainName, "localhost", true) != 0 && string.Compare(Globals.DomainName, HiContext.Current.SiteSettings.SiteUrl, true) != 0)
                {
                    context.Response.Redirect(Globals.GetSiteUrls().Home, true);
                    return;
                }
                HiHttpModule.smethod_0(HiConfiguration.GetConfig().SSL, context);
                HiContext.Create(context, new UrlReWriterDelegate(HiHttpModule.smethod_1));
                if (HiContext.Current.SiteSettings.IsDistributorSettings)
                {
                    if (HiContext.Current.SiteSettings.Disabled && this.applicationType_0 == ApplicationType.Common && !HiHttpModule.regex_0.IsMatch(context.Request.Url.AbsolutePath))
                    {
                        context.Response.Write("站点维护中,暂停访问!");
                        context.Response.End();
                        return;
                    }
                    if (this.applicationType_0 == ApplicationType.Admin)
                    {
                        context.Response.Redirect(Globals.GetSiteUrls().Home, false);
                    }
                }
            }
        }
        private void btnEditPassWordOK_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Context.SiteManager manager = ManagerHelper.GetManager(this.userId);
            if (string.IsNullOrEmpty(this.txtNewPassWord.Text) || this.txtNewPassWord.Text.Length > 20 || this.txtNewPassWord.Text.Length < 6)
            {
                this.ShowMsg("密码不能为空,长度限制在6-20个字符之间", false);
                return;
            }
            if (string.Compare(this.txtNewPassWord.Text, this.txtPassWordCompare.Text) != 0)
            {
                this.ShowMsg("两次输入的密码不一样", false);
                return;
            }
            HiConfiguration config = HiConfiguration.GetConfig();

            if (string.IsNullOrEmpty(this.txtNewPassWord.Text) || this.txtNewPassWord.Text.Length < System.Web.Security.Membership.Provider.MinRequiredPasswordLength || this.txtNewPassWord.Text.Length > config.PasswordMaxLength)
            {
                this.ShowMsg(string.Format("管理员登录密码的长度只能在{0}和{1}个字符之间", System.Web.Security.Membership.Provider.MinRequiredPasswordLength, config.PasswordMaxLength), false);
                return;
            }
            if (this.userId == Hidistro.Membership.Context.HiContext.Current.User.UserId)
            {
                if (manager.ChangePassword(this.txtOldPassWord.Text, this.txtNewPassWord.Text))
                {
                    this.ShowMsg("密码修改成功", true);
                    return;
                }
                this.ShowMsg("修改密码失败,您输入的旧密码有误", false);
                return;
            }
            else
            {
                System.Web.HttpContext arg_126_0 = Hidistro.Membership.Context.HiContext.Current.Context;
                if (manager.ChangePassword(this.txtNewPassWord.Text))
                {
                    this.ShowMsg("密码修改成功", true);
                    return;
                }
                this.ShowMsg("修改密码失败,您输入的旧密码有误", false);
                return;
            }
        }
Exemple #22
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));
                }
            }
        }
Exemple #23
0
        public static string GetAdminAbsolutePath(string path)
        {
            string result;

            if (path.StartsWith("/"))
            {
                result = Globals.ApplicationPath + "/" + HiConfiguration.GetConfig().AdminFolder + path;
            }
            else
            {
                result = string.Concat(new string[]
                {
                    Globals.ApplicationPath,
                    "/",
                    HiConfiguration.GetConfig().AdminFolder,
                    "/",
                    path
                });
            }
            return(result);
        }
Exemple #24
0
 public static void SendQueuedEmails(int failureInterval, int maxNumberOfTries, SiteSettings settings)
 {
     if (settings != null)
     {
         EmailQueueDao   emailQueueDao             = new EmailQueueDao();
         HiConfiguration config                    = HiConfiguration.GetConfig();
         Dictionary <Guid, MailMessage> dictionary = emailQueueDao.DequeueEmail();
         IList <Guid> list        = new List <Guid>();
         EmailSender  emailSender = Messenger.CreateEmailSender(settings);
         if (emailSender != null)
         {
             int   num = 0;
             short smtpServerConnectionLimit = config.SmtpServerConnectionLimit;
             foreach (Guid key in dictionary.Keys)
             {
                 if (Messenger.SendMail(dictionary[key], emailSender))
                 {
                     emailQueueDao.DeleteQueuedEmail(key);
                     if (smtpServerConnectionLimit != -1 && ++num >= smtpServerConnectionLimit)
                     {
                         Thread.Sleep(new TimeSpan(0, 0, 0, 15, 0));
                         num = 0;
                     }
                 }
                 else
                 {
                     int num2 = emailQueueDao.GetMailMessage(key) + 1;
                     if (num2 <= maxNumberOfTries)
                     {
                         emailQueueDao.QueueSendingFailure(key, failureInterval, maxNumberOfTries);
                     }
                     else
                     {
                         emailQueueDao.DeleteQueuedEmail(key);
                     }
                 }
             }
         }
     }
 }
        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[] dirs = Directory.Exists(str) ? Directory.GetDirectories(str) : null;

            if (null != dirs)
            {
                ManageThemeInfo item = null;

                foreach (string dir in dirs)
                {
                    DirectoryInfo info = new DirectoryInfo(dir);

                    string dirName = info.Name.ToLower();

                    if ((dirName.Length > 0) && !dirName.StartsWith("_"))
                    {
                        foreach (FileInfo info3 in info.GetFiles(dirName + ".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   = dirName;
                            list.Add(item);
                        }
                    }
                }
            }
            return(list);
        }
Exemple #26
0
        private void btnEditPassWordOK_Click(object sender, System.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);
                            }
                        }
                    }
                }
            }
        }
Exemple #27
0
        private static string RootPath()
        {
            string text  = AppDomain.CurrentDomain.BaseDirectory;
            string text2 = Path.DirectorySeparatorChar.ToString();

            text = text.Replace("/", text2);
            string text3 = HiConfiguration.GetConfig().FilesPath;

            if (text3 != null)
            {
                text3 = text3.Replace("/", text2);
                if (text3.Length > 0 && text3.StartsWith(text2) && text.EndsWith(text2))
                {
                    text += text3.Substring(1);
                }
                else
                {
                    text += text3;
                }
            }
            return(text);
        }
Exemple #28
0
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication httpApplication = (HttpApplication)sender;
            HttpContext     context         = httpApplication.Context;

            if (context.Request.RawUrl.IndexOfAny(new char[4]
            {
                '<',
                '>',
                '\'',
                '"'
            }) != -1)
            {
                context.Response.Redirect(context.Request.RawUrl.Replace("<", "%3c").Replace(">", "%3e").Replace("'", "%27")
                                          .Replace("\"", "%22"), false);
            }
            else
            {
                this.CheckInstall(context);
                Global.CheckSSL(HiConfiguration.GetConfig().SSL, context);
            }
        }
Exemple #29
0
        protected IList <ManageThemeInfo> LoadThemes(string currentThemeName)
        {
            HttpContext             context  = HiContext.Current.Context;
            XmlDocument             document = new XmlDocument();
            IList <ManageThemeInfo> list     = new List <ManageThemeInfo>();
            string path = context.Request.PhysicalApplicationPath + HiConfiguration.GetConfig().FilesPath + @"\Templates\sites\" + HiContext.Current.User.UserId.ToString();

            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(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;
                        if (string.Compare(item.ThemeName, currentThemeName) == 0)
                        {
                            this.litThemeName.Text       = item.ThemeName;
                            this.imgThemeImgUrl.ImageUrl = string.Concat(new object[] { Globals.ApplicationPath, "/Templates/sites/", HiContext.Current.User.UserId, "/", str2, "/", document.SelectSingleNode("ManageTheme/ImageUrl").InnerText });
                            this.Image1.ImageUrl         = string.Concat(new object[] { Globals.ApplicationPath, "/Templates/sites/", HiContext.Current.User.UserId, "/", str2, "/", document.SelectSingleNode("ManageTheme/BigImageUrl").InnerText });
                        }
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
Exemple #30
0
 static RoleHelper()
 {
     rolesConfig  = HiConfiguration.GetConfig().RolesConfiguration;
     defaultRoles = rolesConfig.RoleList();
 }