I have done as you asked and checked your script:
/usr/local/ispconfig/server/cron_daily.php
It seems it's your SQL query that's faulty. If you think it works properly, then you have missed this logical error.
You use this query to check for the month's traffic, which will return a row-set of dates:
PHP Code:
SELECT traffic_bytes FROM web_traffic WHERE traffic_date like '$current_month%' AND hostname = '$domain'
So when you run the below PHP code, you only retrieve the traffic from the first date of current month:
PHP Code:
$web_traffic = $tmp['traffic_bytes']/1024/1024;
Which should be cast to int by the way:
PHP Code:
$web_traffic = (int)$tmp['traffic_bytes']/1024/1024;
It looks to me like you really meant to use an SQL statement like this instead to return all the month's bytes in 1 row. This will return all the month's traffic, and with the rest of your PHP code compare it correctly against the traffic_quota column from the table web_domain:
PHP Code:
SELECT SUM(traffic_bytes) As total_traffic_bytes FROM web_traffic WHERE traffic_date like '$current_month%' AND hostname = '$domain'
And change the $web_traffic code to:
PHP Code:
$web_traffic = (int)$tmp['total_traffic_bytes']/1024/1024;
To put it simple, your script currently only locks a site if the
first day of traffic for the current month is over the traffic quota that is supposed to be for the whole month. I have made these modifications to your script in my version of ISP Config, and it works properly now if I run: /usr/local/ispconfig/server/cron_daily.sh
Kind regards,
Jonny
Recent comments
18 hours 48 min ago
23 hours 47 min ago
1 day 1 hour ago
1 day 2 hours ago
1 day 3 hours ago
1 day 8 hours ago
1 day 9 hours ago
1 day 11 hours ago
2 days 26 min ago
2 days 2 hours ago