From 4e7b3650a28eb686c54b5d602aac593cdcc012c2 Mon Sep 17 00:00:00 2001 From: Branislav Viest Date: Wed, 23 Sep 2020 13:00:10 +0200 Subject: [PATCH 1/2] Custom PHP variables are not apply when configured in Directive Snippet PHP variables from Directive Snippets order fix in php.ini --- server/plugins-available/apache2_plugin.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index c9ed6508e0..bef49172cd 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1247,13 +1247,14 @@ class apache2_plugin { } //* Create custom php.ini - if(trim($data['new']['custom_php_ini']) != '') { + # Because of custom default PHP directives from snippet + # php.ini custom values order os: 1. general settings 2. Directive Snippets settings 3. custom php.ini settings defined in domain settings + if(trim($data['new']['custom_php_ini']) != '' || $data['new']['directive_snippets_id'] > "0") { $has_custom_php_ini = true; $custom_sendmail_path = false; if(!is_dir($custom_php_ini_dir)) $app->system->mkdirpath($custom_php_ini_dir); $php_ini_content = $this->get_master_php_ini_content($data['new']); - $php_ini_content .= str_replace("\r", '', trim($data['new']['custom_php_ini'])); if(intval($data['new']['directive_snippets_id']) > 0){ $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'apache' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); @@ -1266,6 +1267,7 @@ class apache2_plugin { $php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet); $php_snippet['snippet'] = trim($php_snippet['snippet']); if($php_snippet['snippet'] != ''){ + $php_snippet['snippet'] = str_replace("\r", '', $php_snippet['snippet']); $php_ini_content .= "\n".$php_snippet['snippet']; } } @@ -1273,6 +1275,7 @@ class apache2_plugin { } } } + $php_ini_content .= "\n".str_replace("\r", '', trim($data['new']['custom_php_ini'])); $custom_sendmail_path = false; $line = strtok($php_ini_content, '\n'); -- GitLab From 3a93952c4c9ccead0859eaf77d5b3fed9e5aed2f Mon Sep 17 00:00:00 2001 From: Marius Burkard Date: Tue, 29 Sep 2020 10:02:30 +0200 Subject: [PATCH 2/2] Move custom php in front of snippet data --- server/plugins-available/apache2_plugin.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index bef49172cd..1dd51a6c53 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -1256,6 +1256,8 @@ class apache2_plugin { $php_ini_content = $this->get_master_php_ini_content($data['new']); + $php_ini_content .= "\n".str_replace("\r", '', trim($data['new']['custom_php_ini'])); + if(intval($data['new']['directive_snippets_id']) > 0){ $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'apache' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){ @@ -1275,7 +1277,6 @@ class apache2_plugin { } } } - $php_ini_content .= "\n".str_replace("\r", '', trim($data['new']['custom_php_ini'])); $custom_sendmail_path = false; $line = strtok($php_ini_content, '\n'); -- GitLab