Advertisement
Guest User

Untitled

a guest
May 27th, 2015
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. Imports System.Net
  2. Imports System.IO
  3. Imports System.Text
  4. Module Module1
  5. Function Token() As String
  6. Dim tokenid As New WebClient
  7. Return tokenid.DownloadString("http://192.168.2.7/tokengenerator.php")
  8. End Function
  9. End Module
  10. Public Class Form1
  11. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  12. TextBox1.Text = Token()
  13. RichTextBox2.Hide()
  14. Dim postData = "token=" & TextBox1.Text
  15. Dim request As WebRequest = WebRequest.Create("http://192.168.2.7/create.php")
  16. request.Method = "POST"
  17. Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
  18. request.ContentType = "application/x-www-form-urlencoded"
  19. request.ContentLength = byteArray.Length
  20. Dim dataStream As Stream = request.GetRequestStream()
  21. dataStream.Write(byteArray, 0, byteArray.Length)
  22. dataStream.Close()
  23. Timer1.Start()
  24. If My.Settings.username = ("") Then
  25. Else
  26. TextBox3.Text = My.Settings.username
  27. End If
  28. End Sub
  29.  
  30. Private Sub Button1_Click(sender As Object, e As EventArgs)
  31. End Sub
  32.  
  33. Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
  34. Clipboard.SetText(TextBox1.Text)
  35. End Sub
  36.  
  37. Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
  38.  
  39. End Sub
  40.  
  41. Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
  42.  
  43. End Sub
  44. Private Sub Form1_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
  45. My.Settings.username = TextBox3.Text
  46. End Sub
  47.  
  48. Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
  49.  
  50. End Sub
  51. Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
  52. Dim address As String = "http://192.168.2.7/DataENC/" & TextBox1.Text & ".txt"
  53. Dim client As WebClient = New WebClient()
  54. Dim reply As String = client.DownloadString(address)
  55. RichTextBox2.Text = reply
  56. If RichTextBox2.Text = RichTextBox1.Text Then
  57. Else
  58. RichTextBox1.Text = RichTextBox2.Text
  59. End If
  60. End Sub
  61.  
  62. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  63. TextBox1.Text = TextBox4.Text
  64. End Sub
  65.  
  66. Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged
  67. RichTextBox1.SelectionStart = RichTextBox1.TextLength
  68. RichTextBox1.ScrollToCaret()
  69. End Sub
  70. Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
  71. TextBox3.ReadOnly = True
  72. If TextBox2.Text = ("") Then
  73. Else
  74. Dim postData = "msg=" & TextBox3.Text & ": " & TextBox2.Text & "&token=" & TextBox1.Text
  75. Dim request As WebRequest = WebRequest.Create("http://192.168.2.7/msg.php")
  76. request.Method = "POST"
  77. Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
  78. request.ContentType = "application/x-www-form-urlencoded"
  79. request.ContentLength = byteArray.Length
  80. Dim dataStream As Stream = request.GetRequestStream()
  81. dataStream.Write(byteArray, 0, byteArray.Length)
  82. dataStream.Close()
  83. TextBox2.Clear()
  84. End If
  85. End Sub
  86. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement