@@ -152,6 +152,12 @@ function onShowEnd() {
152152 $ app ->tpl ->setVar ("database_name_prefix " , $ app ->tools_sites ->getPrefix ($ this ->dataRecord ['database_name_prefix ' ], $ dbname_prefix , $ global_config ['dbname_prefix ' ]), true );
153153 }
154154
155+ if ($ global_config ['disable_client_remote_dbserver ' ] == 'y ' && $ _SESSION ["s " ]["user " ]["typ " ] != 'admin ' ) {
156+ $ app ->tpl ->setVar ("disable_remote_db " , 1 );
157+ } else {
158+ $ app ->tpl ->setVar ("disable_remote_db " , 0 );
159+ }
160+
155161 if ($ this ->id > 0 ) {
156162 //* we are editing a existing record
157163 $ edit_disabled = @($ _SESSION ["s " ]["user " ]["typ " ] == 'admin ' )? 0 : 1 ; //* admin can change the database-name
@@ -351,16 +357,22 @@ function onBeforeUpdate() {
351357 if ($ tmp ['server_id ' ] && $ tmp ['server_id ' ] != $ this ->dataRecord ['server_id ' ]) {
352358 // we need remote access rights for this server, so get it's ip address
353359 $ server_config = $ app ->getconf ->get_server_config ($ tmp ['server_id ' ], 'server ' );
360+
361+ // Add default remote_ips from Main Configuration.
362+ $ remote_ips = explode (", " , $ global_config ['default_remote_dbserver ' ]);
363+ if (!in_array ($ server_config ['ip_address ' ], $ default_remote_db )) { $ remote_ips [] = $ server_config ['ip_address ' ]; }
364+
354365 if ($ server_config ['ip_address ' ]!='' ) {
355366 if ($ this ->dataRecord ['remote_access ' ] != 'y ' ){
356- $ this ->dataRecord ['remote_ips ' ] = $ server_config [ ' ip_address ' ] ;
367+ $ this ->dataRecord ['remote_ips ' ] = implode ( ' , ' , $ remote_ips ) ;
357368 $ this ->dataRecord ['remote_access ' ] = 'y ' ;
358369 } else {
359370 if ($ this ->dataRecord ['remote_ips ' ] != '' ){
360371 if (preg_match ('/(^|,) ' . preg_quote ($ server_config ['ip_address ' ], '/ ' ) . '(,|$)/ ' , $ this ->dataRecord ['remote_ips ' ]) == false ) {
361372 $ this ->dataRecord ['remote_ips ' ] .= ', ' . $ server_config ['ip_address ' ];
362373 }
363374 $ tmp = preg_split ('/\s*,\s*/ ' , $ this ->dataRecord ['remote_ips ' ]);
375+ $ tmp = array_merge ($ tmp , $ remote_ips );
364376 $ tmp = array_unique ($ tmp );
365377 $ this ->dataRecord ['remote_ips ' ] = implode (', ' , $ tmp );
366378 unset($ tmp );
@@ -430,16 +442,22 @@ function onBeforeInsert() {
430442 if ($ tmp ['server_id ' ] && $ tmp ['server_id ' ] != $ this ->dataRecord ['server_id ' ]) {
431443 // we need remote access rights for this server, so get it's ip address
432444 $ server_config = $ app ->getconf ->get_server_config ($ tmp ['server_id ' ], 'server ' );
445+
446+ // Add default remote_ips from Main Configuration.
447+ $ remote_ips = explode (", " , $ global_config ['default_remote_dbserver ' ]);
448+ if (!in_array ($ server_config ['ip_address ' ], $ default_remote_db )) { $ remote_ips [] = $ server_config ['ip_address ' ]; }
449+
433450 if ($ server_config ['ip_address ' ]!='' ) {
434451 if ($ this ->dataRecord ['remote_access ' ] != 'y ' ){
435- $ this ->dataRecord ['remote_ips ' ] = $ server_config [ ' ip_address ' ] ;
452+ $ this ->dataRecord ['remote_ips ' ] = implode ( ' , ' , $ remote_ips ) ;
436453 $ this ->dataRecord ['remote_access ' ] = 'y ' ;
437454 } else {
438455 if ($ this ->dataRecord ['remote_ips ' ] != '' ){
439456 if (preg_match ('/(^|,) ' . preg_quote ($ server_config ['ip_address ' ], '/ ' ) . '(,|$)/ ' , $ this ->dataRecord ['remote_ips ' ]) == false ) {
440457 $ this ->dataRecord ['remote_ips ' ] .= ', ' . $ server_config ['ip_address ' ];
441458 }
442459 $ tmp = preg_split ('/\s*,\s*/ ' , $ this ->dataRecord ['remote_ips ' ]);
460+ $ tmp = array_merge ($ tmp , $ remote_ips );
443461 $ tmp = array_unique ($ tmp );
444462 $ this ->dataRecord ['remote_ips ' ] = implode (', ' , $ tmp );
445463 unset($ tmp );
0 commit comments