Skip to content

Commit 2a24c61

Browse files
author
Marius Burkard
committed
Merge branch 'stable-3.1'
2 parents 2f74cf2 + 9fd9303 commit 2a24c61

File tree

3 files changed

+62
-81
lines changed

3 files changed

+62
-81
lines changed

server/conf/php_fpm_pool.conf.master

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ env[TEMP] = <tmpl_var name='document_root'>/tmp
3434

3535
<tmpl_if name='security_level' op='==' value='20'>
3636
<tmpl_var name='enable_php_open_basedir'>php_admin_value[open_basedir] = <tmpl_var name='php_open_basedir'>
37-
php_admin_value[session.save_path] = <tmpl_var name='document_root'>/tmp
37+
<tmpl_if name='custom_session_save_path' op='!=' value='y'>php_admin_value[session.save_path] = <tmpl_var name='document_root'>/tmp</tmpl_if>
3838
php_admin_value[upload_tmp_dir] = <tmpl_var name='document_root'>/tmp
3939
php_admin_value[sendmail_path] = "/usr/sbin/sendmail -t -i -f webmaster@<tmpl_var name='domain'>"
4040
</tmpl_if>

server/plugins-available/apache2_plugin.inc.php

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,52 @@ function onLoad() {
9191
$app->plugins->registerAction('php_ini_changed', $this->plugin_name, 'php_ini_changed');
9292
}
9393

94-
// check for php.ini changes
95-
94+
private function get_master_php_ini_content($web_data) {
95+
global $app, $conf;
96+
97+
$app->uses('getconf');
98+
$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
99+
$fastcgi_config = $app->getconf->get_server_config($conf['server_id'], 'fastcgi');
100+
101+
$php_ini_content = '';
102+
$master_php_ini_path = '';
103+
104+
if($web_data['php'] == 'mod') {
105+
$master_php_ini_path = $web_config['php_ini_path_apache'];
106+
} else {
107+
// check for custom php
108+
if($web_data['fastcgi_php_version'] != '') {
109+
$tmp = explode(':', $web_data['fastcgi_php_version']);
110+
if(isset($tmp[2])) {
111+
$tmppath = $tmp[2];
112+
if(substr($tmppath, -7) != 'php.ini') {
113+
if(substr($tmppath, -1) != '/') $tmppath .= '/';
114+
$tmppath .= 'php.ini';
115+
}
116+
if(file_exists($tmppath)) {
117+
$master_php_ini_path = $tmppath;
118+
}
119+
unset($tmppath);
120+
}
121+
unset($tmp);
122+
}
123+
124+
if(!$master_php_ini_path) {
125+
if($web_data['php'] == 'fast-cgi' && file_exists($fastcgi_config["fastcgi_phpini_path"])) {
126+
$master_php_ini_path = $fastcgi_config["fastcgi_phpini_path"];
127+
} elseif($web_data['php'] == 'php-fpm' && file_exists($web_config['php_fpm_ini_path'])) {
128+
$master_php_ini_path = $fastcgi_config["fastcgi_phpini_path"];
129+
} else {
130+
$master_php_ini_path = $web_config['php_ini_path_cgi'];
131+
}
132+
}
133+
}
134+
if($master_php_ini_path != '' && substr($master_php_ini_path, -7) == 'php.ini' && is_file($master_php_ini_path)) {
135+
$php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n";
136+
}
137+
138+
return $php_ini_content;
139+
}
96140

97141
// Handle php.ini changes
98142
function php_ini_changed($event_name, $data) {
@@ -145,22 +189,10 @@ function php_ini_changed($event_name, $data) {
145189
$custom_php_ini_dir .= '_' . $web_folder;
146190
}
147191
if(!is_dir($web_config['website_basedir'].'/conf')) $app->system->mkdir($web_config['website_basedir'].'/conf');
148-
149-
192+
150193
if(!is_dir($custom_php_ini_dir)) $app->system->mkdir($custom_php_ini_dir);
151-
$php_ini_content = '';
152-
if($web_data['php'] == 'mod') {
153-
$master_php_ini_path = $web_config['php_ini_path_apache'];
154-
} else {
155-
if($web_data['php'] == 'fast-cgi' && file_exists($fastcgi_config["fastcgi_phpini_path"])) {
156-
$master_php_ini_path = $fastcgi_config["fastcgi_phpini_path"];
157-
} else {
158-
$master_php_ini_path = $web_config['php_ini_path_cgi'];
159-
}
160-
}
161-
if($master_php_ini_path != '' && substr($master_php_ini_path, -7) == 'php.ini' && is_file($master_php_ini_path)) {
162-
$php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n";
163-
}
194+
195+
$php_ini_content = $this->get_master_php_ini_content($web_data);
164196

165197
if(intval($web_data['directive_snippets_id']) > 0){
166198
$snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'apache' AND active = 'y' AND customer_viewable = 'y'", intval($web_data['directive_snippets_id']));
@@ -1009,32 +1041,8 @@ function update($event_name, $data) {
10091041
if(trim($data['new']['custom_php_ini']) != '') {
10101042
$has_custom_php_ini = true;
10111043
if(!is_dir($custom_php_ini_dir)) $app->system->mkdirpath($custom_php_ini_dir);
1012-
$php_ini_content = '';
1013-
if($data['new']['php'] == 'mod') {
1014-
$master_php_ini_path = $web_config['php_ini_path_apache'];
1015-
} else {
1016-
if($data["new"]['php'] == 'fast-cgi') {
1017-
if(trim($data['new']['fastcgi_php_version']) != '' && file_exists($custom_fastcgi_php_ini_dir)){
1018-
$master_php_ini_path = $custom_fastcgi_php_ini_dir;
1019-
} elseif(file_exists($fastcgi_config["fastcgi_phpini_path"])){
1020-
$master_php_ini_path = $fastcgi_config["fastcgi_phpini_path"];
1021-
} else {
1022-
$master_php_ini_path = $web_config['php_ini_path_cgi'];
1023-
}
1024-
} else {
1025-
$master_php_ini_path = $web_config['php_ini_path_cgi'];
1026-
}
1027-
}
1028-
1029-
//* Add php.ini to the path in case that the master_php_ini_path is a directory
1030-
if($master_php_ini_path != '' && is_dir($master_php_ini_path) && is_file($master_php_ini_path.'/php.ini')) {
1031-
if(substr($master_php_ini_path, -1) == '/') $master_php_ini_path = substr($master_php_ini_path, 0, -1);
1032-
$master_php_ini_path .= '/php.ini';
1033-
}
1034-
1035-
if($master_php_ini_path != '' && substr($master_php_ini_path, -7) == 'php.ini' && is_file($master_php_ini_path)) {
1036-
$php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n";
1037-
}
1044+
1045+
$php_ini_content = $this->get_master_php_ini_content($data['new']);
10381046
$php_ini_content .= str_replace("\r", '', trim($data['new']['custom_php_ini']));
10391047

10401048
if(intval($data['new']['directive_snippets_id']) > 0){
@@ -3138,6 +3146,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
31383146
}
31393147
}
31403148

3149+
$custom_session_save_path = false;
31413150
if($custom_php_ini_settings != ''){
31423151
// Make sure we only have Unix linebreaks
31433152
$custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
@@ -3153,6 +3162,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
31533162
$value = trim($value);
31543163
if($value != ''){
31553164
$key = trim($key);
3165+
if($key == 'session.save_path') $custom_session_save_path = true;
31563166
switch (strtolower($value)) {
31573167
case '0':
31583168
// PHP-FPM might complain about invalid boolean value if you use 0
@@ -3173,7 +3183,9 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
31733183
}
31743184
}
31753185
}
3176-
3186+
3187+
$tpl->setVar('custom_session_save_path', ($custom_session_save_path ? 'y' : 'n'));
3188+
31773189
$tpl->setLoop('custom_php_ini_settings', $final_php_ini_settings);
31783190

31793191
$app->system->file_put_contents($pool_dir.$pool_name.'.conf', $tpl->grab());

server/plugins-available/nginx_plugin.inc.php

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -889,42 +889,7 @@ function update($event_name, $data) {
889889
$app->system->chown('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log', 'root');
890890
$app->system->chgrp('/var/log/ispconfig/httpd/'.$data['new']['domain'].'/error.log', 'root');
891891
}
892-
893-
// Change the ownership of the error log to the owner of the website
894-
/*
895-
if(!@is_file($data['new']['document_root'].'/log/error.log')) exec('touch '.escapeshellcmd($data['new']['document_root']).'/log/error.log');
896-
$app->system->chown($data['new']['document_root'].'/log/error.log',$username);
897-
$app->system->chgrp($data['new']['document_root'].'/log/error.log',$groupname);
898-
*/
899-
900-
901-
/*
902-
//* Write the custom php.ini file, if custom_php_ini filed is not empty
903-
$custom_php_ini_dir = $web_config['website_basedir'].'/conf/'.$data['new']['system_user'];
904-
if(!is_dir($web_config['website_basedir'].'/conf')) mkdir($web_config['website_basedir'].'/conf');
905-
if(trim($data['new']['custom_php_ini']) != '') {
906-
$has_custom_php_ini = true;
907-
if(!is_dir($custom_php_ini_dir)) $app->system->mkdirpath($custom_php_ini_dir);
908-
$php_ini_content = '';
909-
if($data['new']['php'] == 'mod') {
910-
$master_php_ini_path = $web_config['php_ini_path_apache'];
911-
} else {
912-
if($data["new"]['php'] == 'fast-cgi' && file_exists($fastcgi_config["fastcgi_phpini_path"])) {
913-
$master_php_ini_path = $fastcgi_config["fastcgi_phpini_path"];
914-
} else {
915-
$master_php_ini_path = $web_config['php_ini_path_cgi'];
916-
}
917-
}
918-
if($master_php_ini_path != '' && substr($master_php_ini_path,-7) == 'php.ini' && is_file($master_php_ini_path)) {
919-
$php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n";
920-
}
921-
$php_ini_content .= str_replace("\r",'',trim($data['new']['custom_php_ini']));
922-
$app->system->file_put_contents($custom_php_ini_dir.'/php.ini',$php_ini_content);
923-
} else {
924-
$has_custom_php_ini = false;
925-
if(is_file($custom_php_ini_dir.'/php.ini')) $app->system->unlink($custom_php_ini_dir.'/php.ini');
926-
}
927-
*/
892+
928893

929894
//* Create the vhost config file
930895
$app->load('tpl');
@@ -2792,6 +2757,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
27922757
}
27932758
}
27942759

2760+
$custom_session_save_path = false;
27952761
if($custom_php_ini_settings != ''){
27962762
// Make sure we only have Unix linebreaks
27972763
$custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
@@ -2807,6 +2773,7 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
28072773
$value = trim($value);
28082774
if($value != ''){
28092775
$key = trim($key);
2776+
if($key == 'session.save_path') $custom_session_save_path = true;
28102777
switch (strtolower($value)) {
28112778
case '0':
28122779
// PHP-FPM might complain about invalid boolean value if you use 0
@@ -2828,6 +2795,8 @@ private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name,
28282795
}
28292796
}
28302797

2798+
$tpl->setVar('custom_session_save_path', ($custom_session_save_path ? 'y' : 'n'));
2799+
28312800
$tpl->setLoop('custom_php_ini_settings', $final_php_ini_settings);
28322801

28332802
$app->system->file_put_contents($pool_dir.$pool_name.'.conf', $tpl->grab());

0 commit comments

Comments
 (0)