add possibility to disable web or traffic cron by setting the max-percentage value to 0, fixes #1639
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -145,7 +145,7 @@ return array(
|
|||||||
'settinggroup' => 'system',
|
'settinggroup' => 'system',
|
||||||
'varname' => 'report_webmax',
|
'varname' => 'report_webmax',
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
'int_min' => 1,
|
'int_min' => 0,
|
||||||
'int_max' => 150,
|
'int_max' => 150,
|
||||||
'default' => 90,
|
'default' => 90,
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField',
|
||||||
@@ -155,7 +155,7 @@ return array(
|
|||||||
'settinggroup' => 'system',
|
'settinggroup' => 'system',
|
||||||
'varname' => 'report_trafficmax',
|
'varname' => 'report_trafficmax',
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
'int_min' => 1,
|
'int_min' => 0,
|
||||||
'int_max' => 150,
|
'int_max' => 150,
|
||||||
'default' => 90,
|
'default' => 90,
|
||||||
'save_method' => 'storeSettingField',
|
'save_method' => 'storeSettingField',
|
||||||
|
|||||||
@@ -1314,8 +1314,10 @@ $lng['phpfpm']['ownvhost']['description'] = 'If enabled, Froxlor will also be ru
|
|||||||
// ADDED IN FROXLOR 0.9.17
|
// ADDED IN FROXLOR 0.9.17
|
||||||
$lng['crondesc']['cron_usage_report'] = 'Web- and traffic-reports';
|
$lng['crondesc']['cron_usage_report'] = 'Web- and traffic-reports';
|
||||||
$lng['serversettings']['report']['report'] = 'Enable sending of reports about web- and traffic-usage';
|
$lng['serversettings']['report']['report'] = 'Enable sending of reports about web- and traffic-usage';
|
||||||
$lng['serversettings']['report']['webmax'] = 'Warning-level in percent for webspace';
|
$lng['serversettings']['report']['webmax']['title'] = 'Warning-level in percent for webspace';
|
||||||
$lng['serversettings']['report']['trafficmax'] = 'Warning-level in percent for traffic';
|
$lng['serversettings']['report']['webmax']['description'] = 'Valid values are 0 up to 150. Setting this value to 0 disables this report.';
|
||||||
|
$lng['serversettings']['report']['trafficmax']['title'] = 'Warning-level in percent for traffic';
|
||||||
|
$lng['serversettings']['report']['trafficmax']['description'] = 'Valid values are 0 up to 150. Setting this value to 0 disables this report.';
|
||||||
$lng['mails']['trafficmaxpercent']['mailbody'] = 'Dear {NAME},\n\nyou used {TRAFFICUSED} MB of your available {TRAFFIC} MB of traffic.\nThis is more than {MAX_PERCENT}%.\n\nYours sincerely, your administrator';
|
$lng['mails']['trafficmaxpercent']['mailbody'] = 'Dear {NAME},\n\nyou used {TRAFFICUSED} MB of your available {TRAFFIC} MB of traffic.\nThis is more than {MAX_PERCENT}%.\n\nYours sincerely, your administrator';
|
||||||
$lng['mails']['trafficmaxpercent']['subject'] = 'Reaching your traffic limit';
|
$lng['mails']['trafficmaxpercent']['subject'] = 'Reaching your traffic limit';
|
||||||
$lng['admin']['templates']['trafficmaxpercent'] = 'Notification mail for customers when given maximum of percent of traffic is exhausted';
|
$lng['admin']['templates']['trafficmaxpercent'] = 'Notification mail for customers when given maximum of percent of traffic is exhausted';
|
||||||
|
|||||||
@@ -1293,8 +1293,10 @@ $lng['phpfpm']['ownvhost']['description'] = 'Wenn verwendet, wird Froxlor selbst
|
|||||||
// ADDED IN FROXLOR 0.9.17
|
// ADDED IN FROXLOR 0.9.17
|
||||||
$lng['crondesc']['cron_usage_report'] = 'Webspace- und Trafficreport';
|
$lng['crondesc']['cron_usage_report'] = 'Webspace- und Trafficreport';
|
||||||
$lng['serversettings']['report']['report'] = 'Aktiviere das Senden von Reports über Webspace- und Trafficverbrauch';
|
$lng['serversettings']['report']['report'] = 'Aktiviere das Senden von Reports über Webspace- und Trafficverbrauch';
|
||||||
$lng['serversettings']['report']['webmax'] = 'Warn-Level in Prozent für Webspace';
|
$lng['serversettings']['report']['webmax']['title'] = 'Warn-Level in Prozent für Webspace';
|
||||||
$lng['serversettings']['report']['trafficmax'] = 'Warn-Level in Prozent für Traffic';
|
$lng['serversettings']['report']['webmax']['description'] = 'Gültige Werte sind von 0 bis 150. Der Wert 0 deaktiviert diesen Report.';
|
||||||
|
$lng['serversettings']['report']['trafficmax']['title'] = 'Warn-Level in Prozent für Traffic';
|
||||||
|
$lng['serversettings']['report']['trafficmax']['description'] = 'Gültige Werte sind von 0 bis 150. Der Wert 0 deaktiviert diesen Report.';
|
||||||
$lng['mails']['trafficmaxpercent']['mailbody'] = 'Sehr geehrte(r) {NAME},\n\nSie haben bereits {TRAFFICUSED} MB von Ihren insgesamt {TRAFFIC} MB Traffic verbraucht.\nDies sind mehr als {MAX_PERCENT}%.\n\nVielen Dank,\nIhr Administrator';
|
$lng['mails']['trafficmaxpercent']['mailbody'] = 'Sehr geehrte(r) {NAME},\n\nSie haben bereits {TRAFFICUSED} MB von Ihren insgesamt {TRAFFIC} MB Traffic verbraucht.\nDies sind mehr als {MAX_PERCENT}%.\n\nVielen Dank,\nIhr Administrator';
|
||||||
$lng['mails']['trafficmaxpercent']['subject'] = 'Sie erreichen bald Ihr Traffic-Limit';
|
$lng['mails']['trafficmaxpercent']['subject'] = 'Sie erreichen bald Ihr Traffic-Limit';
|
||||||
$lng['admin']['templates']['trafficmaxpercent'] = 'Hinweismail für Kunden, wenn sie die angegebenen Prozent des Traffics verbraucht haben';
|
$lng['admin']['templates']['trafficmaxpercent'] = 'Hinweismail für Kunden, wenn sie die angegebenen Prozent des Traffics verbraucht haben';
|
||||||
|
|||||||
@@ -15,10 +15,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
if ((int)Settings::Get('system.report_webmax') > 0)
|
||||||
|
{
|
||||||
|
/**
|
||||||
* report about diskusage for customers
|
* report about diskusage for customers
|
||||||
*/
|
*/
|
||||||
$result_stmt = Database::query("
|
$result_stmt = Database::query("
|
||||||
SELECT `c`.`customerid`, `c`.`adminid`, `c`.`name`, `c`.`firstname`,
|
SELECT `c`.`customerid`, `c`.`adminid`, `c`.`name`, `c`.`firstname`,
|
||||||
`c`.`company`, `c`.`diskspace`, `c`.`diskspace_used`, `c`.`email`, `c`.`def_language`,
|
`c`.`company`, `c`.`diskspace`, `c`.`diskspace_used`, `c`.`email`, `c`.`def_language`,
|
||||||
`a`.`name` AS `adminname`, `a`.`email` AS `adminmail`
|
`a`.`name` AS `adminname`, `a`.`email` AS `adminmail`
|
||||||
@@ -26,9 +28,9 @@ $result_stmt = Database::query("
|
|||||||
LEFT JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`
|
LEFT JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`
|
||||||
ON `a`.`adminid` = `c`.`adminid`
|
ON `a`.`adminid` = `c`.`adminid`
|
||||||
WHERE `c`.`diskspace` > '0' AND `c`.`reportsent` <> '2'
|
WHERE `c`.`diskspace` > '0' AND `c`.`reportsent` <> '2'
|
||||||
");
|
");
|
||||||
|
|
||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
if (isset($row['diskspace'])
|
if (isset($row['diskspace'])
|
||||||
&& $row['diskspace_used'] != null
|
&& $row['diskspace_used'] != null
|
||||||
@@ -115,16 +117,16 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|||||||
");
|
");
|
||||||
Database::pexecute($upd_stmt, array('customerid' => $row['customerid']));
|
Database::pexecute($upd_stmt, array('customerid' => $row['customerid']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* report about diskusage for admins/reseller
|
* report about diskusage for admins/reseller
|
||||||
*/
|
*/
|
||||||
$result_stmt = Database::query("
|
$result_stmt = Database::query("
|
||||||
SELECT `a`.* FROM `" . TABLE_PANEL_ADMINS . "` `a` WHERE `a`.`reportsent` <> '2'
|
SELECT `a`.* FROM `" . TABLE_PANEL_ADMINS . "` `a` WHERE `a`.`reportsent` <> '2'
|
||||||
");
|
");
|
||||||
|
|
||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
if (isset($row['diskspace'])
|
if (isset($row['diskspace'])
|
||||||
&& $row['diskspace_used'] != null
|
&& $row['diskspace_used'] != null
|
||||||
@@ -205,4 +207,5 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|||||||
");
|
");
|
||||||
Database::pexecute($upd_stmt, array('adminid' => $row['adminid']));
|
Database::pexecute($upd_stmt, array('adminid' => $row['adminid']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} // webmax > 0
|
||||||
|
|||||||
@@ -34,9 +34,10 @@ if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn the customers at xx% traffic-usage
|
if ((int)Settings::Get('system.report_trafficmax') > 0)
|
||||||
|
{
|
||||||
$result_stmt = Database::prepare("
|
// Warn the customers at xx% traffic-usage
|
||||||
|
$result_stmt = Database::prepare("
|
||||||
SELECT `c`.`customerid`, `c`.`adminid`, `c`.`name`, `c`.`firstname`,
|
SELECT `c`.`customerid`, `c`.`adminid`, `c`.`name`, `c`.`firstname`,
|
||||||
`c`.`company`, `c`.`traffic`, `c`.`email`, `c`.`def_language`,
|
`c`.`company`, `c`.`traffic`, `c`.`email`, `c`.`def_language`,
|
||||||
`a`.`name` AS `adminname`, `a`.`email` AS `adminmail`,
|
`a`.`name` AS `adminname`, `a`.`email` AS `adminmail`,
|
||||||
@@ -47,15 +48,15 @@ $result_stmt = Database::prepare("
|
|||||||
FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c`
|
FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c`
|
||||||
LEFT JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`
|
LEFT JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`
|
||||||
ON `a`.`adminid` = `c`.`adminid` WHERE `c`.`reportsent` <> '1'
|
ON `a`.`adminid` = `c`.`adminid` WHERE `c`.`reportsent` <> '1'
|
||||||
");
|
");
|
||||||
|
|
||||||
$result_data = array(
|
$result_data = array(
|
||||||
'year' => date("Y", $yesterday),
|
'year' => date("Y", $yesterday),
|
||||||
'month' => date("m", $yesterday)
|
'month' => date("m", $yesterday)
|
||||||
);
|
);
|
||||||
Database::pexecute($result_stmt, $result_data);
|
Database::pexecute($result_stmt, $result_data);
|
||||||
|
|
||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
if (isset($row['traffic'])
|
if (isset($row['traffic'])
|
||||||
&& $row['traffic'] > 0
|
&& $row['traffic'] > 0
|
||||||
@@ -141,25 +142,25 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|||||||
");
|
");
|
||||||
Database::pexecute($upd_stmt, array('customerid' => $row['customerid']));
|
Database::pexecute($upd_stmt, array('customerid' => $row['customerid']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn the admins at xx% traffic-usage
|
// Warn the admins at xx% traffic-usage
|
||||||
$result_stmt = Database::prepare("
|
$result_stmt = Database::prepare("
|
||||||
SELECT `a`.*,
|
SELECT `a`.*,
|
||||||
(SELECT SUM(`t`.`http` + `t`.`ftp_up` + `t`.`ftp_down` + `t`.`mail`)
|
(SELECT SUM(`t`.`http` + `t`.`ftp_up` + `t`.`ftp_down` + `t`.`mail`)
|
||||||
FROM `" . TABLE_PANEL_TRAFFIC_ADMINS . "` `t`
|
FROM `" . TABLE_PANEL_TRAFFIC_ADMINS . "` `t`
|
||||||
WHERE `t`.`adminid` = `a`.`adminid` AND `t`.`year` = :year AND `t`.`month` = :month
|
WHERE `t`.`adminid` = `a`.`adminid` AND `t`.`year` = :year AND `t`.`month` = :month
|
||||||
) as `traffic_used_total`
|
) as `traffic_used_total`
|
||||||
FROM `" . TABLE_PANEL_ADMINS . "` `a` WHERE `a`.`reportsent` = '0'
|
FROM `" . TABLE_PANEL_ADMINS . "` `a` WHERE `a`.`reportsent` = '0'
|
||||||
");
|
");
|
||||||
|
|
||||||
$result_data = array(
|
$result_data = array(
|
||||||
'year' => date("Y", $yesterday),
|
'year' => date("Y", $yesterday),
|
||||||
'month' => date("m", $yesterday)
|
'month' => date("m", $yesterday)
|
||||||
);
|
);
|
||||||
Database::pexecute($result_stmt, $result_data);
|
Database::pexecute($result_stmt, $result_data);
|
||||||
|
|
||||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
|
||||||
if (isset($row['traffic'])
|
if (isset($row['traffic'])
|
||||||
&& $row['traffic'] > 0
|
&& $row['traffic'] > 0
|
||||||
@@ -316,7 +317,8 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|||||||
|
|
||||||
$mail->ClearAddresses();
|
$mail->ClearAddresses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} // trafficmax > 0
|
||||||
|
|
||||||
// include diskspace-usage report, #466
|
// include diskspace-usage report, #466
|
||||||
include dirname(__FILE__).'/cron_usage.inc.diskspace.php';
|
include dirname(__FILE__).'/cron_usage.inc.diskspace.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user