Advertisement
Borysel

Untitled

Jul 1st, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 6.14 KB | None | 0 0
  1. Imports System
  2. Imports System.IO
  3. Imports System.Net
  4. Imports System.Text
  5.  
  6. Public Class loginForm
  7.  
  8.     Public va_link As String = "http://lufava.hekko24.pl"
  9.     Public p_id As String
  10.     Public p_name As String
  11.     Public p_sname As String
  12.     Public p_code As String
  13.     Public p_rankstring As String
  14.     Public p_rank As String
  15.     Public p_thours As String
  16.     Public p_tflights As String
  17.     Public p_landing As String
  18.  
  19.  
  20.     Protected Overrides ReadOnly Property CreateParams() As CreateParams
  21.         Get
  22.             Dim cp As CreateParams = MyBase.CreateParams
  23.             cp.ExStyle = cp.ExStyle Or &H2000000
  24.             Return cp
  25.         End Get
  26.     End Property
  27.  
  28.     Public Function GenerateSessionId()
  29.  
  30.         Dim xCharArray() As Char = "0123456789".ToCharArray
  31.         Dim xNoArray() As Char = "0123456789".ToCharArray
  32.         Dim xGenerator As System.Random = New System.Random()
  33.         Dim xStr As String = String.Empty
  34.  
  35.         While xStr.Length < 16
  36.  
  37.             If xGenerator.Next(0, 2) = 0 Then
  38.                 xStr &= xCharArray(xGenerator.Next(0, xCharArray.Length))
  39.             Else
  40.                 xStr &= xNoArray(xGenerator.Next(0, xNoArray.Length))
  41.             End If
  42.  
  43.         End While
  44.  
  45.         Return xStr
  46.  
  47.     End Function
  48.  
  49.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  50.         My.Settings.sessionid = GenerateSessionId()
  51.         My.Settings.user = id_box.Text
  52.         If CheckBox1.Checked = True Then
  53.             My.Settings.autologin = True
  54.             My.Settings.password = pass_box.Text
  55.  
  56.         End If
  57.  
  58.         My.Settings.Save()
  59.  
  60.         Dim str As String = id_box.Text
  61.         Dim Res As String = Nothing
  62.         For Each c As Char In str
  63.             If IsNumeric(c) Then
  64.                 Res = Res & c
  65.             End If
  66.         Next
  67.  
  68.         Dim idBoxCorr As String = Res
  69.         Dim db_req As String = LoginToSystem(idBoxCorr, pass_box.Text)
  70.         If Not db_req = "AUTH_FAILED CODE 1" Then
  71.  
  72.             Dim dane As String() = db_req.Split(",")
  73.             p_name = dane(4)
  74.             p_sname = dane(5)
  75.             p_code = dane(1)
  76.             p_id = dane(0)
  77.             p_rank = dane(7)
  78.  
  79.             Dim db_pilot As String() = GetDB("getpilotcenterdata&dbid=" & p_id).split(",")
  80.             p_thours = db_pilot(0)
  81.             p_tflights = db_pilot(1)
  82.             p_landing = db_pilot(2)
  83.  
  84.             Form1.Button1.Enabled = True
  85.             Form1.Button2.Enabled = True
  86.             Form1.Button3.Enabled = True
  87.             Form1.Button4.Enabled = True
  88.             Form1.Button5.Enabled = True
  89.             Form1.Button6.Enabled = True
  90.             Form1.Button8.Enabled = True
  91.  
  92.             GetPlanes()
  93.  
  94.             Me.Hide()
  95.             Form1.Button1.BackColor = Color.FromArgb(255, 57, 59)
  96.             dashboard.Show()
  97.         Else
  98.             MsgBox("Your login credentials doesn't match!", vbCritical, "Login error!")
  99.  
  100.         End If
  101.     End Sub
  102.  
  103.     Function LoginToSystem(userid As String, userpass As String) As String
  104.         Try
  105.  
  106.             Dim strReq As String
  107.             Dim strData As String
  108.             Dim dataStream As Stream
  109.             Dim reader As StreamReader
  110.             Dim request As WebRequest
  111.             Dim response As WebResponse
  112.  
  113.             strReq = va_link & "/core/ABCrewCenter/borys.php?action=getlogin&userid=" & userid & "&password=" & userpass
  114.  
  115.             request = WebRequest.Create(strReq)
  116.             response = request.GetResponse()
  117.             dataStream = response.GetResponseStream()
  118.             reader = New StreamReader(dataStream)
  119.             strData = reader.ReadToEnd()
  120.             reader.Close()
  121.             response.Close()
  122.  
  123.             Return strData
  124.         Catch ex As Exception
  125.             Return "" & vbNewLine & ex.ToString()
  126.         End Try
  127.     End Function
  128.  
  129.     Function GetDB(dbevent As String)
  130.         Try
  131.  
  132.             Dim strReq As String
  133.             Dim strData As String
  134.             Dim dataStream As Stream
  135.             Dim reader As StreamReader
  136.             Dim request As WebRequest
  137.             Dim response As WebResponse
  138.  
  139.             strReq = va_link & "/core/ABCrewCenter/borys.php?action=" & dbevent
  140.  
  141.             request = WebRequest.Create(strReq)
  142.             response = request.GetResponse()
  143.             dataStream = response.GetResponseStream()
  144.             reader = New StreamReader(dataStream)
  145.             strData = reader.ReadToEnd()
  146.             reader.Close()
  147.             response.Close()
  148.  
  149.             Return strData
  150.         Catch ex As Exception
  151.             Return "" & vbNewLine & ex.ToString()
  152.         End Try
  153.         Return 0
  154.     End Function
  155.  
  156.     Private Sub loginForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  157.         CheckBox1.Checked = My.Settings.autologin
  158.         id_box.Text = My.Settings.user
  159.         pass_box.Text = My.Settings.password
  160.         id_box.Select()
  161.         If My.Settings.sessionid <> "" And My.Settings.user <> "" And My.Settings.password <> "" And CheckBox1.Checked Then
  162.             'LoginButton.Text = "Logging in..."
  163.             'Button1.PerformClick()
  164.         End If
  165.     End Sub
  166.  
  167.     Private Sub BackgroundWorker1_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
  168.  
  169.     End Sub
  170.  
  171.     Private Sub BackgroundWorker1_Completed(sender As System.Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
  172.  
  173.     End Sub
  174.  
  175.     Public samoloty As New ArrayList
  176.  
  177.     Function GetPlanes()
  178.         Dim db As String = GetDB("getaircraft")
  179.         Dim output As String() = db.Split(";")
  180.  
  181.         For n = 0 To output.GetUpperBound(0)
  182.             Dim output2 As String() = output(n).Split(",")
  183.  
  184.             samoloty.Add(New aircrafts)
  185.  
  186.             samoloty(n).id = output2(0)
  187.             samoloty(n).full = output2(1)
  188.             samoloty(n).icao = output2(2)
  189.             samoloty(n).reg = output2(3)
  190.             samoloty(n).pax = output2(4)
  191.             samoloty(n).cargo = output2(5)
  192.             samoloty(n).rank = output2(6)
  193.             Return "ok"
  194.         Next
  195.  
  196.         Return "error"
  197.     End Function
  198.  
  199. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement