Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Net, Microsoft.Win32
- Imports System.Management
- Imports System.IO
- Imports System.Security.Cryptography
- Imports System.Text
- Imports System.Threading
- Public Class Form1
- Dim wc As New WebClient()
- Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
- Remove()
- End Sub
- Private Sub Form_load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim Checker As New Thread(AddressOf Check)
- Checker.Start()
- End Sub
- Sub Add()
- Try
- Dim richiesta As HttpWebRequest = DirectCast(WebRequest.Create("http://localhost/test/utenti.txt"), HttpWebRequest)
- Dim risposta As HttpWebResponse = DirectCast(richiesta.GetResponse(), HttpWebResponse)
- Dim sr As New StreamReader(risposta.GetResponseStream())
- Dim usernow As String = sr.ReadToEnd
- wc.DownloadString("http://localhost/test/users.php?utenti=" & usernow + 1)
- Label1.Text = "Online users: " & usernow + 1
- Catch ex As Exception
- MessageBox.Show("Error: " & ex.Message, "Error", MessageBoxButtons.OK, _
- MessageBoxIcon.Error)
- Environment.Exit(0)
- End Try
- End Sub
- Sub Remove()
- Try
- Dim richiesta As HttpWebRequest = DirectCast(WebRequest.Create("http://localhost/test/utenti.txt"), HttpWebRequest)
- Dim risposta As HttpWebResponse = DirectCast(richiesta.GetResponse(), HttpWebResponse)
- Dim streamr As New StreamReader(risposta.GetResponseStream())
- Dim users As String = streamr.ReadToEnd
- wc.DownloadString("http://localhost/test/users.php?utenti=" & users - 1)
- Label1.Text = "Online users: " & users - 1
- Catch ex As Exception
- MessageBox.Show("Error: " & ex.Message, "Error", MessageBoxButtons.OK, _
- MessageBoxIcon.Error)
- Environment.Exit(0)
- End Try
- End Sub
- Delegate Sub _Check()
- Sub Check()
- If InvokeRequired Then
- Invoke(New _Check(AddressOf Check))
- Else
- Try
- Dim richiesta As HttpWebRequest = DirectCast(WebRequest.Create("http://localhost/test/utenti.txt"), HttpWebRequest)
- Dim risposta As HttpWebResponse = DirectCast(richiesta.GetResponse(), HttpWebResponse)
- Dim l As New StreamReader(risposta.GetResponseStream())
- Label1.Text = String.Format("Online user: {0}", l.ReadToEnd)
- Catch Ex As Exception 'Clauspla catch....
- MessageBox.Show("Error: " & Ex.Message, "Error", MessageBoxButtons.OK, _
- MessageBoxIcon.Error)
- Environment.Exit(0)
- End Try
- End If
- End Sub
- Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
- Add()
- End Sub
- End Class
- _________________________________________________________________________________________________________________________________
- .PHP
- <?php
- $utenti=$_GET['utenti'];
- $file = "utenti.txt";
- $open = fopen($file;
- $write = fwrite ($open, $testo);
- fclose($open);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement