I have a customer who has an dynamic ip, 10 PCs and hundreds of Users. The default profile gave them the piwik monitored site as a startpage, so they falsify the piwik statistic.
It was not (easy) possible to change this for existing users, nor could i set the ignore cookie stable for all Users.
I set up the script bellow on the server which is run every hour by cron.
It compares the Dynamic IP the Customer has (dyndns.org) with the IP stored in the Piwik konfiguration and updates it when needed.
I know that this is realy dirty but it might help someone.
Please note the security risk of putting the piwik mysql-pw in the script in cleartext.
#!/bin/sh
This Script checks an Dynamic-IP and writes it into the Piwik-DB in order to ignore requests
from that IP
This will overwrite the List of IP-Adresses to be ignored in Piwik!!
Only Testest with Piwik 1.6 on Debian
Use at your own Risk
Be carefull with the Access rights to this script as the piwik-db-passsword has to be put in
Plaintext into this Script.
gw@gi-it.de
GPLed
host="127.0.0.1"
username="piwikusername"
password="piwik-mysql-password"
dbname="piwik-db-name"
sitename="site-name-to-ignore"
dynipname=“myhostname.dyndns.org”
logger “Update DynIP $sitename in Piwik-DB:”
altip=mysql -p$password -u $username -D $dbname --execute="SELECT excluded_ips from site WHERE name = '$sitename' \g \q" | tail -n 1
logger "Old-IP: $altip"
neuip=host $dynipname | awk '{print $3}'
logger “New-IP: $neuip”
if [ “$neuip” = “$altip” ] ; then
logger "Nothing to do"
exit 1
else
logger "Update IP in Piwik-DB"
mysql -p$password -u $username -D $dbname --execute="update site SET excluded_ips=’$neuip’ WHERE name = ‘$sitename’ \g \q"
logger "Test Success…"
altip=mysql -p$password -u $username -D $dbname --execute="SELECT excluded_ips from site WHERE name = '$sitename' \g \q" | tail -n 1
if [ “$neuip” = “$altip” ] ; then
logger "Update successfull"
exit 0
else
logger "Error while updating"
exit 2
fi
fi