Guest User

Untitled

a guest
Dec 5th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.85 KB | None | 0 0
  1. Imports System.Collections.Specialized, System.Net, System.Text, System.Security.Cryptography, System.IO
  2. 'VXS Funktions
  3. Public Class Serverpending
  4.    Dim values As New NameValueCollection
  5.    Dim client As New WebClient
  6.    Dim networkconnection As Boolean = False
  7.    Dim VXSTEAMSERVER As String = My.Settings.mainserver
  8.    Public Confignames As String = (CurDir() & "\temp\act.vxs")
  9.    Public Confignames2 As String = (CurDir() & "\temp\req.vxs")
  10.    Sub checknetwork()
  11.        If My.Computer.Network.IsAvailable = True Then
  12.            networkconnection = True
  13.        Else
  14.            networkconnection = False
  15.        End If
  16.    End Sub
  17.    Sub login(ByVal username As String, ByVal userpassword As String)
  18.        If networkconnection = True Then
  19.            Serverbusy = True
  20.            Try
  21.                values.Clear()
  22.                values.Add("u", username)
  23.                values.Add("pw", MD5StringHash(userpassword))
  24.                Dim result() As Byte = client.UploadValues(VXSTEAMSERVER & "_login.php?", "POST", values)
  25.                Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result)   '0=true
  26.                 If resultstring.Contains("login=0") = True Then '1=false
  27.                    Try
  28.                        values.Clear()
  29.                        values.Add("u", username)
  30.                        values.Add("on", "1")
  31.                        Dim onli() As Byte = client.UploadValues(VXSTEAMSERVER & "_oncheck.php?", "POST", values)
  32.                        Dim onlistring As String = System.Text.Encoding.ASCII.GetString(result)   '0=true
  33.                         Dim id() As String = onlistring.Split("/")
  34.                         useridlog = id(0)
  35.                     Catch b As Exception
  36.                         MsgBox("Timeout to server while trying set your online status.", MsgBoxStyle.OkOnly, "Error 100")
  37.                     End Try
  38.  
  39.                     loginfinal = True
  40.                 ElseIf resultstring.Contains("login=1") = True Then
  41.                     MsgBox("Incorrect Login! Check your login and try again.", MsgBoxStyle.OkOnly, "Error 200")
  42.                 End If 'Connection Error?
  43.            Catch e As Exception
  44.                MsgBox("Server is not online or have trouble to handle your request. Try again later!", MsgBoxStyle.OkOnly, "Error 101")
  45.            End Try
  46.            Serverbusy = False
  47.        Else
  48.            MsgBox("There are a problem with your connection. Check your connection and try again", MsgBoxStyle.OkOnly, "Error 201")
  49.        End If
  50.    End Sub
  51.    Public Function MD5StringHash(ByVal strString As String) As String
  52.        Dim MD5 As New MD5CryptoServiceProvider
  53.        Dim Data As Byte()
  54.        Dim Result As Byte()
  55.        Dim Res As String = ""
  56.        Dim Tmp As String = ""
  57.        Data = Encoding.ASCII.GetBytes(strString)
  58.        Result = MD5.ComputeHash(Data)
  59.        For i As Integer = 0 To Result.Length - 1
  60.            Tmp = Hex(Result(i))
  61.            If Len(Tmp) = 1 Then Tmp = "0" & Tmp
  62.            Res += Tmp
  63.        Next
  64.        Return Res
  65.    End Function
  66.    Sub signup(ByVal username As String, ByVal password As String, ByVal email As String)
  67.        If networkconnection = True Then
  68.            Try
  69.                Serverbusy = True
  70.                values.Clear()
  71.                values.Add("u", username)
  72.                values.Add("pw", MD5StringHash(password))
  73.                values.Add("e", email)
  74.                values.Add("o", "1")
  75.                Dim result() As Byte = client.UploadValues(VXSTEAMSERVER & "_register.php?", "POST", values)
  76.                Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result)
  77.                If resultstring.Contains("Account created") = True Then
  78.                    MsgBox("Your account: " & username & vbCrLf & "Your Password: " & password)
  79.                    final = True
  80.                ElseIf resultstring.Contains("There is already an account to your IP") = True Then
  81.                    MsgBox("There is already an account to your IP! Contact Forum for more Infos.", MsgBoxStyle.OkOnly, "Error 202")
  82.                End If
  83.            Catch koko As Exception
  84.                MsgBox("Server is not online or have trouble to handle your request. Try again later!", MsgBoxStyle.OkOnly, "Error 101")
  85.            End Try
  86.            Serverbusy = False
  87.        Else
  88.            MsgBox("There are a problem with your connection. Check your connection and try again", MsgBoxStyle.OkOnly, "Error 201")
  89.        End If
  90.    End Sub
  91.    Sub checkusername(ByVal username As String)
  92.        If networkconnection = True Then
  93.            Try
  94.                Serverbusy = True
  95.                values.Clear()
  96.                values.Add("u", username)
  97.                values.Add("o", "0")
  98.                Dim result() As Byte = client.UploadValues(VXSTEAMSERVER & "_register.php?", "POST", values)
  99.                Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result) '1+ / 0-
  100.                 If resultstring.Contains("username=1") = True Then
  101.                     user = "1"
  102.                 ElseIf resultstring.Contains("username=0") = True Then
  103.                     user = "0"
  104.                 End If
  105.             Catch ea As Exception
  106.                 MsgBox("Server is not online or have trouble to handle your request. Try again later!", MsgBoxStyle.OkOnly, "Error 101")
  107.             End Try
  108.             Serverbusy = False
  109.         Else
  110.             MsgBox("There are a problem with your connection. Check your connection and try again", MsgBoxStyle.OkOnly, "Error 201")
  111.         End If
  112.     End Sub
  113.     Sub playnewgame(ByVal gamename As String, ByVal gameid As String, ByVal user As String)
  114.         If networkconnection = True Then
  115.             Try
  116.                 Serverbusy = True
  117.                 values.Clear()
  118.                 values.Add("u", user)
  119.                 values.Add("id", gameid)
  120.                 values.Add("game", gamename)
  121.                 client.UploadValues(VXSTEAMSERVER & "_game.php?", "POST", values)
  122.             Catch b As Exception
  123.             End Try
  124.             Serverbusy = False
  125.         End If
  126.     End Sub
  127.     Sub buddyrefresh(ByVal user As String)
  128.         Try
  129.             Serverbusy = True
  130.             values.Clear()
  131.             values.Add("u", user)
  132.             Dim getbu() As Byte = client.UploadValues(VXSTEAMSERVER & "/_buddylist.php?", "POST", values)
  133.             Dim onoff As String = System.Text.Encoding.ASCII.GetString(getbu)
  134.             If IO.File.Exists(Confignames) = True Then
  135.                 Dim myWriter As New IO.StreamWriter(Confignames)
  136.                 myWriter.Flush()
  137.                 myWriter.Write(onoff.Replace("#", vbCrLf))
  138.                 myWriter.Close()
  139.             Else
  140.                 IO.File.Create(Confignames)
  141.                 Dim myWriter As New IO.StreamWriter(Confignames)
  142.                 myWriter.Flush()
  143.                 myWriter.Write(onoff.Replace("#", vbCrLf))
  144.                 myWriter.Close()
  145.             End If
  146.  
  147.         Catch b As Exception
  148.         End Try
  149.         Serverbusy = False
  150.     End Sub
  151.     Sub addbuddy(ByVal buddy As String, ByVal user As String)
  152.         Try
  153.             Serverbusy = True
  154.             values.Clear()
  155.             values.Add("u", buddy)
  156.             values.Add("o", "0")
  157.             Dim result() As Byte = client.UploadValues(VXSTEAMSERVER & "_register.php?", "POST", values)
  158.             Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result) '1+ / 0-
  159.            If resultstring.Contains("username=0") = True Then
  160.                values.Clear()
  161.                values.Add("b", buddy)
  162.                values.Add("u", user)
  163.                values.Add("r", "1")
  164.                Dim aresult() As Byte = client.UploadValues(VXSTEAMSERVER & "_buddyrequestout.php?", "POST", values)
  165.                Dim resultstringb As String = System.Text.Encoding.ASCII.GetString(aresult)
  166.                If resultstringb.Contains("ok") Then
  167.                    MsgBox("A friendrequest was sendet to " & buddy & "!", MsgBoxStyle.OkOnly, "OK!")
  168.                    newbud = True
  169.                ElseIf resultstringb.Contains("3") Then
  170.                    MsgBox(buddy & " ignores you!", MsgBoxStyle.OkOnly, "OK!")
  171.                End If
  172.  
  173.            ElseIf resultstring.Contains("username=1") = True Then
  174.                MsgBox(buddy & " was not found!", MsgBoxStyle.OkOnly, "Fail!")
  175.            End If
  176.        Catch ea As Exception
  177.            MsgBox("Server is not online or have trouble to handle your request. Try again later!", MsgBoxStyle.OkOnly, "Error 101")
  178.        End Try
  179.        Serverbusy = False
  180.    End Sub
  181.    Sub logout(ByVal user As String)
  182.        Try
  183.            Serverbusy = True
  184.            values.Clear()
  185.            values.Add("u", user)
  186.            values.Add("on", "0")
  187.            Dim onli() As Byte = client.UploadValues(VXSTEAMSERVER & "_oncheck.php?", "POST", values)
  188.        Catch b As Exception
  189.            MsgBox("Timeout to server while trying set your online status.", MsgBoxStyle.OkOnly, "Error 100")
  190.        End Try
  191.        Serverbusy = False
  192.    End Sub
  193.    Sub msg(ByVal fromusr As String, ByVal tousr As String, ByVal message As String, ByVal prop As String)
  194.        If networkconnection = True Then
  195.            Serverbusy = True
  196.            values.Clear()
  197.            values.Add("from", fromusr)
  198.            values.Add("to", tousr)
  199.            values.Add("msg", message)
  200.            values.Add("o", prop)
  201.            Try
  202.                Dim result() As Byte = client.UploadValues(VXSTEAMSERVER & "_messenger.php?", "POST", values)
  203.                Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result) '1+ / 0-
  204.                 MsgBox(resultstring)
  205.             Catch ea As Exception
  206.                 MsgBox("Server is not online or have trouble to handle your request. Try again later!", MsgBoxStyle.OkOnly, "Error 101")
  207.             End Try
  208.             Serverbusy = False
  209.         Else
  210.             MsgBox("There are a problem with your connection. Check your connection and try again", MsgBoxStyle.OkOnly, "Error 201")
  211.         End If
  212.     End Sub
  213.     Sub anothermsg(ByVal buddy As String)
  214.         If networkconnection = True Then
  215.             Serverbusy = True
  216.             values.Add("bud", buddy)
  217.             Try
  218.                 Dim result() As Byte = client.UploadValues(VXSTEAMSERVER & "_chat.php?", "POST", values)
  219.                 Dim resultstring As String = System.Text.Encoding.ASCII.GetString(result) '1+ / 0-
  220.                ipvia = resultstring
  221.            Catch ea As Exception
  222.                MsgBox("Server is not online or have trouble to handle your request. Try again later!", MsgBoxStyle.OkOnly, "Error 101")
  223.            End Try
  224.            Serverbusy = False
  225.        Else
  226.            MsgBox("There are a problem with your connection. Check your connection and try again", MsgBoxStyle.OkOnly, "Error 201")
  227.        End If
  228.    End Sub
  229.    Sub getusrpic(ByVal buddy As String)
  230.        Try
  231.            Dim ImageInBytes() As Byte = client.DownloadData(VXSTEAMSERVER & "avatar/" & buddy & ".jpg")
  232.            Dim ImageStream As New IO.MemoryStream(ImageInBytes)
  233.            usrpic = New System.Drawing.Bitmap(ImageStream)
  234.        Catch f As Exception
  235.        End Try
  236.    End Sub '/avatar/ on root, jpg files 75x75 px! or use stretch in usrpicbox.pro
  237.     Sub newuserpic(ByVal pic As Drawing.Image)
  238.      
  239.     End Sub
  240.     Sub getrequests(ByVal user As String)
  241.         Try
  242.             Serverbusy = True
  243.             values.Clear()
  244.             values.Add("u", user)
  245.             Dim getbu() As Byte = client.UploadValues(VXSTEAMSERVER & "/_buddyrequestin.php?", "POST", values)
  246.             Dim onoff As String = System.Text.Encoding.ASCII.GetString(getbu)
  247.             MsgBox(onoff)
  248.             If IO.File.Exists(Confignames2) = True Then
  249.                 Dim myWriter As New IO.StreamWriter(Confignames2)
  250.                 myWriter.Flush()
  251.                 myWriter.Write(onoff.Replace("#", vbCrLf))
  252.                 myWriter.Close()
  253.             Else
  254.                 IO.File.Create(Confignames2)
  255.                 Dim myWriter As New IO.StreamWriter(Confignames2)
  256.                 myWriter.Flush()
  257.                 myWriter.Write(onoff.Replace("#", vbCrLf))
  258.                 myWriter.Close()
  259.             End If
  260.         Catch b As Exception
  261.         End Try
  262.         Serverbusy = False
  263.     End Sub
  264.     Property newbud As Boolean = False
  265.     Property game As String
  266.     Property gameidc As String
  267.     Property online As Boolean
  268.     Property user As String
  269.     Property userid As String
  270.     Property loginfinal As Boolean = False
  271.     Property final As Boolean = False
  272.     Property Serverbusy As Boolean = False
  273.     Property useridlog As String
  274.     '--------For TCP Chat only!-----------
  275.    Property ipvia As String
  276.    '--------End of TCP-------
  277.     Property usrpic As Drawing.Image
  278.     Property buddys As String
  279. End Class       'Serverresponse Handler
Add Comment
Please, Sign In to add comment