views:

68

answers:

3

I'd like to create a simple program that will block certain websites for the user under certain conditions (e.g. after 7:00pm if homework is due the next day). This would be just a programming exercise for myself/for self discipline, so it would not have to support passwords or any other security. It need only be very basic. What language would you recommend using for this project, and how might I go about doing it? I'm a beginner Java programmer, and know the very basics of C++, although I think this is a scripting language type project. Any suggestions?

A: 

There is no such simple program. You are writing one program, the browser is another. You can't write a program outside the browser that reaches in and does this sort of thing. You can write plugins: one for IE, one for FireFox, one for Opera. And then you have to convince your User/Victim to install it/them.

bmargulies
A: 

If you are on Windows, you can create two copied of c:\windows\system32\drivers\etc\hosts. Make one copy your original, and to the second one, add entries the site you'd like to restrict:

127.0.0.1 stackoverflow.com

Next, create two scheduled tasks. One to replace hosts with the original file and the other one to replace hosts with your restricted file.

brianegge
It is easy for the user to get around this. He / she simply uses the IP address for stackoverflow.com
Stephen C
But the question stated it was for self-discipline and not a robust business app. Although the question did want to be a programming excercise and this answer would not provide this.
Russell
I missed that point. But the pat answer is that the OP should be self-disciplined. Don't waste study time on trying to implement technological "solutions" to make you study.
Stephen C
+2  A: 

The only bomb-proof way you do this is to build a proxy HTTP server that implements the website access policies that you want to enforce. This typically needs to run on a separate machine for that the user cannot disable it. Then you configure your network firewalls so that the user's machine cannot access remote HTTP servers directly, but has to use your proxy server.

This is probably not a programming problem. Rather you need to find some existing proxy server that can implement the kinds of policies that you want, install it, configure it and configure your firewall and browser web-access.

EDIT : if you are doing this to impose discipline on yourself, the easy way would be to write an Proxy Auto-config file that sends you to some page like this.

Stephen C
+1 for the first half of the answer. I think writing a lightweight HTTP proxy would be an excellent "personal discipline" project. I'd suggest spending a few hours reading RFC 2616, then trying to figure out how to achieve the stated goal while implementing only as much of the spec as necessary, and no more.
Ben Dunlap
http://www.ietf.org/rfc/rfc2616.txt
Ben Dunlap
@Ben - I would consider that a better "personal discipline" project would be to resist the temptation of wasting time on stuff like this ... and do some REAL study!
Stephen C