Any programmer please help me to convert this vb6 code to PHP:
////////////////////
Option Explicit
Public dat1(1000) As String
Public awal1(1000) As String
Public awal2(1000) As String
Public Function DecToHexStr(ByVal inVal As Integer) As String
Dim s As String
s = Trim(Hex(inVal))
If Len(s) < 2 Then
s = "0" & s
End If
DecToHexStr = s
End Function
Function hashCode(Value)
Dim i As Integer
Const maxInt = 4294967295#
Const maxPostInt = 2147483647
Dim h As Currency
Dim div As Long
h = 0
For i = 1 To Len(Value)
h = h * 31 + Asc(Mid(Value, i, 1))
If (h > maxInt) Then
div = Int(h / (maxInt + 1))
h = h - (div * (maxInt + 1))
End If
Next i
If h > maxPostInt Then
h = h - maxInt - 1
End If
hashCode = h
End Function
Public Function SendUname(Username As String)
SendUname = HextoAscii("2 0 C8 0 D 0 0 0 " & DecToHexStr(101 + Len(Username)) & " 0 E 0 0 0 4 0 0 0 0 0 D 0 0 0 4 0 0 0 AE 0 C 0 0 0 4 0 0 0 AA 0 B 0 0 0 04 0 0 0 E 0 9 0 0 0 1 63 0 8 0 0 0 4 6A 32 6D 65 0 7 0 0 0 9 4A 32 4D 45 76 33 2E 30 35 0 5 0 0 0 " & DecToHexStr(Len(Username))) & Username & HextoAscii("0 3 0 0 0 2 1 31 0 2 0 0 0 1 2 0 1 0 0 0 2 0 1")
End Function
Public Function SendUnamee(uname As String)
SendUnamee = HextoAscii("02 00 C8 00 0A 00 00 00 " & DecToHexStr(Len(uname) + 172) & " 00 16 00 00 00 00 00 15 00 00 00 00 00 14 00 00 00 00 00 13 00 00 00 01 00 00 11 00 00 00 00 00 10 00 00 00 04 00 00 00 15 00 0F 00 00 00 05 65 6E 2D 55 53 00 0D 00 00 00 04 00 00 01 18 00 0C 00 00 00 04 00 00 00 EA 00 0B 00 00 00 04 00 00 00 0E 00 09 00 00 00 01 01 00 08 00 00 00 1D 6D 69 67 33 33 2F 34 2E 35 30 20 28 55 6E 6B 6E 6F 77 6E 29 20 6B 42 72 6F 77 73 65 72 00 07 00 00 00 0D 4A 32 4D 45 76 34 2E 35 30 2E 30 30 30 00 05 00 00 00 " & DecToHexStr(Len(uname)) & " " & Asciitohex(uname) & " 00 03 00 00 00 02 01 C2 00 02 00 00 00 01 02 00 01 00 00 00 02 00 01")
End Function
Public Function Kickuser(room As String, target As String) As String
Kickuser = HextoAscii("02 02 C2 00 0D 00 00 00 " & DecToHexStr(Len(target) + Len(room) + 12) & " 00 02 00 00 00 " & DecToHexStr(Len(target))) & target & HextoAscii("00 01 00 00 00 " & DecToHexStr(Len(room))) & room
End Function
Public Function KirimHashCode(password As String, code As String)
KirimHashCode = (HextoAscii("02 00 CA 00 02 00 00 00 0A 00 01 00 00 00 04 " & Left(Hex(hashCode(code & password)), 2) & " " & Mid(Hex(hashCode(code & password$)), 3, 2) & " " & Mid(Hex(hashCode(code & password)), 5, 2) & " " & Right(Hex(hashCode(code & password)), 2)))
End Function
===============================
Thanks in advance.
Help me to convert this vb6 code to PHP
Moderator: General Moderators
Re: Help me to convert this vb6 code to PHP
This appears to be a client side program. What does it do. Appears to be converting from one format to another. I would say that if it is handling say registration or log ins then a php version would be a re-write not a conversion