Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Xml.Serialization;
- using System.IO;
- using System.Net;
- namespace APID_TOOL_Manager
- {
- public partial class Login : Form
- {
- public Login()
- {
- InitializeComponent();
- var app_dir = Path.GetDirectoryName(Application.ExecutablePath);
- Gecko.Xpcom.Initialize(Path.Combine(app_dir, "xulrunner"));
- }
- private void Login_Load(object sender, EventArgs e)
- {
- }
- private void btnLogin_Click(object sender, EventArgs e)
- {
- SubmitData();
- }
- public virtual CookieContainer CookieContainer { get; set; }
- public void SubmitData()
- {
- try
- {
- string apiUser = "phpcode";
- string apiPass = "29012901";
- ASCIIEncoding encoding = new ASCIIEncoding();
- string postData = "user=" + apiUser + "&pass=" + apiPass;
- byte[] data = encoding.GetBytes(postData);
- WebRequest webRequest = WebRequest.Create("http://newapidtool.riek-media.com/index.php");
- HttpWebRequest request = (HttpWebRequest)webRequest;
- CookieContainer cookieContainer = new CookieContainer();
- request.CookieContainer = cookieContainer;
- request.Method = "POST";
- request.ContentType = "application/x-www-form-urlencoded";
- request.ContentLength = data.Length;
- Stream stream = request.GetRequestStream();
- stream.Write(data, 0, data.Length);
- stream.Close();
- WebResponse response = request.GetResponse();
- stream = response.GetResponseStream();
- StreamReader sr = new StreamReader(stream);
- if (sr.ReadToEnd() == "true")
- {
- Dashboard dashboard = new Dashboard();
- // Wir weisen unserer Form2 die Variable zu
- dashboard.apiUser = apiUser;
- dashboard.apiPass = apiPass;
- dashboard.Show();
- Hide();
- }
- else
- {
- MessageBox.Show("Deine Logindaten waren fehlerhaft. Sollte der Fehler weiterhin auftreten, setze dich mit der IT-Apteilung in Verbindung.",
- "Login Error!",
- MessageBoxButtons.OK,
- MessageBoxIcon.Warning // for Warning
- //MessageBoxIcon.Error // for Error
- //MessageBoxIcon.Information // for Information
- //MessageBoxIcon.Question // for Question
- );
- }
- sr.Close();
- stream.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error : " + ex.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement