From dee987b263b021b990ea4c62cb15be47c6d61fb5 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Mon, 05 Jan 2015 08:30:12 -0500
Subject: [PATCH] Merge branch 'master' into 'master'

---
 server/plugins-available/webserver_plugin.inc.php |  193 ++++++++++++++++++++++++-----------------------
 1 files changed, 98 insertions(+), 95 deletions(-)

diff --git a/server/plugins-available/webserver_plugin.inc.php b/server/plugins-available/webserver_plugin.inc.php
index 5678444..dd5a50b 100644
--- a/server/plugins-available/webserver_plugin.inc.php
+++ b/server/plugins-available/webserver_plugin.inc.php
@@ -32,14 +32,16 @@
 
 	var $plugin_name = 'webserver_plugin';
 	var $class_name = 'webserver_plugin';
-	
+
 	/**
 	 * This function is called during ispconfig installation to determine
 	 * if a symlink shall be created for this plugin.
 	 */
+
+
 	public function onInstall() {
 		global $conf;
-        
+
 		if($conf['services']['web'] == true) {
 			return true;
 		} else {
@@ -53,7 +55,7 @@
 	public function onLoad() {
 		global $app;
 
-        $app->plugins->registerAction('server_plugins_loaded', $this->plugin_name, 'check_phpini_changes');
+		$app->plugins->registerAction('server_plugins_loaded', $this->plugin_name, 'check_phpini_changes');
 	}
 
 	/**
@@ -69,98 +71,99 @@
 	 */
 	public function check_phpini_changes() {
 		global $app, $conf;
-		
-        //** check if the main php.ini of the system changed so we need to regenerate all custom php.inis
-        $app->uses('getconf');
-        
-        //** files to check
-        $check_files = array();
-        
-        $web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
-        $fastcgi_config = $app->getconf->get_server_config($conf['server_id'], 'fastcgi');
-        
-        if($web_config['php_ini_check_minutes'] == 0 || @date('i') % $web_config['php_ini_check_minutes'] != 0) {
-            $app->log('Info: php.ini change checking not enabled or not in this minute: ' . $web_config['php_ini_check_minutes'],LOGLEVEL_DEBUG);
-            return; // do not process
-        }
-        
-        //** add default php.ini files to check
-        $check_files[] = array('file' => $web_config['php_ini_path_apache'],
-                               'mode' => 'mod',
-                               'php_version' => ''); // default;
-        
-        $check_files[] = array('file' => $web_config['php_ini_path_cgi'],
-                               'mode' => '', // all but 'mod' and 'fast-cgi'
-                               'php_version' => ''); // default;
-        
-        if($fastcgi_config["fastcgi_phpini_path"] && $fastcgi_config["fastcgi_phpini_path"] != $web_config['php_ini_path_cgi']) {
-            $check_files[] = array('file' => $fastcgi_config["fastcgi_phpini_path"],
-                                   'mode' => 'fast-cgi',
-                                   'php_version' => ''); // default;
-        } else {
-            $check_files[] = array('file' => $web_config['php_ini_path_cgi'],
-                                   'mode' => 'fast-cgi', // all but 'mod'
-                                   'php_version' => ''); // default;
-        }
-        
-        
-        //** read additional php versions of this server
-        $php_versions = $app->db->queryAllRecords('SELECT server_php_id, php_fastcgi_ini_dir, php_fpm_ini_dir FROM server_php WHERE server_id = ' . intval($conf['server_id']));
-        foreach($php_versions as $php) {
-            if($php['php_fastcgi_ini_dir'] && $php['php_fastcgi_ini_dir'] . '/php.ini' != $web_config['php_ini_path_cgi']) {
-                $check_files[] = array('file' => $php['php_fastcgi_ini_dir'] . '/php.ini',
-                                       'mode' => 'fast-cgi',
-                                       'php_version' => $php['php_fastcgi_ini_dir']);
-            } elseif($php['php_fpm_ini_dir'] && $php['php_fpm_ini_dir'] . '/php.ini' != $web_config['php_ini_path_cgi']) {
-                $check_files[] = array('file' => $php['php_fpm_ini_dir'] . '/php.ini',
-                                       'mode' => 'php-fpm',
-                                       'php_version' => $php['php_fpm_ini_dir']);
-            }
-        }
-        unset($php_versions);
-        
-        //** read md5sum status file
-        $new_php_ini_md5 = array();
-        $php_ini_md5 = array();
-        $php_ini_changed = false;
-        $rewrite_ini_files = false;
-        
-        if(file_exists(SCRIPT_PATH . '/temp/php.ini.md5sum')) {
-            $rewrite_ini_files = true;
-            $php_ini_md5 = unserialize(base64_decode(trim($app->system->file_get_contents(SCRIPT_PATH . '/temp/php.ini.md5sum'))));
-        }
-        if(!is_array($php_ini_md5)) $php_ini_md5 = array();
-        
-        $processed = array();
-        foreach($check_files as $file) {
-            $file_path = $file['file'];
-            if(substr($file_path, -8) !== '/php.ini') $file_path .= (substr($file_path, -1) !== '/' ? '/' : '') . 'php.ini';
-            if(!file_exists($file_path)) continue;
-            
-            //** check if this php.ini file was already processed (if additional php version uses same php.ini)
-            $ident = $file_path . '::' . $file['mode'] . '::' . $file['php_version'];
-            if(in_array($ident, $processed) == true) continue;
-            $processed[] = $ident;
-            
-            //** check if md5sum of file changed
-            $file_md5 = md5_file($file_path);
-            if(array_key_exists($file_path, $php_ini_md5) == false || $php_ini_md5[$file_path] != $file_md5) {
-                $php_ini_changed = true;
-                
-                $app->log('Info: PHP.ini changed: ' . $file_path . ', mode ' . $file['mode'] . ' vers ' . $file['php_version'] . '.',LOGLEVEL_DEBUG);
-                // raise action for this file
-                if($rewrite_ini_files == true) $app->plugins->raiseAction('php_ini_changed', $file);
-            }
-            
-            $new_php_ini_md5[$file_path] = $file_md5;
-        }
-        
-        //** write new md5 sums if something changed
-        if($php_ini_changed == true) $app->system->file_put_contents(SCRIPT_PATH . '/temp/php.ini.md5sum', base64_encode(serialize($new_php_ini_md5)));
-        unset($new_php_ini_md5);
-        unset($php_ini_md5);
-        unset($processed);
+
+		//** check if the main php.ini of the system changed so we need to regenerate all custom php.inis
+		$app->uses('getconf');
+
+		//** files to check
+		$check_files = array();
+
+		$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
+		$fastcgi_config = $app->getconf->get_server_config($conf['server_id'], 'fastcgi');
+
+		if($web_config['php_ini_check_minutes'] == 0 || @date('i') % $web_config['php_ini_check_minutes'] != 0) {
+			$app->log('Info: php.ini change checking not enabled or not in this minute: ' . $web_config['php_ini_check_minutes'], LOGLEVEL_DEBUG);
+			return; // do not process
+		}
+
+		//** add default php.ini files to check
+		$check_files[] = array('file' => $web_config['php_ini_path_apache'],
+			'mode' => 'mod',
+			'php_version' => ''); // default;
+
+		$check_files[] = array('file' => $web_config['php_ini_path_cgi'],
+			'mode' => '', // all but 'mod' and 'fast-cgi'
+			'php_version' => ''); // default;
+
+		if($fastcgi_config["fastcgi_phpini_path"] && $fastcgi_config["fastcgi_phpini_path"] != $web_config['php_ini_path_cgi']) {
+			$check_files[] = array('file' => $fastcgi_config["fastcgi_phpini_path"],
+				'mode' => 'fast-cgi',
+				'php_version' => ''); // default;
+		} else {
+			$check_files[] = array('file' => $web_config['php_ini_path_cgi'],
+				'mode' => 'fast-cgi', // all but 'mod'
+				'php_version' => ''); // default;
+		}
+
+
+		//** read additional php versions of this server
+		$php_versions = $app->db->queryAllRecords('SELECT server_php_id, php_fastcgi_ini_dir, php_fpm_ini_dir FROM server_php WHERE server_id = ' . intval($conf['server_id']));
+		foreach($php_versions as $php) {
+			if($php['php_fastcgi_ini_dir'] && $php['php_fastcgi_ini_dir'] . '/php.ini' != $web_config['php_ini_path_cgi']) {
+				$check_files[] = array('file' => $php['php_fastcgi_ini_dir'] . '/php.ini',
+					'mode' => 'fast-cgi',
+					'php_version' => $php['php_fastcgi_ini_dir']);
+			} elseif($php['php_fpm_ini_dir'] && $php['php_fpm_ini_dir'] . '/php.ini' != $web_config['php_ini_path_cgi']) {
+				$check_files[] = array('file' => $php['php_fpm_ini_dir'] . '/php.ini',
+					'mode' => 'php-fpm',
+					'php_version' => $php['php_fpm_ini_dir']);
+			}
+		}
+		unset($php_versions);
+
+		//** read md5sum status file
+		$new_php_ini_md5 = array();
+		$php_ini_md5 = array();
+		$php_ini_changed = false;
+		$rewrite_ini_files = false;
+
+		if(file_exists(SCRIPT_PATH . '/temp/php.ini.md5sum')) {
+			$rewrite_ini_files = true;
+			$php_ini_md5 = unserialize(base64_decode(trim($app->system->file_get_contents(SCRIPT_PATH . '/temp/php.ini.md5sum'))));
+		}
+		if(!is_array($php_ini_md5)) $php_ini_md5 = array();
+
+		$processed = array();
+		foreach($check_files as $file) {
+			$file_path = $file['file'];
+			if(substr($file_path, -8) !== '/php.ini') $file_path .= (substr($file_path, -1) !== '/' ? '/' : '') . 'php.ini';
+			if(!file_exists($file_path)) continue;
+
+			//** check if this php.ini file was already processed (if additional php version uses same php.ini)
+			$ident = $file_path . '::' . $file['mode'] . '::' . $file['php_version'];
+			if(in_array($ident, $processed) == true) continue;
+			$processed[] = $ident;
+
+			//** check if md5sum of file changed
+			$file_md5 = md5_file($file_path);
+			if(array_key_exists($file_path, $php_ini_md5) == false || $php_ini_md5[$file_path] != $file_md5) {
+				$php_ini_changed = true;
+
+				$app->log('Info: PHP.ini changed: ' . $file_path . ', mode ' . $file['mode'] . ' vers ' . $file['php_version'] . '.', LOGLEVEL_DEBUG);
+				// raise action for this file
+				if($rewrite_ini_files == true) $app->plugins->raiseAction('php_ini_changed', $file);
+			}
+
+			$new_php_ini_md5[$file_path] = $file_md5;
+		}
+
+		//** write new md5 sums if something changed
+		if($php_ini_changed == true) $app->system->file_put_contents(SCRIPT_PATH . '/temp/php.ini.md5sum', base64_encode(serialize($new_php_ini_md5)));
+		unset($new_php_ini_md5);
+		unset($php_ini_md5);
+		unset($processed);
 	}
+
 }
 
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1