@@ -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 ());
0 commit comments