Jump to content

Block some websites


Glyco
 Share

Recommended Posts

i want to block access to some websites.

first i was thinking to hide or close the window, but now i think blocking full access is better.

website should not be opened at all.

this is for a basic website blocking program.

you could use the hosts file to redirect traffic to those sites to google
Link to comment
Share on other sites

i think hosts file needs a lot of editing just for blocking one single website.

am i right?

because it seems i will have to put all the sub domains to block the website completely!

then how 'll i get all the sub domains info of a website?

Link to comment
Share on other sites

i think hosts file needs a lot of editing just for blocking one single website.

am i right?

because it seems i will have to put all the sub domains to block the website completely!

then how 'll i get all the sub domains info of a website?

hadn't though of sub domains, sorry... probably not the best or most elegant solution, but you could have a script check the url being displayed in the browser against a list of bad domains, then a bad domain is part of the url, parse out the subdomain, add it to hosts file and refresh the page.
Link to comment
Share on other sites

Using a HOST file to block is very simple to do. There are simple HOST editing programs out there for those who need a GUI instead of using notepad. If you are really bent on blocking certain sites, then something like NetNanny may be better way to go.

Link to comment
Share on other sites

i think it would be better if you use window titles, i use this method:

Opt("WinTitleMatchMode", 2) ; Read more about its use
While 1
    If WinExists("Title") Then
        WinSetState("Title", "", @SW_HIDE) ; or use WinClose()
        MsgBox(64, "Access Denied", "Website Blocked.", 10)
    EndIf
    Sleep(250) ; for low cpu usage
WEnd

Or

Func _Close($title)
    If WinExists($title) Then
        WinSetState($title, "", @SW_HIDE) ; or use WinClose()
        MsgBox(64, "Access Denied", "Website "& $title & "Blocked.", 10)
    EndIf
    Sleep(250)
EndFunc
_Close("Some Website Title")

i have one more idea, we can create a script to block titles only on browsers.

by this way other program windows 'll not be effected by this censorship.

Here (This is for IE Only):

; Modify the script to work with all browsers.
Func _ProcessGetName($i_PID)
    If Not ProcessExists($i_PID) Then Return SetError(1, 0, '')
    If Not @error Then
        Local $a_Processes = ProcessList()
        For $i = 1 To $a_Processes[0][0]
            If $a_Processes[$i][1] = $i_PID Then Return $a_Processes[$i][0]
        Next
    EndIf
    Return SetError(1, 0, '')
EndFunc
Func _RunDOS($sCommand)
    Local $nResult = RunWait(@ComSpec & " /C " & $sCommand, "", @SW_HIDE)
    Return SetError(@error, @extended, $nResult)
EndFunc
Func _Close($Title)
    Opt("WinTitleMatchMode", 4)
    $Title = WinGetTitle("[REGEXPTITLE:(?i)"&$Title&"]", "")
    $P_pid = WinGetProcess($Title)
    $Process = _ProcessGetName($P_pid)
    If $Process = "IExplore.exe"
        WinClose($Title)
        MsgBox(64, "Access Denied", "Website "& $title & "Blocked.", 10)
    EndIf
EndFunc
_Close("A Website Title"); Just use it it a loop

These are just examples i created to make easy for you to understand it.

you can modify any of them to as you want them to work. just read more about the functions i used.

i have not tested any of the above but i think there 'll be no errors.

You can also use FileWrite() & it's related functions to edit the hosts file, just search the google and you 'll get all the details.

i think wikipedia also have information about it. i did not check but i think i had read in past.

Enjoy!

Link to comment
Share on other sites

These are just examples i created to make easy for you to understand it.

you can modify any of them to as you want them to work. just read more about the functions i used.

i have not tested any of the above but i think there 'll be no errors.

You can also use FileWrite() & it's related functions to edit the hosts file, just search the google and you 'll get all the details.

i think wikipedia also have information about it. i did not check but i think i had read in past.

Enjoy!

one issue that you'll run into though; if you have an output like the message box in the examples, a user can just leave that message box up and that would disable the window watching.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...