We have an existing database that records all the downloads off our site in a single table, including username, file, date downloaded, timestamp and IP address.
We need a PHP script (or 2 scripts) to be run off a cron job at preset intervals to examine the data and trigger email alerts if abuse is detected.
Query 1 works off number of downloads per member. For example, if the number of downloads for a single user in a 2 day period exceeds 1000, and email is sent to the administrators reporting the abuse. Otherwise, an "all is well" email is sent (optionally turned off).
Query 2 does the same thing, but with IP Addresses. An alert will be sent out if the number of IP addresses using a single user name exceeds the designated parameter.
Configurable elements for both queries:
1) Number of downloads or different ip addresses per username to trigger email;
2) Length of time to search;
3) Usernames to ignore;
4) Email addresses to send alerts;
5) 2 Email templates
6) Turn "no abuse detected" email on and off
This can be either one script (ideally) or two, whichever is more foolproof. Thank you.