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:
Michael Kaufmann (d00p)
2016-07-14 07:58:56 +02:00
parent 83f40401be
commit 1c369e5503
5 changed files with 456 additions and 447 deletions

View File

@@ -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',

View File

@@ -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';

View File

@@ -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';

View File

@@ -15,6 +15,8 @@
* *
*/ */
if ((int)Settings::Get('system.report_webmax') > 0)
{
/** /**
* report about diskusage for customers * report about diskusage for customers
*/ */
@@ -206,3 +208,4 @@ 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

View File

@@ -34,8 +34,9 @@ if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) {
} }
} }
if ((int)Settings::Get('system.report_trafficmax') > 0)
{
// Warn the customers at xx% traffic-usage // Warn the customers at xx% traffic-usage
$result_stmt = Database::prepare(" $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`,
@@ -317,6 +318,7 @@ 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';