Skip to content

Commit 5d74d30

Browse files
committed
Merge branch 'develop' of git.ispconfig.org:ispconfig/ispconfig3 into develop
2 parents d376b4e + fc43e05 commit 5d74d30

File tree

12 files changed

+262
-77
lines changed

12 files changed

+262
-77
lines changed

install/lib/installer_base.lib.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ public function detect_ips(){
493493
0,
494494
?,
495495
?,
496-
"y",
496+
"n",
497497
"80,443"
498498
)', $conf['server_id'], $ip_type, $line);
499499
$server_ip_id = $this->dbmaster->insertID();
@@ -512,7 +512,7 @@ public function detect_ips(){
512512
0,
513513
?,
514514
?,
515-
"y",
515+
"n",
516516
"80,443"
517517
)', $server_ip_id, $conf['server_id'], $ip_type, $line);
518518
} else {
@@ -530,7 +530,7 @@ public function detect_ips(){
530530
0,
531531
?,
532532
?,
533-
"y",
533+
"n",
534534
"80,443"
535535
)', $conf['server_id'], $ip_type, $line);
536536
}
@@ -666,6 +666,14 @@ public function grant_master_database_rights($verbose = false) {
666666
$this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
667667
}
668668

669+
$query = "GRANT SELECT ON ?? TO ?@?";
670+
if ($verbose){
671+
echo $query ."\n";
672+
}
673+
if(!$this->dbmaster->query($query, $value['db'] . '.web_database', $value['user'], $host)) {
674+
$this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
675+
}
676+
669677
$query = "GRANT SELECT ON ?? TO ?@?";
670678
if ($verbose){
671679
echo $query ."\n";

interface/lib/classes/aps_guicontroller.inc.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function getMainDomain($domain) {
5353
if (substr($domain, 0, 4) == 'www.') $domain = substr($domain, 4);
5454
return $domain;
5555
}
56-
56+
5757

5858
/**
5959
* Reads in a package metadata file and registers it's namespaces
@@ -220,7 +220,7 @@ public function isValidInstanceID($id, $client_id, $is_admin = false)
220220
$params[] = $client_id;
221221
}
222222
$params[] = $id;
223-
223+
224224
$result = $app->db->queryOneRecord('SELECT id FROM aps_instances WHERE '.$sql_ext.' id = ?', true, $params);
225225
if(!$result) return false;
226226

@@ -229,18 +229,18 @@ public function isValidInstanceID($id, $client_id, $is_admin = false)
229229

230230
public function createDatabaseForPackageInstance(&$settings, $websrv) {
231231
global $app;
232-
232+
233233
$app->uses('tools_sites');
234-
234+
235235
$global_config = $app->getconf->get_global_config('sites');
236-
236+
237237
$tmp = array();
238238
$tmp['parent_domain_id'] = $websrv['domain_id'];
239239
$tmp['sys_groupid'] = $websrv['sys_groupid'];
240240
$dbname_prefix = $app->tools_sites->replacePrefix($global_config['dbname_prefix'], $tmp);
241241
$dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $tmp);
242242
unset($tmp);
243-
243+
244244
// get information if the webserver is a db server, too
245245
$web_server = $app->db->queryOneRecord("SELECT server_id,server_name,db_server FROM server WHERE server_id = ?", $websrv['server_id']);
246246
if($web_server['db_server'] == 1) {
@@ -276,14 +276,14 @@ public function createDatabaseForPackageInstance(&$settings, $websrv) {
276276
* although this does not present any error message to the user.
277277
*/
278278
return false;
279-
279+
280280
/*$mysql_db_server_id = $websrv['server_id'];
281281
$settings['main_database_host'] = 'localhost';
282282
$mysql_db_remote_access = 'n';
283283
$mysql_db_remote_ips = '';*/
284284
}
285285
}
286-
286+
287287
if (empty($settings['main_database_name'])) {
288288
//* Find a free db name for the app
289289
for($n = 1; $n <= 1000; $n++) {
@@ -302,7 +302,7 @@ public function createDatabaseForPackageInstance(&$settings, $websrv) {
302302
}
303303
$settings['main_database_login'] = $mysql_db_user;
304304
}
305-
305+
306306
//* Create the mysql database user if not existing
307307
$tmp = $app->db->queryOneRecord("SELECT database_user_id FROM web_database_user WHERE database_user = ?", $settings['main_database_login']);
308308
if(!$tmp) {
@@ -320,7 +320,7 @@ public function createDatabaseForPackageInstance(&$settings, $websrv) {
320320
$mysql_db_user_id = $app->db->datalogInsert('web_database_user', $insert_data, 'database_user_id');
321321
}
322322
else $mysql_db_user_id = $tmp['database_user_id'];
323-
323+
324324
//* Create the mysql database if not existing
325325
$tmp = $app->db->queryOneRecord("SELECT count(database_id) as number FROM web_database WHERE database_name = ?", $settings['main_database_name']);
326326
if($tmp['number'] == 0) {
@@ -340,17 +340,15 @@ public function createDatabaseForPackageInstance(&$settings, $websrv) {
340340
"remote_access" => $mysql_db_remote_access,
341341
"remote_ips" => $mysql_db_remote_ips,
342342
"backup_copies" => $websrv['backup_copies'],
343-
"backup_format_web" => $websrv['backup_format_web'],
344-
"backup_format_db" => $websrv['backup_format_db'],
345-
"active" => 'y',
343+
"active" => 'y',
346344
"backup_interval" => $websrv['backup_interval']
347345
);
348346
$app->db->datalogInsert('web_database', $insert_data, 'database_id');
349347
}
350-
348+
351349
return true;
352350
}
353-
351+
354352
/**
355353
* Creates a new database record for the package instance and
356354
* an install task
@@ -398,7 +396,7 @@ public function createPackageInstance($settings, $packageid)
398396
// mysql-database-name is updated inside if not set already
399397
if (!$this->createDatabaseForPackageInstance($settings, $websrv)) return false;
400398
}
401-
399+
402400
//* Insert new package instance
403401
$insert_data = array(
404402
"sys_userid" => $websrv['sys_userid'],
@@ -428,7 +426,7 @@ public function createPackageInstance($settings, $packageid)
428426

429427
//* Set package status to install afetr we inserted the settings
430428
$app->db->datalogUpdate('aps_instances', array("instance_status" => INSTANCE_INSTALL), 'id', $InstanceID);
431-
429+
432430
return $InstanceID;
433431
}
434432

@@ -446,7 +444,7 @@ public function deleteInstance($instanceid, $keepdatabase = false)
446444
$sql = "SELECT web_database.database_id as database_id, web_database.database_user_id as `database_user_id` FROM aps_instances_settings, web_database WHERE aps_instances_settings.value = web_database.database_name AND aps_instances_settings.name = 'main_database_name' AND aps_instances_settings.instance_id = ? LIMIT 0,1";
447445
$tmp = $app->db->queryOneRecord($sql, $instanceid);
448446
if($tmp['database_id'] > 0) $app->db->datalogDelete('web_database', 'database_id', $tmp['database_id']);
449-
447+
450448
$database_user = $tmp['database_user_id'];
451449
$tmp = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `database_user_id` = ? OR `database_ro_user_id` = ?", $database_user, $database_user);
452450
if($tmp['cnt'] < 1) $app->db->datalogDelete('web_database_user', 'database_user_id', $database_user);
@@ -685,7 +683,7 @@ public function validateInstallerInput($postinput, $pkg_details, $domains, $sett
685683
if (isset($postinput['main_database_host'])) $input['main_database_host'] = $postinput['main_database_host'];
686684
if (isset($postinput['main_database_name'])) $input['main_database_name'] = $postinput['main_database_name'];
687685
if (isset($postinput['main_database_login'])) $input['main_database_login'] = $postinput['main_database_login'];
688-
686+
689687
if(isset($postinput['main_database_password']))
690688
{
691689
if($postinput['main_database_password'] == '') $error[] = $app->lng('error_no_database_pw');

interface/lib/classes/plugin_backuplist.inc.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,22 @@ protected function makeBackup(&$message, &$error, $wb)
5656
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = ? AND action_param = ?";
5757
$tmp = $app->db->queryOneRecord($sql, $action_type, $domain_id);
5858
if ($tmp['number'] == 0) {
59-
$server_id = $this->form->dataRecord['server_id'];
59+
if($action_type === 'backup_database') {
60+
// get all server ids of databases for this domain
61+
$sql = 'SELECT `server_id` FROM `web_database` WHERE `parent_domain_id` = ?';
62+
$result = $app->db->query($sql, $domain_id);
63+
while(($cur = $result->get())) {
64+
$server_id = $cur['server_id'];
65+
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) VALUES (?, UNIX_TIMESTAMP(), ?, ?, 'pending', '')";
66+
$app->db->query($sql, $server_id, $action_type, $domain_id);
67+
}
68+
$result->free();
69+
} else {
70+
$server_id = $this->form->dataRecord['server_id'];
71+
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) VALUES (?, UNIX_TIMESTAMP(), ?, ?, 'pending', '')";
72+
$app->db->query($sql, $server_id, $action_type, $domain_id);
73+
}
6074
$message .= $wb['backup_info_txt'];
61-
$sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) VALUES (?, UNIX_TIMESTAMP(), ?, ?, 'pending', '')";
62-
$app->db->query($sql, $server_id, $action_type, $domain_id);
6375
} else {
6476
$error .= $wb['backup_pending_txt'];
6577
}
@@ -193,10 +205,10 @@ function onShow() {
193205
$rec['backup_encrypted'] = empty($rec['backup_password']) ? $wb["no_txt"] : $wb["yes_txt"];
194206
$backup_manual_prefix = 'manual-';
195207
$rec['backup_job'] = (substr($rec['filename'], 0, strlen($backup_manual_prefix)) == $backup_manual_prefix) ? $wb["backup_job_manual_txt"] : $wb["backup_job_auto_txt"];
196-
208+
197209
$rec['download_available'] = true;
198210
if($rec['server_id'] != $web['server_id']) $rec['download_available'] = false;
199-
211+
200212
if($rec['filesize'] > 0){
201213
$rec['filesize'] = $app->functions->currency_format($rec['filesize']/(1024*1024), 'client').' MB';
202214
}

interface/lib/classes/tform_actions.inc.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ function onUpdate() {
141141
$app->tform->datalogSave('UPDATE', $this->id, $this->oldDataRecord, $new_data_record);
142142
unset($new_data_record);
143143
unset($old_data_record);
144+
145+
$this->onAfterDatalogSave();
144146
}
145147

146148
if($_REQUEST["next_tab"] == '') {
@@ -222,6 +224,7 @@ function onInsert() {
222224
$new_data_record = $app->tform->getDataRecord($this->id);
223225
$app->tform->datalogSave('INSERT', $this->id, array(), $new_data_record);
224226
unset($new_data_record);
227+
$this->onAfterDatalogSave(true);
225228
}
226229

227230

@@ -264,21 +267,19 @@ function onInsertSave($sql) {
264267
}
265268

266269
function onBeforeUpdate() {
267-
global $app, $conf;
268270
}
269271

270272
function onBeforeInsert() {
271-
global $app, $conf;
272273
}
273274

274275
function onAfterUpdate() {
275-
global $app, $conf;
276276
}
277277

278278
function onAfterInsert() {
279-
global $app, $conf;
280279
}
281280

281+
function onAfterDatalogSave($insert = false) {
282+
}
282283

283284
/**
284285
* Function called on data insert or update error
@@ -297,7 +298,7 @@ function onError() {
297298
*/
298299
function onDelete() {
299300
global $app, $conf, $list_def_file, $tform_def_file;
300-
301+
301302
// Check CSRF Token
302303
$app->auth->csrf_token_check('GET');
303304

interface/web/mail/spamfilter_policy_edit.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
$app->load('tform_actions');
5050

5151
class page_action extends tform_actions {
52-
52+
53+
private $record_has_changed = false;
54+
5355
function onShowNew() {
5456
global $app;
5557

@@ -87,38 +89,40 @@ function onSubmit() {
8789

8890
parent::onSubmit();
8991
}
90-
92+
9193
function onAfterUpdate() {
92-
global $app;
93-
94-
$record_has_changed = false;
94+
$this->record_has_changed = false;
9595
foreach($this->dataRecord as $key => $val) {
9696
if(isset($this->oldDataRecord[$key]) && @$this->oldDataRecord[$key] != $val) {
9797
// Record has changed
98-
$record_has_changed = true;
98+
$this->record_has_changed = true;
9999
}
100100
}
101+
}
101102

102-
if($record_has_changed){
103+
function onAfterDatalogSave($insert = false) {
104+
global $app;
105+
106+
if(!$insert && $this->record_has_changed){
103107
$spamfilter_users = $app->db->queryAllRecords("SELECT * FROM spamfilter_users WHERE policy_id = ?", intval($this->id));
104108

105109
if(is_array($spamfilter_users) && !empty($spamfilter_users)){
106110
foreach($spamfilter_users as $spamfilter_user){
107111
$app->db->datalogUpdate('spamfilter_users', $spamfilter_user, 'id', $spamfilter_user["id"], true);
108-
112+
109113
// check if this is an email domain
110114
if(substr($spamfilter_user['email'],0,1) == '@') {
111115
$domain = substr($spamfilter_user['email'],1);
112116
$forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source LIKE ? OR destination LIKE ?", "%@" . $domain, "%@" . $domain);
113-
117+
114118
// Force-update aliases and forwards
115119
if(is_array($forwardings)) {
116120
foreach($forwardings as $rec) {
117121
$app->db->datalogUpdate('mail_forwarding', array("source" => $rec['source']), 'forwarding_id', $rec['forwarding_id'],true);
118122
}
119123
}
120124
}
121-
125+
122126
}
123127
}
124128
}

interface/web/sites/database_edit.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ function onSubmit() {
211211
unset($global_config);
212212
unset($dbname_prefix);
213213
}
214-
214+
215215
//* ensure that quota value is not 0 when quota is set for client
216216
if($client['limit_database_quota'] > 0 && isset($_POST["database_quota"]) && $_POST["database_quota"] == 0) {
217217
$app->tform->errorMessage .= $app->tform->lng("limit_database_quota_not_0_txt")."<br>";
@@ -364,7 +364,11 @@ function onBeforeUpdate() {
364364
$server_config = $app->getconf->get_server_config($tmp['server_id'], 'server');
365365

366366
// Add default remote_ips from Main Configuration.
367-
$remote_ips = explode(",", $global_config['default_remote_dbserver']);
367+
if(empty($global_config['default_remote_dbserver'])) {
368+
$remote_ips = array();
369+
} else {
370+
$remote_ips = explode(",", $global_config['default_remote_dbserver']);
371+
}
368372
if (!in_array($server_config['ip_address'], $default_remote_db)) { $remote_ips[] = $server_config['ip_address']; }
369373

370374
if($server_config['ip_address']!='') {
@@ -449,7 +453,12 @@ function onBeforeInsert() {
449453
$server_config = $app->getconf->get_server_config($tmp['server_id'], 'server');
450454

451455
// Add default remote_ips from Main Configuration.
452-
$remote_ips = explode(",", $global_config['default_remote_dbserver']);
456+
if(empty($global_config['default_remote_dbserver'])) {
457+
$remote_ips = array();
458+
} else {
459+
$remote_ips = explode(",", $global_config['default_remote_dbserver']);
460+
}
461+
453462
if (!in_array($server_config['ip_address'], $default_remote_db)) { $remote_ips[] = $server_config['ip_address']; }
454463

455464
if($server_config['ip_address']!='') {

0 commit comments

Comments
 (0)