/// <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); }
/// <summary> /// 创建账户 /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <param name="HomeDir">主目录</param> /// <param name="Access">权限</param> /// <returns></returns> public bool CreateUser(string username, string password, string HomeDir, string Access = "WLP" /*默认为WLP,具体写法请参见serv-u配置文件说明*/) { if (!con.FtpUserList.ContainsKey(username)) { HomeDir = XMLHelper.getAppSettingValue("FTP_Home") + "\\" + HomeDir; if (!Directory.Exists(HomeDir)) { Directory.CreateDirectory(HomeDir); } FtpUserInfo userinfo = new FtpUserInfo(); userinfo.UserName = username; userinfo.Password = password; PropertyControl pc = userinfo.PropertyList; pc.Add("TimeOut", "600"); pc.Add("RelPaths", "1"); pc.Add("MaxUsersLoginPerIP", "1"); pc.Add("HomeDir", HomeDir); pc.Add("MaxNrUsers", "1"); pc.Add("Access1", HomeDir + "|" + Access); con.FtpUserList.Add(username, userinfo); con.SaveIni(); if (!File.Exists(HomeDir + "\\上传的光盘文件命名请包含正确的ISBN和光盘条码.txt")) { File.Create(@HomeDir + "\\上传的光盘文件命名请包含正确的ISBN和光盘条码!.txt"); } //if (!File.Exists(@HomeDir + "\\请尽量避免光盘文件名包含中文.txt")) { File.Create(@HomeDir + "\\请尽量避免光盘文件名包含中文.txt"); } return(true); } else { return(false); } }