Imports System.Security.Cryptography
Imports System.Net
Imports System.Net.WebException
Imports System
Imports System.IO
Imports System.Text
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Net.Sockets
Imports System.Threading
Public Class Form1
    Dim meuser As String
    Dim ipshow As New Net.WebClient()
    Dim ipadress As String
    Dim mestatus As String
    Dim Checking As New Net.WebClient
    Dim serverip As String
    Dim settingsfile As String
    Dim connectallow As String
    Dim newsforecolor As String
    Dim newsbackcolor As String
    Dim exename As String
    Dim usefilesec As String
    Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, _
      ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Dim cpx, cpy As Int32
    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As  _
    System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        cpx = e.X
        cpy = e.Y
    End Sub
    Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As  _
    System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
            Me.Top = Windows.Forms.Cursor.Position.Y() - cpy
            Me.Left = Windows.Forms.Cursor.Position.X() - cpx
        End If
    End Sub
    Public WithEvents downloader As WebClient
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub
    WithEvents NetworkString As NetworkStringConnection
    Public Shared Function GetMD5Hash(ByVal TextToHash As String) As String
        If TextToHash = "" Or TextToHash.Length = 0 Then
            Return String.Empty
        End If
        Dim md5 As MD5 = New MD5CryptoServiceProvider()
        Dim toHash As Byte() = Encoding.Default.GetBytes(TextToHash)
        Dim result As Byte() = md5.ComputeHash(toHash)
        Return System.BitConverter.ToString(result)
    End Function
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label21.Hide()
        NetworkString = New NetworkStringConnection
        GoTo program
program:
                    mbof.Hide()
                    mb.Hide()
                    Label21.Hide()
                    Me.Show()
                    Me.Refresh()
                    downloader = New WebClient
                    If Not File.Exists("UnRAR.exe") Then
            My.Computer.Network.DownloadFile("http://DeineHomepage/Download/UnRAR.exe", "UnRAR.exe")
                    End If
        PictureBox3.Enabled = False
                    Label13.Hide()
                    Label3.Hide()
                    Dim filelenght2
                    FileOpen(2, "Dump/your.txt", OpenMode.Input)
                    filelenght2 = LOF(2)
                    Label7.Text = InputString(2, filelenght2)
                    FileClose(2)
        If My.Computer.FileSystem.FileExists("Dump/need.txt") Then
            My.Computer.FileSystem.DeleteFile("Dump/need.txt")
        End If
        My.Computer.Network.DownloadFile("http://DeineHomepage/Download/need.txt", "Dump/need.txt")
                    Dim filelenght3
                    FileOpen(3, "Dump/need.txt", OpenMode.Input)
                    filelenght3 = LOF(3)
                    Label5.Text = InputString(3, filelenght3)
                    FileClose(3)
                    If Label7.Text = Label5.Text Then
            PictureBox3.Enabled = True
                        Label11.Text = "Keinen neuen Updates!"
                        Label9.Text = ""
                        ProgressBar1.Hide()
                        Label12.Hide()
                        Me.Refresh()
                    Else
                        ProgressBar1.Value = 0
                        Label9.Text = Label7.Text + Val("1")
            downloader.DownloadFileAsync(New Uri("http://DeineHomepage/Download/data/" + "00" + Label9.Text + ".rar"), "00" + Label9.Text + ".rar")
                    End If
    End Sub
    Private Sub downloader_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles downloader.DownloadFileCompleted
        On Error Resume Next
        Label9.Show()
        mbof.Hide()
        mb.Hide()
        Me.Refresh()
        Dim oProcess As Process
        oProcess = System.Diagnostics.Process.Start("UnRAR.exe", "x -y -ac " + "00" + Label9.Text + ".rar")
        oProcess.WaitForExit()
        File.Delete("00" + Label9.Text + ".rar")
        Label11.Text = "Getting Patch:"
        Label9.Text = Val(Label9.Text) + Val("1")
        Label7.Text = Val(Label7.Text) + Val("1")
        File.WriteAllText("Dump\your.txt", Label7.Text)
        If Label5.Text = Label7.Text Then
            PictureBox3.Enabled = True
            Label11.Text = "No new Updates!"
            Label9.Text = ""
            Label12.Hide()
            Me.Refresh()
        End If
        If Not Label5.Text = Label7.Text Then
            ProgressBar1.Value = 0
            downloader.DownloadFileAsync(New Uri("http://DeineHomepage/Download/data/" + "00" + Label9.Text + ".rar"), "00" + Label9.Text + ".rar")
        End If
    End Sub
    Private Sub downloader_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles downloader.DownloadProgressChanged
        Label12.Text = e.ProgressPercentage & "%"
        Timer1.Start()
        ProgressBar1.Value = e.ProgressPercentage
        If Label12.Text = "100%" Then
            ProgressBar1.Value = 100
        End If
    End Sub
    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Application.Exit()
    End Sub
    Private Sub PictureBox3_Click(sender As Object, e As EventArgs)
        Label3.Text = ""
        Dim tempPassToken As String() = GetMD5Hash(TextBox2.Text).Split("-")

        Dim passMD5 As String = ""

        For i = 0 To tempPassToken.Length - 1
            passMD5 = passMD5 & tempPassToken(i)
        Next

        Dim wc As WebClient = New WebClient()

        Dim Login As String() = wc.DownloadString("http://DeineHomepage/Download/Login.php?Username=" & TextBox1.Text & "&Password=" & passMD5.ToLower()).Split("#")
        wc.Dispose()

        If Login(0) = "OK" Then
            Process.Start("Odin.exe", "-osk_server IPvonDeinemServer -osk_token " & Login(1) & " -osk_store www.google.de")

            Me.Close()
        Else
            Label8.Text = "Please check your password!"
        End If
    End Sub
    Private Sub PictureBox5_Click(sender As Object, e As EventArgs)
        Process.Start("iexplorer.exe", "http://DeineHomepage.de/")
    End Sub
    Private Sub PictureBox4_Click(sender As Object, e As EventArgs)
        Process.Start("iexplorer.exe", "http://DeineHomepage.de/")
    End Sub
    Private Sub Label1_Click(sender As Object, e As EventArgs)
    End Sub

    Private Sub Label5_Click(sender As System.Object, e As System.EventArgs) Handles Label5.Click

    End Sub

    Private Sub news_Click(sender As System.Object, e As System.EventArgs) Handles news.Click

    End Sub

    Private Sub Label15_Click(sender As System.Object, e As System.EventArgs) Handles Label15.Click

    End Sub
    Private Sub PictureBox7_Click(sender As System.Object, e As System.EventArgs)
        regi.Show()
    End Sub

    Private Sub PictureBox4_Click_1(sender As System.Object, e As System.EventArgs) Handles PictureBox4.Click
        Process.Start("http://ForumLink/")
    End Sub

    Private Sub PictureBox7_Click_1(sender As System.Object, e As System.EventArgs) Handles PictureBox7.Click
        regi.Show()
    End Sub

    Private Sub PictureBox6_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox6.Click
        Process.Start("http://DeineHomepage.de")
    End Sub

    Private Sub PictureBox2_Click_2(sender As System.Object, e As System.EventArgs) Handles PictureBox2.Click
        Process.Start("http://DeineHomepage/top.php")
    End Sub

    Private Sub PictureBox8_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox8.Click
        Me.Close()
    End Sub

    Private Sub PictureBox3_Click_1(sender As System.Object, e As System.EventArgs) Handles PictureBox3.Click
        Label3.Text = ""
        Dim tempPassToken As String() = GetMD5Hash(TextBox2.Text).Split("-")

        Dim passMD5 As String = ""

        For i = 0 To tempPassToken.Length - 1
            passMD5 = passMD5 & tempPassToken(i)
        Next

        Dim wc As WebClient = New WebClient()

        Dim Login As String() = wc.DownloadString("http://DeineHomepage/Download/Login.php?Username=" & TextBox1.Text & "&Password=" & passMD5.ToLower()).Split("#")
        wc.Dispose()

        If Login(0) = "OK" Then
            Process.Start("Odin.exe", "-osk_server IPvonDeinemServer -osk_token " & Login(1) & " -osk_store www.google.de")

            Me.Close()
        Else
            Label8.Text = "Please check your password!"
        End If
    End Sub
End Class
