C++ Mybb Login Code

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Banlı Üye
Katılım
1 Eki 2016
Mesajlar
1,521
Tepki puanı
334
Yaş
32
9 HİZMET YILI
  1. private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  2. //http://www.url.com/member.php?action=login
  3. if ((textBox1->Text->IsNullOrWhiteSpace(textBox1->Text)) && (textBox1->Text->IsNullOrWhiteSpace(textBox2->Text)))
  4. {
  5. MessageBox::Show("Please fill in your credentials!", "url - Loader", MessageBoxButtons::OK,
  6. MessageBoxIcon::Error);
  7. }
  8. else
  9. {
  10. HttpWebRequest^ httpWebRequest = nullptr;
  11. HttpWebResponse^ httpWebResponse = nullptr;
  12. Stream^ stream = nullptr;
  13. StreamReader^ streamReader = nullptr;
  14. array<Byte>^ postBytes = nullptr;
  15.  
  16. CookieContainer^ cookieContainer = gcnew CookieContainer();
  17. String^ sPostData = "username=" + textBox1->Text + "&password=" + textBox2->Text + "&remember=yes&submit=Login&action=do_login&url=http://url.com/member.php?action=login";
  18. String^ sFinalData = nullptr;
  19.  
  20. try
  21. {
  22. httpWebRequest = (HttpWebRequest^)WebRequest::Create("http://www.url.com/");
  23. httpWebRequest->Method = "POST";
  24. httpWebRequest->ContentType = "application/x-www-form-urlencoded";
  25. postBytes = Encoding::UTF8->GetBytes(sPostData);
  26. httpWebRequest->ContentLength = postBytes->Length;
  27. httpWebRequest->CookieContainer = cookieContainer;
  28.  
  29. stream = httpWebRequest->GetRequestStream();
  30. stream->Write(postBytes, 0, postBytes->Length);
  31. stream->Close();
  32. stream = nullptr;
  33.  
  34. httpWebResponse = (HttpWebResponse^)httpWebRequest->GetResponse();
  35. streamReader = gcnew StreamReader(httpWebResponse->GetResponseStream(), Encoding::ASCII);
  36.  
  37. sFinalData = streamReader->ReadToEnd();
  38.  
  39. if (sFinalData->Contains("member.php?action=logout"))
  40. {
  41. MessageBox::Show("Login successful!", "", MessageBoxButtons::OK,
  42. MessageBoxIcon::Information);
  43. }
  44. else
  45. {
  46. MessageBox::Show("Login unsuccessful! Please check your credentials!", "", MessageBoxButtons::OK,
  47. MessageBoxIcon::Error);
  48. }
  49. }
  50. catch (Exception^ exception)
  51. {
  52.  
  53. }
  54. }
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst