electrico Posted February 28, 2010 Share Posted February 28, 2010 (edited) This is the whole code. Please change pictures if you want at your own look. expandcollapse popup #NoTrayIcon #include <GuiConstantsEx.au3> #include <EditConstants.au3> #include <File.au3> Global $editfield Global $logfileadd Global $logfile Global $nowopenlog Global $donepic Global $permitted Global $prohibited Opt("GuiOnEventMode", 1) HotKeySet("+{F7}", "alloweverything") HotKeySet("+{F11}", "looklogfile") FileInstall("msgfile.txt", @TempDir & "\msgfile.txt", 1) FileInstall("hosts", @UserProfileDir & "\hosts", 0) FileInstall("logo.bmp", @TempDir & "\logo.bmp", 1) FileInstall("checkmark.bmp", @TempDir & "\checkmark.bmp", 1) $messagefile = (@TempDir & "\msgfile.txt") $message = FileReadLine($messagefile, Random(1,11,1)) $passtorun = InputBox("Protected software!", "Please type password to run this software", "", "#", 200, 150) If $passtorun = String("0x0000001") Then runapp() Else MsgBox(48, "-=Not correct=-", $message) Exit EndIf Func runapp() $Gui = GuiCreate("Web surf protection v1.0", 315, 135) GUISetBkColor(0xffffff) GuiSetOnEvent($GUI_EVENT_CLOSE, "close") GuiSetState(@SW_SHOW) GuiCtrlCreatePic(@TempDir & "\logo.bmp", 170, 3, 152, 41) GuiCtrlCreateLabel("Please enter web adress to forbid:", 20, 45, 180, 20) $editfield = GuiCtrlCreateEdit("", 20, 60, 250, 20, BitOR($ES_LEFT, $ES_PASSWORD)) $button = GuiCtrlCreateButton("OK", 275, 60, 25, 20) GuiCtrlSetOnEvent($button, "forbid") GuiCtrlCreateLabel("Allow everything = [SHIFT+F7]", 20, 95, 240, 15) GuiCtrlCreateLabel("Locked web sites = [SHIFT+F11]", 20, 115, 240, 15) If FileExists (@UserProfileDir & "\websurf.log") Then $prohibited = GuiCtrlCreateLabel("Some web sites are prohibited", 3, 2, 150, 15) GuiCtrlSetColor(-1, "0xcc0033") Else $permitted = GuiCtrlCreateLabel("All web sites are permitted", 3, 2, 150, 15) GuiCtrlSetColor(-1, "0x339966") EndIf EndFunc Func writelog() $logfile = FileExists(@UserProfileDir & "\websurf.log") If $logfile = True Then Sleep(10) Else $logfileadd = _FileCreate(@UserProfileDir & "\websurf.log") EndIF $logfile2 = FileOpen(@UserProfileDir & "\websurf.log",1) FileWriteLine($logfile2, GuiCtrlRead($editfield)) FileClose($logfile2) EndFunc Func forbid() GuiCtrlDelete($permitted) GuiCtrlCreateLabel("Some web sites are prohibited", 3, 2, 150, 15) GuiCtrlSetColor(-1, "0xcc0033") writelog() $filetoedit = (@SystemDir & "\drivers\etc\hosts") $file = FileOpen($filetoedit, 1) FileWriteLine(@SystemDir & "\drivers\etc\hosts", "127.0.0.1 " & GuiCtrlRead($editfield)) FileClose($file) GuiCtrlSetData($editfield, "") $donepic = GuiCtrlCreatePic(@TempDir & "\checkmark.bmp", 275, 90, 28, 26) Sleep(2000) GuiCtrlDelete($donepic) EndFunc Func alloweverything() FileDelete(@UserProfileDir & "\websurf.log") FileDelete(@SystemDir & "\drivers\etc\hosts") FileCopy(@UserProfileDir & "\hosts", @SystemDir & "\drivers\etc\hosts") GuiCtrlDelete($prohibited) GuiCtrlCreateLabel("All web sites are permitted", 3, 2, 150, 15) GuiCtrlSetColor(-1, "0x339966") EndFunc Func looklogfile() $logfile = FileExists(@UserProfileDir & "\websurf.log") If $logfile = True Then Run("notepad websurf.log", @UserProfileDir, @SW_SHOW) Else MsgBox(64, "Message:", "No prohibited web addresses") EndIf EndFunc Func close() FileDelete(@UserProfileDir & "\hosts") Exit EndFunc While 1 Sleep (10) WEnd link to my source files: http://www.cyberspace.times.lv/websurf.rar Edited February 28, 2010 by electrico Link to comment Share on other sites More sharing options...
Shaarad Posted March 1, 2010 Share Posted March 1, 2010 On which browsers does the web surfing gets banned ??? I banned site www.opera.com for testing and it is still loading on google chrome and IE6. also...how to unblock the previously blocked pages ? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Shaarad Posted March 1, 2010 Share Posted March 1, 2010 ok......found all answers myself....cool program dude...keep it up. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
electrico Posted March 1, 2010 Author Share Posted March 1, 2010 Known problems: googhe Chrome avoid hosts file configuration. Answer to previous question. - Find label: Allow everything (thats should be SHIFT+F7) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now