These scripts will be necessary for parsing pihole.log before it is
flushed and then saving the information into a DB. This information
can then be displayed in the Web GUI.
mysql-server and php5-mysql will need to be installed.
you can then setup the database with this command:
mysql -u root -p"raspberry" < /usr/local/bin/setupPiholeStats.sql
Once that is done, run sudo php /usr/local/bin/lrs.php
I wanted the whitelist feature to keep the user on the same page
without having to reload it. I'm sure someone better versed in PHP
could eliminate the need for this hack. Nonetheless, it works.
www-data runs the script if executed from the Web interface. www-data
also needs access to write to /etc/pihole/gravity.list to actually
remove the domain. So a few more things need to happen before this
will fully work.
The changes in this script won't change what is displayed if run from
the terminal, but will help when it needs to be run from the Web
interface, so I am just committing this now.
The only other thing I would like to see would be a progress spinner,
but my Web skills still need some work...
Match domain exactly instead of partially.
Gather list of domains to minimize number of times that hosts file must be enumerated.
Only add domain to whitelist if it isn't already present.
It's pretty slow because /etc/hosts is so large, but it works. You can
add any number of domains as arguments and it will search for and
remove each one.
Maybe someone smarter knows how to make it faster...