From 663caf8590b5998948f79f8cb8c4b507a8fe5140 Mon Sep 17 00:00:00 2001
From: jwarnier <jwarnier@ispconfig3>
Date: Wed, 22 Sep 2010 18:47:40 -0400
Subject: [PATCH] - replaced double quotes with single quotes whenever appropriate - replaced "exec('/etc/init.d/" calls with "exec($conf['init_scripts'] . '/' ." - fixed output wording (typos and more...)

---
 server/plugins-available/mysql_clientdb_plugin.inc.php   |  132 +++++++++++-----------
 server/plugins-available/network_settings_plugin.inc.php |  148 ++++++++++++------------
 server/plugins-available/mail_plugin.inc.php             |   27 ++--
 server/plugins-available/firewall_plugin.inc.php         |   20 +-
 4 files changed, 164 insertions(+), 163 deletions(-)

diff --git a/server/plugins-available/firewall_plugin.inc.php b/server/plugins-available/firewall_plugin.inc.php
index 9039946..d9d1272 100644
--- a/server/plugins-available/firewall_plugin.inc.php
+++ b/server/plugins-available/firewall_plugin.inc.php
@@ -76,7 +76,7 @@
 		$tcp_ports = '';
 		$udp_ports = '';
 		
-		$ports = explode(',',$data["new"]["tcp_port"]);
+		$ports = explode(',',$data['new']['tcp_port']);
 		if(is_array($ports)) {
 			foreach($ports as $p) {
 				if(strstr($p,':')) {
@@ -90,7 +90,7 @@
 		}
 		$tcp_ports = trim($tcp_ports);
 		
-		$ports = explode(',',$data["new"]["udp_port"]);
+		$ports = explode(',',$data['new']['udp_port']);
 		if(is_array($ports)) {
 			foreach($ports as $p) {
 				if(strstr($p,':')) {
@@ -106,21 +106,21 @@
 		
 		$app->load('tpl');
 		$tpl = new tpl();
-		$tpl->newTemplate("bastille-firewall.cfg.master");
+		$tpl->newTemplate('bastille-firewall.cfg.master');
 		
-		$tpl->setVar("TCP_PUBLIC_SERVICES",$tcp_ports);
-		$tpl->setVar("UDP_PUBLIC_SERVICES",$udp_ports);
+		$tpl->setVar('TCP_PUBLIC_SERVICES',$tcp_ports);
+		$tpl->setVar('UDP_PUBLIC_SERVICES',$udp_ports);
 		
 		file_put_contents('/etc/Bastille/bastille-firewall.cfg',$tpl->grab());
 		$app->log('Writing firewall configuration /etc/Bastille/bastille-firewall.cfg',LOGLEVEL_DEBUG);
 		unset($tpl);
 		
-		if($data["new"]["active"] == 'y') {
-			exec('/etc/init.d/bastille-firewall restart');
+		if($data['new']['active'] == 'y') {
+			exec($conf['init_scripts'] . '/' . 'bastille-firewall restart');
 			if(@is_file('/etc/debian_version')) exec('update-rc.d bastille-firewall defaults');
 			$app->log('Restarting the firewall',LOGLEVEL_DEBUG);
 		} else {
-			exec('/etc/init.d/bastille-firewall stop');
+			exec($conf['init_scripts'] . '/' . 'bastille-firewall stop');
 			if(@is_file('/etc/debian_version')) exec('update-rc.d -f bastille-firewall remove');
 			$app->log('Stopping the firewall',LOGLEVEL_DEBUG);
 		}
@@ -131,7 +131,7 @@
 	function delete($event_name,$data) {
 		global $app, $conf;
 		
-		exec('/etc/init.d/bastille-firewall stop');
+		exec($conf['init_scripts'] . '/' . 'bastille-firewall stop');
 		if(@is_file('/etc/debian_version')) exec('update-rc.d -f bastille-firewall remove');
 		$app->log('Stopping the firewall',LOGLEVEL_DEBUG);
 		
@@ -142,4 +142,4 @@
 
 } // end class
 
-?>
\ No newline at end of file
+?>
diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php
index ee24949..2d7d507 100644
--- a/server/plugins-available/mail_plugin.inc.php
+++ b/server/plugins-available/mail_plugin.inc.php
@@ -80,8 +80,8 @@
 		global $app, $conf;
 		
 		//* get the config
-		$app->uses("getconf,system");
-		$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
+		$app->uses('getconf,system');
+		$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
 
 		// convert to lower case - it could cause problems if some directory above has upper case name
 //		$data['new']['maildir'] = strtolower($data['new']['maildir']);
@@ -110,7 +110,7 @@
 		//* When the mail user dir exists but it is not a valid maildir, remove it
 		if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
 			exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail");
-			$app->log("Removed invalid maildir and rebuild it: ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
+			$app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
 		}
 
 		//* Create the maildir, if it doesn not exist, set permissions, set quota.
@@ -120,7 +120,7 @@
 			$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']);
 
 			exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
-			$app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
+			$app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
 
 			//* This is to fix the maildrop quota not being rebuilt after the quota is changed.
 			if($mail_config['pop3_imap_daemon'] != 'dovecot') {
@@ -161,8 +161,8 @@
 		global $app, $conf;
 		
 		// get the config
-		$app->uses("getconf,system");
-		$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
+		$app->uses('getconf,system');
+		$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
 
 		// convert to lower case - it could cause problems if some directory above has upper case name
 		// $data['new']['maildir'] = strtolower($data['new']['maildir']);
@@ -170,8 +170,9 @@
 		// Create the maildir, if it does not exist
 		/*
 		if(!is_dir($data['new']['maildir'])) {
-			exec('mkdir -p '.escapeshellcmd($data['new']['maildir']));
-			exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
+			mkdir(escapeshellcmd($data['new']['maildir']), 0, true);
+			chown(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_name']);
+			chgrp(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_group']);
 			$app->log('Created Maildir: '.$data['new']['maildir'],LOGLEVEL_DEBUG);
 		}
 		*/
@@ -198,7 +199,7 @@
 		//* When the mail user dir exists but it is not a valid maildir, remove it
 		if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
 			exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail");
-			$app->log("Removed invalid maildir and rebuild it: ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
+			$app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_WARN);
 		}
 
 		//* Create the maildir, if it doesn not exist, set permissions, set quota.
@@ -208,7 +209,7 @@
 			$app->system->maildirmake($maildomain_path,$mail_config['mailuser_name']);
 
 			exec('chown -R '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
-			$app->log("Set ownership on ".escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
+			$app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']),LOGLEVEL_DEBUG);
 			//* This is to fix the maildrop quota not being rebuilt after the quota is changed.
 			if($mail_config['pop3_imap_daemon'] != 'dovecot') {
 				exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); // Avoid maildirmake quota bug, see debian bug #214911
@@ -274,7 +275,7 @@
 		
 		// get the config
 		$app->uses("getconf");
-		$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
+		$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
 		
 		//* Delete maildomain path
 		$old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/'.$data['old']['domain']);
@@ -298,7 +299,7 @@
 	function transport_update($event_name,$data) {
 		global $app, $conf;
 		
-		exec('/etc/init.d/postfix reload &> /dev/null');
+		exec($conf['init_scripts'] . '/' . 'postfix reload &> /dev/null');
 		$app->log('Postfix config reloaded ',LOGLEVEL_DEBUG);
 		
 	}
@@ -308,4 +309,4 @@
 
 } // end class
 
-?>
\ No newline at end of file
+?>
diff --git a/server/plugins-available/mysql_clientdb_plugin.inc.php b/server/plugins-available/mysql_clientdb_plugin.inc.php
index 5d52e72..48d8fcf 100644
--- a/server/plugins-available/mysql_clientdb_plugin.inc.php
+++ b/server/plugins-available/mysql_clientdb_plugin.inc.php
@@ -66,16 +66,16 @@
 		
 	}
 	
-  function process_host_list($action, $database_name, $database_user, $database_password, $host_list, $link, $database_rename_user = "") {
+  function process_host_list($action, $database_name, $database_user, $database_password, $host_list, $link, $database_rename_user = '') {
       global $app;
       
       $action = strtoupper($action);
       
       // set to all hosts if none given
-      if(trim($host_list) == "") $host_list = "%";
+      if(trim($host_list) == '') $host_list = '%';
       
       // process arrays and comma separated strings
-      if(!is_array($host_list)) $host_list = split(",", $host_list);
+      if(!is_array($host_list)) $host_list = split(',', $host_list);
       
       $success = true;
       
@@ -85,10 +85,10 @@
           
           // check if entry is valid ip address
           $valid = true;
-		  if($db_host == "%") {
+		  if($db_host == '%') {
 		  	$valid = true;
 		  } elseif(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $db_host)) {
-              $groups = explode(".", $db_host);
+              $groups = explode('.', $db_host);
               foreach($groups as $group){
                 if($group<0 OR $group>255)
                 $valid=false;
@@ -99,15 +99,15 @@
           
           if($valid == false) continue;
           
-          if($action == "GRANT") {
+          if($action == 'GRANT') {
               if(!mysql_query("GRANT ALL ON ".mysql_real_escape_string($database_name,$link).".* TO '".mysql_real_escape_string($database_user,$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($database_password,$link)."';",$link)) $success = false;
-          } elseif($action == "REVOKE") {
+          } elseif($action == 'REVOKE') {
               //mysql_query("REVOKE ALL PRIVILEGES ON ".mysql_real_escape_string($database_name,$link).".* FROM '".mysql_real_escape_string($database_user,$link)."';",$link);
-          } elseif($action == "DROP") {
+          } elseif($action == 'DROP') {
               if(!mysql_query("DROP USER '".mysql_real_escape_string($database_user,$link)."'@'$db_host';",$link)) $success = false;
-          } elseif($action == "RENAME") {
+          } elseif($action == 'RENAME') {
               if(!mysql_query("RENAME USER '".mysql_real_escape_string($database_user,$link)."'@'$db_host' TO '".mysql_real_escape_string($database_rename_user,$link)."'@'$db_host'",$link)) $success = false;
-          } elseif($action == "PASSWORD") {
+          } elseif($action == 'PASSWORD') {
               if(!mysql_query("SET PASSWORD FOR '".mysql_real_escape_string($database_user,$link)."'@'$db_host' = PASSWORD('".mysql_real_escape_string($database_password,$link)."');",$link)) $success = false;
           }
       }
@@ -118,13 +118,13 @@
 	function db_insert($event_name,$data) {
 		global $app, $conf;
 		
-		if($data["new"]["type"] == 'mysql') {
+		if($data['new']['type'] == 'mysql') {
 			if(!include(ISPC_LIB_PATH.'/mysql_clientdb.conf')) {
 				$app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR);
 				return;
 			}
 			
-			if($data["new"]["database_user"] == 'root') {
+			if($data['new']['database_user'] == 'root') {
 				$app->log('User root not allowed for Client databases',LOGLEVEL_WARNING);
 				return;
 			}
@@ -137,33 +137,33 @@
 			}
 
 			// Charset for the new table
-			if($data["new"]["database_charset"] != '') {
-        $query_charset_table = ' DEFAULT CHARACTER SET '.$data["new"]["database_charset"];
+			if($data['new']['database_charset'] != '') {
+        $query_charset_table = ' DEFAULT CHARACTER SET '.$data['new']['database_charset'];
 			} else {
         $query_charset_table = '';
 			}
 
 			//* Create the new database
-			if (mysql_query('CREATE DATABASE '.mysql_real_escape_string($data["new"]["database_name"]).$query_charset_table,$link)) {
-				$app->log('Created MySQL database: '.$data["new"]["database_name"],LOGLEVEL_DEBUG);
+			if (mysql_query('CREATE DATABASE '.mysql_real_escape_string($data['new']['database_name']).$query_charset_table,$link)) {
+				$app->log('Created MySQL database: '.$data['new']['database_name'],LOGLEVEL_DEBUG);
 			} else {
-				$app->log('Unable to create the database'.mysql_error($link),LOGLEVEL_WARNING);
+				$app->log('Unable to create the database: '.mysql_error($link),LOGLEVEL_WARNING);
 			}
 			
 			// Create the database user if database is active
-			if($data["new"]["active"] == 'y') {
+			if($data['new']['active'] == 'y') {
 				
-				if($data["new"]["remote_access"] == 'y') {
-          $this->process_host_list("GRANT", $data["new"]["database_name"], $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
+				if($data['new']['remote_access'] == 'y') {
+          $this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
 				}
 				
 				$db_host = 'localhost';
-				mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* TO '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"],$link)."';",$link);
+				mysql_query("GRANT ALL ON ".mysql_real_escape_string($data['new']['database_name'],$link).".* TO '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data['new']['database_password'],$link)."';",$link);
 
 				
 			}
 			
-			mysql_query("FLUSH PRIVILEGES;",$link);
+			mysql_query('FLUSH PRIVILEGES;',$link);
 			mysql_close($link);
 		}
 	}
@@ -171,13 +171,13 @@
 	function db_update($event_name,$data) {
 		global $app, $conf;
 		
-		if($data["new"]["type"] == 'mysql') {
+		if($data['new']['type'] == 'mysql') {
 			if(!include(ISPC_LIB_PATH.'/mysql_clientdb.conf')) {
 				$app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR);
 				return;
 			}
 			
-			if($data["new"]["database_user"] == 'root') {
+			if($data['new']['database_user'] == 'root') {
 				$app->log('User root not allowed for Client databases',LOGLEVEL_WARNING);
 				return;
 			}
@@ -185,79 +185,79 @@
 			//* Connect to the database
 			$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
 			if (!$link) {
-				$app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR);
+				$app->log('Unable to connect to the database: '.mysql_error($link),LOGLEVEL_ERROR);
 				return;
 			}
 			
 			// Create the database user if database was disabled before
-			if($data["new"]["active"] == 'y' && $data["old"]["active"] == 'n') {
+			if($data['new']['active'] == 'y' && $data['old']['active'] == 'n') {
 				
-				if($data["new"]["remote_access"] == 'y') {
-          $this->process_host_list("GRANT", $data["new"]["database_name"], $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
+				if($data['new']['remote_access'] == 'y') {
+          $this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
 				}
 				
 				$db_host = 'localhost';
-				mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* TO '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"],$link)."';",$link);
+				mysql_query("GRANT ALL ON ".mysql_real_escape_string($data['new']['database_name'],$link).".* TO '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data['new']['database_password'],$link)."';",$link);
 				
 				// mysql_query("GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* TO '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"],$link)."';",$link);
 				//echo "GRANT ALL ON ".mysql_real_escape_string($data["new"]["database_name"]).".* TO '".mysql_real_escape_string($data["new"]["database_user"])."'@'$db_host' IDENTIFIED BY '".mysql_real_escape_string($data["new"]["database_password"])."';";
 			}
 			
 			// Remove database user, if inactive
-			if($data["new"]["active"] == 'n' && $data["old"]["active"] == 'y') {
+			if($data['new']['active'] == 'n' && $data['old']['active'] == 'y') {
 				
-				if($data["old"]["remote_access"] == 'y') {
-          $this->process_host_list("DROP", "", $data["old"]["database_user"], "", $data["old"]["remote_ips"], $link);
+				if($data['old']['remote_access'] == 'y') {
+          $this->process_host_list('DROP', '', $data['old']['database_user'], '', $data['old']['remote_ips'], $link);
 				}
 				
 				$db_host = 'localhost';
-				mysql_query("DROP USER '".mysql_real_escape_string($data["old"]["database_user"],$link)."'@'$db_host';",$link);
+				mysql_query("DROP USER '".mysql_real_escape_string($data['old']['database_user'],$link)."'@'$db_host';",$link);
 				
 				
 				//mysql_query("REVOKE ALL PRIVILEGES ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* FROM '".mysql_real_escape_string($data["new"]["database_user"],$link)."';",$link);
 			}
 			
 			//* Rename User
-			if($data["new"]["database_user"] != $data["old"]["database_user"]) {
+			if($data['new']['database_user'] != $data['old']['database_user']) {
 				$db_host = 'localhost';
-				mysql_query("RENAME USER '".mysql_real_escape_string($data["old"]["database_user"],$link)."'@'$db_host' TO '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host'",$link);
-				if($data["old"]["remote_access"] == 'y') {
-          $this->process_host_list("RENAME", "", $data["new"]["database_user"], "", $data["new"]["remote_ips"], $link, $data["new"]["database_user"]);
+				mysql_query("RENAME USER '".mysql_real_escape_string($data['old']['database_user'],$link)."'@'$db_host' TO '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host'",$link);
+				if($data['old']['remote_access'] == 'y') {
+          $this->process_host_list('RENAME', '', $data['new']['database_user'], '', $data['new']['remote_ips'], $link, $data['new']['database_user']);
 				}
-				$app->log('Renaming mysql user: '.$data["old"]["database_user"].' to '.$data["new"]["database_user"],LOGLEVEL_DEBUG);
+				$app->log('Renaming MySQL user: '.$data['old']['database_user'].' to '.$data['new']['database_user'],LOGLEVEL_DEBUG);
 			}
 			
 			//* Remote access option has changed.
-			if($data["new"]["remote_access"] != $data["old"]["remote_access"]) {
+			if($data['new']['remote_access'] != $data['old']['remote_access']) {
 				
 				//* revoke old priveliges
 				//mysql_query("REVOKE ALL PRIVILEGES ON ".mysql_real_escape_string($data["new"]["database_name"],$link).".* FROM '".mysql_real_escape_string($data["new"]["database_user"],$link)."';",$link);
 				
 				//* set new priveliges
-				if($data["new"]["remote_access"] == 'y') { 		
-					$this->process_host_list("GRANT", $data["new"]["database_name"], $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
+				if($data['new']['remote_access'] == 'y') { 		
+					$this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
 				} else {
-					$this->process_host_list("DROP", "", $data["old"]["database_user"], "", $data["old"]["remote_ips"], $link);
+					$this->process_host_list('DROP', '', $data['old']['database_user'], '', $data['old']['remote_ips'], $link);
 				}
-				$app->log('Changing mysql remote access priveliges for database: '.$data["new"]["database_name"],LOGLEVEL_DEBUG);
-			} elseif($data["new"]["remote_access"] == 'y' && $data["new"]["remote_ips"] != $data["old"]["remote_ips"]) {
+				$app->log('Changing MySQL remote access privileges for database: '.$data['new']['database_name'],LOGLEVEL_DEBUG);
+			} elseif($data['new']['remote_access'] == 'y' && $data['new']['remote_ips'] != $data['old']['remote_ips']) {
           //* Change remote access list
-          $this->process_host_list("DROP", "", $data["old"]["database_user"], "", $data["old"]["remote_ips"], $link);
-          $this->process_host_list("GRANT", $data["new"]["database_name"], $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
+          $this->process_host_list('DROP', '', $data['old']['database_user'], '', $data['old']['remote_ips'], $link);
+          $this->process_host_list('GRANT', $data['new']['database_name'], $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
       }
       
 			//* Change password
-			if($data["new"]["database_password"] != $data["old"]["database_password"]) {
+			if($data['new']['database_password'] != $data['old']['database_password']) {
 				$db_host = 'localhost';
-				mysql_query("SET PASSWORD FOR '".mysql_real_escape_string($data["new"]["database_user"],$link)."'@'$db_host' = PASSWORD('".mysql_real_escape_string($data["new"]["database_password"],$link)."');",$link);
+				mysql_query("SET PASSWORD FOR '".mysql_real_escape_string($data['new']['database_user'],$link)."'@'$db_host' = PASSWORD('".mysql_real_escape_string($data['new']['database_password'],$link)."');",$link);
 
-				if($data["new"]["remote_access"] == 'y') {
-          $this->process_host_list("PASSWORD", "", $data["new"]["database_user"], $data["new"]["database_password"], $data["new"]["remote_ips"], $link);
+				if($data['new']['remote_access'] == 'y') {
+          $this->process_host_list('PASSWORD', '', $data['new']['database_user'], $data['new']['database_password'], $data['new']['remote_ips'], $link);
 				}
-				$app->log('Changing mysql user password for: '.$data["new"]["database_user"],LOGLEVEL_DEBUG);
+				$app->log('Changing MySQL user password for: '.$data['new']['database_user'],LOGLEVEL_DEBUG);
 			}
 			
-			mysql_query("FLUSH PRIVILEGES;",$link);
+			mysql_query('FLUSH PRIVILEGES;',$link);
 			mysql_close($link);
 		}
 		
@@ -266,7 +266,7 @@
 	function db_delete($event_name,$data) {
 		global $app, $conf;
 		
-		if($data["old"]["type"] == 'mysql') {
+		if($data['old']['type'] == 'mysql') {
 			if(!include(ISPC_LIB_PATH.'/mysql_clientdb.conf')) {
 				$app->log('Unable to open'.ISPC_LIB_PATH.'/mysql_clientdb.conf',LOGLEVEL_ERROR);
 				return;
@@ -275,32 +275,32 @@
 			//* Connect to the database
 			$link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password);
 			if (!$link) {
-				$app->log('Unable to connect to the database'.mysql_error($link),LOGLEVEL_ERROR);
+				$app->log('Unable to connect to the database: '.mysql_error($link),LOGLEVEL_ERROR);
 				return;
 			}
 			
 			//* Get the db host setting for the access priveliges
-			if($data["old"]["remote_access"] == 'y') {
-			 	if($this->process_host_list("DROP", "", $data["old"]["database_user"], "", $data["old"]["remote_ips"], $link)) {
-        	$app->log('Dropping mysql user: '.$data["old"]["database_user"],LOGLEVEL_DEBUG);
+			if($data['old']['remote_access'] == 'y') {
+			 	if($this->process_host_list('DROP', '', $data['old']['database_user'], '', $data['old']['remote_ips'], $link)) {
+        	$app->log('Dropping MySQL user: '.$data['old']['database_user'],LOGLEVEL_DEBUG);
 				} else {
-					$app->log('Error while dropping mysql user: '.$data["old"]["database_user"].' '.mysql_error($link),LOGLEVEL_WARNING);
+					$app->log('Error while dropping MySQL user: '.$data['old']['database_user'].' '.mysql_error($link),LOGLEVEL_WARNING);
 				}
 			}
 			$db_host = 'localhost';
-			if(mysql_query("DROP USER '".mysql_real_escape_string($data["old"]["database_user"],$link)."'@'$db_host';",$link)) {
-				$app->log('Dropping mysql user: '.$data["old"]["database_user"],LOGLEVEL_DEBUG);
+			if(mysql_query("DROP USER '".mysql_real_escape_string($data['old']['database_user'],$link)."'@'$db_host';",$link)) {
+				$app->log('Dropping MySQL user: '.$data['old']['database_user'],LOGLEVEL_DEBUG);
 			} else {
-				$app->log('Error while dropping mysql user: '.$data["old"]["database_user"].' '.mysql_error($link),LOGLEVEL_WARNING);
+				$app->log('Error while dropping MySQL user: '.$data['old']['database_user'].' '.mysql_error($link),LOGLEVEL_WARNING);
 			}
 			
-			if(mysql_query('DROP DATABASE '.mysql_real_escape_string($data["old"]["database_name"],$link),$link)) {
-				$app->log('Dropping mysql database: '.$data["old"]["database_name"],LOGLEVEL_DEBUG);
+			if(mysql_query('DROP DATABASE '.mysql_real_escape_string($data['old']['database_name'],$link),$link)) {
+				$app->log('Dropping MySQL database: '.$data['old']['database_name'],LOGLEVEL_DEBUG);
 			} else {
-				$app->log('Error while dropping mysql database: '.$data["old"]["database_name"].' '.mysql_error($link),LOGLEVEL_WARNING);
+				$app->log('Error while dropping MySQL database: '.$data['old']['database_name'].' '.mysql_error($link),LOGLEVEL_WARNING);
 			}
 			
-			mysql_query("FLUSH PRIVILEGES;",$link);
+			mysql_query('FLUSH PRIVILEGES;',$link);
 			mysql_close($link);
 		}
 		
@@ -312,4 +312,4 @@
 
 } // end class
 
-?>
\ No newline at end of file
+?>
diff --git a/server/plugins-available/network_settings_plugin.inc.php b/server/plugins-available/network_settings_plugin.inc.php
index 961e2cd..4b06006 100644
--- a/server/plugins-available/network_settings_plugin.inc.php
+++ b/server/plugins-available/network_settings_plugin.inc.php
@@ -76,8 +76,8 @@
 		global $app, $conf;
 		
 		// get the config
-		$app->uses("getconf");
-		$server_config = $app->getconf->get_server_config($conf["server_id"], 'server');
+		$app->uses('getconf');
+		$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
 		
 		// Configure the debian network card settings
 		if($server_config['auto_network_configuration'] == 'y') {
@@ -89,15 +89,15 @@
 				$app->load('tpl');
 				
 				$network_tpl = new tpl();
-				$network_tpl->newTemplate("debian_network_interfaces.master");
+				$network_tpl->newTemplate('debian_network_interfaces.master');
 					
-				$network_tpl->setVar('ip_address',$server_config["ip_address"]);
-				$network_tpl->setVar('netmask',$server_config["netmask"]);
-				$network_tpl->setVar('gateway',$server_config["gateway"]);
-				$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
-				$network_tpl->setVar('network',$this->network($server_config["ip_address"],$server_config["netmask"]));
+				$network_tpl->setVar('ip_address',$server_config['ip_address']);
+				$network_tpl->setVar('netmask',$server_config['netmask']);
+				$network_tpl->setVar('gateway',$server_config['gateway']);
+				$network_tpl->setVar('broadcast',$this->broadcast($server_config['ip_address'],$server_config['netmask']));
+				$network_tpl->setVar('network',$this->network($server_config['ip_address'],$server_config['netmask']));
 				
-				$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
+				$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf['server_id']) . ' order by ip_address');
 				$ip_records = array();
 				$additionl_ip_records = 0;
 				$n = 0;
@@ -106,15 +106,15 @@
 						/*
 						 * don't insert the main-ip again!
 						 */
-						if ($rec['ip_address'] != $server_config["ip_address"])
+						if ($rec['ip_address'] != $server_config['ip_address'])
 						{
 							$ip_records[$n] = array(
 								'id' => $n,
 								'ip_address' => $rec['ip_address'],
-								'netmask' => $server_config["netmask"],
-								'gateway' => $server_config["gateway"],
-								'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"]),
-								'network' => $this->network($rec['ip_address'],$server_config["netmask"])
+								'netmask' => $server_config['netmask'],
+								'gateway' => $server_config['gateway'],
+								'broadcast' => $this->broadcast($rec['ip_address'],$server_config['netmask']),
+								'network' => $this->network($rec['ip_address'],$server_config['netmask'])
 							);
 							$additionl_ip_records = 1;
 							$n++;
@@ -131,23 +131,23 @@
 				 */
 				if ($additionl_ip_records != 0)
 				{
-					$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
-					$swap["netmask"] = $ip_records[$n-1]["netmask"];
-					$swap["gateway"] = $ip_records[$n-1]["gateway"];
+					$swap['ip_address'] = $ip_records[$n-1]['ip_address'];
+					$swap['netmask'] = $ip_records[$n-1]['netmask'];
+					$swap['gateway'] = $ip_records[$n-1]['gateway'];
 					
 					$ip_records[$n-1] = array(
 						'id' => $n-1,
 						'ip_address' => $server_config['ip_address'],
-						'netmask' => $server_config["netmask"],
-						'gateway' => $server_config["gateway"],
-						'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"]),
-						'network' => $this->network($server_config['ip_address'],$server_config["netmask"])
+						'netmask' => $server_config['netmask'],
+						'gateway' => $server_config['gateway'],
+						'broadcast' => $this->broadcast($server_config['ip_address'],$server_config['netmask']),
+						'network' => $this->network($server_config['ip_address'],$server_config['netmask'])
 					);
-					$network_tpl->setVar('ip_address',$swap["ip_address"]);
-					$network_tpl->setVar('netmask',$swap["netmask"]);
-					$network_tpl->setVar('gateway',$swap["gateway"]);
-					$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
-					$network_tpl->setVar('network',$this->network($swap["ip_address"],$swap["netmask"]));
+					$network_tpl->setVar('ip_address',$swap['ip_address']);
+					$network_tpl->setVar('netmask',$swap['netmask']);
+					$network_tpl->setVar('gateway',$swap['gateway']);
+					$network_tpl->setVar('broadcast',$this->broadcast($swap['ip_address'],$swap['netmask']));
+					$network_tpl->setVar('network',$this->network($swap['ip_address'],$swap['netmask']));
 				}
 				
 				$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
@@ -155,7 +155,7 @@
 				file_put_contents('/etc/network/interfaces',$network_tpl->grab());
 				unset($network_tpl);
 				
-				$app->log("Changed Network settings",LOGLEVEL_DEBUG);
+				$app->log('Changed Network settings',LOGLEVEL_DEBUG);
 				exec($conf['init_scripts'] . '/' . 'networking force-reload');
 			} 
 			elseif (is_file('/etc/gentoo-release')) 
@@ -165,14 +165,14 @@
 				$app->load('tpl');
 				
 				$network_tpl = new tpl();
-				$network_tpl->newTemplate("gentoo_network_interfaces.master");
+				$network_tpl->newTemplate('gentoo_network_interfaces.master');
 				
-				$network_tpl->setVar('ip_address',$server_config["ip_address"]);
-				$network_tpl->setVar('netmask',$server_config["netmask"]);
-				$network_tpl->setVar('gateway',$server_config["gateway"]);
-				$network_tpl->setVar('broadcast',$this->broadcast($server_config["ip_address"],$server_config["netmask"]));
+				$network_tpl->setVar('ip_address',$server_config['ip_address']);
+				$network_tpl->setVar('netmask',$server_config['netmask']);
+				$network_tpl->setVar('gateway',$server_config['gateway']);
+				$network_tpl->setVar('broadcast',$this->broadcast($server_config['ip_address'],$server_config['netmask']));
 				
-				$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf["server_id"]) . " order by ip_address");
+				$records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf['server_id']) . " order by ip_address");
 				$ip_records = array();
 				$additionl_ip_records = 0;
 				$n = 0;
@@ -181,14 +181,14 @@
 						/*
 						 * don't insert the main-ip again!
 						 */
-						if ($rec['ip_address'] != $server_config["ip_address"])
+						if ($rec['ip_address'] != $server_config['ip_address'])
 						{
 							$ip_records[$n] = array(
 								'id' => $n,
 								'ip_address' => $rec['ip_address'],
-								'netmask' => $server_config["netmask"],
-								'gateway' => $server_config["gateway"],
-								'broadcast' => $this->broadcast($rec['ip_address'],$server_config["netmask"])
+								'netmask' => $server_config['netmask'],
+								'gateway' => $server_config['gateway'],
+								'broadcast' => $this->broadcast($rec['ip_address'],$server_config['netmask'])
 							);
 							$additionl_ip_records = 1;
 							$n++;
@@ -205,21 +205,21 @@
 				 */
 				if ($additionl_ip_records != 0)
 				{
-					$swap["ip_address"] = $ip_records[$n-1]["ip_address"];
-					$swap["netmask"] = $ip_records[$n-1]["netmask"];
-					$swap["gateway"] = $ip_records[$n-1]["gateway"];
+					$swap['ip_address'] = $ip_records[$n-1]['ip_address'];
+					$swap['netmask'] = $ip_records[$n-1]['netmask'];
+					$swap['gateway'] = $ip_records[$n-1]['gateway'];
 					
 					$ip_records[$n-1] = array(
 						'id' => $n-1,
 						'ip_address' => $server_config['ip_address'],
-						'netmask' => $server_config["netmask"],
-						'gateway' => $server_config["gateway"],
-						'broadcast' => $this->broadcast($server_config['ip_address'],$server_config["netmask"])
+						'netmask' => $server_config['netmask'],
+						'gateway' => $server_config['gateway'],
+						'broadcast' => $this->broadcast($server_config['ip_address'],$server_config['netmask'])
 					);
-					$network_tpl->setVar('ip_address',$swap["ip_address"]);
-					$network_tpl->setVar('netmask',$swap["netmask"]);
-					$network_tpl->setVar('gateway',$swap["gateway"]);
-					$network_tpl->setVar('broadcast',$this->broadcast($swap["ip_address"],$swap["netmask"]));
+					$network_tpl->setVar('ip_address',$swap['ip_address']);
+					$network_tpl->setVar('netmask',$swap['netmask']);
+					$network_tpl->setVar('gateway',$swap['gateway']);
+					$network_tpl->setVar('broadcast',$this->broadcast($swap['ip_address'],$swap['netmask']));
 				}
 				
 				$network_tpl->setVar('additionl_ip_records',$additionl_ip_records);
@@ -227,59 +227,59 @@
 				file_put_contents('/etc/conf.d/net',$network_tpl->grab());
 				unset($network_tpl);
 				
-				$app->log("Changed Network settings",LOGLEVEL_DEBUG);
+				$app->log('Changed Network settings',LOGLEVEL_DEBUG);
 				exec($conf['init_scripts'] . '/' . 'net.eth0 restart');
 			} 
 			else {
-				$app->log("Network configuration not available for this Linux distribution.",LOGLEVEL_DEBUG);
+				$app->log('Network configuration not available for this Linux distribution.',LOGLEVEL_DEBUG);
 			}
 			
 		} else {
-			$app->log("Network configuration disabled in server settings.",LOGLEVEL_WARN);
+			$app->log('Network configuration disabled in server settings.',LOGLEVEL_WARN);
 		}
 		
 	}
 	
 	function network($ip, $netmask){
 		$netmask = $this->netmask($netmask);
-		list($f1,$f2,$f3,$f4) = explode(".", $netmask);
-		$netmask_bin = str_pad(decbin($f1),8,"0",STR_PAD_LEFT).str_pad(decbin($f2),8,"0",STR_PAD_LEFT).str_pad(decbin($f3),8,"0",STR_PAD_LEFT).str_pad(decbin($f4),8,"0",STR_PAD_LEFT);
-		list($f1,$f2,$f3,$f4) = explode(".", $ip);
-		$ip_bin = str_pad(decbin($f1),8,"0",STR_PAD_LEFT).str_pad(decbin($f2),8,"0",STR_PAD_LEFT).str_pad(decbin($f3),8,"0",STR_PAD_LEFT).str_pad(decbin($f4),8,"0",STR_PAD_LEFT);
+		list($f1,$f2,$f3,$f4) = explode('.', $netmask);
+		$netmask_bin = str_pad(decbin($f1),8,'0',STR_PAD_LEFT).str_pad(decbin($f2),8,'0',STR_PAD_LEFT).str_pad(decbin($f3),8,'0',STR_PAD_LEFT).str_pad(decbin($f4),8,'0',STR_PAD_LEFT);
+		list($f1,$f2,$f3,$f4) = explode('.', $ip);
+		$ip_bin = str_pad(decbin($f1),8,'0',STR_PAD_LEFT).str_pad(decbin($f2),8,'0',STR_PAD_LEFT).str_pad(decbin($f3),8,'0',STR_PAD_LEFT).str_pad(decbin($f4),8,'0',STR_PAD_LEFT);
 		for($i=0;$i<32;$i++){
 			$network_bin .= substr($netmask_bin,$i,1) * substr($ip_bin,$i,1);
 		}
-		$network_bin = wordwrap($network_bin, 8, ".", 1);
-		list($f1,$f2,$f3,$f4) = explode(".", trim($network_bin));
-		return bindec($f1).".".bindec($f2).".".bindec($f3).".".bindec($f4);
+		$network_bin = wordwrap($network_bin, 8, '.', 1);
+		list($f1,$f2,$f3,$f4) = explode('.', trim($network_bin));
+		return bindec($f1).'.'.bindec($f2).'.'.bindec($f3).'.'.bindec($f4);
 	}
 
 	function broadcast($ip, $netmask){
 		$netmask = $this->netmask($netmask);
 		$binary_netmask = $this->binary_netmask($netmask);
-		list($f1,$f2,$f3,$f4) = explode(".", $ip);
-		$ip_bin = str_pad(decbin($f1),8,"0",STR_PAD_LEFT).str_pad(decbin($f2),8,"0",STR_PAD_LEFT).str_pad(decbin($f3),8,"0",STR_PAD_LEFT).str_pad(decbin($f4),8,"0",STR_PAD_LEFT);
-		$broadcast_bin = str_pad(substr($ip_bin, 0, $binary_netmask),32,"1",STR_PAD_RIGHT);
-		$broadcast_bin = wordwrap($broadcast_bin, 8, ".", 1);
-		list($f1,$f2,$f3,$f4) = explode(".", trim($broadcast_bin));
-		return bindec($f1).".".bindec($f2).".".bindec($f3).".".bindec($f4);
+		list($f1,$f2,$f3,$f4) = explode('.', $ip);
+		$ip_bin = str_pad(decbin($f1),8,'0',STR_PAD_LEFT).str_pad(decbin($f2),8,'0',STR_PAD_LEFT).str_pad(decbin($f3),8,'0',STR_PAD_LEFT).str_pad(decbin($f4),8,'0',STR_PAD_LEFT);
+		$broadcast_bin = str_pad(substr($ip_bin, 0, $binary_netmask),32,'1',STR_PAD_RIGHT);
+		$broadcast_bin = wordwrap($broadcast_bin, 8, '.', 1);
+		list($f1,$f2,$f3,$f4) = explode('.', trim($broadcast_bin));
+		return bindec($f1).'.'.bindec($f2).'.'.bindec($f3).'.'.bindec($f4);
 	}
 	
 	function netmask($netmask){
-		list($f1,$f2,$f3,$f4) = explode(".", trim($netmask));
-		$bin = str_pad(decbin($f1),8,"0",STR_PAD_LEFT).str_pad(decbin($f2),8,"0",STR_PAD_LEFT).str_pad(decbin($f3),8,"0",STR_PAD_LEFT).str_pad(decbin($f4),8,"0",STR_PAD_LEFT);
-		$parts = explode("0", $bin);
-		$bin = str_pad($parts[0], 32, "0", STR_PAD_RIGHT);
-		$bin = wordwrap($bin, 8, ".", 1);
-		list($f1,$f2,$f3,$f4) = explode(".", trim($bin));
-		return bindec($f1).".".bindec($f2).".".bindec($f3).".".bindec($f4);
+		list($f1,$f2,$f3,$f4) = explode('.', trim($netmask));
+		$bin = str_pad(decbin($f1),8,'0',STR_PAD_LEFT).str_pad(decbin($f2),8,'0',STR_PAD_LEFT).str_pad(decbin($f3),8,'0',STR_PAD_LEFT).str_pad(decbin($f4),8,'0',STR_PAD_LEFT);
+		$parts = explode('0', $bin);
+		$bin = str_pad($parts[0], 32, '0', STR_PAD_RIGHT);
+		$bin = wordwrap($bin, 8, '.', 1);
+		list($f1,$f2,$f3,$f4) = explode('.', trim($bin));
+		return bindec($f1).'.'.bindec($f2).'.'.bindec($f3).'.'.bindec($f4);
 	}
 
 	function binary_netmask($netmask){
-		list($f1,$f2,$f3,$f4) = explode(".", trim($netmask));
-		$bin = str_pad(decbin($f1),8,"0",STR_PAD_LEFT).str_pad(decbin($f2),8,"0",STR_PAD_LEFT).str_pad(decbin($f3),8,"0",STR_PAD_LEFT).str_pad(decbin($f4),8,"0",STR_PAD_LEFT);
-		$parts = explode("0", $bin);
-		return substr_count($parts[0], "1");
+		list($f1,$f2,$f3,$f4) = explode('.', trim($netmask));
+		$bin = str_pad(decbin($f1),8,'0',STR_PAD_LEFT).str_pad(decbin($f2),8,'0',STR_PAD_LEFT).str_pad(decbin($f3),8,'0',STR_PAD_LEFT).str_pad(decbin($f4),8,'0',STR_PAD_LEFT);
+		$parts = explode('0', $bin);
+		return substr_count($parts[0], '1');
 	}
 
 } // end class

--
Gitblit v1.9.1