diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 5ebb669b61fa6b8c0a0b7307e0396b3cadfad0e8..dd7ce0d2975e09b8e03ebe7743be756dff2f8ffd 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -2161,7 +2161,7 @@ class installer_base { $root_cron_jobs = array( "* * * * * ".$install_dir."/server/server.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done", - "30 00 * * * ".$install_dir."/server/cron.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done" + "* * * * * ".$install_dir."/server/cron.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done" ); if ($conf['nginx']['installed'] == true) { diff --git a/install/sql/incremental/upd_0071.sql b/install/sql/incremental/upd_0071.sql new file mode 100644 index 0000000000000000000000000000000000000000..b4bafd851e9b57e3d772b08f3ab85736856256d2 --- /dev/null +++ b/install/sql/incremental/upd_0071.sql @@ -0,0 +1,7 @@ +ALTER TABLE `client` + ADD `limit_database_quota` int(11) NOT NULL default '-1' AFTER `limit_database`; +ALTER TABLE `client_template` + ADD `limit_database_quota` int(11) NOT NULL default '-1' AFTER `limit_database`; +ALTER TABLE `web_database` + ADD `database_quota` int(11) unsigned DEFAULT NULL AFTER `database_name_prefix`, + ADD `last_quota_notification` date NULL default NULL; diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index a64cb689d5f7df2be2468f4319739a172cc5461c..92370373af340f29296b99b1ca0a29f0a49f4783 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -214,6 +214,7 @@ CREATE TABLE `client` ( `default_dbserver` int(11) NOT NULL DEFAULT '1', `dns_servers` blob NOT NULL DEFAULT '', `limit_database` int(11) NOT NULL DEFAULT '-1', + `limit_database_quota` int(11) NOT NULL default '-1', `limit_cron` int(11) NOT NULL DEFAULT '0', `limit_cron_type` enum('url','chrooted','full') NOT NULL DEFAULT 'url', `limit_cron_frequency` int(11) NOT NULL DEFAULT '5', @@ -317,6 +318,7 @@ CREATE TABLE `client_template` ( `limit_dns_slave_zone` int(11) NOT NULL default '-1', `limit_dns_record` int(11) NOT NULL default '-1', `limit_database` int(11) NOT NULL default '-1', + `limit_database_quota` int(11) NOT NULL default '-1', `limit_cron` int(11) NOT NULL default '0', `limit_cron_type` enum('url','chrooted','full') NOT NULL default 'url', `limit_cron_frequency` int(11) NOT NULL default '5', @@ -1758,6 +1760,7 @@ CREATE TABLE `web_database` ( `type` varchar(16) NOT NULL DEFAULT 'y', `database_name` varchar(64) DEFAULT NULL, `database_name_prefix` varchar(50) NOT NULL default '', + `database_quota` int(11) unsigned DEFAULT NULL, `database_user_id` int(11) unsigned DEFAULT NULL, `database_ro_user_id` int(11) unsigned DEFAULT NULL, `database_charset` varchar(64) DEFAULT NULL, diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index 0d578e1582803cc2f9fe4c6f00b5ddeef3d11a4b..0822d20b4fd4bf9da68df07f1bf9a21e25187fbc 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -101,6 +101,8 @@ php_ini_check_minutes=1 overquota_notify_admin=y overquota_notify_client=y overquota_notify_freq=7 +overquota_db_notify_admin=y +overquota_db_notify_client=y overquota_notify_onok=n [dns] diff --git a/interface/lib/classes/tools_monitor.inc.php b/interface/lib/classes/tools_monitor.inc.php index fe316cee2e6292d26745209a330edb56a316a4db..db8c91ec2a83eb4ee2e8dc2a6128fef8fcddf565 100644 --- a/interface/lib/classes/tools_monitor.inc.php +++ b/interface/lib/classes/tools_monitor.inc.php @@ -124,32 +124,35 @@ class tools_monitor { $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'database_size' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); if(isset($record['data'])) { $data = unserialize($record['data']); - /* - Format the data - */ + //* format the data $html = '<div class="systemmonitor-state state-'.$record['state'].'"> <div class="systemmonitor-content icons32 ico-'.$record['state'].'"> - <table> - <thead> - <tr> + <table><thead><tr> <td>'.$app->lng("monitor_database_name_txt").'</td> <td>'.$app->lng("monitor_database_size_txt").'</td> <td>'.$app->lng("monitor_database_client_txt").'</td> + <td>'.$app->lng("monitor_database_domain_txt").'</td> </tr>'; foreach($data as $line) { $html .= '<tr>'; if ($line['size'] > 0) $line['size'] = $app->functions->formatBytes($line['size']); - $t=$app->db->queryOneRecord("SELECT username FROM client WHERE sys_groupid = ".$line['client_id']); - $line['client_id']=$t['username']; - unset($t); + + //* get the client + $line['client']=$app->db->queryOneRecord("SELECT client.username FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name='".$line['database_name']."'")['username']; + + //* get the domain + $line['domain']=$app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id=(SELECT parent_domain_id FROM web_database WHERE database_name='".$line['database_name']."')")['domain']; + + //* remove the sys_groupid from output + unset($line['sys_groupid']); + foreach ($line as $item) { $html .= '<td>' . $item . '</td>'; } $html .= '</tr></tmpl loop>'; } - $html .= '</tbody></table>'; - $html .= '</div></div>'; + $html .= '</tbody></table></div></div>'; } else { $html = '<p>'.$app->lng("no_data_database_size_txt").'</p>'; } diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index 5b270c6b29f324e5644e2b133653820eed4493d6..98337b95a05f267bdd079378d31fdbb0312ba642 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -688,6 +688,18 @@ $form["tabs"]['web'] = array( 'default' => 'y', 'value' => array(0 => 'n', 1 => 'y') ), + 'overquota_db_notify_admin' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'overquota_db_notify_client' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') + ), 'overquota_notify_freq' => array( 'datatype' => 'INTEGER', 'formtype' => 'TEXT', diff --git a/interface/web/admin/lib/lang/en_server_config.lng b/interface/web/admin/lib/lang/en_server_config.lng index 108437207d06013c8ddbb6391244105d4e61db0f..68f5e454fdeeb2bda5e5354050e966dd522b578f 100644 --- a/interface/web/admin/lib/lang/en_server_config.lng +++ b/interface/web/admin/lib/lang/en_server_config.lng @@ -197,4 +197,6 @@ $wb["v6_prefix_length"] = 'Prefix too long according to defined IPv6 '; $wb['backup_dir_is_mount_txt'] = 'Backup directory is a mount?'; $wb['backup_dir_mount_cmd_txt'] = 'Mount command, if backup directory not mounted'; $wb['backup_delete_txt'] = 'Delete backups on domain/website delete'; +$wb["overquota_db_notify_admin_txt"] = 'Send DB quota warnings to admin'; +$wb["overquota_db_notify_client_txt"] = 'Send DB quota warnings to client'; ?> diff --git a/interface/web/admin/templates/server_config_web_edit.htm b/interface/web/admin/templates/server_config_web_edit.htm index ece9d7ddabb86ac78e5b20e82e2dc102811e5dc8..d813952dfcae52a07ac267c5931f9181de97ca2b 100644 --- a/interface/web/admin/templates/server_config_web_edit.htm +++ b/interface/web/admin/templates/server_config_web_edit.htm @@ -125,6 +125,18 @@ {tmpl_var name='overquota_notify_client'} </div> </div> + <div class="ctrlHolder"> + <p class="label">{tmpl_var name='overquota_db_notify_admin_txt'}</p> + <div class="multiField"> + {tmpl_var name='overquota_db_notify_admin'} + </div> + </div> + <div class="ctrlHolder"> + <p class="label">{tmpl_var name='overquota_db_notify_client_txt'}</p> + <div class="multiField"> + {tmpl_var name='overquota_db_notify_client'} + </div> + </div> <div class="ctrlHolder"> <label for="overquota_notify_freq">{tmpl_var name='overquota_notify_freq_txt'}</label> <input name="overquota_notify_freq" id="overquota_notify_freq" value="{tmpl_var name='overquota_notify_freq'}" size="40" maxlength="255" type="text" class="textInput" /> {tmpl_var name='overquota_notify_freq_note_txt'} diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 1b7c57650f8cea159a0763c1859f076ddff75735..fb0fdbcd953d6e695f6a7662b5a0499b418784cd 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -1093,6 +1093,20 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'limit_database_quota' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_database_quota_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), 'limit_cron' => array ( 'datatype' => 'INTEGER', 'formtype' => 'TEXT', diff --git a/interface/web/client/form/client_template.tform.php b/interface/web/client/form/client_template.tform.php index f9d9f6b2c0d499d6c79a19dbe0487aa5bceac352..f55b501d374863dbe42b9be6576cb8bc8a2ff897 100644 --- a/interface/web/client/form/client_template.tform.php +++ b/interface/web/client/form/client_template.tform.php @@ -557,6 +557,20 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'limit_database_quota' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_database_quota_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), 'limit_cron' => array ( 'datatype' => 'INTEGER', 'formtype' => 'TEXT', diff --git a/interface/web/client/lib/lang/en_client.lng b/interface/web/client/lib/lang/en_client.lng index a9565a32e493a2718d4ae3d930dad4f39464a2ed..7e8dd6504a6392187965066ef4bb24130c45b22f 100644 --- a/interface/web/client/lib/lang/en_client.lng +++ b/interface/web/client/lib/lang/en_client.lng @@ -172,4 +172,6 @@ $wb['added_by_txt'] = 'Added by'; $wb['added_date_txt'] = 'Added date'; $wb['parent_client_id_txt'] = 'Client of reseller'; $wb['none_txt'] = 'none'; +$wb['limit_database_quota_txt'] = 'Database quota'; +$wb['limit_database_quota_error_notint'] = 'The database quota limit must be a number.'; ?> diff --git a/interface/web/client/lib/lang/en_client_template.lng b/interface/web/client/lib/lang/en_client_template.lng index 0eef4700bf0bb88c39a12d7b072debb9d418d0ee..3c6691dc2b4f2012cb77a707e36161ddd602393f 100644 --- a/interface/web/client/lib/lang/en_client_template.lng +++ b/interface/web/client/lib/lang/en_client_template.lng @@ -89,5 +89,7 @@ $wb['aps_limits_txt'] = 'APS Installer Limits'; $wb['limit_aps_txt'] = 'Max. number of APS instances'; $wb['limit_aps_error_notint'] = 'The APS instances limit must be a number.'; $wb['limit_domainmodule_txt'] = 'Domainmodule Limit'; -$wb['client_limits_txt'] = 'Client Limits' -?> \ No newline at end of file +$wb['client_limits_txt'] = 'Client Limits'; +$wb['limit_database_quota_txt'] = 'Database quota'; +$wb['limit_database_quota_error_notint'] = 'The database quota limit must be a number.'; +?> diff --git a/interface/web/client/templates/client_edit_limits.htm b/interface/web/client/templates/client_edit_limits.htm index c97e03f53e225366f0477ebb9f9cd85d0a9f51d8..01dae6405d04960ce96b8bfdbeb32cd8e7bf839c 100644 --- a/interface/web/client/templates/client_edit_limits.htm +++ b/interface/web/client/templates/client_edit_limits.htm @@ -229,6 +229,10 @@ <label for="limit_database">{tmpl_var name='limit_database_txt'}</label> <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" /> </div> + <div class="ctrlHolder"> + <label for="limit_database_quota">{tmpl_var name='limit_database_quota_txt'}</label> + <input name="limit_database_quota" id="limit_database_quota" value="{tmpl_var name='limit_database_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" /> MB + </div> </div> <div class="subsectiontoggle"><span></span>{tmpl_var name='cron_job_limits_txt'}<em></em></div> <div style="display:none;"> diff --git a/interface/web/client/templates/client_template_edit_limits.htm b/interface/web/client/templates/client_template_edit_limits.htm index 1eea39900407dba216fc2f6761236cbd7012316a..244014649261d77c27b67c41fa44fed12978de97 100644 --- a/interface/web/client/templates/client_template_edit_limits.htm +++ b/interface/web/client/templates/client_template_edit_limits.htm @@ -171,6 +171,10 @@ <label for="limit_database">{tmpl_var name='limit_database_txt'}</label> <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" /> </div> + <div class="ctrlHolder"> + <label for="limit_database_quota">{tmpl_var name='limit_database_quota_txt'}</label> + <input name="limit_database_quota" id="limit_database_quota" value="{tmpl_var name='limit_database_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" /> MB + </div> </div> <div class="subsectiontoggle"><span></span>{tmpl_var name='cron_job_limits_txt'}<em></em></div> <div style="display:none;"> @@ -247,4 +251,4 @@ </div> </div> -</div> \ No newline at end of file +</div> diff --git a/interface/web/dns/form/dns_dkim.tform.php b/interface/web/dns/form/dns_dkim.tform.php index 2da9b42f874cfa5e6d4772d80471df101f3ee932..bbc1214f2280768a0d21288689d10d125ee60097 100644 --- a/interface/web/dns/form/dns_dkim.tform.php +++ b/interface/web/dns/form/dns_dkim.tform.php @@ -116,6 +116,10 @@ $form["tabs"]['dns'] = array ( 'ttl' => array ( 'datatype' => 'INTEGER', 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'RANGE', + 'range' => '60:', + 'errmsg'=> 'ttl_range_error'), + ), 'default' => '86400', 'value' => '', 'width' => '10', diff --git a/interface/web/dns/lib/lang/ar_dns_dkim.lng b/interface/web/dns/lib/lang/ar_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/ar_dns_dkim.lng +++ b/interface/web/dns/lib/lang/ar_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/bg_dns_dkim.lng b/interface/web/dns/lib/lang/bg_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/bg_dns_dkim.lng +++ b/interface/web/dns/lib/lang/bg_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/br_dns_dkim.lng b/interface/web/dns/lib/lang/br_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/br_dns_dkim.lng +++ b/interface/web/dns/lib/lang/br_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/cz_dns_dkim.lng b/interface/web/dns/lib/lang/cz_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/cz_dns_dkim.lng +++ b/interface/web/dns/lib/lang/cz_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/de_dns_dkim.lng b/interface/web/dns/lib/lang/de_dns_dkim.lng index 550239de1261fa869ea79647dd8b86269e72205a..d1ba493584b93f4ba9e86514d66f77f67b19f89b 100644 --- a/interface/web/dns/lib/lang/de_dns_dkim.lng +++ b/interface/web/dns/lib/lang/de_dns_dkim.lng @@ -6,4 +6,5 @@ $wb["record_exists_txt"] = 'DNS-Eintrag bereits vorhanden'; $wb["dkim_disabled_txt"] = 'DKIM st fuer diese Domain nicht aktiv.'; $wb["limit_dns_record_txt"] = 'Die max. Anzahl von DNS Eintraegen fuer den Account ist erreicht.'; $wb["no_zone_perm"] = 'Fehlende Berechtigung zum Hinzufuegen eines Eintrags zur DNS-Zone.'; +$wb['ttl_range_error'] = 'Min. TTL time ist 60 Sekunden.'; ?> diff --git a/interface/web/dns/lib/lang/el_dns_dkim.lng b/interface/web/dns/lib/lang/el_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/el_dns_dkim.lng +++ b/interface/web/dns/lib/lang/el_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/en_dns_dkim.lng b/interface/web/dns/lib/lang/en_dns_dkim.lng index c24d401c979e3e29d91e501ba99c1165ac733c70..62025f8917612f544b5fd2bf88dfebc81f4d2110 100644 --- a/interface/web/dns/lib/lang/en_dns_dkim.lng +++ b/interface/web/dns/lib/lang/en_dns_dkim.lng @@ -6,4 +6,5 @@ $wb["record_exists_txt"] = 'DNS-Record already exists'; $wb["dkim_disabled_txt"] = 'DKIM disabled for this mail-domain'; $wb["limit_dns_record_txt"] = 'The max. number of DNS records for your account is reached.'; $wb["no_zone_perm"] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/es_dns_dkim.lng b/interface/web/dns/lib/lang/es_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/es_dns_dkim.lng +++ b/interface/web/dns/lib/lang/es_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/fi_dns_dkim.lng b/interface/web/dns/lib/lang/fi_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/fi_dns_dkim.lng +++ b/interface/web/dns/lib/lang/fi_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/fr_dns_dkim.lng b/interface/web/dns/lib/lang/fr_dns_dkim.lng index f64c89b8cd5672e9319b59f91a854bd164f17a45..6b2c6874c9deecd45e0e021a7df020262ce38205 100644 --- a/interface/web/dns/lib/lang/fr_dns_dkim.lng +++ b/interface/web/dns/lib/lang/fr_dns_dkim.lng @@ -5,4 +5,5 @@ $wb["active_txt"] = 'Actif'; $wb["record_exists_txt"] = 'L\'enregistrement DNS exist déjà '; $wb["limit_dns_record_txt"] = 'Le nombre max. d\'enregistrement DNS pour votre compte à été atteint.'; $wb["no_zone_perm"] = 'Vous n\'avez pas la permission d\'ajouter un enregistrement à cette Zone DNS.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/hr_dns_dkim.lng b/interface/web/dns/lib/lang/hr_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/hr_dns_dkim.lng +++ b/interface/web/dns/lib/lang/hr_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/hu_dns_dkim.lng b/interface/web/dns/lib/lang/hu_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/hu_dns_dkim.lng +++ b/interface/web/dns/lib/lang/hu_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/id_dns_dkim.lng b/interface/web/dns/lib/lang/id_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/id_dns_dkim.lng +++ b/interface/web/dns/lib/lang/id_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/it_dns_dkim.lng b/interface/web/dns/lib/lang/it_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/it_dns_dkim.lng +++ b/interface/web/dns/lib/lang/it_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/ja_dns_dkim.lng b/interface/web/dns/lib/lang/ja_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/ja_dns_dkim.lng +++ b/interface/web/dns/lib/lang/ja_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/nl_dns_dkim.lng b/interface/web/dns/lib/lang/nl_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/nl_dns_dkim.lng +++ b/interface/web/dns/lib/lang/nl_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/ru_dns_dkim.lng b/interface/web/dns/lib/lang/ru_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/ru_dns_dkim.lng +++ b/interface/web/dns/lib/lang/ru_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/se_dns_dkim.lng b/interface/web/dns/lib/lang/se_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/se_dns_dkim.lng +++ b/interface/web/dns/lib/lang/se_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/sk_dns_dkim.lng b/interface/web/dns/lib/lang/sk_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/sk_dns_dkim.lng +++ b/interface/web/dns/lib/lang/sk_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/dns/lib/lang/tr_dns_dkim.lng b/interface/web/dns/lib/lang/tr_dns_dkim.lng index 6ca7521495f7d4f7d87f549fa2b18f9fb66fb459..5ed8bfa416a7874b65075ef3e091bf75493736b7 100644 --- a/interface/web/dns/lib/lang/tr_dns_dkim.lng +++ b/interface/web/dns/lib/lang/tr_dns_dkim.lng @@ -6,4 +6,5 @@ $wb['record_exists_txt'] = 'DNS-Record already exists'; $wb['dkim_disabled_txt'] = 'DKIM disabled for this mail-domain'; $wb['limit_dns_record_txt'] = 'The max. number of DNS records for your account is reached.'; $wb['no_zone_perm'] = 'You do not have the permission to add a record to this DNS zone.'; +$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.'; ?> diff --git a/interface/web/sites/database_edit.php b/interface/web/sites/database_edit.php index 22493515bbffe9680c5cbfa250f8791f66dd3592..6ae8856ec5b92055c594deb14a8e4d178cc0aa1e 100644 --- a/interface/web/sites/database_edit.php +++ b/interface/web/sites/database_edit.php @@ -166,7 +166,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] != 'admin') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT db_servers, limit_database FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT db_servers, limit_database, limit_database_quota FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.groupid = $client_group_id"); // When the record is updated if($this->id > 0) { @@ -191,6 +191,20 @@ class page_action extends tform_actions { } } + // Check client quota + if ($client['limit_database_quota'] >= 0) { + $tmp = $app->db->queryOneRecord("SELECT sum(database_quota) as db_quota FROM web_database WHERE sys_groupid = $client_group_id"); + $db_quota = $tmp['db_quota']; + $new_db_quota = $app->functions->intval($this->dataRecord["database_quota"]); + if(($db_quota + $new_db_quota > $client['limit_database_quota']) || ($new_db_quota < 0 && $client['limit_database_quota'] >= 0)) { + $max_free_quota = floor($client['limit_database_quota'] - $db_quota); + if($max_free_quota < 0) $max_free_quota = 0; + $app->tform->errorMessage .= $app->tform->lng("limit_database_quota_free_txt").": ".$max_free_quota." MB<br>"; + $this->dataRecord['database_quota'] = $max_free_quota; + } + unset($tmp); + } + } } else { // check if client of database parent domain is client of db user! diff --git a/interface/web/sites/form/database.tform.php b/interface/web/sites/form/database.tform.php index 5207fd5b38cfda45795b90ffa73f4aefb625a047..995e020f94c90232e1c8b4a291b43b22f7ce8305 100644 --- a/interface/web/sites/form/database.tform.php +++ b/interface/web/sites/form/database.tform.php @@ -117,6 +117,20 @@ $form["tabs"]['database'] = array ( 'width' => '30', 'maxlength' => '25' ), + 'database_quota' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_database_quota_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), 'database_user_id' => array ( 'datatype' => 'INTEGER', 'formtype' => 'SELECT', diff --git a/interface/web/sites/lib/lang/en_database.lng b/interface/web/sites/lib/lang/en_database.lng index 521e8c40fad3bb0f8a2e556ee26f1bb1d5108a76..e29f5b6be5b2d1b831c6c4f529f3bed2b4a91b5d 100644 --- a/interface/web/sites/lib/lang/en_database.lng +++ b/interface/web/sites/lib/lang/en_database.lng @@ -43,4 +43,7 @@ $wb['globalsearch_noresults_text_txt'] = "No results."; $wb['globalsearch_noresults_limit_txt'] = "0 results"; $wb['globalsearch_searchfield_watermark_txt'] = "Search"; $wb['globalsearch_suggestions_text_txt'] = "Suggestions"; +$wb['limit_database_quota_txt'] = 'Database quota'; +$wb['limit_database_quota_error_notint'] = 'The database quota limit must be a number.'; +$wb['limit_database_quota_free_txt']='Max. available DB quota '; ?> diff --git a/interface/web/sites/templates/database_edit.htm b/interface/web/sites/templates/database_edit.htm index 6b7afc94b0b1e11ef89446ca84baef38f718a2fc..3e1489cf92990eb7d1a3f2ee5c62353e1caf4a88 100644 --- a/interface/web/sites/templates/database_edit.htm +++ b/interface/web/sites/templates/database_edit.htm @@ -62,6 +62,10 @@ <input name="database_name" id="database_name" value="{tmpl_var name='database_name'}" size="30" maxlength="255" type="text" class="textInput formLengthHalf" /> </tmpl_if> </div> + <div class="ctrlHolder"> + <label for="database_quota">{tmpl_var name='limit_database_quota_txt'}</label> + <input name="database_quota" id="database_quota" value="{tmpl_var name='limit_database_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" /> MB + </div> <div class="ctrlHolder"> <label for="database_user_id">{tmpl_var name='database_user_txt'}</label> <select name="database_user_id" id="database_user_id" class="selectInput"> @@ -149,4 +153,4 @@ searchFieldWatermark: '', resultBoxPosition: 'e' }); -</script> \ No newline at end of file +</script> diff --git a/server/conf/mail/db_quota_notification_de.txt b/server/conf/mail/db_quota_notification_de.txt new file mode 100644 index 0000000000000000000000000000000000000000..1405fc4f91db2358b05a31587552a3660714db8b --- /dev/null +++ b/server/conf/mail/db_quota_notification_de.txt @@ -0,0 +1,13 @@ +ME-Version: 1.0 +Content-type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit +From: {admin_mail} +Reply-To: {admin_mail} +Subject: Datenbank-Speicherhinweis + +Ihre Datenbank {database_name} hat den verfuegbaren Speicherplatz (nahezu) ausgeschoepft. + +Datenbank: {databbase_name} +Belegter Speicherplatz: {used} +Verfuegbarer Speicherplatz: {quota} +Belegter Speicherplatz in %: {ratio} diff --git a/server/conf/mail/db_quota_notification_en.txt b/server/conf/mail/db_quota_notification_en.txt new file mode 100644 index 0000000000000000000000000000000000000000..cd5d71604b6c3b65db1cd2768c2fd228c08bfdde --- /dev/null +++ b/server/conf/mail/db_quota_notification_en.txt @@ -0,0 +1,13 @@ +ME-Version: 1.0 +Content-type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit +From: {admin_mail} +Reply-To: {admin_mail} +Subject: Database quota notification + +The database {database_name} is near or over quota. + +Database: {databbase_name} +Used space: {used} +Quota: {quota} +Usage ratio: {ratio} diff --git a/server/conf/mail/db_quota_ok_notification_de.txt b/server/conf/mail/db_quota_ok_notification_de.txt new file mode 100644 index 0000000000000000000000000000000000000000..ad88ef1b432255c3f5fa3fe522966ce2e14f1637 --- /dev/null +++ b/server/conf/mail/db_quota_ok_notification_de.txt @@ -0,0 +1,13 @@ +ME-Version: 1.0 +Content-type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit +From: {admin_mail} +Reply-To: {admin_mail} +Subject: Datenbank-Speicherhinweis + +Der belegte Speicherplatz Ihrer Datenbank {database_name} ist wieder ok. + +Datenbank: {databbase_name} +Belegter Speicherplatz: {used} +Verfuegbarer Speicherplatz: {quota} +Belegter Speicherplatz in %: {ratio} diff --git a/server/conf/mail/db_quota_ok_notification_en.txt b/server/conf/mail/db_quota_ok_notification_en.txt new file mode 100644 index 0000000000000000000000000000000000000000..476a99988224624ec512fc94866c04db027e099f --- /dev/null +++ b/server/conf/mail/db_quota_ok_notification_en.txt @@ -0,0 +1,13 @@ +MIME-Version: 1.0 +Content-type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit +From: {admin_mail} +Reply-To: {admin_mail} +Subject: Database quota ok + +The database {database_name} is no longer near or over quota. + +Database: {database_name} +Used space: {used} +Quota: {quota} +Usage ratio: {ratio} diff --git a/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php b/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php index 3586649442444d1c0c8b95306ee59408b856d9ef..25f7448cbec87929786babe151db5e482cac60f6 100644 --- a/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php +++ b/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php @@ -145,7 +145,7 @@ class cronjob_monitor_clamav_log extends cronjob { //* Warn when clamav is outdated and main.cld update failed. if($clamav_outdated_warning == true && $clamav_bytecode_updated == false) { - $state = $this->_setState($state, 'info'); + $state = $this->_tools->_setState($state, 'info'); } $res = array(); diff --git a/server/lib/classes/cron.d/100-monitor_database_size.inc.php b/server/lib/classes/cron.d/100-monitor_database_size.inc.php index 6ec22d8b246beff97a9d0f0be24dc70d65b7e6fd..c03b82de026a620fa8b65234a925e70f2c7869ed 100644 --- a/server/lib/classes/cron.d/100-monitor_database_size.inc.php +++ b/server/lib/classes/cron.d/100-monitor_database_size.inc.php @@ -77,38 +77,39 @@ class cronjob_monitor_database_size extends cronjob { /** The state of the database-usage */ $state = 'ok'; - /** Fetch the data of all active databases into an array */ - $records = $app->db->queryAllRecords("SELECT database_name, sys_groupid FROM web_database WHERE server_id = $server_id AND active='y' GROUP BY sys_groupid, database_name ASC"); - if(is_array($records) && !empty($records)) { + /** Fetch the data of all databases into an array */ + $databases = $app->db->queryAllRecords("SELECT database_name, sys_groupid FROM web_database WHERE server_id = $server_id GROUP BY sys_groupid, database_name ASC"); + + if(is_array($databases) && !empty($databases)) { + $data = array(); - for ($i = 0; $i < sizeof($records); $i++) { - $data[$i]['name'] = $records[$i]['database_name']; - $data[$i]['size'] = $app->db->getDatabaseSize($data[$i]['name']); - $data[$i]['client_id'] = $records[$i]['sys_groupid']; + + for ($i = 0; $i < sizeof($databases); $i++) { + $data[$i]['database_name']= $databases[$i]['database_name']; + $data[$i]['size'] = $app->db->getDatabaseSize($databases[$i]['database_name']); + $data[$i]['sys_groupid'] = $databases[$i]['sys_groupid']; } - } - $res = array(); - $res['server_id'] = $server_id; - $res['type'] = $type; - $res['data'] = $data; - $res['state'] = $state; - - /* - * Insert the data into the database - */ - $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); - - /* The new data is written, now we can delete the old one */ - $this->_tools->delOldRecords($res['type'], $res['server_id']); + $res = array(); + $res['server_id'] = $server_id; + $res['type'] = $type; + $res['data'] = $data; + $res['state'] = $state; + + //* Insert the data into the database + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . + 'VALUES (' . + $res['server_id'] . ', ' . + "'" . $app->dbmaster->quote($res['type']) . "', " . + 'UNIX_TIMESTAMP(), ' . + "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . + "'" . $res['state'] . "'" . + ')'; + $app->dbmaster->query($sql); + + //* The new data is written, now we can delete the old one + $this->_tools->delOldRecords($res['type'], $res['server_id']); + } parent::onRunJob(); } diff --git a/server/lib/classes/cron.d/300-quota_notify.inc.php b/server/lib/classes/cron.d/300-quota_notify.inc.php index e8b64fae45c4f9e9f5500e098c696a203170e4b4..23808dc09744896bafbaa21bbe29376d2a37be89 100644 --- a/server/lib/classes/cron.d/300-quota_notify.inc.php +++ b/server/lib/classes/cron.d/300-quota_notify.inc.php @@ -463,7 +463,125 @@ class cronjob_quota_notify extends cronjob { } } + //###################################################################################################### + // send database quota warnings by email + //###################################################################################################### + + if ($app->dbmaster == $app->db) { + + $global_config = $app->getconf->get_global_config('mail'); + + //* get monitor-data + $tmp_rec = $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'database_size' ORDER BY created DESC"); + if(is_array($tmp_rec)) { + $monitor_data = array(); + foreach ($tmp_rec as $tmp_mon) { + $tmp_array = unserialize($app->db->unquote($tmp_mon['data'])); + if(is_array($tmp_array)) + foreach($tmp_array as $sys_groupid => $data) + $monitor_data[$data['sys_groupid']][] = $data; + } + //* remove duplicates from monitor-data + foreach($monitor_data as $_monitor_data) + $monitor_data[$_monitor_data[0]['sys_groupid']]=array_map("unserialize", array_unique(array_map("serialize", $_monitor_data))); + } + + //* get databases + $database_records = $app->db->queryAllRecords("SELECT database_id,sys_groupid,database_name,database_quota,last_quota_notification,DATEDIFF(CURDATE(), last_quota_notification) as `notified_before` FROM web_database;"); + + if(is_array($database_records) && !empty($database_records) && is_array($monitor_data) && !empty($monitor_data)) { + //* check database-quota + foreach($database_records as $rec) { + $database = $rec['database_name']; + $quota = $rec['database_quota'] * 1024 * 1024; + if (!is_numeric($quota)) break; + + foreach ($monitor_data as $cid) { + + foreach($cid_data as $monitor) { + + if ($monitor['database_name'] == $database) { + //* get the client + $client = $app->db->queryOneRecord("SELECT client.username, client.email FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name='".$database."'"); + + //* check quota + if ($quota > 0) $used_ratio = $monitor['size'] / $quota; + else $used_ratio = 0; + + //* send notifications only if 90% or more of the quota are used + if($used_ratio > 0.9) { + + //* reset notification date + if($rec['last_quota_notification']) $app->dbmaster->datalogUpdate('web_database', "last_quota_notification = NULL", 'database_id', $rec['database_id']); + + $app->dbmaster->datalogUpdate('web_database', "last_quota_notification = CURDATE()", 'database_id', $rec['database_id']); + + // send notification - everything ok again + if($rec['last_quota_notification'] && $web_config['overquota_notify_onok'] == 'y' && ($web_config['overquota_db_notify_admin'] == 'y' || $web_config['overquota_db_notify_client'] == 'y')) { + $placeholders = array( + '{database_name}' => $rec['database_name'], + '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), + '{used}' => $app->functions->formatBytes($monitor['size']), + '{quota}' => $quota.' MB', + '{ratio}' => number_format($used_ratio * 100, 2, '.', '').'%' + ); + + $recipients = array(); + + //* send email to admin + if($global_config['admin_mail'] != '' && $web_config['overquota_db_notify_admin'] == 'y') + $recipients[] = $global_config['admin_mail']; + //* Send email to client + if($web_config['overquota_db_notify_client'] == 'y' && $client['email'] != '') + $recipients[] = $client['email']; + + send_notification_email('db_quota_ok_notification', $placeholders, $recipients); + + } + + } + + //* could a notification be sent? + $send_notification = false; + if(!$rec['last_quota_notification']) $send_notification = true; //* not yet notified + elseif($web_config['overquota_notify_freq'] > 0 && $rec['notified_before'] >= $web_config['overquota_notify_freq']) $send_notification = true; + + //* Send quota notifications + if(($web_config['overquota_db_notify_admin'] == 'y' || $web_config['overquota_db_notify_client'] == 'y') && $send_notification == true) { + $app->dbmaster->datalogUpdate('web_database', "last_quota_notification = CURDATE()", 'database_id', $rec['database_id']); + $placeholders = array( + '{database_name}' => $rec['database_name'], + '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), + '{used}' => $app->functions->formatBytes($monitor['size']), + '{quota}' => $quota.' MB', + '{ratio}' => number_format($used_ratio * 100, 2, '.', '').'%' + ); + + $recipients = array(); + + //* send email to admin + if($global_config['admin_mail'] != '' && $web_config['overquota_db_notify_admin'] == 'y') + $recipients[] = $global_config['admin_mail']; + + //* Send email to client + if($web_config['overquota_db_notify_client'] == 'y' && $client['email'] != '') + $recipients[] = $client['email']; + + send_notification_email('db_quota_notification', $placeholders, $recipients); + + } + + } + + } + + } + + } + + } + } parent::onRunJob(); } diff --git a/server/lib/classes/cron.d/500-backup_mail.inc.php b/server/lib/classes/cron.d/500-backup_mail.inc.php index 2197251e91a3007d3b41811945401f128613ad18..6c2cb3182841a98c5c707e602f3394a4b0c785f9 100644 --- a/server/lib/classes/cron.d/500-backup_mail.inc.php +++ b/server/lib/classes/cron.d/500-backup_mail.inc.php @@ -27,7 +27,7 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -class cronjob_backup extends cronjob { +class cronjob_backup_mail extends cronjob { // job schedule protected $_schedule = '0 0 * * *';