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?
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.
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.
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.