Skip to content

Commit 695825a

Browse files
author
mike_p
committed
BUG FS#1139 - fix as described in forum has been applied and tested by running script - no errors encountered. - and query checked with mysql.
1 parent c89471e commit 695825a

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

server/cron_daily.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// make sure server_id is always an int
3737
$conf["server_id"] = intval($conf["server_id"]);
3838

39-
39+
4040
// Load required base-classes
4141
$app->uses('ini_parser,file,services');
4242

@@ -49,27 +49,27 @@
4949
$records = $app->db->queryAllRecords($sql);
5050
foreach($records as $rec) {
5151
if(@is_file($rec["maildir"].'/ispconfig_mailsize')) {
52-
52+
5353
// rename file
5454
rename($rec["maildir"].'/ispconfig_mailsize',$rec["maildir"].'/ispconfig_mailsize_save');
55-
55+
5656
// Read the file
5757
$lines = file($rec["maildir"].'/ispconfig_mailsize_save');
5858
$mail_traffic = 0;
5959
foreach($lines as $line) {
6060
$mail_traffic += intval($line);
6161
}
6262
unset($lines);
63-
63+
6464
// Delete backup file
6565
if(@is_file($rec["maildir"].'/ispconfig_mailsize_save')) unlink($rec["maildir"].'/ispconfig_mailsize_save');
66-
66+
6767
// Save the traffic stats in the sql database
6868
$tstamp = date("Y-m");
69-
69+
7070
$sql = "SELECT * FROM mail_traffic WHERE month = '$tstamp' AND mailuser_id = ".$rec["mailuser_id"];
7171
$tr = $app->dbmaster->queryOneRecord($sql);
72-
72+
7373
$mail_traffic += $tr["traffic"];
7474
if($tr["traffic_id"] > 0) {
7575
$sql = "UPDATE mail_traffic SET traffic = $mail_traffic WHERE traffic_id = ".$tr["traffic_id"];
@@ -78,9 +78,9 @@
7878
}
7979
$app->dbmaster->query($sql);
8080
echo $sql;
81-
81+
8282
}
83-
83+
8484
}
8585

8686
#######################################################################################################
@@ -166,7 +166,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
166166
exec("gzip -c $logfile > $logfile.gz");
167167
unlink($logfile);
168168
}
169-
169+
170170
// delete logfiles after 30 days
171171
$month_ago = date("Ymd",time() - 86400 * 30);
172172
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$month_ago.'-access.log.gz');
@@ -284,30 +284,30 @@ function setConfigVar( $filename, $varName, $varValue ) {
284284
if ($app->dbmaster == $app->db) {
285285

286286
$current_month = date('Y-m');
287-
287+
288288
//* Check website traffic quota
289289
$sql = "SELECT sys_groupid,domain_id,domain,traffic_quota,traffic_quota_lock FROM web_domain WHERE traffic_quota > 0 and type = 'vhost'";
290290
$records = $app->db->queryAllRecords($sql);
291291
if(is_array($records)) {
292292
foreach($records as $rec) {
293-
293+
294294
$web_traffic_quota = $rec['traffic_quota'];
295295
$domain = $rec['domain'];
296-
296+
297297
// get the client
298298
/*
299299
$client_group_id = $rec["sys_groupid"];
300300
$client = $app->db->queryOneRecord("SELECT limit_traffic_quota,parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
301301
$reseller = $app->db->queryOneRecord("SELECT limit_traffic_quota FROM client WHERE client_id = ".intval($client['parent_client_id']));
302-
302+
303303
$client_traffic_quota = intval($client['limit_traffic_quota']);
304304
$reseller_traffic_quota = intval($reseller['limit_traffic_quota']);
305305
*/
306-
306+
307307
//* get the traffic
308-
$tmp = $app->db->queryOneRecord("SELECT traffic_bytes FROM web_traffic WHERE traffic_date like '$current_month%' AND hostname = '$domain'");
309-
$web_traffic = $tmp['traffic_bytes']/1024/1024;
310-
308+
$tmp = $app->db->queryOneRecord("SELECT SUM(traffic_bytes) As total_traffic_bytes FROM web_traffic WHERE traffic_date like '$current_month%' AND hostname = '$domain'");
309+
$web_traffic = (int)$tmp['total_traffic_bytes']/1024/1024;
310+
311311
//* Website is over quota, we will disable it
312312
/*if( ($web_traffic_quota > 0 && $web_traffic > $web_traffic_quota) ||
313313
($client_traffic_quota > 0 && $web_traffic > $client_traffic_quota) ||
@@ -324,8 +324,8 @@ function setConfigVar( $filename, $varName, $varValue ) {
324324
}
325325
}
326326
}
327-
328-
327+
328+
329329
}
330330

331331

0 commit comments

Comments
 (0)