public ActionResult DeleteConfirmed(int id) { ssh ssh = db.sshes.Find(id); db.sshes.Remove(ssh); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,ssh1,username,password,country,city,used,live")] ssh ssh) { if (ModelState.IsValid) { db.Entry(ssh).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ssh)); }
public ActionResult Create([Bind(Include = "ID,ssh1,username,password,country,city,used,live")] ssh ssh) { if (ModelState.IsValid) { db.sshes.Add(ssh); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ssh)); }
// GET: sshes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ssh ssh = db.sshes.Find(id); if (ssh == null) { return(HttpNotFound()); } return(View(ssh)); }
public ActionResult Upload(HttpPostedFileBase[] files) { List <ssh> _listssh = new List <ssh>(); string content = ""; foreach (var file in files) { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var contentLength = file.ContentLength; var contentType = file.ContentType; // Get file data byte[] data = new byte[] { }; using (var binaryReader = new BinaryReader(file.InputStream)) { data = binaryReader.ReadBytes(file.ContentLength); content += System.Text.Encoding.UTF8.GetString(data); content += "\r\n"; } } } string sshes = content; IEnumerable <string> listssh = sshes.Split(new string[] { "\r\n" }, StringSplitOptions.None); var _listsshdb = IPAddressRange.listsshes.Select(x => x.ssh1); string listip = String.Join("|", _listsshdb.ToArray()); foreach (var ssh in listssh) { List <string> sshdetail = ssh.Split(new string[] { "|" }, StringSplitOptions.None).ToList(); if (sshdetail.Count >= 3) { if (sshdetail.Count == 3) { sshdetail.Add("Unknown"); sshdetail.Add("Unknown"); } else if (sshdetail.Count == 4) { sshdetail.Add("Unknown"); } string ssh_ = sshdetail[0]; string _country = sshdetail[3]; string _city = sshdetail[4]; MaxMind.GeoIP2.Responses.CityResponse city; try { city = reader.City(sshdetail[0]); _country = city.Country.Name; _city = city.City.Name; } catch (Exception) { } if (!listip.Contains(ssh_)) { ssh newssh = new ssh(); newssh.ssh1 = sshdetail[0]; newssh.username = sshdetail[1]; newssh.password = sshdetail[2]; newssh.used = null; newssh.live = true; newssh.country = _country; newssh.city = _city; listip += ssh_; listip += "|"; _listssh.Add(newssh); } else { ssh prevssh = db.sshes.Where(x => x.ssh1 == ssh_).FirstOrDefault(); if (prevssh != null) { prevssh.username = sshdetail[1]; prevssh.password = sshdetail[2]; prevssh.country = _country; prevssh.city = _city; prevssh.live = true; } } } } using (var transactionScope = new TransactionScope()) { // some stuff in dbcontext db.BulkInsert(_listssh); db.SaveChanges(); transactionScope.Complete(); } return(RedirectToAction("Index")); }
public void uploadssh(string sshes) { List <ssh> _listssh = new List <ssh>(); IEnumerable <string> listssh = sshes.Split(new string[] { "\r\n" }, StringSplitOptions.None); foreach (var ssh in listssh) { List <string> sshdetail = ssh.Split(new string[] { "|" }, StringSplitOptions.None).ToList(); if (sshdetail.Count >= 3) { if (sshdetail.Count == 3) { sshdetail.Add("Unknown"); sshdetail.Add("Unknown"); } else if (sshdetail.Count == 4) { sshdetail.Add("Unknown"); } string ssh_ = sshdetail[0]; string _country = sshdetail[3]; string _city = sshdetail[4]; MaxMind.GeoIP2.Responses.CityResponse city; try { city = reader.City(sshdetail[0]); _country = city.Country.Name; _city = city.City.Name; } catch (Exception) { } ssh prevssh = IPAddressRange.listsshes.FirstOrDefault(x => x.ssh1 == ssh_); if (prevssh == null) { ssh newssh = new ssh(); newssh.ssh1 = sshdetail[0]; newssh.username = sshdetail[1]; newssh.password = sshdetail[2]; newssh.used = null; newssh.live = true; newssh.country = _country; newssh.city = _city; IPAddressRange.listsshes.Add(newssh); } else { if (prevssh != null) { prevssh.username = sshdetail[1]; prevssh.password = sshdetail[2]; prevssh.country = _country; prevssh.city = _city; prevssh.live = true; } } } } /* * using (var transactionScope = new TransactionScope()) * { * // some stuff in dbcontext * * db.BulkInsert(_listssh); * * db.SaveChanges(); * transactionScope.Complete(); * } */ }
public string getssh(string country, string offerID, string IP, string citygeo, string fast) { if (IP != null && IP != "") { var sssh = IPAddressRange.listsshes.FirstOrDefault(x => x.ssh1 == IP && x.live == true); if (sssh != null) { return(sssh.ID.ToString() + "|" + sssh.ssh1 + "|" + sssh.username + "|" + sssh.password + "|" + sssh.country + "|" + sssh.city); } } var b = IPAddressRange.listsshes.Where(x => (country == "" || country == null || x.country == country) && x.live == true); var a = b.OrderBy(x => x.ID).Skip(new Random().Next(b.Count())).FirstOrDefault(); if (a == null) { return("hetssh"); } return(a.ID.ToString() + "|" + a.ssh1 + "|" + a.username + "|" + a.password + "|" + a.country + "|" + a.city); List <ssh> Listssh; if (offerID != null) { Listssh = db.sshes.Where(x => x.country == country && x.live == true && (x.used == null || x.used.Contains("|" + offerID + "|") == false)).ToList(); } else { Listssh = db.sshes.Where(x => x.country == country && x.live == true).ToList(); } if (Listssh.Count() == 0) { return("hetssh"); } if (IP != null) { var _listSSH = Listssh.Where(x => x.ssh1.StartsWith(IP)); if (_listSSH.Count() != 0) { Listssh = _listSSH.ToList(); } else { string curcity = citygeo; if (curcity == null || curcity == "") { Regex ip = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"); Match match = ip.Match(IP); if (match.Success) { try { var city = reader.City(match.Groups[0].Value.ToString()); curcity = city.City.Name; } catch (Exception) { } } } if (curcity != "" && curcity != null) { _listSSH = Listssh.Where(x => x.city == curcity); if (_listSSH.Count() != 0) { Listssh = _listSSH.ToList(); } } } } else { if (citygeo != null && citygeo != "") { string curcity = citygeo; if (curcity != "" && curcity != null) { var _listSSH = Listssh.Where(x => x.city == curcity); if (_listSSH.Count() != 0) { Listssh = _listSSH.ToList(); } } } } Random rd = new Random(); int _rd = rd.Next(0, Listssh.Count()); ssh randomssh = Listssh.OrderBy(x => x.ssh1).Skip(_rd).FirstOrDefault(); if (offerID != null) { if (randomssh.used == null) { randomssh.used = "|"; } randomssh.used += offerID + "|"; } db.SaveChanges(); return(randomssh.ID.ToString() + "|" + randomssh.ssh1 + "|" + randomssh.username + "|" + randomssh.password + "|" + randomssh.country + "|" + randomssh.city); }