Exemple #1
0
        /// <summary>
        /// 解锁IP
        /// </summary>
        /// <param name="IP">IP地址</param>
        /// <returns></returns>
        public bool UnLockIP(string IP)
        {
            PropertyControl pc         = con.MainDomainConfigWithoutUserConfig;
            int             needDelete = 0;
            string          maxStr     = pc["IPAccess1"].ToString();

            foreach (DictionaryEntry de in pc)
            {
                Match m = Regex.Match(de.Key.ToString(), @"IPAccess([0-9]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (m.Success)
                {
                    Match m1 = Regex.Match(de.Value.ToString(), IP, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    if (m1.Success)
                    {
                        needDelete = Convert.ToInt32(m.Groups[1].Value);
                    }
                }
            }

            if (needDelete != 0)
            {
                string needDeleteStr = "IPAccess" + needDelete.ToString();
                pc.Remove(needDeleteStr);
                string reStr = "IPAccess" + (needDelete + 1).ToString();
                pc.Add(needDeleteStr, pc[reStr]);
                pc.Remove(reStr);
                con.SaveIni();
                return(true);
            }
            return(false);
        }