Dim IsBlocked As Boolean
IsBlocked = CheckIsBlocked(txtSite.Text)
If IsBlocked = False Then
Dim path As [String] = "C:\Windows\System32\drivers\etc\hosts"
Dim sw As New StreamWriter(path, True)
Dim sitetoblock As [String] = vbCrLf & "127.0.0.1 " & txtSite.Text
sw.Write(sitetoblock)
sw.Close()
AddNewSiteToDb(txtSite.Text)
ServiceController1.Stop()
MessageBox.Show("Site " & txtSite.Text & " Blocked")
ServiceController1.Start()
txtSite.Clear()
Else
MsgBox("The site " & txtSite.Text & " has already blocked.")
txtSite.Clear()
End If
End Sub
Dim IsBlocked As Boolean
IsBlocked = CheckIsBlocked(txtSite.Text) '<<< ก็ตรวจสอบก่อนว่าติดใน blacklist มัน coding ผมไม่รู้ ถ้าให้เดา น่าจะมี database อีกตัวไว้ check กัน
If IsBlocked = False Then
Dim path As [String] = "C:\Windows\System32\drivers\etc\hosts"
Dim sw As New StreamWriter(path, True)
Dim sitetoblock As [String] = vbCrLf & "127.0.0.1 " & txtSite.Text
sw.Write(sitetoblock)
sw.Close()
AddNewSiteToDb(txtSite.Text) '<<<ตรงนี้แหร่ะที่เก็บ database ไว้ check blacklist
ServiceController1.Stop()
MessageBox.Show("Site " & txtSite.Text & " Blocked")
ServiceController1.Start()
txtSite.Clear()
Else
MsgBox("The site " & txtSite.Text & " has already blocked.")
txtSite.Clear()
End If
End Sub