private void Form1_Load(object sender, EventArgs e)
 {
     LoadData();
     AppExtension.LoadApp(chkuseragent);
     //lbaccount.Text = user;
     //lbexpday.Text = expdate;
 }
        private void btnopencookie_Click(object sender, EventArgs e)
        {
            string OpenfileStatus = AppExtension.OpenfileDialog("File cookie á");

            if (OpenfileStatus == "chưa có mở")
            {
                return;
            }
            txtcookiefile.Text = OpenfileStatus;
        }
        private void btnopenemail_Click(object sender, EventArgs e)
        {
            string OpenfileStatus = AppExtension.OpenfileDialog("File email á");

            if (OpenfileStatus == "chưa có mở")
            {
                return;
            }
            txtemail.Text = OpenfileStatus;
            TotalCount    = Convert.ToInt32(File.ReadAllLines(OpenfileStatus).Length);
        }
 private void btnsetup_Click(object sender, EventArgs e)
 {
     lbstatus.Text = "đang setup...";
     if (txtcookiefile.Text.Length < 3 || txtemail.Text.Length < 3)
     {
         AppExtension.MessageBoxShow("Thiếu file đầu vào email hoặc cookie !", 3);
         return;
     }
     new Thread(() =>
     {
         SetupData();
     }).Start();
 }
 private void btnstart_Click(object sender, EventArgs e)
 {
     //AppExtension.MessageBoxShow("thiếu cmn file rồi", 2);
     //AppExtension.MessageBoxShow("good", 1);
     //AppExtension.MessageBoxShow("lỗi gì đó", 3);
     //string namefb = Regex.Match(txtemail.Text, "uid.*?(\\d+)").Groups[1].Value;\
     //string test = Facebook.FacebookDateCreated("100055700742809", "AQHi6kC3ZdPS:AQEQ6yi5NMrE");
     PathError   = Application.StartupPath + "\\data\\fail\\" + "error_mail_" + DateFormat + ".txt";
     PathSuccess = Application.StartupPath + "\\data\\success\\" + "success_" + DateFormat + ".txt";
     if (isSetupsucces == false)
     {
         AppExtension.MessageBoxShow("chưa setup data ! vui lòng bấm setup data...", 2);
         return;
     }
     isstop           = false;
     btnstart.Enabled = false;
     btnstop.Enabled  = true;
     lbstatus.Text    = "đang chạy...";
     try
     {
         new Thread(() =>
         {
             string[] ListEmail = File.ReadAllLines(txtemail.Text);
             ParallelOptions parallelOptions        = new ParallelOptions();
             parallelOptions.MaxDegreeOfParallelism = Convert.ToInt32(numthread.Value);
             //  parallelOptions.CancellationToken = cts.Token;
             int row = 0;
             Parallel.ForEach(ListEmail, parallelOptions, (string emailLine, ParallelLoopState state) =>
             {
                 if (isstop == true)
                 {
                     state.Break();
                 }
                 dtgrvdata.Invoke((MethodInvoker) delegate()
                 {
                     row = dtgrvdata.Rows.Add();
                 });
                 GetInfoFacebook(emailLine, row);
                 AppExtension.DataGridScroll(dtgrvdata);
                 Thread.Sleep(TimeSpan.FromSeconds(Convert.ToDouble(numsleep.Value)));
             });
             btnstart.Enabled = true;
             btnstop.Enabled  = false;
             lbstatus.Text    = "chạy xong !";
         }).Start();
     }
     catch
     { }
 }
 /// <summary>
 /// Get infomation facebook from email
 /// </summary>
 public void FaceBookInfomation()
 {
     try
     {
         RequestService requestService = new RequestService(this.Cookie, FacebookInfo.UserAgentGetcre);
         //RequestService requestService = new RequestService(FacebookInfo.UserAgentGetcre);
         string ResponsePageAdmin = requestService.RequestGet(FacebookInfo.FacebookAdminPage + IdPage + "&eav=" + fb_eav + "&q=" + Email + "&session_id=undefined&m_sess=&fb_dtsg_ag=" + fb_dtsg + "&jazoest=" + jazoest + "&__user="******"checkpoint/block/"))
         {
             this.FbName = "checkpoint";
             return;
         }
         if (ResponsePageAdmin.Contains("uid"))
         {
             this.ID     = Regex.Match(ResponsePageAdmin, "uid.*?(\\d+)").Groups[1].Value;
             this.FbName = Regex.Match(ResponsePageAdmin, "text\":\"(.*?)\",").Groups[1].Value;
             this.FbName = Regex.Unescape(this.FbName);
         }
         else
         {
             this.FbName = "not_id";   // Nguyen Dac Tai // Code đến bao giờ ???
             return;
         }
         if (isonlyuid == true)
         {
             this.CreatedDay   = "0";
             this.HomeTown     = "0";
             this.Friend_Count = "0";
             this.Follow_Count = "0";
             this.LatsOnline   = "0";
             this.BirthDay     = "0";
             return;
         }
         string FacebookInfoAccount = requestService.RequestGet(FacebookInfo.FacebookGraph + this.ID + "?access_token=" + this.Token);
         string FriendCount         = requestService.RequestGet(FacebookInfo.FacebookGraph + this.ID + FacebookInfo.FriendPath + this.Token);
         string FollowCount         = requestService.RequestGet(FacebookInfo.FacebookGraph + this.ID + FacebookInfo.FollowPath + this.Token);
         string LastOnlinerq        = requestService.RequestGet(FacebookInfo.FacebookGraph + this.ID + FacebookInfo.AlbumPath + this.Token + "&limit=1");
         string timestampcre        = FacebookDateCreated(ID, fb_dtsg);
         if (timestampcre == "error")
         {
             this.CreatedDay = "0";
         }
         else
         {
             this.CreatedDay = AppExtension.TimeStampConvert(Convert.ToInt32(timestampcre));
         }
         if (FacebookInfoAccount.Contains("birthday"))
         {
             this.BirthDay = JsonConvert(FacebookInfoAccount, "birthday");
         }
         else
         {
             this.BirthDay = "0";
         }
         if (FacebookInfoAccount.Contains("hometown"))
         {
             this.HomeTown = JObject.Parse(FacebookInfoAccount)["hometown"]["name"].ToString();
         }
         else
         {
             this.HomeTown = "private";
         }
         if (FriendCount.Contains("id"))
         {
             if (!FriendCount.Contains("sentry_block_data"))
             {
                 this.Friend_Count = JObject.Parse(FriendCount)["data"].Count().ToString();
             }
             else
             {
                 this.Friend_Count = "0";
             }
         }
         else
         {
             this.Friend_Count = "0";
         }
         if (LastOnlinerq.Contains("updated_time"))
         {
             this.LatsOnline = Regex.Match(LastOnlinerq, FacebookInfo.RegexLastOn).Groups[1].Value;
         }
         else
         {
             this.LatsOnline = "0";
         }
         this.Follow_Count = JObject.Parse(FollowCount)["summary"]["total_count"].ToString();
     }
     catch (Exception ex)
     {
         this.FbName = "error";
         app.ExportError(ex.Message);
         return;
     }
 }
        private void SetupData()
        {
            isSetupsucces = false;
            DateFormat    = DateTime.Now.ToString("dd-mm-yyy hh-mm");
            TempdataSave  = Application.StartupPath + "\\data\\temp\\" + "temp_fbdata_" + DateFormat + ".txt";
            string[] CookiesFile = File.ReadAllLines(txtcookiefile.Text);
            string   c*k         = "";

            foreach (string cookie in CookiesFile)
            {
                c*k = cookie;
                if (c*k.Contains("useragent="))
                {
                    c*k = Regex.Replace(cookie, "useragent=([a-zA-Z0-9]{100,300})", "");
                }
                Facebook facebook = new Facebook();
                facebook.Cookie = c*k;
                string FacebookIdentifyCodeStatus = facebook.FacebookIdentifyCode();
                if (FacebookIdentifyCodeStatus == "die" || FacebookIdentifyCodeStatus == "error")
                {
                    goto END_W;
                }
                string FacebookTokenStatus = "";
                if (cbbtypetoken.SelectedIndex != 1)
                {
                    FacebookTokenStatus = facebook.FacebookTokenNormal();
                }
                else
                {
                    FacebookTokenStatus = facebook.FacebookTokenBussine();
                }
                if (FacebookTokenStatus == "die" || FacebookTokenStatus == "error")
                {
                    goto END_W;
                }
                string FacebookIdPageStatus = facebook.FacebookPageid();
                if (FacebookIdPageStatus == "die" || FacebookIdPageStatus == "not_a_page" || FacebookIdPageStatus == "error")
                {
                    goto END_W;
                }
                foreach (string Idpage in facebook.Listidpage)
                {
                    string ContentSave = facebook.Token + DataSeperator + cookie + DataSeperator + Idpage + DataSeperator + facebook.fb_dtsg + DataSeperator + facebook.jazoest + DataSeperator + facebook.fb_av + DataSeperator + facebook.fb_eav;
                    File.AppendAllText(TempdataSave, ContentSave + "\r\n");
                }
                END_W :;
            }
            if (!File.Exists(TempdataSave))
            {
                isSetupsucces = false;
                AppExtension.MessageBoxShow("lỗi setup ! có thể toàn bộ cookie đã die hoặc không thể lấy data...", 3);
                return;
            }
            else
            {
                int CountData  = Convert.ToInt32(File.ReadAllLines(TempdataSave).Length);
                int CountEmail = Convert.ToInt32(File.ReadAllLines(txtemail.Text).Length);
                if (CountEmail >= 50)
                {
                    if (CountData <= 1)
                    {
                        isSetupsucces = false;
                        AppExtension.MessageBoxShow("dữ liệu facebook quá ít ! nhỏ hơn 1, nên không thể chạy ! vui lòng thêm cookie...", 3);
                        return;
                    }
                }
            }
            isSetupsucces = true;
            btnstart.PerformClick();
        }
 private void lbquesnumthread_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     AppExtension.MessageBoxShow(AppExtension.ShowFaq(2), 1);
 }
 private void lbquestimesleep_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     AppExtension.MessageBoxShow(AppExtension.ShowFaq(1), 1);
 }
        private void GetInfoFacebook(string emmail, int row)
        {
            string subemail = emmail;

            if (emmail.Contains(":"))
            {
                subemail = emmail.Split(':')[0].ToString();
            }
            int trycount   = 0;
            int trycountcp = 0;

            try
            {
startcheck:
                AppExtension appExtension = new AppExtension();
                string   datafromrandom = appExtension.RandomData(TempdataSave);
                string   Token          = datafromrandom.Split('|')[0].ToString();
                string   Cookie         = datafromrandom.Split('|')[1].ToString();
                string   Idpage         = datafromrandom.Split('|')[2].ToString();
                string   fb_dtg         = datafromrandom.Split('|')[3].ToString();
                string   jazoet         = datafromrandom.Split('|')[4].ToString();
                string   fb_av          = datafromrandom.Split('|')[5].ToString();
                string   fbeav          = datafromrandom.Split('|')[6].ToString();
                Facebook facebook       = new Facebook();
                if (onlyuid.Checked)
                {
                    facebook.isonlyuid = true;
                }
                facebook.Token    = Token;
                facebook.Cookie   = Cookie;
                facebook.IdPage   = Idpage;
                facebook.Email    = subemail;
                facebook.fb_dtsg  = fb_dtg;
                facebook.jazoest  = jazoet;
                facebook.Uidclone = fb_av;
                facebook.fb_eav   = fbeav;
                facebook.FaceBookInfomation();
                if (facebook.FbName == "not_id")
                {
                    SaveFile(PathError, emmail);
                    appExtension.LoadGrid(row, emmail, dtgrvdata);
                    FailCount += 1;
                    UpdateCount();
                }
                else if (facebook.FbName == "error")
                {
                    trycount += 1;
                    if (trycount >= 3)
                    {
                        SaveFile(PathError, emmail);
                        appExtension.LoadGrid(row, emmail, dtgrvdata);
                        FailCount += 1;
                        UpdateCount();
                        return;
                    }
                    goto startcheck;
                }
                else if (facebook.FbName == "checkpoint")
                {
                    try
                    {
                        trycountcp += 1;
                        if (trycountcp >= 3)
                        {
                            SaveFile(PathError, emmail);
                            appExtension.LoadGrid(row, emmail, dtgrvdata);
                            FailCount += 1;
                            UpdateCount();
                            SaveFile("checkpointcookie.txt", Cookie);
                            //File.AppendAllText("checkpointcookie.txt", Cookie + "\r\n");
                            return;
                        }
                        goto startcheck;
                    }
                    catch { }
                }
                else
                {
                    SaveFile(PathSuccess, emmail + DataSeperator + facebook.ID + DataSeperator + facebook.FbName + DataSeperator + facebook.BirthDay + DataSeperator + facebook.HomeTown + DataSeperator + facebook.Friend_Count + DataSeperator + facebook.Follow_Count + DataSeperator + facebook.CreatedDay + DataSeperator + facebook.LatsOnline);
                    appExtension.LoadGridSuccess(facebook, row, emmail, dtgrvdata);
                    successCount += 1;
                    UpdateCount();
                }
                CheckedCount += 1;
                UpdateCount();
            }
            catch { }
        }