Sign in to follow this  
Followers 0
JustinReno

Parental Filter

1 post in this topic

After searching the example scripts, I see that no one has tried to make a parental filter! So, after an hour or two, I came up with my own.

Its really simple, and it needs improvement, like scanning the webpage for bad words.

In the Var $Filter, fill out what you want to filter. REMEMBER: It searches through this array at 0. Example: $Filter[1] = ["Crap"] NOT $Filter[2] = ["Crap"]

#NoTrayIcon
#Include <IE.au3>

Opt("GUIResizeMode", 1)

Global $Filter[2] = ["Blah", "Crap"]
Global $RedirectURL = "http://www.parentalfilter.tk/"
Global $Log = @WindowsDir & "\Log.txt"
Global $Found

$Password = InputBox("Parental Browser", "Please enter a password to use when exiting:", "", "*M")
If @error Then Exit
_FileWriteLog($Log, "Password " & $Password)

$GUI = GUICreate("Parental Browser", 627, 414, -1, -1, -1, 0x00000080)
$IE = ObjCreate("Shell.Explorer.2")
GUICtrlCreateObj($IE, 0, 0, 626, 388)
GUICtrlCreateLabel("URL:", 0, 392, 34, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$URL = GUICtrlCreateInput("", 40, 392, 121, 21)
$Go = GUICtrlCreateButton("Go", 168, 392, 75, 21, 0)
$Back = GUICtrlCreateButton("Back", 243, 392, 75, 21, 0)
GUISetState(@SW_SHOW, $GUI)
GUISetState(@SW_MAXIMIZE, $GUI)

While 1
    _IELoadWaitTimeout(100)
    If Not WinActive($GUI) Then WinActivate($GUI)
    If WinGetState($GUI) <> 32 Then GUISetState(@SW_MAXIMIZE, $GUI)
    If ProcessExists("TaskMgr.exe") Then ProcessClose("TaskMgr.exe")
    If $IE.LocationURL () <> "" And $IE.LocationURL () <> $RedirectURL And Not StringInStr(FileRead($Log), $IE.LocationURL ()) Then _FileWriteLog($Log, $IE.LocationURL ())
    _FilterURL()
    Switch GUIGetMsg()
        Case - 3
            $AskForPassword = InputBox("Parental Browser", "Please enter the password to exit:", "", "*M")
            If $AskForPassword = $Password Then
                _FileWriteLog($Log, "Closed")
                Exit
            EndIf
            If $AskForPassword <> $Password And Not @error Then _FileWriteLog($Log, "Bad Exit Password: " & $AskForPassword)
        Case $Go
            If _FilterURLBox() = 0 Then $IE.Navigate (GUICtrlRead($URL))
        Case $Back
            If FileRead($Log) <> "" Then $IE.GoBack ()
    EndSwitch
WEnd

Func _FilterURLBox()
    $Found = 0
    For $I = 0 To UBound($Filter) - 1
        If StringInStr(GUICtrlRead($URL), $Filter[$I]) Then
            _FileWriteLog($Log, "Bad URL: " & GUICtrlRead($URL) & " | " & $Filter[$I])
            $IE.Navigate ($RedirectURL)
            $Found = 1
            ExitLoop
        EndIf
    Next
    Return $Found
EndFunc   ;==>_FilterURLBox

Func _FilterURL()
    For $I = 0 To UBound($Filter) - 1
        If StringInStr($IE.LocationURL (), $Filter[$I]) And Not StringInStr(FileRead($Log), $IE.LocationURL ()) Then
            _FileWriteLog($Log, "Bad URL: " & $IE.LocationURL () & " | " & $Filter[$I])
            $IE.Navigate ($RedirectURL)
        EndIf
    Next
EndFunc   ;==>_FilterURL

Func _FileWriteLog($H_Log, $S_Msg)
    FileWrite($H_Log, @CRLF & @YEAR & "-" & @MON & "-" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & " : " & $S_Msg)
EndFunc

If you use any of my code give credit.

Share this post


Link to post
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
Sign in to follow this  
Followers 0