Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Net
- Imports System.IO
- Imports System.Text
- Imports System.Text.RegularExpressions
- Public Class Form1
- #Region "ServerConfig"
- Dim ServerIP As String = "192.168.1.44"
- Dim ClientExe As String = "Phoenix.exe"
- Dim Login As String = "http://192.168.1.44/Login/"
- Dim Homepage As String = "http://fiesta.pephix.square7.net/"
- Dim Register As String = "http://fiesta.pephix.square7.net/"
- Dim cpx, cpy As Int32
- Friend WithEvents Downloader As New Net.WebClient
- Dim wc As New WebClient
- Dim Encrypt As New Encrypt
- Dim ClientConfig As String() = Nothing
- Dim PatchList As String() = Nothing
- #End Region
- Private Sub Download()
- If SV.Text = CV.Text Then
- PBLaunch.Enabled = True
- StatusLabel.Text = "Client has been updated."
- PPLabel.Hide()
- ElseIf Val(CV.Text) > Val(SV.Text) Then
- MessageBox.Show("An Error occured. The Launcher will restart now.", "Error 1 - Client Overpatched", MessageBoxButtons.OK, MessageBoxIcon.Error)
- Directory.Delete("Launcher", True)
- Application.Restart()
- Else
- StatusLabel.Text = "Downloading Patch " & Val(CV.Text) + Val(1) & "..."
- ProgressBar.Value = 0
- Downloader.DownloadFileAsync(New Uri(PatchList(Val(CV.Text) + Val(1)).Split(vbTab)(1)), "Patch.rar")
- End If
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- 'If File.Exists("Updater.exe") Then
- ' File.Delete("Updater.exe")
- 'End If
- 'If Downloader.DownloadString("http://192.168.1.44:1234/login/version.txt") <> FileVersionInfo.GetVersionInfo(Application.ExecutablePath).FileVersion Then
- ' My.Computer.Network.DownloadFile("http://192.168.1.44:1234/login/Updater.exe", "Updater.exe")
- ' Process.Start("Updater.exe")
- ' Application.Exit()
- ' End
- 'End If
- If Not File.Exists("UnRAR.exe") Then
- My.Computer.Network.DownloadFile(Login & "UnRAR.exe", "UnRAR.exe")
- End If
- If Not File.Exists("Launcher/information.info") Then
- Directory.CreateDirectory("Launcher")
- File.WriteAllText("Launcher/information.info", Encrypt.Encrypt("Version=0"))
- End If
- TBUser.Select()
- ClientConfig = IO.File.ReadAllLines("Launcher/information.info")
- ClientConfig(0) = Encrypt.Decrypt(ClientConfig(0))
- PatchList = wc.DownloadString(Login & "patch_list.txt").Split(vbNewLine)
- CV.Text = ClientConfig(0).Split("=")(1)
- SV.Text = Encrypt.CountPatches(Login & "patch_list.txt")
- Download()
- End Sub
- Private Sub Downloader_Completed(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles Downloader.DownloadFileCompleted
- StatusLabel.Text = "Extracting Patch " & CV.Text & "..."
- CV.Text = Val(CV.Text) + Val(1)
- Dim Process As Process
- Dim ProcessStartInfo As New ProcessStartInfo
- Me.Refresh()
- ProcessStartInfo.FileName = "UnRAR.exe"
- ProcessStartInfo.Arguments = "x -y -ac Patch.rar"
- ProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden
- Process = Process.Start(ProcessStartInfo)
- Process.WaitForExit()
- File.Delete("Patch.rar")
- IO.File.WriteAllText("Launcher/information.info", Encrypt.Encrypt("ClientVersion=" & CV.Text))
- Download()
- End Sub
- Private Sub Downloader_Progress(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles Downloader.DownloadProgressChanged
- PBProgressFill.Width = PBProgressEmpty.Width * ProgressBar.Value / 100
- PPLabel.Text = e.ProgressPercentage & "%"
- ProgressBar.Value = e.ProgressPercentage
- End Sub
- Private Sub Form1_FormClosed(sender As System.Object, e As System.EventArgs) Handles MyBase.Closed
- NotifyIcon1.Visible = False
- NotifyIcon1.Dispose()
- NotifyIcon1 = Nothing
- End Sub
- Private Sub PBLaunch_Click(sender As System.Object, e As System.EventArgs) Handles PBLaunch.Click
- Dim MD5Pass As String = Encrypt.MD5StringHash(TBPass.Text)
- Dim wc As WebClient = New WebClient()
- Dim Log As String = wc.DownloadString(Login & "Login.php?Username=" & TBUser.Text & "&Password=" & MD5Pass.ToLower())
- If Log.Contains("OK") Then
- Process.Start(ClientExe, "-osk_server " & ServerIP & " -osk_token " & Log.Split("#")(1) & " -osk_store " & Homepage)
- Application.Exit()
- Else
- MessageBox.Show("Wrong Username or Password. Please try again.", "Login Error 1 - Wrong Credentials", MessageBoxButtons.OK, MessageBoxIcon.Error)
- End If
- End Sub
- #Region "Button Müll"
- Private Sub PBRegister_Click(sender As System.Object, e As System.EventArgs) Handles PBRegister.Click
- Process.Start(Register)
- End Sub
- Private Sub PBHomepage_Click(sender As System.Object, e As System.EventArgs) Handles PBHomepage.Click
- Process.Start(Homepage)
- End Sub
- Private Sub PBExit_Click(sender As System.Object, e As System.EventArgs) Handles PBExit.Click
- Application.Exit()
- End Sub
- Private Sub PBPatch_Click(sender As System.Object, e As System.EventArgs) Handles PBPatch.Click
- Directory.Delete("Launcher", True)
- Application.Restart()
- End Sub
- #End Region
- #Region "Button Hover"
- Private Sub PBLaunch_Hover(sender As System.Object, e As System.EventArgs) Handles PBLaunch.MouseHover
- PBLaunch.Image = My.Resources.PephixStartMouse
- End Sub
- Private Sub PBLaunch_Leave(sender As System.Object, e As System.EventArgs) Handles PBLaunch.MouseLeave
- PBLaunch.Image = My.Resources.PephixStart
- End Sub
- Private Sub PBRegister_Hover(sender As System.Object, e As System.EventArgs) Handles PBRegister.MouseHover
- PBRegister.Image = My.Resources.PephixRegisterMouse
- End Sub
- Private Sub PBRegister_Leave(sender As System.Object, e As System.EventArgs) Handles PBRegister.MouseLeave
- PBRegister.Image = My.Resources.PephixRegister
- End Sub
- Private Sub PBHomepage_Hover(sender As System.Object, e As System.EventArgs) Handles PBHomepage.MouseHover
- PBHomepage.Image = My.Resources.PephixHomeMouse1
- End Sub
- Private Sub PBHomepage_Leave(sender As System.Object, e As System.EventArgs) Handles PBHomepage.MouseLeave
- PBHomepage.Image = My.Resources.PephixHome1
- End Sub
- Private Sub PBPatch_Hover(sender As System.Object, e As System.EventArgs) Handles PBPatch.MouseHover
- PBPatch.Image = My.Resources.PephixPatchMouse
- End Sub
- Private Sub PBPatch_Leave(sender As System.Object, e As System.EventArgs) Handles PBPatch.MouseLeave
- PBPatch.Image = My.Resources.PephixPatch
- End Sub
- Private Sub PBExit_Hover(sender As System.Object, e As System.EventArgs) Handles PBExit.MouseHover
- PBExit.Image = My.Resources.PephixExitMouse
- End Sub
- Private Sub PBExit_Leave(sender As System.Object, e As System.EventArgs) Handles PBExit.MouseLeave
- PBExit.Image = My.Resources.PephixExit
- End Sub
- #End Region
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement