From add36e9a703c1977aca1d835526b017d57828ba6 Mon Sep 17 00:00:00 2001
From: ftimme <ft@falkotimme.com>
Date: Mon, 19 Sep 2011 06:46:21 -0400
Subject: [PATCH] - Added open_basedir support to PHP-FPM.

---
 interface/web/admin/templates/server_config_web_edit.htm |    2 +-
 server/plugins-available/nginx_plugin.inc.php            |    8 +++++++-
 server/conf/php_fpm_pool.conf.master                     |    4 +++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/interface/web/admin/templates/server_config_web_edit.htm b/interface/web/admin/templates/server_config_web_edit.htm
index 9f60b74..60ad32c 100644
--- a/interface/web/admin/templates/server_config_web_edit.htm
+++ b/interface/web/admin/templates/server_config_web_edit.htm
@@ -89,7 +89,7 @@
       	<label for="php_ini_path_apache">{tmpl_var name='php_ini_path_apache_txt'}</label>
         <input name="php_ini_path_apache" id="php_ini_path_apache" value="{tmpl_var name='php_ini_path_apache'}" size="40" maxlength="255" type="text" class="textInput" />
 	  </div>
-	  <div class="ctrlHolder">
+	  <div class="ctrlHolder apache">
       	<label for="php_ini_path_cgi">{tmpl_var name='php_ini_path_cgi_txt'}</label>
         <input name="php_ini_path_cgi" id="php_ini_path_cgi" value="{tmpl_var name='php_ini_path_cgi'}" size="40" maxlength="255" type="text" class="textInput" />
 	  </div>
diff --git a/server/conf/php_fpm_pool.conf.master b/server/conf/php_fpm_pool.conf.master
index 600d484..91d8656 100644
--- a/server/conf/php_fpm_pool.conf.master
+++ b/server/conf/php_fpm_pool.conf.master
@@ -11,4 +11,6 @@
 pm.min_spare_servers = 5
 pm.max_spare_servers = 35
 
-chdir = /
\ No newline at end of file
+chdir = /
+
+<tmpl_var name='enable_php_open_basedir'>php_admin_value[open_basedir] = <tmpl_var name='php_open_basedir'>
\ No newline at end of file
diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php
index 8ff7258..44cd26b 100644
--- a/server/plugins-available/nginx_plugin.inc.php
+++ b/server/plugins-available/nginx_plugin.inc.php
@@ -640,7 +640,6 @@
 		$vhost_data['web_basedir'] = $web_config['website_basedir'];
 		$vhost_data['security_level'] = $web_config['security_level'];
 		$vhost_data['allow_override'] = ($data['new']['allow_override'] == '')?'All':$data['new']['allow_override'];
-		//$vhost_data['php_open_basedir'] = ($data['new']['php_open_basedir'] == '')?$data['new']['document_root']:$data['new']['php_open_basedir'];
 		$vhost_data['ssl_domain'] = $data['new']['ssl_domain'];
 		//$vhost_data['has_custom_php_ini'] = $has_custom_php_ini;
 		//$vhost_data['custom_php_ini_dir'] = escapeshellcmd($custom_php_ini_dir);
@@ -1082,6 +1081,13 @@
 			$tpl->setVar('fpm_port', $web_config['php_fpm_start_port'] + $data['new']['domain_id']);
 			$tpl->setVar('fpm_user', $data['new']['system_user']);
 			$tpl->setVar('fpm_group', $data['new']['system_group']);
+			$php_open_basedir = ($data['new']['php_open_basedir'] == '')?$data['new']['document_root']:$data['new']['php_open_basedir'];
+			$tpl->setVar('php_open_basedir', $php_open_basedir);
+			if($php_open_basedir != ''){
+				$tpl->setVar('enable_php_open_basedir', '');
+			} else {
+				$tpl->setVar('enable_php_open_basedir', ';');
+			}
 			
 			file_put_contents($pool_dir.'/'.$data['new']['domain'].'.conf',$tpl->grab());
 			$app->log('Writing the PHP-FPM config file: '.$pool_dir.'/'.$data['new']['domain'].'.conf',LOGLEVEL_DEBUG);

--
Gitblit v1.9.1