public JsonResult HEO_InsertMembers(string Id, string Account, string Password, string Name, string Facebookid, string Cookie) { if (Id == "HEOInsertMembers") { int useragent_count = useragentService.Get().Where(a => a.Isweb == 1).Count(); Random crandom = new Random(); int rand = crandom.Next(0, useragent_count - 1); Useragent[] useragent = useragentService.Get().Where(a => a.Isweb == 1).ToArray(); Members member = new Members(); member.Isenable = 1; member.Is_import = 1; member.Memberid = Guid.NewGuid(); member.Levelid = Guid.Parse("0db21b54-35a7-400b-a8ea-e9c4c2879609"); member.Account = Account; member.Password = Password; member.Name = Name; member.Facebookid = Facebookid; member.Facebookcookie = Cookie; member.Useragent_phone = useragent[rand].User_agent; member.Logindate = 99999999999; member.Lastdate = Now; member.Createdate = DateTime.Now; member.Updatedate = DateTime.Now; /**** 寫入登入列表裡 ****/ Memberloginrecord memberloginrecord = new Memberloginrecord(); memberloginrecord.Memberid = member.Memberid; memberloginrecord.Status = 1; memberloginrecord.Createdate = DateTime.Now; member.Memberloginrecord.Add(memberloginrecord); /**** 開產品權限 ****/ IEnumerable <Feedbackproduct> feedbackproduct = feedbackproductService.Get().ToList(); /**** 產品授權功能,預設都為true 【false : 未授權 , true: 已授權】 ****/ foreach (Feedbackproduct productList in feedbackproduct) { Memberauthorization memberauthorization = new Memberauthorization(); memberauthorization.Id = Guid.NewGuid(); memberauthorization.Memberid = member.Memberid; memberauthorization.Feedbackproductid = productList.Feedbackproductid; memberauthorization.Checked = true; member.Memberauthorization.Add(memberauthorization); } membersService.Create(member); membersService.SaveChanges(); return(this.Json("Success", JsonRequestBehavior.AllowGet)); } else { return(this.Json("Error", JsonRequestBehavior.AllowGet)); } }
// GET: UseragentMs public ActionResult Useragent(int p = 1) { var data = useragentService.Get().OrderByDescending(o => o.Createdate); ViewBag.pageNumber = p; ViewBag.Useragent = data.ToPagedList(pageNumber: p, pageSize: 20); return(View()); }
public ActionResult Useragent(int p = 1) { var data = useragentService.Get().OrderBy(a => a.Id); ViewBag.pageNumber = p; ViewBag.Useragent = data.ToPagedList(pageNumber: p, pageSize: 20); return(View()); }
public ActionResult AddMembers(Members members) { /*** 隨機指派手機版Useragent ***/ int useragent_phone = useragentService.Get().Where(a => a.Isweb == 1).Count(); Random rnd = new Random(); int rnd_useragent = rnd.Next(1, useragent_phone); Useragent useragent = useragentService.Get().Where(a => a.Id == rnd_useragent).FirstOrDefault(); /*** End Useragent ***/ if (TryUpdateModel(members, new string[] { "Sex", "Account", "Password", "Facebookstauts", "Facebookid", "Feedbackmoney", "Name", "Isenable" }) && ModelState.IsValid) { members.Memberid = Guid.NewGuid(); members.Account = Regex.Replace(members.Account, @"[^a-z||A-Z||@||.||0-9]", ""); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值 members.Createdate = DateTime.Now; members.Updatedate = DateTime.Now; members.Lastdate = ((int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds) - 28800; // 總秒數 members.Isenable = 1; members.Is_import = 1; members.Logindate = 99999999999; members.Isreal = members.Isreal; members.Levelid = members.Levelid; members.Useragent_phone = useragent.User_agent; members.Facebookid = members.Facebookid.Replace("https://www.facebook.com/profile.php?id=", ""); /**** 將會員寫進會員登入紀錄裡,預設狀態為0 【0 : 未驗證 , 1 : 已驗證 , 2 : 需驗證】 ****/ Memberloginrecord memberloginrecord = new Memberloginrecord(); memberloginrecord.Memberid = members.Memberid; memberloginrecord.Createdate = members.Createdate; memberloginrecord.Status = 0; members.Memberloginrecord.Add(memberloginrecord); /**** End Memberloginrecord ****/ membersService.Create(members); foreach (Memberauthorization memberauthorization in members.Memberauthorization) { memberauthorization.Id = Guid.NewGuid(); memberauthorizationService.Create(memberauthorization); } membersService.SaveChanges(); } return(RedirectToAction("Members")); }
public ActionResult AddFBMembers(FBMembers fbmember) { Guid FBAccountCostid = Guid.Parse("bfc0aa6b-91e9-4c1e-ba33-853ce7e92880"); // FB帳號成本ID Product FBAccountCostProduct = productService.GetByID(FBAccountCostid); // FB帳號成本 if (TryUpdateModel(fbmember, new string[] { "FB_Account", "FB_Password", "Facebooklink", "FB_Name", "Isenable", "Productid" }) && ModelState.IsValid) { fbmember.FBMemberid = Guid.NewGuid(); fbmember.FB_Account = Regex.Replace(fbmember.FB_Account, @"[^a-z||A-Z||@||.||0-9]", "").Replace(" ", "").Trim(); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值,清除頭尾空白 fbmember.Createdate = dt_tw(); fbmember.Updatedate = dt_tw(); fbmember.Lastdate = ((int)(dt_tw() - new DateTime(1970, 1, 1)).TotalSeconds) - 28800; // 總秒數 fbmember.AccountCost = FBAccountCostProduct.Cost; // 帳號成本為當前的帳號成本 fbmember.Isenable = 1; /*** 隨機抓取Useragent ***/ int useragentCount = useragentService.Get().Count(); Useragent[] useragent = useragentService.Get().ToArray(); Random crand = new Random(); int rand = crand.Next(0, useragentCount - 1); fbmember.Useragent = useragent[rand].User_agent; /**** 將會員寫進會員登入紀錄裡,預設狀態為0 【0 : 未驗證 , 1 : 已驗證 , 2 : 需驗證】 ****/ FBMembersLoginlog fbmembersloginlog = new FBMembersLoginlog(); fbmembersloginlog.FBMemberid = fbmember.FBMemberid; fbmembersloginlog.Createdate = fbmember.Createdate; fbmembersloginlog.Status = 0; fbmember.FBMembersLoginlog.Add(fbmembersloginlog); /**** End Memberloginrecord ****/ fbmembersService.Create(fbmember); fbmembersService.SaveChanges(); } return(RedirectToAction("FBMembers")); }
public ActionResult Login(Members members) { string Account = Regex.Replace(members.Account, @"[^a-z||A-Z||@||.||0-9||_]", ""); // 保留A-Z、a-z、0-9、小老鼠、小數點,其餘取代空值 Members thismember = membersService.Get().Where(a => a.Account == members.Account).FirstOrDefault(); string useragent_phone = ""; if (thismember != null) { useragent_phone = thismember.Useragent_phone; } else { /***** useragent *****/ useragent_phone = "Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0 Mobile/15B202 Safari/604.1"; } /**** HTTP POST ****/ HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://heohelp.com:8080/Check/CheckFacebook"); httpWebRequest.ContentType = "application/json"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json = new JavaScriptSerializer().Serialize(new { Account = Account, Password = members.Password, Useragent = useragent_phone }); streamWriter.Write(json); } HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); string result = ""; using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { result = streamReader.ReadToEnd(); } //ViewBag.message = result; //return View(); string[] status = result.Replace("\"", "").Split('#'); ///**** 測試用 ****/ //string[] status = new string[5]; //status[0] = "成功登入!"; //status[1] = ""; //status[2] = ""; //status[3] = ""; //status[4] = ""; if (status[0] == "成功登入!") { Session["Img"] = status[2]; Session["Facebookname"] = status[3]; IEnumerable <Members> old_members = membersService.Get().ToList(); Guid NormalLevelid = memberlevelService.Get().Where(a => a.Levelname == "一般").FirstOrDefault().Levelid; IEnumerable <Feedbackproduct> feedbackproduct = feedbackproductService.Get(); foreach (Members old_member in old_members) { if (old_member.Facebookid.Equals(status[1])) { if (Session["href"] == null) { if (old_member.Facebookstatus == 0) { Session["IsLogin"] = true; Session["Memberid"] = old_member.Memberid; /**** 將會員成功登入寫進會員登入紀錄裡 ****/ Memberloginrecord memberloginrecord = new Memberloginrecord(); memberloginrecord.Memberid = old_member.Memberid; memberloginrecord.Createdate = DateTime.Now; memberloginrecord.Status = 1; memberloginrecordService.Create(memberloginrecord); memberloginrecordService.SaveChanges(); /**** End Memberloginrecord ****/ /**** 更新會員Facebooklink連結 *****/ old_member.Facebookid = status[1]; old_member.Facebookcookie = status[4]; old_member.Password = members.Password; // 更新密碼 old_member.Logindate = ((int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800); // 登入時間為現在時間的總秒數 membersService.SpecificUpdate(old_member, new string[] { "Facebookid", "Facebookcookie", "Logindate", "Password" }); membersService.SaveChanges(); /***** End Facebookid ****/ return(RedirectToAction("Certified")); } else { Session["IsLogin"] = true; Session["Memberid"] = old_member.Memberid; /**** 將會員成功登入寫進會員登入紀錄裡 ****/ Memberloginrecord memberloginrecord = new Memberloginrecord(); memberloginrecord.Memberid = old_member.Memberid; memberloginrecord.Createdate = DateTime.Now; memberloginrecord.Status = 1; memberloginrecordService.Create(memberloginrecord); memberloginrecordService.SaveChanges(); /**** End Memberloginrecord ****/ /**** 更新會員Facebookid連結 *****/ old_member.Facebookid = status[1]; old_member.Facebookcookie = status[4]; old_member.Password = members.Password; // 更新密碼 old_member.Logindate = ((int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800); // 登入時間為現在時間的總秒數 membersService.SpecificUpdate(old_member, new string[] { "Facebookid", "Facebookcookie", "Logindate", "Password" }); membersService.SaveChanges(); /***** End Facebookid ****/ return(RedirectToAction("Order", "OrderMs")); } } else { Session["IsLogin"] = true; Session["Memberid"] = old_member.Memberid; /**** 將會員成功登入寫進會員登入紀錄裡 ****/ Memberloginrecord memberloginrecord = new Memberloginrecord(); memberloginrecord.Memberid = old_member.Memberid; memberloginrecord.Createdate = DateTime.Now; memberloginrecord.Status = 1; memberloginrecordService.Create(memberloginrecord); memberloginrecordService.SaveChanges(); /**** End Memberloginrecord ****/ /**** 更新會員Facebookid連結 *****/ old_member.Facebookid = status[1]; old_member.Facebookcookie = status[4]; old_member.Password = members.Password; // 更新密碼 old_member.Logindate = ((int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800); // 登入時間為現在時間的總秒數 membersService.SpecificUpdate(old_member, new string[] { "Facebookid", "Facebookcookie", "Logindate", "Password" }); membersService.SaveChanges(); /***** End Facebookid ****/ return(RedirectToAction("Deposit", "DepositMs")); } } } if (TryUpdateModel(members, new string[] { "Password" })) { /*** 隨機抓取Useragent ***/ int useragentCount = useragentService.Get().Count(); Useragent[] useragent = useragentService.Get().ToArray(); Random crand = new Random(); int rand = crand.Next(0, useragentCount - 1); /******* 新增會員 ********/ members.Memberid = Guid.NewGuid(); members.Levelid = NormalLevelid; members.Isenable = 1; members.Is_import = 0; // 是否匯入【0: 前台登入 , 1 : 後台匯入 , 2 : 轉前台】 members.Account = Account; members.Createdate = DateTime.Now; members.Updatedate = DateTime.Now; members.Facebookcookie = status[4]; members.Useragent_phone = useragent[rand].User_agent; members.Lastdate = (int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800; members.Logindate = (int)(DateTime.Now - new DateTime(1970, 1, 1)).TotalSeconds - 28800; // 紀錄目前登入時間 members.Name = status[3]; members.Facebookid = status[1]; /*** 預設將產品授權功能為fasle 【false:未授權 , true: 已授權】 ***/ foreach (Feedbackproduct feedbackproductlist in feedbackproduct) { Memberauthorization memberauthorization = new Memberauthorization(); memberauthorization.Id = Guid.NewGuid(); memberauthorization.Memberid = members.Memberid; memberauthorization.Feedbackproductid = feedbackproductlist.Feedbackproductid; memberauthorization.Checked = false; members.Memberauthorization.Add(memberauthorization); //memberauthorizationService.Create(memberauthorization); } /**** 將會員成功登入寫進會員登入紀錄裡 ****/ Memberloginrecord memberloginrecord = new Memberloginrecord(); memberloginrecord.Memberid = members.Memberid; memberloginrecord.Createdate = members.Createdate; memberloginrecord.Status = 1; members.Memberloginrecord.Add(memberloginrecord); /**** End Memberloginrecord ****/ membersService.Create(members); membersService.SaveChanges(); } Session["IsLogin"] = true; Session["Memberid"] = members.Memberid; if (Session["href"] == null) { return(RedirectToAction("Certified")); } else { return(RedirectToAction("Deposit", "DepositMs")); } } else { /*** 如果該會員有登過heo ***/ if (thismember != null) { /**** 將會員登入失敗寫進會員登入紀錄裡 ****/ Memberloginrecord memberloginrecord = new Memberloginrecord(); memberloginrecord.Memberid = thismember.Memberid; memberloginrecord.Createdate = DateTime.Now; memberloginrecord.Status = 2; memberloginrecordService.Create(memberloginrecord); memberloginrecordService.SaveChanges(); /**** End Memberloginrecord ****/ } ViewBag.Status = status[0]; return(View()); } }