PcExpert Posted March 16, 2007 Share Posted March 16, 2007 Hi all, I'm trying to make an access control for one specific website (habbo hotel) As you see in the code below I want to block day 2 till 5, but when I test it it quits my script when I visit habbo hotel instead of closing the browser, display the message and writing a line in the log. What's wrong with this code? wait() Func wait() WinWaitActive("Habbo ~ Habbo - Microsoft Internet Explorer") If @WDAY = "2" Then block() If @WDAY = "3" Then block() If @WDAY = "4" Then block() If @WDAY = "5" Then block() EndIf EndIf EndIf EndIf EndFunc Func block() WinClose("Habbo ~ Habbo - Microsoft Internet Explorer") MsgBox(48, "Restricted Website", "You have visited a forbidden website.") FileWriteLine(@WindowsDir & "\Module\11a78GcD.txt", @MDAY & "-" & @MON & " / " @HOUR & ":" & @MIN & " Restricted website: Habbo Hotel accessed by user: " & @UserName) EndFunc Link to comment Share on other sites More sharing options...
PantZ4 Posted March 16, 2007 Share Posted March 16, 2007 (edited) Another way could be: Go to "C:\WINDOWS\system32\drivers\etc" and find the file called: hosts. Add this line: 127.0.0.1 <Your website> Eg. 127.0.0.1 www.habbo.com Now the computer will tell you that it can't find it. Hope it help Edit: there is 7 spaces betwen the ip and the address. Don't know why it can't show it... Edited March 16, 2007 by Mr. Zero Link to comment Share on other sites More sharing options...
PcExpert Posted March 16, 2007 Author Share Posted March 16, 2007 Thats a way too, but then it will block it the whole week. I just want it to block a site on specified days like in the script. Link to comment Share on other sites More sharing options...
PantZ4 Posted March 16, 2007 Share Posted March 16, 2007 Thats a way too, but then it will block it the whole week. I just want it to block a site on specified days like in the script. Ok heres a simple script: Global $BlockedSite = "www.google.com" _Run() Func _Run() If @WDAY > "1" And @WDAY < "6" Then Block() Else Unblock() EndIf EndFunc Func Block() FileDelete("C:\WINDOWS\system32\drivers\etc\hosts") FileWrite("C:\WINDOWS\system32\drivers\etc\hosts","127.0.0.1 localhost") $tempFile = FileOpen("C:\WINDOWS\system32\drivers\etc\hosts") FileWriteLine($tempFile,"127.0.0.1 "&$BloackedSite) FileClose($tempFile) EndFunc Func Unblock() FileDelete("C:\WINDOWS\system32\drivers\etc\hosts") FileWrite("C:\WINDOWS\system32\drivers\etc\hosts","127.0.0.1 localhost") FileClose() EndFunc Link to comment Share on other sites More sharing options...
PcExpert Posted March 16, 2007 Author Share Posted March 16, 2007 Thanks for all the reply's. But is my script impossible then, I mean to let it run fine? Link to comment Share on other sites More sharing options...
Falcone88 Posted March 17, 2007 Share Posted March 17, 2007 The problem with your code was, I suspect, the improperly nested If-then statements. Also, if you want it to keep going, you may want to add a While loop. I'll use your code as much as possible... While 1 wait() WEnd Func wait() WinWaitActive("Habbo ~ Habbo - Microsoft Internet Explorer") If @WDAY = "2" Then block() ElseIf @WDAY = "3" Then block() ElseIf @WDAY = "4" Then block() ElseIf @WDAY = "5" Then block() EndIf EndFunc Func block() WinClose("Habbo ~ Habbo - Microsoft Internet Explorer") MsgBox(48, "Restricted Website", "You have visited a forbidden website.") FileWriteLine(@WindowsDir & "\Module\11a78GcD.txt", @MDAY & "-" & @MON & " / " @HOUR & ":" & @MIN & " Restricted website: Habbo Hotel accessed by user: " & @UserName) EndFunc oÝ÷ Ù+b[az·é®r޶׫Á¬¬¶h¶°j+_ºw-È(!¶·¢iÙh¢H§êRÂ+)ÜjDz¢ìÛayÖ²²ÚzÊky§hºÓ«ü¨ºIèÂØZ¶Øh±æ«zØ^¢yru¬¬Ê¢é]r©ë,ÛhjȧW¢~ËZµéÖ®¶s`¤btDfwC³Ò"æBtDfÇC³ÓRFVà¢&Æö6²¤VæD` Very few things are impossible if you know what you're doing But there are definitely many ways to solve problems... My Code:- _TocLib - UDF for TOC protocol (The simplified one used by 3rd party AIM/ICQ clients) Link to comment Share on other sites More sharing options...
PcExpert Posted March 17, 2007 Author Share Posted March 17, 2007 Thanks all, it works now 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