public static bool CanCreate( IPAddress ip ) { if ( !IPTable.ContainsKey( ip ) ) return true; return ( IPTable[ip] < MaxAccountsPerIP ); }
public static bool CanCreate(IPAddress ip) { if (!IPTable.ContainsKey(ip)) { return(true); } // ADDING EXCEPTION FOR KIMCHI (skype: sexykimchi) List <IPAddress> allowTen = new List <IPAddress>(); allowTen.Add(IPAddress.Parse("14.42.47.67")); allowTen.Add(IPAddress.Parse("59.7.203.153")); allowTen.Add(IPAddress.Parse("112.161.232.54")); allowTen.Add(IPAddress.Parse("211.202.136.163")); foreach (IPAddress exempt in allowTen) { if (ip.Equals(exempt)) { return(IPTable[ip] < 11); } } // END EXCEPTION return(IPTable[ip] < MaxAccountsPerIP); }
public static bool CanCreate(IPAddress ip) { if (!IPTable.ContainsKey(ip)) { return(true); } if (IPLimiter.IsExempt(ip)) { return(true); } return(IPTable[ip] <= MaxAccountsPerIP); }
public void ReadExcelContent(HttpPostedFileBase File, List <IPTable> data) { uint rowNum = 0; uint colNum = 0; try { Net.SourceForge.Koogra.IWorkbook wb = null; string fileExt = Path.GetExtension(File.FileName); if (string.IsNullOrEmpty(fileExt)) { throw new Exception("File extension not found"); } if (fileExt.Equals(".xlsx", StringComparison.OrdinalIgnoreCase)) { wb = Net.SourceForge.Koogra.WorkbookFactory.GetExcel2007Reader(File.InputStream); } else if (fileExt.Equals(".xls", StringComparison.OrdinalIgnoreCase)) { wb = Net.SourceForge.Koogra.WorkbookFactory.GetExcelBIFFReader(File.InputStream); } for (int i = 0; i < wb.Worksheets.Count; i++) { Net.SourceForge.Koogra.IWorksheet ws = wb.Worksheets.GetWorksheetByIndex(i); IPTable table = data.FirstOrDefault(f => f.Name == ws.Name); if (table == default(IPTable)) { continue; } for (uint r = ws.FirstRow; r <= ws.LastRow; ++r) { rowNum = r; Net.SourceForge.Koogra.IRow row = ws.Rows.GetRow(r); if (row != null) { for (uint colCount = ws.FirstCol; colCount <= ws.LastCol; ++colCount) { colNum = colCount; string cellData = string.Empty; if (row.GetCell(colCount) != null && row.GetCell(colCount).Value != null) { cellData = row.GetCell(colCount).Value.ToString(); } if (r == ws.FirstRow) { table.AddHeader(cellData); } else { table.Flow = cellData; } } } } } } catch (Exception ex) { Exception exception = ex; exception.Source = string.Format("Error occured on row {0} col {1}", rowNum, colNum); throw ex; } }
public ActionResult Login(string Username, string Password) { BLL.AdminTable bllAdmin = new BLL.AdminTable(); BLL.TeacherTable bllTeacher = new BLL.TeacherTable(); BLL.StudentTable bllStudent = new BLL.StudentTable(); if (string.IsNullOrEmpty(Username) || string.IsNullOrEmpty(Password)) { return(this.Json(new { result = 0, data = "" })); } Password = encryptPwd(Password); string strSql = "Username='******' and Password='******'"; List <AdminTable> adminList = bllAdmin.DataTableToList(bllAdmin.GetList(strSql).Tables[0]); List <TeacherTable> teacherList = bllTeacher.DataTableToList(bllTeacher.GetList(strSql).Tables[0]); List <StudentTable> studentList = bllStudent.DataTableToList(bllStudent.GetList(strSql).Tables[0]); if (adminList.Count > 0) { AdminTable adminModel = adminList[0]; strSql = "select * from AccessTable where ID = 1 or ID = 2 or ID = 3 or ID = 4 or ID = 5 or ID = 6"; List <AccessTable> tableList = new BLL.AccessTable().DataTableToList(DbHelperSQL.Query(strSql).Tables[0]); string sessionString = ""; if (tableList.Count != 0) { sessionString += "["; foreach (AccessTable tableModel in tableList) { sessionString += new JavaScriptSerializer().Serialize(tableModel) + ","; } sessionString = sessionString.Remove(sessionString.Length - 1); sessionString += "]"; } Session.Timeout = 30; Session["username"] = adminModel.Username; Session["access"] = sessionString; Session["name"] = adminModel.Name; Session["type"] = "管理员"; return(this.Json(new { result = 1, data = "" })); } else if (teacherList.Count > 0) { TeacherTable teacherModel = teacherList[0]; strSql = "select * from AccessTable where ID = 3 or ID = 4 or ID = 5 or ID = 6"; List <AccessTable> tableList = new BLL.AccessTable().DataTableToList(DbHelperSQL.Query(strSql).Tables[0]); string sessionString = ""; if (tableList.Count != 0) { sessionString += "["; foreach (AccessTable tableModel in tableList) { sessionString += new JavaScriptSerializer().Serialize(tableModel) + ","; } sessionString = sessionString.Remove(sessionString.Length - 1); sessionString += "]"; } Session.Timeout = 30; Session["username"] = teacherModel.Username; Session["access"] = sessionString; Session["name"] = teacherModel.Name; Session["type"] = "教师"; return(this.Json(new { result = 1, data = "" })); } else if (studentList.Count > 0) { BLL.IPTable bllIP = new BLL.IPTable(); string ipv4 = GetIPv4.GetClientIPv4Address(); string strIP = "IP='" + ipv4 + "'"; List <IPTable> ipList1 = bllIP.DataTableToList(bllIP.GetList(strIP).Tables[0]); if (ipList1.Count > 0) { IPTable IPModel = ipList1[0]; if (IPModel.Username.Equals(Username)) { StudentTable studentModel = studentList[0]; strSql = "select * from AccessTable where ID = 7 or ID = 8"; List <AccessTable> tableList = new BLL.AccessTable().DataTableToList(DbHelperSQL.Query(strSql).Tables[0]); string sessionString = ""; if (tableList.Count != 0) { sessionString += "["; foreach (AccessTable tableModel in tableList) { sessionString += new JavaScriptSerializer().Serialize(tableModel) + ","; } sessionString = sessionString.Remove(sessionString.Length - 1); sessionString += "]"; } Session.Timeout = 30; Session["username"] = studentModel.Username; Session["access"] = sessionString; Session["name"] = studentModel.Name; Session["type"] = "学生"; return(this.Json(new { result = 1, data = "" })); } else { return(this.Json(new { result = 2, data = "" })); } } else { strIP = "Username = '******'"; List <IPTable> ipList2 = bllIP.DataTableToList(bllIP.GetList(strIP).Tables[0]); if (ipList2.Count > 0) { return(this.Json(new { result = 2, data = "" })); } else { IPTable model = new IPTable(); model.Username = Username; model.IP = ipv4; bllIP.Add(model); StudentTable studentModel = studentList[0]; strSql = "select * from AccessTable where ID = 7 or ID = 8"; List <AccessTable> tableList = new BLL.AccessTable().DataTableToList(DbHelperSQL.Query(strSql).Tables[0]); string sessionString = ""; if (tableList.Count != 0) { sessionString += "["; foreach (AccessTable tableModel in tableList) { sessionString += new JavaScriptSerializer().Serialize(tableModel) + ","; } sessionString = sessionString.Remove(sessionString.Length - 1); sessionString += "]"; } Session.Timeout = 30; Session["username"] = studentModel.Username; Session["access"] = sessionString; Session["name"] = studentModel.Name; Session["type"] = "学生"; return(this.Json(new { result = 1, data = "" })); } } } else { return(this.Json(new { result = 0, data = "" })); } }