Imports System.Text.RegularExpressions
Imports System
Imports System.IO
Public Class frmMain
Inherits System.Windows.Forms.Form
'Create a new Random class in VB.NET
Dim RandomClass As New Random()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error GoTo err
'Go to requested url
Dim url As System.Uri = New System.Uri(txtRequest.Text)
Me.WebBrowser1.Navigate(url)
err:
End Sub
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Create projects dir
Dim di As DirectoryInfo = New DirectoryInfo("c:\Uis")
' Determine whether the directory exists.
If di.Exists Then
'already exists.
Else
' Try to create the directory.
di.Create()
End If
If File.Exists("C:\Uis\User.txt") Then
'Load user accounts
Dim sTemp As String
sTemp = My.Computer.FileSystem.ReadAllText("C:\Uis\User.txt")
End If
If File.Exists("C:\Uis\Agent.txt") Then
'Load user agent
Dim sTemp As String
sTemp = My.Computer.FileSystem.ReadAllText("C:\Uis\Agent.txt")
End If
'Sort entrys in ascending order
lvPost.Sorting = SortOrder.Ascending
'Gather
'Reset txtH
txtH.Text = ""
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
txtSource.Text = Me.WebBrowser1.Document.Body.InnerHtml
txtRequest.Text = WebBrowser1.Url.ToString()
End Sub
Private Sub cmdPostAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPostAdd.Click
'check value
If String.IsNullOrEmpty(txtPostName.Text) Then
MessageBox.Show("Enter a username", "Invaild", MessageBoxButtons.OK, _
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
Exit Sub
ElseIf String.IsNullOrEmpty(txtPostValue.Text) Then
MessageBox.Show("Enter a password", "Invalid", MessageBoxButtons.OK, _
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
Exit Sub
End If
'Add new username and password
If txtPostName.Text <> "" And txtPostValue.Text <> "" Then
Dim liNew As ListViewItem = lvPost.Items.Add(txtPostName.Text)
liNew.SubItems.Add(txtPostValue.Text)
txtPostName.Text = ""
txtPostValue.Text = ""
Dim i As Integer = 0
Dim sTemp As String = ""
'************************************
' Write All Items and subitems to a file
With lvPost
.View = View.Details
For i = 0 To .Items.Count - 1
' Collect Item and subitems as comma separated elements
' sTemp += .Items(i).Text & ","
sTemp += .Items(i).SubItems(0).Text & ":"
sTemp += .Items(i).SubItems(1).Text & vbNewLine
Next
End With
My.Computer.FileSystem.WriteAllText("C:\Uis\User.txt", sTemp, False)
'***********************************
End If
End Sub
Private Sub lvpost_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles lvPost.SelectedIndexChanged
'Display selected index in auth tab
Dim SelectedItems As ListView.SelectedListViewItemCollection = _
CType(sender, ListView).SelectedItems
If (SelectedItems.Count > 0) Then
txtAuthUsername.Text = SelectedItems(0).SubItems(0).Text
txtAuthPassword.Text = SelectedItems(0).SubItems(1).Text
End If
End Sub
Private Sub tpPost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tpPost.Click
End Sub
Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteToolStripMenuItem.Click
'Do you really want to remove the user account?
Dim i As Integer
Try
For i = 0 To lvPost.Items.Count - 1
If lvPost.Items(i).Selected Then Exit For
Next
If lvPost.Items.Count <> 0 Then
If MessageBox.Show("Delete User Account " & lvPost.Items(i).Text & "?", "Deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
lvPost.Items.RemoveAt(i)
End If
End If
Catch ex As Exception
End Try
tmr.Enabled = True
End Sub
Private Sub tmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr.Tick
Dim i As Integer = 0
Dim sTemp As String = ""
'************************************
' Write All Items and subitems to a file
With lvPost
.View = View.Details
For i = 0 To .Items.Count - 1
' Collect Item and subitems as comma separated elements
' sTemp += .Items(i).Text & ","
sTemp += .Items(i).SubItems(0).Text & ":"
sTemp += .Items(i).SubItems(1).Text & vbNewLine
Next
End With
My.Computer.FileSystem.WriteAllText("C:\Uis\User.txt", sTemp, False)
'***********************************
tmr.Enabled = False
End Sub
Private Sub KillDatabaseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KillDatabaseToolStripMenuItem.Click
If MessageBox.Show("Are you sure you want to delete the database? This cannot be recovered.", "Deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
Dim Argument As String()
Dim FileToBurn As String
Dim i As Integer = 0
Dim RandomNumber As Integer
RandomNumber = RandomClass.Next()
Argument = System.Environment.GetCommandLineArgs
Do Until i = 10
FileToBurn = "C:\Uis\User.txt" 'Argument(i)
FileOpen(1, FileToBurn, OpenMode.Output)
Print(1, RandomNumber, "***Over written data***", RandomNumber)
FileClose(1)
i = i + 1
Loop
End If
'kill over passed file
Dim ow As String
ow = "C:\Uis\User.txt" 'Argument(i)
Kill(ow)
End Sub
Private Sub btnAgent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAgent.Click
'check value
If String.IsNullOrEmpty(txtAgentName.Text) Then
MessageBox.Show("Enter a username", "Invaild", MessageBoxButtons.OK, _
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
Exit Sub
ElseIf String.IsNullOrEmpty(txtAgentId.Text) Then
MessageBox.Show("Enter a User-Agent", "Invalid", MessageBoxButtons.OK, _
MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
Exit Sub
End If
'Add new username and password
If txtAgentName.Text <> "" And txtAgentId.Text <> "" Then
Dim liNew As ListViewItem = lvAgent.Items.Add(txtAgentName.Text)
liNew.SubItems.Add(txtAgentId.Text)
txtAgentName.Text = ""
txtAgentId.Text = ""
Dim i As Integer = 0
Dim sTemp As String = ""
'************************************
' Write All Items and subitems to a file
With lvAgent
.View = View.Details
For i = 0 To .Items.Count - 1
' Collect Item and subitems as comma separated elements
' sTemp += .Items(i).Text & ","
sTemp += .Items(i).SubItems(0).Text & ":"
sTemp += .Items(i).SubItems(1).Text & vbNewLine
Next
End With
My.Computer.FileSystem.WriteAllText("C:\Uis\Agent.txt", sTemp, False)
'***********************************
End If
End Sub
Private Sub DeleteAgentToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteAgentToolStripMenuItem.Click
'Do you really want to remove the user account?
Dim i As Integer
Try
For i = 0 To lvAgent.Items.Count - 1
If lvAgent.Items(i).Selected Then Exit For
Next
If lvAgent.Items.Count <> 0 Then
If MessageBox.Show("Delete User Agent? " & lvAgent.Items(i).Text & "?", "Deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
lvAgent.Items.RemoveAt(i)
End If
End If
Catch ex As Exception
End Try
tmragent.Enabled = True
End Sub
Private Sub tmragent_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmragent.Tick
Dim i As Integer = 0
Dim sTemp As String = ""
'************************************
' Write All Items and subitems to a file
With lvAgent
.View = View.Details
For i = 0 To .Items.Count - 1
' Collect Item and subitems as comma separated elements
' sTemp += .Items(i).Text & ","
sTemp += .Items(i).SubItems(0).Text & ":"
sTemp += .Items(i).SubItems(1).Text & vbNewLine
Next
End With
My.Computer.FileSystem.WriteAllText("C:\Uis\Agent.txt", sTemp, False)
'***********************************
tmragent.Enabled = False
End Sub
Private Sub KillDatabaseToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KillDatabaseToolStripMenuItem1.Click
If MessageBox.Show("Are you sure you want to delete the database? This cannot be recovered.", "Deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
Dim Argument As String()
Dim FileToBurn As String
Dim i As Integer = 0
Dim RandomNumber As Integer
RandomNumber = RandomClass.Next()
Argument = System.Environment.GetCommandLineArgs
Do Until i = 10
FileToBurn = "C:\Uis\Agent.txt" 'Argument(i)
FileOpen(1, FileToBurn, OpenMode.Output)
Print(1, RandomNumber, "***Over written data***", RandomNumber)
FileClose(1)
i = i + 1
Loop
End If
'kill over passed file
Dim ow As String
ow = "C:\Uis\Agent.txt" 'Argument(i)
Kill(ow)
End Sub
Private Sub ContextMenuStrip2_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip2.Opening
End Sub
Private Sub lvAgent_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvAgent.SelectedIndexChanged
'Display selected user agent in Useragent field
Dim SelectedItems As ListView.SelectedListViewItemCollection = _
CType(sender, ListView).SelectedItems
If (SelectedItems.Count > 0) Then
Dim UserAgent
UserAgent = SelectedItems(0).SubItems(0).Text & ":" & SelectedItems(0).SubItems(1).Text
txtUserAgent.Text = UserAgent
End If
End Sub
End Class