Advertisement
kelvin1232

Untitled

Jul 30th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. Imports System.Net, Microsoft.Win32
  2. Imports System.Management
  3. Imports System.IO
  4. Imports System.Security.Cryptography
  5. Imports System.Text
  6. Imports System.Threading
  7. Public Class Form1
  8.  
  9. Dim wc As New WebClient()
  10.  
  11. Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
  12. Remove()
  13. End Sub
  14. Private Sub Form_load(sender As Object, e As EventArgs) Handles MyBase.Load
  15. Dim Checker As New Thread(AddressOf Check)
  16. Checker.Start()
  17. End Sub
  18.  
  19. Sub Add()
  20. Try
  21. Dim richiesta As HttpWebRequest = DirectCast(WebRequest.Create("http://localhost/test/utenti.txt"), HttpWebRequest)
  22. Dim risposta As HttpWebResponse = DirectCast(richiesta.GetResponse(), HttpWebResponse)
  23. Dim sr As New StreamReader(risposta.GetResponseStream())
  24. Dim usernow As String = sr.ReadToEnd
  25. wc.DownloadString("http://localhost/test/users.php?utenti=" & usernow + 1)
  26. Label1.Text = "Online users: " & usernow + 1
  27. Catch ex As Exception
  28. MessageBox.Show("Error: " & ex.Message, "Error", MessageBoxButtons.OK, _
  29. MessageBoxIcon.Error)
  30. Environment.Exit(0)
  31. End Try
  32. End Sub
  33.  
  34. Sub Remove()
  35. Try
  36. Dim richiesta As HttpWebRequest = DirectCast(WebRequest.Create("http://localhost/test/utenti.txt"), HttpWebRequest)
  37. Dim risposta As HttpWebResponse = DirectCast(richiesta.GetResponse(), HttpWebResponse)
  38. Dim streamr As New StreamReader(risposta.GetResponseStream())
  39. Dim users As String = streamr.ReadToEnd
  40. wc.DownloadString("http://localhost/test/users.php?utenti=" & users - 1)
  41. Label1.Text = "Online users: " & users - 1
  42. Catch ex As Exception
  43. MessageBox.Show("Error: " & ex.Message, "Error", MessageBoxButtons.OK, _
  44. MessageBoxIcon.Error)
  45. Environment.Exit(0)
  46. End Try
  47.  
  48. End Sub
  49.  
  50.  
  51. Delegate Sub _Check()
  52. Sub Check()
  53. If InvokeRequired Then
  54. Invoke(New _Check(AddressOf Check))
  55. Else
  56. Try
  57. Dim richiesta As HttpWebRequest = DirectCast(WebRequest.Create("http://localhost/test/utenti.txt"), HttpWebRequest)
  58. Dim risposta As HttpWebResponse = DirectCast(richiesta.GetResponse(), HttpWebResponse)
  59. Dim l As New StreamReader(risposta.GetResponseStream())
  60. Label1.Text = String.Format("Online user: {0}", l.ReadToEnd)
  61. Catch Ex As Exception 'Clauspla catch....
  62. MessageBox.Show("Error: " & Ex.Message, "Error", MessageBoxButtons.OK, _
  63. MessageBoxIcon.Error)
  64. Environment.Exit(0)
  65. End Try
  66. End If
  67. End Sub
  68. Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
  69. Add()
  70. End Sub
  71. End Class
  72. _________________________________________________________________________________________________________________________________
  73.  
  74. .PHP
  75.  
  76.  
  77. <?php
  78. $utenti=$_GET['utenti'];
  79. $file = "utenti.txt";
  80. $open = fopen($file;
  81. $write = fwrite ($open, $testo);
  82. fclose($open);
  83. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement