Situation: I control Internet access and my teen likes to use the Internet
Solution: Internet access is prohibited unless I get regular written communication
Warning: Restricting internet access may not make you popular
Here's how I did it:
The effect of this is that my teenager now has incentive to write me regular communication. The more I get, the more Internet access is allowed. If too much time passes between messages, then there is incentive to write again. It helps me feel like I'm staying in touch a little better and it gives my teen some freedom to enable Internet access when desired.
I've provided attached examples of the files that I'm using to set up this system. The files are text files, suitable for examples, but obviously modified so that our own real email addresses are not used.
Some basic setup is required in order to make this sort of thing possible, beyond just the files that the examples illustrate.
My home network gets Internet access from my router, which is a PC I've customized to do the job. It is running CentoOS, a version of Linux I favor for systems I don't want to change very often. CentOS works nicely with the webserver apache and iptables, which are needed for this to work.
I have set up apache to work with PHP and set aside the directories /var/www/wordeater and /var/www/wordeater.results for it to use. Apache has a customized configuration file I store in /etc/httpd/conf.d called wordeater.conf which sets it to listen on port 8080 and to direct all access attempts to the file at /var/www/wordeater/index.php. Apache has the rights to read and write to the directory /var/www/wordeater.results so that it can store information.
I use a script I store at /root/bin/wordeater.process.bash to remove one word each time it is run and count the number of words that are stored as submissions at /var/www/wordeater.results. When it has enough words, it enables normal Internet access and when the number of words drops too low, it stops and redirects Internet access attempts using another script I store at /root/bin/router.wordsinsufficient. It updates a status note to indicate the state of blocking, including blocking it does for bedtime hours.
The script at /root/bin/router.wordsinsufficient requires a start or stop argument and it checks to see if internet access is blocked or enabled, then makes the changes to the firewall as indicated by the argument. It uses iptables and based on the start and stop argument will redirect Internet
access attempts to apache on port 8080 when it is being blocked.
I have a scheduled task that runs /root/bin/wordeater.process.bash once every ten minutes, effectively meaning that six words are eaten each hour, or 144 words per day. It also checks the time and updates a status message indicating why Internet access is enabled or disabled, how many words are in the bank and whether internet access has been disabled for bedtime hours.
My page uses some images I've grabbed from the web that make sense to me as embodying "Not Hungry", "Sorta Hungry" and "Very Hungry" to give a nice visual to the current word count status. I am not including them because I don't want to worry about potentially infringing on anyone's copyrights.